-
Notifications
You must be signed in to change notification settings - Fork 346
Support v3/snapshot #444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gavingolden
merged 18 commits into
master
from
gg/implement-universal-snapshot-endpoint
May 18, 2023
Merged
Support v3/snapshot #444
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ae07001
Update specs
gavingolden 6f7a158
Update spec
gavingolden 576e3b2
Implement v3/snapshot & test
gavingolden 85e615d
Update readme
gavingolden ab9580d
formatting
gavingolden 5aba98f
fix type issue
gavingolden 37df55d
fix
gavingolden 49cb91d
fix
gavingolden 12c20b6
Merge remote-tracking branch 'origin/master' into gg/implement-univer…
gavingolden ee18331
Add ticker filters
gavingolden f846420
Fix typo
gavingolden 6bc7412
Add example
gavingolden e1ba5f2
cleanup
gavingolden 3f77fe6
rename
gavingolden 9bf9071
fix type
gavingolden e0aa189
cleanup
gavingolden a55b379
Rename method
gavingolden 6548d0f
Merge remote-tracking branch 'origin/master' into gg/implement-univer…
gavingolden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| from typing import cast, Iterator, Union | ||
|
|
||
| from urllib3 import HTTPResponse | ||
|
|
||
| from polygon import RESTClient | ||
| from polygon.rest.models import UniversalSnapshot, SnapshotMarketType | ||
|
|
||
| # docs | ||
| # https://polygon.io/docs/stocks/get_v3_snapshot | ||
| # https://polygon-api-client.readthedocs.io/en/latest/Snapshot.html | ||
|
|
||
| # client = RESTClient("XXXXXX") # hardcoded api_key is used | ||
| client = RESTClient() # POLYGON_API_KEY environment variable is used | ||
|
|
||
|
|
||
| def print_snapshots(iterator: Union[Iterator[UniversalSnapshot], HTTPResponse]): | ||
| snapshots = [s for s in iterator] | ||
|
|
||
| print(f"count: {len(snapshots)}") | ||
|
|
||
| for item in snapshots: | ||
| print(item) | ||
|
|
||
|
|
||
| # it = client.list_universal_snapshots() # all tickers for all assets types in lexicographical order | ||
|
|
||
| it = client.list_universal_snapshots( | ||
| ticker_any_of=[ | ||
| "AAPL", | ||
| "O:AAPL230519C00055000", | ||
| "DOES_NOT_EXIST", | ||
| "X:1INCHUSD", | ||
| "C:AEDAUD", | ||
| ] | ||
| ) | ||
| print_snapshots(it) | ||
|
|
||
| it = client.list_universal_snapshots( | ||
| market_type=SnapshotMarketType.STOCKS, ticker_gt="A", ticker_lt="AAPL" | ||
| ) | ||
| print_snapshots(it) | ||
|
|
||
| it = client.list_universal_snapshots( | ||
| market_type=SnapshotMarketType.STOCKS, ticker_gte="AAPL", ticker_lte="ABB" | ||
| ) | ||
| print_snapshots(it) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.