diff options
author | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-01-22 07:17:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 15:17:42 +0000 |
commit | e2f7e597fa51cbadc143a42e7955e3840ae3badd (patch) | |
tree | b8e307c14c9e776e542a60dbd0a5c8790869bf6a | |
parent | a9b4d2070faab977e9784a457afc195fc1a513e2 (diff) |
feature/cboe-async: Refactor Cboe for Async (#5900)
* refactor cboe for async
* codespell
* unused imports
* pylint
* more pylint
* platform metadata
* classmethod decorator
* test params
* intrinio quote
* test param names
* date in test needs to be a datetime.date not string
* make fmp unix timestamp tz-aware and normalize percent change
* different way of parsing datetime string
* recapture cboe equity historical test
* unused import
* index snapshot update
* black
* extension map
* pylint
* cboe pyproject.toml
* proposal to standardize equity_quote
* one more file
* removing changes on static assets
* index_historical
* index_historical again
* last_time -> last_timestamp
* obsolete router path
* fix tests
* test param
* restore market index deprecation that I forgot about
* fixing tests
---------
Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
54 files changed, 17524 insertions, 18361 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/equity_historical.py b/openbb_platform/core/openbb_core/provider/standard_models/equity_historical.py index 1b2bf5e8b0f..d7463769c7c 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/equity_historical.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/equity_historical.py @@ -8,7 +8,7 @@ from datetime import ( from typing import List, Optional, Set, Union from dateutil import parser -from pydantic import Field, PositiveFloat, field_validator +from pydantic import Field, field_validator from openbb_core.provider.abstract.data import Data from openbb_core.provider.abstract.query_params import QueryParams @@ -47,17 +47,24 @@ class EquityHistoricalQueryParams(QueryParams): class EquityHistoricalData(Data): """Equity Historical Price Data.""" - date: datetime = Field(description=DATA_DESCRIPTIONS.get("date", "")) - open: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("open", "")) - high: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("high", "")) - low: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("low", "")) - close: PositiveFloat = Field(description=DATA_DESCRIPTIONS.get("close", "")) - volume: Union[float, int] = Field(description=DATA_DESCRIPTIONS.get("volume", "")) - vwap: Optional[PositiveFloat] = Field( + date: Union[dateType, datetime] = Field( + description=DATA_DESCRIPTIONS.get("date", "") + ) + open: float = Field(description=DATA_DESCRIPTIONS.get("open", "")) + high: float = Field(description=DATA_DESCRIPTIONS.get("high", "")) + low: float = Field(description=DATA_DESCRIPTIONS.get("low", "")) + close: float = Field(description=DATA_DESCRIPTIONS.get("close", "")) + volume: Optional[Union[float, int]] = Field( + default=None, description=DATA_DESCRIPTIONS.get("volume", "") + ) + vwap: Optional[float] = Field( default=None, description=DATA_DESCRIPTIONS.get("vwap", "") ) @field_validator("date", mode="before", check_fields=False) def date_validate(cls, v): # pylint: disable=E0213 """Return formatted datetime.""" - return parser.isoparse(str(v)) + v = parser.isoparse(str(v)) + if v.hour == 0 and v.minute == 0: + return v.date() + return v diff --git a/openbb_platform/core/openbb_core/provider/standard_models/european_index_constituents.py b/openbb_platform/core/openbb_core/provider/standard_models/european_index_constituents.py deleted file mode 100644 index 94c00eff908..00000000000 --- a/openbb_platform/core/openbb_core/provider/standard_models/european_index_constituents.py +++ /dev/null @@ -1,50 +0,0 @@ -"""European Index Constituents Standard Model.""" - - -from typing import List, Set, Union - -from pydantic import Field, field_validator - -from openbb_core.provider.abstract.data import Data -from openbb_core.provider.abstract.query_params import QueryParams -from openbb_core.provider.utils.descriptions import ( - DATA_DESCRIPTIONS, - QUERY_DESCRIPTIONS, -) - - -class EuropeanIndexConstituentsQueryParams(QueryParams): - """European Index Constituents Query.""" - - symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) - - @field_validator("symbol", mode="before", check_fields=False) - def upper_symbol(cls, v: Union[str, List[str], Set[str]]): - """Convert symbol to uppercase.""" - if isinstance(v, str): - return v.upper() - return ",".join([symbol.upper() for symbol in list(v)]) - - -class EuropeanIndexConstituentsData(Data): - """European Index Constituents Data.""" - - symbol: str = Field( - description=DATA_DESCRIPTIONS.get("symbol", "") - + " The symbol is the constituent company in the index." - ) - price: float = Field( - description="Current price of the constituent company in the index." - ) - open: float = Field(description=DATA_DESCRIPTIONS.get("open", "")) - high: float = Field(description=DATA_DESCRIPTIONS.get("high", "")) - low: float = Field(description=DATA_DESCRIPTIONS.get("low", "")) - close: float = Field(description=DATA_DESCRIPTIONS.get("close", "")) - volume: float = Field(description=DATA_DESCRIPTIONS.get("volume", "")) - - @field_validator("symbol", mode="before", check_fields=False) - def upper_symbol(cls, v: Union[str, List[str], Set[str]]): - """Convert symbol to uppercase.""" - if isinstance(v, str): - return v.upper() - return ",".join([symbol.upper() for symbol in list(v)]) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/european_indices.py b/openbb_platform/core/openbb_core/provider/standard_models/european_indices.py deleted file mode 100644 index aef7d5f7f4f..00000000000 --- a/openbb_platform/core/openbb_core/provider/standard_models/european_indices.py +++ /dev/null @@ -1,44 +0,0 @@ -"""European Indices Standard Model.""" - - -from datetime import ( - date as dateType, - datetime, -) -from typing import List, Optional, Set, Union - -from pydantic import Field, field_validator - -from openbb_core.provider.abstract.data import Data -from openbb_core.provider.abstract.query_params import QueryParams -from openbb_core.provider.utils.descriptions import ( - DATA_DESCRIPTIONS, - QUERY_DESCRIPTIONS, -) - - -class EuropeanIndicesQueryParams(QueryParams): - """European Indices Query.""" - - symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) - start_date: Optional[dateType] = Field( - description=QUERY_DESCRIPTIONS.get("start_date", ""), default=None - ) - end_date: Optional[dateType] = Field( - description=QUERY_DESCRIPTIONS.get("end_date", ""), default=None - ) - - @field_validator("symbol", mode="before", check_fields=False) - @classmethod - def upper_symbol(cls, v: Union[str, List[str], Set[str]]): - """Convert symbol to uppercase.""" - if isinstance(v, str): - return v.upper() - return ",".join([symbol.upper() for symbol in list(v)]) - - -class EuropeanIndicesData(Data): - """European Indices Data.""" - - date: datetime = Field(description=DATA_DESCRIPTIONS.get("date", "")) - close: float = Field(description=DATA_DESCRIPTIONS.get("close", "")) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/index_constituents.py b/openbb_platform/core/openbb_core/provider/standard_models/index_constituents.py index 8b336eebc03..a29ca427c95 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/index_constituents.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/index_constituents.py @@ -1,8 +1,7 @@ """Index Constituents Standard Model.""" -from datetime import date -from typing import List, Literal, Optional, Set, Union +from typing import List, Optional, Set, Union from pydantic import Field, field_validator @@ -14,9 +13,8 @@ from openbb_core.provider.utils.descriptions import DATA_DESCRIPTIONS class IndexConstituentsQueryParams(QueryParams): """Index Constituents Query.""" - index: Literal["nasdaq", "sp500", "dowjones"] = Field( - default="dowjones", - description="Index for which we want to fetch the constituents.", + index: str = Field( + description="Index to fetch the constituents of.", ) @@ -24,27 +22,8 @@ class IndexConstituentsData(Data): """Index Constituents Data.""" symbol: str = Field(description=DATA_DESCRIPTIONS.get("symbol", "")) - name: str = Field(description="Name of the constituent company in the index.") - sector: str = Field( - description="Sector the constituent company in the index belongs to." - ) - sub_sector: Optional[str] = Field( - default=None, - description="Sub-sector the constituent company in the index belongs to.", - ) - headquarter: Optional[str] = Field( - default=None, - description="Location of the headquarter of the constituent company in the index.", - ) - date_first_added: Optional[Union[date, str]] = Field( - default=None, description="Date the constituent company was added to the index." - ) - cik: int = Field( - description=DATA_DESCRIPTIONS.get("cik", ""), - ) - founded: Optional[Union[date, str]] = Field( - default=None, - description="Founding year of the constituent company in the index.", + name: Optional[str] = Field( + default=None, description="Name of the constituent company in the index." ) @field_validator("symbol", mode="before", check_fields=False) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/index_snapshots.py b/openbb_platform/core/openbb_core/provider/standard_models/index_snapshots.py index bf5fac3a991..faba0cf1f4c 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/index_snapshots.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/index_snapshots.py @@ -1,6 +1,6 @@ """Index Snapshots Standard Model.""" -from typing import Literal, Optional +from typing import Optional from pydantic import Field @@ -12,8 +12,8 @@ from openbb_core.provider.utils.descriptions import DATA_DESCRIPTIONS class IndexSnapshotsQueryParams(QueryParams): """Index Snapshots Query.""" - region: Optional[Literal["US", "EU"]] = Field( - description="The region to return. Currently supports US and EU.", default="US" + region: Optional[str] = Field( + default=None, description="The region to return data for - i.e. 'us' or 'eu'." ) @@ -38,10 +38,16 @@ class IndexSnapshotsData(Data): close: Optional[float] = Field( default=None, description=DATA_DESCRIPTIONS.get("close", "") ) + volume: Optional[int] = Field( + default=None, description=DATA_DESCRIPTIONS.get("volume", "") + ) prev_close: Optional[float] = Field( - default=None, description="Previous closing price of the index." + default=None, description=DATA_DESCRIPTIONS.get("prev_close", "") + ) + change: Optional[float] = Field( + default=None, description="Change in value of the index." ) - change: Optional[float] = Field(default=None, description="Change of the index.") change_percent: Optional[float] = Field( - default=None, description="Change percent of the index." + default=None, + description="Change, in normalized percentage points, of the index.", ) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/options_chains.py b/openbb_platform/core/openbb_core/provider/standard_models/options_chains.py index 6eec3e1bbe1..a0a9ef7e25b 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/options_chains.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/options_chains.py @@ -1,6 +1,9 @@ """Options Chains Standard Model.""" -from datetime import date as dateType +from datetime import ( + date as dateType, + datetime, +) from typing import List, Optional, Set, Union from pydantic im |