Skip to content

Commit

Permalink
Fix parameter naming and add missing parameters in list_universal_sna…
Browse files Browse the repository at this point in the history
…pshots (#485)

* Fix parameter naming and add missing parameters in list_universal_snapshots
  • Loading branch information
justinpolygon authored Aug 3, 2023
1 parent b68db9c commit faf55de
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
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

0 comments on commit faf55de

Please sign in to comment.