summaryrefslogtreecommitdiffstats
path: root/openbb_platform/providers/yfinance/openbb_yfinance/models/price_target_consensus.py
diff options
context:
space:
mode:
Diffstat (limited to 'openbb_platform/providers/yfinance/openbb_yfinance/models/price_target_consensus.py')
-rw-r--r--openbb_platform/providers/yfinance/openbb_yfinance/models/price_target_consensus.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/openbb_platform/providers/yfinance/openbb_yfinance/models/price_target_consensus.py b/openbb_platform/providers/yfinance/openbb_yfinance/models/price_target_consensus.py
index a412f210dae..15d628580fd 100644
--- a/openbb_platform/providers/yfinance/openbb_yfinance/models/price_target_consensus.py
+++ b/openbb_platform/providers/yfinance/openbb_yfinance/models/price_target_consensus.py
@@ -10,7 +10,7 @@ from openbb_core.provider.standard_models.price_target_consensus import (
PriceTargetConsensusData,
PriceTargetConsensusQueryParams,
)
-from pydantic import Field
+from pydantic import Field, field_validator
from yfinance import Ticker
_warn = warnings.warn
@@ -21,6 +21,14 @@ class YFinancePriceTargetConsensusQueryParams(PriceTargetConsensusQueryParams):
__json_schema_extra__ = {"symbol": ["multiple_items_allowed"]}
+ @field_validator("symbol", mode="before", check_fields=False)
+ @classmethod
+ def check_symbol(cls, value):
+ """Check the symbol."""
+ if not value:
+ raise RuntimeError("Error: Symbol is a required field for yFinance.")
+ return value
+
class YFinancePriceTargetConsensusData(PriceTargetConsensusData):
"""YFinance Price Target Consensus Data."""
@@ -78,7 +86,7 @@ class YFinancePriceTargetConsensusFetcher(
**kwargs: Any,
) -> List[Dict]:
"""Extract the raw data from YFinance."""
- symbols = query.symbol.split(",")
+ symbols = query.symbol.split(",") # type: ignore
results = []
fields = [
"symbol",