From d2c080c5b554b0c57c5ff88e688ca99201c7b09b Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Tue, 10 Oct 2023 16:59:10 +0530 Subject: [PATCH 1/9] add multithreading --- .../openbb_intrinio/models/options_chains.py | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py index 57668d26c64a..50529dabcfd7 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py @@ -1,9 +1,12 @@ """Intrinio Options Chains fetcher.""" +from concurrent.futures import ThreadPoolExecutor from datetime import ( + date as dateType, datetime, timedelta, ) +from itertools import repeat from typing import Any, Dict, List, Optional from openbb_intrinio.utils.helpers import get_data_many @@ -22,7 +25,7 @@ class IntrinioOptionsChainsQueryParams(OptionsChainsQueryParams): source: https://docs.intrinio.com/documentation/web_api/get_options_chain_eod_v2 """ - date: Optional[str] = Field( + date: Optional[dateType] = Field( description="Date for which the options chains are returned." ) @@ -38,12 +41,11 @@ def date_validate(cls, v): # pylint: disable=E0213 return datetime.strptime(v, "%Y-%m-%d") -def get_weekday(date: str) -> str: +def get_weekday(date: dateType) -> str: """Return the weekday date.""" - strptime = datetime.strptime(date, "%Y-%m-%d") - if strptime.weekday() in [5, 6]: - date = (strptime - timedelta(days=strptime.weekday() - 4)).strftime("%Y-%m-%d") - return date + if date.weekday() in [5, 6]: + return (date - timedelta(days=date.weekday() - 4)).strftime("%Y-%m-%d") + return date.strftime("%Y-%m-%d") class IntrinioOptionsChainsFetcher( @@ -70,11 +72,13 @@ def extract_data( ) -> List[Dict]: """Return the raw data from the Intrinio endpoint.""" api_key = credentials.get("intrinio_api_key") if credentials else "" - base_url = "https://api-v2.intrinio.com/options" if query.symbol in TICKER_EXCEPTIONS: query.symbol = f"${query.symbol}" + data: List = [] + base_url = "https://api-v2.intrinio.com/options" + def get_expirations(date: str) -> List[str]: """Return the expirations for the given date.""" url = ( @@ -83,23 +87,29 @@ def get_expirations(date: str) -> List[str]: ) return get_data_many(url, "expirations", **kwargs) - def get_data(expirations: List[str]) -> List[Dict]: + def get_options_chains( + expiration: str, data: List[IntrinioOptionsChainsData] + ) -> None: """Return the data for the given expiration.""" - data = [] - for expiration in expirations: - url = ( - f"{base_url}/chain/{query.symbol}/{expiration}/eod?" - f"date={query.date}&api_key={api_key}" - ) - response = get_data_many(url, "chain", **kwargs) - data.extend(response) - - return data - - if len(data := get_data(get_expirations(get_weekday(query.date)))) == 0: - data = get_data( - get_expirations(get_weekday(query.date - timedelta(days=1))) + url = ( + f"{base_url}/chain/{query.symbol}/{expiration}/eod?" + f"date={query.date}&api_key={api_key}" ) + response = get_data_many(url, "chain", **kwargs) + data.extend(response) + + def get_data(date: str) -> None: + """Fetch data for a given date using ThreadPoolExecutor.""" + expirations = get_expirations(date) + with ThreadPoolExecutor() as executor: + executor.map(get_options_chains, expirations, repeat(data)) + + date = get_weekday(query.date) + get_data(date) + + if not data: + date = get_weekday(query.date - timedelta(days=1)) + get_data(date) return data From 40ba9486e8622427de75c4c3dd7f1efea147afdf Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Tue, 10 Oct 2023 17:03:21 +0530 Subject: [PATCH 2/9] cleanup --- .../openbb_intrinio/models/options_chains.py | 24 ++++++------------- .../intrinio/openbb_intrinio/utils/helpers.py | 8 +++++++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py index 50529dabcfd7..2fcb98b4de2c 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py @@ -9,7 +9,7 @@ from itertools import repeat from typing import Any, Dict, List, Optional -from openbb_intrinio.utils.helpers import get_data_many +from openbb_intrinio.utils.helpers import get_data_many, get_weekday from openbb_intrinio.utils.references import TICKER_EXCEPTIONS from openbb_provider.abstract.fetcher import Fetcher from openbb_provider.standard_models.options_chains import ( @@ -41,13 +41,6 @@ def date_validate(cls, v): # pylint: disable=E0213 return datetime.strptime(v, "%Y-%m-%d") -def get_weekday(date: dateType) -> str: - """Return the weekday date.""" - if date.weekday() in [5, 6]: - return (date - timedelta(days=date.weekday() - 4)).strftime("%Y-%m-%d") - return date.strftime("%Y-%m-%d") - - class IntrinioOptionsChainsFetcher( Fetcher[IntrinioOptionsChainsQueryParams, List[IntrinioOptionsChainsData]] ): @@ -79,14 +72,6 @@ def extract_data( data: List = [] base_url = "https://api-v2.intrinio.com/options" - def get_expirations(date: str) -> List[str]: - """Return the expirations for the given date.""" - url = ( - f"{base_url}/expirations/{query.symbol}/eod?" - f"after={date}&api_key={api_key}" - ) - return get_data_many(url, "expirations", **kwargs) - def get_options_chains( expiration: str, data: List[IntrinioOptionsChainsData] ) -> None: @@ -100,7 +85,12 @@ def get_options_chains( def get_data(date: str) -> None: """Fetch data for a given date using ThreadPoolExecutor.""" - expirations = get_expirations(date) + url = ( + f"{base_url}/expirations/{query.symbol}/eod?" + f"after={date}&api_key={api_key}" + ) + expirations = get_data_many(url, "expirations", **kwargs) + with ThreadPoolExecutor() as executor: executor.map(get_options_chains, expirations, repeat(data)) diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/utils/helpers.py b/openbb_platform/providers/intrinio/openbb_intrinio/utils/helpers.py index 902c1fcca91b..7ba3476ac1d4 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/utils/helpers.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/utils/helpers.py @@ -1,6 +1,7 @@ """Intrinio Helpers Module.""" import json +from datetime import date as dateType, datetime, timedelta from io import StringIO from typing import Any, List, Optional, TypeVar, Union @@ -116,3 +117,10 @@ def get_data_one(url: str, **kwargs: Any) -> dict: raise ValueError("Expected dict, got list of dicts") from e return data + + +def get_weekday(date: dateType) -> str: + """Return the weekday date.""" + if date.weekday() in [5, 6]: + return (date - timedelta(days=date.weekday() - 4)).strftime("%Y-%m-%d") + return date.strftime("%Y-%m-%d") From e384af96e1164de0dc92813579b92dc543291cbe Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Tue, 10 Oct 2023 17:05:12 +0530 Subject: [PATCH 3/9] linting --- .../providers/intrinio/openbb_intrinio/utils/helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/utils/helpers.py b/openbb_platform/providers/intrinio/openbb_intrinio/utils/helpers.py index 7ba3476ac1d4..83169ad7c0fd 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/utils/helpers.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/utils/helpers.py @@ -1,7 +1,10 @@ """Intrinio Helpers Module.""" import json -from datetime import date as dateType, datetime, timedelta +from datetime import ( + date as dateType, + timedelta, +) from io import StringIO from typing import Any, List, Optional, TypeVar, Union From 7bd5f60dee49107e41fdef2b3c11aad8a3c38229 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Tue, 10 Oct 2023 17:07:04 +0530 Subject: [PATCH 4/9] use dateutil.parser --- .../intrinio/openbb_intrinio/models/options_chains.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py index 2fcb98b4de2c..d3c524c58377 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py @@ -9,6 +9,7 @@ from itertools import repeat from typing import Any, Dict, List, Optional +from dateutil import parser from openbb_intrinio.utils.helpers import get_data_many, get_weekday from openbb_intrinio.utils.references import TICKER_EXCEPTIONS from openbb_provider.abstract.fetcher import Fetcher @@ -36,9 +37,10 @@ class IntrinioOptionsChainsData(OptionsChainsData): __alias_dict__ = {"contract_symbol": "code", "symbol": "ticker"} @validator("expiration", "date", pre=True, check_fields=False) + @classmethod def date_validate(cls, v): # pylint: disable=E0213 """Return the datetime object from the date string""" - return datetime.strptime(v, "%Y-%m-%d") + return parser.parse(v) class IntrinioOptionsChainsFetcher( From a873fb333fc7c7f44d6bd27c547f55be0c7beb62 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Thu, 12 Oct 2023 21:28:02 +0530 Subject: [PATCH 5/9] removed `TICKER_EXCEPTIONS` --- .../openbb_intrinio/models/options_chains.py | 8 ++------ .../intrinio/openbb_intrinio/utils/references.py | 14 -------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py index d3c524c58377..76427d4d36e4 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py @@ -11,13 +11,12 @@ from dateutil import parser from openbb_intrinio.utils.helpers import get_data_many, get_weekday -from openbb_intrinio.utils.references import TICKER_EXCEPTIONS from openbb_provider.abstract.fetcher import Fetcher from openbb_provider.standard_models.options_chains import ( OptionsChainsData, OptionsChainsQueryParams, ) -from pydantic import Field, validator +from pydantic import Field, field_validator class IntrinioOptionsChainsQueryParams(OptionsChainsQueryParams): @@ -36,7 +35,7 @@ class IntrinioOptionsChainsData(OptionsChainsData): __alias_dict__ = {"contract_symbol": "code", "symbol": "ticker"} - @validator("expiration", "date", pre=True, check_fields=False) + @field_validator("expiration", "date", mode="before", check_fields=False) @classmethod def date_validate(cls, v): # pylint: disable=E0213 """Return the datetime object from the date string""" @@ -68,9 +67,6 @@ def extract_data( """Return the raw data from the Intrinio endpoint.""" api_key = credentials.get("intrinio_api_key") if credentials else "" - if query.symbol in TICKER_EXCEPTIONS: - query.symbol = f"${query.symbol}" - data: List = [] base_url = "https://api-v2.intrinio.com/options" diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/utils/references.py b/openbb_platform/providers/intrinio/openbb_intrinio/utils/references.py index 545afa40741c..a0479f69c2da 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/utils/references.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/utils/references.py @@ -12,20 +12,6 @@ "delayed_sip", ] -TICKER_EXCEPTIONS = [ - "SPX", - "XSP", - "XEO", - "NDX", - "XND", - "VIX", - "RUT", - "MRUT", - "DJX", - "XAU", - "OEX", -] - INTERVALS = Literal["1m", "5m", "10m", "15m", "30m", "60m", "1h"] TIMEZONES = Literal[ From f9bb40cda456c138fa7f431001a4f91c34977c81 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Thu, 12 Oct 2023 22:21:57 +0530 Subject: [PATCH 6/9] modified `date` and `type` fields in standard model --- .../openbb_provider/standard_models/options_chains.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openbb_platform/platform/provider/openbb_provider/standard_models/options_chains.py b/openbb_platform/platform/provider/openbb_provider/standard_models/options_chains.py index 95fc789dbe7c..54291c2f1b56 100644 --- a/openbb_platform/platform/provider/openbb_provider/standard_models/options_chains.py +++ b/openbb_platform/platform/provider/openbb_provider/standard_models/options_chains.py @@ -27,11 +27,11 @@ class OptionsChainsData(Data): """Options Chains Data.""" contract_symbol: str = Field(description="Contract symbol for the option.") - symbol: str = Field(description="Underlying symbol for the option.") + symbol: Optional[str] = Field(description="Underlying symbol for the option.") expiration: dateType = Field(description="Expiration date of the contract.") strike: float = Field(description="Strike price of the contract.") - type: str = Field(description="Call or Put.") - date: dateType = Field( + option_type: str = Field(description="Call or Put.") + eod_date: dateType = Field( description="Date for which the options chains are returned." ) From eead9c7cf70e0a3be98330aca67b543961fb0702 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Thu, 12 Oct 2023 22:22:40 +0530 Subject: [PATCH 7/9] set alias for `date` and `type` to match standards --- .../intrinio/openbb_intrinio/models/options_chains.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py index 76427d4d36e4..ec79b7c9fd5f 100644 --- a/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py +++ b/openbb_platform/providers/intrinio/openbb_intrinio/models/options_chains.py @@ -33,7 +33,12 @@ class IntrinioOptionsChainsQueryParams(OptionsChainsQueryParams): class IntrinioOptionsChainsData(OptionsChainsData): """Intrinio Options Chains Data.""" - __alias_dict__ = {"contract_symbol": "code", "symbol": "ticker"} + __alias_dict__ = { + "contract_symbol": "code", + "symbol": "ticker", + "eod_date": "date", + "option_type": "type", + } @field_validator("expiration", "date", mode="before", check_fields=False) @classmethod From bfa291219ab951fbd677d2e9a2537dfc5ac48ddf Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Thu, 12 Oct 2023 22:22:57 +0530 Subject: [PATCH 8/9] static --- .../openbb/package/__extensions__.py | 39 +- openbb_platform/openbb/package/crypto.py | 12 +- .../openbb/package/econometrics.py | 514 ++++++ openbb_platform/openbb/package/economy.py | 688 +++++++- .../openbb/package/extension_map.json | 13 +- openbb_platform/openbb/package/forex.py | 12 +- openbb_platform/openbb/package/futures.py | 188 +++ .../openbb/package/module_map.json | 67 +- openbb_platform/openbb/package/qa.py | 375 +++++ openbb_platform/openbb/package/stocks.py | 281 +++- openbb_platform/openbb/package/stocks_fa.py | 958 +++++------ .../openbb/package/stocks_options.py | 40 +- openbb_platform/openbb/package/ta.py | 1485 +++++++++++++++++ 13 files changed, 4143 insertions(+), 529 deletions(-) create mode 100644 openbb_platform/openbb/package/econometrics.py create mode 100644 openbb_platform/openbb/package/futures.py create mode 100644 openbb_platform/openbb/package/qa.py create mode 100644 openbb_platform/openbb/package/ta.py diff --git a/openbb_platform/openbb/package/__extensions__.py b/openbb_platform/openbb/package/__extensions__.py index f55f965b650e..198cf9254983 100644 --- a/openbb_platform/openbb/package/__extensions__.py +++ b/openbb_platform/openbb/package/__extensions__.py @@ -9,25 +9,38 @@ class Extensions(Container): """ Routers: /crypto + /econometrics /economy /fixedincome /forex + /futures /news + /qa /stocks + /ta Extensions: - crypto@0.1.0a2 + - econometrics@0.1.0a2 - economy@0.1.0a2 - fixedincome@0.1.0a2 - forex@0.1.0a2 + - futures@0.1.0a2 - news@0.1.0a2 + - openbb_charting@0.1.0a2 + - qa@0.1.0a2 - stocks@0.1.0a2 + - ta@0.1.0a2 + - alpha_vantage@0.1.0a2 - benzinga@0.1.0a2 + - cboe@0.1.0a2 - fmp@0.1.0a2 - fred@0.1.0a2 - intrinio@0.1.0a2 - - polygon@0.1.0a2 """ + - polygon@0.1.0a2 + - quandl@0.1.0a2 + - yfinance@0.1.0a2 """ # fmt: on def __repr__(self) -> str: return self.__doc__ or "" @@ -38,6 +51,12 @@ def crypto(self): # route = "/crypto" return crypto.ROUTER_crypto(command_runner=self._command_runner) + @property + def econometrics(self): # route = "/econometrics" + from . import econometrics + + return econometrics.ROUTER_econometrics(command_runner=self._command_runner) + @property def economy(self): # route = "/economy" from . import economy @@ -56,14 +75,32 @@ def forex(self): # route = "/forex" return forex.ROUTER_forex(command_runner=self._command_runner) + @property + def futures(self): # route = "/futures" + from . import futures + + return futures.ROUTER_futures(command_runner=self._command_runner) + @property def news(self): # route = "/news" from . import news return news.ROUTER_news(command_runner=self._command_runner) + @property + def qa(self): # route = "/qa" + from . import qa + + return qa.ROUTER_qa(command_runner=self._command_runner) + @property def stocks(self): # route = "/stocks" from . import stocks return stocks.ROUTER_stocks(command_runner=self._command_runner) + + @property + def ta(self): # route = "/ta" + from . import ta + + return ta.ROUTER_ta(command_runner=self._command_runner) diff --git a/openbb_platform/openbb/package/crypto.py b/openbb_platform/openbb/package/crypto.py index 7fa9d7378299..32aaa85c201b 100644 --- a/openbb_platform/openbb/package/crypto.py +++ b/openbb_platform/openbb/package/crypto.py @@ -39,7 +39,7 @@ def load( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Union[Literal["fmp", "polygon"], None] = None, + provider: Union[Literal["fmp", "polygon", "yfinance"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Crypto Historical Price. @@ -52,14 +52,14 @@ def load( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None] End date of the data, in YYYY-MM-DD format. - provider : Union[Literal['fmp', 'polygon'], None] + provider : Union[Literal['fmp', 'polygon', 'yfinance'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. timeseries : Optional[Union[typing_extensions.Annotated[int, Ge(ge=0)]]] Number of days to look back. (provider: fmp) - interval : Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'] - Data granularity. (provider: fmp) + interval : Optional[Union[Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] + Data granularity. (provider: fmp, yfinance) multiplier : int Multiplier of the timespan. (provider: polygon) timespan : Literal['minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'] @@ -70,13 +70,15 @@ def load( The number of data entries to return. (provider: polygon) adjusted : bool Whether the data is adjusted. (provider: polygon) + period : Optional[Union[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']]] + Period of the data to return. (provider: yfinance) Returns ------- OBBject results : Union[List[CryptoHistorical]] Serializable results. - provider : Union[Literal['fmp', 'polygon'], None] + provider : Union[Literal['fmp', 'polygon', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. diff --git a/openbb_platform/openbb/package/econometrics.py b/openbb_platform/openbb/package/econometrics.py new file mode 100644 index 000000000000..dd4009580cc0 --- /dev/null +++ b/openbb_platform/openbb/package/econometrics.py @@ -0,0 +1,514 @@ +### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ### + +from typing import Dict, List, Literal, Union + +import pandas +import typing_extensions +from annotated_types import Gt +from openbb_core.app.model.obbject import OBBject +from openbb_core.app.static.container import Container +from openbb_core.app.static.filters import filter_inputs +from openbb_provider.abstract.data import Data +from pydantic import validate_call + + +class ROUTER_econometrics(Container): + """/econometrics + bgot + coint + corr + dwat + granger + ols + ols_summary + panelbols + panelfd + panelfmac + panelols + panelpols + panelre + unitroot + """ + + def __repr__(self) -> str: + return self.__doc__ or "" + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def bgot( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + lags: typing_extensions.Annotated[int, Gt(gt=0)] = 1, + ) -> OBBject[Data]: + """Perform Breusch-Godfrey Lagrange Multiplier tests for residual autocorrelation. + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + lags: PositiveInt + Number of lags to use in the test. + Returns + ------- + OBBject[Data] + OBBject with the results being the score from the test. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + lags=lags, + ) + + return self._run( + "/econometrics/bgot", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def coint( + self, data: Union[List[Data], pandas.DataFrame], columns: List[str] + ) -> OBBject[Data]: + """Show co-integration between two timeseries using the two step Engle-Granger test. + + Parameters + ---------- + data: List[Data] + Input dataset. + columns: List[str] + Data columns to check cointegration + maxlag: PositiveInt + Number of lags to use in the test. + Returns + ------- + OBBject[Data] + OBBject with the results being the score from the test. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + columns=columns, + ) + + return self._run( + "/econometrics/coint", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def corr(self, data: Union[List[Data], pandas.DataFrame]) -> OBBject[List[Data]]: + """Get the corrlelation matrix of an input dataset. + + Parameters + ---------- + data : List[Data] + Input dataset. + + Returns + ------- + OBBject[List[Data]] + Correlation matrix. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + ) + + return self._run( + "/econometrics/corr", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def dwat( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Dict]: + """Perform Durbin-Watson test for autocorrelation + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Data] + OBBject with the results being the score from the test. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/dwat", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def granger( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_column: str, + lag: typing_extensions.Annotated[int, Gt(gt=0)] = 3, + ) -> OBBject[Data]: + """Perform Granger causality test to determine if X "causes" y. + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_column: str + Columns to use as exogenous variables. + lag: PositiveInt + Number of lags to use in the test. + Returns + ------- + OBBject[Data] + OBBject with the results being the score from the test. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_column=x_column, + lag=lag, + ) + + return self._run( + "/econometrics/granger", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def ols( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Dict]: + """Perform OLS regression. This returns the model and results objects from statsmodels. + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Dict] + OBBject with the results being model and results objects. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/ols", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def ols_summary( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Data]: + """Perform OLS regression. This returns the summary object from statsmodels. + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Dict] + OBBject with the results being summary object. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/ols_summary", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def panelbols( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Dict]: + """Perform a Between estimator regression on panel data + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Dict] + OBBject with the fit model returned + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/panelbols", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def panelfd( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Dict]: + """Perform a first-difference estimate for panel data + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Dict] + OBBject with the fit model returned + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/panelfd", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def panelfmac( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Dict]: + """Fama-MacBeth estimator for panel data + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Dict] + OBBject with the fit model returned + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/panelfmac", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def panelols( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Dict]: + """One- and two-way fixed effects estimator for panel data + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Dict] + OBBject with the fit model returned + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/panelols", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def panelpols( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Dict]: + """Perform a Pooled coefficvient estimator regression on panel data + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Dict] + OBBject with the fit model returned + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/panelpols", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def panelre( + self, + data: Union[List[Data], pandas.DataFrame], + y_column: str, + x_columns: List[str], + ) -> OBBject[Dict]: + """Perform One-way Random Effects model for panel data + + Parameters + ---------- + data: List[Data] + Input dataset. + y_column: str + Target column. + x_columns: str + List of columns to use as exogenous variables. + + Returns + ------- + OBBject[Dict] + OBBject with the fit model returned + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + y_column=y_column, + x_columns=x_columns, + ) + + return self._run( + "/econometrics/panelre", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def unitroot( + self, + data: Union[List[Data], pandas.DataFrame], + column: str, + regression: Literal["c", "ct", "ctt"] = "c", + ) -> OBBject[Data]: + """Perform Augmented Dickey-Fuller unit root test. + + Parameters + ---------- + data: List[Data] + Input dataset. + column: str + Data columns to check unit root + regression: str + Regression type to use in the test. Either "c" for constant only, "ct" for constant and trend, or "ctt" for + constant, trend, and trend-squared. + Returns + ------- + OBBject[Data] + OBBject with the results being the score from the test. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + column=column, + regression=regression, + ) + + return self._run( + "/econometrics/unitroot", + **inputs, + ) diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 204db5544112..3e6b9efe7454 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -16,10 +16,17 @@ class ROUTER_economy(Container): """/economy available_indices const + cot + cot_search cpi + european_index + european_index_constituents fred_index index + index_search + index_snapshots risk + sp500_multiples """ def __repr__(self) -> str: @@ -27,23 +34,25 @@ def __repr__(self) -> str: @validate_call def available_indices( - self, provider: Union[Literal["fmp"], None] = None, **kwargs + self, provider: Union[Literal["cboe", "fmp", "yfinance"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Lists of available indices from a provider. Parameters ---------- - provider : Union[Literal['fmp'], None] + provider : Union[Literal['cboe', 'fmp', 'yfinance'], None] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fmp' if there is + If None, the provider specified in defaults is selected or 'cboe' if there is no default. + europe : bool + Filter for European indices. False for US indices. (provider: cboe) Returns ------- OBBject results : Union[List[AvailableIndices]] Serializable results. - provider : Union[Literal['fmp'], None] + provider : Union[Literal['cboe', 'fmp', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -58,11 +67,34 @@ def available_indices( Name of the index. currency : Optional[Union[str]] Currency the index is traded in. + isin : Optional[Union[str]] + ISIN code for the index. Valid only for European indices. (provider: cboe) + region : Optional[Union[str]] + Region for the index. Valid only for European indices (provider: cboe) + symbol : Optional[Union[str]] + Symbol for the index. (provider: cboe, yfinance) + description : Optional[Union[str]] + Description for the index. Valid only for US indices. (provider: cboe) + data_delay : Optional[Union[int]] + Data delay for the index. Valid only for US indices. (provider: cboe) + open_time : Optional[Union[datetime.time]] + Opening time for the index. Valid only for US indices. (provider: cboe) + close_time : Optional[Union[datetime.time]] + Closing time for the index. Valid only for US indices. (provider: cboe) + time_zone : Optional[Union[str]] + Time zone for the index. Valid only for US indices. (provider: cboe) + tick_days : Optional[Union[str]] + The trading days for the index. Valid only for US indices. (provider: cboe) + tick_frequency : Optional[Union[str]] + The frequency of the index ticks. Valid only for US indices. (provider: cboe) + tick_period : Optional[Union[str]] + The period of the index ticks. Valid only for US indices. (provider: cboe) stock_exchange : Optional[Union[str]] Stock exchange where the index is listed. (provider: fmp) exchange_short_name : Optional[Union[str]] Short name of the stock exchange where the index is listed. (provider: fmp) - """ # noqa: E501 + code : Optional[Union[str]] + ID code for keying the index in the OpenBB Terminal. (provider: yfinance)""" # noqa: E501 inputs = filter_inputs( provider_choices={ @@ -148,6 +180,162 @@ def const( **inputs, ) + @validate_call + def cot( + self, provider: Union[Literal["quandl"], None] = None, **kwargs + ) -> OBBject[List[Data]]: + """Lookup Commitment of Traders Reports by series ID. + + Parameters + ---------- + provider : Union[Literal['quandl'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'quandl' if there is + no default. + code : str + + CFTC series code. Use search_cot() to find the code. + Codes not listed in the curated list, but are published by on the Nasdaq Data Link website, are valid. + Certain symbols, such as "ES=F", or exact names are also valid. + Default report is: S&P 500 Consolidated (CME)) + (provider: quandl) + data_type : Optional[Union[Literal['F', 'FO', 'CITS']]] + + The type of data to reuturn. Default is "FO". + + F = Futures only + + FO = Futures and Options + + CITS = Commodity Index Trader Supplemental. Only valid for commodities. + (provider: quandl) + legacy_format : Optional[Union[bool]] + Returns the legacy format of report. Default is False. (provider: quandl) + report_type : Optional[Union[Literal['ALL', 'CHG', 'OLD', 'OTR']]] + + The type of report to return. Default is "ALL". + + ALL = All + + CHG = Change in Positions + + OLD = Old Crop Years + + OTR = Other Crop Years + (provider: quandl) + measure : Optional[Union[Literal['CR', 'NT', 'OI', 'CHG']]] + + The measure to return. Default is None. + + CR = Concentration Ratios + + NT = Number of Traders + + OI = Percent of Open Interest + + CHG = Change in Positions. Only valid when data_type is "CITS". + (provider: quandl) + start_date : Optional[Union[datetime.date]] + The start date of the time series. Defaults to all. (provider: quandl) + end_date : Optional[Union[datetime.date]] + The end date of the time series. Defaults to the most recent data. (provider: quandl) + transform : Optional[Union[Literal['diff', 'rdiff', 'cumul', 'normalize']]] + Transform the data as w/w difference, percent change, cumulative, or normalize. (provider: quandl) + + Returns + ------- + OBBject + results : Union[List[COT]] + Serializable results. + provider : Union[Literal['quandl'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + COT + ---""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={}, + extra_params=kwargs, + ) + + return self._run( + "/economy/cot", + **inputs, + ) + + @validate_call + def cot_search( + self, + query: typing_extensions.Annotated[ + str, OpenBBCustomParameter(description="Search query.") + ] = "", + provider: Union[Literal["quandl"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Fuzzy search and list of curated Commitment of Traders Reports series information. + + Parameters + ---------- + query : str + Search query. + provider : Union[Literal['quandl'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'quandl' if there is + no default. + + Returns + ------- + OBBject + results : Union[List[COTSearch]] + Serializable results. + provider : Union[Literal['quandl'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + COTSearch + --------- + code : str + CFTC Code of the report. + name : str + Name of the underlying asset. + category : Optional[Union[str]] + Category of the underlying asset. + subcategory : Optional[Union[str]] + Subcategory of the underlying asset. + units : Optional[Union[str]] + The units for one contract. + symbol : Optional[Union[str]] + Trading symbol representing the underlying asset.""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "query": query, + }, + extra_params=kwargs, + ) + + return self._run( + "/economy/cot_search", + **inputs, + ) + @validate_call def cpi( self, @@ -298,6 +486,174 @@ def cpi( **inputs, ) + @validate_call + def european_index( + self, + symbol: typing_extensions.Annotated[ + Union[str, List[str]], + OpenBBCustomParameter(description="Symbol to get data for."), + ], + start_date: typing_extensions.Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: typing_extensions.Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + provider: Union[Literal["cboe"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Get historical close values for select European indices. + + Parameters + ---------- + symbol : str + Symbol to get data for. + start_date : Union[datetime.date, None] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None] + End date of the data, in YYYY-MM-DD format. + provider : Union[Literal['cboe'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'cboe' if there is + no default. + interval : Optional[Union[Literal['1d', '1m']]] + Data granularity. (provider: cboe) + + Returns + ------- + OBBject + results : Union[List[EuropeanIndexHistorical]] + Serializable results. + provider : Union[Literal['cboe'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + EuropeanIndexHistorical + ----------------------- + date : datetime + The date of the data. + close : float + The close price of the symbol. + open : Optional[Union[float]] + Opening price for the interval. Only valid when interval is 1m. (provider: cboe) + high : Optional[Union[float]] + High price for the interval. Only valid when interval is 1m. (provider: cboe) + low : Optional[Union[float]] + Low price for the interval. Only valid when interval is 1m. (provider: cboe) + utc_datetime : Optional[Union[datetime]] + UTC datetime. Only valid when interval is 1m. (provider: cboe)""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "symbol": ",".join(symbol) if isinstance(symbol, list) else symbol, + "start_date": start_date, + "end_date": end_date, + }, + extra_params=kwargs, + ) + + return self._run( + "/economy/european_index", + **inputs, + ) + + @validate_call + def european_index_constituents( + self, + symbol: typing_extensions.Annotated[ + Union[str, List[str]], + OpenBBCustomParameter(description="Symbol to get data for."), + ], + provider: Union[Literal["cboe"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Get current levels for constituents of select European indices. + + Parameters + ---------- + symbol : str + Symbol to get data for. + provider : Union[Literal['cboe'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'cboe' if there is + no default. + + Returns + ------- + OBBject + results : Union[List[EuropeanIndexConstituents]] + Serializable results. + provider : Union[Literal['cboe'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + EuropeanIndexConstituents + ------------------------- + symbol : str + Symbol of the constituent company in the index. + price : float + Current price of the constituent company in the index. + open : float + The open price of the symbol. + high : float + The high price of the symbol. + low : float + The low price of the symbol. + close : float + The close price of the symbol. + volume : float + The volume of the symbol. + prev_close : Optional[Union[float]] + Previous closing price. (provider: cboe) + change : Optional[Union[float]] + Change in price. (provider: cboe) + change_percent : Optional[Union[float]] + Change in price as a percentage. (provider: cboe) + tick : Optional[Union[str]] + Whether the last sale was an up or down tick. (provider: cboe) + last_trade_timestamp : Optional[Union[datetime]] + Last trade timestamp for the symbol. (provider: cboe) + exchange_id : Optional[Union[int]] + The Exchange ID number. (provider: cboe) + seqno : Optional[Union[int]] + Sequence number of the last trade on the tape. (provider: cboe) + asset_type : Optional[Union[str]] + Type of asset. (provider: cboe)""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "symbol": ",".join(symbol) if isinstance(symbol, list) else symbol, + }, + extra_params=kwargs, + ) + + return self._run( + "/economy/european_index_constituents", + **inputs, + ) + @validate_call def fred_index( self, @@ -403,7 +759,7 @@ def index( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Union[Literal["fmp", "polygon"], None] = None, + provider: Union[Literal["cboe", "fmp", "polygon", "yfinance"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Get historical levels for an index. @@ -416,14 +772,14 @@ def index( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None] End date of the data, in YYYY-MM-DD format. - provider : Union[Literal['fmp', 'polygon'], None] + provider : Union[Literal['cboe', 'fmp', 'polygon', 'yfinance'], None] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fmp' if there is + If None, the provider specified in defaults is selected or 'cboe' if there is no default. + interval : Optional[Union[Literal['1d', '1m'], Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] + Use interval, 1m, for intraday prices during the most recent trading period. (provider: cboe); Data granularity. (provider: fmp); Data granularity. (provider: yfinance) timeseries : Optional[Union[typing_extensions.Annotated[int, Ge(ge=0)]]] Number of days to look back. (provider: fmp) - interval : Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'] - Data granularity. (provider: fmp) timespan : Literal['minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'] Timespan of the data. (provider: polygon) sort : Literal['asc', 'desc'] @@ -434,13 +790,19 @@ def index( Whether the data is adjusted. (provider: polygon) multiplier : int Multiplier of the timespan. (provider: polygon) + period : Optional[Union[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']]] + Period of the data to return. (provider: yfinance) + prepost : bool + Include Pre and Post market data. (provider: yfinance) + rounding : bool + Round prices to two decimals? (provider: yfinance) Returns ------- OBBject results : Union[List[MajorIndicesHistorical]] Serializable results. - provider : Union[Literal['fmp', 'polygon'], None] + provider : Union[Literal['cboe', 'fmp', 'polygon', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -463,6 +825,12 @@ def index( The close price of the symbol. volume : Optional[int] The volume of the symbol. + calls_volume : Optional[Union[float]] + Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + puts_volume : Optional[Union[float]] + Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + total_options_volume : Optional[Union[float]] + Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) adj_close : Optional[Union[float]] Adjusted Close Price of the symbol. (provider: fmp) unadjusted_volume : Optional[Union[float]] @@ -496,6 +864,174 @@ def index( **inputs, ) + @validate_call + def index_search( + self, + query: typing_extensions.Annotated[ + str, OpenBBCustomParameter(description="Search query.") + ] = "", + symbol: typing_extensions.Annotated[ + Union[bool, List[str]], + OpenBBCustomParameter(description="Whether to search by ticker symbol."), + ] = False, + provider: Union[Literal["cboe"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Search for indices. + + Parameters + ---------- + query : str + Search query. + symbol : bool + Whether to search by ticker symbol. + provider : Union[Literal['cboe'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'cboe' if there is + no default. + europe : bool + Filter for European indices. False for US indices. (provider: cboe) + + Returns + ------- + OBBject + results : Union[List[IndexSearch]] + Serializable results. + provider : Union[Literal['cboe'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + IndexSearch + ----------- + symbol : str + Symbol of the index. + name : str + Name of the index. + isin : Optional[Union[str]] + ISIN code for the index. Valid only for European indices. (provider: cboe) + region : Optional[Union[str]] + Region for the index. Valid only for European indices (provider: cboe) + description : Optional[Union[str]] + Description for the index. (provider: cboe) + data_delay : Optional[Union[int]] + Data delay for the index. Valid only for US indices. (provider: cboe) + currency : Optional[Union[str]] + Currency for the index. (provider: cboe) + time_zone : Optional[Union[str]] + Time zone for the index. Valid only for US indices. (provider: cboe) + open_time : Optional[Union[datetime.time]] + Opening time for the index. Valid only for US indices. (provider: cboe) + close_time : Optional[Union[datetime.time]] + Closing time for the index. Valid only for US indices. (provider: cboe) + tick_days : Optional[Union[str]] + The trading days for the index. Valid only for US indices. (provider: cboe) + tick_frequency : Optional[Union[str]] + Tick frequency for the index. Valid only for US indices. (provider: cboe) + tick_period : Optional[Union[str]] + Tick period for the index. Valid only for US indices. (provider: cboe)""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "query": query, + "symbol": ",".join(symbol) if isinstance(symbol, list) else symbol, + }, + extra_params=kwargs, + ) + + return self._run( + "/economy/index_search", + **inputs, + ) + + @validate_call + def index_snapshots( + self, + region: typing_extensions.Annotated[ + Union[Literal["US", "EU"], None], + OpenBBCustomParameter( + description="The region to return. Currently supports US and EU." + ), + ] = "US", + provider: Union[Literal["cboe"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Get current levels for all indices from a provider. + + Parameters + ---------- + region : Union[Literal['US', 'EU'], None] + The region to return. Currently supports US and EU. + provider : Union[Literal['cboe'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'cboe' if there is + no default. + + Returns + ------- + OBBject + results : Union[List[IndexSnapshots]] + Serializable results. + provider : Union[Literal['cboe'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + IndexSnapshots + -------------- + symbol : str + Symbol of the index. + name : Optional[Union[str]] + Name of the index. + currency : Optional[Union[str]] + Currency of the index. + price : Optional[Union[float]] + Current price of the index. + open : Optional[Union[float]] + Opening price of the index. + high : Optional[Union[float]] + Highest price of the index. + low : Optional[Union[float]] + Lowest price of the index. + close : Optional[Union[float]] + Closing price of the index. + prev_close : Optional[Union[float]] + Previous closing price of the index. + change : Optional[Union[float]] + Change of the index. + change_percent : Optional[Union[float]] + Change percent of the index. + isin : Optional[Union[str]] + ISIN code for the index. Valid only for European indices. (provider: cboe) + last_trade_timestamp : Optional[Union[datetime]] + Last trade timestamp for the index. (provider: cboe)""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "region": region, + }, + extra_params=kwargs, + ) + + return self._run( + "/economy/index_snapshots", + **inputs, + ) + @validate_call def risk( self, provider: Union[Literal["fmp"], None] = None, **kwargs @@ -546,3 +1082,133 @@ def risk( "/economy/risk", **inputs, ) + + @validate_call + def sp500_multiples( + self, + series_name: typing_extensions.Annotated[ + Literal[ + "Shiller PE Ratio by Month", + "Shiller PE Ratio by Year", + "PE Ratio by Year", + "PE Ratio by Month", + "Dividend by Year", + "Dividend by Month", + "Dividend Growth by Quarter", + "Dividend Growth by Year", + "Dividend Yield by Year", + "Dividend Yield by Month", + "Earnings by Year", + "Earnings by Month", + "Earnings Growth by Year", + "Earnings Growth by Quarter", + "Real Earnings Growth by Year", + "Real Earnings Growth by Quarter", + "Earnings Yield by Year", + "Earnings Yield by Month", + "Real Price by Year", + "Real Price by Month", + "Inflation Adjusted Price by Year", + "Inflation Adjusted Price by Month", + "Sales by Year", + "Sales by Quarter", + "Sales Growth by Year", + "Sales Growth by Quarter", + "Real Sales by Year", + "Real Sales by Quarter", + "Real Sales Growth by Year", + "Real Sales Growth by Quarter", + "Price to Sales Ratio by Year", + "Price to Sales Ratio by Quarter", + "Price to Book Value Ratio by Year", + "Price to Book Value Ratio by Quarter", + "Book Value per Share by Year", + "Book Value per Share by Quarter", + ], + OpenBBCustomParameter( + description="The name of the series. Defaults to 'PE Ratio by Month'." + ), + ] = "PE Ratio by Month", + start_date: typing_extensions.Annotated[ + Union[str, None], + OpenBBCustomParameter( + description="The start date of the time series. Format: YYYY-MM-DD" + ), + ] = "", + end_date: typing_extensions.Annotated[ + Union[str, None], + OpenBBCustomParameter( + description="The end date of the time series. Format: YYYY-MM-DD" + ), + ] = "", + collapse: typing_extensions.Annotated[ + Union[Literal["daily", "weekly", "monthly", "quarterly", "annual"], None], + OpenBBCustomParameter( + description="Collapse the frequency of the time series." + ), + ] = "monthly", + transform: typing_extensions.Annotated[ + Union[Literal["diff", "rdiff", "cumul", "normalize"], None], + OpenBBCustomParameter(description="The transformation of the time series."), + ] = None, + provider: Union[Literal["quandl"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Historical S&P 500 multiples and Shiller PE ratios. + + Parameters + ---------- + series_name : Literal['Shiller PE Ratio by Month', 'Shiller PE Ratio by Year', 'PE Rat... + The name of the series. Defaults to 'PE Ratio by Month'. + start_date : Union[str, None] + The start date of the time series. Format: YYYY-MM-DD + end_date : Union[str, None] + The end date of the time series. Format: YYYY-MM-DD + collapse : Union[Literal['daily', 'weekly', 'monthly', 'quarterly', 'annual'... + Collapse the frequency of the time series. + transform : Union[Literal['diff', 'rdiff', 'cumul', 'normalize'], None] + The transformation of the time series. + provider : Union[Literal['quandl'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'quandl' if there is + no default. + + Returns + ------- + OBBject + results : Union[List[SP500Multiples]] + Serializable results. + provider : Union[Literal['quandl'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + SP500Multiples + -------------- + date : str + The date data for the time series. + value : float + The data value for the time series.""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "series_name": series_name, + "start_date": start_date, + "end_date": end_date, + "collapse": collapse, + "transform": transform, + }, + extra_params=kwargs, + ) + + return self._run( + "/economy/sp500_multiples", + **inputs, + ) diff --git a/openbb_platform/openbb/package/extension_map.json b/openbb_platform/openbb/package/extension_map.json index bd468205a5d8..fd19f57c957d 100644 --- a/openbb_platform/openbb/package/extension_map.json +++ b/openbb_platform/openbb/package/extension_map.json @@ -1,17 +1,26 @@ { "openbb_core_extension": [ "crypto@0.1.0a2", + "econometrics@0.1.0a2", "economy@0.1.0a2", "fixedincome@0.1.0a2", "forex@0.1.0a2", + "futures@0.1.0a2", "news@0.1.0a2", - "stocks@0.1.0a2" + "openbb_charting@0.1.0a2", + "qa@0.1.0a2", + "stocks@0.1.0a2", + "ta@0.1.0a2" ], "openbb_provider_extension": [ + "alpha_vantage@0.1.0a2", "benzinga@0.1.0a2", + "cboe@0.1.0a2", "fmp@0.1.0a2", "fred@0.1.0a2", "intrinio@0.1.0a2", - "polygon@0.1.0a2" + "polygon@0.1.0a2", + "quandl@0.1.0a2", + "yfinance@0.1.0a2" ] } \ No newline at end of file diff --git a/openbb_platform/openbb/package/forex.py b/openbb_platform/openbb/package/forex.py index 4dacfd8e951c..4926e27a7db3 100644 --- a/openbb_platform/openbb/package/forex.py +++ b/openbb_platform/openbb/package/forex.py @@ -40,7 +40,7 @@ def load( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Union[Literal["fmp", "polygon"], None] = None, + provider: Union[Literal["fmp", "polygon", "yfinance"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Forex Intraday Price. @@ -53,12 +53,12 @@ def load( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None] End date of the data, in YYYY-MM-DD format. - provider : Union[Literal['fmp', 'polygon'], None] + provider : Union[Literal['fmp', 'polygon', 'yfinance'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. - interval : Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'] - Data granularity. (provider: fmp) + interval : Optional[Union[Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] + Data granularity. (provider: fmp, yfinance) multiplier : int Multiplier of the timespan. (provider: polygon) timespan : Literal['minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'] @@ -69,13 +69,15 @@ def load( The number of data entries to return. (provider: polygon) adjusted : bool Whether the data is adjusted. (provider: polygon) + period : Optional[Union[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']]] + Period of the data to return. (provider: yfinance) Returns ------- OBBject results : Union[List[ForexHistorical]] Serializable results. - provider : Union[Literal['fmp', 'polygon'], None] + provider : Union[Literal['fmp', 'polygon', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. diff --git a/openbb_platform/openbb/package/futures.py b/openbb_platform/openbb/package/futures.py new file mode 100644 index 000000000000..95eaaabfe7ea --- /dev/null +++ b/openbb_platform/openbb/package/futures.py @@ -0,0 +1,188 @@ +### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ### + +import datetime +from typing import List, Literal, Union + +import typing_extensions +from openbb_core.app.model.custom_parameter import OpenBBCustomParameter +from openbb_core.app.model.obbject import OBBject +from openbb_core.app.static.container import Container +from openbb_core.app.static.filters import filter_inputs +from openbb_provider.abstract.data import Data +from pydantic import validate_call + + +class ROUTER_futures(Container): + """/futures + curve + load + """ + + def __repr__(self) -> str: + return self.__doc__ or "" + + @validate_call + def curve( + self, + symbol: typing_extensions.Annotated[ + Union[str, List[str]], + OpenBBCustomParameter(description="Symbol to get data for."), + ], + date: typing_extensions.Annotated[ + Union[datetime.date, None], + OpenBBCustomParameter(description="Historical date to search curve for."), + ] = None, + provider: Union[Literal["cboe", "yfinance"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Futures Historical Price. + + Parameters + ---------- + symbol : str + Symbol to get data for. + date : Union[datetime.date, None] + Historical date to search curve for. + provider : Union[Literal['cboe', 'yfinance'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'cboe' if there is + no default. + + Returns + ------- + OBBject + results : Union[List[FuturesCurve]] + Serializable results. + provider : Union[Literal['cboe', 'yfinance'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + FuturesCurve + ------------ + expiration : str + Futures expiration month. + price : Optional[Union[float]] + The close price of the symbol. + symbol : Optional[Union[str]] + The trading symbol for the tenor of future. (provider: cboe)""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "symbol": ",".join(symbol) if isinstance(symbol, list) else symbol, + "date": date, + }, + extra_params=kwargs, + ) + + return self._run( + "/futures/curve", + **inputs, + ) + + @validate_call + def load( + self, + symbol: typing_extensions.Annotated[ + Union[str, List[str]], + OpenBBCustomParameter(description="Symbol to get data for."), + ], + start_date: typing_extensions.Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: typing_extensions.Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + expiration: typing_extensions.Annotated[ + Union[str, None], + OpenBBCustomParameter(description="Future expiry date with format YYYY-MM"), + ] = None, + provider: Union[Literal["yfinance"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Futures Historical Price. + + Parameters + ---------- + symbol : str + Symbol to get data for. + start_date : Union[datetime.date, None] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None] + End date of the data, in YYYY-MM-DD format. + expiration : Union[str, None] + Future expiry date with format YYYY-MM + provider : Union[Literal['yfinance'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'yfinance' if there is + no default. + interval : Optional[Union[Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] + Data granularity. (provider: yfinance) + period : Optional[Union[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']]] + Period of the data to return. (provider: yfinance) + prepost : bool + Include Pre and Post market data. (provider: yfinance) + adjust : bool + Adjust all the data automatically. (provider: yfinance) + back_adjust : bool + Back-adjusted data to mimic true historical prices. (provider: yfinance) + + Returns + ------- + OBBject + results : Union[List[FuturesHistorical]] + Serializable results. + provider : Union[Literal['yfinance'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + FuturesHistorical + ----------------- + date : datetime + The date of the data. + open : float + The open price of the symbol. + high : float + The high price of the symbol. + low : float + The low price of the symbol. + close : float + The close price of the symbol. + volume : float + The volume of the symbol.""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "symbol": ",".join(symbol) if isinstance(symbol, list) else symbol, + "start_date": start_date, + "end_date": end_date, + "expiration": expiration, + }, + extra_params=kwargs, + ) + + return self._run( + "/futures/load", + **inputs, + ) diff --git a/openbb_platform/openbb/package/module_map.json b/openbb_platform/openbb/package/module_map.json index 75ffa6356bab..0cea51923361 100644 --- a/openbb_platform/openbb/package/module_map.json +++ b/openbb_platform/openbb/package/module_map.json @@ -2,13 +2,35 @@ "__extensions__": "", "crypto": "/crypto", "crypto_load": "/crypto/load", + "econometrics": "/econometrics", + "econometrics_bgot": "/econometrics/bgot", + "econometrics_coint": "/econometrics/coint", + "econometrics_corr": "/econometrics/corr", + "econometrics_dwat": "/econometrics/dwat", + "econometrics_granger": "/econometrics/granger", + "econometrics_ols": "/econometrics/ols", + "econometrics_ols_summary": "/econometrics/ols_summary", + "econometrics_panelbols": "/econometrics/panelbols", + "econometrics_panelfd": "/econometrics/panelfd", + "econometrics_panelfmac": "/econometrics/panelfmac", + "econometrics_panelols": "/econometrics/panelols", + "econometrics_panelpols": "/econometrics/panelpols", + "econometrics_panelre": "/econometrics/panelre", + "econometrics_unitroot": "/econometrics/unitroot", "economy": "/economy", "economy_available_indices": "/economy/available_indices", "economy_const": "/economy/const", + "economy_cot": "/economy/cot", + "economy_cot_search": "/economy/cot_search", "economy_cpi": "/economy/cpi", + "economy_european_index": "/economy/european_index", + "economy_european_index_constituents": "/economy/european_index_constituents", "economy_fred_index": "/economy/fred_index", "economy_index": "/economy/index", + "economy_index_search": "/economy/index_search", + "economy_index_snapshots": "/economy/index_snapshots", "economy_risk": "/economy/risk", + "economy_sp500_multiples": "/economy/sp500_multiples", "fixedincome": "/fixedincome", "fixedincome_ameribor": "/fixedincome/ameribor", "fixedincome_estr": "/fixedincome/estr", @@ -22,8 +44,22 @@ "forex": "/forex", "forex_load": "/forex/load", "forex_pairs": "/forex/pairs", + "futures": "/futures", + "futures_curve": "/futures/curve", + "futures_load": "/futures/load", "news": "/news", "news_globalnews": "/news/globalnews", + "qa": "/qa", + "qa_capm": "/qa/capm", + "qa_kurtosis": "/qa/kurtosis", + "qa_normality": "/qa/normality", + "qa_om": "/qa/om", + "qa_quantile": "/qa/quantile", + "qa_sh": "/qa/sh", + "qa_skew": "/qa/skew", + "qa_so": "/qa/so", + "qa_summary": "/qa/summary", + "qa_unitroot": "/qa/unitroot", "stocks": "/stocks", "stocks_ca": "/stocks/ca", "stocks_ca_peers": "/stocks/ca/peers", @@ -56,10 +92,39 @@ "stocks_fa_shrs": "/stocks/fa/shrs", "stocks_fa_split": "/stocks/fa/split", "stocks_fa_transcript": "/stocks/fa/transcript", + "stocks_info": "/stocks/info", "stocks_load": "/stocks/load", "stocks_multiples": "/stocks/multiples", "stocks_news": "/stocks/news", "stocks_options": "/stocks/options", "stocks_options_chains": "/stocks/options/chains", - "stocks_quote": "/stocks/quote" + "stocks_quote": "/stocks/quote", + "stocks_search": "/stocks/search", + "ta": "/ta", + "ta_ad": "/ta/ad", + "ta_adosc": "/ta/adosc", + "ta_adx": "/ta/adx", + "ta_aroon": "/ta/aroon", + "ta_atr": "/ta/atr", + "ta_bbands": "/ta/bbands", + "ta_cci": "/ta/cci", + "ta_cg": "/ta/cg", + "ta_clenow": "/ta/clenow", + "ta_cones": "/ta/cones", + "ta_demark": "/ta/demark", + "ta_donchian": "/ta/donchian", + "ta_ema": "/ta/ema", + "ta_fib": "/ta/fib", + "ta_fisher": "/ta/fisher", + "ta_hma": "/ta/hma", + "ta_ichimoku": "/ta/ichimoku", + "ta_kc": "/ta/kc", + "ta_macd": "/ta/macd", + "ta_obv": "/ta/obv", + "ta_rsi": "/ta/rsi", + "ta_sma": "/ta/sma", + "ta_stoch": "/ta/stoch", + "ta_vwap": "/ta/vwap", + "ta_wma": "/ta/wma", + "ta_zlma": "/ta/zlma" } \ No newline at end of file diff --git a/openbb_platform/openbb/package/qa.py b/openbb_platform/openbb/package/qa.py new file mode 100644 index 000000000000..eb7bd70c1d69 --- /dev/null +++ b/openbb_platform/openbb/package/qa.py @@ -0,0 +1,375 @@ +### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ### + +from typing import List, Literal, Union + +import pandas +import typing_extensions +from annotated_types import Ge, Gt +from openbb_core.app.model.obbject import OBBject +from openbb_core.app.static.container import Container +from openbb_core.app.static.filters import filter_inputs +from openbb_provider.abstract.data import Data +from openbb_qa.qa_models import ( + CAPMModel, + NormalityModel, + OmegaModel, + SummaryModel, + UnitRootModel, +) +from pydantic import validate_call + + +class ROUTER_qa(Container): + """/qa + capm + kurtosis + normality + om + quantile + sh + skew + so + summary + unitroot + """ + + def __repr__(self) -> str: + return self.__doc__ or "" + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def capm( + self, data: Union[List[Data], pandas.DataFrame], target: str + ) -> OBBject[CAPMModel]: + """Capital Asset Pricing Model.""" # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + ) + + return self._run( + "/qa/capm", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def kurtosis( + self, + data: Union[List[Data], pandas.DataFrame], + target: str, + window: typing_extensions.Annotated[int, Gt(gt=0)], + ) -> OBBject[List[Data]]: + """Kurtosis. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + window : PositiveInt + Window size. + + Returns + ------- + OBBject[List[Data]] + Kurtosis. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + window=window, + ) + + return self._run( + "/qa/kurtosis", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def normality( + self, data: Union[List[Data], pandas.DataFrame], target: str + ) -> OBBject[NormalityModel]: + """ + Normality Statistics. + + - **Kurtosis**: whether the kurtosis of a sample differs from the normal distribution. + - **Skewness**: whether the skewness of a sample differs from the normal distribution. + - **Jarque-Bera**: whether the sample data has the skewness and kurtosis matching a normal distribution. + - **Shapiro-Wilk**: whether a random sample comes from a normal distribution. + - **Kolmogorov-Smirnov**: whether two underlying one-dimensional probability distributions differ. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + + Returns + ------- + OBBject[NormalityModel] + Normality tests summary. See qa_models.NormalityModel for details. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + ) + + return self._run( + "/qa/normality", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def om( + self, + data: Union[List[Data], pandas.DataFrame], + target: str, + threshold_start: float = 0.0, + threshold_end: float = 1.5, + ) -> OBBject[List[OmegaModel]]: + """Omega Ratio. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + threshold_start : float, optional + Start threshold, by default 0.0 + threshold_end : float, optional + End threshold, by default 1.5 + + Returns + ------- + OBBject[List[OmegaModel]] + Omega ratios. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + threshold_start=threshold_start, + threshold_end=threshold_end, + ) + + return self._run( + "/qa/om", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def quantile( + self, + data: Union[List[Data], pandas.DataFrame], + target: str, + window: typing_extensions.Annotated[int, Gt(gt=0)], + quantile_pct: typing_extensions.Annotated[float, Ge(ge=0)] = 0.5, + ) -> OBBject[List[Data]]: + """Quantile.""" # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + window=window, + quantile_pct=quantile_pct, + ) + + return self._run( + "/qa/quantile", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def sh( + self, + data: Union[List[Data], pandas.DataFrame], + target: str, + rfr: float = 0.0, + window: typing_extensions.Annotated[int, Gt(gt=0)] = 252, + ) -> OBBject[List[Data]]: + """Sharpe Ratio. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + rfr : float, optional + Risk-free rate, by default 0.0 + window : PositiveInt, optional + Window size, by default 252 + + Returns + ------- + OBBject[List[Data]] + Sharpe ratio. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + rfr=rfr, + window=window, + ) + + return self._run( + "/qa/sh", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def skew( + self, + data: Union[List[Data], pandas.DataFrame], + target: str, + window: typing_extensions.Annotated[int, Gt(gt=0)], + ) -> OBBject[List[Data]]: + """Skewness. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + window : PositiveInt + Window size. + + Returns + ------- + OBBject[List[Data]] + Skewness. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + window=window, + ) + + return self._run( + "/qa/skew", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def so( + self, + data: Union[List[Data], pandas.DataFrame], + target: str, + target_return: float = 0.0, + window: typing_extensions.Annotated[int, Gt(gt=0)] = 252, + adjusted: bool = False, + ) -> OBBject[List[Data]]: + """Sortino Ratio. + + For method & terminology see: http://www.redrockcapital.com/Sortino__A__Sharper__Ratio_Red_Rock_Capital.pdf + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + target_return : float, optional + Target return, by default 0.0 + window : PositiveInt, optional + Window size, by default 252 + adjusted : bool, optional + Adjust sortino ratio to compare it to sharpe ratio, by default False + + Returns + ------- + OBBject[List[Data]] + Sortino ratio. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + target_return=target_return, + window=window, + adjusted=adjusted, + ) + + return self._run( + "/qa/so", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def summary( + self, data: Union[List[Data], pandas.DataFrame], target: str + ) -> OBBject[SummaryModel]: + """Summary. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + + Returns + ------- + OBBject[SummaryModel] + Summary table. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + ) + + return self._run( + "/qa/summary", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def unitroot( + self, + data: Union[List[Data], pandas.DataFrame], + target: str, + fuller_reg: Literal["c", "ct", "ctt", "nc", "c"] = "c", + kpss_reg: Literal["c", "ct"] = "c", + ) -> OBBject[UnitRootModel]: + """Unit Root Test. + + Augmented Dickey-Fuller test for unit root. + Kwiatkowski-Phillips-Schmidt-Shin test for unit root. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + fuller_reg : Literal["c", "ct", "ctt", "nc", "c"] + Regression type for ADF test. + kpss_reg : Literal["c", "ct"] + Regression type for KPSS test. + + Returns + ------- + OBBject[UnitRootModel] + Unit root tests summary. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + fuller_reg=fuller_reg, + kpss_reg=kpss_reg, + ) + + return self._run( + "/qa/unitroot", + **inputs, + ) diff --git a/openbb_platform/openbb/package/stocks.py b/openbb_platform/openbb/package/stocks.py index ad7a76dcc30d..d48c39d69e18 100644 --- a/openbb_platform/openbb/package/stocks.py +++ b/openbb_platform/openbb/package/stocks.py @@ -17,11 +17,13 @@ class ROUTER_stocks(Container): """/stocks /ca /fa + info load multiples news /options quote + search """ def __repr__(self) -> str: @@ -39,6 +41,121 @@ def fa(self): # route = "/stocks/fa" return stocks_fa.ROUTER_stocks_fa(command_runner=self._command_runner) + @validate_call + def info( + self, + symbol: typing_extensions.Annotated[ + Union[str, List[str]], + OpenBBCustomParameter(description="Symbol to get data for."), + ], + provider: Union[Literal["cboe"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Get general price and performance metrics of a stock. + + Parameters + ---------- + symbol : str + Symbol to get data for. + provider : Union[Literal['cboe'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'cboe' if there is + no default. + + Returns + ------- + OBBject + results : Union[List[StockInfo]] + Serializable results. + provider : Union[Literal['cboe'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + StockInfo + --------- + symbol : str + Symbol to get data for. + name : str + Name associated with the ticker symbol. + price : Optional[Union[float]] + Last transaction price. + open : Optional[Union[float]] + Opening price of the stock. + high : Optional[Union[float]] + High price of the current trading day. + low : Optional[Union[float]] + Low price of the current trading day. + close : Optional[Union[float]] + Closing price of the most recent trading day. + change : Optional[Union[float]] + Change in price over the current trading period. + change_percent : Optional[Union[float]] + Percent change in price over the current trading period. + prev_close : Optional[Union[float]] + Previous closing price. + type : Optional[Union[str]] + Type of asset. (provider: cboe) + exchange_id : Optional[Union[int]] + The Exchange ID number. (provider: cboe) + tick : Optional[Union[str]] + Whether the last sale was an up or down tick. (provider: cboe) + bid : Optional[Union[float]] + Current bid price. (provider: cboe) + bid_size : Optional[Union[float]] + Bid lot size. (provider: cboe) + ask : Optional[Union[float]] + Current ask price. (provider: cboe) + ask_size : Optional[Union[float]] + Ask lot size. (provider: cboe) + volume : Optional[Union[float]] + Stock volume for the current trading day. (provider: cboe) + iv30 : Optional[Union[float]] + The 30-day implied volatility of the stock. (provider: cboe) + iv30_change : Optional[Union[float]] + Change in 30-day implied volatility of the stock. (provider: cboe) + last_trade_timestamp : Optional[Union[datetime]] + Last trade timestamp for the stock. (provider: cboe) + iv30_annual_high : Optional[Union[float]] + The 1-year high of implied volatility. (provider: cboe) + hv30_annual_high : Optional[Union[float]] + The 1-year high of realized volatility. (provider: cboe) + iv30_annual_low : Optional[Union[float]] + The 1-year low of implied volatility. (provider: cboe) + hv30_annual_low : Optional[Union[float]] + The 1-year low of realized volatility. (provider: cboe) + iv60_annual_high : Optional[Union[float]] + The 60-day high of implied volatility. (provider: cboe) + hv60_annual_high : Optional[Union[float]] + The 60-day high of realized volatility. (provider: cboe) + iv60_annual_low : Optional[Union[float]] + The 60-day low of implied volatility. (provider: cboe) + hv60_annual_low : Optional[Union[float]] + The 60-day low of realized volatility. (provider: cboe) + iv90_annual_high : Optional[Union[float]] + The 90-day high of implied volatility. (provider: cboe) + hv90_annual_high : Optional[Union[float]] + The 90-day high of realized volatility. (provider: cboe)""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "symbol": ",".join(symbol) if isinstance(symbol, list) else symbol, + }, + extra_params=kwargs, + ) + + return self._run( + "/stocks/info", + **inputs, + ) + @validate_call def load( self, @@ -58,7 +175,11 @@ def load( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Union[Literal["fmp", "intrinio", "polygon"], None] = None, + chart: bool = False, + provider: Union[ + Literal["alpha_vantage", "cboe", "fmp", "intrinio", "polygon", "yfinance"], + None, + ] = None, **kwargs ) -> OBBject[List[Data]]: """Load stock data for a specific ticker. @@ -71,14 +192,28 @@ def load( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None] End date of the data, in YYYY-MM-DD format. - provider : Union[Literal['fmp', 'intrinio', 'polygon'], None] + chart : bool + Whether to create a chart or not, by default False. + provider : Union[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygo... The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fmp' if there is + If None, the provider specified in defaults is selected or 'alpha_vantage' if there is no default. + function_ : Literal['TIME_SERIES_INTRADAY', 'TIME_SERIES_DAILY', 'TIME_SERIES_WEEKLY', 'TIME_SERIES_MONTHLY', 'TIME_SERIES_DAILY_ADJUSTED', 'TIME_SERIES_WEEKLY_ADJUSTED', 'TIME_SERIES_MONTHLY_ADJUSTED'] + The time series of your choice. (provider: alpha_vantage) + period : Optional[Union[Literal['intraday', 'daily', 'weekly', 'monthly'], Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']]] + Period of the data to return. (provider: alpha_vantage, yfinance) + interval : Optional[Union[Literal['1min', '5min', '15min', '30min', '60min'], Literal['1d', '1m'], Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] + Data granularity. (provider: alpha_vantage, cboe, fmp, yfinance) + adjusted : Optional[Union[bool]] + Output time series is adjusted by historical split and dividend events. (provider: alpha_vantage, polygon) + extended_hours : Optional[Union[bool]] + Extended trading hours during pre-market and after-hours. (provider: alpha_vantage) + month : Optional[Union[str]] + Query a specific month in history (in YYYY-MM format). (provider: alpha_vantage) + outputsize : Optional[Union[Literal['compact', 'full']]] + Compact returns only the latest 100 data points in the intraday time series; full returns trailing 30 days of the most recent intraday data if the month parameter (see above) is not specified, or the full intraday data for a specific month in history if the month parameter is specified. (provider: alpha_vantage) timeseries : Optional[Union[typing_extensions.Annotated[int, Ge(ge=0)]]] Number of days to look back. (provider: fmp) - interval : Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'] - Data granularity. (provider: fmp) timezone : Optional[Union[Literal['Africa/Algiers', 'Africa/Cairo', 'Africa/Casablanca', 'Africa/Harare', 'Africa/Johannesburg', 'Africa/Monrovia', 'Africa/Nairobi', 'America/Argentina/Buenos_Aires', 'America/Bogota', 'America/Caracas', 'America/Chicago', 'America/Chihuahua', 'America/Denver', 'America/Godthab', 'America/Guatemala', 'America/Guyana', 'America/Halifax', 'America/Indiana/Indianapolis', 'America/Juneau', 'America/La_Paz', 'America/Lima', 'America/Lima', 'America/Los_Angeles', 'America/Mazatlan', 'America/Mexico_City', 'America/Mexico_City', 'America/Monterrey', 'America/Montevideo', 'America/New_York', 'America/Phoenix', 'America/Regina', 'America/Santiago', 'America/Sao_Paulo', 'America/St_Johns', 'America/Tijuana', 'Asia/Almaty', 'Asia/Baghdad', 'Asia/Baku', 'Asia/Bangkok', 'Asia/Bangkok', 'Asia/Chongqing', 'Asia/Colombo', 'Asia/Dhaka', 'Asia/Dhaka', 'Asia/Hong_Kong', 'Asia/Irkutsk', 'Asia/Jakarta', 'Asia/Jerusalem', 'Asia/Kabul', 'Asia/Kamchatka', 'Asia/Karachi', 'Asia/Karachi', 'Asia/Kathmandu', 'Asia/Kolkata', 'Asia/Kolkata', 'Asia/Kolkata', 'Asia/Kolkata', 'Asia/Krasnoyarsk', 'Asia/Kuala_Lumpur', 'Asia/Kuwait', 'Asia/Magadan', 'Asia/Muscat', 'Asia/Muscat', 'Asia/Novosibirsk', 'Asia/Rangoon', 'Asia/Riyadh', 'Asia/Seoul', 'Asia/Shanghai', 'Asia/Singapore', 'Asia/Srednekolymsk', 'Asia/Taipei', 'Asia/Tashkent', 'Asia/Tbilisi', 'Asia/Tehran', 'Asia/Tokyo', 'Asia/Tokyo', 'Asia/Tokyo', 'Asia/Ulaanbaatar', 'Asia/Urumqi', 'Asia/Vladivostok', 'Asia/Yakutsk', 'Asia/Yekaterinburg', 'Asia/Yerevan', 'Atlantic/Azores', 'Atlantic/Cape_Verde', 'Atlantic/South_Georgia', 'Australia/Adelaide', 'Australia/Brisbane', 'Australia/Darwin', 'Australia/Hobart', 'Australia/Melbourne', 'Australia/Melbourne', 'Australia/Perth', 'Australia/Sydney', 'Etc/UTC', 'UTC', 'Europe/Amsterdam', 'Europe/Athens', 'Europe/Belgrade', 'Europe/Berlin', 'Europe/Berlin', 'Europe/Bratislava', 'Europe/Brussels', 'Europe/Bucharest', 'Europe/Budapest', 'Europe/Copenhagen', 'Europe/Dublin', 'Europe/Helsinki', 'Europe/Istanbul', 'Europe/Kaliningrad', 'Europe/Kiev', 'Europe/Lisbon', 'Europe/Ljubljana', 'Europe/London', 'Europe/London', 'Europe/Madrid', 'Europe/Minsk', 'Europe/Moscow', 'Europe/Moscow', 'Europe/Paris', 'Europe/Prague', 'Europe/Riga', 'Europe/Rome', 'Europe/Samara', 'Europe/Sarajevo', 'Europe/Skopje', 'Europe/Sofia', 'Europe/Stockholm', 'Europe/Tallinn', 'Europe/Vienna', 'Europe/Vilnius', 'Europe/Volgograd', 'Europe/Warsaw', 'Europe/Zagreb', 'Pacific/Apia', 'Pacific/Auckland', 'Pacific/Auckland', 'Pacific/Chatham', 'Pacific/Fakaofo', 'Pacific/Fiji', 'Pacific/Guadalcanal', 'Pacific/Guam', 'Pacific/Honolulu', 'Pacific/Majuro', 'Pacific/Midway', 'Pacific/Midway', 'Pacific/Noumea', 'Pacific/Pago_Pago', 'Pacific/Port_Moresby', 'Pacific/Tongatapu']]] Returns trading times in this timezone. (provider: intrinio) source : Optional[Union[Literal['realtime', 'delayed', 'nasdaq_basic']]] @@ -97,15 +232,33 @@ def load( Sort order of the data. (provider: polygon) limit : int The number of data entries to return. (provider: polygon) - adjusted : bool - Output time series is adjusted by historical split and dividend events. (provider: polygon) + prepost : bool + Include Pre and Post market data. (provider: yfinance) + actions : bool + Include actions. (provider: yfinance) + auto_adjust : bool + Adjust all OHLC data automatically. (provider: yfinance) + back_adjust : bool + Attempt to adjust all the data automatically. (provider: yfinance) + progress : bool + Show progress bar. (provider: yfinance) + ignore_tz : bool + When combining from different timezones, ignore that part of datetime. (provider: yfinance) + rounding : bool + Round to two decimal places? (provider: yfinance) + repair : bool + Detect currency unit 100x mixups and attempt repair. (provider: yfinance) + keepna : bool + Keep NaN rows returned by Yahoo? (provider: yfinance) + group_by : Literal['ticker', 'column'] + Group by ticker or column. (provider: yfinance) Returns ------- OBBject results : Union[List[StockHistorical]] Serializable results. - provider : Union[Literal['fmp', 'intrinio', 'polygon'], None] + provider : Union[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygon', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -130,8 +283,18 @@ def load( The volume of the symbol. vwap : Optional[Union[typing_extensions.Annotated[float, Gt(gt=0)]]] Volume Weighted Average Price of the symbol. - adj_close : Optional[Union[float]] - Adjusted Close Price of the symbol. (provider: fmp) + adj_close : Optional[Union[typing_extensions.Annotated[float, Gt(gt=0)], float]] + The adjusted close price of the symbol. (provider: alpha_vantage, fmp) + dividend_amount : Optional[Union[typing_extensions.Annotated[float, Ge(ge=0)]]] + Dividend amount paid for the corresponding date. (provider: alpha_vantage) + split_coefficient : Optional[Union[typing_extensions.Annotated[float, Ge(ge=0)]]] + Split coefficient for the corresponding date. (provider: alpha_vantage) + calls_volume : Optional[Union[float]] + Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + puts_volume : Optional[Union[float]] + Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + total_options_volume : Optional[Union[float]] + Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) unadjusted_volume : Optional[Union[float]] Unadjusted volume of the symbol. (provider: fmp) change : Optional[Union[float]] @@ -162,6 +325,7 @@ def load( "end_date": end_date, }, extra_params=kwargs, + chart=chart, ) return self._run( @@ -180,6 +344,7 @@ def multiples( Union[int, None], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, + chart: bool = False, provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: @@ -191,6 +356,8 @@ def multiples( Symbol to get data for. limit : Union[int, None] The number of data entries to return. + chart : bool + Whether to create a chart or not, by default False. provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is @@ -342,6 +509,7 @@ def multiples( "limit": limit, }, extra_params=kwargs, + chart=chart, ) return self._run( @@ -359,7 +527,10 @@ def news( Union[typing_extensions.Annotated[int, Ge(ge=0)], None], OpenBBCustomParameter(description="Number of results to return per page."), ] = 20, - provider: Union[Literal["benzinga", "fmp", "intrinio", "polygon"], None] = None, + chart: bool = False, + provider: Union[ + Literal["benzinga", "fmp", "intrinio", "polygon", "yfinance"], None + ] = None, **kwargs ) -> OBBject[List[Data]]: """Get news for one or more stock tickers. @@ -370,7 +541,9 @@ def news( Comma separated list of symbols. limit : Union[typing_extensions.Annotated[int, Ge(ge=0)], None] Number of results to return per page. - provider : Union[Literal['benzinga', 'fmp', 'intrinio', 'polygon'], None] + chart : bool + Whether to create a chart or not, by default False. + provider : Union[Literal['benzinga', 'fmp', 'intrinio', 'polygon', 'yfinance... The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'benzinga' if there is no default. @@ -410,7 +583,7 @@ def news( OBBject results : Union[List[StockNews]] Serializable results. - provider : Union[Literal['benzinga', 'fmp', 'intrinio', 'polygon'], None] + provider : Union[Literal['benzinga', 'fmp', 'intrinio', 'polygon', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -457,10 +630,18 @@ def news( Image URL. (provider: polygon) keywords : Optional[Union[List[str]]] Keywords in the article (provider: polygon) - publisher : Optional[Union[openbb_polygon.models.stock_news.PolygonPublisher]] - Publisher of the article. (provider: polygon) + publisher : Optional[Union[openbb_polygon.models.stock_news.PolygonPublisher, str]] + Publisher of the article. (provider: polygon, yfinance) tickers : Optional[Union[List[str]]] - Tickers covered in the article. (provider: polygon)""" # noqa: E501 + Tickers covered in the article. (provider: polygon) + uuid : Optional[Union[str]] + Unique identifier for the news article (provider: yfinance) + type : Optional[Union[str]] + Type of the news article (provider: yfinance) + thumbnail : Optional[Union[List]] + Thumbnail related data to the ticker news article. (provider: yfinance) + related_tickers : Optional[Union[str]] + Tickers related to the news article. (provider: yfinance)""" # noqa: E501 inputs = filter_inputs( provider_choices={ @@ -471,6 +652,7 @@ def news( "limit": limit, }, extra_params=kwargs, + chart=chart, ) return self._run( @@ -626,3 +808,70 @@ def quote( "/stocks/quote", **inputs, ) + + @validate_call + def search( + self, + query: typing_extensions.Annotated[ + str, OpenBBCustomParameter(description="Search query.") + ] = "", + ticker: typing_extensions.Annotated[ + bool, + OpenBBCustomParameter(description="Whether to search by ticker symbol."), + ] = False, + provider: Union[Literal["cboe"], None] = None, + **kwargs + ) -> OBBject[List[Data]]: + """Search for a company or stock ticker. + + Parameters + ---------- + query : str + Search query. + ticker : bool + Whether to search by ticker symbol. + provider : Union[Literal['cboe'], None] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'cboe' if there is + no default. + + Returns + ------- + OBBject + results : Union[List[StockSearch]] + Serializable results. + provider : Union[Literal['cboe'], None] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra: Dict[str, Any] + Extra info. + + StockSearch + ----------- + symbol : str + Symbol to get data for. + name : str + Name of the company. + dpm_name : Optional[Union[str]] + Name of the primary market maker. (provider: cboe) + post_station : Optional[Union[str]] + Post and station location on the CBOE trading floor. (provider: cboe)""" # noqa: E501 + + inputs = filter_inputs( + provider_choices={ + "provider": provider, + }, + standard_params={ + "query": query, + "ticker": ticker, + }, + extra_params=kwargs, + ) + + return self._run( + "/stocks/search", + **inputs, + ) diff --git a/openbb_platform/openbb/package/stocks_fa.py b/openbb_platform/openbb/package/stocks_fa.py index 62e86f641b17..7d5cd9ee5793 100644 --- a/openbb_platform/openbb/package/stocks_fa.py +++ b/openbb_platform/openbb/package/stocks_fa.py @@ -1,15 +1,15 @@ ### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ### import datetime -from typing import List, Literal, Optional, Union +from typing import List, Literal, Union +import typing_extensions from openbb_core.app.model.custom_parameter import OpenBBCustomParameter from openbb_core.app.model.obbject import OBBject from openbb_core.app.static.container import Container from openbb_core.app.static.filters import filter_inputs from openbb_provider.abstract.data import Data from pydantic import validate_call -from typing_extensions import Annotated class ROUTER_stocks_fa(Container): @@ -50,19 +50,19 @@ def __repr__(self) -> str: @validate_call def balance( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - period: Annotated[ + period: typing_extensions.Annotated[ Literal["annual", "quarter"], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - limit: Annotated[ + limit: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 12, - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + provider: Union[Literal["fmp", "intrinio", "polygon", "yfinance"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Balance Sheet. @@ -75,55 +75,55 @@ def balance( Period of the data to return. limit : int The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] + provider : Union[Literal['fmp', 'intrinio', 'polygon', 'yfinance'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. - cik : Optional[str] + cik : Optional[Union[str]] Central Index Key (CIK) of the company. (provider: fmp) type : Literal['reported', 'standardized'] Type of the statement to be fetched. (provider: intrinio) - year : Optional[int] + year : Optional[Union[int]] Year of the statement to be fetched. (provider: intrinio) - company_name : Optional[str] + company_name : Optional[Union[str]] Name of the company. (provider: polygon) - company_name_search : Optional[str] + company_name_search : Optional[Union[str]] Name of the company to search. (provider: polygon) - sic : Optional[str] + sic : Optional[Union[str]] The Standard Industrial Classification (SIC) of the company. (provider: polygon) - filing_date : Optional[datetime.date] + filing_date : Optional[Union[datetime.date]] Filing date of the financial statement. (provider: polygon) - filing_date_lt : Optional[datetime.date] + filing_date_lt : Optional[Union[datetime.date]] Filing date less than the given date. (provider: polygon) - filing_date_lte : Optional[datetime.date] + filing_date_lte : Optional[Union[datetime.date]] Filing date less than or equal to the given date. (provider: polygon) - filing_date_gt : Optional[datetime.date] + filing_date_gt : Optional[Union[datetime.date]] Filing date greater than the given date. (provider: polygon) - filing_date_gte : Optional[datetime.date] + filing_date_gte : Optional[Union[datetime.date]] Filing date greater than or equal to the given date. (provider: polygon) - period_of_report_date : Optional[datetime.date] + period_of_report_date : Optional[Union[datetime.date]] Period of report date of the financial statement. (provider: polygon) - period_of_report_date_lt : Optional[datetime.date] + period_of_report_date_lt : Optional[Union[datetime.date]] Period of report date less than the given date. (provider: polygon) - period_of_report_date_lte : Optional[datetime.date] + period_of_report_date_lte : Optional[Union[datetime.date]] Period of report date less than or equal to the given date. (provider: polygon) - period_of_report_date_gt : Optional[datetime.date] + period_of_report_date_gt : Optional[Union[datetime.date]] Period of report date greater than the given date. (provider: polygon) - period_of_report_date_gte : Optional[datetime.date] + period_of_report_date_gte : Optional[Union[datetime.date]] Period of report date greater than or equal to the given date. (provider: polygon) - include_sources : Optional[bool] + include_sources : Optional[Union[bool]] Whether to include the sources of the financial statement. (provider: polygon) - order : Optional[Literal['asc', 'desc']] + order : Optional[Union[Literal['asc', 'desc']]] Order of the financial statement. (provider: polygon) - sort : Optional[Literal['filing_date', 'period_of_report_date']] + sort : Optional[Union[Literal['filing_date', 'period_of_report_date']]] Sort of the financial statement. (provider: polygon) Returns ------- OBBject - results : List[BalanceSheet] + results : Union[List[BalanceSheet]] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] + provider : Union[Literal['fmp', 'intrinio', 'polygon', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -134,19 +134,19 @@ def balance( BalanceSheet ------------ - symbol : Optional[str] + symbol : Optional[Union[str]] Symbol to get data for. date : date Date of the fetched statement. - cik : Optional[str] + cik : Optional[Union[str]] Central Index Key (CIK) of the company. - currency : Optional[str] + currency : Optional[Union[str]] Reporting currency. - filling_date : Optional[date] + filling_date : Optional[Union[date]] Filling date. - accepted_date : Optional[datetime] + accepted_date : Optional[Union[datetime]] Accepted date. - period : Optional[str] + period : Optional[Union[str]] Reporting period of the statement. cash_and_cash_equivalents : Optional[int] Cash and cash equivalents @@ -244,9 +244,9 @@ def balance( Total Debt (provider: fmp) net_debt : Optional[int] Net Debt (provider: fmp) - link : Optional[str] + link : Optional[Union[str]] Link to the statement. (provider: fmp) - final_link : Optional[str] + final_link : Optional[Union[str]] Link to the final statement. (provider: fmp)""" # noqa: E501 inputs = filter_inputs( @@ -269,15 +269,15 @@ def balance( @validate_call def balance_growth( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - limit: Annotated[ + limit: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 10, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Balance Sheet Statement Growth. @@ -288,7 +288,7 @@ def balance_growth( Symbol to get data for. limit : int The number of data entries to return. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -296,9 +296,9 @@ def balance_growth( Returns ------- OBBject - results : List[BalanceSheetGrowth] + results : Union[List[BalanceSheetGrowth]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -309,7 +309,7 @@ def balance_growth( BalanceSheetGrowth ------------------ - symbol : Optional[str] + symbol : Optional[Union[str]] Symbol to get data for. date : date The date of the data. @@ -413,19 +413,19 @@ def balance_growth( @validate_call def cal( self, - start_date: Annotated[ + start_date: typing_extensions.Annotated[ Union[datetime.date, str], OpenBBCustomParameter( description="Start date of the data, in YYYY-MM-DD format." ), ] = None, - end_date: Annotated[ + end_date: typing_extensions.Annotated[ Union[datetime.date, str], OpenBBCustomParameter( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Show Dividend Calendar for a given start and end dates. @@ -436,7 +436,7 @@ def cal( Start date of the data, in YYYY-MM-DD format. end_date : date End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -444,9 +444,9 @@ def cal( Returns ------- OBBject - results : List[DividendCalendar] + results : Union[List[DividendCalendar]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -463,15 +463,15 @@ def cal( The date of the data. label : str Date in human readable form in the calendar. - adj_dividend : Optional[float] + adj_dividend : Optional[Union[float]] Adjusted dividend on a date in the calendar. - dividend : Optional[float] + dividend : Optional[Union[float]] Dividend amount in the calendar. - record_date : Optional[date] + record_date : Optional[Union[date]] Record date of the dividend in the calendar. - payment_date : Optional[date] + payment_date : Optional[Union[date]] Payment date of the dividend in the calendar. - declaration_date : Optional[date] + declaration_date : Optional[Union[date]] Declaration date of the dividend in the calendar.""" # noqa: E501 inputs = filter_inputs( @@ -493,19 +493,19 @@ def cal( @validate_call def cash( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - period: Annotated[ + period: typing_extensions.Annotated[ Literal["annual", "quarter"], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - limit: Annotated[ + limit: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 12, - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + provider: Union[Literal["fmp", "intrinio", "polygon", "yfinance"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Cash Flow Statement. @@ -518,55 +518,55 @@ def cash( Period of the data to return. limit : int The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] + provider : Union[Literal['fmp', 'intrinio', 'polygon', 'yfinance'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. - cik : Optional[str] + cik : Optional[Union[str]] Central Index Key (CIK) of the company. (provider: fmp) type : Literal['reported', 'standardized'] Type of the statement to be fetched. (provider: intrinio) - year : Optional[int] + year : Optional[Union[int]] Year of the statement to be fetched. (provider: intrinio) - company_name : Optional[str] + company_name : Optional[Union[str]] Name of the company. (provider: polygon) - company_name_search : Optional[str] + company_name_search : Optional[Union[str]] Name of the company to search. (provider: polygon) - sic : Optional[str] + sic : Optional[Union[str]] The Standard Industrial Classification (SIC) of the company. (provider: polygon) - filing_date : Optional[datetime.date] + filing_date : Optional[Union[datetime.date]] Filing date of the financial statement. (provider: polygon) - filing_date_lt : Optional[datetime.date] + filing_date_lt : Optional[Union[datetime.date]] Filing date less than the given date. (provider: polygon) - filing_date_lte : Optional[datetime.date] + filing_date_lte : Optional[Union[datetime.date]] Filing date less than or equal to the given date. (provider: polygon) - filing_date_gt : Optional[datetime.date] + filing_date_gt : Optional[Union[datetime.date]] Filing date greater than the given date. (provider: polygon) - filing_date_gte : Optional[datetime.date] + filing_date_gte : Optional[Union[datetime.date]] Filing date greater than or equal to the given date. (provider: polygon) - period_of_report_date : Optional[datetime.date] + period_of_report_date : Optional[Union[datetime.date]] Period of report date of the financial statement. (provider: polygon) - period_of_report_date_lt : Optional[datetime.date] + period_of_report_date_lt : Optional[Union[datetime.date]] Period of report date less than the given date. (provider: polygon) - period_of_report_date_lte : Optional[datetime.date] + period_of_report_date_lte : Optional[Union[datetime.date]] Period of report date less than or equal to the given date. (provider: polygon) - period_of_report_date_gt : Optional[datetime.date] + period_of_report_date_gt : Optional[Union[datetime.date]] Period of report date greater than the given date. (provider: polygon) - period_of_report_date_gte : Optional[datetime.date] + period_of_report_date_gte : Optional[Union[datetime.date]] Period of report date greater than or equal to the given date. (provider: polygon) - include_sources : Optional[bool] + include_sources : Optional[Union[bool]] Whether to include the sources of the financial statement. (provider: polygon) - order : Optional[Literal['asc', 'desc']] + order : Optional[Union[Literal['asc', 'desc']]] Order of the financial statement. (provider: polygon) - sort : Optional[Literal['filing_date', 'period_of_report_date']] + sort : Optional[Union[Literal['filing_date', 'period_of_report_date']]] Sort of the financial statement. (provider: polygon) Returns ------- OBBject - results : List[CashFlowStatement] + results : Union[List[CashFlowStatement]] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] + provider : Union[Literal['fmp', 'intrinio', 'polygon', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -577,13 +577,13 @@ def cash( CashFlowStatement ----------------- - symbol : Optional[str] + symbol : Optional[Union[str]] Symbol to get data for. date : date Date of the fetched statement. - period : Optional[str] + period : Optional[Union[str]] Reporting period of the statement. - cik : Optional[str] + cik : Optional[Union[str]] Central Index Key (CIK) of the company. net_income : Optional[int] Net income. @@ -641,11 +641,11 @@ def cash( Net cash flow from financing activities. net_change_in_cash : Optional[int] Net increase (decrease) in cash, cash equivalents, and restricted cash - reported_currency : Optional[str] + reported_currency : Optional[Union[str]] Reported currency in the statement. (provider: fmp) - filling_date : Optional[date] + filling_date : Optional[Union[date]] Filling date. (provider: fmp) - accepted_date : Optional[datetime] + accepted_date : Optional[Union[datetime]] Accepted date. (provider: fmp) calendar_year : Optional[int] Calendar year. (provider: fmp) @@ -667,9 +667,9 @@ def cash( Capital expenditure. (provider: fmp) free_cash_flow : Optional[int] Free cash flow. (provider: fmp) - link : Optional[str] + link : Optional[Union[str]] Link to the statement. (provider: fmp) - final_link : Optional[str] + final_link : Optional[Union[str]] Link to the final statement. (provider: fmp)""" # noqa: E501 inputs = filter_inputs( @@ -692,15 +692,15 @@ def cash( @validate_call def cash_growth( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - limit: Annotated[ + limit: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 10, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Cash Flow Statement Growth. @@ -711,7 +711,7 @@ def cash_growth( Symbol to get data for. limit : int The number of data entries to return. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -719,9 +719,9 @@ def cash_growth( Returns ------- OBBject - results : List[CashFlowStatementGrowth] + results : Union[List[CashFlowStatementGrowth]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -732,7 +732,7 @@ def cash_growth( CashFlowStatementGrowth ----------------------- - symbol : Optional[str] + symbol : Optional[Union[str]] Symbol to get data for. date : date The date of the data. @@ -818,11 +818,11 @@ def cash_growth( @validate_call def comp( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Executive Compensation. @@ -831,7 +831,7 @@ def comp( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -839,9 +839,9 @@ def comp( Returns ------- OBBject - results : List[ExecutiveCompensation] + results : Union[List[ExecutiveCompensation]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -854,7 +854,7 @@ def comp( --------------------- symbol : str Symbol to get data for. - cik : Optional[str] + cik : Optional[Union[str]] Central Index Key (CIK) of the company. filing_date : date Date of the filing. @@ -897,30 +897,30 @@ def comp( @validate_call def comsplit( self, - start_date: Annotated[ + start_date: typing_extensions.Annotated[ Union[datetime.date, None, str], OpenBBCustomParameter( description="Start date of the data, in YYYY-MM-DD format." ), ] = None, - end_date: Annotated[ + end_date: typing_extensions.Annotated[ Union[datetime.date, None, str], OpenBBCustomParameter( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Stock Split Calendar. Parameters ---------- - start_date : Optional[datetime.date] + start_date : Union[datetime.date, None] Start date of the data, in YYYY-MM-DD format. - end_date : Optional[datetime.date] + end_date : Union[datetime.date, None] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -928,9 +928,9 @@ def comsplit( Returns ------- OBBject - results : List[StockSplitCalendar] + results : Union[List[StockSplitCalendar]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -971,11 +971,11 @@ def comsplit( @validate_call def divs( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Historical Dividends. @@ -984,7 +984,7 @@ def divs( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -992,9 +992,9 @@ def divs( Returns ------- OBBject - results : List[HistoricalDividends] + results : Union[List[HistoricalDividends]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1013,11 +1013,11 @@ def divs( Adjusted dividend of the historical dividends. dividend : float Dividend of the historical dividends. - record_date : Optional[date] + record_date : Optional[Union[date]] Record date of the historical dividends. - payment_date : Optional[date] + payment_date : Optional[Union[date]] Payment date of the historical dividends. - declaration_date : Optional[date] + declaration_date : Optional[Union[date]] Declaration date of the historical dividends.""" # noqa: E501 inputs = filter_inputs( @@ -1038,15 +1038,15 @@ def divs( @validate_call def earning( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - limit: Annotated[ - Optional[int], + limit: typing_extensions.Annotated[ + Union[int, None], OpenBBCustomParameter(description="The number of data entries to return."), ] = 50, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Earnings Calendar. @@ -1055,9 +1055,9 @@ def earning( ---------- symbol : str Symbol to get data for. - limit : Optional[int] + limit : Union[int, None] The number of data entries to return. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -1065,9 +1065,9 @@ def earning( Returns ------- OBBject - results : List[EarningsCalendar] + results : Union[List[EarningsCalendar]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1082,15 +1082,15 @@ def earning( Symbol to get data for. date : date The date of the data. - eps : Optional[float] + eps : Optional[Union[float]] EPS of the earnings calendar. - eps_estimated : Optional[float] + eps_estimated : Optional[Union[float]] Estimated EPS of the earnings calendar. time : str Time of the earnings calendar. - revenue : Optional[float] + revenue : Optional[Union[float]] Revenue of the earnings calendar. - revenue_estimated : Optional[float] + revenue_estimated : Optional[Union[float]] Estimated revenue of the earnings calendar. updated_from_date : Optional[date] Updated from date of the earnings calendar. @@ -1116,11 +1116,11 @@ def earning( @validate_call def emp( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Number of Employees. @@ -1129,7 +1129,7 @@ def emp( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -1137,9 +1137,9 @@ def emp( Returns ------- OBBject - results : List[HistoricalEmployees] + results : Union[List[HistoricalEmployees]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1187,19 +1187,19 @@ def emp( @validate_call def est( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - period: Annotated[ - Literal["annual", "quarter"], + period: typing_extensions.Annotated[ + Literal["quarter", "annual"], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - limit: Annotated[ + limit: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 30, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Analyst Estimates. @@ -1212,7 +1212,7 @@ def est( Period of the data to return. limit : int The number of data entries to return. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -1220,9 +1220,9 @@ def est( Returns ------- OBBject - results : List[AnalystEstimates] + results : Union[List[AnalystEstimates]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1298,15 +1298,15 @@ def est( @validate_call def filings( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - limit: Annotated[ - Optional[int], + limit: typing_extensions.Annotated[ + Union[int, None], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Company Filings. @@ -1315,23 +1315,23 @@ def filings( ---------- symbol : str Symbol to get data for. - limit : Optional[int] + limit : Union[int, None] The number of data entries to return. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. - type : Optional[Literal['1', '1-A', '1-E', '1-K', '1-N', '1-SA', '1-U', '1-Z', '10', '10-D', '10-K', '10-M', '10-Q', '11-K', '12b-25', '13F', '13H', '144', '15', '15F', '17-H', '18', '18-K', '19b-4', '19b-4(e)', '19b-7', '2-E', '20-F', '24F-2', '25', '3', '4', '40-F', '5', '6-K', '7-M', '8-A', '8-K', '8-M', '9-M', 'ABS-15G', 'ABS-EE', 'ABS DD-15E', 'ADV', 'ADV-E', 'ADV-H', 'ADV-NR', 'ADV-W', 'ATS', 'ATS-N', 'ATS-R', 'BD', 'BD-N', 'BDW', 'C', 'CA-1', 'CB', 'CFPORTAL', 'CRS', 'CUSTODY', 'D', 'F-1', 'F-10', 'F-3', 'F-4', 'F-6', 'F-7', 'F-8', 'F-80', 'F-N', 'F-X', 'ID', 'MA', 'MA-I', 'MA-NR', 'MA-W', 'MSD', 'MSDW', 'N-14', 'N-17D-1', 'N-17f-1', 'N-17f-2', 'N-18f-1', 'N-1A', 'N-2', 'N-23c-3', 'N-27D-1', 'N-3', 'N-4', 'N-5', 'N-54A', 'N-54C', 'N-6', 'N-6EI-1', 'N-6F', 'N-8A', 'N-8B-2', 'N-8B-4', 'N-8F', 'N-CEN']] + type : Optional[Union[Literal['1', '1-A', '1-E', '1-K', '1-N', '1-SA', '1-U', '1-Z', '10', '10-D', '10-K', '10-M', '10-Q', '11-K', '12b-25', '13F', '13H', '144', '15', '15F', '17-H', '18', '18-K', '19b-4', '19b-4(e)', '19b-7', '2-E', '20-F', '24F-2', '25', '3', '4', '40-F', '5', '6-K', '7-M', '8-A', '8-K', '8-M', '9-M', 'ABS-15G', 'ABS-EE', 'ABS DD-15E', 'ADV', 'ADV-E', 'ADV-H', 'ADV-NR', 'ADV-W', 'ATS', 'ATS-N', 'ATS-R', 'BD', 'BD-N', 'BDW', 'C', 'CA-1', 'CB', 'CFPORTAL', 'CRS', 'CUSTODY', 'D', 'F-1', 'F-10', 'F-3', 'F-4', 'F-6', 'F-7', 'F-8', 'F-80', 'F-N', 'F-X', 'ID', 'MA', 'MA-I', 'MA-NR', 'MA-W', 'MSD', 'MSDW', 'N-14', 'N-17D-1', 'N-17f-1', 'N-17f-2', 'N-18f-1', 'N-1A', 'N-2', 'N-23c-3', 'N-27D-1', 'N-3', 'N-4', 'N-5', 'N-54A', 'N-54C', 'N-6', 'N-6EI-1', 'N-6F', 'N-8A', 'N-8B-2', 'N-8B-4', 'N-8F', 'N-CEN']]] Type of the SEC filing form. (provider: fmp) - page : Optional[int] + page : Optional[Union[int]] Page number of the results. (provider: fmp) Returns ------- OBBject - results : List[CompanyFilings] + results : Union[List[CompanyFilings]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1348,13 +1348,13 @@ def filings( Type of document. link : str URL to the document. - symbol : Optional[str] + symbol : Optional[Union[str]] The ticker symbol of the company. (provider: fmp) - accepted_date : Optional[date] - Accepted date of the SEC filing. (provider: fmp) - cik : Optional[str] + cik : Optional[Union[str]] CIK of the SEC filing. (provider: fmp) - final_link : Optional[str] + accepted_date : Optional[Union[datetime]] + Accepted date of the SEC filing. (provider: fmp) + final_link : Optional[Union[str]] Final link of the SEC filing. (provider: fmp)""" # noqa: E501 inputs = filter_inputs( @@ -1376,19 +1376,19 @@ def filings( @validate_call def income( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - period: Annotated[ + period: typing_extensions.Annotated[ Literal["annual", "quarter"], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - limit: Annotated[ + limit: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 12, - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + provider: Union[Literal["fmp", "intrinio", "polygon", "yfinance"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Income Statement. @@ -1401,55 +1401,55 @@ def income( Period of the data to return. limit : int The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] + provider : Union[Literal['fmp', 'intrinio', 'polygon', 'yfinance'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. - cik : Optional[str] + cik : Optional[Union[str]] The CIK of the company if no symbol is provided. (provider: fmp) type : Literal['reported', 'standardized'] Type of the statement to be fetched. (provider: intrinio) - year : Optional[int] + year : Optional[Union[int]] Year of the statement to be fetched. (provider: intrinio) - company_name : Optional[str] + company_name : Optional[Union[str]] Name of the company. (provider: polygon) - company_name_search : Optional[str] + company_name_search : Optional[Union[str]] Name of the company to search. (provider: polygon) - sic : Optional[str] + sic : Optional[Union[str]] The Standard Industrial Classification (SIC) of the company. (provider: polygon) - filing_date : Optional[datetime.date] + filing_date : Optional[Union[datetime.date]] Filing date of the financial statement. (provider: polygon) - filing_date_lt : Optional[datetime.date] + filing_date_lt : Optional[Union[datetime.date]] Filing date less than the given date. (provider: polygon) - filing_date_lte : Optional[datetime.date] + filing_date_lte : Optional[Union[datetime.date]] Filing date less than or equal to the given date. (provider: polygon) - filing_date_gt : Optional[datetime.date] + filing_date_gt : Optional[Union[datetime.date]] Filing date greater than the given date. (provider: polygon) - filing_date_gte : Optional[datetime.date] + filing_date_gte : Optional[Union[datetime.date]] Filing date greater than or equal to the given date. (provider: polygon) - period_of_report_date : Optional[datetime.date] + period_of_report_date : Optional[Union[datetime.date]] Period of report date of the financial statement. (provider: polygon) - period_of_report_date_lt : Optional[datetime.date] + period_of_report_date_lt : Optional[Union[datetime.date]] Period of report date less than the given date. (provider: polygon) - period_of_report_date_lte : Optional[datetime.date] + period_of_report_date_lte : Optional[Union[datetime.date]] Period of report date less than or equal to the given date. (provider: polygon) - period_of_report_date_gt : Optional[datetime.date] + period_of_report_date_gt : Optional[Union[datetime.date]] Period of report date greater than the given date. (provider: polygon) - period_of_report_date_gte : Optional[datetime.date] + period_of_report_date_gte : Optional[Union[datetime.date]] Period of report date greater than or equal to the given date. (provider: polygon) - include_sources : Optional[bool] + include_sources : Optional[Union[bool]] Whether to include the sources of the financial statement. (provider: polygon) - order : Optional[Literal['asc', 'desc']] + order : Optional[Union[Literal['asc', 'desc']]] Order of the financial statement. (provider: polygon) - sort : Optional[Literal['filing_date', 'period_of_report_date']] + sort : Optional[Union[Literal['filing_date', 'period_of_report_date']]] Sort of the financial statement. (provider: polygon) Returns ------- OBBject - results : List[IncomeStatement] + results : Union[List[IncomeStatement]] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] + provider : Union[Literal['fmp', 'intrinio', 'polygon', 'yfinance'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1460,13 +1460,13 @@ def income( IncomeStatement --------------- - symbol : Optional[str] + symbol : Optional[Union[str]] Symbol to get data for. date : date Date of the income statement. - period : Optional[str] + period : Optional[Union[str]] Period of the income statement. - cik : Optional[str] + cik : Optional[Union[str]] Central Index Key. revenue : Optional[int] Revenue. @@ -1476,7 +1476,7 @@ def income( Gross profit. cost_and_expenses : Optional[int] Cost and expenses. - gross_profit_ratio : Optional[float] + gross_profit_ratio : Optional[Union[float]] Gross profit ratio. research_and_development_expenses : Optional[int] Research and development expenses. @@ -1494,11 +1494,11 @@ def income( Depreciation and amortization. ebitda : Optional[int] Earnings before interest, taxes, depreciation and amortization. - ebitda_ratio : Optional[float] + ebitda_ratio : Optional[Union[float]] Earnings before interest, taxes, depreciation and amortization ratio. operating_income : Optional[int] Operating income. - operating_income_ratio : Optional[float] + operating_income_ratio : Optional[Union[float]] Operating income ratio. interest_income : Optional[int] Interest income. @@ -1508,51 +1508,51 @@ def income( Total other income expenses net. income_before_tax : Optional[int] Income before tax. - income_before_tax_ratio : Optional[float] + income_before_tax_ratio : Optional[Union[float]] Income before tax ratio. income_tax_expense : Optional[int] Income tax expense. net_income : Optional[int] Net income. - net_income_ratio : Optional[float] + net_income_ratio : Optional[Union[float]] Net income ratio. - eps : Optional[float] + eps : Optional[Union[float]] Earnings per share. - eps_diluted : Optional[float] + eps_diluted : Optional[Union[float]] Earnings per share diluted. weighted_average_shares_outstanding : Optional[int] Weighted average shares outstanding. weighted_average_shares_outstanding_dil : Optional[int] Weighted average shares outstanding diluted. - link : Optional[str] + link : Optional[Union[str]] Link to the income statement. - final_link : Optional[str] + final_link : Optional[Union[str]] Final link to the income statement. - reported_currency : Optional[str] + reported_currency : Optional[Union[str]] Reporting currency. (provider: fmp) - filling_date : Optional[date] + filling_date : Optional[Union[date]] Filling date. (provider: fmp) - accepted_date : Optional[datetime] + accepted_date : Optional[Union[datetime]] Accepted date. (provider: fmp) - calendar_year : Optional[int] + calendar_year : Optional[Union[int]] Calendar year. (provider: fmp) - income_loss_from_continuing_operations_before_tax : Optional[float] + income_loss_from_continuing_operations_before_tax : Optional[Union[float]] Income/Loss From Continuing Operations After Tax (provider: polygon) - income_loss_from_continuing_operations_after_tax : Optional[float] + income_loss_from_continuing_operations_after_tax : Optional[Union[float]] Income (loss) from continuing operations after tax (provider: polygon) - benefits_costs_expenses : Optional[float] + benefits_costs_expenses : Optional[Union[float]] Benefits, costs and expenses (provider: polygon) net_income_loss_attributable_to_noncontrolling_interest : Optional[int] Net income (loss) attributable to noncontrolling interest (provider: polygon) - net_income_loss_attributable_to_parent : Optional[float] + net_income_loss_attributable_to_parent : Optional[Union[float]] Net income (loss) attributable to parent (provider: polygon) - net_income_loss_available_to_common_stockholders_basic : Optional[float] + net_income_loss_available_to_common_stockholders_basic : Optional[Union[float]] Net Income/Loss Available To Common Stockholders Basic (provider: polygon) - participating_securities_distributed_and_undistributed_earnings_loss_basic : Optional[float] + participating_securities_distributed_and_undistributed_earnings_loss_basic : Optional[Union[float]] Participating Securities Distributed And Undistributed Earnings Loss Basic (provider: polygon) - nonoperating_income_loss : Optional[float] + nonoperating_income_loss : Optional[Union[float]] Nonoperating Income Loss (provider: polygon) - preferred_stock_dividends_and_other_adjustments : Optional[float] + preferred_stock_dividends_and_other_adjustments : Optional[Union[float]] Preferred stock dividends and other adjustments (provider: polygon)""" # noqa: E501 inputs = filter_inputs( @@ -1575,19 +1575,19 @@ def income( @validate_call def income_growth( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - limit: Annotated[ + limit: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 10, - period: Annotated[ + period: typing_extensions.Annotated[ Literal["annual", "quarter"], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Income Statement Growth. @@ -1600,7 +1600,7 @@ def income_growth( The number of data entries to return. period : Literal['annual', 'quarter'] Period of the data to return. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -1608,9 +1608,9 @@ def income_growth( Returns ------- OBBject - results : List[IncomeStatementGrowth] + results : Union[List[IncomeStatementGrowth]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1621,7 +1621,7 @@ def income_growth( IncomeStatementGrowth --------------------- - symbol : Optional[str] + symbol : Optional[Union[str]] Symbol to get data for. date : date The date of the data. @@ -1700,11 +1700,11 @@ def income_growth( @validate_call def ins( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - transactionType: Annotated[ + transactionType: typing_extensions.Annotated[ Union[ List[ Literal[ @@ -1733,11 +1733,11 @@ def ins( ], OpenBBCustomParameter(description="Type of the transaction."), ] = ["P-Purchase"], - page: Annotated[ - Optional[int], + page: typing_extensions.Annotated[ + Union[int, None], OpenBBCustomParameter(description="Page number of the data to fetch."), ] = 0, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Stock Insider Trading. @@ -1748,9 +1748,9 @@ def ins( Symbol to get data for. transactionType : Union[List[Literal['A-Award', 'C-Conversion', 'D-Return', ... Type of the transaction. - page : Optional[int] + page : Union[int, None] Page number of the data to fetch. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -1758,9 +1758,9 @@ def ins( Returns ------- OBBject - results : List[StockInsiderTrading] + results : Union[List[StockInsiderTrading]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1822,19 +1822,19 @@ def ins( @validate_call def ins_own( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - include_current_quarter: Annotated[ - Optional[bool], + include_current_quarter: typing_extensions.Annotated[ + Union[bool, None], OpenBBCustomParameter(description="Include current quarter data."), ] = False, - date: Annotated[ - Optional[datetime.date], + date: typing_extensions.Annotated[ + Union[datetime.date, None], OpenBBCustomParameter(description="A specific date to get data for."), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Institutional Ownership. @@ -1843,11 +1843,11 @@ def ins_own( ---------- symbol : str Symbol to get data for. - include_current_quarter : Optional[bool] + include_current_quarter : Union[bool, None] Include current quarter data. - date : Optional[datetime.date] + date : Union[datetime.date, None] A specific date to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -1855,9 +1855,9 @@ def ins_own( Returns ------- OBBject - results : List[InstitutionalOwnership] + results : Union[List[InstitutionalOwnership]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1870,7 +1870,7 @@ def ins_own( ---------------------- symbol : str Symbol to get data for. - cik : Optional[str] + cik : Optional[Union[str]] CIK of the company. date : date The date of the data. @@ -1962,19 +1962,19 @@ def ins_own( @validate_call def metrics( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - period: Annotated[ - Optional[Literal["annual", "quarter"]], + period: typing_extensions.Annotated[ + Union[Literal["annual", "quarter"], None], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - limit: Annotated[ - Optional[int], + limit: typing_extensions.Annotated[ + Union[int, None], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Key Metrics. @@ -1983,23 +1983,23 @@ def metrics( ---------- symbol : str Symbol to get data for. - period : Optional[Literal['annual', 'quarter']] + period : Union[Literal['annual', 'quarter'], None] Period of the data to return. - limit : Optional[int] + limit : Union[int, None] The number of data entries to return. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. - with_ttm : Optional[bool] + with_ttm : Optional[Union[bool]] Include trailing twelve months (TTM) data. (provider: fmp) Returns ------- OBBject - results : List[KeyMetrics] + results : Union[List[KeyMetrics]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2010,125 +2010,125 @@ def metrics( KeyMetrics ---------- - symbol : Optional[str] + symbol : Optional[Union[str]] Symbol to get data for. date : date The date of the data. period : str Period of the data. - revenue_per_share : Optional[float] + revenue_per_share : Optional[Union[float]] Revenue per share - net_income_per_share : Optional[float] + net_income_per_share : Optional[Union[float]] Net income per share - operating_cash_flow_per_share : Optional[float] + operating_cash_flow_per_share : Optional[Union[float]] Operating cash flow per share - free_cash_flow_per_share : Optional[float] + free_cash_flow_per_share : Optional[Union[float]] Free cash flow per share - cash_per_share : Optional[float] + cash_per_share : Optional[Union[float]] Cash per share - book_value_per_share : Optional[float] + book_value_per_share : Optional[Union[float]] Book value per share - tangible_book_value_per_share : Optional[float] + tangible_book_value_per_share : Optional[Union[float]] Tangible book value per share - shareholders_equity_per_share : Optional[float] + shareholders_equity_per_share : Optional[Union[float]] Shareholders equity per share - interest_debt_per_share : Optional[float] + interest_debt_per_share : Optional[Union[float]] Interest debt per share - market_cap : Optional[float] + market_cap : Optional[Union[float]] Market capitalization - enterprise_value : Optional[float] + enterprise_value : Optional[Union[float]] Enterprise value - pe_ratio : Optional[float] + pe_ratio : Optional[Union[float]] Price-to-earnings ratio (P/E ratio) - price_to_sales_ratio : Optional[float] + price_to_sales_ratio : Optional[Union[float]] Price-to-sales ratio - pocf_ratio : Optional[float] + pocf_ratio : Optional[Union[float]] Price-to-operating cash flow ratio - pfcf_ratio : Optional[float] + pfcf_ratio : Optional[Union[float]] Price-to-free cash flow ratio - pb_ratio : Optional[float] + pb_ratio : Optional[Union[float]] Price-to-book ratio - ptb_ratio : Optional[float] + ptb_ratio : Optional[Union[float]] Price-to-tangible book ratio - ev_to_sales : Optional[float] + ev_to_sales : Optional[Union[float]] Enterprise value-to-sales ratio - enterprise_value_over_ebitda : Optional[float] + enterprise_value_over_ebitda : Optional[Union[float]] Enterprise value-to-EBITDA ratio - ev_to_operating_cash_flow : Optional[float] + ev_to_operating_cash_flow : Optional[Union[float]] Enterprise value-to-operating cash flow ratio - ev_to_free_cash_flow : Optional[float] + ev_to_free_cash_flow : Optional[Union[float]] Enterprise value-to-free cash flow ratio - earnings_yield : Optional[float] + earnings_yield : Optional[Union[float]] Earnings yield - free_cash_flow_yield : Optional[float] + free_cash_flow_yield : Optional[Union[float]] Free cash flow yield - debt_to_equity : Optional[float] + debt_to_equity : Optional[Union[float]] Debt-to-equity ratio - debt_to_assets : Optional[float] + debt_to_assets : Optional[Union[float]] Debt-to-assets ratio - net_debt_to_ebitda : Optional[float] + net_debt_to_ebitda : Optional[Union[float]] Net debt-to-EBITDA ratio - current_ratio : Optional[float] + current_ratio : Optional[Union[float]] Current ratio - interest_coverage : Optional[float] + interest_coverage : Optional[Union[float]] Interest coverage - income_quality : Optional[float] + income_quality : Optional[Union[float]] Income quality - dividend_yield : Optional[float] + dividend_yield : Optional[Union[float]] Dividend yield - payout_ratio : Optional[float] + payout_ratio : Optional[Union[float]] Payout ratio - sales_general_and_administrative_to_revenue : Optional[float] + sales_general_and_administrative_to_revenue : Optional[Union[float]] Sales general and administrative expenses-to-revenue ratio - research_and_development_to_revenue : Optional[float] + research_and_development_to_revenue : Optional[Union[float]] Research and development expenses-to-revenue ratio - intangibles_to_total_assets : Optional[float] + intangibles_to_total_assets : Optional[Union[float]] Intangibles-to-total assets ratio - capex_to_operating_cash_flow : Optional[float] + capex_to_operating_cash_flow : Optional[Union[float]] Capital expenditures-to-operating cash flow ratio - capex_to_revenue : Optional[float] + capex_to_revenue : Optional[Union[float]] Capital expenditures-to-revenue ratio - capex_to_depreciation : Optional[float] + capex_to_depreciation : Optional[Union[float]] Capital expenditures-to-depreciation ratio - stock_based_compensation_to_revenue : Optional[float] + stock_based_compensation_to_revenue : Optional[Union[float]] Stock-based compensation-to-revenue ratio - graham_number : Optional[float] + graham_number : Optional[Union[float]] Graham number - roic : Optional[float] + roic : Optional[Union[float]] Return on invested capital - return_on_tangible_assets : Optional[float] + return_on_tangible_assets : Optional[Union[float]] Return on tangible assets - graham_net_net : Optional[float] + graham_net_net : Optional[Union[float]] Graham net-net working capital - working_capital : Optional[float] + working_capital : Optional[Union[float]] Working capital - tangible_asset_value : Optional[float] + tangible_asset_value : Optional[Union[float]] Tangible asset value - net_current_asset_value : Optional[float] + net_current_asset_value : Optional[Union[float]] Net current asset value - invested_capital : Optional[float] + invested_capital : Optional[Union[float]] Invested capital - average_receivables : Optional[float] + average_receivables : Optional[Union[float]] Average receivables - average_payables : Optional[float] + average_payables : Optional[Union[float]] Average payables - average_inventory : Optional[float] + average_inventory : Optional[Union[float]] Average inventory - days_sales_outstanding : Optional[float] + days_sales_outstanding : Optional[Union[float]] Days sales outstanding - days_payables_outstanding : Optional[float] + days_payables_outstanding : Optional[Union[float]] Days payables outstanding - days_of_inventory_on_hand : Optional[float] + days_of_inventory_on_hand : Optional[Union[float]] Days of inventory on hand - receivables_turnover : Optional[float] + receivables_turnover : Optional[Union[float]] Receivables turnover - payables_turnover : Optional[float] + payables_turnover : Optional[Union[float]] Payables turnover - inventory_turnover : Optional[float] + inventory_turnover : Optional[Union[float]] Inventory turnover - roe : Optional[float] + roe : Optional[Union[float]] Return on equity - capex_per_share : Optional[float] + capex_per_share : Optional[Union[float]] Capital expenditures per share calendar_year : Optional[int] Calendar year. (provider: fmp)""" # noqa: E501 @@ -2153,11 +2153,11 @@ def metrics( @validate_call def mgmt( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Key Executives. @@ -2166,7 +2166,7 @@ def mgmt( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -2174,9 +2174,9 @@ def mgmt( Returns ------- OBBject - results : List[KeyExecutives] + results : Union[List[KeyExecutives]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2195,7 +2195,7 @@ def mgmt( Pay of the key executive. currency_pay : str Currency of the pay. - gender : Optional[str] + gender : Optional[Union[str]] Gender of the key executive. year_born : Optional[int] Birth year of the key executive. @@ -2220,11 +2220,11 @@ def mgmt( @validate_call def overview( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[Data]: """Company Overview. @@ -2233,7 +2233,7 @@ def overview( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -2241,9 +2241,9 @@ def overview( Returns ------- OBBject - results : CompanyOverview + results : Union[CompanyOverview] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2256,65 +2256,65 @@ def overview( --------------- symbol : str Symbol to get data for. - price : Optional[float] + price : Optional[Union[float]] Price of the company. - beta : Optional[float] + beta : Optional[Union[float]] Beta of the company. vol_avg : Optional[int] Volume average of the company. mkt_cap : Optional[int] Market capitalization of the company. - last_div : Optional[float] + last_div : Optional[Union[float]] Last dividend of the company. - range : Optional[str] + range : Optional[Union[str]] Range of the company. - changes : Optional[float] + changes : Optional[Union[float]] Changes of the company. - company_name : Optional[str] + company_name : Optional[Union[str]] Company name of the company. - currency : Optional[str] + currency : Optional[Union[str]] Currency of the company. - cik : Optional[str] + cik : Optional[Union[str]] CIK of the company. - isin : Optional[str] + isin : Optional[Union[str]] ISIN of the company. - cusip : Optional[str] + cusip : Optional[Union[str]] CUSIP of the company. - exchange : Optional[str] + exchange : Optional[Union[str]] Exchange of the company. - exchange_short_name : Optional[str] + exchange_short_name : Optional[Union[str]] Exchange short name of the company. - industry : Optional[str] + industry : Optional[Union[str]] Industry of the company. - website : Optional[str] + website : Optional[Union[str]] Website of the company. - description : Optional[str] + description : Optional[Union[str]] Description of the company. - ceo : Optional[str] + ceo : Optional[Union[str]] CEO of the company. - sector : Optional[str] + sector : Optional[Union[str]] Sector of the company. - country : Optional[str] + country : Optional[Union[str]] Country of the company. - full_time_employees : Optional[str] + full_time_employees : Optional[Union[str]] Full time employees of the company. - phone : Optional[str] + phone : Optional[Union[str]] Phone of the company. - address : Optional[str] + address : Optional[Union[str]] Address of the company. - city : Optional[str] + city : Optional[Union[str]] City of the company. - state : Optional[str] + state : Optional[Union[str]] State of the company. - zip : Optional[str] + zip : Optional[Union[str]] Zip of the company. - dcf_diff : Optional[float] + dcf_diff : Optional[Union[float]] Discounted cash flow difference of the company. - dcf : Optional[float] + dcf : Optional[Union[float]] Discounted cash flow of the company. - image : Optional[str] + image : Optional[Union[str]] Image of the company. - ipo_date : Optional[date] + ipo_date : Optional[Union[date]] IPO date of the company. default_image : bool If the image is the default image. @@ -2345,19 +2345,19 @@ def overview( @validate_call def own( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - date: Annotated[ - Optional[datetime.date], + date: typing_extensions.Annotated[ + Union[datetime.date, None], OpenBBCustomParameter(description="A specific date to get data for."), ] = None, - page: Annotated[ - Optional[int], + page: typing_extensions.Annotated[ + Union[int, None], OpenBBCustomParameter(description="Page number of the data to fetch."), ] = 0, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Stock Ownership. @@ -2366,11 +2366,11 @@ def own( ---------- symbol : str Symbol to get data for. - date : Optional[datetime.date] + date : Union[datetime.date, None] A specific date to get data for. - page : Optional[int] + page : Union[int, None] Page number of the data to fetch. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -2378,9 +2378,9 @@ def own( Returns ------- OBBject - results : List[StockOwnership] + results : Union[List[StockOwnership]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2490,11 +2490,11 @@ def own( @validate_call def pt( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[Data]: """Price Target Consensus. @@ -2503,7 +2503,7 @@ def pt( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -2511,9 +2511,9 @@ def pt( Returns ------- OBBject - results : PriceTargetConsensus + results : Union[PriceTargetConsensus] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2526,13 +2526,13 @@ def pt( -------------------- symbol : str Symbol to get data for. - target_high : Optional[float] + target_high : Optional[Union[float]] High target of the price target consensus. - target_low : Optional[float] + target_low : Optional[Union[float]] Low target of the price target consensus. - target_consensus : Optional[float] + target_consensus : Optional[Union[float]] Consensus target of the price target consensus. - target_median : Optional[float] + target_median : Optional[Union[float]] Median target of the price target consensus.""" # noqa: E501 inputs = filter_inputs( @@ -2553,11 +2553,11 @@ def pt( @validate_call def pta( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Price Target. @@ -2566,7 +2566,7 @@ def pta( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -2576,9 +2576,9 @@ def pta( Returns ------- OBBject - results : List[PriceTarget] + results : Union[List[PriceTarget]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2593,29 +2593,29 @@ def pta( Symbol to get data for. published_date : datetime Published date of the price target. - news_url : Optional[str] + news_url : Optional[Union[str]] News URL of the price target. - news_title : Optional[str] + news_title : Optional[Union[str]] News title of the price target. - analyst_name : Optional[str] + analyst_name : Optional[Union[str]] Analyst name. - analyst_company : Optional[str] + analyst_company : Optional[Union[str]] Analyst company. - price_target : Optional[float] + price_target : Optional[Union[float]] Price target. - adj_price_target : Optional[float] + adj_price_target : Optional[Union[float]] Adjusted price target. - price_when_posted : Optional[float] + price_when_posted : Optional[Union[float]] Price when posted. - news_publisher : Optional[str] + news_publisher : Optional[Union[str]] News publisher of the price target. - news_base_url : Optional[str] + news_base_url : Optional[Union[str]] News base URL of the price target. - new_grade : Optional[str] + new_grade : Optional[Union[str]] New grade (provider: fmp) - previous_grade : Optional[str] + previous_grade : Optional[Union[str]] Previous grade (provider: fmp) - grading_company : Optional[str] + grading_company : Optional[Union[str]] Grading company (provider: fmp)""" # noqa: E501 inputs = filter_inputs( @@ -2636,19 +2636,19 @@ def pta( @validate_call def ratios( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - period: Annotated[ + period: typing_extensions.Annotated[ Literal["annual", "quarter"], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - limit: Annotated[ + limit: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 12, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Extensive set of ratios over time. @@ -2661,19 +2661,19 @@ def ratios( Period of the data to return. limit : int The number of data entries to return. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. - with_ttm : Optional[bool] + with_ttm : Optional[Union[bool]] Include trailing twelve months (TTM) data. (provider: fmp) Returns ------- OBBject - results : List[FinancialRatios] + results : Union[List[FinancialRatios]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2690,113 +2690,113 @@ def ratios( Date of the financial ratios. period : str Period of the financial ratios. - current_ratio : Optional[float] + current_ratio : Optional[Union[float]] Current ratio. - quick_ratio : Optional[float] + quick_ratio : Optional[Union[float]] Quick ratio. - cash_ratio : Optional[float] + cash_ratio : Optional[Union[float]] Cash ratio. - days_of_sales_outstanding : Optional[float] + days_of_sales_outstanding : Optional[Union[float]] Days of sales outstanding. - days_of_inventory_outstanding : Optional[float] + days_of_inventory_outstanding : Optional[Union[float]] Days of inventory outstanding. - operating_cycle : Optional[float] + operating_cycle : Optional[Union[float]] Operating cycle. - days_of_payables_outstanding : Optional[float] + days_of_payables_outstanding : Optional[Union[float]] Days of payables outstanding. - cash_conversion_cycle : Optional[float] + cash_conversion_cycle : Optional[Union[float]] Cash conversion cycle. - gross_profit_margin : Optional[float] + gross_profit_margin : Optional[Union[float]] Gross profit margin. - operating_profit_margin : Optional[float] + operating_profit_margin : Optional[Union[float]] Operating profit margin. - pretax_profit_margin : Optional[float] + pretax_profit_margin : Optional[Union[float]] Pretax profit margin. - net_profit_margin : Optional[float] + net_profit_margin : Optional[Union[float]] Net profit margin. - effective_tax_rate : Optional[float] + effective_tax_rate : Optional[Union[float]] Effective tax rate. - return_on_assets : Optional[float] + return_on_assets : Optional[Union[float]] Return on assets. - return_on_equity : Optional[float] + return_on_equity : Optional[Union[float]] Return on equity. - return_on_capital_employed : Optional[float] + return_on_capital_employed : Optional[Union[float]] Return on capital employed. - net_income_per_ebt : Optional[float] + net_income_per_ebt : Optional[Union[float]] Net income per EBT. - ebt_per_ebit : Optional[float] + ebt_per_ebit : Optional[Union[float]] EBT per EBIT. - ebit_per_revenue : Optional[float] + ebit_per_revenue : Optional[Union[float]] EBIT per revenue. - debt_ratio : Optional[float] + debt_ratio : Optional[Union[float]] Debt ratio. - debt_equity_ratio : Optional[float] + debt_equity_ratio : Optional[Union[float]] Debt equity ratio. - long_term_debt_to_capitalization : Optional[float] + long_term_debt_to_capitalization : Optional[Union[float]] Long term debt to capitalization. - total_debt_to_capitalization : Optional[float] + total_debt_to_capitalization : Optional[Union[float]] Total debt to capitalization. - interest_coverage : Optional[float] + interest_coverage : Optional[Union[float]] Interest coverage. - cash_flow_to_debt_ratio : Optional[float] + cash_flow_to_debt_ratio : Optional[Union[float]] Cash flow to debt ratio. - company_equity_multiplier : Optional[float] + company_equity_multiplier : Optional[Union[float]] Company equity multiplier. - receivables_turnover : Optional[float] + receivables_turnover : Optional[Union[float]] Receivables turnover. - payables_turnover : Optional[float] + payables_turnover : Optional[Union[float]] Payables turnover. - inventory_turnover : Optional[float] + inventory_turnover : Optional[Union[float]] Inventory turnover. - fixed_asset_turnover : Optional[float] + fixed_asset_turnover : Optional[Union[float]] Fixed asset turnover. - asset_turnover : Optional[float] + asset_turnover : Optional[Union[float]] Asset turnover. - operating_cash_flow_per_share : Optional[float] + operating_cash_flow_per_share : Optional[Union[float]] Operating cash flow per share. - free_cash_flow_per_share : Optional[float] + free_cash_flow_per_share : Optional[Union[float]] Free cash flow per share. - cash_per_share : Optional[float] + cash_per_share : Optional[Union[float]] Cash per share. - payout_ratio : Optional[float] + payout_ratio : Optional[Union[float]] Payout ratio. - operating_cash_flow_sales_ratio : Optional[float] + operating_cash_flow_sales_ratio : Optional[Union[float]] Operating cash flow sales ratio. - free_cash_flow_operating_cash_flow_ratio : Optional[float] + free_cash_flow_operating_cash_flow_ratio : Optional[Union[float]] Free cash flow operating cash flow ratio. - cash_flow_coverage_ratios : Optional[float] + cash_flow_coverage_ratios : Optional[Union[float]] Cash flow coverage ratios. - short_term_coverage_ratios : Optional[float] + short_term_coverage_ratios : Optional[Union[float]] Short term coverage ratios. - capital_expenditure_coverage_ratio : Optional[float] + capital_expenditure_coverage_ratio : Optional[Union[float]] Capital expenditure coverage ratio. - dividend_paid_and_capex_coverage_ratio : Optional[float] + dividend_paid_and_capex_coverage_ratio : Optional[Union[float]] Dividend paid and capex coverage ratio. - dividend_payout_ratio : Optional[float] + dividend_payout_ratio : Optional[Union[float]] Dividend payout ratio. - price_book_value_ratio : Optional[float] + price_book_value_ratio : Optional[Union[float]] Price book value ratio. - price_to_book_ratio : Optional[float] + price_to_book_ratio : Optional[Union[float]] Price to book ratio. - price_to_sales_ratio : Optional[float] + price_to_sales_ratio : Optional[Union[float]] Price to sales ratio. - price_earnings_ratio : Optional[float] + price_earnings_ratio : Optional[Union[float]] Price earnings ratio. - price_to_free_cash_flows_ratio : Optional[float] + price_to_free_cash_flows_ratio : Optional[Union[float]] Price to free cash flows ratio. - price_to_operating_cash_flows_ratio : Optional[float] + price_to_operating_cash_flows_ratio : Optional[Union[float]] Price to operating cash flows ratio. - price_cash_flow_ratio : Optional[float] + price_cash_flow_ratio : Optional[Union[float]] Price cash flow ratio. - price_earnings_to_growth_ratio : Optional[float] + price_earnings_to_growth_ratio : Optional[Union[float]] Price earnings to growth ratio. - price_sales_ratio : Optional[float] + price_sales_ratio : Optional[Union[float]] Price sales ratio. - dividend_yield : Optional[float] + dividend_yield : Optional[Union[float]] Dividend yield. - enterprise_value_multiple : Optional[float] + enterprise_value_multiple : Optional[Union[float]] Enterprise value multiple. - price_fair_value : Optional[float] + price_fair_value : Optional[Union[float]] Price fair value.""" # noqa: E501 inputs = filter_inputs( @@ -2819,19 +2819,19 @@ def ratios( @validate_call def revgeo( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - period: Annotated[ - Literal["annual", "quarter"], + period: typing_extensions.Annotated[ + Literal["quarter", "annual"], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - structure: Annotated[ + structure: typing_extensions.Annotated[ Literal["hierarchical", "flat"], OpenBBCustomParameter(description="Structure of the returned data."), ] = "flat", - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Revenue Geographic. @@ -2844,7 +2844,7 @@ def revgeo( Period of the data to return. structure : Literal['hierarchical', 'flat'] Structure of the returned data. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -2852,9 +2852,9 @@ def revgeo( Returns ------- OBBject - results : List[RevenueGeographic] + results : Union[List[RevenueGeographic]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2900,19 +2900,19 @@ def revgeo( @validate_call def revseg( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - period: Annotated[ - Literal["annual", "quarter"], + period: typing_extensions.Annotated[ + Literal["quarter", "annual"], OpenBBCustomParameter(description="Period of the data to return."), ] = "annual", - structure: Annotated[ + structure: typing_extensions.Annotated[ Literal["hierarchical", "flat"], OpenBBCustomParameter(description="Structure of the returned data."), ] = "flat", - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Revenue Business Line. @@ -2925,7 +2925,7 @@ def revseg( Period of the data to return. structure : Literal['hierarchical', 'flat'] Structure of the returned data. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -2933,9 +2933,9 @@ def revseg( Returns ------- OBBject - results : List[RevenueBusinessLine] + results : Union[List[RevenueBusinessLine]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2971,11 +2971,11 @@ def revseg( @validate_call def shrs( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Share Statistics. @@ -2984,7 +2984,7 @@ def shrs( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -2992,9 +2992,9 @@ def shrs( Returns ------- OBBject - results : List[ShareStatistics] + results : Union[List[ShareStatistics]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -3007,15 +3007,15 @@ def shrs( --------------- symbol : str Symbol to get data for. - date : Optional[date] + date : Optional[Union[date]] A specific date to get data for. - free_float : Optional[float] + free_float : Optional[Union[float]] Percentage of unrestricted shares of a publicly-traded company. - float_shares : Optional[float] + float_shares : Optional[Union[float]] Number of shares available for trading by the general public. - outstanding_shares : Optional[float] + outstanding_shares : Optional[Union[float]] Total number of shares of a publicly-traded company. - source : Optional[str] + source : Optional[Union[str]] Source of the received data.""" # noqa: E501 inputs = filter_inputs( @@ -3036,11 +3036,11 @@ def shrs( @validate_call def split( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Historical Stock Splits. @@ -3049,7 +3049,7 @@ def split( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -3057,9 +3057,9 @@ def split( Returns ------- OBBject - results : List[HistoricalStockSplits] + results : Union[List[HistoricalStockSplits]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -3097,21 +3097,21 @@ def split( @validate_call def transcript( self, - symbol: Annotated[ + symbol: typing_extensions.Annotated[ Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - year: Annotated[ + year: typing_extensions.Annotated[ int, OpenBBCustomParameter(description="Year of the earnings call transcript."), ], - quarter: Annotated[ + quarter: typing_extensions.Annotated[ int, OpenBBCustomParameter( description="Quarter of the earnings call transcript." ), ] = 1, - provider: Optional[Literal["fmp"]] = None, + provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Earnings Call Transcript. @@ -3124,7 +3124,7 @@ def transcript( Year of the earnings call transcript. quarter : int Quarter of the earnings call transcript. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default. @@ -3132,9 +3132,9 @@ def transcript( Returns ------- OBBject - results : List[EarningsCallTranscript] + results : Union[List[EarningsCallTranscript]] Serializable results. - provider : Optional[Literal['fmp']] + provider : Union[Literal['fmp'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. diff --git a/openbb_platform/openbb/package/stocks_options.py b/openbb_platform/openbb/package/stocks_options.py index 888b0019d9ce..38a7e1b66214 100644 --- a/openbb_platform/openbb/package/stocks_options.py +++ b/openbb_platform/openbb/package/stocks_options.py @@ -26,7 +26,7 @@ def chains( Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for."), ], - provider: Union[Literal["intrinio"], None] = None, + provider: Union[Literal["cboe", "intrinio"], None] = None, **kwargs ) -> OBBject[List[Data]]: """Get the complete options chain for a ticker. @@ -35,11 +35,11 @@ def chains( ---------- symbol : str Symbol to get data for. - provider : Union[Literal['intrinio'], None] + provider : Union[Literal['cboe', 'intrinio'], None] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'intrinio' if there is + If None, the provider specified in defaults is selected or 'cboe' if there is no default. - date : Optional[Union[str]] + date : Optional[Union[datetime.date]] Date for which the options chains are returned. (provider: intrinio) Returns @@ -47,7 +47,7 @@ def chains( OBBject results : Union[List[OptionsChains]] Serializable results. - provider : Union[Literal['intrinio'], None] + provider : Union[Literal['cboe', 'intrinio'], None] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -60,15 +60,15 @@ def chains( ------------- contract_symbol : str Contract symbol for the option. - symbol : str + symbol : Union[str] Underlying symbol for the option. expiration : date Expiration date of the contract. strike : float Strike price of the contract. - type : str + option_type : str Call or Put. - date : date + eod_date : date Date for which the options chains are returned. close : Optional[Union[float]] Close price for the option that day. @@ -109,7 +109,29 @@ def chains( theta : Optional[Union[float]] Theta of the option. vega : Optional[Union[float]] - Vega of the option.""" # noqa: E501 + Vega of the option. + bid_size : Optional[Union[int]] + Bid size for the option. (provider: cboe) + ask_size : Optional[Union[int]] + Ask size for the option. (provider: cboe) + theoretical : Optional[Union[float]] + Theoretical value of the option. (provider: cboe) + last_trade_price : Optional[Union[float]] + Last trade price of the option. (provider: cboe) + tick : Optional[Union[str]] + Whether the last tick was up or down in price. (provider: cboe) + prev_close : Optional[Union[float]] + Previous closing price of the option. (provider: cboe) + change : Optional[Union[float]] + Change in price of the option. (provider: cboe) + change_percent : Optional[Union[float]] + Change, in percent, of the option. (provider: cboe) + rho : Optional[Union[float]] + Rho of the option. (provider: cboe) + last_trade_timestamp : Optional[Union[datetime]] + Last trade timestamp of the option. (provider: cboe) + dte : Optional[Union[int]] + Days to expiration for the option. (provider: cboe)""" # noqa: E501 inputs = filter_inputs( provider_choices={ diff --git a/openbb_platform/openbb/package/ta.py b/openbb_platform/openbb/package/ta.py new file mode 100644 index 000000000000..120046b289d1 --- /dev/null +++ b/openbb_platform/openbb/package/ta.py @@ -0,0 +1,1485 @@ +### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ### + +from typing import List, Literal, Union + +import pandas +import typing_extensions +from annotated_types import Ge, Gt +from openbb_core.app.model.obbject import OBBject +from openbb_core.app.static.container import Container +from openbb_core.app.static.filters import filter_inputs +from openbb_provider.abstract.data import Data +from pydantic import validate_call + + +class ROUTER_ta(Container): + """/ta + ad + adosc + adx + aroon + atr + bbands + cci + cg + clenow + cones + demark + donchian + ema + fib + fisher + hma + ichimoku + kc + macd + obv + rsi + sma + stoch + vwap + wma + zlma + """ + + def __repr__(self) -> str: + return self.__doc__ or "" + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def ad( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + offset: int = 0, + ) -> OBBject[List[Data]]: + """ + The Accumulation/Distribution Line is similar to the On Balance + Volume (OBV), which sums the volume times +1/-1 based on whether the close is + higher than the previous close. The Accumulation/Distribution indicator, however + multiplies the volume by the close location value (CLV). The CLV is based on the + movement of the issue within a single bar and can be +1, -1 or zero. + + + The Accumulation/Distribution Line is interpreted by looking for a divergence in + the direction of the indicator relative to price. If the Accumulation/Distribution + Line is trending upward it indicates that the price may follow. Also, if the + Accumulation/Distribution Line becomes flat while the price is still rising (or falling) + then it signals an impending flattening of the price. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + index : str, optional + Index column name to use with `data`, by default "date". + offset : int, optional + Offset of the AD, by default 0. + + Returns + ------- + OBBject[List[Data]] + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> ad_data = obb.ta.ad(data=stock_data.results,offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + offset=offset, + ) + + return self._run( + "/ta/ad", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def adosc( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + fast: typing_extensions.Annotated[int, Gt(gt=0)] = 3, + slow: typing_extensions.Annotated[int, Gt(gt=0)] = 10, + offset: int = 0, + ) -> OBBject[List[Data]]: + """ + Accumulation/Distribution Oscillator, also known as the Chaikin Oscillator + is essentially a momentum indicator, but of the Accumulation-Distribution line + rather than merely price. It looks at both the strength of price moves and the + underlying buying and selling pressure during a given time period. The oscillator + reading above zero indicates net buying pressure, while one below zero registers + net selling pressure. Divergence between the indicator and pure price moves are + the most common signals from the indicator, and often flag market turning points. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + fast : PositiveInt, optional + Number of periods to be used for the fast calculation, by default 3. + slow : PositiveInt, optional + Number of periods to be used for the slow calculation, by default 10. + offset : int, optional + Offset to be used for the calculation, by default 0. + + Returns + ------- + OBBject[List[Data]] + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> adosc_data = obb.ta.adosc(data=stock_data.results, fast=3, slow=10, offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + fast=fast, + slow=slow, + offset=offset, + ) + + return self._run( + "/ta/adosc", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def adx( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + length: int = 50, + scalar: float = 100.0, + drift: int = 1, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + The ADX is a Welles Wilder style moving average of the Directional Movement Index (DX). + The values range from 0 to 100, but rarely get above 60. To interpret the ADX, consider + a high number to be a strong trend, and a low number, a weak trend. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + index : str, optional + Index column name to use with `data`, by default "date". + length : int, optional + Number of periods for the ADX, by default 50. + scalar : float, optional + Scalar value for the ADX, by default 100.0. + drift : int, optional + Drift value for the ADX, by default 1. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> adx_data = obb.ta.adx(data=stock_data.results,length=50,scalar=100.0,drift=1) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + length=length, + scalar=scalar, + drift=drift, + chart=chart, + ) + + return self._run( + "/ta/adx", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def aroon( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + length: int = 25, + scalar: int = 100, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + The word aroon is Sanskrit for "dawn's early light." The Aroon + indicator attempts to show when a new trend is dawning. The indicator consists + of two lines (Up and Down) that measure how long it has been since the highest + high/lowest low has occurred within an n period range. + + When the Aroon Up is staying between 70 and 100 then it indicates an upward trend. + When the Aroon Down is staying between 70 and 100 then it indicates an downward trend. + A strong upward trend is indicated when the Aroon Up is above 70 while the Aroon Down is below 30. + Likewise, a strong downward trend is indicated when the Aroon Down is above 70 while + the Aroon Up is below 30. Also look for crossovers. When the Aroon Down crosses above + the Aroon Up, it indicates a weakening of the upward trend (and vice versa). + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + index: str, optional + Index column name to use with `data`, by default "date". + length : int, optional + Number of periods to be used for the calculation, by default 25. + scalar : int, optional + Scalar to be used for the calculation, by default 100. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> aroon_data = obb.ta.aroon(data=stock_data.results, length=25, scalar=100) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + length=length, + scalar=scalar, + chart=chart, + ) + + return self._run( + "/ta/aroon", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def atr( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + length: typing_extensions.Annotated[int, Gt(gt=0)] = 14, + mamode: Literal["rma", "ema", "sma", "wma"] = "rma", + drift: typing_extensions.Annotated[int, Ge(ge=0)] = 1, + offset: int = 0, + ) -> OBBject[List[Data]]: + """ + Average True Range is used to measure volatility, especially volatility caused by + gaps or limit moves. + + Parameters + ---------- + data : List[Data] + List of data to apply the indicator to. + index : str, optional + Index column name, by default "date" + length : PositiveInt, optional + It's period, by default 14 + mamode : Literal["rma", "ema", "sma", "wma"], optional + Moving average mode, by default "rma" + drift : NonNegativeInt, optional + The difference period, by default 1 + offset : int, optional + How many periods to offset the result, by default 0 + + Returns + ------- + OBBject[List[Data]] + List of data with the indicator applied. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> atr_data = obb.ta.atr(data=stock_data.results) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + length=length, + mamode=mamode, + drift=drift, + offset=offset, + ) + + return self._run( + "/ta/atr", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def bbands( + self, + data: Union[List[Data], pandas.DataFrame], + target: str = "close", + index: str = "date", + length: int = 50, + std: typing_extensions.Annotated[float, Ge(ge=0)] = 2, + mamode: Literal["sma", "ema", "wma", "rma"] = "sma", + offset: int = 0, + ) -> OBBject[List[Data]]: + """ + Bollinger Bands consist of three lines. The middle band is a simple + moving average (generally 20 periods) of the typical price (TP). The upper and lower + bands are F standard deviations (generally 2) above and below the middle band. + The bands widen and narrow when the volatility of the price is higher or lower, + respectively. + + Bollinger Bands do not, in themselves, generate buy or sell signals; + they are an indicator of overbought or oversold conditions. When the price is near the + upper or lower band it indicates that a reversal may be imminent. The middle band + becomes a support or resistance level. The upper and lower bands can also be + interpreted as price targets. When the price bounces off of the lower band and crosses + the middle band, then the upper band becomes the price target. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + target : str + Target column name. + index : str, optional + Index column name to use with `data`, by default "date". + length : int, optional + Number of periods to be used for the calculation, by default 50. + std : NonNegativeFloat, optional + Standard deviation to be used for the calculation, by default 2. + mamode : Literal["sma", "ema", "wma", "rma"], optional + Moving average mode to be used for the calculation, by default "sma". + offset : int, optional + Offset to be used for the calculation, by default 0. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> bbands = obb.ta.bbands( + >>> data=stock_data.results, target="close", length=50, std=2, mamode="sma", offset=0 + >>> ) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + index=index, + length=length, + std=std, + mamode=mamode, + offset=offset, + ) + + return self._run( + "/ta/bbands", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def cci( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + length: typing_extensions.Annotated[int, Gt(gt=0)] = 14, + scalar: typing_extensions.Annotated[float, Gt(gt=0)] = 0.015, + ) -> OBBject[List[Data]]: + """ + The CCI is designed to detect beginning and ending market trends. + The range of 100 to -100 is the normal trading range. CCI values outside of this + range indicate overbought or oversold conditions. You can also look for price + divergence in the CCI. If the price is making new highs, and the CCI is not, + then a price correction is likely. + + Parameters + ---------- + data : List[Data] + The data to use for the CCI calculation. + index : str, optional + Index column name to use with `data`, by default "date". + length : PositiveInt, optional + The length of the CCI, by default 14. + scalar : PositiveFloat, optional + The scalar of the CCI, by default 0.015. + + Returns + ------- + OBBject[List[Data]] + The CCI data. + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + length=length, + scalar=scalar, + ) + + return self._run( + "/ta/cci", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def cg( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + length: typing_extensions.Annotated[int, Gt(gt=0)] = 14, + ) -> OBBject[List[Data]]: + """ + The Center of Gravity indicator, in short, is used to anticipate future price movements + and to trade on price reversals as soon as they happen. However, just like other oscillators, + the COG indicator returns the best results in range-bound markets and should be avoided when + the price is trending. Traders who use it will be able to closely speculate the upcoming + price change of the asset. + + Parameters + ---------- + data : List[Data] + The data to use for the COG calculation. + index : str, optional + Index column name to use with `data`, by default "date" + length : PositiveInt, optional + The length of the COG, by default 14 + + Returns + ------- + OBBject[List[Data]] + The COG data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> cg_data = obb.ta.cg(data=stock_data.results, length=14) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + length=length, + ) + + return self._run( + "/ta/cg", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def clenow( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + target: str = "adj_close", + period: typing_extensions.Annotated[int, Gt(gt=0)] = 90, + ) -> OBBject[List[Data]]: + """ + Clenow Volatility Adjusted Momentum. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + index : str, optional + Index column name to use with `data`, by default "date". + target : str, optional + Target column name, by default "adj_close". + period : PositiveInt, optional + Number of periods for the momentum, by default 90. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> clenow_data = obb.ta.clenow(data=stock_data.results,period=90) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + target=target, + period=period, + ) + + return self._run( + "/ta/clenow", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def cones( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + lower_q: float = 0.25, + upper_q: float = 0.75, + model: Literal[ + "STD", + "Parkinson", + "Garman-Klass", + "Hodges-Tompkins", + "Rogers-Satchell", + "Yang-Zhang", + ] = "STD", + is_crypto: bool = False, + ) -> OBBject[List[Data]]: + """Calculate the realized volatility quantiles over rolling windows of time. + + The model for calculating volatility is selectable. + + Parameters + ---------- + data : List[Data] + The data to use for the calculation. + index : str, optional + Index column name to use with `data`, by default "date" + lower_q : float, optional + The lower quantile value for calculations + upper_q : float, optional + The upper quantile value for calculations + model : Literal["STD", "Parkinson", "Garman-Klass", "Hodges-Tompkins", "Rogers-Satchell", "Yang-Zhang"], optional + The model used to calculate realized volatility + + Standard deviation measures how widely returns are dispersed from the average return. + It is the most common (and biased) estimator of volatility. + + Parkinson volatility uses the high and low price of the day rather than just close to close prices. + It is useful for capturing large price movements during the day. + + Garman-Klass volatility extends Parkinson volatility by taking into account the opening and closing price. + As markets are most active during the opening and closing of a trading session; + it makes volatility estimation more accurate. + + Hodges-Tompkins volatility is a bias correction for estimation using an overlapping data sample. + It produces unbiased estimates and a substantial gain in efficiency. + + Rogers-Satchell is an estimator for measuring the volatility with an average return not equal to zero. + Unlike Parkinson and Garman-Klass estimators, Rogers-Satchell incorporates a drift term, + mean return not equal to zero. + + Yang-Zhang volatility is the combination of the overnight (close-to-open volatility). + It is a weighted average of the Rogers-Satchell volatility and the open-to-close volatility. + is_crypto : bool, optional + Whether the data is crypto or not. If True, volatility is calculated for 365 days instead of 252 + + Returns + ------- + OBBject[List[Data]] + The cones data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> cones_data = obb.ta.cones(data=stock_data.results, lower_q=0.25, upper_q=0.75, model="STD") + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + lower_q=lower_q, + upper_q=upper_q, + model=model, + is_crypto=is_crypto, + ) + + return self._run( + "/ta/cones", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def demark( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + target: str = "close", + show_all: bool = True, + asint: bool = True, + offset: int = 0, + ) -> OBBject[List[Data]]: + """ + Demark sequential indicator + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + index : str, optional + Index column name to use with `data`, by default "date". + target : str, optional + Target column name, by default "close". + show_all : bool, optional + Show 1 - 13. If set to False, show 6 - 9 + asint : bool, optional + If True, fill NAs with 0 and change type to int, by default True. + offset : int, optional + How many periods to offset the result + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> demark_data = obb.ta.demark(data=stock_data.results,offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + target=target, + show_all=show_all, + asint=asint, + offset=offset, + ) + + return self._run( + "/ta/demark", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def donchian( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + lower_length: typing_extensions.Annotated[int, Gt(gt=0)] = 20, + upper_length: typing_extensions.Annotated[int, Gt(gt=0)] = 20, + offset: int = 0, + ) -> OBBject[List[Data]]: + """ + Donchian Channels are three lines generated by moving average + calculations that comprise an indicator formed by upper and lower + bands around a midrange or median band. The upper band marks the + highest price of a security over N periods while the lower band + marks the lowest price of a security over N periods. The area + between the upper and lower bands represents the Donchian Channel. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + index : str, optional + Index column name to use with `data`, by default "date". + lower_length : PositiveInt, optional + Number of periods for the lower band, by default 20. + upper_length : PositiveInt, optional + Number of periods for the upper band, by default 20. + offset : int, optional + Offset of the Donchian Channel, by default 0. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> donchian_data = obb.ta.donchian(data=stock_data.results,lower_length=20,upper_length=20,offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + lower_length=lower_length, + upper_length=upper_length, + offset=offset, + ) + + return self._run( + "/ta/donchian", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def ema( + self, + data: Union[List[Data], pandas.DataFrame], + target: str = "close", + index: str = "date", + length: int = 50, + offset: int = 0, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + The Exponential Moving Average is a staple of technical + analysis and is used in countless technical indicators. In a Simple Moving + Average, each value in the time period carries equal weight, and values outside + of the time period are not included in the average. However, the Exponential + Moving Average is a cumulative calculation, including all data. Past values have + a diminishing contribution to the average, while more recent values have a greater + contribution. This method allows the moving average to be more responsive to changes + in the data. + + Parameters + ---------- + data : List[Data] + The data to use for the calculation. + target : str + Target column name. + index : str, optional + Index column name to use with `data`, by default "date" + length : int, optional + The length of the calculation, by default 50. + offset : int, optional + The offset of the calculation, by default 0. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> ema_data = obb.ta.ema(data=stock_data.results,target="close",length=50,offset=0) + + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + index=index, + length=length, + offset=offset, + chart=chart, + ) + + return self._run( + "/ta/ema", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def fib( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + close_column: Literal["close", "adj_close"] = "close", + period: typing_extensions.Annotated[int, Gt(gt=0)] = 120, + start_date: Union[str, None] = None, + end_date: Union[str, None] = None, + ) -> OBBject[List[Data]]: + """Create Fibonacci Retracement Levels. + + Parameters + ---------- + data : List[Data] + List of data to apply the indicator to. + index : str, optional + Index column name, by default "date" + period : PositiveInt, optional + Period to calculate the indicator, by default 120 + + Returns + ------- + OBBject[List[Data]] + List of data with the indicator applied. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> fib_data = obb.ta.fib(data=stock_data.results, period=120) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + close_column=close_column, + period=period, + start_date=start_date, + end_date=end_date, + ) + + return self._run( + "/ta/fib", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def fisher( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + length: typing_extensions.Annotated[int, Gt(gt=0)] = 14, + signal: typing_extensions.Annotated[int, Gt(gt=0)] = 1, + ) -> OBBject[List[Data]]: + """ + The Fisher Transform is a technical indicator created by John F. Ehlers + that converts prices into a Gaussian normal distribution.1 The indicator + highlights when prices have moved to an extreme, based on recent prices. + This may help in spotting turning points in the price of an asset. It also + helps show the trend and isolate the price waves within a trend. + + Parameters + ---------- + data : List[Data] + List of data to apply the indicator to. + index : str, optional + Index column name, by default "date" + length : PositiveInt, optional + Fisher period, by default 14 + signal : PositiveInt, optional + Fisher Signal period, by default 1 + + Returns + ------- + OBBject[List[Data]] + List of data with the indicator applied. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> fisher_data = obb.ta.fisher(data=stock_data.results, length=14, signal=1) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + length=length, + signal=signal, + ) + + return self._run( + "/ta/fisher", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def hma( + self, + data: Union[List[Data], pandas.DataFrame], + target: str = "close", + index: str = "date", + length: int = 50, + offset: int = 0, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + The Hull Moving Average solves the age old dilemma of making a moving average + more responsive to current price activity whilst maintaining curve smoothness. + In fact the HMA almost eliminates lag altogether and manages to improve smoothing + at the same time. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + target : str + Target column name. + index : str, optional + Index column name to use with `data`, by default "date". + length : int, optional + Number of periods for the HMA, by default 50. + offset : int, optional + Offset of the HMA, by default 0. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> hma_data = obb.ta.hma(data=stock_data.results,target="close",length=50,offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + index=index, + length=length, + offset=offset, + chart=chart, + ) + + return self._run( + "/ta/hma", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def ichimoku( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + conversion: typing_extensions.Annotated[int, Gt(gt=0)] = 9, + base: typing_extensions.Annotated[int, Gt(gt=0)] = 26, + lagging: typing_extensions.Annotated[int, Gt(gt=0)] = 52, + offset: typing_extensions.Annotated[int, Gt(gt=0)] = 26, + lookahead: bool = False, + ) -> OBBject[List[Data]]: + """ + The Ichimoku Cloud, also known as Ichimoku Kinko Hyo, is a versatile indicator that + defines support and resistance, identifies trend direction, gauges momentum and provides + trading signals. Ichimoku Kinko Hyo translates into "one look equilibrium chart". With + one look, chartists can identify the trend and look for potential signals within that trend. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + index : str, optional + Index column name to use with `data`, by default "date". + conversion : PositiveInt, optional + Number of periods for the conversion line, by default 9. + base : PositiveInt, optional + Number of periods for the base line, by default 26. + lagging : PositiveInt, optional + Number of periods for the lagging span, by default 52. + offset : PositiveInt, optional + Number of periods for the offset, by default 26. + lookahead : bool, optional + drops the Chikou Span Column to prevent potential data leak + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + conversion=conversion, + base=base, + lagging=lagging, + offset=offset, + lookahead=lookahead, + ) + + return self._run( + "/ta/ichimoku", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def kc( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + length: typing_extensions.Annotated[int, Gt(gt=0)] = 20, + scalar: typing_extensions.Annotated[float, Gt(gt=0)] = 20, + mamode: Literal["ema", "sma", "wma", "hma", "zlma"] = "ema", + offset: typing_extensions.Annotated[int, Ge(ge=0)] = 0, + ) -> OBBject[List[Data]]: + """ + Keltner Channels are volatility-based bands that are placed + on either side of an asset's price and can aid in determining + the direction of a trend.The Keltner channel uses the average + true range (ATR) or volatility, with breaks above or below the top + and bottom barriers signaling a continuation. + + Parameters + ---------- + data : List[Data] + The data to use for the Keltner Channels calculation. + index : str, optional + Index column name to use with `data`, by default "date" + length : PositiveInt, optional + The length of the Keltner Channels, by default 20 + scalar : PositiveFloat, optional + The scalar to use for the Keltner Channels, by default 20 + mamode : Literal["ema", "sma", "wma", "hma", "zlma"], optional + The moving average mode to use for the Keltner Channels, by default "ema" + offset : NonNegativeInt, optional + The offset to use for the Keltner Channels, by default 0 + + Returns + ------- + OBBject[List[Data]] + The Keltner Channels data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> kc_data = obb.ta.kc(data=stock_data.results, length=20, scalar=20, ma_mode="ema", offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + length=length, + scalar=scalar, + mamode=mamode, + offset=offset, + ) + + return self._run( + "/ta/kc", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def macd( + self, + data: Union[List[Data], pandas.DataFrame], + target: str = "close", + index: str = "date", + fast: int = 12, + slow: int = 26, + signal: int = 9, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + The Moving Average Convergence Divergence (MACD) is the difference + between two Exponential Moving Averages. The Signal line is an Exponential Moving + Average of the MACD. + + The MACD signals trend changes and indicates the start of new trend direction. + High values indicate overbought conditions, low values indicate oversold conditions. + Divergence with the price indicates an end to the current trend, especially if the + MACD is at extreme high or low values. When the MACD line crosses above the + signal line a buy signal is generated. When the MACD crosses below the signal line a + sell signal is generated. To confirm the signal, the MACD should be above zero for a buy, + and below zero for a sell. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + target : str + Target column name. + fast : int, optional + Number of periods for the fast EMA, by default 12. + slow : int, optional + Number of periods for the slow EMA, by default 26. + signal : int, optional + Number of periods for the signal EMA, by default 9. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> macd_data = obb.ta.macd(data=stock_data.results,target="close",fast=12,slow=26,signal=9) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + index=index, + fast=fast, + slow=slow, + signal=signal, + chart=chart, + ) + + return self._run( + "/ta/macd", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def obv( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + offset: int = 0, + ) -> OBBject[List[Data]]: + """ + The On Balance Volume (OBV) is a cumulative total of the up and + down volume. When the close is higher than the previous close, the volume is added + to the running total, and when the close is lower than the previous close, the volume + is subtracted from the running total. + + To interpret the OBV, look for the OBV to move with the price or precede price moves. + If the price moves before the OBV, then it is a non-confirmed move. A series of rising peaks, + or falling troughs, in the OBV indicates a strong trend. If the OBV is flat, then the market + is not trending. + + Parameters + ---------- + data : List[Data] + List of data to apply the indicator to. + index : str, optional + Index column name, by default "date" + offset : int, optional + How many periods to offset the result, by default 0. + + Returns + ------- + OBBject[List[Data]] + List of data with the indicator applied. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> obv_data = obb.ta.obv(data=stock_data.results, offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + offset=offset, + ) + + return self._run( + "/ta/obv", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def rsi( + self, + data: Union[List[Data], pandas.DataFrame], + target: str = "close", + index: str = "date", + length: int = 14, + scalar: float = 100.0, + drift: int = 1, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + The Relative Strength Index (RSI) calculates a ratio of the + recent upward price movements to the absolute price movement. The RSI ranges + from 0 to 100. The RSI is interpreted as an overbought/oversold indicator when + the value is over 70/below 30. You can also look for divergence with price. If + the price is making new highs/lows, and the RSI is not, it indicates a reversal. + + Parameters + ---------- + data : List[Data] + The data to use for the RSI calculation. + target : str + Target column name. + index : str, optional + Index column name to use with `data`, by default "date" + length : int, optional + The length of the RSI, by default 14 + scalar : float, optional + The scalar to use for the RSI, by default 100.0 + drift : int, optional + The drift to use for the RSI, by default 1 + + Returns + ------- + OBBject[List[Data]] + The RSI data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> rsi_data = obb.ta.rsi(data=stock_data.results, target="close", length=14, scalar=100.0, drift=1) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + index=index, + length=length, + scalar=scalar, + drift=drift, + chart=chart, + ) + + return self._run( + "/ta/rsi", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def sma( + self, + data: Union[List[Data], pandas.DataFrame], + target: str = "close", + index: str = "date", + length: int = 50, + offset: int = 0, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + Moving Averages are used to smooth the data in an array to + help eliminate noise and identify trends. The Simple Moving Average is literally + the simplest form of a moving average. Each output value is the average of the + previous n values. In a Simple Moving Average, each value in the time period carries + equal weight, and values outside of the time period are not included in the average. + This makes it less responsive to recent changes in the data, which can be useful for + filtering out those changes. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + target : str + Target column name. + index : str, optional + Index column name to use with `data`, by default "date". + length : int, optional + Number of periods to be used for the calculation, by default 50. + offset : int, optional + Offset from the current period, by default 0. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> sma_data = obb.ta.sma(data=stock_data.results,target="close",length=50,offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + index=index, + length=length, + offset=offset, + chart=chart, + ) + + return self._run( + "/ta/sma", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def stoch( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + fast_k_period: typing_extensions.Annotated[int, Ge(ge=0)] = 14, + slow_d_period: typing_extensions.Annotated[int, Ge(ge=0)] = 3, + slow_k_period: typing_extensions.Annotated[int, Ge(ge=0)] = 3, + ) -> OBBject[List[Data]]: + """ + The Stochastic Oscillator measures where the close is in relation + to the recent trading range. The values range from zero to 100. %D values over 75 + indicate an overbought condition; values under 25 indicate an oversold condition. + When the Fast %D crosses above the Slow %D, it is a buy signal; when it crosses + below, it is a sell signal. The Raw %K is generally considered too erratic to use + for crossover signals. + + Parameters + ---------- + data : List[Data] + The data to use for the Stochastic Oscillator calculation. + index : str, optional + Index column name to use with `data`, by default "date". + fast_k_period : NonNegativeInt, optional + The fast %K period, by default 14. + slow_d_period : NonNegativeInt, optional + The slow %D period, by default 3. + slow_k_period : NonNegativeInt, optional + The slow %K period, by default 3. + + Returns + ------- + OBBject[List[Data]] + The Stochastic Oscillator data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> stoch_data = obb.ta.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + fast_k_period=fast_k_period, + slow_d_period=slow_d_period, + slow_k_period=slow_k_period, + ) + + return self._run( + "/ta/stoch", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def vwap( + self, + data: Union[List[Data], pandas.DataFrame], + index: str = "date", + anchor: str = "D", + offset: int = 0, + ) -> OBBject[List[Data]]: + """ + The Volume Weighted Average Price that measures the average typical price + by volume. It is typically used with intraday charts to identify general direction. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + index : str, optional + Index column name to use with `data`, by default "date". + anchor : str, optional + Anchor period to use for the calculation, by default "D". + See Timeseries Offset Aliases below for additional options: + https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#timeseries-offset-aliases + offset : int, optional + Offset from the current period, by default 0. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> vwap_data = obb.ta.vwap(data=stock_data.results,anchor="D",offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + index=index, + anchor=anchor, + offset=offset, + ) + + return self._run( + "/ta/vwap", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def wma( + self, + data: Union[List[Data], pandas.DataFrame], + target: str = "close", + index: str = "date", + length: int = 50, + offset: int = 0, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + A Weighted Moving Average puts more weight on recent data and less on past data. + This is done by multiplying each bar's price by a weighting factor. Because of its + unique calculation, WMA will follow prices more closely than a corresponding Simple + Moving Average. + + Parameters + ---------- + data : List[Data] + The data to use for the calculation. + target : str + Target column name. + index : str, optional + Index column name to use with `data`, by default "date". + length : int, optional + The length of the WMA, by default 50. + offset : int, optional + The offset of the WMA, by default 0. + + Returns + ------- + OBBject[List[Data]] + The WMA data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> wma_data = obb.ta.wma(data=stock_data.results, target="close", length=50, offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + index=index, + length=length, + offset=offset, + chart=chart, + ) + + return self._run( + "/ta/wma", + **inputs, + ) + + @validate_call(config=dict(arbitrary_types_allowed=True)) + def zlma( + self, + data: Union[List[Data], pandas.DataFrame], + target: str = "close", + index: str = "date", + length: int = 50, + offset: int = 0, + chart: bool = False, + ) -> OBBject[List[Data]]: + """ + The zero lag exponential moving average (ZLEMA) indicator + was created by John Ehlers and Ric Way. The idea is do a + regular exponential moving average (EMA) calculation but + on a de-lagged data instead of doing it on the regular data. + Data is de-lagged by removing the data from "lag" days ago + thus removing (or attempting to) the cumulative effect of + the moving average. + + Parameters + ---------- + data : List[Data] + List of data to be used for the calculation. + target : str + Target column name. + index : str, optional + Index column name to use with `data`, by default "date". + length : int, optional + Number of periods to be used for the calculation, by default 50. + offset : int, optional + Offset to be used for the calculation, by default 0. + + Returns + ------- + OBBject[List[Data]] + The calculated data. + + Examples + -------- + >>> from openbb import obb + >>> stock_data = obb.stocks.load(symbol="TSLA", start_date="2023-01-01", provider="fmp") + >>> zlma_data = obb.ta.zlma(data=stock_data.results, target="close", length=50, offset=0) + """ # noqa: E501 + + inputs = filter_inputs( + data=data, + target=target, + index=index, + length=length, + offset=offset, + chart=chart, + ) + + return self._run( + "/ta/zlma", + **inputs, + ) From 7f25ddf7d8c420a65c76e75af2a983e32f37f149 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Thu, 12 Oct 2023 22:29:03 +0530 Subject: [PATCH 9/9] static --- .../openbb/package/econometrics.py | 48 ++++++++------- openbb_platform/openbb/package/economy.py | 20 +++---- openbb_platform/openbb/package/futures.py | 6 +- openbb_platform/openbb/package/qa.py | 60 ++++++++++++------- openbb_platform/openbb/package/stocks.py | 12 ++-- openbb_platform/openbb/package/stocks_fa.py | 1 - openbb_platform/openbb/package/ta.py | 54 ++++++++--------- 7 files changed, 110 insertions(+), 91 deletions(-) diff --git a/openbb_platform/openbb/package/econometrics.py b/openbb_platform/openbb/package/econometrics.py index dd4009580cc0..f4a1e9f34227 100644 --- a/openbb_platform/openbb/package/econometrics.py +++ b/openbb_platform/openbb/package/econometrics.py @@ -7,9 +7,9 @@ from annotated_types import Gt from openbb_core.app.model.obbject import OBBject from openbb_core.app.static.container import Container +from openbb_core.app.static.decorators import validate from openbb_core.app.static.filters import filter_inputs from openbb_provider.abstract.data import Data -from pydantic import validate_call class ROUTER_econometrics(Container): @@ -33,7 +33,7 @@ class ROUTER_econometrics(Container): def __repr__(self) -> str: return self.__doc__ or "" - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def bgot( self, data: Union[List[Data], pandas.DataFrame], @@ -53,6 +53,7 @@ def bgot( List of columns to use as exogenous variables. lags: PositiveInt Number of lags to use in the test. + Returns ------- OBBject[Data] @@ -71,7 +72,7 @@ def bgot( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def coint( self, data: Union[List[Data], pandas.DataFrame], columns: List[str] ) -> OBBject[Data]: @@ -85,6 +86,7 @@ def coint( Data columns to check cointegration maxlag: PositiveInt Number of lags to use in the test. + Returns ------- OBBject[Data] @@ -101,7 +103,7 @@ def coint( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def corr(self, data: Union[List[Data], pandas.DataFrame]) -> OBBject[List[Data]]: """Get the corrlelation matrix of an input dataset. @@ -125,14 +127,14 @@ def corr(self, data: Union[List[Data], pandas.DataFrame]) -> OBBject[List[Data]] **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def dwat( self, data: Union[List[Data], pandas.DataFrame], y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform Durbin-Watson test for autocorrelation + """Perform Durbin-Watson test for autocorrelation. Parameters ---------- @@ -160,7 +162,7 @@ def dwat( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def granger( self, data: Union[List[Data], pandas.DataFrame], @@ -180,6 +182,7 @@ def granger( Columns to use as exogenous variables. lag: PositiveInt Number of lags to use in the test. + Returns ------- OBBject[Data] @@ -198,7 +201,7 @@ def granger( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def ols( self, data: Union[List[Data], pandas.DataFrame], @@ -233,7 +236,7 @@ def ols( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def ols_summary( self, data: Union[List[Data], pandas.DataFrame], @@ -268,14 +271,14 @@ def ols_summary( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def panelbols( self, data: Union[List[Data], pandas.DataFrame], y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform a Between estimator regression on panel data + """Perform a Between estimator regression on panel data. Parameters ---------- @@ -303,14 +306,14 @@ def panelbols( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def panelfd( self, data: Union[List[Data], pandas.DataFrame], y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform a first-difference estimate for panel data + """Perform a first-difference estimate for panel data. Parameters ---------- @@ -338,14 +341,14 @@ def panelfd( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def panelfmac( self, data: Union[List[Data], pandas.DataFrame], y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Fama-MacBeth estimator for panel data + """Fama-MacBeth estimator for panel data. Parameters ---------- @@ -373,14 +376,14 @@ def panelfmac( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def panelols( self, data: Union[List[Data], pandas.DataFrame], y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """One- and two-way fixed effects estimator for panel data + """One- and two-way fixed effects estimator for panel data. Parameters ---------- @@ -408,14 +411,14 @@ def panelols( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def panelpols( self, data: Union[List[Data], pandas.DataFrame], y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform a Pooled coefficvient estimator regression on panel data + """Perform a Pooled coefficvient estimator regression on panel data. Parameters ---------- @@ -443,14 +446,14 @@ def panelpols( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def panelre( self, data: Union[List[Data], pandas.DataFrame], y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform One-way Random Effects model for panel data + """Perform One-way Random Effects model for panel data. Parameters ---------- @@ -478,7 +481,7 @@ def panelre( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def unitroot( self, data: Union[List[Data], pandas.DataFrame], @@ -496,6 +499,7 @@ def unitroot( regression: str Regression type to use in the test. Either "c" for constant only, "ct" for constant and trend, or "ctt" for constant, trend, and trend-squared. + Returns ------- OBBject[Data] diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 60caf08f5de0..cfb143ae063b 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -180,7 +180,7 @@ def const( **inputs, ) - @validate_call + @validate def cot( self, provider: Union[Literal["quandl"], None] = None, **kwargs ) -> OBBject[List[Data]]: @@ -272,7 +272,7 @@ def cot( **inputs, ) - @validate_call + @validate def cot_search( self, query: typing_extensions.Annotated[ @@ -336,7 +336,7 @@ def cot_search( **inputs, ) - @validate_call + @validate def cpi( self, countries: typing_extensions.Annotated[ @@ -486,7 +486,7 @@ def cpi( **inputs, ) - @validate_call + @validate def european_index( self, symbol: typing_extensions.Annotated[ @@ -571,7 +571,7 @@ def european_index( **inputs, ) - @validate_call + @validate def european_index_constituents( self, symbol: typing_extensions.Annotated[ @@ -654,7 +654,7 @@ def european_index_constituents( **inputs, ) - @validate_call + @validate def fred_index( self, symbol: typing_extensions.Annotated[ @@ -864,7 +864,7 @@ def index( **inputs, ) - @validate_call + @validate def index_search( self, query: typing_extensions.Annotated[ @@ -951,7 +951,7 @@ def index_search( **inputs, ) - @validate_call + @validate def index_snapshots( self, region: typing_extensions.Annotated[ @@ -1032,7 +1032,7 @@ def index_snapshots( **inputs, ) - @validate_call + @validate def risk( self, provider: Union[Literal["fmp"], None] = None, **kwargs ) -> OBBject[List[Data]]: @@ -1083,7 +1083,7 @@ def risk( **inputs, ) - @validate_call + @validate def sp500_multiples( self, series_name: typing_extensions.Annotated[ diff --git a/openbb_platform/openbb/package/futures.py b/openbb_platform/openbb/package/futures.py index 95eaaabfe7ea..6a57a26710d8 100644 --- a/openbb_platform/openbb/package/futures.py +++ b/openbb_platform/openbb/package/futures.py @@ -7,9 +7,9 @@ from openbb_core.app.model.custom_parameter import OpenBBCustomParameter from openbb_core.app.model.obbject import OBBject from openbb_core.app.static.container import Container +from openbb_core.app.static.decorators import validate from openbb_core.app.static.filters import filter_inputs from openbb_provider.abstract.data import Data -from pydantic import validate_call class ROUTER_futures(Container): @@ -21,7 +21,7 @@ class ROUTER_futures(Container): def __repr__(self) -> str: return self.__doc__ or "" - @validate_call + @validate def curve( self, symbol: typing_extensions.Annotated[ @@ -87,7 +87,7 @@ def curve( **inputs, ) - @validate_call + @validate def load( self, symbol: typing_extensions.Annotated[ diff --git a/openbb_platform/openbb/package/qa.py b/openbb_platform/openbb/package/qa.py index eb7bd70c1d69..0be073b7b4c3 100644 --- a/openbb_platform/openbb/package/qa.py +++ b/openbb_platform/openbb/package/qa.py @@ -7,6 +7,7 @@ from annotated_types import Ge, Gt from openbb_core.app.model.obbject import OBBject from openbb_core.app.static.container import Container +from openbb_core.app.static.decorators import validate from openbb_core.app.static.filters import filter_inputs from openbb_provider.abstract.data import Data from openbb_qa.qa_models import ( @@ -16,7 +17,6 @@ SummaryModel, UnitRootModel, ) -from pydantic import validate_call class ROUTER_qa(Container): @@ -36,11 +36,11 @@ class ROUTER_qa(Container): def __repr__(self) -> str: return self.__doc__ or "" - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def capm( self, data: Union[List[Data], pandas.DataFrame], target: str ) -> OBBject[CAPMModel]: - """Capital Asset Pricing Model.""" # noqa: E501 + """Get Capital Asset Pricing Model.""" # noqa: E501 inputs = filter_inputs( data=data, @@ -52,14 +52,14 @@ def capm( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def kurtosis( self, data: Union[List[Data], pandas.DataFrame], target: str, window: typing_extensions.Annotated[int, Gt(gt=0)], ) -> OBBject[List[Data]]: - """Kurtosis. + """Get the Kurtosis. Parameters ---------- @@ -87,12 +87,11 @@ def kurtosis( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def normality( self, data: Union[List[Data], pandas.DataFrame], target: str ) -> OBBject[NormalityModel]: - """ - Normality Statistics. + """Get Normality Statistics. - **Kurtosis**: whether the kurtosis of a sample differs from the normal distribution. - **Skewness**: whether the skewness of a sample differs from the normal distribution. @@ -123,7 +122,7 @@ def normality( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def om( self, data: Union[List[Data], pandas.DataFrame], @@ -131,7 +130,7 @@ def om( threshold_start: float = 0.0, threshold_end: float = 1.5, ) -> OBBject[List[OmegaModel]]: - """Omega Ratio. + """Calculate the Omega Ratio. Parameters ---------- @@ -162,7 +161,7 @@ def om( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def quantile( self, data: Union[List[Data], pandas.DataFrame], @@ -170,7 +169,24 @@ def quantile( window: typing_extensions.Annotated[int, Gt(gt=0)], quantile_pct: typing_extensions.Annotated[float, Ge(ge=0)] = 0.5, ) -> OBBject[List[Data]]: - """Quantile.""" # noqa: E501 + """Get Quantile. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + window : PositiveInt + Window size. + quantile_pct : NonNegativeFloat, optional + Quantile percentage, by default 0.5 + + Returns + ------- + OBBject[List[Data]] + Quantile. + """ # noqa: E501 inputs = filter_inputs( data=data, @@ -184,7 +200,7 @@ def quantile( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def sh( self, data: Union[List[Data], pandas.DataFrame], @@ -192,7 +208,7 @@ def sh( rfr: float = 0.0, window: typing_extensions.Annotated[int, Gt(gt=0)] = 252, ) -> OBBject[List[Data]]: - """Sharpe Ratio. + """Get Sharpe Ratio. Parameters ---------- @@ -223,14 +239,14 @@ def sh( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def skew( self, data: Union[List[Data], pandas.DataFrame], target: str, window: typing_extensions.Annotated[int, Gt(gt=0)], ) -> OBBject[List[Data]]: - """Skewness. + """Get Skewness. Parameters ---------- @@ -258,7 +274,7 @@ def skew( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def so( self, data: Union[List[Data], pandas.DataFrame], @@ -267,7 +283,7 @@ def so( window: typing_extensions.Annotated[int, Gt(gt=0)] = 252, adjusted: bool = False, ) -> OBBject[List[Data]]: - """Sortino Ratio. + """Get Sortino Ratio. For method & terminology see: http://www.redrockcapital.com/Sortino__A__Sharper__Ratio_Red_Rock_Capital.pdf @@ -303,11 +319,11 @@ def so( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def summary( self, data: Union[List[Data], pandas.DataFrame], target: str ) -> OBBject[SummaryModel]: - """Summary. + """Get Summary Statistics. Parameters ---------- @@ -332,7 +348,7 @@ def summary( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def unitroot( self, data: Union[List[Data], pandas.DataFrame], @@ -340,7 +356,7 @@ def unitroot( fuller_reg: Literal["c", "ct", "ctt", "nc", "c"] = "c", kpss_reg: Literal["c", "ct"] = "c", ) -> OBBject[UnitRootModel]: - """Unit Root Test. + """Get Unit Root Test. Augmented Dickey-Fuller test for unit root. Kwiatkowski-Phillips-Schmidt-Shin test for unit root. diff --git a/openbb_platform/openbb/package/stocks.py b/openbb_platform/openbb/package/stocks.py index 0513199a54f6..d747df5f3d91 100644 --- a/openbb_platform/openbb/package/stocks.py +++ b/openbb_platform/openbb/package/stocks.py @@ -41,7 +41,7 @@ def fa(self): # route = "/stocks/fa" return stocks_fa.ROUTER_stocks_fa(command_runner=self._command_runner) - @validate_call + @validate def info( self, symbol: typing_extensions.Annotated[ @@ -156,7 +156,7 @@ def info( **inputs, ) - @validate_call + @validate def load( self, symbol: typing_extensions.Annotated[ @@ -809,13 +809,13 @@ def quote( **inputs, ) - @validate_call + @validate def search( self, query: typing_extensions.Annotated[ str, OpenBBCustomParameter(description="Search query.") ] = "", - ticker: typing_extensions.Annotated[ + is_symbol: typing_extensions.Annotated[ bool, OpenBBCustomParameter(description="Whether to search by ticker symbol."), ] = False, @@ -828,7 +828,7 @@ def search( ---------- query : str Search query. - ticker : bool + is_symbol : bool Whether to search by ticker symbol. provider : Union[Literal['cboe'], None] The provider to use for the query, by default None. @@ -866,7 +866,7 @@ def search( }, standard_params={ "query": query, - "ticker": ticker, + "is_symbol": is_symbol, }, extra_params=kwargs, ) diff --git a/openbb_platform/openbb/package/stocks_fa.py b/openbb_platform/openbb/package/stocks_fa.py index 4eb586acd052..c6b1e84cf32e 100644 --- a/openbb_platform/openbb/package/stocks_fa.py +++ b/openbb_platform/openbb/package/stocks_fa.py @@ -10,7 +10,6 @@ from openbb_core.app.static.decorators import validate from openbb_core.app.static.filters import filter_inputs from openbb_provider.abstract.data import Data -from pydantic import validate_call class ROUTER_stocks_fa(Container): diff --git a/openbb_platform/openbb/package/ta.py b/openbb_platform/openbb/package/ta.py index 120046b289d1..d080bc26eaf3 100644 --- a/openbb_platform/openbb/package/ta.py +++ b/openbb_platform/openbb/package/ta.py @@ -7,9 +7,9 @@ from annotated_types import Ge, Gt from openbb_core.app.model.obbject import OBBject from openbb_core.app.static.container import Container +from openbb_core.app.static.decorators import validate from openbb_core.app.static.filters import filter_inputs from openbb_provider.abstract.data import Data -from pydantic import validate_call class ROUTER_ta(Container): @@ -45,7 +45,7 @@ class ROUTER_ta(Container): def __repr__(self) -> str: return self.__doc__ or "" - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def ad( self, data: Union[List[Data], pandas.DataFrame], @@ -97,7 +97,7 @@ def ad( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def adosc( self, data: Union[List[Data], pandas.DataFrame], @@ -150,7 +150,7 @@ def adosc( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def adx( self, data: Union[List[Data], pandas.DataFrame], @@ -204,7 +204,7 @@ def adx( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def aroon( self, data: Union[List[Data], pandas.DataFrame], @@ -262,7 +262,7 @@ def aroon( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def atr( self, data: Union[List[Data], pandas.DataFrame], @@ -317,7 +317,7 @@ def atr( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def bbands( self, data: Union[List[Data], pandas.DataFrame], @@ -388,7 +388,7 @@ def bbands( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def cci( self, data: Union[List[Data], pandas.DataFrame], @@ -432,7 +432,7 @@ def cci( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def cg( self, data: Union[List[Data], pandas.DataFrame], @@ -478,7 +478,7 @@ def cg( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def clenow( self, data: Union[List[Data], pandas.DataFrame], @@ -524,7 +524,7 @@ def clenow( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def cones( self, data: Union[List[Data], pandas.DataFrame], @@ -606,7 +606,7 @@ def cones( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def demark( self, data: Union[List[Data], pandas.DataFrame], @@ -660,7 +660,7 @@ def demark( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def donchian( self, data: Union[List[Data], pandas.DataFrame], @@ -715,7 +715,7 @@ def donchian( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def ema( self, data: Union[List[Data], pandas.DataFrame], @@ -775,7 +775,7 @@ def ema( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def fib( self, data: Union[List[Data], pandas.DataFrame], @@ -822,7 +822,7 @@ def fib( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def fisher( self, data: Union[List[Data], pandas.DataFrame], @@ -872,7 +872,7 @@ def fisher( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def hma( self, data: Union[List[Data], pandas.DataFrame], @@ -927,7 +927,7 @@ def hma( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def ichimoku( self, data: Union[List[Data], pandas.DataFrame], @@ -977,7 +977,7 @@ def ichimoku( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def kc( self, data: Union[List[Data], pandas.DataFrame], @@ -1035,7 +1035,7 @@ def kc( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def macd( self, data: Union[List[Data], pandas.DataFrame], @@ -1099,7 +1099,7 @@ def macd( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def obv( self, data: Union[List[Data], pandas.DataFrame], @@ -1149,7 +1149,7 @@ def obv( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def rsi( self, data: Union[List[Data], pandas.DataFrame], @@ -1209,7 +1209,7 @@ def rsi( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def sma( self, data: Union[List[Data], pandas.DataFrame], @@ -1267,7 +1267,7 @@ def sma( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def stoch( self, data: Union[List[Data], pandas.DataFrame], @@ -1322,7 +1322,7 @@ def stoch( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def vwap( self, data: Union[List[Data], pandas.DataFrame], @@ -1371,7 +1371,7 @@ def vwap( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def wma( self, data: Union[List[Data], pandas.DataFrame], @@ -1426,7 +1426,7 @@ def wma( **inputs, ) - @validate_call(config=dict(arbitrary_types_allowed=True)) + @validate(config=dict(arbitrary_types_allowed=True)) def zlma( self, data: Union[List[Data], pandas.DataFrame],