error in gethistoricaldata 877057 Invalid `api_key` or `access_token`.

pritish1708
pritish1708 edited August 2020 in Python client
def gethistoricaldata(token):
kite = get_kite_client()
enddate = datetime.datetime.today()
startdate = datetime.datetime(enddate.year, enddate.month, enddate.day,9,30)
df = pd.DataFrame(columns=['date', 'open', 'high', 'low', 'close', 'volume'])
try:
data = kite.historical_data(token, startdate, enddate, interval='15minute')
df = pd.DataFrame.from_dict(data, orient='columns', dtype=None)
if not df.empty:
df = df[['date', 'open', 'high', 'low', 'close', 'volume']]
df['date'] = df['date'].astype(str).str[:-6]
df['date'] = pd.to_datetime(df['date'])
df = df.iloc[-2]
except Exception as e:
print(" error in gethistoricaldata", token, e)
return df

@app.route("/lebc", methods=['POST'])
def algo():
kite = get_kite_client()
try:
data = kite.historical_data(877057 , startdate, enddate, interval='15minute')
Sign In or Register to comment.