Too Many "Gateway connection error" Errors

razcads
Hi,
Since a couple of days I am see many "Gateway connection error" messages when getting quotes especially next month quotes. This is got to a point that its just unacceptable.
Quote api is to - put it mildly - totally crappy. Using historic api to get current quote is not an option.
Please give a permanent solution where siple quopte requests even i in some 3 to 4 hours doesnt retrieve quotes consistently.
Any ideas?

Regards
Ravi
  • sujith
    @razcads,
    Can you let us know which version of pykiteconnect you are using?
  • razcads
    prev version of pytkite. Not v3
  • sujith
    Hi @razcads,
    The old quote call is provided by our OMS vendor TR. It is known to have random and intermittent issues lately. We would suggest using new Quote API calls. If it takes time for migration then you can write your custom request to api.kite.trade/quote. You can check out the documentation for more information about request and response.
  • razcads
    @sujith yes I created custom function as @tonystark had indicated. this works but it gives blank quotes and also errors out giving "Too many requests". What is the number of requests limit? Is it per minute? How many?
  • tonystark
    @razcads You can send multiple instruments to the URL instead of requesting separately. You will get rate limited otherwise. The rate is 1 request per second. And you can request up to 500 instruments in one request.
  • razcads
    @tonystark thanks. my requests are well within the limit than. I do only 1 request in 10 mins or so. But still i seem to be hitting this error where i just don't get a quote. I get a simple python error indicating the key data is not present.

    this is an excerpt from my code.
            header_token ='token '+ kite.api_key+ ":" + kite.access_token
    # use a comma separated list for instrument, or single as below
    instrument = exchange+':'+next_month_trading_symbol
    headers = {
    'X-Kite-Version': '3',
    'Authorization': header_token,
    }
    params = (('i', [instrument]),)
    response = requests.get('https://api.kite.trade/quote', headers=headers, params=params)
    next_month_quote = response.json()
    if (next_month_quote['data'][instrument]['depth']['sell'][0]['price'] == 0) or \
    (next_month_quote['data'][instrument]['depth']['buy'][0]['price'] ==0):
    pass
    else:
    print next_month_quote
    The above code works when i test it out. But then on deploying to Amazon AMI i get error key data not found which only means that quote was not returned . Have you seen this issue? Any clues?
  • razcads
    hi u can close this issue now. I am no closer to understanding what went wrong. but anyway will figure it out.
  • tonystark
    @razcads Did you try printing response.json() while running in AMI?
  • razcads
    @tonystark I finally did find it.. it so happened that my code was executing call to quote twice within 1 second and returning the error. Resolved now.

    Can you clarify if the one second limit is only for http quote response and not for python quote api right?
  • Vivek
    Vivek edited January 2018
    @razcads Rate limit is for Kite connect api's, since Python client is just a wrapper for it so rate limits are not applicable.
Sign In or Register to comment.