Skip to main content

APIs for TD Ameritrade

Project description


Python interface to TD Ameritrade Api

Build Status Coverage License PyPI

Getting Started


Install from pip

pip install tdameritrade

or from source

python install


Major changes in the v0.1.0 update to the way tokens are handled.
You will still need the original authentication instructions, but the TDClient now takes the refresh token and client id, not the access token. A new session class handles token expiration and will automatically call a new token as needed.

It is recommended that you store these as environmental variables.

client_id = os.getenv('TDAMERITRADE_CLIENT_ID')
account_id = os.getenv('TDAMERITRADE_ACCOUNT_ID')
refresh_token = os.getenv('TDAMERITRADE_REFRESH_TOKEN')

tdclient = tdameritrade.TDClient(client_id=client_id, refresh_token=refresh_token, account_ids=[account_id])

See the tests\ file for examples on current usage.

All functionality is available as methods on the TDClient object. For most methods, there is a convenience method to return the result as a pandas DataFrame.

Most data fetching methods accept the symbol as argument. For equities, this is just the ticker.

For different assets, utilize the search and instrument methods to lookup symbols. For options, you can utilize the options method.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tdameritrade-0.2.1.tar.gz (28.5 kB view hashes)

Uploaded source

Built Distribution

tdameritrade-0.2.1-py2.py3-none-any.whl (28.5 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page