api.kite.trade Read Timeout

darsh
darsh edited May 2018 in Python client
After upgrading to kiteConnect 3. i am facing issues regarding order placement.
first,I used API: "kite.place_order (tradingsymbol= "SUBEX",quantity=1,exchange="NSE",transaction_type="SELL",order_type="MARKET",product="MIS")

But i faced error reading "Variety"

Then after i used API :kite.place_order (variety="regular",tradingsymbol= "SUBEX",quantity=1,exchange="NSE",transaction_type="SELL",order_type="MARKET",product="MIS")
Then order is placed but then after program is terminated due to error regarding "Access Token

Then again i regenerated access token and run program.This time instead of 1 quantity of SUBEX ,API placed 3 quantity of SUBEX and among then one is "CNC" order and others are "MIS".

This is totally weird and boring. I think there is bug in API or system or i do not know in your server.

Please make a note that when i used previous version of kite connect,faced error regarding the "An internal server error occurred",due to that my program was terminated.then after "suggestion of upgrading the kite version is made" and i followed.

I have been trying to run my program for couple of weeks,but i can not run that program flawlessly so far.

Please resolve this issues seriously, 2000 per month is really considerable amount.


  • sujith
    There is no issue with pykiteconnect. It is tested and is working fine. You can enable debug logs and check what is happening.
  • darsh
    if everything is fine from kite connect,then how can you logically justify below things.

    code runs fine and precisely for while.(it implies that no error in coding and syntax)

    code gives desire out put for while.(it implies that no logical blunder)

    then after, suddenly code gives strange output such as program only ask to place order of one quantity at a time(and make a note that same code followed the command for while) but program place order of more than one quantity,program placed order CNC instead of MIS
    (it definitely implies that some problem is occurred from server)
  • tonystark
    Can you write logging.basicConfig(level=logging.DEBUG) at the beginning of your code? Give us the log generated when the issue happens. We will investigate.
  • darsh
    okay i will do that ,and when i encounter that error
  • darsh
    now i faced another error:
    SSLError: HTTPSConnectionPool(host='api.kite.trade', port=443): Max retries exceeded with url: /portfolio/positions (Caused by SSLError(SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')",),
  • darsh
    darsh edited February 2018
    now again i faced error (this is different then previous one)

    Debug .......
    "DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /quote/ltp?i=2867969 HTTP/1.1" 200 86"

    error :
    ReadTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)


  • darsh
    again faced error

    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "GET /portfolio/positions HTTP/1.1" 500 102

    error :
    GeneralException: Error fetching API session.

    you can see my problem....i can not run the program for even 1 hours and sometimes i get lucky then i can run for more than one hour.

    i have to frequently check my PC ..although i am approaching algo-trading
  • sujith
    @darsh,
    Do you see this error(Error fetching API session) in other API calls? How often do you make this API call?
  • darsh
    darsh edited February 2018
    @sujith @Kailash @vivek @nithin @ i am using time delay in my program, so that number of request per second will be optimal.
    Apart from that as per my knowledge if there is problem with "too many requests in server",then Logically program should be terminated every time,when i hit the run button.

    please make a note that "program runs fine for while (sometimes 30 to 40 minutes,sometimes 10 to 15 minutes).Then program is terminated showing above mentioned error.How can you justify this thing. it is totally weird.

    please consider all error mentioned above ,and pay attention that that all error came for exact same coding,not a single word was changed.But those errors came at different times. that is totally illogical

    that is why i am concern about server or API or system
  • sujith
    sujith edited February 2018
    @darsh,
    We will look into this. But polling positions is a bad idea, you can use websockets to get order updates and fetch positions only when there is order update.
    Quote call: ReadTimeout: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
    We don't have 7 seconds timeout. I think this is timeout at your end, can you increase this and check?
    Can you also mention for how many instruments you are requesting here?
  • nandas21
    Hi, I am also facing a similar issue. Hence posting in this discussion. What could be wrong here. I am actually using the software written by some one else. So I don't have the code. Please let me know what other details you would need.

    INFO:root:Connection to Zerodha failed: HTTPSConnectionPool(host='api.kite.trade', port=443): Read timed out. (read timeout=7)
    Email sent!
    INFO:werkzeug:127.0.0.1 - - [14/May/2018 19:09:10] "GET /trade HTTP/1.1" 200 -
    ----------------------------------------
    Exception happened during processing of request from ('127.0.0.1', 53766)
    Traceback (most recent call last):
    File "SocketServer.py", line 290, in _handle_request_noblock
    File "SocketServer.py", line 318, in process_request
    File "SocketServer.py", line 331, in finish_request
    File "SocketServer.py", line 654, in __init__
    File "SocketServer.py", line 713, in finish
    File "socket.py", line 283, in close
    File "socket.py", line 307, in flush
    error: [Errno 10053] An established connection was aborted by the software in your host machine
    ----------------------------------------
  • sujith
    This is a pykiteconnect timeout, more like a client-side timeout. Can you try on some other network?
  • sujith
    You can follow up here.
This discussion has been closed.