Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamer update for the new DXFeed API #83

Merged
merged 22 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from setuptools import find_packages, setup


Quenos marked this conversation as resolved.
Show resolved Hide resolved
f = open('README.rst', 'r')
LONG_DESCRIPTION = f.read()
f.close()
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/candle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Candle(Event):
for a specific period. Candles are build with a specified period using a
specified price type with data taken from a specified exchange.
"""

#: symbol of this event
Quenos marked this conversation as resolved.
Show resolved Hide resolved
eventSymbol: str
#: time of this event
Expand Down
23 changes: 22 additions & 1 deletion tastytrade/dxfeed/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class EventType(str, Enum):
for the data streamer.

Information on different types of events, their uses and their properties
can be found at the `dxfeed Knowledge Base
can be found at the `dxfeed Knowledge Base.
<https://kb.dxfeed.com/en/data-model/dxfeed-api-market-events.html>`_.
"""

CANDLE = 'Candle'
GREEKS = 'Greeks'
PROFILE = 'Profile'
Expand All @@ -32,6 +33,26 @@ def from_stream(cls, data: list) -> List['Event']:

:param data: list of raw quote data from streamer

:return: list of event objects from data
"""
objs = []
size = len(cls.__dataclass_fields__) # type: ignore
multiples = len(data) / size
if not multiples.is_integer():
msg = 'Mapper data input values are not a multiple of the key size'
raise Exception(msg)
for i in range(int(multiples)):
objs.append(cls(**data))
return objs

@classmethod
def from_stream_legacy(cls, data: list) -> List['Event']:
"""
Makes a list of event objects from a list of raw trade data fetched by
a :class:`~tastyworks.streamer.DataStreamer`.

:param data: list of raw quote data from streamer

:return: list of event objects from data
"""
objs = []
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/greeks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Greeks(Event):
in different axes. If a derivative is very far from zero, then the
portfolio has a risky sensitivity in this parameter.
"""

#: symbol of this event
eventSymbol: str
#: time of this event
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Profile(Event):
represents the most recent information that is available about the
traded security on the market at any given moment of time.
"""

#: symbol of this event
eventSymbol: str
#: time of this event
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Quote(Event):
A Quote event is a snapshot of the best bid and ask prices, and other
fields that change with each quote.
"""

#: symbol of this event
eventSymbol: str
#: time of this event
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Summary(Event):

Before opening the bidding, the values are reset to N/A or NaN.
"""

#: symbol of this event
eventSymbol: str
#: time of this event
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/theoprice.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class TheoPrice(Event):
you with a formula so you can perform calculations based on values from
this event.
"""

#: symbol of this event
eventSymbol: str
#: time of this event
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/timeandsale.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TimeAndSale(Event):
TimeAndSale events have a unique index that can be used for later
correction/cancellation processing.
"""

#: symbol of this event
eventSymbol: str
#: time of this event
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Trade(Event):
about all transactions, but only about the last transaction for a single
instrument.
"""

#: symbol of this event
eventSymbol: str
#: time of this event
Expand Down
1 change: 1 addition & 0 deletions tastytrade/dxfeed/underlying.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Underlying(Event):
represents the most recent information that is available about the
corresponding values on the market at any given moment of time.
"""

#: symbol of this event
eventSymbol: str
#: transactional event flags
Expand Down
12 changes: 6 additions & 6 deletions tastytrade/metrics.py
Graeme22 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ class MarketMetricInfo(TastytradeJsonDataclass):
option_expiration_implied_volatilities: List[OptionExpirationImpliedVolatility] # noqa: E501
beta: Decimal
corr_spy_3month: Decimal
dividend_rate_per_share: Optional[Decimal] = None
dividend_rate_per_share: Decimal
market_cap: Decimal
implied_volatility_30_day: Optional[Decimal] = None
historical_volatility_30_day: Optional[Decimal] = None
historical_volatility_60_day: Optional[Decimal] = None
historical_volatility_90_day: Optional[Decimal] = None
iv_hv_30_day_difference: Optional[Decimal] = None
implied_volatility_30_day: Decimal
historical_volatility_30_day: Decimal
historical_volatility_60_day: Decimal
historical_volatility_90_day: Decimal
iv_hv_30_day_difference: Decimal
price_earnings_ratio: Decimal
earnings_per_share: Decimal
created_at: Optional[datetime] = None
Expand Down
Loading