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.fernandez
Here's an alternative syntax to the one provided by @nick.zincone.1, 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.
1
Answers
-
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)"])1 -
Great feedback, than you both for all the information it was very useful!
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 中文论坛