Skip to content

Commit a160827

Browse files
authored
fix dry run bug (#176)
1 parent 0cf0ce0 commit a160827

File tree

8 files changed

+13
-11
lines changed

8 files changed

+13
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async with DXLinkStreamer(session) as streamer:
4343
```
4444

4545
```python
46-
>>> [Quote(eventSymbol='SPY', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='Q', bidPrice=411.58, bidSize=400.0, askTime=0, askExchangeCode='Q', askPrice=411.6, askSize=1313.0), Quote(eventSymbol='SPX', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='\x00', bidPrice=4122.49, bidSize='NaN', askTime=0, askExchangeCode='\x00', askPrice=4123.65, askSize='NaN')]
46+
>>> Quote(eventSymbol='SPY', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='Q', bidPrice=411.58, bidSize=400.0, askTime=0, askExchangeCode='Q', askPrice=411.6, askSize=1313.0)
4747
```
4848

4949
Note that this is asynchronous code, so you can't run it as is unless you're using a Jupyter notebook or something similar.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
project = "tastytrade"
1414
copyright = "2024, Graeme Holliday"
1515
author = "Graeme Holliday"
16-
release = "9.0"
16+
release = "9.1"
1717

1818
# -- General configuration ---------------------------------------------------
1919
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

docs/data-streamer.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Once you've created the streamer, you can subscribe/unsubscribe to events, like
2525
.. code-block:: python
2626
2727
from tastytrade.dxfeed import Quote
28-
subs_list = ['SPY', 'SPX']
28+
subs_list = ['SPY'] # you can add more symbols here!
2929
3030
async with DXLinkStreamer(session) as streamer:
3131
await streamer.subscribe(Quote, subs_list)
@@ -36,7 +36,7 @@ Once you've created the streamer, you can subscribe/unsubscribe to events, like
3636
break
3737
print(quotes)
3838
39-
>>> {'SPY': Quote(eventSymbol='SPY', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='Q', bidPrice=411.58, bidSize=400.0, askTime=0, askExchangeCode='Q', askPrice=411.6, askSize=1313.0), 'SPX': Quote(eventSymbol='SPX', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='\x00', bidPrice=4122.49, bidSize='NaN', askTime=0, askExchangeCode='\x00', askPrice=4123.65, askSize='NaN')}
39+
>>> [{'SPY': Quote(eventSymbol='SPY', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='Q', bidPrice=411.58, bidSize=400.0, askTime=0, askExchangeCode='Q', askPrice=411.6, askSize=1313.0), 'SPX': Quote(eventSymbol='SPX', eventTime=0, sequence=0, timeNanoPart=0, bidTime=0, bidExchangeCode='\x00', bidPrice=4122.49, bidSize='NaN', askTime=0, askExchangeCode='\x00', askPrice=4123.65, askSize='NaN')}]
4040

4141
Note that these are ``asyncio`` calls, so you'll need to run this code asynchronously. Here's an example:
4242

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "tastytrade"
7-
version = "9.0"
7+
version = "9.1"
88
description = "An unofficial, sync/async SDK for Tastytrade!"
99
readme = "README.md"
1010
requires-python = ">=3.8"

tastytrade/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
BACKTEST_URL = "https://backtester.vast.tastyworks.com"
55
CERT_URL = "https://api.cert.tastyworks.com"
66
VAST_URL = "https://vast.tastyworks.com"
7-
VERSION = "9.0"
7+
VERSION = "9.1"
88

99
logger = logging.getLogger(__name__)
1010
logger.setLevel(logging.DEBUG)

tastytrade/order.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ class PlacedOrder(TastytradeJsonDataclass):
281281
"""
282282

283283
account_number: str
284-
id: int
285284
time_in_force: OrderTimeInForce
286285
order_type: OrderType
287286
underlying_symbol: str
@@ -292,6 +291,8 @@ class PlacedOrder(TastytradeJsonDataclass):
292291
edited: bool
293292
updated_at: datetime
294293
legs: List[Leg]
294+
#: the ID of the order; test orders placed with dry_run don't have an ID
295+
id: int = -1
295296
size: Optional[Decimal] = None
296297
price: Optional[Decimal] = None
297298
gtc_date: Optional[date] = None
@@ -328,9 +329,10 @@ class PlacedComplexOrder(TastytradeJsonDataclass):
328329
"""
329330

330331
account_number: str
331-
id: int
332332
type: str
333333
orders: List[PlacedOrder]
334+
#: the ID of the order; test orders placed with dry_run don't have an ID
335+
id: int = -1
334336
trigger_order: Optional[PlacedOrder] = None
335337
terminal_at: Optional[str] = None
336338
ratio_price_threshold: Optional[Decimal] = None

tastytrade/streamer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ async def create(cls, session: Session) -> "AlertStreamer":
205205
self = cls(session)
206206
return await self.__aenter__()
207207

208-
async def __aexit__(self, exc_type, exc, tb):
208+
async def __aexit__(self, *exc):
209209
await self.close()
210210

211211
async def close(self):
@@ -381,7 +381,7 @@ async def create(
381381
self = cls(session, ssl_context=ssl_context)
382382
return await self.__aenter__()
383383

384-
async def __aexit__(self, exc_type, exc, tb):
384+
async def __aexit__(self, *exc):
385385
await self.close()
386386

387387
async def close(self):

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)