I am using python kiteconnect module to fetch historical data for options of expiry 29th April despite giving To date: 2021/04/21 From date: 2021/04/27 i am able to fetch historical day for present day only please assist
//have already fetched instruments list and stored it in dataframe def instrumentLookup(instrument_df,symbol): """Looks up instrument token for a given script from instrument dump""" try: return instrument_df[instrument_df.tradingsymbol==symbol].instrument_token.values[0] except: return -1
// function which returns historical data taking interval and duration instrument lookup is used to fetch instrument id def fetchOHLC(ticker,interval,duration): """extracts historical data and outputs in the form of dataframe""" instrument = instrumentLookup(instrument_df,ticker) data = pd.DataFrame(kite.historical_data(instrument,dt.date.today()-dt.timedelta(duration), dt.date.today(),interval)) data.set_index("date",inplace=True) return data
def instrumentLookup(instrument_df,symbol):
"""Looks up instrument token for a given script from instrument dump"""
try:
return instrument_df[instrument_df.tradingsymbol==symbol].instrument_token.values[0]
except:
return -1
// function which returns historical data taking interval and duration instrument lookup is used to fetch instrument id
def fetchOHLC(ticker,interval,duration):
"""extracts historical data and outputs in the form of dataframe"""
instrument = instrumentLookup(instrument_df,ticker)
data = pd.DataFrame(kite.historical_data(instrument,dt.date.today()-dt.timedelta(duration),
dt.date.today(),interval))
data.set_index("date",inplace=True)
return data
fetchOHLC('NIFTY21APRIL14100PE','3minute',10)
Make sure to remove client and app specific tokens.