Getting NFO dump for a particular expiry date

satheesh7134
Hi Everyone
The below line of code gives me the complete dump of all instruments traded under NFO

self.instrument_dump = self.kite.instruments("NFO")

But I don't want the entire dump, I just need the dump corresponding to particular expiry [for eg, 28.07.2022]

Please let me know how to achieve this

Thanks
Satheesh
  • SRIJAN
    There is a expiry column in the instruments dump.

    You can use that to filter instruments for any expiry.
  • satheesh7134
    Hi Srijan

    I tried this code,but its giving error

    self.instrument_dump = self.kite.instruments("NFO")['expiry'] = "28-07-2022"

    Please advise the correct way to do this
  • SRIJAN
    SRIJAN edited July 2022
    Convert the instruments dump into a pandas dataframe and then you can sort easily.
  • Imran
    @satheesh7134
    instrument = kite.instruments()
    instrument = pd.DataFrame(instrument)
    instrument['expiry'] = instrument['expiry'].astype(str)
    expiry_df = instrument[instrument['expiry'] == '2022-07-28']
  • satheesh7134
    @Imran

    Thanks. If I try to do this on the main code, it's taking lot of load, the execution is getting slowed
    So took all the dump into CSV file and retrieving from there
Sign In or Register to comment.