@rohitva We don't have individual APIs to fetch the option chain for any contract.You can loop through all the required contract/strike , fetch its OI value and form the option chain at your end.
@rakeshr I tried with all the 2740 calls and puts for Nifty. PCR Ialculated from it was way too wrong from actuals. But all the derivative instruments are not listed I believe, for instance instrument tokens for those CE/PE contacts expiring on 2nd Jan, 9th Jan, etc are not available
@saahiil No, there is no direct API for fetching all Nifty 50 call/put option contracts. You can do something as explained below to create an option chain at your end of any given contract. 1> Write a method that fetches all trading option contracts for the required instrument. Eg:
#Fetch complete instrument dump #Filter required exchange,segment and tradingsymbol of the required instrument #This should give all trading contracts for the required instrument, #store those contracts in list or dictionary to later fetch oi and #other value from Quote call/Websocket Streaming.
2> Write a method that fetches oi, volume, LTP,%change, etc for all those filtered contracts collected in 1st method using Quote APIs/Websocket streaming and keep appending them in nested dictionary/other data structure as per expiry month or other value as per your need. Something as below. Eg. {'20MAY' : {NFO:NIFTY20MAY8900PE {''oi': 251550,'volume': 907200,...}, {'NFO:NIFTY20MAY8950CE':{'oi': 1732875,'volume': 15337800,...},...} {'20JUNE' : {NFO:NIFTY20JUN8900PE {''oi': 171525,'volume': 227400,..},..}
You can use the above month-wise option contract nested dictionary for your option chain.
@rakeshr Thanks. This looks promising. But, Is it safe to give away API secret and token? Since option chain is not specific to account, may be this looks like an overhead.
Is it safe to give away API secret and token? Since option chain is not specific to account, may be this looks like an overhead.
Didn't get you? It's an open package specifically installed in your system, no one logs anything. Also, you can always clone this and modify it as per your requirement. It's just a wrapper over kiteconnect WebSocket streaming.
We don't have individual APIs to fetch the option chain for any contract.You can loop through all the required contract/strike , fetch its OI value and form the option chain at your end.
If yes, can you please assist how to get it ?
No, there is no direct API for fetching all Nifty 50 call/put option contracts.
You can do something as explained below to create an option chain at your end of any given contract.
1> Write a method that fetches all trading option contracts for the required instrument.
Eg: 2> Write a method that fetches oi, volume, LTP,%change, etc for all those filtered contracts collected in 1st method using Quote APIs/Websocket streaming and keep appending them in nested dictionary/other data structure as per expiry month or other value as per your need. Something as below. Eg.
{'20MAY' : {NFO:NIFTY20MAY8900PE {''oi': 251550,'volume': 907200,...},
{'NFO:NIFTY20MAY8950CE':{'oi': 1732875,'volume': 15337800,...},...}
{'20JUNE' : {NFO:NIFTY20JUN8900PE {''oi': 171525,'volume': 227400,..},..}
You can use the above month-wise option contract nested dictionary for your option chain.
Thanks. This looks promising.
But,
Is it safe to give away API secret and token? Since option chain is not specific to account, may be this looks like an overhead.
It's an open package specifically installed in your system, no one logs anything. Also, you can always clone this and modify it as per your requirement. It's just a wrapper over kiteconnect WebSocket streaming.