Option Chain Data using API

I see a difference in the option chain data in option chain api vs data from NSE website for NIFTY.

data = {

"symbol":"NSE:NIFTY50-INDEX",

"strikecount":"",

"timestamp": ""

}

response = fyers.optionchain(data=data);

options_data = response['data']['optionsChain']

columns = ['symbol', 'option_type','strike_price', 'ltp', 'oi', 'volume']

df = pd.DataFrame(options_data, columns=columns)

df

This will give me below list. Note the strike starts from 22900.

From NSE site :

It starts from 22400.

Why is it showing this difference ?

Hi @anoop.rnheogki
This is due to a limitation on the strike price count, capped at a maximum of 50. As a result, when you retrieve data through the option chain API, it begins from the 50th strike price.
For further information, please refer to our API documentation using the link provided below.
https://myapi.fyers.in/docsv3#tag/Data-Api/paths/~1DataApi/put

Hello @R3bVyTWVQG , Thanks. Is there any other to get all the strikes through API ?

Hi @anoop.rnheogki,

As @R3bVyTWVQG mentioned, it’s limited to 50 strikes, as traders typically don’t use strikes beyond that range, even for hedging.
Could you confirm the use case, how having more than 50 strike prices would be beneficial for a trader?

data = {“symbol”: “NSE:NIFTY50-INDEX”, “strikecount”: 5, “timestamp”: “”}

optRes = fyers.optionchain(data=data)

vix = optRes[“data”][“indiavixData”][“ltp”]

pcr = optRes[“data”][“callOi”] / optRes[“data”][“putOi”]

optdf = pd.DataFrame(optRes[“data”][“optionsChain”])

spotLtp = optdf[optdf.exchange == “NSE”][“ltp”].iloc[0]

optdf = optdf[optdf.option_type.isin([“CE”, “PE”])]

optdf = optdf.dropna(axis=1, how=“all”)

optdf[“Strike”] = optdf[“strike_price”]

del optdf[“strike_price”], optdf[“fyToken”]

cedf = optdf[optdf.option_type == “CE”]

pedf = optdf[optdf.option_type == “PE”]

ocdf = pd.merge(cedf, pedf, on=“Strike”, suffixes=[“_CE”, “_PE”])

ocdf = ocdf.sort_values(by=“Strike”)