Real Time Streaming Futures Price Data With TD Ameritrade API In Python
Description
Let's take a look at how to stream real time futures price data for exchange traded futures contracts using the TD Ameritrade API in Python.
0:37 open the documentation, futures product list, and TD ThinkOrSwim (links below!)
2:06 import modules 2:35 authenticate streaming client
3:07 create a queue class to store data from stream
3:43 overview of read_stream() function
4:04 defining a "handler" function to handle stream messages
4:18 adding a handler
4:34 subscribe to futures product stream
4:40 get futures contract name to use when subscribing to stream
5:53 add futures contract name to sub/unsubscribe functions
6:01 review unsubscribe function
6:18 subscribe to the data stream
6:39 unsubscribe from the data stream
6:50 inspect the data in the queue
There are a bit of specifics in choosing the futures contract name when streaming futures price data, so be sure to specify the exact contract name you are looking for. It's fairly straight forward to find the contract name using the CME products list and the search function in ThinkOrSwim.
The set up of the code is similar to the equity/option real time streaming with the TD Ameritrade API; however, in the body of the read_stream function, you just have to swap in StreamClient.level_one_futures_subs(...) and StreamClient.add_level_one_futures_handler(...)
Easy business, finance family. Here's all the code from the video
https://github.com/AdamGetbags/streamingQuotesTDA/blob/main/streamingFuturesQuotesTDA.py https://github.com/AdamGetbags/streamingQuotesTDA/blob/main/secretsTDA.py
TDA API Documentation
https://tda-api.readthedocs.io/en/latest/streaming.html
TD for Developers https://developer.tdameritrade.com/
CME Futures Product Slate https://www.cmegroup.com/markets/products.html
- - -
Follow the podcast and join our larger community on Youtube to receive value on all things finance and technology!
https://www.youtube.com/c/adamgetbags
If you love the content, buy me a coffee!
https://www.buymeacoffee.com/adamgetbags
Keep up with me!
https://www.instagram.com/damgetbags
https://twitter.com/damgetbags
- - -
Need some ideas for your project portfolio?
Check out how to get historical option price data in Python from the Polygon API.
https://youtu.be/87O9qxfMJ-g
Here's how to quickly get crypto data in Python from the CoinGecko API
Here's how to create a SQL database from a Pandas DataFrame in Python
- - -
DISCLAIMER: The Information on Async Finance is provided for education and informational purposes only, without any express or implied warranty of any kind, including warranties of accuracy, completeness, or fitness for any particular purpose. The Information contained in or provided from or through Async Finance is not intended to be and does not constitute financial advice, investment recommendations, investment advice, trading advice, or any other advice. The Information on Async Finance is general in nature and is not specific to you the User or anyone else. You should not make any decision, financial, investment, trading, or otherwise, based on any of The Information presented on Async Finance without undertaking independent due diligence and consultation with a professional broker or financial advisory.