# tdameritrade
Python interface to TD Ameritrade Api
[![Build Status](https://github.com/timkpaine/tdameritrade/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/timkpaine/tdameritrade/actions?query=workflow%3A%22Build+Status%22)
[![Coverage](https://codecov.io/gh/timkpaine/tdameritrade/branch/main/graph/badge.svg)](https://codecov.io/gh/timkpaine/tdameritrade)
[![License](https://img.shields.io/github/license/timkpaine/tdameritrade.svg)](https://pypi.python.org/pypi/tdameritrade/)
[![PyPI](https://img.shields.io/pypi/v/tdameritrade.svg)](https://pypi.python.org/pypi/tdameritrade/)
## Getting Started
### Install
Install from pip
`pip install tdameritrade`
or from source
`python setup.py install`
### Docs
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\test_client.py 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.
![](https://raw.githubusercontent.com/timkpaine/tdameritrade/main/docs/img/client/client.png)
Most data fetching methods accept the symbol as argument. For equities, this is just the ticker.
![](https://raw.githubusercontent.com/timkpaine/tdameritrade/main/docs/img/client/quote.png)
For different assets, utilize the `search` and `instrument` methods to lookup symbols. For options, you can utilize the options method.
![](https://raw.githubusercontent.com/timkpaine/tdameritrade/main/docs/img/options.png)
Raw data
{
"_id": null,
"home_page": "https://github.com/timkpaine/tdameritrade",
"name": "tdameritrade",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "finance data",
"author": "Tim Paine",
"author_email": "t.paine154@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/fb/c1/56a790c36e702e555a90b9b8ec237c0aca4d9ee79199af4de93c6c0268a0/tdameritrade-0.2.1.tar.gz",
"platform": null,
"description": "# tdameritrade\nPython interface to TD Ameritrade Api\n\n[![Build Status](https://github.com/timkpaine/tdameritrade/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/timkpaine/tdameritrade/actions?query=workflow%3A%22Build+Status%22)\n[![Coverage](https://codecov.io/gh/timkpaine/tdameritrade/branch/main/graph/badge.svg)](https://codecov.io/gh/timkpaine/tdameritrade)\n[![License](https://img.shields.io/github/license/timkpaine/tdameritrade.svg)](https://pypi.python.org/pypi/tdameritrade/)\n[![PyPI](https://img.shields.io/pypi/v/tdameritrade.svg)](https://pypi.python.org/pypi/tdameritrade/)\n\n\n\n## Getting Started\n\n### Install\nInstall from pip\n\n`pip install tdameritrade`\n\nor from source\n\n`python setup.py install`\n\n\n### Docs\nMajor changes in the v0.1.0 update to the way tokens are handled. \nYou will still need the original authentication instructions, but the TDClient now takes the refresh token and client\nid, not the access token. A new session class handles token expiration and will automatically call a new token as\nneeded. \n\nIt is recommended that you store these as environmental variables. \n\n```\nclient_id = os.getenv('TDAMERITRADE_CLIENT_ID')\naccount_id = os.getenv('TDAMERITRADE_ACCOUNT_ID')\nrefresh_token = os.getenv('TDAMERITRADE_REFRESH_TOKEN')\n\ntdclient = tdameritrade.TDClient(client_id=client_id, refresh_token=refresh_token, account_ids=[account_id])\n``` \n\nSee the tests\\test_client.py file for examples on current usage. \n\nAll 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.\n\n![](https://raw.githubusercontent.com/timkpaine/tdameritrade/main/docs/img/client/client.png)\n\nMost data fetching methods accept the symbol as argument. For equities, this is just the ticker.\n\n![](https://raw.githubusercontent.com/timkpaine/tdameritrade/main/docs/img/client/quote.png)\n\nFor different assets, utilize the `search` and `instrument` methods to lookup symbols. For options, you can utilize the options method.\n\n![](https://raw.githubusercontent.com/timkpaine/tdameritrade/main/docs/img/options.png)\n\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "APIs for TD Ameritrade",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/timkpaine/tdameritrade"
},
"split_keywords": [
"finance",
"data"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5d1455def97725823a4e01ea2c64ce330e4bf92dffb212c3ced70d2abf248c30",
"md5": "bf16540ebbec52034499f2e2ce20a7c0",
"sha256": "2c51f3887634b617810bc9908d0b7bd70ff6d7b17a2efe6d270d509c9d99c528"
},
"downloads": -1,
"filename": "tdameritrade-0.2.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "bf16540ebbec52034499f2e2ce20a7c0",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 28472,
"upload_time": "2023-06-15T18:42:10",
"upload_time_iso_8601": "2023-06-15T18:42:10.155925Z",
"url": "https://files.pythonhosted.org/packages/5d/14/55def97725823a4e01ea2c64ce330e4bf92dffb212c3ced70d2abf248c30/tdameritrade-0.2.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fbc156a790c36e702e555a90b9b8ec237c0aca4d9ee79199af4de93c6c0268a0",
"md5": "99aabae59ff7fc21d7c4c948781ec232",
"sha256": "7ef13cf4bbef50633df3d5e3f263bc6a4a301e4b2ff3397077927a9fae0c709a"
},
"downloads": -1,
"filename": "tdameritrade-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "99aabae59ff7fc21d7c4c948781ec232",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 28497,
"upload_time": "2023-06-15T18:42:11",
"upload_time_iso_8601": "2023-06-15T18:42:11.422551Z",
"url": "https://files.pythonhosted.org/packages/fb/c1/56a790c36e702e555a90b9b8ec237c0aca4d9ee79199af4de93c6c0268a0/tdameritrade-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-15 18:42:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "timkpaine",
"github_project": "tdameritrade",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tdameritrade"
}