From b739ddfe90b68c03198a0eee43c0062d3f48fc91 Mon Sep 17 00:00:00 2001 From: suremarc Date: Thu, 29 Apr 2021 12:02:49 -0400 Subject: [PATCH 1/4] add endpoints in client --- polygon/rest/client.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/polygon/rest/client.py b/polygon/rest/client.py index 55f39e83..958ef43a 100644 --- a/polygon/rest/client.py +++ b/polygon/rest/client.py @@ -175,16 +175,23 @@ def forex_currencies_last_quote_for_a_currency_pair(self, from_, to, **query_params) -> models.ForexCurrenciesLastQuoteForACurrencyPairApiResponse: endpoint = f"{self.url}/v1/last_quote/currencies/{from_}/{to}" return self._handle_response("ForexCurrenciesLastQuoteForACurrencyPairApiResponse", endpoint, query_params) + + def forex_currencies_grouped_daily(self, date, **query_params) -> models.ForexCurrenciesGroupedDailyApiResponse: + endpoint = f"{self.url}/v2/aggs/grouped/locale/global/market/fx/{date}" + return self._handle_response("ForexCurrenciesGroupedDailyApiResponse", endpoint, query_params) - # FIXME: add daily open/close - # FIXME: add grouped daily bars - # FIXME: add previous close - # FIXME: add snapshot for single ticker + def forex_currencies_previous_close(self, ticker, **query_params) -> models.ForexCurrenciesGroupedDailyApiResponse: + endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/prev" + return self._handle_response("ForexCurrenciesPreviousCloseApiResponse", endpoint, query_params) def forex_currencies_snapshot_all_tickers(self, **query_params) -> models.ForexCurrenciesSnapshotAllTickersApiResponse: endpoint = f"{self.url}/v2/snapshot/locale/global/markets/forex/tickers" return self._handle_response("ForexCurrenciesSnapshotAllTickersApiResponse", endpoint, query_params) + + def forex_currencies_snapshot_single_ticker(self, ticker, **query_params) -> models.ForexCurrenciesSnapshotSingleTickerApiResponse: + endpoint = f"{self.url}/v2/snapshot/locale/global/markets/forex/tickers/{ticker}" + return self._handle_response("ForexCurrenciesSnapshotSingleTickerApiResponse", endpoint, query_params) def forex_currencies_snapshot_gainers_losers(self, direction, **query_params) -> models.ForexCurrenciesSnapshotGainersLosersApiResponse: @@ -219,8 +226,13 @@ def crypto_historic_crypto_trades(self, from_, to, date, endpoint = f"{self.url}/v1/historic/crypto/{from_}/{to}/{date}" return self._handle_response("CryptoHistoricCryptoTradesApiResponse", endpoint, query_params) - # FIXME: add grouped daily bars - # FIXME: add previous close + def crypto_grouped_daily(self, date, **query_params) -> models.CryptoGroupedDailyApiResponse: + endpoint = f"{self.url}/v2/aggs/grouped/locale/global/market/crypto/{date}" + return self._handle_response("CryptoGroupedDailyApiResponse", endpoint, query_params) + + def crypto_previous_close(self, ticker, **query_params) -> models.CryptoPreviousCloseApiResponse: + endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/prev" + return self._handle_response("CryptoPreviousClose", endpoint, query_params) def crypto_snapshot_all_tickers(self, **query_params) -> models.CryptoSnapshotAllTickersApiResponse: endpoint = f"{self.url}/v2/snapshot/locale/global/markets/crypto/tickers" From be43d55d4a68c1aeab8e7c6fd7b64b20e95c7dd0 Mon Sep 17 00:00:00 2001 From: suremarc Date: Thu, 29 Apr 2021 12:35:16 -0400 Subject: [PATCH 2/4] add crypto prev. close + grouped daily --- polygon/rest/models/__init__.py | 4 ++ polygon/rest/models/definitions.py | 71 ++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/polygon/rest/models/__init__.py b/polygon/rest/models/__init__.py index d21b57ad..b48686f6 100644 --- a/polygon/rest/models/__init__.py +++ b/polygon/rest/models/__init__.py @@ -87,6 +87,8 @@ from .definitions import CryptoLastTradeForACryptoPairApiResponse from .definitions import CryptoDailyOpenCloseApiResponse from .definitions import CryptoHistoricCryptoTradesApiResponse +from .definitions import CryptoGroupedDailyApiResponse +from .definitions import CryptoPreviousCloseApiResponse from .definitions import CryptoSnapshotAllTickersApiResponse from .definitions import CryptoSnapshotSingleTickerApiResponse from .definitions import CryptoSnapshotSingleTickerFullBookApiResponse @@ -195,6 +197,8 @@ "CryptoLastTradeForACryptoPairApiResponse": CryptoLastTradeForACryptoPairApiResponse, "CryptoDailyOpenCloseApiResponse": CryptoDailyOpenCloseApiResponse, "CryptoHistoricCryptoTradesApiResponse": CryptoHistoricCryptoTradesApiResponse, + "CryptoGroupedDailyApiResponse": CryptoGroupedDailyApiResponse, + "CryptoPreviousCloseApiResponse": CryptoPreviousCloseApiResponse, "CryptoSnapshotAllTickersApiResponse": CryptoSnapshotAllTickersApiResponse, "CryptoSnapshotSingleTickerApiResponse": CryptoSnapshotSingleTickerApiResponse, "CryptoSnapshotSingleTickerFullBookApiResponse": CryptoSnapshotSingleTickerFullBookApiResponse, diff --git a/polygon/rest/models/definitions.py b/polygon/rest/models/definitions.py index 4f834cee..51b9f85a 100644 --- a/polygon/rest/models/definitions.py +++ b/polygon/rest/models/definitions.py @@ -3909,6 +3909,77 @@ def __init__(self): self.ticks: List[CryptoTickJson] +# noinspection SpellCheckingInspection +class CryptoGroupedDailyApiResponse(Definition): + _swagger_name_to_python = { + "status": "status", + "adjusted": "adjusted", + "queryCount": "queryCount", + "resultsCount": "resultsCount", + "results": "results", + } + + _attribute_is_primitive = { + "status": True, + "adjusted": True, + "queryCount": True, + "resultsCount": True, + "results": False, + } + + _attributes_to_types = { + "status": "str", + "adjusted": "bool", + "queryCount": "int", + "resultsCount": "int", + "results": "List[Aggv2]" + } + + def __init__(self): + self.status: str + self.adjusted: bool + self.queryCount: int + self.resultsCount: int + self.results: List[Aggv2] + + +# noinspection SpellCheckingInspection +class CryptoPreviousCloseApiResponse(Definition): + _swagger_name_to_python = { + "ticker": "ticker", + "status": "status", + "adjusted": "adjusted", + "queryCount": "queryCount", + "resultsCount": "resultsCount", + "results": "results", + } + + _attribute_is_primitive = { + "ticker": True, + "status": True, + "adjusted": True, + "queryCount": True, + "resultsCount": True, + "results": False, + } + + _attributes_to_types = { + "ticker": "str", + "status": "str", + "adjusted": "bool", + "queryCount": "int", + "resultsCount": "int", + "results": "List[Aggv2]" + } + + def __init__(self): + self.ticker: str + self.status: str + self.adjusted: bool + self.queryCount: int + self.resultsCount: int + self.results: List[Aggv2] + # noinspection SpellCheckingInspection class CryptoSnapshotAllTickersApiResponse(Definition): _swagger_name_to_python = { From a74614615a611e202a54549d7f1bdb09339dd70d Mon Sep 17 00:00:00 2001 From: suremarc Date: Thu, 29 Apr 2021 12:47:20 -0400 Subject: [PATCH 3/4] add fx previous close + grouped daily + single ticker snapshot api responses --- polygon/rest/models/__init__.py | 6 ++ polygon/rest/models/definitions.py | 94 ++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/polygon/rest/models/__init__.py b/polygon/rest/models/__init__.py index b48686f6..8afea378 100644 --- a/polygon/rest/models/__init__.py +++ b/polygon/rest/models/__init__.py @@ -81,7 +81,10 @@ from .definitions import ForexCurrenciesHistoricForexTicksApiResponse from .definitions import ForexCurrenciesRealTimeCurrencyConversionApiResponse from .definitions import ForexCurrenciesLastQuoteForACurrencyPairApiResponse +from. definitions import ForexCurrenciesGroupedDailyApiResponse +from .definitions import ForexCurrenciesPreviousCloseApiResponse from .definitions import ForexCurrenciesSnapshotAllTickersApiResponse +from .definitions import ForexCurrenciesSnapshotSingleTickerApiResponse from .definitions import ForexCurrenciesSnapshotGainersLosersApiResponse from .definitions import CryptoCryptoExchangesApiResponse from .definitions import CryptoLastTradeForACryptoPairApiResponse @@ -191,7 +194,10 @@ "ForexCurrenciesHistoricForexTicksApiResponse": ForexCurrenciesHistoricForexTicksApiResponse, "ForexCurrenciesRealTimeCurrencyConversionApiResponse": ForexCurrenciesRealTimeCurrencyConversionApiResponse, "ForexCurrenciesLastQuoteForACurrencyPairApiResponse": ForexCurrenciesLastQuoteForACurrencyPairApiResponse, + "ForexCurrenciesGroupedDailyApiResponse": ForexCurrenciesGroupedDailyApiResponse, + "ForexCurrenciesPreviousCloseApiResponse": ForexCurrenciesPreviousCloseApiResponse, "ForexCurrenciesSnapshotAllTickersApiResponse": ForexCurrenciesSnapshotAllTickersApiResponse, + "ForexCurrenciesSnapshotSingleTickerApiResponse": ForexCurrenciesSnapshotSingleTickerApiResponse, "ForexCurrenciesSnapshotGainersLosersApiResponse": ForexCurrenciesSnapshotGainersLosersApiResponse, "CryptoCryptoExchangesApiResponse": CryptoCryptoExchangesApiResponse, "CryptoLastTradeForACryptoPairApiResponse": CryptoLastTradeForACryptoPairApiResponse, diff --git a/polygon/rest/models/definitions.py b/polygon/rest/models/definitions.py index 51b9f85a..6a7d6690 100644 --- a/polygon/rest/models/definitions.py +++ b/polygon/rest/models/definitions.py @@ -3719,6 +3719,78 @@ def __init__(self): self.last: LastForexQuote +# noinspection SpellCheckingInspection +class ForexCurrenciesGroupedDailyApiResponse(Definition): + _swagger_name_to_python = { + "status": "status", + "adjusted": "adjusted", + "queryCount": "queryCount", + "resultsCount": "resultsCount", + "results": "results", + } + + _attribute_is_primitive = { + "status": True, + "adjusted": True, + "queryCount": True, + "resultsCount": True, + "results": False, + } + + _attributes_to_types = { + "status": "str", + "adjusted": "bool", + "queryCount": "int", + "resultsCount": "int", + "results": "List[Aggv2]" + } + + def __init__(self): + self.status: str + self.adjusted: bool + self.queryCount: int + self.resultsCount: int + self.results: List[Aggv2] + + +# noinspection SpellCheckingInspection +class ForexCurrenciesPreviousCloseApiResponse(Definition): + _swagger_name_to_python = { + "ticker": "ticker", + "status": "status", + "adjusted": "adjusted", + "queryCount": "queryCount", + "resultsCount": "resultsCount", + "results": "results", + } + + _attribute_is_primitive = { + "ticker": True, + "status": True, + "adjusted": True, + "queryCount": True, + "resultsCount": True, + "results": False, + } + + _attributes_to_types = { + "ticker": "str", + "status": "str", + "adjusted": "bool", + "queryCount": "int", + "resultsCount": "int", + "results": "List[Aggv2]" + } + + def __init__(self): + self.ticker: str + self.status: str + self.adjusted: bool + self.queryCount: int + self.resultsCount: int + self.results: List[Aggv2] + + # noinspection SpellCheckingInspection class ForexCurrenciesSnapshotAllTickersApiResponse(Definition): _swagger_name_to_python = { @@ -3744,6 +3816,28 @@ def __init__(self): self.tickers: List[ForexSnapshotTicker] +# noinspection SpellCheckingInspection +class ForexCurrenciesSnapshotSingleTickerApiResponse(Definition): + _swagger_name_to_python = { + "status": "status", + "ticker": "ticker", + } + + _attribute_is_primitive = { + "status": True, + "ticker": False, + } + + _attributes_to_types = { + "status": "str", + "ticker": "ForexSnapshotTicker", + } + + def __init__(self): + self.status: str + self.ticker: ForexSnapshotTicker + + # noinspection SpellCheckingInspection class ForexCurrenciesSnapshotGainersLosersApiResponse(Definition): _swagger_name_to_python = { From 36e9ba6eeb526043c0224ce2d9f15eff683ff2f4 Mon Sep 17 00:00:00 2001 From: suremarc Date: Thu, 29 Apr 2021 12:53:25 -0400 Subject: [PATCH 4/4] fix typo --- polygon/rest/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polygon/rest/client.py b/polygon/rest/client.py index 958ef43a..50a8f80d 100644 --- a/polygon/rest/client.py +++ b/polygon/rest/client.py @@ -232,7 +232,7 @@ def crypto_grouped_daily(self, date, **query_params) -> models.CryptoGroupedDail def crypto_previous_close(self, ticker, **query_params) -> models.CryptoPreviousCloseApiResponse: endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/prev" - return self._handle_response("CryptoPreviousClose", endpoint, query_params) + return self._handle_response("CryptoPreviousCloseApiResponse", endpoint, query_params) def crypto_snapshot_all_tickers(self, **query_params) -> models.CryptoSnapshotAllTickersApiResponse: endpoint = f"{self.url}/v2/snapshot/locale/global/markets/crypto/tickers"