在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:areed1192/td-ameritrade-python-api开源软件地址:https://github.com/areed1192/td-ameritrade-python-api开源编程语言:Python 99.5%开源软件介绍:UPDATEThis repo will soon be updated to include the new https://github.com/areed1192/td-ameritrade-api library. The master branch will be overwritten and the old code will need to be updated to reflect the new changes. If you would like to start rewriting your old code, please refer to the new branch merge-new-repo or go the link above. Unofficial TD Ameritrade Python API LibraryTable of Contents
OverviewCurrent Version: 0.3.5 The unofficial Python API client library for TD Ameritrade allows individuals with TD Ameritrade accounts to manage trades, pull historical and real-time data, manage their accounts, create and modify orders all using the Python programming language. To learn more about the TD Ameritrade API, please refer to the official documentation. What's in the API
RequirementsThe following requirements must be met to use this API:
API Key and CredentialsEach TD Ameritrade API request requires a TD Ameritrade Developer API Key, a consumer ID, an account password, an account number, and a redirect URI. API Keys, consumer IDs, and redirect URIs are generated from the TD Ameritrade developer portal. To set up and create your TD Ameritrade developer account, please refer to the official documentation. Additionally, to authenticate yourself using this library, you will need to provide your account number and password for your main TD Ameritrade account. Important: Your account number, an account password, consumer ID, and API key should be kept secret. InstallationThe project can be found at PyPI, if you'd like to view the project please use this link. pip install td-ameritrade-python-api To upgrade the library run the following command: pip install --upgrade td-ameritrade-python-api UsageThis example demonstrates how to login to the API and demonstrates sending a request
using the Credentials:
Please note, that the # Import the client
from td.client import TDClient
# Create a new session, credentials path is required.
TDSession = TDClient(
client_id='<CLIENT_ID>',
redirect_uri='<REDIRECT_URI>',
credentials_path='<PATH_TO_CREDENTIALS_FILE>'
)
# Login to the session
TDSession.login()
# Grab real-time quotes for 'MSFT' (Microsoft)
msft_quotes = TDSession.get_quotes(instruments=['MSFT'])
# Grab real-time quotes for 'AMZN' (Amazon) and 'SQ' (Square)
multiple_quotes = TDSession.get_quotes(instruments=['AMZN','SQ']) FeaturesAuthentication Workflow SupportAutomatically will handle the authentication workflow for new users, returning users, and users with expired tokens (refresh token or access token). Request ValidationFor certain requests, in a limited fashion, it will help validate your request when possible.
For example, when using the Customized Objects for Watchlists, Orders, and Option ChainsRequests for saved orders, regular orders, watchlists, and option chains can be a challenging process that has multiple opportunities to make mistakes. This library has built-in objects that will allow you to quickly build your request and then validate certain portions of your request when possible. Library RequirementsThe following requirements must be met before being able to use the TD Ameritrade Python API library.
Documentation and ResourcesOfficial API DocumentationUnofficial DocumentationSupport these ProjectsPatreon: Help support this project and future projects by donating to my Patreon Page. I'm always looking to add more content for individuals like yourself, unfortuantely some of the APIs I would require me to pay monthly fees. YouTube: If you'd like to watch more of my content, feel free to visit my YouTube channel Sigma Coding. Hire Me: If you have a project, you think I can help you with feel free to reach out at [email protected] or fill out the contract request form Authentication WorkflowStep 1 - Start the Script: While in Visual Studio Code, right click anywhere in the code editor while in the file that contains your code. The following dropdown will appear: From the dropdown, click Step 2 - Go to Redirect URL: The TD Library will automatically generate the redirect URL that will navigate you to the TD website for for
you authentication. You can either copy the link and paste it into a browser manually or if you're using Visual
Studio Code you can press Step 3 - Login to the TD API: Once you've arrived at the login screen, you'll need to provide your credentials to authenticate the session. Please provide your Account Username and Account Password in the userform and then press enter. As a reminder these, are the same username/password combination you use to login to your regular TD Account. Step 4 - Accept the Terms: Accept the Terms of the API by clicking Step 5 - Copy the Authorization Code: After accepting the terms, you'll be taken to the URL that you provided as your Step 6 - Paste the Authorization Code in the Terminal: Take the URL and copy it into the Terminal, after you have pasted it, press After, that the script should run. Additionally, if you go to the location you specified in the |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论