Skip to content

tastyware/tastytrade:v9.3

Compare
Choose a tag to compare
@Graeme22 Graeme22 released this 03 Dec 19:24
· 9 commits to master since this release

What's Changed

  • All event fields from tastytrade.dxfeed changed to Pythonic snake_case instead of their previous names, which came directly from the Java documentation and therefore used camelCase.
    So this code:
print(quote.eventSymbol)

Becomes:

print(quote.event_symbol)
  • Candle, Quote, and Trade events from tastytrade.dxfeed have less Optional fields.
    Previously, the streamer would return a lot of "garbage" events that would have to be handled in some way. For example, listening to Quote events might have looked like this:
from tastytrade.dxfeed import Quote
# ...
async for quote in streamer.listen(Quote):
    if quote.bidPrice is not None and quote.askPrice is not None:
        quotes.append(quote)

To make things even worse, using the Quote objects returned down the road led to lots of # type: ignores littering the code as type checkers are unable to determine that quotes without crucial properties have already been filtered out:

# type checker will complain as these may be `None`!
mid = quote.bidPrice + quote.askPrice  # type: ignore

This mini-release solves these problems by making these fields non-optional, and not returning the events at all if they're missing crucial fields. (For example, Quotes are pretty much useless without the bid/ask, or Candles without OHLC.)
So the above code can be changed to:

from tastytrade.dxfeed import Quote
# ...
async for quote in streamer.listen(Quote):
    quotes.append(quote)

and

mid = quote.bid_price + quote.ask_price

Full Changelog: v9.2...v9.3