-
-
Notifications
You must be signed in to change notification settings - Fork 339
TD Ameritrade Request Limit Details
The Getting Started documentation on TD Ameritrade's developer website, under "Making Your First Request" states:
All private, non-commercial use apps are currently limited to 120 requests per minute on all APIs except for Accounts & Trading
After some testing from a few tda-api users. We have a few more specifics about this 120 requests per minute limit.
To understand the situation better, there are multiple ways TD Ameritrade (TDA) could implement the limit, for example:
- Calculate the time difference between the most recent request
n
and 120th request priorn-120
, if the differencetime(n) - time(n-120)
is less than 1 minute, throw an error. - Maintain a running requests counter, if that counter exceeds 120 requests, throw an error. Reset the counter every 1 minute.
- etc.
TDA chose to implement method #2. Our best guess, through testing, is that TDA maintains a server side clock that resets a requests counter every 60 seconds. Since the clock is server side and there is no known way to synchronize your local clock to TDA's clock (other than something overly complicated like a phase lock loop), you never really know when the clock will reset. This can lead to situations in which you can theoretically send up to 240 requests within 1 minute, but this rate improvement is only temporary, as you can not sustain an average rate of more than 120 requests per minute.
A simple and effective method for maximizing your request rate given TDA's limit is to repeat the request until you no longer receive the limit exceeded error. Be aware, that retrying an http request after receiving an error is such a common procedure that libraries exist to attempt the retries in an intelligent fashion, for an example see this requests library for http retrying: requests.urllib3.util.retry or this HTTP retry StackOverflow discussion.
Below is the error TDA returns when you exceed the limit:
Response status_code: '429' Response text: "error":"Individual App's transactions per seconds restriction reached. Please contact us with further questions"
NOTE: Not all of TDA's interface's endpoints implement the rate limiting as alluded to in the statement TDA made on their Getting Started web page.
on all APIs except for Accounts & Trading
-
Client.get_order(order_id, account_id)
(tested on 9/2/2020), No per minute rate limiting. - There is a maximum number of orders per month (rumor is the limit is 14790)