RDP IPA FX Volatility
I am trying to plot fx vol surf using the file I found on Git Hub in below link.
https://github.com/Refinitiv-API-Samples/Article.RDPLibrary.Python.VolatilitySurfaces_Curves
File name "Vol Surfaces Webinar.ipynb". It worked for ETI option but for FX Volatility Surface, it returned error. Vol Surfaces Webinar.zip
--------------------------------------------------------
fx_surfaces = fx_response.data.raw['data']
plot_surface(fx_surfaces, 'FxVol-USDSGD', True)
--------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-23-1b085c0e4326> in <module>
1 fx_surfaces = fx_response.data.raw['data']
----> 2 plot_surface(fx_surfaces, 'FxVol-USDSGD', True)
<ipython-input-5-0e89ac2f0bf9> in plot_surface(surfaces, surfaceTag, delta_plot)
26 # When plotting FX Delta rather than Strike
27 # I'm converting the x axis value from Delta to Put Delta
---> 28 delta_axis = list(map(convert_delta, strike_axis))
29 x = np.array(delta_axis, dtype=float)
30 else:
<ipython-input-5-10b94499ab72> in convert_delta(delta)
1 def convert_delta(delta):
----> 2 if (delta<0):
3 return -delta
4 elif (delta>0):
5 return 1-delta
TypeError: '<' not supported between instances of 'str' and 'int'
Best Answer
-
The problem seems to be that for FX, the strike_axis values now contain an at the money text value:
[-0.1, -0.15, -0.2, -0.25, -0.3, -0.35, -0.4, -0.45, 'ATM', 0.45, 0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1]
So, it would appear there has been a change to the Vol Surfaces response since when I presented the Webinar and the notebooks.
I am not 100% sure but I think the following should fix this:
def convert_delta(delta):
if (delta=='ATM'):
return 0.5
elif (delta<0):
return -delta
elif (delta>0):
return 1-delta
else:
return 0.5I have asked the IPA team to confirm if the above is correct and if there could be other text values I need to consider.
I will update the notebook on Github once they have confirmed the corrections.
0
Answers
-
The IPA team advised a different solution, they suggested I change the original request to something like:
"universe": [
{
"underlyingType": "Fx",
"surfaceTag": "FxVol-USDSGD",
"underlyingDefinition": {
"fxCrossCode": "USDSGD"
},
"surfaceLayout": {
"format": "Matrix",
"yValues": [ "-0.1","-0.15","-0.2","-0.25","-0.3","-0.35","-0.4","-0.45","0.5","0.45","0.4","0.35","0.3","0.25","0.2","0.15","0.1"]
},
"surfaceParameters": {
"xAxis": "Date",
"yAxis": "Delta",
"calculationDate": "2018-08-20T00:00:00Z",
"returnAtm": "False",
}
}
]The changes above would avoid having to change the convert_delta() function.
I am holding off updating the Github file for now - as there is another issue in the notebook I have spotted (not related to the above Vol Surface)
0 -
@umer.nalla Thank you very much! It worked!
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛