API limits are only for API users doing automated trading. Manual traders are less likely to face this issue unless they are sending a lot of orders in bulk; 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
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.
The load from a single user’s badly written code can affect all of our clients if we do not keep API Rate Limits.
Whenever a breach happens, the system will automatically disable the user account. The user is expected to explain the cause as well as the fixes to avoid hitting API limits again. If a user keeps repeatedly breaching the limits or fails to cooperate with the support team, his/her access will be permanently revoked.Admin
Note: If your AutoTrader Web’s user is disabled, it does not mean you cannot trade in your account. You can always login to your stock broker’s trading terminal and operate your trading account.
API limits have been put in place to safeguard stock exchanges & their systems, stock brokers & their systems, our own systems as well as all market participants (traders & investors). Hence, we have a zero tolerance policy with users failing to cooperate in case of API limits breach.
Please note that it is a standard practice to have API rate limits in the industry. Unfortunately, not every user is aware of it. Hence, we have given below some links of similar limits imposed by top market participants.