Commit 0c6c0b1
authored
Move to async-only library for version>=12 (#299)
* Move to async-only library for version>=12
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.
* update docs
* bump min pydantic version for 3.14 support1 parent 2d951dd commit 0c6c0b1
File tree
44 files changed
+1104
-3732
lines changed- .github
- workflows
- docs
- tastytrade
- dxfeed
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
44 files changed
+1104
-3732
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
| 41 | + | |
43 | 42 | | |
44 | 43 | | |
45 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
65 | 64 | | |
66 | 65 | | |
67 | 66 | | |
68 | | - | |
69 | | - | |
| 67 | + | |
| 68 | + | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | 76 | | |
90 | 77 | | |
91 | 78 | | |
| |||
94 | 81 | | |
95 | 82 | | |
96 | 83 | | |
97 | | - | |
98 | | - | |
| 84 | + | |
| 85 | + | |
99 | 86 | | |
100 | 87 | | |
101 | 88 | | |
| |||
104 | 91 | | |
105 | 92 | | |
106 | 93 | | |
107 | | - | |
| 94 | + | |
108 | 95 | | |
109 | 96 | | |
110 | 97 | | |
| |||
120 | 107 | | |
121 | 108 | | |
122 | 109 | | |
123 | | - | |
| 110 | + | |
124 | 111 | | |
125 | 112 | | |
126 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
| |||
33 | 29 | | |
34 | 30 | | |
35 | 31 | | |
36 | | - | |
| 32 | + | |
| 33 | + | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | 38 | | |
42 | | - | |
43 | | - | |
| 39 | + | |
| 40 | + | |
44 | 41 | | |
45 | | - | |
46 | | - | |
47 | | - | |
| 42 | + | |
48 | 43 | | |
49 | 44 | | |
50 | 45 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 46 | + | |
| 47 | + | |
77 | 48 | | |
78 | | - | |
79 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
80 | 58 | | |
81 | | - | |
82 | | - | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
0 commit comments