diff --git a/openbb_sdk/providers/cboe/openbb_cboe/models/european_index_historical.py b/openbb_sdk/providers/cboe/openbb_cboe/models/european_index_historical.py index e289f000561..ea41ba78843 100644 --- a/openbb_sdk/providers/cboe/openbb_cboe/models/european_index_historical.py +++ b/openbb_sdk/providers/cboe/openbb_cboe/models/european_index_historical.py @@ -43,10 +43,10 @@ class CboeEuropeanIndexHistoricalData(EuropeanIndexHistoricalData): description="UTC datetime. Only valid when interval is 1m." ) - @validator("close", pre=True, check_fields=False) + @validator("date", pre=True, check_fields=False) def date_validate(cls, v): # pylint: disable=E0213 - """Return the datetime object from the date string""" - return float(v) + """Return datetime object from string.""" + return datetime.strptime(v, "%Y-%m-%d") class CboeEuropeanIndexHistoricalFetcher( diff --git a/openbb_sdk/providers/cboe/openbb_cboe/models/major_indices_historical.py b/openbb_sdk/providers/cboe/openbb_cboe/models/major_indices_historical.py index f7a0f9060a8..86c7a910e59 100644 --- a/openbb_sdk/providers/cboe/openbb_cboe/models/major_indices_historical.py +++ b/openbb_sdk/providers/cboe/openbb_cboe/models/major_indices_historical.py @@ -10,7 +10,7 @@ from openbb_provider.standard_models.major_indices_historical import ( MajorIndicesHistoricalQueryParams, ) from openbb_provider.utils.helpers import make_request -from pydantic import Field +from pydantic import Field, validator from openbb_cboe.utils.helpers import ( TICKER_EXCEPTIONS, @@ -44,6 +44,11 @@ class CboeMajorIndicesHistoricalData(MajorIndicesHistoricalData): description="Total number of options traded during the most recent trading period. Only valid if interval is 1m." ) + @validator("date", pre=True, check_fields=False) + def date_validate(cls, v): # pylint: disable=E0213 + """Return datetime object from string.""" + return datetime.strptime(v, "%Y-%m-%d") + class CboeMajorIndicesHistoricalFetcher( Fetcher[ diff --git a/openbb_sdk/providers/cboe/openbb_cboe/models/stock_historical.py b/openbb_sdk/providers/cboe/openbb_cboe/models/stock_historical.py index 8d91be12e83..54c5d722c7f 100644 --- a/openbb_sdk/providers/cboe/openbb_cboe/models/stock_historical.py +++ b/openbb_sdk/providers/cboe/openbb_cboe/models/stock_historical.py @@ -10,7 +10,7 @@ from openbb_provider.standard_models.stock_historical import ( StockHistoricalQueryParams, ) from openbb_provider.utils.helpers import make_request -from pydantic import Field +from pydantic import Field, validator from openbb_cboe.utils.helpers import ( TICKER_EXCEPTIONS, @@ -45,6 +45,11 @@ class CboeStockHistoricalData(StockHistoricalData): description="Total number of options traded during the most recent trading period. Only valid if interval is 1m." ) + @validator("date", pre=True, check_fields=False) + def date_validate(cls, v): # pylint: disable=E0213 + """Return datetime object from string.""" + return datetime.strptime(v, "%Y-%m-%d") + class CboeStockHistoricalFetcher( Fetcher[ diff --git a/openbb_sdk/providers/cboe/openbb_cboe/utils/helpers.py b/openbb_sdk/providers/cboe/openbb_cboe/utils/helpers.py index b3b0341b890..00f79a67810 100644 --- a/openbb_sdk/providers/cboe/openbb_cboe/utils/helpers.py +++ b/openbb_sdk/providers/cboe/openbb_cboe/utils/helpers.py @@ -159,11 +159,11 @@ def get_cboe_index_directory(**kwargs) -> pd.DataFrame: return CBOE_INDEXES[idx] -def get_ticker_info(symbol: str, **kwargs) -> dict[str, Any]: +def get_ticker_info(symbol: str, **kwargs) -> Dict[str, Any]: symbol = symbol.upper() SYMBOLS = get_cboe_directory() INDEXES = get_cboe_index_directory() - data: dict[str, Any] = {} + data: Dict[str, Any] = {} if symbol not in SYMBOLS.index and symbol not in INDEXES.index: raise RuntimeError(f"Data not found for: {symbol}") @@ -205,7 +205,7 @@ def get_ticker_info(symbol: str, **kwargs) -> dict[str, Any]: return _data.transpose()[0].to_dict() -def get_ticker_iv(symbol: str, **kwargs) -> dict[str, float]: +def get_ticker_iv(symbol: str, **kwargs) -> Dict[str, float]: """Get annualized high/low historical and implied volatility over 30/60/90 day windows. Parameters @@ -333,12 +333,12 @@ class Europe: """Class for European CBOE data.""" @staticmethod - def get_all_index_definitions(**kwargs) -> dict[Any, Any]: + def get_all_index_definitions(**kwargs) -> Dict[Any, Any]: """Get the full list of European index definitions. Returns ------- - dict[Any, Any] + Dict[Any, Any] Dictionary with results. """ @@ -357,7 +357,7 @@ class Europe: Returns ------- - dict[str, str] + Dict[str, str] List of dictionaries with the results. """ diff --git a/openbb_sdk/sdk/provider/openbb_provider/standard_models/european_index_historical.py b/openbb_sdk/sdk/provider/openbb_provider/standard_models/european_index_historical.py index 4d28832308b..bc07094e5b3 100644 --- a/openbb_sdk/sdk/provider/openbb_provider/standard_models/european_index_historical.py +++ b/openbb_sdk/sdk/provider/openbb_provider/standard_models/european_index_historical.py @@ -29,5 +29,5 @@ class EuropeanIndexHistoricalQueryParams(QueryParams, BaseSymbol): class EuropeanIndexHistoricalData(Data): """European Indices end of day price data.""" - date: dateType | datetime = Field(description=DATA_DESCRIPTIONS.get("date", "")) + date: datetime = Field(description=DATA_DESCRIPTIONS.get("date", "")) close: float = Field(description=DATA_DESCRIPTIONS.get("close", ""))