Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone authored Nov 25, 2024
2 parents 6aa86c5 + 23c8780 commit dbe3fe0
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions openbb_platform/providers/fmp/openbb_fmp/models/equity_peers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""FMP Equity Peers Model."""

from typing import Any, Dict, Optional
# pylint: disable=unused-argument

from typing import Any, Optional

from openbb_core.provider.abstract.fetcher import Fetcher
from openbb_core.provider.standard_models.equity_peers import (
EquityPeersData,
EquityPeersQueryParams,
)
from openbb_fmp.utils.helpers import create_url, get_data_one


class FMPEquityPeersQueryParams(EquityPeersQueryParams):
Expand All @@ -27,20 +28,23 @@ class FMPEquityPeersFetcher(
FMPEquityPeersData,
]
):
"""Transform the query, extract and transform the data from the FMP endpoints."""
"""FMP Equity Peers Fetcher."""

@staticmethod
def transform_query(params: Dict[str, Any]) -> FMPEquityPeersQueryParams:
def transform_query(params: dict[str, Any]) -> FMPEquityPeersQueryParams:
"""Transform the query params."""
return FMPEquityPeersQueryParams(**params)

@staticmethod
async def aextract_data(
query: FMPEquityPeersQueryParams,
credentials: Optional[Dict[str, str]],
credentials: Optional[dict[str, str]],
**kwargs: Any,
) -> Dict:
) -> dict:
"""Return the raw data from the FMP endpoint."""
# pylint: disable=import-outside-toplevel
from openbb_fmp.utils.helpers import create_url, get_data_one

api_key = credentials.get("fmp_api_key") if credentials else ""
url = create_url(4, "stock_peers", api_key, query)

Expand All @@ -51,5 +55,8 @@ def transform_data(
query: FMPEquityPeersQueryParams, data: dict, **kwargs: Any
) -> FMPEquityPeersData:
"""Return the transformed data."""
data.pop("symbol", None)
_ = data.pop("symbol", None)
peers: list = [d for d in data.get("peersList", []) if d]
data["peersList"] = peers

return FMPEquityPeersData.model_validate(data)

0 comments on commit dbe3fe0

Please sign in to comment.