Skip to content

Commit cd047eb

Browse files
committed
Expose response fields the models were dropping
Found by comparing live API responses with the deserialized objects: - RealTimeCurrencyConversion.from_ read the key "from_", but the API sends "from", so it was always None; also add symbol - PreviousCloseAgg.transactions (n) - TickerDetails.round_lot - EtfGlobalConstituent.constituent_rank - LastQuoteOptionContractSnapshot.ask_exchange / bid_exchange Two existing tests asserted the old values (from_=None, no transactions) even though their fixtures carried the data; updated them.
1 parent fd78d75 commit cd047eb

7 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎massive/rest/models/aggs.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class PreviousCloseAgg:
107107
timestamp: Optional[float] = None
108108
volume: Optional[float] = None
109109
vwap: Optional[float] = None
110+
transactions: Optional[int] = None
110111

111112
@staticmethod
112113
def from_dict(d):
@@ -119,6 +120,7 @@ def from_dict(d):
119120
d.get("t", None),
120121
d.get("v", None),
121122
d.get("vw", None),
123+
d.get("n", None),
122124
)
123125

124126

‎massive/rest/models/etf_global.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class EtfGlobalConstituent:
8484
asset_class: Optional[str] = None
8585
composite_ticker: Optional[str] = None
8686
constituent_name: Optional[str] = None
87+
constituent_rank: Optional[int] = None
8788
constituent_ticker: Optional[str] = None
8889
country_of_exchange: Optional[str] = None
8990
currency_traded: Optional[str] = None
@@ -105,6 +106,7 @@ def from_dict(d):
105106
asset_class=d.get("asset_class"),
106107
composite_ticker=d.get("composite_ticker"),
107108
constituent_name=d.get("constituent_name"),
109+
constituent_rank=d.get("constituent_rank"),
108110
constituent_ticker=d.get("constituent_ticker"),
109111
country_of_exchange=d.get("country_of_exchange"),
110112
currency_traded=d.get("currency_traded"),

‎massive/rest/models/quotes.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ class RealTimeCurrencyConversion:
103103
initial_amount: Optional[float] = None
104104
last: Optional[ForexQuote] = None
105105
to: Optional[str] = None
106+
symbol: Optional[str] = None
106107

107108
@staticmethod
108109
def from_dict(d):
109110
return RealTimeCurrencyConversion(
110111
converted=d.get("converted", None),
111-
from_=d.get("from_", None),
112+
from_=d.get("from", d.get("from_")),
112113
initial_amount=d.get("initialAmount", None),
113114
last=None if "last" not in d else ForexQuote.from_dict(d["last"]),
114115
to=d.get("to", None),
116+
symbol=d.get("symbol"),
115117
)

‎massive/rest/models/snapshot.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class LastQuoteOptionContractSnapshot:
170170
last_updated: Optional[int] = None
171171
midpoint: Optional[float] = None
172172
timeframe: Optional[str] = None
173+
ask_exchange: Optional[int] = None
174+
bid_exchange: Optional[int] = None
173175

174176
@staticmethod
175177
def from_dict(d):

‎massive/rest/models/tickers.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class TickerDetails:
112112
name: Optional[str] = None
113113
phone_number: Optional[str] = None
114114
primary_exchange: Optional[str] = None
115+
round_lot: Optional[int] = None
115116
share_class_figi: Optional[str] = None
116117
share_class_shares_outstanding: Optional[int] = None
117118
sic_code: Optional[str] = None
@@ -147,6 +148,7 @@ def from_dict(d):
147148
name=d.get("name", None),
148149
phone_number=d.get("phone_number", None),
149150
primary_exchange=d.get("primary_exchange", None),
151+
round_lot=d.get("round_lot", None),
150152
share_class_figi=d.get("share_class_figi", None),
151153
share_class_shares_outstanding=d.get(
152154
"share_class_shares_outstanding", None

‎test_rest/test_aggs.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def test_get_previous_close_agg(self):
108108
timestamp=1651003200000,
109109
volume=95595226.0,
110110
vwap=158.6074,
111+
transactions=899965,
111112
)
112113
]
113114
self.assertEqual(aggs, expected)

‎test_rest/test_quotes.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,13 @@ def test_get_real_time_currency_conversion(self):
351351
conversion = self.c.get_real_time_currency_conversion("AUD", "USD", 100, 2)
352352
expected = RealTimeCurrencyConversion(
353353
converted=69.31,
354-
from_=None,
354+
from_="AUD",
355355
initial_amount=100,
356356
last=ForexQuote(
357357
ask=1.4436264, bid=1.4427932, exchange=48, timestamp=1652195426000
358358
),
359359
to="USD",
360+
symbol="USD/AUD",
360361
)
361362

362363
self.assertEqual(conversion, expected)

0 commit comments

Comments
 (0)