summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanglewood <85772166+deeleeramone@users.noreply.github.com>2024-01-03 14:10:31 -0800
committerGitHub <noreply@github.com>2024-01-03 22:10:31 +0000
commitfe63d40731c27ce2be2a89f63dbeee253c66350f (patch)
tree912dd7e25d1d59234a57753c48fefff7ddf5b842
parentc43100d209296b6d03569a82bdb45abe003593fa (diff)
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
-rw-r--r--openbb_platform/providers/fmp/openbb_fmp/models/price_performance.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/openbb_platform/providers/fmp/openbb_fmp/models/price_performance.py b/openbb_platform/providers/fmp/openbb_fmp/models/price_performance.py
index 584cc774bfb..3146cc4d6e0 100644
--- a/openbb_platform/providers/fmp/openbb_fmp/models/price_performance.py
+++ b/openbb_platform/providers/fmp/openbb_fmp/models/price_performance.py
@@ -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[