Skip to content

Commit 3bbf778

Browse files
authored
Missing endpoints (#63)
* add endpoints in client * add crypto prev. close + grouped daily * add fx previous close + grouped daily + single ticker snapshot api responses
1 parent 27c4cc4 commit 3bbf778

File tree

3 files changed

+193
-6
lines changed

3 files changed

+193
-6
lines changed

polygon/rest/client.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,23 @@ def forex_currencies_last_quote_for_a_currency_pair(self, from_, to,
175175
**query_params) -> models.ForexCurrenciesLastQuoteForACurrencyPairApiResponse:
176176
endpoint = f"{self.url}/v1/last_quote/currencies/{from_}/{to}"
177177
return self._handle_response("ForexCurrenciesLastQuoteForACurrencyPairApiResponse", endpoint, query_params)
178+
179+
def forex_currencies_grouped_daily(self, date, **query_params) -> models.ForexCurrenciesGroupedDailyApiResponse:
180+
endpoint = f"{self.url}/v2/aggs/grouped/locale/global/market/fx/{date}"
181+
return self._handle_response("ForexCurrenciesGroupedDailyApiResponse", endpoint, query_params)
178182

179-
# FIXME: add daily open/close
180-
# FIXME: add grouped daily bars
181-
# FIXME: add previous close
182-
# FIXME: add snapshot for single ticker
183+
def forex_currencies_previous_close(self, ticker, **query_params) -> models.ForexCurrenciesGroupedDailyApiResponse:
184+
endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/prev"
185+
return self._handle_response("ForexCurrenciesPreviousCloseApiResponse", endpoint, query_params)
183186

184187
def forex_currencies_snapshot_all_tickers(self,
185188
**query_params) -> models.ForexCurrenciesSnapshotAllTickersApiResponse:
186189
endpoint = f"{self.url}/v2/snapshot/locale/global/markets/forex/tickers"
187190
return self._handle_response("ForexCurrenciesSnapshotAllTickersApiResponse", endpoint, query_params)
191+
192+
def forex_currencies_snapshot_single_ticker(self, ticker, **query_params) -> models.ForexCurrenciesSnapshotSingleTickerApiResponse:
193+
endpoint = f"{self.url}/v2/snapshot/locale/global/markets/forex/tickers/{ticker}"
194+
return self._handle_response("ForexCurrenciesSnapshotSingleTickerApiResponse", endpoint, query_params)
188195

189196
def forex_currencies_snapshot_gainers_losers(self, direction,
190197
**query_params) -> models.ForexCurrenciesSnapshotGainersLosersApiResponse:
@@ -219,8 +226,13 @@ def crypto_historic_crypto_trades(self, from_, to, date,
219226
endpoint = f"{self.url}/v1/historic/crypto/{from_}/{to}/{date}"
220227
return self._handle_response("CryptoHistoricCryptoTradesApiResponse", endpoint, query_params)
221228

222-
# FIXME: add grouped daily bars
223-
# FIXME: add previous close
229+
def crypto_grouped_daily(self, date, **query_params) -> models.CryptoGroupedDailyApiResponse:
230+
endpoint = f"{self.url}/v2/aggs/grouped/locale/global/market/crypto/{date}"
231+
return self._handle_response("CryptoGroupedDailyApiResponse", endpoint, query_params)
232+
233+
def crypto_previous_close(self, ticker, **query_params) -> models.CryptoPreviousCloseApiResponse:
234+
endpoint = f"{self.url}/v2/aggs/ticker/{ticker}/prev"
235+
return self._handle_response("CryptoPreviousCloseApiResponse", endpoint, query_params)
224236

225237
def crypto_snapshot_all_tickers(self, **query_params) -> models.CryptoSnapshotAllTickersApiResponse:
226238
endpoint = f"{self.url}/v2/snapshot/locale/global/markets/crypto/tickers"

polygon/rest/models/__init__.py

+10
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,17 @@
8181
from .definitions import ForexCurrenciesHistoricForexTicksApiResponse
8282
from .definitions import ForexCurrenciesRealTimeCurrencyConversionApiResponse
8383
from .definitions import ForexCurrenciesLastQuoteForACurrencyPairApiResponse
84+
from. definitions import ForexCurrenciesGroupedDailyApiResponse
85+
from .definitions import ForexCurrenciesPreviousCloseApiResponse
8486
from .definitions import ForexCurrenciesSnapshotAllTickersApiResponse
87+
from .definitions import ForexCurrenciesSnapshotSingleTickerApiResponse
8588
from .definitions import ForexCurrenciesSnapshotGainersLosersApiResponse
8689
from .definitions import CryptoCryptoExchangesApiResponse
8790
from .definitions import CryptoLastTradeForACryptoPairApiResponse
8891
from .definitions import CryptoDailyOpenCloseApiResponse
8992
from .definitions import CryptoHistoricCryptoTradesApiResponse
93+
from .definitions import CryptoGroupedDailyApiResponse
94+
from .definitions import CryptoPreviousCloseApiResponse
9095
from .definitions import CryptoSnapshotAllTickersApiResponse
9196
from .definitions import CryptoSnapshotSingleTickerApiResponse
9297
from .definitions import CryptoSnapshotSingleTickerFullBookApiResponse
@@ -189,12 +194,17 @@
189194
"ForexCurrenciesHistoricForexTicksApiResponse": ForexCurrenciesHistoricForexTicksApiResponse,
190195
"ForexCurrenciesRealTimeCurrencyConversionApiResponse": ForexCurrenciesRealTimeCurrencyConversionApiResponse,
191196
"ForexCurrenciesLastQuoteForACurrencyPairApiResponse": ForexCurrenciesLastQuoteForACurrencyPairApiResponse,
197+
"ForexCurrenciesGroupedDailyApiResponse": ForexCurrenciesGroupedDailyApiResponse,
198+
"ForexCurrenciesPreviousCloseApiResponse": ForexCurrenciesPreviousCloseApiResponse,
192199
"ForexCurrenciesSnapshotAllTickersApiResponse": ForexCurrenciesSnapshotAllTickersApiResponse,
200+
"ForexCurrenciesSnapshotSingleTickerApiResponse": ForexCurrenciesSnapshotSingleTickerApiResponse,
193201
"ForexCurrenciesSnapshotGainersLosersApiResponse": ForexCurrenciesSnapshotGainersLosersApiResponse,
194202
"CryptoCryptoExchangesApiResponse": CryptoCryptoExchangesApiResponse,
195203
"CryptoLastTradeForACryptoPairApiResponse": CryptoLastTradeForACryptoPairApiResponse,
196204
"CryptoDailyOpenCloseApiResponse": CryptoDailyOpenCloseApiResponse,
197205
"CryptoHistoricCryptoTradesApiResponse": CryptoHistoricCryptoTradesApiResponse,
206+
"CryptoGroupedDailyApiResponse": CryptoGroupedDailyApiResponse,
207+
"CryptoPreviousCloseApiResponse": CryptoPreviousCloseApiResponse,
198208
"CryptoSnapshotAllTickersApiResponse": CryptoSnapshotAllTickersApiResponse,
199209
"CryptoSnapshotSingleTickerApiResponse": CryptoSnapshotSingleTickerApiResponse,
200210
"CryptoSnapshotSingleTickerFullBookApiResponse": CryptoSnapshotSingleTickerFullBookApiResponse,

polygon/rest/models/definitions.py

+165
Original file line numberDiff line numberDiff line change
@@ -3719,6 +3719,78 @@ def __init__(self):
37193719
self.last: LastForexQuote
37203720

37213721

3722+
# noinspection SpellCheckingInspection
3723+
class ForexCurrenciesGroupedDailyApiResponse(Definition):
3724+
_swagger_name_to_python = {
3725+
"status": "status",
3726+
"adjusted": "adjusted",
3727+
"queryCount": "queryCount",
3728+
"resultsCount": "resultsCount",
3729+
"results": "results",
3730+
}
3731+
3732+
_attribute_is_primitive = {
3733+
"status": True,
3734+
"adjusted": True,
3735+
"queryCount": True,
3736+
"resultsCount": True,
3737+
"results": False,
3738+
}
3739+
3740+
_attributes_to_types = {
3741+
"status": "str",
3742+
"adjusted": "bool",
3743+
"queryCount": "int",
3744+
"resultsCount": "int",
3745+
"results": "List[Aggv2]"
3746+
}
3747+
3748+
def __init__(self):
3749+
self.status: str
3750+
self.adjusted: bool
3751+
self.queryCount: int
3752+
self.resultsCount: int
3753+
self.results: List[Aggv2]
3754+
3755+
3756+
# noinspection SpellCheckingInspection
3757+
class ForexCurrenciesPreviousCloseApiResponse(Definition):
3758+
_swagger_name_to_python = {
3759+
"ticker": "ticker",
3760+
"status": "status",
3761+
"adjusted": "adjusted",
3762+
"queryCount": "queryCount",
3763+
"resultsCount": "resultsCount",
3764+
"results": "results",
3765+
}
3766+
3767+
_attribute_is_primitive = {
3768+
"ticker": True,
3769+
"status": True,
3770+
"adjusted": True,
3771+
"queryCount": True,
3772+
"resultsCount": True,
3773+
"results": False,
3774+
}
3775+
3776+
_attributes_to_types = {
3777+
"ticker": "str",
3778+
"status": "str",
3779+
"adjusted": "bool",
3780+
"queryCount": "int",
3781+
"resultsCount": "int",
3782+
"results": "List[Aggv2]"
3783+
}
3784+
3785+
def __init__(self):
3786+
self.ticker: str
3787+
self.status: str
3788+
self.adjusted: bool
3789+
self.queryCount: int
3790+
self.resultsCount: int
3791+
self.results: List[Aggv2]
3792+
3793+
37223794
# noinspection SpellCheckingInspection
37233795
class ForexCurrenciesSnapshotAllTickersApiResponse(Definition):
37243796
_swagger_name_to_python = {
@@ -3744,6 +3816,28 @@ def __init__(self):
37443816
self.tickers: List[ForexSnapshotTicker]
37453817

37463818

3819+
# noinspection SpellCheckingInspection
3820+
class ForexCurrenciesSnapshotSingleTickerApiResponse(Definition):
3821+
_swagger_name_to_python = {
3822+
"status": "status",
3823+
"ticker": "ticker",
3824+
}
3825+
3826+
_attribute_is_primitive = {
3827+
"status": True,
3828+
"ticker": False,
3829+
}
3830+
3831+
_attributes_to_types = {
3832+
"status": "str",
3833+
"ticker": "ForexSnapshotTicker",
3834+
}
3835+
3836+
def __init__(self):
3837+
self.status: str
3838+
self.ticker: ForexSnapshotTicker
3839+
3840+
37473841
# noinspection SpellCheckingInspection
37483842
class ForexCurrenciesSnapshotGainersLosersApiResponse(Definition):
37493843
_swagger_name_to_python = {
@@ -3909,6 +4003,77 @@ def __init__(self):
39094003
self.ticks: List[CryptoTickJson]
39104004

39114005

4006+
# noinspection SpellCheckingInspection
4007+
class CryptoGroupedDailyApiResponse(Definition):
4008+
_swagger_name_to_python = {
4009+
"status": "status",
4010+
"adjusted": "adjusted",
4011+
"queryCount": "queryCount",
4012+
"resultsCount": "resultsCount",
4013+
"results": "results",
4014+
}
4015+
4016+
_attribute_is_primitive = {
4017+
"status": True,
4018+
"adjusted": True,
4019+
"queryCount": True,
4020+
"resultsCount": True,
4021+
"results": False,
4022+
}
4023+
4024+
_attributes_to_types = {
4025+
"status": "str",
4026+
"adjusted": "bool",
4027+
"queryCount": "int",
4028+
"resultsCount": "int",
4029+
"results": "List[Aggv2]"
4030+
}
4031+
4032+
def __init__(self):
4033+
self.status: str
4034+
self.adjusted: bool
4035+
self.queryCount: int
4036+
self.resultsCount: int
4037+
self.results: List[Aggv2]
4038+
4039+
4040+
# noinspection SpellCheckingInspection
4041+
class CryptoPreviousCloseApiResponse(Definition):
4042+
_swagger_name_to_python = {
4043+
"ticker": "ticker",
4044+
"status": "status",
4045+
"adjusted": "adjusted",
4046+
"queryCount": "queryCount",
4047+
"resultsCount": "resultsCount",
4048+
"results": "results",
4049+
}
4050+
4051+
_attribute_is_primitive = {
4052+
"ticker": True,
4053+
"status": True,
4054+
"adjusted": True,
4055+
"queryCount": True,
4056+
"resultsCount": True,
4057+
"results": False,
4058+
}
4059+
4060+
_attributes_to_types = {
4061+
"ticker": "str",
4062+
"status": "str",
4063+
"adjusted": "bool",
4064+
"queryCount": "int",
4065+
"resultsCount": "int",
4066+
"results": "List[Aggv2]"
4067+
}
4068+
4069+
def __init__(self):
4070+
self.ticker: str
4071+
self.status: str
4072+
self.adjusted: bool
4073+
self.queryCount: int
4074+
self.resultsCount: int
4075+
self.results: List[Aggv2]
4076+
39124077
# noinspection SpellCheckingInspection
39134078
class CryptoSnapshotAllTickersApiResponse(Definition):
39144079
_swagger_name_to_python = {

0 commit comments

Comments
 (0)