Conversation
For a long time this library was mostly sync, with the streamers being the exception. PR #168 added async endpoints on top of the existing endpoints, which gave users more flexibility. With this change, I propose that version 12+ be async-only. There are a few reasons for this. First of all, having both sync and async versions of everything resulted in a ton of code duplication (check out how many lines are removed in this commit!). Second, both streamers are (and always have been) async, meaning that almost all users are already implementing at least *some* async code, so having the separate sync versions makes less sense. Finally, this change allows us to support Trio and clean up the streamer implementation which was hard to reason about and prone to bugs. Summary of important changes: - `httpx-ws` library replaces `websockets`, allowing for Trio support. As a consequence of this, reconnect and disconnect functionality is gone (however, this is almost certainly better handled on the user side anyways). - Python 3.10 support is dropped as we're now using `ExceptionGroup`s. This would likely have happened soon anyways as the official support lifecycle only goes through October 2026. - All previous sync endpoints are now async. All previous async endpoints have been removed (so instead of having endpoints named `Account.a_get` for async and `Account.get` for sync, we have a single endpoint named `Account.get`, which is async). - Session token refreshing is smarter: Instead of making users check and refresh themselves, they will auto-refresh before any request if they're close to expiry. Sessions also have an optional async context manager which can be used to ensure cleanup happens. - Streamers now use `httpx-ws` websockets and structured concurrency, making them much simpler and easier to reason about (which implies a lower chance of bugs in the future). We also get to use the helpful `send_json` and `receive_json` functions instead of wrapping everything in `json.dumps`/`json.loads`. - `tastytrade.dxfeed.Quote` events now have helpful `mid_price` and `micro_price` properties calculated from its bid/ask prices. - `tastytrade.order.OrderAction` has a `multiplier` property which is `-1` when it's a "Sell" leg and `1` when it's a "Buy" leg. - Test suite now runs on both asyncio and Trio.
Graeme22
commented
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
For a long time this library was mostly sync, with the streamers being the exception. PR #168 added async endpoints on top of the existing endpoints, which gave users more flexibility. With this change, I propose that version 12+ be async-only.
There are a few reasons for this. First of all, having both sync and async versions of everything resulted in a ton of code duplication (check out how many lines are removed in this commit!). Second, both streamers are (and always have been) async, meaning that almost all users are already implementing at least some async code, so having the separate sync versions makes less sense. Finally, this change allows us to support Trio and clean up the streamer implementation which was hard to reason about and prone to bugs.
Summary of important changes:
httpx-wslibrary replaceswebsockets, allowing for Trio support. As a consequence of this, reconnect and disconnect functionality is gone (however, this is almost certainly better handled on the user side anyways).Python 3.10 support is dropped as we're now using
ExceptionGroups. This would likely have happened soon anyways as the official support lifecycle only goes through October 2026.All previous sync endpoints are now async. All previous async endpoints have been removed (so instead of having endpoints named
Account.a_getfor async andAccount.getfor sync, we have a single endpoint namedAccount.get, which is async).Session token refreshing is smarter: Instead of making users check and refresh themselves, they will auto-refresh before any request if they're close to expiry. Sessions also have an optional async context manager which can be used to ensure cleanup happens.
Streamers now use
httpx-wswebsockets and structured concurrency, making them much simpler and easier to reason about (which implies a lower chance of bugs in the future). We also get to use the helpfulsend_jsonandreceive_jsonfunctions instead of wrapping everything injson.dumps/json.loads.tastytrade.dxfeed.Quoteevents now have helpfulmid_priceandmicro_priceproperties calculated from its bid/ask prices.tastytrade.order.OrderActionhas amultiplierproperty which is-1when it's a "Sell" leg and1when it's a "Buy" leg.Test suite now runs on both asyncio and Trio.
Pre-merge checklist
make lint)make test, make sure you haveTT_REFRESH,TT_SECRET, andTT_ACCOUNTenvironment variables set)Please note that, in order to pass the tests, you'll need to set up your Tastytrade credentials as repository secrets on your local fork. Read more at CONTRIBUTING.md.