kite.orders() error

Aakash369
Hi,
I am getting below mentioned errors when i call kite.orders() functions to retrieve orderbook.

Traceback (most recent call last):
File "C:\python\lib\site-packages\urllib3\connection.py", line 160, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "C:\python\lib\site-packages\urllib3\util\connection.py", line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "C:\python\lib\socket.py", line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\python\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen
chunked=chunked)
File "C:\python\lib\site-packages\urllib3\connectionpool.py", line 344, in _make_request
self._validate_conn(conn)
File "C:\python\lib\site-packages\urllib3\connectionpool.py", line 843, in _validate_conn
conn.connect()
File "C:\python\lib\site-packages\urllib3\connection.py", line 316, in connect
conn = self._new_conn()
File "C:\python\lib\site-packages\urllib3\connection.py", line 169, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 11002] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\python\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\python\lib\site-packages\urllib3\connectionpool.py", line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\python\lib\site-packages\urllib3\util\retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /orders (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "orderbook.py", line 16, in
ko=kite.orders()
File "C:\python\lib\site-packages\kiteconnect-3.7.7-py3.7.egg\kiteconnect\connect.py", line 379, in orders
File "C:\python\lib\site-packages\kiteconnect-3.7.7-py3.7.egg\kiteconnect\connect.py", line 697, in _get
File "C:\python\lib\site-packages\kiteconnect-3.7.7-py3.7.egg\kiteconnect\connect.py", line 745, in _request
File "C:\python\lib\site-packages\kiteconnect-3.7.7-py3.7.egg\kiteconnect\connect.py", line 742, in _request
File "C:\python\lib\site-packages\requests\api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "C:\python\lib\site-packages\requests\sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "C:\python\lib\site-packages\requests\sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "C:\python\lib\site-packages\requests\adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /orders (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))

Also, from the exception log it could be seen that most of these errors are raised between 12:00 Noon to 3:00 PM from past 3 days(market open days).

My algo places BO depending on test condition and may exit order based on its own RMS if SL is not reached. So, I need to access orderbook to know which SL is still not triggered.

It is not my internet specific error as ticks could be received for that period.

Is there any specific reason why OMS is down in these hours? Any other way to access orderbook when such error occur?
  • sujith
    Post midnight OMS runs a BOD process and hence it is not available for the use.
  • Aakash369
    Hi Sujith,
    I have mentioned 12:00 Noon to 3:00 PM i.e. market hours
  • rakeshr
    @Aakash369
    Does this ConnectionError happens for all the order book fetch requests made between specified time or only few requests are failing?
    In case of ConnectionError, you can handle the exception at your end and retry the same request again.
  • Aakash369
    Yesterday, it occurred for 8 of 13 orderbook fetch requests starting around 12:45 PM. I understand that I need to handle ConnectionError exception at my end and retry. And thats what the algo does. It retries four times before proceeding to next section of code.

    Below is the results from one such attempt (update_order() is a function that is trying to access order book) :

    2019-11-27 12:45:11.489378 exception error raised in update order HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /orders (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
    2019-11-27 12:45:11.489378 recalling function

    2019-11-27 12:45:23.875384 exception error raised in update order HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /orders (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
    2019-11-27 12:45:23.875384 recalling function

    2019-11-27 12:45:29.456803 exception error raised in update order HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /orders (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))
    2019-11-27 12:45:29.456803 recalling function

    2019-11-27 12:45:41.840117 exception error raised in update order HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /orders (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
    2019-11-27 12:45:41.840117 recalling function

    As you can see in the timestamp, this error is persistent.

    Can zerodha cross-check status of OMS at the above timestamps? I have also mailed other time stamps for the day to [email protected]

    I am also not sure why there is a time gap between these re-tries. Ideally, the algo should retry at internals of 0.35 sec just like it did on 26-11-2019 as shown below:

    2019-11-26 13:29:59.924001 exception error raised in update order
    2019-11-26 13:29:59.924001 recalling update function
    2019-11-26 13:30:00.293755 exception error raised in update order
    2019-11-26 13:30:00.293755 recalling update function
    2019-11-26 13:30:00.654896 exception error raised in update order
    2019-11-26 13:30:00.654896 recalling update function
    2019-11-26 13:30:01.008921 exception error raised in update order
    2019-11-26 13:30:01.008921 recalling update function
  • sujith
    Can you switch to some other ISP and give it a try?
    We haven't observed any issues like this and 8 requests failing out of 13 requests is a huge drop rate.
    If we had an issue like this then it would be chaotic.
  • RishiS
    I get these too, don't worry, if you have an exception handling system to retry the call, it'll most likely work. Most likely just normal network inefficiencies
  • Aakash369
    Hi, Sujith. I understand your point.
    But if the algo can receive ticks for the particular time when error is raised, can it still be an ISP issue?

    I am on a 100 MB/s broadband connection with a ping of 7msec most of the time.

    I have attached two files:
    1) ticks received for yesterday. It shows that internet worked when the error was raised.
    2) Log file for yesterday

    It would be great help if you could go through these and let me know what could be the possible root cause.
Sign In or Register to comment.