volatility surface
Hi,
I am trying to get this function to work in eikon but I was not able to make it work. Could you advice how to retrieve this?
Eikon excel:
TR("SAN.MC","TR.SurfVolMoneyness","CH:Range RH:Tenor Range:50;150 Tenor:1M;10M VolType:MID",,)
Python:
case 1:
case 2:
Best Answer
-
@daniel.fernandez1@refinitiv.com
Here's an alternative syntax to the one provided by @nick.zincone, which is probably more suitable for your use case.df, err = ek.get_data("SAN.MC",["TR.SurfVolMoneyness.tenor","TR.SurfVolMoneyness.range","TR.SurfVolMoneyness"],{"Range":"50;150", "Tenor":"1M;10M", "VolType":"MID"})
The caveat here is that Eikon Python library does not provide capability to control what labels are returned as column and row headers the way =TR Excel worksheet function does. get_data method ignores RH and CH parameters. This is why you need to include in the field list TR.SurfVolMoneyness.tenor and TR.SurfVolMoneyness.range.
And then if you'd like to format the resulting table the same way the table returned by =TR function is formatted, you need to do a bit of manipulation with the dataframe returned by get_data method.
First remove the Instrument column.df = df.drop('Instrument', axis=1)
Then reshape or pivot the table using tenor as row headers and moneyness range as column headers.
df = df.pivot(index='Tenor', columns='Range', values='Moneyness')
Finally you'll notice that index labels are ordered lexicographically, which means that "10M" comes before "1M" and "100%" comes before "50%". To produce the same table as the one returned by =TR function we need to reindex the dataframe. To reorder the rows you can use
df = df.iloc[df.index.str.extract('(\d+)', expand=False).astype(int).argsort()]
and to reorder the columns use
df = df.reindex(columns = df.columns[df.columns.str.extract('(\d+)', expand=False).astype(int).argsort()])
Now the dataframe fully conforms to the table returned by =TR function. This said, unless the objective is to display the data as a table, all this dataframe manipulation is probably quite unnecessary. If you are looking to do some calcs based on the values retrieved, the values can be easily accessed from the dataframe returned by get_data method without any reshaping and reindexing.
0
Answers
-
Hi @daniel.fernandez1@refinitiv.com,
When formulating syntax, the DIB - Data Item Browser within Eikon can be extremely useful. For example, pulling up the details above within DIB, click on Parameters
You can pull out the specification detailed within the bottom right corner and paste this into you field specific, i.e.
df, err = tr.get_data("IBM.N",
["TR.SurfVolMONEYNESS(Tenor=1M:10M,Range=50:100,VolType=Mid)"])0 -
Great feedback, than you both for all the information it was very useful!
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 687 Datastream
- 1.4K DSS
- 621 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 4 Trading API
- 2.9K Elektron
- 1.4K EMA
- 254 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 276 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 669 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 229 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛