Skip to content

Commit

Permalink
Introduces a limit argument for the `equity.fundamental.trailing_divi…
Browse files Browse the repository at this point in the history
…dend_yield` endpoint (#5925)

* introduces a limit argument for the equity.fundamental.trailing_dividend_yield endpoint

* add default args to test
  • Loading branch information
hjoaquim authored Jan 8, 2024
1 parent f79f50a commit bae3388
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


from datetime import date as dateType
from typing import Optional

from pydantic import Field

Expand All @@ -17,6 +18,11 @@ class TrailingDivYieldQueryParams(QueryParams):
"""Trailing Dividend Yield Query."""

symbol: str = Field(default=None, description=QUERY_DESCRIPTIONS.get("symbol", ""))
limit: Optional[int] = Field(
default=252,
description=f"{QUERY_DESCRIPTIONS.get('limit', '')}"
" Default is 252, the number of trading days in a year.",
)


class TrailingDivYieldData(Data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ def test_equity_fundamental_historical_eps(params, headers):

@parametrize(
"params",
[({"provider": "tiingo", "symbol": "AAPL"})],
[({"provider": "tiingo", "symbol": "AAPL", "limit": 10})],
)
@pytest.mark.integration
def test_equity_fundamental_trailing_dividend_yield(params, headers):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ def test_equity_fundamental_historical_eps(params, obb):

@parametrize(
"params",
[({"provider": "tiingo", "symbol": "AAPL"})],
[({"provider": "tiingo", "symbol": "AAPL", "limit": 10})],
)
@pytest.mark.integration
def test_equity_fundamental_trailing_dividend_yield(params, obb):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def transform_query(params: Dict[str, Any]) -> TiingoTrailingDivYieldQueryParams
transformed_params = params
return TiingoTrailingDivYieldQueryParams(**transformed_params)

# pylint: disable=protected-access
# pylint: disable=unused-argument
@staticmethod
def extract_data(
query: TiingoTrailingDivYieldQueryParams,
Expand All @@ -60,4 +60,5 @@ def transform_data(
**kwargs: Any,
) -> List[TiingoTrailingDivYieldData]:
"""Return the transformed data."""
data = data[-query.limit :] if query.limit else data
return [TiingoTrailingDivYieldData.model_validate(d) for d in data]

0 comments on commit bae3388

Please sign in to comment.