fix cboe bugs

This commit is contained in:
montezdesousa
2023-09-05 14:33:53 +01:00
parent fcb03ddeee
commit 558cc0c916
5 changed files with 22 additions and 12 deletions

View File

@@ -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(

View File

@@ -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[

View File

@@ -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[

View File

@@ -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.
"""

View File

@@ -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", ""))