#AttributeError: 'NoneType' object has no attribute
sriayyan opened this issue · 1 comments
Hi Friend,
We are beginners to Python and Flask. We are tiring to execute your code. We are facing some technical problems. Please help us to resolve it.
Please refer to the error.
2020-12-22 20:40:55: * Detected change in 'C:\xampp\htdocs\flask-intro\sdoosa-algo-trade-python-master\src\zerodha.py', reloading
2020-12-22 20:40:55: * Restarting with stat
2020-12-22 20:40:58: serverConfig => {'port': 5000, 'enableSSL': False, 'sslPort': 8443}
2020-12-22 20:40:58: userConfig => {'clientID': 'MG4332', 'apiKey': 'hcdi8tyn1i01dnqe', 'apiSecret': 'nmkabafrwt7zylg5a0q9ehyi4gkaj6s8', 'redirectUrl': 'http://localhost:5000/apis/broker/login/zerodha'}
2020-12-22 20:40:58: * Debugger is active!
2020-12-22 20:40:58: * Debugger PIN: 120-108-093
2020-12-22 20:40:58: * Running on http://localhost:5000/ (Press CTRL+C to quit)
2020-12-22 20:41:06: 127.0.0.1 - - [22/Dec/2020 20:41:06] "←[37mGET /?algoStarted=true HTTP/1.1←[0m" 200 -
2020-12-22 20:41:35: 127.0.0.1 - - [22/Dec/2020 20:41:35] "←[37mGET /?algoStarted=true HTTP/1.1←[0m" 200 -
2020-12-22 20:41:53: Algo started...
2020-12-22 20:41:53: Going to fetch instruments...
2020-12-22 20:41:53: Sending redirect url http://127.0.0.1:5000?algoStarted=true in response
2020-12-22 20:41:53: 127.0.0.1 - - [22/Dec/2020 20:41:53] "←[37mPOST /apis/algo/start HTTP/1.1←[0m" 200 -
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Program Files\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\xampp\htdocs\flask-intro\sdoosa-algo-trade-python-master\src\algo.py", line 15, in startAlgo
fetchInstruments(kite)
File "C:\xampp\htdocs\flask-intro\sdoosa-algo-trade-python-master\src\instruments.py", line 17, in fetchInstruments
instrumentsList = kite.instruments('NSE')
AttributeError: 'NoneType' object has no attribute 'instruments'
2020-12-22 20:41:53: 127.0.0.1 - - [22/Dec/2020 20:41:53] "←[37mGET /?algoStarted=true HTTP/1.1←[0m" 200 -
Friend,
At some time, we are also facing the errors below.
C:\xampp\htdocs\flask-intro\sdoosa-algo-trade-python-master\src>python main.py
2020-12-22 20:50:24: serverConfig => {'port': 5000, 'enableSSL': False, 'sslPort': 8443}
2020-12-22 20:50:24: userConfig => {'clientID': 'MG4332', 'apiKey': 'hcdi8tyn1i01dnqe', 'apiSecret': 'nmkabafrwt7zylg5a0q9ehyi4gkaj6s8', 'redirectUrl': 'http://localhost:5000/apis/broker/login/zerodha'}
- Serving Flask app "main" (lazy loading)
- Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead. - Debug mode: on
2020-12-22 20:50:24: * Restarting with stat
2020-12-22 20:50:26: serverConfig => {'port': 5000, 'enableSSL': False, 'sslPort': 8443}
2020-12-22 20:50:26: userConfig => {'clientID': 'MG4332', 'apiKey': 'hcdi8tyn1i01dnqe', 'apiSecret': 'nmkabafrwt7zylg5a0q9ehyi4gkaj6s8', 'redirectUrl': 'http://localhost:5000/apis/broker/login/zerodha'}
2020-12-22 20:50:26: * Debugger is active!
2020-12-22 20:50:26: * Debugger PIN: 120-108-093
2020-12-22 20:50:27: * Running on http://localhost:5000/ (Press CTRL+C to quit)
2020-12-22 20:50:42: 127.0.0.1 - - [22/Dec/2020 20:50:42] "←[37mGET / HTTP/1.1←[0m" 200 -
2020-12-22 20:50:43: Redirecting to zerodha login url = https://kite.trade/connect/login?api_key=hcdi8tyn1i01dnqe&v=3
2020-12-22 20:50:43: 127.0.0.1 - - [22/Dec/2020 20:50:43] "←[32mGET /apis/broker/login/zerodha HTTP/1.1←[0m" 302 -
2020-12-22 20:50:57: 127.0.0.1 - - [22/Dec/2020 20:50:57] "←[37mGET /?loggedIn=true&request_token=32WrafjyP9d9eqJMgbssuQaXOTeB8o55&action=login&status=success HTTP/1.1←[0m" 200 -
2020-12-22 20:51:02: Algo started...
2020-12-22 20:51:02: Going to fetch instruments...
2020-12-22 20:51:02: Sending redirect url http://127.0.0.1:5000?algoStarted=true in response
2020-12-22 20:51:02: 127.0.0.1 - - [22/Dec/2020 20:51:02] "←[37mPOST /apis/algo/start HTTP/1.1←[0m" 200 -
2020-12-22 20:51:02: 127.0.0.1 - - [22/Dec/2020 20:51:02] "←[37mGET /?algoStarted=true HTTP/1.1←[0m" 200 -
2020-12-22 20:51:03: Fetching instruments done. Instruments count = 3391
Exception in thread Thread-6:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Program Files\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "C:\xampp\htdocs\flask-intro\sdoosa-algo-trade-python-master\src\algo.py", line 17, in startAlgo
testOrders()
File "C:\xampp\htdocs\flask-intro\sdoosa-algo-trade-python-master\src\algo.py", line 47, in testOrders
lastTradedPrice = getCMP(exchange + ':' + tradingSymbol)
File "C:\xampp\htdocs\flask-intro\sdoosa-algo-trade-python-master\src\quotes.py", line 5, in getCMP
quote = kite.quote(tradingSymbol)
File "C:\Users\OMSAI\AppData\Roaming\Python\Python36\site-packages\kiteconnect\connect.py", line 566, in quote
data = self._get("market.quote", {"i": ins})
File "C:\Users\OMSAI\AppData\Roaming\Python\Python36\site-packages\kiteconnect\connect.py", line 817, in _get
return self._request(route, "GET", params)
File "C:\Users\OMSAI\AppData\Roaming\Python\Python36\site-packages\kiteconnect\connect.py", line 886, in _request
raise exp(data["message"], code=r.status_code)
kiteconnect.exceptions.InputException: Invalidapi_key
oraccess_token
.