JSONDecodeError

nikunjchauhan58
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "1.live_code.py", line 68, in
df5 = bt_lib.get_dataframes(name=name,rsi_timeperiod=rsi_timeperiod)
File "C:\Users\Administrator\Desktop\02 Live_Algo_old\01 Subhashish sir_Modify_Strategy_Profitable\bt_lib.py", line 10, in get_dataframes
df5 = kt.historical_data_days(names = name, interval = '5minute', day = 10,exchange = 'NSE')
File "C:\Users\Administrator\Desktop\02 Live_Algo_old\01 Subhashish sir_Modify_Strategy_Profitable\kite_trade.py", line 235, in historical_data_days
get_historical_data = kite.historical_data(instrument_token, from_datetime, to_datetime, interval, continuous=False, oi=False)
File "C:\Users\Administrator\Desktop\02 Live_Algo_old\01 Subhashish sir_Modify_Strategy_Profitable\kite_trade.py", line 108, in historical_data
lst = self.session.get(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am getting error again and again while call historical data request ??
Tagged:
  • sujith
    Can you run with debug logs enabled and paste the complete stacktrace here?

    PS: Make sure to remove client and app specific tokens.
  • nikunjchauhan58
    give me sample code
  • nikunjchauhan58
    ''''''''''
    name1 = exchange + ":" +names
    instrument_token=kite.ltp(name1)[name1]['instrument_token']
    from_datetime = datetime.datetime.now() - datetime.timedelta(days=day) # From last & days
    to_datetime = datetime.datetime.now()
    interval = interval
    get_historical_data = kite.historical_data(instrument_token, from_datetime, to_datetime, interval, continuous=False, oi=False)
    ''''''''''''
    I Give him a stock list with a for loop. While the loop is running, some time error pops up. I am also using sleep time, but still some time error stops my loop.
  • rakeshr
    requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    Historical data response seems to be empty. Can you paste here the complete debug logs?
  • nikunjchauhan58
    After I apply, try and except it works properly.
This discussion has been closed.