Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions massive/rest/models/markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class MarketStatus:
exchanges: Optional[MarketExchanges] = None
indicesGroups: Optional[MarketIndices] = None
market: Optional[str] = None
overnight: Optional[bool] = None
server_time: Optional[str] = None

@staticmethod
Expand All @@ -96,5 +97,6 @@ def from_dict(d):
else MarketIndices.from_dict(d["indicesGroups"])
),
market=d.get("market", None),
overnight=d.get("overnight", None),
server_time=d.get("serverTime", None),
)
1 change: 1 addition & 0 deletions test_rest/mocks/v1/marketstatus/now.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"market": "extended-hours",
"earlyHours": false,
"afterHours": true,
"overnight": false,
"serverTime": "2022-04-28T16:48:08-04:00",
"exchanges": {
"nyse": "extended-hours",
Expand Down
32 changes: 32 additions & 0 deletions test_rest/test_markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,38 @@ def test_get_market_status(self):
nasdaq="extended-hours", nyse="extended-hours", otc="extended-hours"
),
market="extended-hours",
overnight=False,
server_time="2022-04-28T16:48:08-04:00",
)
self.assertEqual(status, expected)

def test_market_status_overnight(self):
# During the overnight session (9:00 PM to 4:00 AM ET), earlyHours and
# afterHours are both false; only overnight identifies the session.
status = MarketStatus.from_dict(
{
"market": "extended-hours",
"earlyHours": False,
"afterHours": False,
"overnight": True,
"serverTime": "2026-12-07T23:15:00-05:00",
"exchanges": {
"nyse": "extended-hours",
"nasdaq": "extended-hours",
"otc": "extended-hours",
},
"currencies": {"fx": "open", "crypto": "open"},
}
)
expected = MarketStatus(
after_hours=False,
currencies=MarketCurrencies(crypto="open", fx="open"),
early_hours=False,
exchanges=MarketExchanges(
nasdaq="extended-hours", nyse="extended-hours", otc="extended-hours"
),
market="extended-hours",
overnight=True,
server_time="2026-12-07T23:15:00-05:00",
)
self.assertEqual(status, expected)
Loading