hotfix/fmp-price-performance-zeros: Replace returned zero with None and normalize percent values. (#5918)

* replace zeros with none and normalize percents

* pylint unused argument
This commit is contained in:
Danglewood
2024-01-03 14:10:31 -08:00
committed by GitHub
parent c43100d209
commit fe63d40731

View File

@@ -1,5 +1,5 @@
"""FMP Price Performance Model."""
# pylint: disable=unused-argument
from typing import Any, Dict, List, Optional
from openbb_core.provider.abstract.fetcher import Fetcher
@@ -8,7 +8,7 @@ from openbb_core.provider.standard_models.recent_performance import (
RecentPerformanceQueryParams,
)
from openbb_fmp.utils.helpers import create_url, get_data_many
from pydantic import Field
from pydantic import Field, model_validator
class FMPPricePerformanceQueryParams(RecentPerformanceQueryParams):
@@ -35,6 +35,15 @@ class FMPPricePerformanceData(RecentPerformanceData):
"ten_year": "10Y",
}
@model_validator(mode="before")
@classmethod
def replace_zero(cls, values): # pylint: disable=no-self-argument
"""Replace zero with None and convert percents to normalized values."""
for k, v in values.items():
if k != "symbol":
values[k] = None if v == 0 else float(v) / 100
return values
class FMPPricePerformanceFetcher(
Fetcher[