Live option chain

rohitva
How to get the live (and historical) option chain data using the kiteconnect?
  • rakeshr
    @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.
  • sharathsankar
    @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
    @rakeshr Can we directly get Nifty 50 total number of call holders from API ?
    If yes, can you please assist how to get it ?
  • rakeshr
    @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
    Python users can try out this open python package to fetch the option chain for equity derivatives.
  • ronstrader
    ronstrader edited April 2021
    @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.
  • rakeshr
    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.
  • sahilajmeri1
    Hi @rakeshr, please guide me through your github repo. How to run your project in my local environment?
  • rakeshr
    You can visit the usage section of README.
This discussion has been closed.