For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 0

How to get multiple instrument/field rights in get_data() [Python]

I am trying to get open interest and implied volatility for a few options as a time series, but it seems like I can only access OI&IV through get_data instead of time_series.


instruments = ['TKMB700K1', 'TKMB800W1']

df_, _ = ek.get_data(
instruments = [instrument],
fields = [f'TR.OPENINTEREST(Frq=D,SDate=2019-01-01,EDate=2021-01-01).Timestamp',
f'TR.OPENINTEREST(Frq=D,SDate=2019-01-01,EDate=2021-01-01).Value']
)

It works if I get the data for each instrument separately, but it doesn't give the right dataframe back if I send a list of different instruments.

I also tried to add [f'TR.IMPLIEDVOLATILITY(Frq=D,SDate=2019-01-01,EDate=2021-01-01).Timestamp',
f'TR.IMPLIEDVOLATILITY(Frq=D,SDate=2019-01-01,EDate=2021-01-01).Value'] into the field list and again that doesn't work.


I am very new to this API and would like to have some guidance in terms of how to proceed with this. Thanks!

eikonrefinitiv-dataplatform-eikonpython
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
6.7k 8 6 7

@bgner So the code below does work - i could not find the instruments you tried - are they valid RICs? I tried this for the crude oil future and it returns open interest (obviously IV is only for options so it returns nothing for a future). There is no need to add parameters to each field - you can add them once at the end to apply to all fields.

instruments = ['CLc1','CLc2']
fields = ['TR.OPENINTEREST.timestamp','TR.OPENINTEREST','TR.IMPLIEDVOLATILITY']

df, err = ek.get_data(instruments,fields,
                      parameters={'SDate':'2019-01-01',
                                  'EDate':'2021-01-01',
                                  'Frq':'D'})

df

1634314494207.png

I hope this can help.


1634314494207.png (143.8 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea