Skip to content
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

Param handling #348

Merged
merged 11 commits into from
Dec 13, 2022
5 changes: 0 additions & 5 deletions polygon/rest/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ def _get(
raw: bool = False,
options: Optional[RequestOptionBuilder] = None,
) -> Any:
if params is None:
params = {}
params = {str(k): str(v) for k, v in params.items() if v is not None}
logger.debug("_get %s params %s", path, params)

antdjohns marked this conversation as resolved.
Show resolved Hide resolved
option = options if options is not None else RequestOptionBuilder()

resp = self.client.request(
Expand Down
9 changes: 3 additions & 6 deletions polygon/rest/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_real_time_currency_conversion(
self,
from_: str,
to: str,
amount: float,
amount: Optional[float] = None,
antdjohns marked this conversation as resolved.
Show resolved Hide resolved
precision: Union[int, Precision] = 2,
params: Optional[Dict[str, Any]] = None,
raw: bool = False,
Expand All @@ -133,13 +133,10 @@ def get_real_time_currency_conversion(
:return: Real-Time Currency Conversion
"""
url = f"/v1/conversion/{from_}/{to}"
if params is None:
params = {}
params["amount"] = amount
params["precision"] = precision

return self._get(
path=url,
params=params,
params=self._get_params(self.get_real_time_currency_conversion, locals()),
deserializer=RealTimeCurrencyConversion.from_dict,
raw=raw,
options=options,
Expand Down
9 changes: 5 additions & 4 deletions polygon/rest/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def get_ticker_details(

def get_ticker_events(
self,
ticker: Optional[str] = None,
ticker: str,
types: Optional[str] = None,
params: Optional[Dict[str, Any]] = None,
raw: bool = False,
options: Optional[RequestOptionBuilder] = None,
Expand All @@ -169,7 +170,7 @@ def get_ticker_events(

return self._get(
path=url,
params=params,
params=self._get_params(self.get_ticker_events, locals()),
deserializer=TickerChangeResults.from_dict,
result_key="results",
raw=raw,
Expand Down Expand Up @@ -238,7 +239,7 @@ def get_ticker_types(

return self._get(
path=url,
params=params,
params=self._get_params(self.get_ticker_types, locals()),
deserializer=TickerTypes.from_dict,
raw=raw,
result_key="results",
Expand Down Expand Up @@ -451,7 +452,7 @@ def get_exchanges(

return self._get(
path=url,
params=params,
params=self._get_params(self.get_exchanges, locals()),
deserializer=Exchange.from_dict,
raw=raw,
result_key="results",
Expand Down
2 changes: 1 addition & 1 deletion test_rest/test_tickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_get_ticker_types(self):
self.assertEqual(types, expected)

def test_get_ticker_events_ticker_change(self):
events = self.c.get_ticker_events(ticker="META")
events = self.c.get_ticker_events(ticker="META", types="ticker_change")
expected = TickerChangeResults(
name="Meta Platforms, Inc. Class A Common Stock",
figi="BBG000MM2P62",
Expand Down