Instrument_key not found from complete instrument csv files

Hi Team,

I am trying to fetch instrument_key of NIFTY for this expiry date “2025-06-26”.
Not able to found the key.
I am using this url- https://assets.upstox.com/market-quote/instruments/exchange/complete.csv.gz

Could you please help here.

Thanks
Rahul

Hi @Anand_Sajankar

Could you please check?

Thanks
Rahul

Hi @rahul, Could you please help with the specific instrument key that you are looking for, I can see the NIFTY instruments for 2025-06-26

Also, we recommend using the JSON file instead as CSV file will be deprecated in near future.

For more information, please refer to this link: Instruments | Upstox Developer API

Additionally, kindly refer to the note provided on the page.

Thanks

Hi @Anand_Sajankar

I got the same intrument keys but problem is it will give the NIFTY2562625250CE
like this. am i right?

if i am trying to fetch for expiry 2025-07-03 the symble is coming like
‘NIFTY2570325050CE’, ‘NIFTY2570325250CE’, ‘NIFTY2570325150CE’, ‘NIFTY2570325100PE’, ‘NIFTY2570325150PE’

so for 2025-06-26 expiry date why it is not coming like this?

Thanks
Rahul

Hi @rahul, It depends on the monthly or weekly symbol. It’s highly recommend to use Instrument JSON files

Hope this clears things up. Thank you!

1 Like

sirjee kya apna mail id nai de sakte jahan mein code bhej ke usko thik karwa sakoon

Hi @Anand_Sajankar

Here is my code for getting the weekly options of NIFTY from json data.
But here weekly date 2025-06-26 is missing in json data.
you can my code and check data. this weekly date 2025-06-26 is not
there.

Could you please check again from your end?

def load_upstox_data():
    #file_url = 'https://assets.upstox.com/market-quote/instruments/exchange/complete.json.gz'
    file_url = 'https://assets.upstox.com/market-quote/instruments/exchange/NSE.json.gz'
    # Read the full JSON array
    df = pd.read_json(file_url)
    # Convert expiry (milliseconds) to datetime.date
    df['expiry'] = pd.to_datetime(df['expiry'], unit='ms', errors='coerce').dt.date
    return df


def index_getInstrumetKey(SYMBOL):
    symboldf = load_upstox_data()
    print("Total rows in dataset:", len(symboldf))
#     print("Instrument types:", symboldf['instrument_type'].unique())
#     print("segment types:", symboldf['segment'].unique())
    # Apply filter
    optDf = symboldf[
        (symboldf['weekly'] == True) &
        (symboldf['trading_symbol'].str.startswith(SYMBOL)) &
        (symboldf['segment'] == 'NSE_FO')
    ]
    print("Filtered NSE_FO rows for", SYMBOL, ":", len(optDf))
    # Expiry logic
    expiryList = sorted(optDf['expiry'].dropna().unique())
    print("Expiries:", expiryList)
    finalDf = optDf[optDf['expiry'].isin(expiryList)]
    return finalDf

SYMBOL = 'NIFTY'  
df=index_getInstrumetKey(SYMBOL)

Thanks
Rahul

Hi @rahul, The date you’re referring to corresponds to a monthly expiry, not a weekly one.

1 Like