Even though i have subscribed to historical data getting exception "kiteconnect.exceptions.TokenException: Incorrect `api_key` or `access_token`." while downloading historical data
Can you enabled debug logs of pykiteconnect and share the complete stacktrace of that? Please do share on private message. It looks like you are not passing a valid api_key or access_token.
Traceback (most recent call last): File "D:\PythonProjects\AngelBrokerImpl\algo_trading_app\broker\main.py", line 24, in main symbol_data = historial_data.download_historical_data(symbol) File "D:\PythonProjects\AngelBrokerImpl\algo_trading_app\broker\angel\HistoricalData.py", line 12, in download_historical_data return self.kite.historical_data(symbol.instrument_token, date_after_days(TODAY_DATE_TIME, days=days), File "D:\PythonProjects\AngelBrokerImpl\.venv\lib\site-packages\kiteconnect\connect.py", line 632, in historical_data data = self._get("market.historical", File "D:\PythonProjects\AngelBrokerImpl\.venv\lib\site-packages\kiteconnect\connect.py", line 861, in _get return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json) File "D:\PythonProjects\AngelBrokerImpl\.venv\lib\site-packages\kiteconnect\connect.py", line 937, in _request raise exp(data["message"], code=r.status_code) kiteconnect.exceptions.TokenException: Incorrect `api_key` or `access_token`.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "D:\PythonProjects\AngelBrokerImpl\algo_trading_app\broker\main.py", line 34, in main() File "D:\PythonProjects\AngelBrokerImpl\algo_trading_app\broker\main.py", line 27, in main print(e.with_traceback()) TypeError: BaseException.with_traceback() takes exactly one argument (0 given)
Traceback (most recent call last):
File "D:\PythonProjects\AngelBrokerImpl\algo_trading_app\broker\main.py", line 24, in main
symbol_data = historial_data.download_historical_data(symbol)
File "D:\PythonProjects\AngelBrokerImpl\algo_trading_app\broker\angel\HistoricalData.py", line 12, in download_historical_data
return self.kite.historical_data(symbol.instrument_token, date_after_days(TODAY_DATE_TIME, days=days),
File "D:\PythonProjects\AngelBrokerImpl\.venv\lib\site-packages\kiteconnect\connect.py", line 632, in historical_data
data = self._get("market.historical",
File "D:\PythonProjects\AngelBrokerImpl\.venv\lib\site-packages\kiteconnect\connect.py", line 861, in _get
return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
File "D:\PythonProjects\AngelBrokerImpl\.venv\lib\site-packages\kiteconnect\connect.py", line 937, in _request
raise exp(data["message"], code=r.status_code)
kiteconnect.exceptions.TokenException: Incorrect `api_key` or `access_token`.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\PythonProjects\AngelBrokerImpl\algo_trading_app\broker\main.py", line 34, in
main()
File "D:\PythonProjects\AngelBrokerImpl\algo_trading_app\broker\main.py", line 27, in main
print(e.with_traceback())
TypeError: BaseException.with_traceback() takes exactly one argument (0 given)
Make sure to private message the stacktrace as it will contain app and client specific tokens.
DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /instruments/historical/112391431/minute?from=2025-01-29+14%3A55%3A44&to=2025-01-31+14%3A55%3A44&interval=minute&continuous=0&oi=1 HTTP/1.1" 403 None
\PythonProjects\AngelBrokerImpl\.venv\Scripts\python.exe \PythonProjects\AngelBrokerImpl\algo_trading_app\broker\angel\DataStream.py
ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
ERROR:kiteconnect.ticker:Connection closed: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))