Gateway connection error: Historical API


Under what exception does Gateway connection error falls in python client?? Am getting this issue during histAPI calls.
  • sujith
    Hi @kiran,
    Can you let us know for which scrip and what are the params you were trying?
  • kiran
    @sujith: These are basic kite.historical calls for bunch of scripts at 5 min interval:
    The error is not constant for a script and is randomized.

    ex: kite.historical(3861249, '2017-06-20', '2017-06-21', "5minute")
    log info: 2017-06-21 11:15:19,471 CRITICAL: Exception found for ADANIPORTS, Token: 3861249: Gateway connection error
    2017-06-21 11:15:19,471 CRITICAL: Exception found for MCDOWELL-N, Token: 2674433: Gateway connection error

    Note: I use a thread pool of 4 for these calls, as there is an api liimit and i believe this gateway error is different from NetworkException which occurs when max limit of API calls were reached.
  • sujith
    Hi @kiran,
    I think you should give some delay and try.
    How often do you make API call?
  • kiran
    I make API call on start of every 5 min bar for around 10 stocks with thread pool of 4 (When one of the thread completes it makes the next API call). Thought i might get NetworkException when too many call were made and handled it accordingly. (made the thread sleep for a sec and then continue)

    Seems, Gateway connection error occurs when API calls were made above the threshold and not NetworkException. Can you let me know under what exceptions does [Gateway connection error] falls under, So that i can handle in my code accordingly??
  • sujith
    Hi @kiran,
    It is a database call, the request might be timing out before data is being fetched. I would suggest distributing your API calls, instead of triggering fetch after 5 min for 10 scrips, you can make it fetch for 5 scrips after 150 seconds. I am not sure, if it will fit your purpose but try not to bombard with requests at once.
    It is not only used by Kite Connect users but also Kite Charts which will have 35k+ concurrent users during market hours.

    One more alternative would be to use websockets to dump data at your end and make your own candle data.
Sign In or Register to comment.