mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-01 15:01:18 +00:00
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:
@@ -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[
|
||||
|
||||
Reference in New Issue
Block a user