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
13 changes: 7 additions & 6 deletions examples/rest/universal-snapshot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import cast, Iterator, Union

from urllib3 import HTTPResponse

from polygon import RESTClient
from polygon.rest.models import UniversalSnapshot, SnapshotMarketType

Expand Down Expand Up @@ -35,12 +33,15 @@ def print_snapshots(iterator: Union[Iterator[UniversalSnapshot], HTTPResponse]):
)
print_snapshots(it)

it = client.list_universal_snapshots(
market_type=SnapshotMarketType.STOCKS, ticker_gt="A", ticker_lt="AAPL"
)
it = client.list_universal_snapshots(type="stocks", ticker_gt="A", ticker_lt="AAPL")
print_snapshots(it)

it = client.list_universal_snapshots(type="stocks", ticker_gte="AAPL", ticker_lte="ABB")
print_snapshots(it)

it = client.list_universal_snapshots(
market_type=SnapshotMarketType.STOCKS, ticker_gte="AAPL", ticker_lte="ABB"
type="options",
ticker_gte="O:AAPL230804C00050000",
ticker_lte="O:AAPL230804C00070000",
)
print_snapshots(it)
12 changes: 10 additions & 2 deletions polygon/rest/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
SnapshotTickerFullBook,
UniversalSnapshot,
IndicesSnapshot,
Sort,
Order,
)
from urllib3 import HTTPResponse

Expand All @@ -24,8 +26,11 @@ def get_locale(market_type: Union[SnapshotMarketType, str]):
class SnapshotClient(BaseClient):
def list_universal_snapshots(
self,
market_type: Optional[Union[str, SnapshotMarketType]] = None,
type: Optional[Union[str, SnapshotMarketType]] = None,
ticker_any_of: Optional[List[str]] = None,
order: Optional[Union[str, Order]] = None,
limit: Optional[int] = 10,
sort: Optional[Union[str, Sort]] = None,
ticker_lt: Optional[str] = None,
ticker_lte: Optional[str] = None,
ticker_gt: Optional[str] = None,
Expand All @@ -42,8 +47,11 @@ def list_universal_snapshots(
- https://polygon.io/docs/forex/get_v3_snapshot
- https://polygon.io/docs/crypto/get_v3_snapshot

:param market_type: the type of the asset
:param type: the type of the asset
:param ticker_any_of: Comma-separated list of tickers, up to a maximum of 250. If no tickers are passed then all
:param order: The order to sort the results on. Default is asc (ascending).
:param limit: Limit the size of the response per-page, default is 10 and max is 250.
:param sort: The field to sort the results on. Default is ticker. If the search query parameter is present, sort is ignored and results are ordered by relevance.
results will be returned in a paginated manner. Warning: The maximum number of characters allowed in a URL
are subject to your technology stack.
:param ticker_lt search for tickers less than
Expand Down