Skip to content

Commit 94b15fd

Browse files
committed
indices snapshot addition
1 parent a8cc93f commit 94b15fd

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

polygon/rest/models/snapshot.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class MinuteSnapshot:
1515
close: Optional[float] = None
1616
volume: Optional[float] = None
1717
vwap: Optional[float] = None
18-
value: Optional[float] = None
1918
otc: Optional[bool] = None
2019

2120
@staticmethod
@@ -28,7 +27,6 @@ def from_dict(d):
2827
d.get("c", None),
2928
d.get("v", None),
3029
d.get("vw", None),
31-
d.get("val", None),
3230
d.get("otc", None),
3331
)
3432

@@ -53,13 +51,34 @@ def from_dict(d):
5351

5452

5553
@modelclass
56-
class TickerSnapshot:
57-
"Contains the most up-to-date market data for all traded ticker symbols."
54+
class IndicesSnapshot:
5855
value: Optional[float] = None
5956
name: Optional[str] = None
6057
type: Optional[str] = None
58+
ticket: Optional[str] = None
6159
market_status: Optional[str] = None
6260
session: Optional[DayOptionContractSnapshot] = None
61+
error: Optional[str] = None
62+
message: Optional[str] = None
63+
64+
@staticmethod
65+
def from_dict(d):
66+
return IndicesSnapshot(
67+
value=d.get("value", None),
68+
name=d.get("name", None),
69+
type=d.get("type", None),
70+
market_status=d.get("market_status", None),
71+
session=None
72+
if "session" not in d
73+
else DayOptionContractSnapshot.from_dict(d["session"]),
74+
error=d.get("error", None),
75+
message=d.get("message", None),
76+
)
77+
78+
79+
@modelclass
80+
class TickerSnapshot:
81+
"Contains the most up-to-date market data for all traded ticker symbols."
6382
day: Optional[Agg] = None
6483
last_quote: Optional[LastQuote] = None
6584
last_trade: Optional[LastTrade] = None
@@ -73,13 +92,6 @@ class TickerSnapshot:
7392
@staticmethod
7493
def from_dict(d):
7594
return TickerSnapshot(
76-
value=d.get("value", None),
77-
name=d.get("name", None),
78-
type=d.get("type", None),
79-
market_status=d.get("market_status", None),
80-
session=None
81-
if "session" not in d
82-
else DayOptionContractSnapshot.from_dict(d["session"]),
8395
day=None if "day" not in d else Agg.from_dict(d["day"]),
8496
last_quote=None
8597
if "lastQuote" not in d

polygon/rest/snapshot.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
OptionContractSnapshot,
77
SnapshotMarketType,
88
SnapshotTickerFullBook,
9+
IndicesSnapshot,
910
)
1011
from urllib3 import HTTPResponse
1112

@@ -184,3 +185,22 @@ def get_snapshot_crypto_book(
184185
raw=raw,
185186
options=options,
186187
)
188+
189+
def get_snapshot_indices(
190+
self,
191+
ticker: Optional[str] = None,
192+
ticker_any_of: Optional[Union[str, List[str]]] = None,
193+
params: Optional[Dict[str, Any]] = None,
194+
raw: bool = False,
195+
options: Optional[RequestOptionBuilder] = None,
196+
) -> Union[List[IndicesSnapshot], HTTPResponse]:
197+
url = f"/v3/snapshot/indices"
198+
199+
return self._get(
200+
path=url,
201+
params=self._get_params(self.get_snapshot_indices, locals()),
202+
deserializer=IndicesSnapshot.from_dict,
203+
raw=raw,
204+
result_key="results",
205+
options=options,
206+
)

0 commit comments

Comments
 (0)