From a4e0f2c810d86ff0d0b89497af9d7a0b0b4e8cf7 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Wed, 2 Dec 2026 11:24:54 -0700 Subject: [PATCH] [PRO-3269] Add the overnight field to MarketStatus /v1/marketstatus/now now returns overnight (bool). During the overnight session (9:00 PM to 4:00 AM ET), market is "extended-hours" and both earlyHours and afterHours are false, so overnight is the only way to tell that session apart. --- massive/rest/models/markets.py | 2 ++ test_rest/mocks/v1/marketstatus/now.json | 1 + test_rest/test_markets.py | 32 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/massive/rest/models/markets.py b/massive/rest/models/markets.py index 1460929e..1c62db09 100644 --- a/massive/rest/models/markets.py +++ b/massive/rest/models/markets.py @@ -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 @@ -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), ) diff --git a/test_rest/mocks/v1/marketstatus/now.json b/test_rest/mocks/v1/marketstatus/now.json index 51172de1..49a11f29 100644 --- a/test_rest/mocks/v1/marketstatus/now.json +++ b/test_rest/mocks/v1/marketstatus/now.json @@ -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", diff --git a/test_rest/test_markets.py b/test_rest/test_markets.py index 97fe7fc6..cefd842b 100644 --- a/test_rest/test_markets.py +++ b/test_rest/test_markets.py @@ -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)