Too many Requests Error in Kite API

MW5790
I have a Javascript program that looks up price for 15 scripts and executes trades based on LTP.
It was running just fine for 3 months until this morning (07-Sep-2020) when I suddenly encounter this error -- Too many requests

I am not sure why any rate limit didnt get triggered in past 3 months and only now is reflecting
I have raised support ticket as well. can you please suggest some remedy urgently as my trading has come to a halt.
Tagged:
  • sujith
    It seems like you have exceeded the rate limits. You can check out the rate limits here.
  • MW5790
    Sujith

    the rate limits are per second and everyday. How can i exceed them only one fine day when I have never exceeded them for 3 months so far ?

    The only suspect is that I poll LTP for 18 scripts in a while loop continuously. based on LTP matching Entry, Stop Loss and Target conditions, i place orders.

    I have placed only one order today.
    Now if I can;t even do that then what's the solution ?

    Its the most basic automation. requesting your help. how do i know if i am exceeding the rate limit ?

    I was blocked the whole day today and i guess now i am refactoring code for a backup to zerodha.
    Its been a good experience so far but this is simply a showstopper.
  • sujith
    I am not sure what is wrong. We can see more than 10 requests per second at our end. Kite Connect APIs are limited at 10 read requests per second.
  • MW5790
    i even tested with a 1 sec delay between request. is there a way for you to check if some rogue user got my access token ? by the IP address. right now i have just one IP address running code . Does even call to getpositions or getholdings consume a request ?
  • MW5790
    Also what is the long term recommendation for algo execution. is there some way to never get into these issues ? For example, i cannot run a Stop loss or target execution every 5 minutes. that is self defeating. how to do closer to real time without hitting your limits ? Specifically READ LIMITS. assuming we are hardly placing 10 orders maximum per day
  • sujith
    Every request is counted. You will have to find ways to optimize your algorithm to stick within the rate limits or you may have to use another Kite Connect app.
    Kite Connect is purely an execution platform. We don't provide suggestions or solutions to write strategies.
  • MW5790
    no strategy recommendation how do u go about protecting your stop loss if you have restrictions on rate limit. is there a broadcast feed of Kite that I can tap ? so that i dont consume calls ?
  • sujith
    You can use WebSockets API for getting live market data.
  • MW5790
    In Websockets , how will things change ? wouldn't the rate limits apply to socket calls also ?
  • MW5790
    so in my code if i have one statement like kiteconnect.getholdings immediately followed by kc.getPositions, its likely to exceed 1 request per Sec. strangely only today have i Seen this error ? and I ensure i ran only one thread
  • MW5790
    If I have to getpositions and getholdings, etc, how do I use websockets ? is there documentation on lower level actions for those calls ?
  • rakeshr
    @MW5790
    In Websockets, how will things change ? wouldn't the rate limits apply to socket calls also?
    No, the rate limit won't apply on Websocket as you don't make an API call(unlike rest other API calls(positions holdings, etc) here but listen to Websocket Server. Go through this documentation to know about Websocket Streaming.
    so in my code if i have one statement like kiteconnect.getholdings immediately followed by kc.getPositions, its likely to exceed 1 request per Sec
    Why do you need to keep polling Holdings or Positions every second, as these values won't change with every tick?
    So, what you can do is fetch Holdings/Positions once, store them at your end and use the same for further computation at your end.

    Also, we will recommend you to perform as much possible fixed computation at your end, using Websocket Streaming data as this will reduce your dependency on polling data-heavy API calls(like holdings, positions).
  • MW5790
    There is just one problem with above recommendations. while websocket can reduce dependency on API calls, for closing your existing position, the cleanest way is to check as frequently as possible the holdings and positions. So even with websocket, for each tick, you have to cross check whether some new position has not hit Stop loss or Target. because new positions can be created anytime during the trading hours.
    the only way to circumvent this polling, is to store positions and holdings information locally and updated say every 1 minute.

    I am curious how internally within zerodha u manage to close Stop loss orders ? without checking on every tick
  • sujith
    You need to use postbacks or order updates via websocket for the same and not poll APIs.
Sign In or Register to comment.