Code to get day candles and stock quote failing since today.

MAG
When I try to use the kite connect python api to get a stock quote it is failing with an invalid token exception. This was working fine till Friday and there have been no changes to the code from my end.
Below is the output. As you can see the authentication works fine.
But
1. Even for the day candle retrieved via historical call, I am not getting all one minute candles for the day.
2. Stock quote call is failing with invalid token exception.
GM:daytrade godwin.monis$ ./testquotes.py asianpaint
StockSymbol is ASIANPAINT
InstName is ASIANPAINT
InstToken is 60417
time,Thu Dec 22 09:26:15 IST 2016
['time', 'Thu Dec 22 09:26:15 IST 2016']
API_KEY,XXXXXXXX
['API_KEY', 'XXXXXXXXX']
REQUEST_TOKEN,XXXXXXXXXXXX
['REQUEST_TOKEN', 'XXXXXXXXXXXX']
ACCESS_TOKEN,XXXXXXX
['ACCESS_TOKEN', 'XXXXXX']
day candle start #Start prettyprint dictionary of day candle
[ { 'close': 919.05,
'date': '2017-01-09T09:15:00+0530',
'high': 933,
'low': 916.1,
'open': 932.8,
'volume': 392379}]
day candle end #End prettyprint dictionary of day candle
Traceback (most recent call last):
File "./bjstel.py", line 88, in
StockQuote=kite.quote('NSE', InstToken)
File "/usr/local/lib/python3.5/site-packages/kiteconnect/__init__.py", line 396, in quote
return self._get("market.quote", {"exchange": exchange, "tradingsymbol": tradingsymbol})
File "/usr/local/lib/python3.5/site-packages/kiteconnect/__init__.py", line 455, in _get
return self._request(route, "GET", params)
File "/usr/local/lib/python3.5/site-packages/kiteconnect/__init__.py", line 542, in _request
raise(exp(data["message"], code=r.status_code))
kiteconnect.exceptions.TokenException: Invalid token
Code that gets the Date candles:
#Get todays date
DateToday=datetime.datetime.today().strftime('%Y-%m-%d')
day1mincandles=kite.historical(InstToken, DateToday, DateToday, 'minute')
Code section that gets quote:

StockQuote=kite.quote('NSE', InstName)
*Where instname is stock symbol like 'ASIANPAINT'


  • Vivek
    Vivek edited January 2017
    @MAG Just now tested and it seems to be working. Looks like your access token is invalidated and you need to regenerate it.
Sign In or Register to comment.