Proper queries for options on futures using Python and Eikon API

Good afternoon,
I try to request Eikon API from python to find EUA options open interest relative to strike prices.
I want to get open interest for all strike prices of a contract, for example Dec24 (CFI2Z4).
Please find below my code. I think the code i am using for options is wrong : 0#GCFI2Z*.EX
Thank you for your support,
_____________________________________________________________________
import eikon as ek
ek.set_app_key('My_key')
fields = [ek.TR_Field('TR.RIC'), ek.TR_Field('STRIKE_PRC'), ek.TR_Field('TR.PUTCALLIND'), ek.TR_Field('TR.OPENINTEREST')]
EUA_options = ek.get_data("0#GCFI2Z*.EX", fields=fields)
print(EUA_options)
_____________________________________________________________________
Best Answer
-
Hi @Amine.Sabri ,
Is the RIC chain 0#GCFI2Z*.EX correct? I don't seem to find it in LSEG Workspace. Nevertheless I have replicated the process for 0#CL+. You can then replace this with another ric:
First we need to expand the chain using the following code:
options, err = ek.get_data("0#CL+", fields = 'X_RIC_NAME')
print(list(options['Instrument']))['0#CLF24+', '0#CLG24+', '0#CLH24+', '0#CLJ24+', '0#CLK24+', '0#CLM24+', '0#CLN24+', '0#CLQ24+', '0#CLU24+', '0#CLV24+', '0#CLX24+', '0#CLZ24+', '0#CLF25+', '0#CLG25+', '0#CLH25+', '0#CLJ25+', '0#CLK25+', '0#CLM25+', '0#CLN25+', '0#CLQ25+', '0#CLU25+', '0#CLV25+', '0#CLX25+', '0#CLZ25+', '0#CLF26+', '0#CLG26+', '0#CLH26+', '0#CLJ26+', '0#CLK26+', '0#CLM26+', '0#CLN26+', '0#CLQ26+', '0#CLU26+', '0#CLV26+', '0#CLX26+', '0#CLZ26+', '0#CLF27+', '0#CLG27+', '0#CLH27+', '0#CLJ27+', '0#CLK27+', '0#CLM27+', '0#CLN27+', '0#CLQ27+', '0#CLU27+', '0#CLV27+', '0#CLX27+', '0#CLZ27+', '0#CLF28+', '0#CLM28+', '0#CLZ28+', '0#CLM29+', '0#CLZ29+', '0#CLM30+', '0#CLZ30+', '0#CLM31+', '0#CLZ31+', '0#CLM32+', '0#CLZ32+', '0#CLM33+', '0#CLZ33+', '0#CLM34+', '0#CLZ34+']
This will return the monthly contract chains. Then you can expand those further to get contracts with specific strikes and get prices on those. E.g for '0#CLFG24+':
options_G, err = ek.get_data("0#CLG24+", fields = 'X_RIC_NAME
options_GFinally we can request the fields you are after:
rics = options_G['Instrument'].to_list()
df, err = ek.get_data(rics, fields = ['STRIKE_PRC', 'PUTCALLIND', 'TR.OPENINTEREST'])
dfIf you need help with identifying correct chain RICs you can post a content question via Helpdesk.
Hope this helps.
Best regards,
Haykaz
0
Answers
-
Thank you, that answer is relevant
0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 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
- 275 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
- 629 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
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 86 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛