Skip to content

TD Ameritrade Request Limit Details

hmanfarmer edited this page Sep 6, 2020 · 14 revisions

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:

  1. Calculate the time difference between the most recent request n and 120th request prior n-120, if the difference time(n) - time(n-120) is less than 1 minute, throw an error.
  2. Maintain a running requests counter, if that counter exceeds 120 requests, throw an error. Reset the counter every 1 minute.
  3. 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

Notes related to rate limiting

  • 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)

Links