API limits are only for API users doing automated trading. Manual traders are less likely to face this issue; but if they do, then they need to report it to support.
There are two main reasons for putting in rate limits:
- A bad code written by users causing API functions to be invoked continuously in a loop
- A malicious user trying DOS attacks
As an API user, you need to understand that this is the most important feature for You as well. An API breach is almost all the time caused by a bug in the user’s strategy code. API limits help you safeguard yourself. We have seen users suffering heavy losses as their rogue code continuously fired orders; when they used APIs which do not have such limits.Admin
If your system breaks any of below mentioned limits, then you will receive a server error 429 Too Many Requests.
This applies at the user level, so requests for all accounts are considered.
- A maximum of 200 requests per 5 seconds interval
- A maximum of 600 requests per 1 minute interval
- A maximum of 1800 requests per 5 minutes interval
Pseudo/Trading Account Level
This applies at the pseudo/trading account level, so requests for a single pseudo/trading account are considered.
- A maximum of 60 requests per 5 seconds interval
- A maximum of 120 requests per 1 minute interval
- A maximum of 300 requests per 5 minutes interval
How limits are calculated?
Every API request made to AutoTrader Server is counted as 1 unit. The common requests are:
- Place Order
- Modify Order
- Cancel Order
- Read Positions
- Read Orders
- Read Margins
The desktop client is designed to sync live Portfolio to your computer. It runs a sync operation every 15-20 seconds. Sync interval can be configured in settings. The desktop client might increase this interval if the user has more accounts. This is due to the fact that each sync operation results in 3 requests being made for each live account (to fetch orders, positions & margins).
Guidelines for staying within API limits
- First of all, you can see that the limits are set to a decent value, so if your code is breaking the limits then make sure that it is not doing something that is wrong or redundant
- Only keep those pseudo accounts live, which you are using in your trading strategy
- If you are using desktop client
- If you are doing random testing, then close the desktop client. This will make sure, your requests do not reach AutoTrader server.
- Set portfolio sync to OFF (if your strategy does not read live portfolio data)
- Increase the portfolio sync interval (Example: 30 or 40 seconds)
- The client has internal handling to avoid hitting the limits. So unless you have too many live accounts, the client should take care of it.
- If you are directly accessing the API (without the desktop client)
- You can cache the portfolio in your strategy and refresh it periodically or only when needed
- If your strategy generates too many orders in a short period of time, then add some delay in your code to avoid hitting the limits
Breach of limit
Users need to understand that this is a very serious issue. Not only because it puts load on our servers and affects other clients; but if a broker’s RMS (Risk Management System) has bugs then this would result in too many orders reaching exchange which may in rare cases result in far bigger issues.
Whenever API limits are breached, you will receive an email. You need to respond to that mail explaining what caused the breach and actions taken to avoid such occurrence in the future.
Whenever a breach happens, the system will automatically disable the user account in few hours. If a user keeps repeatedly breaching the limits or fails to cooperate with the support team, his/her access will be permanently revoked.Admin