From f630df7b8b73d5bfd22e3932e032193261258d93 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 12:03:30 +0000 Subject: [PATCH 001/133] remove auto examples and split python from api --- .../app/assets/parameter_pool.json | 41 ----- .../core/openbb_core/app/example_generator.py | 83 ---------- .../core/openbb_core/app/model/example.py | 12 ++ .../core/openbb_core/app/router.py | 17 +-- .../openbb_core/app/static/package_builder.py | 118 ++++++++------ .../app/static/test_example_generator.py | 59 ------- .../openbb_commodity/commodity_router.py | 6 +- .../crypto/openbb_crypto/crypto_router.py | 7 +- .../openbb_crypto/price/price_router.py | 40 ++++- .../openbb_currency/currency_router.py | 27 +++- .../openbb_currency/price/price_router.py | 20 ++- .../futures/futures_router.py | 33 ++-- .../options/options_router.py | 23 +-- .../econometrics_router.py | 16 +- .../economy/openbb_economy/economy_router.py | 113 +++++++------- .../economy/openbb_economy/gdp/gdp_router.py | 16 +- .../openbb_equity/calendar/calendar_router.py | 46 ++++-- .../openbb_equity/compare/compare_router.py | 26 +++- .../openbb_equity/darkpool/darkpool_router.py | 9 +- .../discovery/discovery_router.py | 50 ++++-- .../equity/openbb_equity/equity_router.py | 16 +- .../estimates/estimates_router.py | 30 ++-- .../fundamental/fundamental_router.py | 144 +++++++++++++----- .../ownership/ownership_router.py | 20 ++- .../openbb_equity/price/price_router.py | 18 ++- .../openbb_equity/shorts/shorts_router.py | 10 +- .../openbb_etf/discovery/discovery_router.py | 16 +- .../extensions/etf/openbb_etf/etf_router.py | 91 ++++++----- .../corporate/corporate_router.py | 24 +-- .../openbb_fixedincome/fixedincome_router.py | 6 +- .../government/government_router.py | 33 ++-- .../openbb_fixedincome/rate/rate_router.py | 41 ++--- .../spreads/spreads_router.py | 16 +- .../index/openbb_index/index_router.py | 38 ++--- .../index/openbb_index/price/price_router.py | 12 +- .../news/openbb_news/news_router.py | 69 ++++++--- .../performance/performance_router.py | 6 +- .../quantitative_router.py | 4 +- .../rolling/rolling_router.py | 12 +- .../openbb_quantitative/stats/stats_router.py | 12 +- .../openbb_regulators/cftc/cftc_router.py | 26 ++-- .../openbb_regulators/sec/sec_router.py | 26 +--- .../openbb_technical/technical_router.py | 52 +++---- openbb_platform/openbb/package/crypto.py | 4 +- .../openbb/package/crypto_price.py | 10 +- .../openbb/package/currency_price.py | 4 +- .../openbb/package/derivatives_options.py | 12 +- openbb_platform/openbb/package/economy.py | 48 +++--- openbb_platform/openbb/package/economy_gdp.py | 6 +- openbb_platform/openbb/package/equity.py | 4 +- .../openbb/package/equity_compare.py | 2 +- .../openbb/package/equity_discovery.py | 16 +- .../openbb/package/equity_estimates.py | 8 +- .../openbb/package/equity_fundamental.py | 45 +++--- .../openbb/package/equity_ownership.py | 8 +- .../openbb/package/equity_price.py | 8 +- openbb_platform/openbb/package/etf.py | 51 ++++--- openbb_platform/openbb/package/fixedincome.py | 2 +- .../openbb/package/fixedincome_corporate.py | 10 +- .../openbb/package/fixedincome_government.py | 2 +- .../openbb/package/fixedincome_rate.py | 12 +- .../openbb/package/fixedincome_spreads.py | 6 +- openbb_platform/openbb/package/index.py | 10 +- .../openbb/package/regulators_sec.py | 12 +- 64 files changed, 904 insertions(+), 860 deletions(-) delete mode 100644 openbb_platform/core/openbb_core/app/assets/parameter_pool.json delete mode 100644 openbb_platform/core/openbb_core/app/example_generator.py create mode 100644 openbb_platform/core/openbb_core/app/model/example.py delete mode 100644 openbb_platform/core/tests/app/static/test_example_generator.py diff --git a/openbb_platform/core/openbb_core/app/assets/parameter_pool.json b/openbb_platform/core/openbb_core/app/assets/parameter_pool.json deleted file mode 100644 index 41b8af1d0f87..000000000000 --- a/openbb_platform/core/openbb_core/app/assets/parameter_pool.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "crypto": { - "symbol": "BTCUSD" - }, - "currency": { - "symbol": "EURUSD" - }, - "derivatives": { - "symbol": "AAPL" - }, - "economy": { - "country": "portugal", - "countries": ["portugal", "spain"] - }, - "economy.fred_series": { - "symbol": "GFDGDPA188S" - }, - "equity": { - "symbol": "AAPL", - "symbols": "AAPL,MSFT", - "query": "AAPL" - }, - "etf": { - "symbol": "SPY", - "query": "Vanguard" - }, - "futures": { - "symbol": "ES" - }, - "index": { - "symbol": "SPX", - "index": "^IBEX" - }, - "news": { - "symbol": "AAPL" - }, - "regulators": { - "symbol": "AAPL", - "query": "AAPL" - } -} diff --git a/openbb_platform/core/openbb_core/app/example_generator.py b/openbb_platform/core/openbb_core/app/example_generator.py deleted file mode 100644 index c661936621d6..000000000000 --- a/openbb_platform/core/openbb_core/app/example_generator.py +++ /dev/null @@ -1,83 +0,0 @@ -"""OpenBB Platform example generator.""" - -import json -from pathlib import Path -from typing import ( - Any, - Dict, -) - -from pydantic.fields import FieldInfo -from pydantic_core import PydanticUndefined - -from openbb_core.app.constants import ASSETS_DIRECTORY -from openbb_core.app.provider_interface import ProviderInterface - -try: - with Path(ASSETS_DIRECTORY, "parameter_pool.json").open() as f: - PARAMETER_POOL = json.load(f) -except Exception: - PARAMETER_POOL = {} - - -class ExampleGenerator: - """Generate examples for the API.""" - - @staticmethod - def _get_value_from_pool(pool: dict, route: str, param: str) -> str: - """Get the value from the pool. - - The example parameters can be defined for: - - route: "crypto.historical.price": {"symbol": "CRYPTO_HISTORICAL_PRICE_SYMBOL"} - - sub-router: "crypto.historical": {"symbol": "CRYPTO_HISTORICAL_SYMBOL"} - - router: "crypto": {"symbol": "CRYPTO_SYMBOL"} - - The search for the 'key' is done in the following order: - - route - - sub-router - - router - """ - parts = route.split(".") - for i in range(len(parts), 0, -1): - partial_route = ".".join(parts[:i]) - if partial_route in pool and param in pool[partial_route]: - return pool[partial_route][param] - return "VALUE_NOT_FOUND" - - @classmethod - def generate( - cls, - route: str, - model: str, - ) -> str: - """Generate the example for the command.""" - if not route or not model: - return "" - - standard_params: Dict[str, FieldInfo] = ( - ProviderInterface() - .map.get(model, {}) - .get("openbb", {}) - .get("QueryParams", {}) - .get("fields", {}) - ) - - eg_params: Dict[str, Any] = {} - for p, v in standard_params.items(): - if v.default is not None: - if v.default is not PydanticUndefined and v.default != "": - eg_params[p] = v.default - else: - eg_params[p] = cls._get_value_from_pool(PARAMETER_POOL, route, p) - - example = f"obb.{route}(" - for n, v in eg_params.items(): - if isinstance(v, str): - v = f'"{v}"' # noqa: PLW2901 - example += f"{n}={v}, " - if eg_params: - example = example[:-2] + ")" - else: - example += ")" - - return example diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py new file mode 100644 index 000000000000..35c7bdf6b36c --- /dev/null +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -0,0 +1,12 @@ +from typing import Any, Dict, Optional + +from pydantic import BaseModel, ConfigDict + + +class Example(BaseModel): + """Example model.""" + + description: Optional[str] = None + parameters: Dict[str, Any] + + model_config = ConfigDict(validate_assignment=True) diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index 038697fdd83b..2c6347e75460 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -25,10 +25,10 @@ from typing_extensions import Annotated, ParamSpec, _AnnotatedAlias from openbb_core.app.deprecation import DeprecationSummary, OpenBBDeprecationWarning -from openbb_core.app.example_generator import ExampleGenerator from openbb_core.app.extension_loader import ExtensionLoader from openbb_core.app.model.abstract.warning import OpenBBWarning from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -233,23 +233,16 @@ def command( api_router = self._api_router model = kwargs.pop("model", "") - examples = kwargs.pop("examples", []) - exclude_auto_examples = kwargs.pop("exclude_auto_examples", False) + api_examples: List[Example] = kwargs.pop("api_examples", []) + python_examples = kwargs.pop("python_examples", None) if func := SignatureInspector.complete(func, model): - if not exclude_auto_examples: - examples.insert( - 0, - ExampleGenerator.generate( - route=SignatureInspector.get_operation_id(func, sep="."), - model=model, - ), - ) kwargs["response_model_exclude_unset"] = True kwargs["openapi_extra"] = kwargs.get("openapi_extra", {}) kwargs["openapi_extra"]["model"] = model - kwargs["openapi_extra"]["examples"] = examples + kwargs["openapi_extra"]["api_examples"] = api_examples + kwargs["openapi_extra"]["python_examples"] = python_examples kwargs["operation_id"] = kwargs.get( "operation_id", SignatureInspector.get_operation_id(func) ) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index abfad97eda61..38b578c09955 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -37,6 +37,7 @@ from openbb_core.app.extension_loader import ExtensionLoader, OpenBBGroups from openbb_core.app.model.custom_parameter import OpenBBCustomParameter +from openbb_core.app.model.example import Example from openbb_core.app.provider_interface import ProviderInterface from openbb_core.app.router import CommandMap, RouterLoader from openbb_core.app.static.utils.console import Console @@ -404,8 +405,9 @@ def build(path: str, ext_map: Optional[Dict[str, List[str]]] = None) -> str: if route.openapi_extra else None ), - examples=route.openapi_extra.get("examples", None), - ) # type: ignore + examples=(route.openapi_extra.get("api_examples", []) or []) + + (route.openapi_extra.get("python_examples", []) or []), + ) else: doc += " /" if path else " /" doc += c.split("/")[-1] + "\n" @@ -701,14 +703,16 @@ def build_command_method_signature( @staticmethod def build_command_method_doc( + path: str, func: Callable, formatted_params: OrderedDict[str, Parameter], model_name: Optional[str] = None, - examples: Optional[List[str]] = None, + examples: Optional[List[Union[Example, str]]] = None, ): """Build the command method docstring.""" doc = func.__doc__ doc = DocstringGenerator.generate( + path=path, func=func, formatted_params=formatted_params, model_name=model_name, @@ -794,7 +798,7 @@ def build_command_method( path: str, func: Callable, model_name: Optional[str] = None, - examples: Optional[List[str]] = None, + examples: Optional[List[Union[Example, str]]] = None, ) -> str: """Build the command method.""" func_name = func.__name__ @@ -812,6 +816,7 @@ def build_command_method( model_name=model_name, ) code += cls.build_command_method_doc( + path=path, func=func, formatted_params=formatted_params, model_name=model_name, @@ -850,16 +855,53 @@ def get_OBBject_description(results_type: str, providers: Optional[str]) -> str: return obbject_description + @staticmethod + def append_examples( + func_name: str, + func_params: dict[str, Field], + examples: Optional[List[Union[Example, str]]], + ) -> str: + """Get the example section from the examples.""" + if examples: + doc = "\n Example\n -------\n" + doc += " >>> from openbb import obb\n" + + for e in examples: + if isinstance(e, Example): + if e.description: + doc += f" >>> # {e.description}\n" + doc += f" >>> obb{func_name}(" + + for k, v in e.parameters.items(): + if k in func_params and (field := func_params.get(k)): + field_type_str = str(field.type) + # TODO: Handle types better, some edge cases + # like Union[str, List[str]] will be stringified + # even if the type is a list + if any( + t in field_type_str for t in ["int", "float", "bool"] + ): + doc += f"{k}={v}, " + else: + doc += f"{k}='{v}', " + else: + doc += f"{k}='{v}', " + + doc = doc.strip(", ") + ")\n" + else: + doc += f" >>> {e}\n" + return doc + return "" + @classmethod def generate_model_docstring( cls, model_name: str, summary: str, explicit_params: dict, - params: dict, + kwarg_params: dict, returns: Dict[str, FieldInfo], results_type: str, - examples: Optional[List[str]] = None, ) -> str: """Create the docstring for model.""" @@ -878,15 +920,6 @@ def format_description(description: str) -> str: description = description.replace("\n", "\n ") return description - standard_dict = params["standard"].__dataclass_fields__ - extra_dict = params["extra"].__dataclass_fields__ - - if examples: - example_docstring = "\n Example\n -------\n" - example_docstring += " >>> from openbb import obb\n" - for example in examples: - example_docstring += f" >>> {example}\n" - docstring = summary.strip("\n") docstring += "\n\n" docstring += " Parameters\n" @@ -894,14 +927,7 @@ def format_description(description: str) -> str: # Explicit parameters for param_name, param in explicit_params.items(): - if param_name in standard_dict: - # pylint: disable=W0212 - p_type = param._annotation.__args__[0] - type_ = p_type.__name__ if inspect.isclass(p_type) else p_type - description = getattr( - param._annotation.__metadata__[0], "description", "" - ) - elif param_name == "provider": + if param_name == "provider": # pylint: disable=W0212 type_ = param._annotation default = param._annotation.__args__[0].__args__[0] @@ -912,15 +938,19 @@ def format_description(description: str) -> str: type_ = "bool" description = "Whether to create a chart or not, by default False." else: - type_ = "" - description = "" + # pylint: disable=W0212 + p_type = param._annotation.__args__[0] + type_ = p_type.__name__ if inspect.isclass(p_type) else p_type + description = getattr( + param._annotation.__metadata__[0], "description", "" + ) type_str = format_type(type_, char_limit=79) # type: ignore docstring += f" {param_name} : {type_str}\n" docstring += f" {format_description(description)}\n" # Kwargs - for param_name, param in extra_dict.items(): + for param_name, param in kwarg_params.items(): p_type = param.type type_ = p_type.__name__ if inspect.isclass(p_type) else p_type @@ -976,50 +1006,52 @@ def format_description(description: str) -> str: docstring += f" {field.alias or name} : {field_type}\n" docstring += f" {format_description(description)}\n" - - if examples: - docstring += example_docstring - return docstring @classmethod def generate( cls, + path: str, func: Callable, formatted_params: OrderedDict[str, Parameter], model_name: Optional[str] = None, - examples: Optional[List[str]] = None, + examples: Optional[List[Union[Example, str]]] = None, ) -> Optional[str]: """Generate the docstring for the function.""" doc = func.__doc__ + func_params = {} if model_name: - params = cls.provider_interface.params.get(model_name, None) + params = cls.provider_interface.params.get(model_name, {}) return_schema = cls.provider_interface.return_schema.get(model_name, None) if params and return_schema: explicit_dict = dict(formatted_params) explicit_dict.pop("extra_params", None) - + kwarg_params = params["extra"].__dataclass_fields__ + func_params = { + **params["standard"].__dataclass_fields__, + **params["extra"].__dataclass_fields__, + } returns = return_schema.model_fields results_type = func.__annotations__.get("return", model_name) if hasattr(results_type, "results_type_repr"): results_type = results_type.results_type_repr() - return cls.generate_model_docstring( + doc = cls.generate_model_docstring( model_name=model_name, summary=func.__doc__ or "", explicit_params=explicit_dict, - params=params, + kwarg_params=kwarg_params, returns=returns, results_type=results_type, - examples=examples, ) - return doc - if examples and examples != [""] and doc: - doc += "\n Examples\n --------\n" - doc += " >>> from openbb import obb\n" - for example in examples: - if example != "": - doc += f" >>> {example}\n" + + if doc and examples: + doc += cls.append_examples( + path.replace("/", "."), + func_params, + examples, + ) + return doc @staticmethod diff --git a/openbb_platform/core/tests/app/static/test_example_generator.py b/openbb_platform/core/tests/app/static/test_example_generator.py deleted file mode 100644 index 86029fabe13f..000000000000 --- a/openbb_platform/core/tests/app/static/test_example_generator.py +++ /dev/null @@ -1,59 +0,0 @@ -"""Test the example_generator.py file.""" - -# pylint: disable=redefined-outer-name, protected-access - - -import pytest -from openbb_core.app.example_generator import ExampleGenerator - - -@pytest.fixture(scope="module") -def example_generator(): - """Return example generator.""" - return ExampleGenerator() - - -def test_docstring_generator_init(example_generator): - """Test example generator init.""" - assert example_generator - - -TEST_POOL = { - "crypto": {"symbol": "CRYPTO_SYMBOL"}, - "crypto.search": {"symbol": "CRYPTO_SEARCH_SYMBOL"}, - "crypto.price.historical": {"symbol": "CRYPTO_HISTORICAL_PRICE_SYMBOL"}, -} - - -@pytest.mark.parametrize( - "route, param, expected", - [ - ("", "", "VALUE_NOT_FOUND"), - ("random_route", "", "VALUE_NOT_FOUND"), - ("crypto", "symbol", "CRYPTO_SYMBOL"), - ("crypto.search", "symbol", "CRYPTO_SEARCH_SYMBOL"), - ("crypto.price.historical", "symbol", "CRYPTO_HISTORICAL_PRICE_SYMBOL"), - ("crypto.price.historical", "random_param", "VALUE_NOT_FOUND"), - ], -) -def test_get_value_from_pool(example_generator, route, param, expected): - """Test get value from pool.""" - assert example_generator._get_value_from_pool(TEST_POOL, route, param) == expected - - -@pytest.mark.parametrize( - "route, model, expected", - [ - ("", "", ""), - ("random", "test", "obb.random()"), - ("crypto.search", "CryptoSearch", "obb.crypto.search()"), - ( - "crypto.price.historical", - "CryptoHistorical", - 'obb.crypto.price.historical(symbol="BTCUSD")', - ), - ], -) -def test_generate(example_generator, route, model, expected): - """Test generate example.""" - assert example_generator.generate(route, model) == expected diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index 6d9a7e63b86d..15189dae5733 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -1,6 +1,7 @@ """The Commodity router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -15,7 +16,10 @@ # pylint: disable=unused-argument -@router.command(model="LbmaFixing") +@router.command( + model="LbmaFixing", + api_examples=[Example(parameters={"asset": "gold"})], +) async def lbma_fixing( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py index e4f6d24ed317..d22aa927f34e 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py @@ -1,6 +1,7 @@ """Crypto Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -19,7 +20,11 @@ # pylint: disable=unused-argument @router.command( model="CryptoSearch", - examples=['obb.crypto.search("BTCUSD")', 'obb.crypto.search("ETH-USD")'], + api_examples=[ + Example(parameters={}), + Example(parameters={"symbol": "BTCUSD"}), + Example(parameters={"symbol": "ETH-USD"}), + ], ) async def search( cc: CommandContext, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index 6c95097c0752..fb4e60f2aff5 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -2,6 +2,7 @@ """Crypto Price Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,11 +18,40 @@ # pylint: disable=unused-argument,line-too-long @router.command( model="CryptoHistorical", - examples=[ - 'obb.crypto.price.historical("BTCUSD", start_date="2024-01-01", end_date="2024-01-31")', - 'obb.crypto.price.historical("ETH-USD", provider="yfinance", interval="1mo", start_date="2024-01-01", end_date="2024-12-31")', # noqa: E501 - 'obb.crypto.price.historical("BTCUSD,ETH-USD", provider="yfinance", interval="1d", start_date="2024-01-01", end_date="2024-01-31")', # noqa: E501 - 'obb.crypto.price.historical(["BTCUSD", "ETH-USD"], start_date="2024-01-01", end_date="2024-01-31")', + api_examples=[ + Example(parameters={"symbol": "BTCUSD"}), + Example( + parameters={ + "symbol": "BTCUSD", + "start_date": "2024-01-01", + "end_date": "2024-01-31", + } + ), + Example( + parameters={ + "symbol": "ETH-USD", + "provider": "yfinance", + "interval": "1mo", + "start_date": "2024-01-01", + "end_date": "2024-12-31", + } + ), # noqa: E501 + Example( + parameters={ + "symbol": "BTCUSD,ETH-USD", + "provider": "yfinance", + "interval": "1d", + "start_date": "2024-01-01", + "end_date": "2024-01-31", + } + ), # noqa: E501 + Example( + parameters={ + "symbol": "BTCUSD,ETH-USD", + "start_date": "2024-01-01", + "end_date": "2024-01-31", + } + ), ], ) async def historical( diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index e7ef5d46f7c6..63fe18701587 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -1,6 +1,7 @@ """The Currency router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -19,13 +20,20 @@ # pylint: disable=unused-argument @router.command( model="CurrencyPairs", - examples=[ - "# Search for 'EURUSD' currency pair using 'polygon' as provider.", - "obb.currency.search(provider='polygon', symbol='EURUSD')", - "# Search for terms using 'polygon' as provider.", - "obb.currency.search(provider='polygon', search='Euro zone')", - "# Search for actively traded currency pairs on the queried date using 'polygon' as provider.", - "obb.currency.search(provider='polygon', date='2024-01-02', active=True)", + api_examples=[ + Example(parameters={}), + Example( + description="Search for 'EURUSD' currency pair using 'polygon' as provider.", + parameters={"provider": "polygon", "symbol": "EURUSD"}, + ), + Example( + description="Search for terms using 'polygon' as provider.", + parameters={"provider": "polygon", "search": "Euro zone"}, + ), + Example( + description="Search for actively traded currency pairs on the queried date using 'polygon' as provider.", + parameters={"provider": "polygon", "date": "2024-01-02", "active": True}, + ), ], ) async def search( @@ -48,7 +56,10 @@ async def search( return await OBBject.from_query(Query(**locals())) -@router.command(model="CurrencyReferenceRates") +@router.command( + model="CurrencyReferenceRates", + api_examples=[Example(parameters={"symbol": "EURUSD"})], +) async def reference_rates( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index 86b029b720d3..9e45e98eedaf 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -10,6 +10,7 @@ ) from openbb_core.app.query import Query from openbb_core.app.router import Router +from openbb_core.app.model.example import Example router = Router(prefix="/price") @@ -17,11 +18,20 @@ # pylint: disable=unused-argument @router.command( model="CurrencyHistorical", - examples=[ - "# Filter historical data with specific start and end date.", - "obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='20213-12-31')", - "# Get data with different granularity.", - "obb.currency.price.historical(symbol='EURUSD', interval='15m', provider='polygon')", + api_examples=[ + Example(parameters={"symbol": "EURUSD"}), + Example( + description="Filter historical data with specific start and end date.", + parameters={ + "symbol": "EURUSD", + "start_date": "2023-01-01", + "end_date": "2023-12-31", + }, + ), + Example( + description="Get data with different granularity.", + parameters={"symbol": "EURUSD", "interval": "15m", "provider": "polygon"}, + ), ], ) async def historical( diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index 1ea63586701d..9834ff32d0ed 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -1,6 +1,7 @@ """Futures Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -16,13 +17,20 @@ # pylint: disable=unused-argument @router.command( model="FuturesHistorical", - exclude_auto_examples=True, - examples=[ - 'obb.derivatives.futures.historical("ES", provider="yfinance")', - '#### Enter expiration dates as "YYYY-MM" ####', - 'obb.derivatives.futures.historical("ES", provider="yfinance", expiration="2025-12")', - "#### Enter multiple symbols as a list. ####", - 'obb.derivatives.futures.historical(["ES", "NQ", "ESZ24.CME", "NQZ24.CME"], provider="yfinance")', + api_examples=[ + Example(parameters={"symbol": "ES", "provider": "yfinance"}), + Example( + description='Enter expiration dates as "YYYY-MM".', + parameters={ + "symbol": "ES", + "provider": "yfinance", + "expiration": "2025-12", + }, + ), + Example( + description="Enter multiple symbols as a list.", + parameters={"symbol": "ES,NQ,ESZ24.CME,NQZ24.CME", "provider": "yfinance"}, + ), ], ) async def historical( @@ -37,11 +45,12 @@ async def historical( @router.command( model="FuturesCurve", - exclude_auto_examples=True, - examples=[ - 'obb.derivatives.futures.curve("NG", provider="yfinance")', - "#### Enter a date to get the term structure from a historical date. ####", - 'obb.derivatives.futures.curve("NG", provider="yfinance", date="2023-01-01")', + api_examples=[ + Example(parameters={"symbol": "NG", "provider": "yfinance"}), + Example( + description="Enter a date to get the term structure from a historical date.", + parameters={"symbol": "NG", "provider": "yfinance", "date": "2023-01-01"}, + ), ], ) async def curve( diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index 925caf5be49b..da46204c615d 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -1,6 +1,7 @@ """Options Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,11 +18,12 @@ @router.command( model="OptionsChains", - exclude_auto_examples=True, - examples=[ - 'chains = obb.derivatives.options.chains(symbol="AAPL", provider="intrinio").to_df()', - '#### Use the "date" parameter to get the end-of-day-data for a specific date, where supported. ####', - 'eod_chains = obb.derivatives.options.chains(symbol="AAPL", date="2023-01-25", provider="intrinio").to_df()', + api_examples=[ + Example(parameters={"symbol": "AAPL", "provider": "intrinio"}), + Example( + description='Use the "date" parameter to get the end-of-day-data for a specific date, where supported.', + parameters={"symbol": "AAPL", "date": "2023-01-25", "provider": "intrinio"}, + ), ], ) async def chains( @@ -36,11 +38,12 @@ async def chains( @router.command( model="OptionsUnusual", - exclude_auto_examples=True, - examples=[ - "options = obb.derivatives.options.unusual().to_df()", - '#### Use the "symbol" parameter to get the most recent activity for a specific symbol. ####', - 'options = obb.derivatives.options.unusual(symbol="TSLA").to_df()', + api_examples=[ + Example(parameters={}), + Example( + description="Use the 'symbol' parameter to get the most recent activity for a specific symbol.", + parameters={"symbol": "TSLA"}, + ), ], ) async def unusual( diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 2a1a941e553d..376334b9ddfc 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -31,7 +31,7 @@ @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.econometrics.correlation_matrix(data=stock_data)", ], @@ -73,7 +73,7 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: @router.command( methods=["POST"], include_in_schema=False, - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.ols_regression(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], @@ -113,7 +113,7 @@ def ols_regression( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], @@ -186,7 +186,7 @@ def ols_regression_summary( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], @@ -228,7 +228,7 @@ def autocorrelation( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], @@ -283,7 +283,7 @@ def residual_autocorrelation( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.cointegration(data=stock_data, columns=["open", "close"])', ], @@ -342,7 +342,7 @@ def cointegration( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.causality(data=stock_data, y_column="close", x_column="open")', ], @@ -399,7 +399,7 @@ def causality( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.unit_root(data=stock_data, column="close")', 'obb.econometrics.unit_root(data=stock_data, column="close", regression="ct")', diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index b6f0bde05d54..6bb7aa71cc8e 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -1,6 +1,7 @@ """Economy Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -20,11 +21,18 @@ @router.command( model="EconomicCalendar", - exclude_auto_examples=True, - examples=[ - 'obb.economy.calendar(provider="fmp", start_date="2020-03-01", end_date="2020-03-31")', - "#### By default, the calendar will be forward-looking. ####", - 'obb.economy.calendar(provider="nasdaq")', + api_examples=[ + Example( + parameters={ + "provider": "fmp", + "start_date": "2020-03-01", + "end_date": "2020-03-31", + } + ), + Example( + description="By default, the calendar will be forward-looking.", + parameters={"provider": "nasdaq"}, + ), ], ) async def calendar( @@ -39,11 +47,15 @@ async def calendar( @router.command( model="ConsumerPriceIndex", - exclude_auto_examples=True, - examples=[ - 'obb.economy.cpi(countries=["japan", "china", "turkey"]).to_df()', - "#### Use the `units` parameter to define the reference period for the change in values. ####", - 'obb.economy.cpi(countries=["united_states", "united_kingdom"], units="growth_previous").to_df()', + api_examples=[ + Example(parameters={"country": "japan,china,turkey"}), + Example( + description="Use the `units` parameter to define the reference period for the change in values.", + parameters={ + "country": "united_states,united_kingdom", + "units": "growth_previous", + }, + ), ], ) async def cpi( @@ -58,8 +70,7 @@ async def cpi( @router.command( model="RiskPremium", - exclude_auto_examples=True, - examples=["obb.economy.risk_premium().to_df()"], + api_examples=[Example(parameters={})], ) async def risk_premium( cc: CommandContext, @@ -73,11 +84,12 @@ async def risk_premium( @router.command( model="BalanceOfPayments", - exclude_auto_examples=True, - examples=[ - 'obb.economy.balance_of_payments(report_type="summary").to_df().set_index("period").T', - "#### The `country` parameter will override the `report_type`. ####", - 'obb.economy.balance_of_payments(country="united_states", provider="ecb").to_df().set_index("period").T', + api_examples=[ + Example(parameters={"report_type": "summary"}), + Example( + description="The `country` parameter will override the `report_type`.", + parameters={"country": "united_states", "provider": "ecb"}, + ), ], ) async def balance_of_payments( @@ -90,7 +102,7 @@ async def balance_of_payments( return await OBBject.from_query(Query(**locals())) -@router.command(model="FredSearch") +@router.command(model="FredSearch", api_examples=[Example(parameters={})]) async def fred_search( cc: CommandContext, provider_choices: ProviderChoices, @@ -107,13 +119,16 @@ async def fred_search( @router.command( model="FredSeries", - exclude_auto_examples=True, - examples=[ - 'obb.economy.fred_series("NFCI").to_df()', - "#### Multiple series can be passed in as a list. ####", - 'obb.economy.fred_series(["NFCI","STLFSI4"]).to_df()', - "#### Use the `transform` parameter to transform the data as change, log, or percent change. ####", - 'obb.economy.fred_series("CBBTCUSD", transform="pc1").to_df()', + api_examples=[ + Example(parameters={"series_id": "NFCI"}), + Example( + description="Multiple series can be passed in as a list.", + parameters={"series_id": "NFCI,STLFSI4"}, + ), + Example( + description="Use the `transform` parameter to transform the data as change, log, or percent change.", + parameters={"series_id": "CBBTCUSD", "transform": "pc1"}, + ), ], ) async def fred_series( @@ -128,10 +143,7 @@ async def fred_series( @router.command( model="MoneyMeasures", - exclude_auto_examples=True, - examples=[ - "obb.economy.money_measures(adjusted=False).to_df()", - ], + api_examples=[Example(parameters={"adjusted": False})], ) async def money_measures( cc: CommandContext, @@ -145,13 +157,12 @@ async def money_measures( @router.command( model="Unemployment", - exclude_auto_examples=True, - examples=[ - 'obb.economy.unemployment(country="all", frequency="quarterly")', - "#### Demographics for the statistics are selected with the `age` and `sex` parameters. ####", - "obb.economy.unemployment(", - 'country="all", frequency="quarterly", age="25-54"', - ').to_df().pivot(columns="country", values="value")', + api_examples=[ + Example(parameters={"country": "all", "frequency": "quarterly"}), + Example( + description="Demographics for the statistics are selected with the `age` and `sex` parameters.", + parameters={"country": "all", "frequency": "quarterly", "age": "25-54"}, + ), ], ) async def unemployment( @@ -166,10 +177,7 @@ async def unemployment( @router.command( model="CLI", - exclude_auto_examples=True, - examples=[ - 'obb.economy.composite_leading_indicator(country="all").to_df()', - ], + api_examples=[Example(parameters={"country": "all"})], ) async def composite_leading_indicator( cc: CommandContext, @@ -186,10 +194,7 @@ async def composite_leading_indicator( @router.command( model="STIR", - exclude_auto_examples=True, - examples=[ - 'obb.economy.short_term_interest_rate(country="all", frequency="quarterly").to_df()', - ], + api_examples=[Example(parameters={"country": "all", "frequency": "quarterly"})], ) async def short_term_interest_rate( cc: CommandContext, @@ -209,10 +214,7 @@ async def short_term_interest_rate( @router.command( model="LTIR", - exclude_auto_examples=True, - examples=[ - 'obb.economy.long_term_interest_rate(country="all", frequency="quarterly").to_df()', - ], + api_examples=[Example(parameters={"country": "all", "frequency": "quarterly"})], ) async def long_term_interest_rate( cc: CommandContext, @@ -235,12 +237,15 @@ async def long_term_interest_rate( @router.command( model="FredRegional", - exclude_auto_examples=True, - examples=[ - "#### With no date, the most recent report is returned. ####", - 'obb.economy.fred_regional("NYICLAIMS")', - "#### With a date, time series data is returned. ####", - 'obb.economy.fred_regional("NYICLAIMS", start_date="2021-01-01")', + api_examples=[ + Example( + description="With no date, the most recent report is returned.", + parameters={"series_id": "NYICLAIMS"}, + ), + Example( + description="With a date, time series data is returned.", + parameters={"series_id": "NYICLAIMS", "start_date": "2021-01-01"}, + ), ], ) async def fred_regional( diff --git a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py index 4f3b5340ef3d..039e0df56946 100644 --- a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py @@ -1,6 +1,7 @@ """Economy GDP Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -15,7 +16,10 @@ # pylint: disable=unused-argument -@router.command(model="GdpForecast") +@router.command( + model="GdpForecast", + api_examples=[Example(parameters={"period": "annual", "type": "real"})], +) async def forecast( cc: CommandContext, provider_choices: ProviderChoices, @@ -26,7 +30,10 @@ async def forecast( return await OBBject.from_query(Query(**locals())) -@router.command(model="GdpNominal") +@router.command( + model="GdpNominal", + api_examples=[Example(parameters={"units": "usd"})], +) async def nominal( cc: CommandContext, provider_choices: ProviderChoices, @@ -37,7 +44,10 @@ async def nominal( return await OBBject.from_query(Query(**locals())) -@router.command(model="GdpReal") +@router.command( + model="GdpReal", + api_examples=[Example(parameters={"units": "yoy"})], +) async def real( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py index 6693aecb2024..9625858cac89 100644 --- a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py @@ -1,6 +1,7 @@ """Calendar Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,11 +18,13 @@ @router.command( model="CalendarIpo", - examples=[ - "# Get all IPOs available.", - "obb.equity.calendar.ipo()", - "# Get IPOs for specific dates.", - "obb.equity.calendar.ipo(start_date='2024-02-01', end_date='2024-02-07')", + api_examples=[ + Example(parameters={"limit": 100}), + Example(description="Get all IPOs available.", parameters={}), + Example( + description="Get IPOs for specific dates.", + parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, + ), ], ) async def ipo( @@ -36,9 +39,15 @@ async def ipo( @router.command( model="CalendarDividend", - examples=[ - "# Get dividend calendar for specific dates.", - "obb.equity.calendar.dividend(start_date='2024-02-01', end_date='2024-02-07')", + api_examples=[ + Example(parameters={}), + Example( + description="Get dividend calendar for specific dates.", + parameters={ + "start_date": "2024-02-01", + "end_date": "2024-02-07", + }, + ), ], ) async def dividend( @@ -53,9 +62,15 @@ async def dividend( @router.command( model="CalendarSplits", - examples=[ - "# Get stock splits calendar for specific dates.", - "obb.equity.calendar.splits(start_date='2024-02-01', end_date='2024-02-07')", + api_examples=[ + Example(parameters={}), + Example( + description="Get stock splits calendar for specific dates.", + parameters={ + "start_date": "2024-02-01", + "end_date": "2024-02-07", + }, + ), ], ) async def splits( @@ -70,9 +85,12 @@ async def splits( @router.command( model="CalendarEarnings", - examples=[ - "# Get earnings calendar for specific dates.", - "obb.equity.calendar.earnings(start_date='2024-02-01', end_date='2024-02-07')", + api_examples=[ + Example(parameters={}), + Example( + description="Get earnings calendar for specific dates.", + parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, + ), ], ) async def earnings( diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py index da08a4cf110e..a4d181a17d0f 100644 --- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py @@ -2,6 +2,7 @@ """Comparison Analysis Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -14,7 +15,10 @@ router = Router(prefix="/compare") -@router.command(model="EquityPeers") +@router.command( + model="EquityPeers", + api_examples=[Example(parameters={"symbol": "AAPL"})], +) async def peers( cc: CommandContext, provider_choices: ProviderChoices, @@ -30,13 +34,19 @@ async def peers( @router.command( model="CompareGroups", - examples=[ - "# Group by sector and analyze valuation", - "obb.equity.compare.groups(group='sector', metric='valuation')", - "# Group by industry and analyze performance", - "obb.equity.compare.groups(group='industry', metric='performance')", - "# Group by country and analyze valuation", - "obb.equity.compare.groups(group='country', metric='valuation')", + api_examples=[ + Example( + description="Group by sector and analyze valuation.", + parameters={"group": "sector", "metric": "valuation"}, + ), + Example( + description="Group by industry and analyze performance.", + parameters={"group": "industry", "metric": "performance"}, + ), + Example( + description="Group by country and analyze valuation.", + parameters={"group": "country", "metric": "valuation"}, + ), ], ) async def groups( diff --git a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py index 1cda9b50ec58..6e6658ea19ee 100644 --- a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py @@ -1,6 +1,7 @@ """Dark Pool Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,9 +18,11 @@ @router.command( model="OTCAggregate", - examples=[ - "# Get OTC data for a symbol", - "obb.equity.darkpool.otc(symbol='AAPL')", + api_examples=[ + Example( + description="Get OTC data for a symbol", + parameters={"symbol": "AAPL"}, + ), ], ) async def otc( diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index 58247da48c86..3f180612adb3 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -2,6 +2,7 @@ # pylint: disable=unused-argument from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -14,7 +15,9 @@ router = Router(prefix="/discovery") -@router.command(model="EquityGainers") +@router.command( + model="EquityGainers", api_examples=[Example(parameters={"sort": "desc"})] +) async def gainers( cc: CommandContext, provider_choices: ProviderChoices, @@ -25,7 +28,9 @@ async def gainers( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityLosers") +@router.command( + model="EquityLosers", api_examples=[Example(parameters={"sort": "desc"})] +) async def losers( cc: CommandContext, provider_choices: ProviderChoices, @@ -36,7 +41,9 @@ async def losers( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityActive") +@router.command( + model="EquityActive", api_examples=[Example(parameters={"sort": "desc"})] +) async def active( cc: CommandContext, provider_choices: ProviderChoices, @@ -47,7 +54,10 @@ async def active( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityUndervaluedLargeCaps") +@router.command( + model="EquityUndervaluedLargeCaps", + api_examples=[Example(parameters={"sort": "desc"})], +) async def undervalued_large_caps( cc: CommandContext, provider_choices: ProviderChoices, @@ -58,7 +68,9 @@ async def undervalued_large_caps( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityUndervaluedGrowth") +@router.command( + model="EquityUndervaluedGrowth", api_examples=[Example(parameters={"sort": "desc"})] +) async def undervalued_growth( cc: CommandContext, provider_choices: ProviderChoices, @@ -69,7 +81,10 @@ async def undervalued_growth( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityAggressiveSmallCaps") +@router.command( + model="EquityAggressiveSmallCaps", + api_examples=[Example(parameters={"sort": "desc"})], +) async def aggressive_small_caps( cc: CommandContext, provider_choices: ProviderChoices, @@ -80,7 +95,9 @@ async def aggressive_small_caps( return await OBBject.from_query(Query(**locals())) -@router.command(model="GrowthTechEquities") +@router.command( + model="GrowthTechEquities", api_examples=[Example(parameters={"sort": "desc"})] +) async def growth_tech( cc: CommandContext, provider_choices: ProviderChoices, @@ -91,7 +108,7 @@ async def growth_tech( return await OBBject.from_query(Query(**locals())) -@router.command(model="TopRetail") +@router.command(model="TopRetail", api_examples=[Example(parameters={"sort": "desc"})]) async def top_retail( cc: CommandContext, provider_choices: ProviderChoices, @@ -105,7 +122,9 @@ async def top_retail( return await OBBject.from_query(Query(**locals())) -@router.command(model="UpcomingReleaseDays") +@router.command( + model="UpcomingReleaseDays", api_examples=[Example(parameters={"sort": "desc"})] +) async def upcoming_release_days( cc: CommandContext, provider_choices: ProviderChoices, @@ -118,9 +137,16 @@ async def upcoming_release_days( @router.command( model="DiscoveryFilings", - examples=[ - "# Get filings for the year 2023, limited to 100 results", - "obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31')", + api_examples=[ + Example(parameters={"limit": 100}), + Example( + description="Get filings for the year 2023, limited to 100 results", + parameters={ + "start_date": "2023-01-01", + "end_date": "2023-12-31", + "limit": 100, + }, + ), ], ) async def filings( diff --git a/openbb_platform/extensions/equity/openbb_equity/equity_router.py b/openbb_platform/extensions/equity/openbb_equity/equity_router.py index d47e2e5dcd46..8c2283f231da 100644 --- a/openbb_platform/extensions/equity/openbb_equity/equity_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/equity_router.py @@ -1,6 +1,7 @@ """Equity Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -34,7 +35,12 @@ # pylint: disable=import-outside-toplevel, W0613:unused-argument -@router.command(model="EquitySearch") +@router.command( + model="EquitySearch", + api_examples=[ + Example(parameters={"query": "AAPL", "is_symbol": False, "use_cache": True}) + ], +) async def search( cc: CommandContext, provider_choices: ProviderChoices, @@ -45,7 +51,7 @@ async def search( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityScreener") +@router.command(model="EquityScreener", api_examples=[Example(parameters={})]) async def screener( cc: CommandContext, provider_choices: ProviderChoices, @@ -57,7 +63,9 @@ async def screener( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityInfo") +@router.command( + model="EquityInfo", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def profile( cc: CommandContext, provider_choices: ProviderChoices, @@ -68,7 +76,7 @@ async def profile( return await OBBject.from_query(Query(**locals())) -@router.command(model="MarketSnapshots") +@router.command(model="MarketSnapshots", api_examples=[Example(parameters={})]) async def market_snapshots( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index 4d6f8902fe67..524328971da1 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -1,6 +1,7 @@ """Estimates Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,9 +18,17 @@ @router.command( model="PriceTarget", - exclude_auto_examples=True, - examples=[ - 'obb.equity.estimates.price_target(start_date="2020-01-01", end_date="2024-02-16",limit=10, symbol="msft", provider="benzinga",action="downgrades").to_df()' # noqa: E501 pylint: disable=line-too-long + api_examples=[ + Example( + parameters={ + "start_date": "2020-01-01", + "end_date": "2024-02-16", + "limit": 10, + "symbol": "msft", + "provider": "benzinga", + "action": "downgrades", + } + ), ], ) async def price_target( @@ -34,10 +43,7 @@ async def price_target( @router.command( model="AnalystEstimates", - exclude_auto_examples=True, - examples=[ - 'obb.equity.estimates.historical("AAPL", period="quarter", provider="fmp").to_df()', - ], + api_examples=[Example(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def historical( cc: CommandContext, @@ -51,10 +57,7 @@ async def historical( @router.command( model="PriceTargetConsensus", - exclude_auto_examples=True, - examples=[ - 'obb.equity.estimates.consensus("AAPL,MSFT", provider="yfinance").to_df()' - ], + api_examples=[Example(parameters={"symbol": "AAPL,MSFT", "provider": "yfinance"})], ) async def consensus( cc: CommandContext, @@ -68,10 +71,7 @@ async def consensus( @router.command( model="AnalystSearch", - exclude_auto_examples=True, - examples=[ - 'obb.equity.estimates.analyst_search(firm_name="Wedbush", provider="benzinga").to_df()', - ], + api_examples=[Example(parameters={"firm_name": "Wedbush", "provider": "benzinga"})], ) async def analyst_search( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index eb36250b484c..a3f573c4fb73 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -3,6 +3,7 @@ from openbb_core.app.deprecation import OpenBBDeprecationWarning from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -15,7 +16,10 @@ router = Router(prefix="/fundamental") -@router.command(model="EquityValuationMultiples") +@router.command( + model="EquityValuationMultiples", + api_examples=[Example(parameters={"symbol": "AAPL"})], +) async def multiples( cc: CommandContext, provider_choices: ProviderChoices, @@ -26,7 +30,12 @@ async def multiples( return await OBBject.from_query(Query(**locals())) -@router.command(model="BalanceSheet") +@router.command( + model="BalanceSheet", + api_examples=[ + Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}) + ], +) async def balance( cc: CommandContext, provider_choices: ProviderChoices, @@ -37,7 +46,10 @@ async def balance( return await OBBject.from_query(Query(**locals())) -@router.command(model="BalanceSheetGrowth") +@router.command( + model="BalanceSheetGrowth", + api_examples=[Example(parameters={"symbol": "AAPL", "limit": 10})], +) async def balance_growth( cc: CommandContext, provider_choices: ProviderChoices, @@ -48,7 +60,12 @@ async def balance_growth( return await OBBject.from_query(Query(**locals())) -@router.command(model="CashFlowStatement") +@router.command( + model="CashFlowStatement", + api_examples=[ + Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}) + ], +) async def cash( cc: CommandContext, provider_choices: ProviderChoices, @@ -61,11 +78,23 @@ async def cash( @router.command( model="ReportedFinancials", - examples=[ - "# Get reported income statement", - "obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='income)", - "# Get reported cash flow statement", - "obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='cash')", + api_examples=[ + Example( + parameters={ + "symbol": "AAPL", + "period": "annual", + "statement_type": "balance", + "limit": 100, + } + ), + Example( + description="Get reported income statement", + parameters={"symbol": "AAPL", "statement_type": "income"}, + ), + Example( + description="Get reported cash flow statement", + parameters={"symbol": "AAPL", "statement_type": "cash"}, + ), ], ) async def reported_financials( @@ -78,7 +107,10 @@ async def reported_financials( return await OBBject.from_query(Query(**locals())) -@router.command(model="CashFlowStatementGrowth") +@router.command( + model="CashFlowStatementGrowth", + api_examples=[Example(parameters={"symbol": "AAPL", "limit": 10})], +) async def cash_growth( cc: CommandContext, provider_choices: ProviderChoices, @@ -89,7 +121,9 @@ async def cash_growth( return await OBBject.from_query(Query(**locals())) -@router.command(model="HistoricalDividends") +@router.command( + model="HistoricalDividends", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def dividends( cc: CommandContext, provider_choices: ProviderChoices, @@ -111,7 +145,9 @@ async def historical_eps( return await OBBject.from_query(Query(**locals())) -@router.command(model="HistoricalEmployees") +@router.command( + model="HistoricalEmployees", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def employee_count( cc: CommandContext, provider_choices: ProviderChoices, @@ -124,10 +160,7 @@ async def employee_count( @router.command( model="SearchAttributes", - exclude_auto_examples=True, - examples=[ - "obb.equity.fundamental.search_attributes(query='ebitda')", - ], + api_examples=[Example(parameters={"query": "ebitda"})], ) async def search_attributes( cc: CommandContext, @@ -141,10 +174,7 @@ async def search_attributes( @router.command( model="LatestAttributes", - exclude_auto_examples=True, - examples=[ - "obb.equity.fundamental.latest_attributes(tag='ceo')", - ], + api_examples=[Example(parameters={"tag": "ceo"})], ) async def latest_attributes( cc: CommandContext, @@ -158,10 +188,7 @@ async def latest_attributes( @router.command( model="HistoricalAttributes", - exclude_auto_examples=True, - examples=[ - "obb.equity.fundamental.historical_attributes(tag='ebitda')", - ], + api_examples=[Example(parameters={"tag": "ebitda"})], ) async def historical_attributes( cc: CommandContext, @@ -173,7 +200,12 @@ async def historical_attributes( return await OBBject.from_query(Query(**locals())) -@router.command(model="IncomeStatement") +@router.command( + model="IncomeStatement", + api_examples=[ + Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}) + ], +) async def income( cc: CommandContext, provider_choices: ProviderChoices, @@ -184,7 +216,12 @@ async def income( return await OBBject.from_query(Query(**locals())) -@router.command(model="IncomeStatementGrowth") +@router.command( + model="IncomeStatementGrowth", + api_examples=[ + Example(parameters={"symbol": "AAPL", "limit": 10, "period": "annual"}) + ], +) async def income_growth( cc: CommandContext, provider_choices: ProviderChoices, @@ -195,7 +232,12 @@ async def income_growth( return await OBBject.from_query(Query(**locals())) -@router.command(model="KeyMetrics") +@router.command( + model="KeyMetrics", + api_examples=[ + Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 100}) + ], +) async def metrics( cc: CommandContext, provider_choices: ProviderChoices, @@ -206,7 +248,9 @@ async def metrics( return await OBBject.from_query(Query(**locals())) -@router.command(model="KeyExecutives") +@router.command( + model="KeyExecutives", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def management( cc: CommandContext, provider_choices: ProviderChoices, @@ -217,7 +261,9 @@ async def management( return await OBBject.from_query(Query(**locals())) -@router.command(model="ExecutiveCompensation") +@router.command( + model="ExecutiveCompensation", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def management_compensation( cc: CommandContext, provider_choices: ProviderChoices, @@ -236,6 +282,7 @@ async def management_compensation( since=(4, 1), expected_removal=(4, 3), ), + api_examples=[Example(parameters={"symbol": "AAPL"})], ) async def overview( cc: CommandContext, @@ -247,7 +294,12 @@ async def overview( return await OBBject.from_query(Query(**locals())) -@router.command(model="FinancialRatios") +@router.command( + model="FinancialRatios", + api_examples=[ + Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 12}) + ], +) async def ratios( cc: CommandContext, provider_choices: ProviderChoices, @@ -258,7 +310,12 @@ async def ratios( return await OBBject.from_query(Query(**locals())) -@router.command(model="RevenueGeographic") +@router.command( + model="RevenueGeographic", + api_examples=[ + Example(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) + ], +) async def revenue_per_geography( cc: CommandContext, provider_choices: ProviderChoices, @@ -269,7 +326,12 @@ async def revenue_per_geography( return await OBBject.from_query(Query(**locals())) -@router.command(model="RevenueBusinessLine") +@router.command( + model="RevenueBusinessLine", + api_examples=[ + Example(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) + ], +) async def revenue_per_segment( cc: CommandContext, provider_choices: ProviderChoices, @@ -280,7 +342,9 @@ async def revenue_per_segment( return await OBBject.from_query(Query(**locals())) -@router.command(model="CompanyFilings") +@router.command( + model="CompanyFilings", api_examples=[Example(parameters={"limit": 100})] +) async def filings( cc: CommandContext, provider_choices: ProviderChoices, @@ -296,7 +360,9 @@ async def filings( return await OBBject.from_query(Query(**locals())) -@router.command(model="HistoricalSplits") +@router.command( + model="HistoricalSplits", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def historical_splits( cc: CommandContext, provider_choices: ProviderChoices, @@ -309,10 +375,7 @@ async def historical_splits( @router.command( model="EarningsCallTranscript", - exclude_auto_examples=True, - examples=[ - "obb.equity.fundamental.transcript(symbol='AAPL', year=2020)", - ], + api_examples=[Example(parameters={"symbol": "AAPL", "year": 2020})], ) async def transcript( cc: CommandContext, @@ -324,7 +387,10 @@ async def transcript( return await OBBject.from_query(Query(**locals())) -@router.command(model="TrailingDividendYield") +@router.command( + model="TrailingDividendYield", + api_examples=[Example(parameters={"symbol": "AAPL", "limit": 252})], +) async def trailing_dividend_yield( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index ccaf9115ff5b..3a2534e4a47c 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -1,6 +1,7 @@ """Ownership Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -15,7 +16,10 @@ # pylint: disable=unused-argument -@router.command(model="EquityOwnership") +@router.command( + model="EquityOwnership", + api_examples=[Example(parameters={"symbol": "AAPL", "page": 0})], +) async def major_holders( cc: CommandContext, provider_choices: ProviderChoices, @@ -26,7 +30,10 @@ async def major_holders( return await OBBject.from_query(Query(**locals())) -@router.command(model="InstitutionalOwnership") +@router.command( + model="InstitutionalOwnership", + api_examples=[Example(parameters={"symbol": "AAPL"})], +) async def institutional( cc: CommandContext, provider_choices: ProviderChoices, @@ -37,7 +44,10 @@ async def institutional( return await OBBject.from_query(Query(**locals())) -@router.command(model="InsiderTrading") +@router.command( + model="InsiderTrading", + api_examples=[Example(parameters={"symbol": "AAPL", "limit": 500})], +) async def insider_trading( cc: CommandContext, provider_choices: ProviderChoices, @@ -48,7 +58,9 @@ async def insider_trading( return await OBBject.from_query(Query(**locals())) -@router.command(model="ShareStatistics") +@router.command( + model="ShareStatistics", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def share_statistics( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index bae1fc26cec1..aa1031225799 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -1,6 +1,7 @@ """Price Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -15,7 +16,9 @@ # pylint: disable=unused-argument -@router.command(model="EquityQuote") +@router.command( + model="EquityQuote", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def quote( cc: CommandContext, provider_choices: ProviderChoices, @@ -26,7 +29,9 @@ async def quote( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityNBBO") +@router.command( + model="EquityNBBO", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def nbbo( cc: CommandContext, provider_choices: ProviderChoices, @@ -37,7 +42,10 @@ async def nbbo( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityHistorical") +@router.command( + model="EquityHistorical", + api_examples=[Example(parameters={"symbol": "AAPL", "interval": "1d"})], +) async def historical( cc: CommandContext, provider_choices: ProviderChoices, @@ -48,7 +56,9 @@ async def historical( return await OBBject.from_query(Query(**locals())) -@router.command(model="PricePerformance") +@router.command( + model="PricePerformance", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def performance( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index c5283a947eea..1ab8073aed43 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -1,6 +1,7 @@ """Shorts Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,8 +18,7 @@ @router.command( model="EquityFTD", - exclude_auto_examples=True, - examples=["obb.equity.shorts.fails_to_deliver(symbol='AAPL')"], + api_examples=[Example(parameters={"symbol": "AAPL"})], ) async def fails_to_deliver( cc: CommandContext, @@ -32,8 +32,7 @@ async def fails_to_deliver( @router.command( model="ShortVolume", - exclude_auto_examples=True, - examples=["obb.equity.shorts.short_volume(symbol='AAPL')"], + api_examples=[Example(parameters={"symbol": "AAPL"})], ) async def short_volume( cc: CommandContext, @@ -47,8 +46,7 @@ async def short_volume( @router.command( model="EquityShortInterest", - exclude_auto_examples=True, - examples=["obb.equity.shorts.short_interest(symbol='AAPL')"], + api_examples=[Example(parameters={"symbol": "AAPL"})], ) async def short_interest( cc: CommandContext, diff --git a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py index 21e60286f491..d334f97ff996 100644 --- a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py @@ -1,6 +1,7 @@ """Disc router for ETFs.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -18,9 +19,8 @@ @router.command( model="ETFGainers", operation_id="etf_gainers", - examples=[ - "### Get the top ETF gainers. ###", - 'obb.etf.discovery.gainers(provider="wsj")', + api_examples=[ + Example(description="Get the top ETF gainers.", parameters={"provider": "wsj"}), ], ) async def gainers( @@ -36,9 +36,8 @@ async def gainers( @router.command( model="ETFLosers", operation_id="etf_losers", - examples=[ - "### Get the top ETF losers. ###", - 'obb.etf.discovery.losers(provider="wsj")', + api_examples=[ + Example(description="Get the top ETF losers.", parameters={"provider": "wsj"}) ], ) async def losers( @@ -54,9 +53,8 @@ async def losers( @router.command( model="ETFActive", operation_id="etf_active", - examples=[ - "### Get the most active ETFs. ###", - 'obb.etf.discovery.active(provider="wsj")', + api_examples=[ + Example(description="Get the most active ETFs.", parameters={"provider": "wsj"}) ], ) async def active( diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index 8a528a885cf3..2f3ff6cd8539 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -1,6 +1,7 @@ """ETF Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -20,12 +21,15 @@ @router.command( model="EtfSearch", - exclude_auto_examples=True, - examples=[ - "### An empty query returns the full list of ETFs from the provider. ###", - 'obb.etf.search("", provider="fmp")', - "#### The query will return results from text-based fields containing the term. ####" - 'obb.etf.search("commercial real estate", provider="fmp")', + api_examples=[ + Example( + description="An empty query returns the full list of ETFs from the provider.", + parameters={"provider": "fmp"}, + ), + Example( + description="The query will return results from text-based fields containing the term.", + parameters={"query": "commercial real estate", "provider": "fmp"}, + ), ], ) async def search( @@ -44,10 +48,13 @@ async def search( @router.command( model="EtfHistorical", operation_id="etf_historical", - examples=[ - 'obb.etf.historical("SPY", provider="yfinance")', - "#### This function accepts multiple tickers. ####", - 'obb.etf.historical("SPY,IWM,QQQ,DJIA", provider="yfinance")', + api_examples=[ + Example(parameters={"symbol": "SPY"}), + Example(parameters={"symbol": "SPY", "provider": "yfinance"}), + Example( + description="This function accepts multiple tickers.", + parameters={"symbol": "SPY,IWM,QQQ,DJIA", "provider": "yfinance"}, + ), ], ) async def historical( @@ -62,11 +69,12 @@ async def historical( @router.command( model="EtfInfo", - exclude_auto_examples=True, - examples=[ - 'obb.etf.info("SPY", provider="fmp")', - "#### This function accepts multiple tickers. ####", - 'obb.etf.info("SPY,IWM,QQQ,DJIA", provider="fmp")', + api_examples=[ + Example(parameters={"symbol": "SPY", "provider": "fmp"}), + Example( + description="This function accepts multiple tickers.", + parameters={"symbol": "SPY,IWM,QQQ,DJIA", "provider": "fmp"}, + ), ], ) async def info( @@ -81,10 +89,7 @@ async def info( @router.command( model="EtfSectors", - exclude_auto_examples=True, - examples=[ - 'obb.etf.sectors("SPY", provider="fmp")', - ], + api_examples=[Example(parameters={"symbol": "SPY", "provider": "fmp"})], ) async def sectors( cc: CommandContext, @@ -98,10 +103,7 @@ async def sectors( @router.command( model="EtfCountries", - exclude_auto_examples=True, - examples=[ - 'obb.etf.countries("VT", provider="fmp")', - ], + api_examples=[Example(parameters={"symbol": "VT", "provider": "fmp"})], ) async def countries( cc: CommandContext, @@ -115,9 +117,8 @@ async def countries( @router.command( model="PricePerformance", - exclude_auto_examples=True, - examples=[ - 'obb.etf.price_performance("SPY,QQQ,IWM,DJIA", provider="fmp")', + api_examples=[ + Example(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"}) ], ) async def price_performance( @@ -132,13 +133,16 @@ async def price_performance( @router.command( model="EtfHoldings", - exclude_auto_examples=True, - examples=[ - 'obb.etf.holdings("XLK", provider="fmp").to_df()', - "#### Including a date (FMP, SEC) will return the holdings as per NPORT-P filings. ####", - 'obb.etf.holdings("XLK", date="2022-03-31",provider="fmp").to_df()', - "#### The same data can be returned from the SEC directly. ####", - 'obb.etf.holdings("XLK", date="2022-03-31",provider="sec").to_df()', + api_examples=[ + Example(parameters={"symbol": "XLK", "provider": "fmp"}), + Example( + description="Including a date (FMP, SEC) will return the holdings as per NPORT-P filings.", + parameters={"symbol": "XLK", "date": "2022-03-31", "provider": "fmp"}, + ), + Example( + description="The same data can be returned from the SEC directly.", + parameters={"symbol": "XLK", "date": "2022-03-31", "provider": "sec"}, + ), ], ) async def holdings( @@ -153,10 +157,7 @@ async def holdings( @router.command( model="EtfHoldingsDate", - exclude_auto_examples=True, - examples=[ - 'obb.etf.holdings_date("XLK", provider="fmp").results', - ], + api_examples=[Example(parameters={"symbol": "XLK", "provider": "fmp"})], ) async def holdings_date( cc: CommandContext, @@ -170,10 +171,7 @@ async def holdings_date( @router.command( model="EtfHoldingsPerformance", - exclude_auto_examples=True, - examples=[ - 'obb.etf.holdings_performance("XLK", provider="fmp")', - ], + api_examples=[Example(parameters={"symbol": "XLK", "provider": "fmp"})], ) async def holdings_performance( cc: CommandContext, @@ -187,11 +185,12 @@ async def holdings_performance( @router.command( model="EtfEquityExposure", - exclude_auto_examples=True, - examples=[ - 'obb.etf.equity_exposure("MSFT", provider="fmp")', - "#### This function accepts multiple tickers. ####", - 'obb.etf.equity_exposure("MSFT,AAPL", provider="fmp")', + api_examples=[ + Example(parameters={"symbol": "MSFT", "provider": "fmp"}), + Example( + description="This function accepts multiple tickers.", + parameters={"symbol": "MSFT,AAPL", "provider": "fmp"}, + ), ], ) async def equity_exposure( diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index a655e66f64e7..62f1b04b6bdd 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -1,6 +1,7 @@ """Fixed Income Corporate Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,10 +18,7 @@ @router.command( model="ICEBofA", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.corporate.ice_bofa(index_type="yield_to_worst")', - ], + api_examples=[Example(parameters={"index_type": "yield_to_worst"})], ) async def ice_bofa( cc: CommandContext, @@ -41,10 +39,7 @@ async def ice_bofa( @router.command( model="MoodyCorporateBondIndex", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.corporate.moody(index_type="baa")', - ], + api_examples=[Example(parameters={"index_type": "baa"})], ) async def moody( cc: CommandContext, @@ -64,8 +59,7 @@ async def moody( @router.command( model="HighQualityMarketCorporateBond", - exclude_auto_examples=True, - examples=['obb.fixedincome.corporate.hqm(yield_curve="par")'], + api_examples=[Example(parameters={"yield_curve": "par"})], ) async def hqm( cc: CommandContext, @@ -85,10 +79,7 @@ async def hqm( @router.command( model="SpotRate", - exclude_auto_examples=True, - examples=[ - "obb.fixedincome.corporate.spot_rates(maturity=[10,20,30,50])", - ], + api_examples=[Example(parameters={"maturity": [10, 20, 30, 50]})], ) async def spot_rates( cc: CommandContext, @@ -108,10 +99,7 @@ async def spot_rates( @router.command( model="CommercialPaper", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.corporate.commercial_paper(maturity="15d")', - ], + api_examples=[Example(parameters={"maturity": "15d"})], ) async def commercial_paper( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py index 01182a13666e..ea4efb3518fa 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py @@ -3,6 +3,7 @@ # pylint: disable=W0613:unused-argument from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -26,10 +27,7 @@ @router.command( model="SOFR", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.fixedincome.sofr(period="overnight")', - ], + api_examples=[Example(parameters={"period": "overnight"})], ) async def sofr( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index a817f7933f03..5de66f7a6eb5 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -1,6 +1,7 @@ """Fixed Income Government Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,10 +18,7 @@ @router.command( model="USYieldCurve", - exclude_auto_examples=True, - examples=[ - "obb.fixedincome.government.us_yield_curve(inflation_adjusted=True)", - ], + api_examples=[Example(parameters={"inflation_adjusted": True})], ) async def us_yield_curve( cc: CommandContext, @@ -34,10 +32,7 @@ async def us_yield_curve( @router.command( model="EUYieldCurve", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.government.eu_yield_curve(yield_curve_type="spot_rate")', - ], + api_examples=[Example(parameters={"yield_curve_type": "spot_rate"})], ) async def eu_yield_curve( cc: CommandContext, @@ -70,10 +65,7 @@ async def eu_yield_curve( @router.command( model="TreasuryRates", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.government.treasury_rates(provider="federal_reserve")', - ], + api_examples=[Example(parameters={"provider": "federal_reserve"})], ) async def treasury_rates( cc: CommandContext, @@ -87,10 +79,14 @@ async def treasury_rates( @router.command( model="TreasuryAuctions", - exclude_auto_examples=True, - examples=[ - "obb.fixedincome.government.treasury_auctions(" - + 'security_type="Bill", start_date="2022-01-01", end_date="2023-01-01', + api_examples=[ + Example( + parameters={ + "security_type": "Bill", + "start_date": "2022-01-01", + "end_date": "2023-01-01", + } + ) ], ) async def treasury_auctions( @@ -105,10 +101,7 @@ async def treasury_auctions( @router.command( model="TreasuryPrices", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.government.treasury_prices(date="2019-02-05")', - ], + api_examples=[Example(parameters={"date": "2019-02-05"})], ) async def treasury_prices( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index d192b7d4c08d..111108ea8f70 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -1,6 +1,7 @@ """Fixed Income Rate Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,10 +18,7 @@ @router.command( model="AMERIBOR", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.rate.ameribor(parameter="30_day_ma").to_df()', - ], + api_examples=[Example(parameters={"parameter": "30_day_ma"})], ) async def ameribor( cc: CommandContext, @@ -39,10 +37,7 @@ async def ameribor( @router.command( model="SONIA", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.rate.sonia(parameter="total_nominal_value")', - ], + api_examples=[Example(parameters={"parameter": "total_nominal_value"})], ) async def sonia( cc: CommandContext, @@ -61,10 +56,7 @@ async def sonia( @router.command( model="IORB", - exclude_auto_examples=True, - examples=[ - "obb.fixedincome.rate.iorb()", - ], + api_examples=[Example(parameters={})], ) async def iorb( cc: CommandContext, @@ -83,10 +75,7 @@ async def iorb( @router.command( model="FEDFUNDS", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.rate.effr(parameter="daily", provider="fred").to_df()', - ], + api_examples=[Example(parameters={"parameter": "daily", "provider": "fred"})], ) async def effr( cc: CommandContext, @@ -105,10 +94,7 @@ async def effr( @router.command( model="PROJECTIONS", - exclude_auto_examples=True, - examples=[ - "obb.fixedincome.rate.effr_forecast(long_run=True)", - ], + api_examples=[Example(parameters={"long_run": True})], ) async def effr_forecast( cc: CommandContext, @@ -128,10 +114,7 @@ async def effr_forecast( @router.command( model="ESTR", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.rate.estr(parameter="number_of_active_banks")', - ], + api_examples=[Example(parameters={"parameter": "number_of_active_banks"})], ) async def estr( cc: CommandContext, @@ -151,10 +134,7 @@ async def estr( @router.command( model="EuropeanCentralBankInterestRates", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.rate.ecb(interest_rate_type="refinancing")', - ], + api_examples=[Example(parameters={"interest_rate_type": "refinancing"})], ) async def ecb( cc: CommandContext, @@ -176,9 +156,8 @@ async def ecb( @router.command( model="DiscountWindowPrimaryCreditRate", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.rate.dpcredit(start_date="2023-02-01", end_date="2023-05-01").to_df()', + api_examples=[ + Example(parameters={"start_date": "2023-02-01", "end_date": "2023-05-01"}) ], ) async def dpcredit( diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py index b45705465926..2b331eae5eb3 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py @@ -1,6 +1,7 @@ """Fixed Income Corporate Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,10 +18,7 @@ @router.command( model="TreasuryConstantMaturity", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.fixedincome.spreads.tcm(maturity="2y")', - ], + api_examples=[Example(parameters={"maturity": "2y"})], ) async def tcm( cc: CommandContext, @@ -40,10 +38,7 @@ async def tcm( @router.command( model="SelectedTreasuryConstantMaturity", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.fixedincome.spreads.tcm_effr(maturity="10y")', - ], + api_examples=[Example(parameters={"maturity": "10y"})], ) async def tcm_effr( cc: CommandContext, @@ -63,10 +58,7 @@ async def tcm_effr( @router.command( model="SelectedTreasuryBill", - exclude_auto_examples=True, - examples=[ - 'obb.fixedincome.fixedincome.spreads.treasury_effr(maturity="6m")', - ], + api_examples=[Example(parameters={"maturity": "6m"})], ) async def treasury_effr( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index cd85c4de9694..5e8bb8ef1250 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -2,6 +2,7 @@ from openbb_core.app.deprecation import OpenBBDeprecationWarning from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -27,6 +28,7 @@ since=(4, 1), expected_removal=(4, 3), ), + api_examples=[Example(parameters={"symbol": "SPX"})], ) async def market( cc: CommandContext, @@ -40,11 +42,12 @@ async def market( @router.command( model="IndexConstituents", - exclude_auto_examples=True, - examples=[ - 'obb.index.constituents("dowjones", provider="fmp").to_df()', - "#### Providers other than FMP will use the ticker symbol. ####", - 'obb.index.constituents("BEP50P", provider="cboe").to_df()', + api_examples=[ + Example(parameters={"symbol": "dowjones", "provider": "fmp"}), + Example( + description="Providers other than FMP will use the ticker symbol.", + parameters={"symbol": "BEP50P", "provider": "cboe"}, + ), ], ) async def constituents( @@ -59,10 +62,7 @@ async def constituents( @router.command( model="IndexSnapshots", - exclude_auto_examples=True, - examples=[ - 'obb.index.snapshots(region="us",provider="cboe").to_df()', - ], + api_examples=[Example(parameters={"region": "us", "provider": "cboe"})], ) async def snapshots( cc: CommandContext, @@ -76,10 +76,7 @@ async def snapshots( @router.command( model="AvailableIndices", - exclude_auto_examples=True, - examples=[ - 'obb.index.available(provider="yfinance").to_df()', - ], + api_examples=[Example(parameters={"provider": "yfinance"})], ) async def available( cc: CommandContext, @@ -93,10 +90,7 @@ async def available( @router.command( model="IndexSearch", - exclude_auto_examples=True, - examples=[ - "obb.index.search(query='SPX', provider='cboe').to_df()", - ], + api_examples=[Example(parameters={"query": "SPX", "provider": "cboe"})], ) async def search( cc: CommandContext, @@ -110,9 +104,8 @@ async def search( @router.command( model="SP500Multiples", - exclude_auto_examples=True, - examples=[ - 'obb.index.sp500_multiples(series_name="shiller_pe_year", provider="nasdaq").to_df()', + api_examples=[ + Example(parameters={"series_name": "shiller_pe_year", "provider": "nasdaq"}) ], ) async def sp500_multiples( @@ -127,10 +120,7 @@ async def sp500_multiples( @router.command( model="IndexSectors", - exclude_auto_examples=True, - examples=[ - 'obb.index.sectors(symbol="^TX60", provider="tmx").to_df()', - ], + api_examples=[Example(parameters={"symbol": "^TX60", "provider": "tmx"})], ) async def sectors( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index c5f44332eff7..4843502e4c5b 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -1,6 +1,7 @@ """Price Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -17,11 +18,12 @@ @router.command( model="IndexHistorical", - exclude_auto_examples=True, - examples=[ - 'obb.index.price.historical("^GSPC", provider="fmp").to_df()', - "#### Not all providers have the same symbols. ####", - 'obb.index.price.historical("SPX", provider="intrinio").to_df()', + api_examples=[ + Example(parameters={"symbol": "^GSPC", "provider": "fmp"}), + Example( + description="Not all providers have the same symbols.", + parameters={"symbol": "SPX", "provider": "intrinio"}, + ), ], ) async def historical( diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index 00546ac6602a..2f43b365f8ba 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -2,6 +2,7 @@ """News Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -16,17 +17,28 @@ @router.command( model="WorldNews", - examples=[ - "# Get news on the specified dates.", - "obb.news.world(start_date='2024-02-01', end_date='2024-02-07')", - "# Display the headlines of the news.", - "obb.news.world(display='headline', provider='benzinga')", - "# Get news by topics.", - "obb.news.world(topics='finance', provider='benzinga')", - "# Get news by source using 'tingo' as provider.", - "obb.news.world(provider='tiingo', source='bloomberg')", - "# Filter aticles by term using 'biztoc' as provider.", - "obb.news.world(provider='biztoc', term='apple')", + api_examples=[ + Example(parameters={"limit": 2500}), + Example( + description="Get news on the specified dates.", + parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, + ), + Example( + description="Display the headlines of the news.", + parameters={"display": "headline", "provider": "benzinga"}, + ), + Example( + description="Get news by topics.", + parameters={"topics": "finance", "provider": "benzinga"}, + ), + Example( + description="Get news by source using 'tingo' as provider.", + parameters={"provider": "tiingo", "source": "bloomberg"}, + ), + Example( + description="Filter aticles by term using 'biztoc' as provider.", + parameters={"provider": "biztoc", "term": "apple"}, + ), ], ) async def world( @@ -41,15 +53,32 @@ async def world( @router.command( model="CompanyNews", - examples=[ - "# Get news on the specified dates.", - "obb.news.company(symbol='AAPL', start_date='2024-02-01', end_date='2024-02-07')", - "# Display the headlines of the news.", - "obb.news.company(symbol='AAPL', display='headline', provider='benzinga')", - "# Get news for multiple symbols.", - "obb.news.company(symbol='aapl,tsla')", - "# Get news company's ISIN.", - "obb.news.company(symbol='NVDA', isin='US0378331005')", + api_examples=[ + Example(parameters={"limit": 2500}), + Example( + description="Get news on the specified dates.", + parameters={ + "symbol": "AAPL", + "start_date": "2024-02-01", + "end_date": "2024-02-07", + }, + ), + Example( + description="Display the headlines of the news.", + parameters={ + "symbol": "AAPL", + "display": "headline", + "provider": "benzinga", + }, + ), + Example( + description="Get news for multiple symbols.", + parameters={"symbol": "aapl,tsla"}, + ), + Example( + description="Get news company's ISIN.", + parameters={"symbol": "NVDA", "isin": "US0378331005"}, + ), ], ) async def company( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 92bd611a3802..87a356deb0a1 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -21,7 +21,7 @@ @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.omega_ratio(data=returns, target="close")', @@ -80,7 +80,7 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.sharpe_ratio(data=returns, target="close")', @@ -134,7 +134,7 @@ def sharpe_ratio( @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.sortino_ratio(data=stock_data, target="close")', diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index bede1e9ac84e..83c3f5a5bb6f 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -37,7 +37,7 @@ @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.quantitative.normality(data=stock_data, target='close')", ], @@ -87,7 +87,7 @@ def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.quantitative.capm(data=stock_data, target='close')", ], diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index c2cc5c7a1aed..35103c2038c6 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -26,7 +26,7 @@ @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.skew(data=returns, target="close")', @@ -75,7 +75,7 @@ def skew( @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.variance(data=returns, target="close", window=252)', @@ -117,7 +117,7 @@ def variance( @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.stdev(data=returns, target="close", window=252)', @@ -163,7 +163,7 @@ def stdev( @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.kurtosis(data=returns, target="close", window=252)', @@ -211,7 +211,7 @@ def kurtosis( @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.25)', @@ -276,7 +276,7 @@ def quantile( @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.mean(data=returns, target="close", window=252)', diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index deff80471b1d..5f13f502c62a 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -25,7 +25,7 @@ @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.skew(data=returns, target="close")', @@ -66,7 +66,7 @@ def skew( @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.variance(data=returns, target="close")', @@ -101,7 +101,7 @@ def variance(data: List[Data], target: str) -> OBBject[List[Data]]: @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.stdev(data=returns, target="close")', @@ -138,7 +138,7 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.kurtosis(data=returns, target="close")', @@ -175,7 +175,7 @@ def kurtosis(data: List[Data], target) -> OBBject[List[Data]]: @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.quantile(data=returns, target="close", quantile_pct=0.75)', @@ -220,7 +220,7 @@ def quantile( @router.command( methods=["POST"], - examples=[ + api_examples=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.mean(data=returns, target="close")', diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 4ed99f219654..1ee4923feaaa 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -2,6 +2,7 @@ """Commodity Futures Trading Commission (CFTC) Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -16,10 +17,7 @@ @router.command( model="COTSearch", - exclude_auto_examples=True, - examples=[ - 'obb.regulators.cftc.cot_search(query="gold")', - ], + api_examples=[Example(parameters={"query": "gold"})], ) async def cot_search( cc: CommandContext, @@ -36,13 +34,19 @@ async def cot_search( @router.command( model="COT", - exclude_auto_examples=True, - examples=[ - 'obb.regulators.cftc.cot(series_id="GC=F").to_df()', - "#### Enter the report ID by the Nasdaq Data Link Code. ####", - 'obb.regulators.cftc.cot(series_id="088691").to_df()', - "### Get the report for futures only. ####", - 'obb.regulators.cftc.cot(series_id="088691", data_type="F").to_df()', + api_examples=[ + Example( + description="Get the Commitment of Traders Report for Gold.", + parameters={"series_id": "GC=F"}, + ), + Example( + description="Enter the report ID by the Nasdaq Data Link Code.", + parameters={"series_id": "088691"}, + ), + Example( + description="Get the report for futures only.", + parameters={"series_id": "088691", "data_type": "F"}, + ), ], ) async def cot( diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index cd03a1c53a07..3eb01e775561 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -2,6 +2,7 @@ """SEC Router.""" from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -16,11 +17,7 @@ @router.command( model="CikMap", - exclude_auto_examples=True, - examples=[ - 'obb.regulators.sec.cik_map(symbol="MSFT").results.cik', - " 0000789019", - ], + api_examples=[Example(parameters={"symbol": "MSFT"})], ) async def cik_map( cc: CommandContext, @@ -34,10 +31,7 @@ async def cik_map( @router.command( model="InstitutionsSearch", - exclude_auto_examples=True, - examples=[ - 'obb.regulators.sec.institutions_search(query="blackstone real estate").to_df()' - ], + api_examples=[Example(parameters={"query": "blackstone real estate"})], ) async def institutions_search( cc: CommandContext, @@ -51,8 +45,7 @@ async def institutions_search( @router.command( model="SchemaFiles", - exclude_auto_examples=True, - examples=[ + python_examples=[ "data = obb.regulators.sec.schema_files()", "data.files[0]", " https://xbrl.fasb.org/us-gaap/", @@ -84,8 +77,7 @@ async def schema_files( @router.command( model="SymbolMap", - exclude_auto_examples=True, - examples=['obb.regulators.sec.symbol_map("0000789019").results.symbol', " MSFT"], + api_examples=[Example(parameters={"cik": "0000789019"})], ) async def symbol_map( cc: CommandContext, @@ -99,8 +91,7 @@ async def symbol_map( @router.command( model="RssLitigation", - exclude_auto_examples=True, - examples=['obb.regulators.sec.rss_litigation().to_dict("records")[0]'], + api_examples=[Example(parameters={})], ) async def rss_litigation( cc: CommandContext, @@ -114,10 +105,7 @@ async def rss_litigation( @router.command( model="SicSearch", - exclude_auto_examples=True, - examples=[ - 'obb.regulators.sec.sic_search("real estate investment trusts").results', - ], + api_examples=[Example(parameters={"query": "real estate investment trusts"})], ) async def sic_search( cc: CommandContext, diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 60b27220b95d..5192170435a3 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -24,7 +24,7 @@ @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "atr_data = obb.technical.atr(data=stock_data.results)", ], @@ -81,7 +81,7 @@ def atr( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "fib_data = obb.technical.fib(data=stock_data.results, period=120)", ], @@ -146,7 +146,7 @@ def fib( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "obv_data = obb.technical.obv(data=stock_data.results, offset=0)", ], @@ -193,7 +193,7 @@ def obv( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "fisher_data = obb.technical.fisher(data=stock_data.results, length=14, signal=1)", ], @@ -240,7 +240,7 @@ def fisher( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "adosc_data = obb.technical.adosc(data=stock_data.results, fast=3, slow=10, offset=0)", ], @@ -290,7 +290,7 @@ def adosc( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", ], @@ -362,7 +362,7 @@ def bbands( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "zlma_data = obb.technical.zlma(data=stock_data.results, target='close', length=50, offset=0)", ], @@ -420,7 +420,7 @@ def zlma( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "aaron_data = obb.technical.aroon(data=stock_data.results, length=25, scalar=100)", ], @@ -473,7 +473,7 @@ def aroon( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "sma_data = obb.technical.sma(data=stock_data.results, target='close', length=50, offset=0)", ], @@ -532,7 +532,7 @@ def sma( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "demark_data = obb.technical.demark(data=stock_data.results, offset=0)", ], @@ -586,7 +586,7 @@ def demark( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "vwap_data = obb.technical.vwap(data=stock_data.results, anchor='D', offset=0)", ], @@ -634,7 +634,7 @@ def vwap( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "macd_data = obb.technical.macd(data=stock_data.results, target='close', fast=12, slow=26, signal=9)", ], @@ -697,7 +697,7 @@ def macd( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "hma_data = obb.technical.hma(data=stock_data.results, target='close', length=50, offset=0)", ], @@ -753,7 +753,7 @@ def hma( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", ], @@ -807,7 +807,7 @@ def donchian( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ichimoku_data = obb.technical.ichimoku(data=stock_data.results, conversion=9, base=26, lookahead=False)", ], @@ -871,7 +871,7 @@ def ichimoku( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "clenow_data = obb.technical.clenow(data=stock_data.results, period=90)", ], @@ -926,7 +926,7 @@ def clenow( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", ], @@ -972,7 +972,7 @@ def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[D @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "adx_data = obb.technical.adx(data=stock_data.results, length=50, scalar=100.0, drift=1)", ], @@ -1022,7 +1022,7 @@ def adx( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "wma_data = obb.technical.wma(data=stock_data.results, target='close', length=50, offset=0)", ], @@ -1078,7 +1078,7 @@ def wma( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cci_data = obb.technical.cci(data=stock_data.results, length=14, scalar=0.015)", ], @@ -1125,7 +1125,7 @@ def cci( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "rsi_data = obb.technical.rsi(data=stock_data.results, target='close', length=14, scalar=100.0, drift=1)", ], @@ -1186,7 +1186,7 @@ def rsi( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", ], @@ -1243,7 +1243,7 @@ def stoch( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "kc_data = obb.technical.kc(data=stock_data.results, length=20, scalar=20, mamode='ema', offset=0)", ], @@ -1302,7 +1302,7 @@ def kc( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cg_data = obb.technical.cg(data=stock_data.results, length=14)", ], @@ -1344,7 +1344,7 @@ def cg( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cones_data = obb.technical.cones(data=stock_data.results, lower_q=0.25, upper_q=0.75, model='STD')", ], @@ -1443,7 +1443,7 @@ def cones( @router.command( methods=["POST"], - examples=[ + python_examples=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ema_data = obb.technical.ema(data=stock_data.results, target='close', length=50, offset=0)", ], diff --git a/openbb_platform/openbb/package/crypto.py b/openbb_platform/openbb/package/crypto.py index f55c7884a884..7bdbf3f8716c 100644 --- a/openbb_platform/openbb/package/crypto.py +++ b/openbb_platform/openbb/package/crypto.py @@ -78,8 +78,8 @@ def search( ------- >>> from openbb import obb >>> obb.crypto.search() - >>> obb.crypto.search("BTCUSD") - >>> obb.crypto.search("ETH-USD") + >>> obb.crypto.search(symbol='BTCUSD') + >>> obb.crypto.search(symbol='ETH-USD') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/crypto_price.py b/openbb_platform/openbb/package/crypto_price.py index 23ad4ec0a863..655dd265c38c 100644 --- a/openbb_platform/openbb/package/crypto_price.py +++ b/openbb_platform/openbb/package/crypto_price.py @@ -121,11 +121,11 @@ def historical( Example ------- >>> from openbb import obb - >>> obb.crypto.price.historical(symbol="BTCUSD") - >>> obb.crypto.price.historical("BTCUSD", start_date="2024-01-01", end_date="2024-01-31") - >>> obb.crypto.price.historical("ETH-USD", provider="yfinance", interval="1mo", start_date="2024-01-01", end_date="2024-12-31") - >>> obb.crypto.price.historical("BTCUSD,ETH-USD", provider="yfinance", interval="1d", start_date="2024-01-01", end_date="2024-01-31") - >>> obb.crypto.price.historical(["BTCUSD", "ETH-USD"], start_date="2024-01-01", end_date="2024-01-31") + >>> obb.crypto.price.historical(symbol='BTCUSD') + >>> obb.crypto.price.historical(symbol='BTCUSD', start_date='2024-01-01', end_date='2024-01-31') + >>> obb.crypto.price.historical(symbol='ETH-USD', provider='yfinance', interval='1mo', start_date='2024-01-01', end_date='2024-12-31') + >>> obb.crypto.price.historical(symbol='BTCUSD,ETH-USD', provider='yfinance', interval='1d', start_date='2024-01-01', end_date='2024-01-31') + >>> obb.crypto.price.historical(symbol='BTCUSD,ETH-USD', start_date='2024-01-01', end_date='2024-01-31') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/currency_price.py b/openbb_platform/openbb/package/currency_price.py index 1262aeb1754f..ab13fd1b0c95 100644 --- a/openbb_platform/openbb/package/currency_price.py +++ b/openbb_platform/openbb/package/currency_price.py @@ -122,9 +122,9 @@ def historical( Example ------- >>> from openbb import obb - >>> obb.currency.price.historical(symbol="EURUSD") + >>> obb.currency.price.historical(symbol='EURUSD') >>> # Filter historical data with specific start and end date. - >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='20213-12-31') + >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='2023-12-31') >>> # Get data with different granularity. >>> obb.currency.price.historical(symbol='EURUSD', interval='15m', provider='polygon') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py index 492b6c872e41..cc24cfda0cfd 100644 --- a/openbb_platform/openbb/package/derivatives_options.py +++ b/openbb_platform/openbb/package/derivatives_options.py @@ -150,9 +150,9 @@ def chains( Example ------- >>> from openbb import obb - >>> chains = obb.derivatives.options.chains(symbol="AAPL", provider="intrinio").to_df() - >>> #### Use the "date" parameter to get the end-of-day-data for a specific date, where supported. #### - >>> eod_chains = obb.derivatives.options.chains(symbol="AAPL", date="2023-01-25", provider="intrinio").to_df() + >>> obb.derivatives.options.chains(symbol='AAPL', provider='intrinio') + >>> # Use the "date" parameter to get the end-of-day-data for a specific date, where supported. + >>> obb.derivatives.options.chains(symbol='AAPL', date='2023-01-25', provider='intrinio') """ # noqa: E501 return self._run( @@ -240,9 +240,9 @@ def unusual( Example ------- >>> from openbb import obb - >>> options = obb.derivatives.options.unusual().to_df() - >>> #### Use the "symbol" parameter to get the most recent activity for a specific symbol. #### - >>> options = obb.derivatives.options.unusual(symbol="TSLA").to_df() + >>> obb.derivatives.options.unusual() + >>> # Use the 'symbol' parameter to get the most recent activity for a specific symbol. + >>> obb.derivatives.options.unusual(symbol='TSLA') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 9f4556f72fb8..3a836462852c 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -124,9 +124,9 @@ def calendar( Example ------- >>> from openbb import obb - >>> obb.economy.calendar(provider="fmp", start_date="2020-03-01", end_date="2020-03-31") - >>> #### By default, the calendar will be forward-looking. #### - >>> obb.economy.calendar(provider="nasdaq") + >>> obb.economy.calendar(provider='fmp', start_date='2020-03-01', end_date='2020-03-31') + >>> # By default, the calendar will be forward-looking. + >>> obb.economy.calendar(provider='nasdaq') """ # noqa: E501 return self._run( @@ -210,7 +210,7 @@ def composite_leading_indicator( Example ------- >>> from openbb import obb - >>> obb.economy.composite_leading_indicator(country="all").to_df() + >>> obb.economy.composite_leading_indicator(country='all') """ # noqa: E501 return self._run( @@ -324,9 +324,9 @@ def cpi( Example ------- >>> from openbb import obb - >>> obb.economy.cpi(countries=["japan", "china", "turkey"]).to_df() - >>> #### Use the `units` parameter to define the reference period for the change in values. #### - >>> obb.economy.cpi(countries=["united_states", "united_kingdom"], units="growth_previous").to_df() + >>> obb.economy.cpi(country='japan,china,turkey') + >>> # Use the `units` parameter to define the reference period for the change in values. + >>> obb.economy.cpi(country='united_states,united_kingdom', units='growth_previous') """ # noqa: E501 return self._run( @@ -480,10 +480,10 @@ def fred_regional( Example ------- >>> from openbb import obb - >>> #### With no date, the most recent report is returned. #### - >>> obb.economy.fred_regional("NYICLAIMS") - >>> #### With a date, time series data is returned. #### - >>> obb.economy.fred_regional("NYICLAIMS", start_date="2021-01-01") + >>> # With no date, the most recent report is returned. + >>> obb.economy.fred_regional(series_id='NYICLAIMS') + >>> # With a date, time series data is returned. + >>> obb.economy.fred_regional(series_id='NYICLAIMS', start_date='2021-01-01') """ # noqa: E501 return self._run( @@ -743,11 +743,11 @@ def fred_series( Example ------- >>> from openbb import obb - >>> obb.economy.fred_series("NFCI").to_df() - >>> #### Multiple series can be passed in as a list. #### - >>> obb.economy.fred_series(["NFCI","STLFSI4"]).to_df() - >>> #### Use the `transform` parameter to transform the data as change, log, or percent change. #### - >>> obb.economy.fred_series("CBBTCUSD", transform="pc1").to_df() + >>> obb.economy.fred_series(series_id='NFCI') + >>> # Multiple series can be passed in as a list. + >>> obb.economy.fred_series(series_id='NFCI,STLFSI4') + >>> # Use the `transform` parameter to transform the data as change, log, or percent change. + >>> obb.economy.fred_series(series_id='CBBTCUSD', transform='pc1') """ # noqa: E501 return self._run( @@ -848,7 +848,7 @@ def long_term_interest_rate( Example ------- >>> from openbb import obb - >>> obb.economy.long_term_interest_rate(country="all", frequency="quarterly").to_df() + >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 return self._run( @@ -945,7 +945,7 @@ def money_measures( Example ------- >>> from openbb import obb - >>> obb.economy.money_measures(adjusted=False).to_df() + >>> obb.economy.money_measures(adjusted=False) """ # noqa: E501 return self._run( @@ -1009,7 +1009,7 @@ def risk_premium( Example ------- >>> from openbb import obb - >>> obb.economy.risk_premium().to_df() + >>> obb.economy.risk_premium() """ # noqa: E501 return self._run( @@ -1094,7 +1094,7 @@ def short_term_interest_rate( Example ------- >>> from openbb import obb - >>> obb.economy.short_term_interest_rate(country="all", frequency="quarterly").to_df() + >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 return self._run( @@ -1183,11 +1183,9 @@ def unemployment( Example ------- >>> from openbb import obb - >>> obb.economy.unemployment(country="all", frequency="quarterly") - >>> #### Demographics for the statistics are selected with the `age` and `sex` parameters. #### - >>> obb.economy.unemployment( - >>> country="all", frequency="quarterly", age="25-54" - >>> ).to_df().pivot(columns="country", values="value") + >>> obb.economy.unemployment(country='all', frequency='quarterly') + >>> # Demographics for the statistics are selected with the `age` and `sex` parameters. + >>> obb.economy.unemployment(country='all', frequency='quarterly', age='25-54') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/economy_gdp.py b/openbb_platform/openbb/package/economy_gdp.py index 8b2c779ea8fa..e02303b12bd5 100644 --- a/openbb_platform/openbb/package/economy_gdp.py +++ b/openbb_platform/openbb/package/economy_gdp.py @@ -95,7 +95,7 @@ def forecast( Example ------- >>> from openbb import obb - >>> obb.economy.gdp.forecast(period="annual", type="real") + >>> obb.economy.gdp.forecast(period='annual', type='real') """ # noqa: E501 return self._run( @@ -184,7 +184,7 @@ def nominal( Example ------- >>> from openbb import obb - >>> obb.economy.gdp.nominal(units="usd") + >>> obb.economy.gdp.nominal(units='usd') """ # noqa: E501 return self._run( @@ -272,7 +272,7 @@ def real( Example ------- >>> from openbb import obb - >>> obb.economy.gdp.real(units="yoy") + >>> obb.economy.gdp.real(units='yoy') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index 01c8f5d8c653..8747b9a57e9f 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -387,7 +387,7 @@ def profile( Example ------- >>> from openbb import obb - >>> obb.equity.profile(symbol="AAPL") + >>> obb.equity.profile(symbol='AAPL') """ # noqa: E501 return self._run( @@ -593,7 +593,7 @@ def search( Example ------- >>> from openbb import obb - >>> obb.equity.search(query="AAPL", is_symbol=False, use_cache=True) + >>> obb.equity.search(query='AAPL', is_symbol=False, use_cache=True) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_compare.py b/openbb_platform/openbb/package/equity_compare.py index f08472add9b4..3079147dc789 100644 --- a/openbb_platform/openbb/package/equity_compare.py +++ b/openbb_platform/openbb/package/equity_compare.py @@ -64,7 +64,7 @@ def peers( Example ------- >>> from openbb import obb - >>> obb.equity.compare.peers(symbol="AAPL") + >>> obb.equity.compare.peers(symbol='AAPL') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_discovery.py b/openbb_platform/openbb/package/equity_discovery.py index c84cae036229..e1d2c19e4b02 100644 --- a/openbb_platform/openbb/package/equity_discovery.py +++ b/openbb_platform/openbb/package/equity_discovery.py @@ -88,7 +88,7 @@ def active( Example ------- >>> from openbb import obb - >>> obb.equity.discovery.active(sort="desc") + >>> obb.equity.discovery.active(sort='desc') """ # noqa: E501 return self._run( @@ -170,7 +170,7 @@ def aggressive_small_caps( Example ------- >>> from openbb import obb - >>> obb.equity.discovery.aggressive_small_caps(sort="desc") + >>> obb.equity.discovery.aggressive_small_caps(sort='desc') """ # noqa: E501 return self._run( @@ -277,7 +277,7 @@ def filings( >>> from openbb import obb >>> obb.equity.discovery.filings(limit=100) >>> # Get filings for the year 2023, limited to 100 results - >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31') + >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31', limit=100) """ # noqa: E501 return self._run( @@ -362,7 +362,7 @@ def gainers( Example ------- >>> from openbb import obb - >>> obb.equity.discovery.gainers(sort="desc") + >>> obb.equity.discovery.gainers(sort='desc') """ # noqa: E501 return self._run( @@ -444,7 +444,7 @@ def growth_tech( Example ------- >>> from openbb import obb - >>> obb.equity.discovery.growth_tech(sort="desc") + >>> obb.equity.discovery.growth_tech(sort='desc') """ # noqa: E501 return self._run( @@ -526,7 +526,7 @@ def losers( Example ------- >>> from openbb import obb - >>> obb.equity.discovery.losers(sort="desc") + >>> obb.equity.discovery.losers(sort='desc') """ # noqa: E501 return self._run( @@ -608,7 +608,7 @@ def undervalued_growth( Example ------- >>> from openbb import obb - >>> obb.equity.discovery.undervalued_growth(sort="desc") + >>> obb.equity.discovery.undervalued_growth(sort='desc') """ # noqa: E501 return self._run( @@ -690,7 +690,7 @@ def undervalued_large_caps( Example ------- >>> from openbb import obb - >>> obb.equity.discovery.undervalued_large_caps(sort="desc") + >>> obb.equity.discovery.undervalued_large_caps(sort='desc') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py index 1880f70d4400..aca93d06d4cf 100644 --- a/openbb_platform/openbb/package/equity_estimates.py +++ b/openbb_platform/openbb/package/equity_estimates.py @@ -171,7 +171,7 @@ def analyst_search( Example ------- >>> from openbb import obb - >>> obb.equity.estimates.analyst_search(firm_name="Wedbush", provider="benzinga").to_df() + >>> obb.equity.estimates.analyst_search(firm_name='Wedbush', provider='benzinga') """ # noqa: E501 return self._run( @@ -256,7 +256,7 @@ def consensus( Example ------- >>> from openbb import obb - >>> obb.equity.estimates.consensus("AAPL,MSFT", provider="yfinance").to_df() + >>> obb.equity.estimates.consensus(symbol='AAPL,MSFT', provider='yfinance') """ # noqa: E501 return self._run( @@ -374,7 +374,7 @@ def historical( Example ------- >>> from openbb import obb - >>> obb.equity.estimates.historical("AAPL", period="quarter", provider="fmp").to_df() + >>> obb.equity.estimates.historical(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -524,7 +524,7 @@ def price_target( Example ------- >>> from openbb import obb - >>> obb.equity.estimates.price_target(start_date="2020-01-01", end_date="2024-02-16",limit=10, symbol="msft", provider="benzinga",action="downgrades").to_df() + >>> obb.equity.estimates.price_target(start_date='2020-01-01', end_date='2024-02-16', limit=10, symbol='msft', provider='benzinga', action=downgrades) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index b62691b6a2d0..30de71b6353a 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -380,7 +380,7 @@ def balance( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.balance(symbol="AAPL", period="annual", limit=5) + >>> obb.equity.fundamental.balance(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 return self._run( @@ -533,7 +533,7 @@ def balance_growth( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.balance_growth(symbol="AAPL", limit=10) + >>> obb.equity.fundamental.balance_growth(symbol='AAPL', limit=10) """ # noqa: E501 return self._run( @@ -796,7 +796,7 @@ def cash( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.cash(symbol="AAPL", period="annual", limit=5) + >>> obb.equity.fundamental.cash(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 return self._run( @@ -931,7 +931,7 @@ def cash_growth( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.cash_growth(symbol="AAPL", limit=10) + >>> obb.equity.fundamental.cash_growth(symbol='AAPL', limit=10) """ # noqa: E501 return self._run( @@ -1031,7 +1031,7 @@ def dividends( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.dividends(symbol="AAPL") + >>> obb.equity.fundamental.dividends(symbol='AAPL') """ # noqa: E501 return self._run( @@ -1112,7 +1112,7 @@ def employee_count( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.employee_count(symbol="AAPL") + >>> obb.equity.fundamental.employee_count(symbol='AAPL') """ # noqa: E501 return self._run( @@ -1468,11 +1468,6 @@ def historical_eps( The date when the data was last updated. (provider: fmp) period_ending : Optional[date] The fiscal period end date. (provider: fmp) - - Example - ------- - >>> from openbb import obb - >>> obb.equity.fundamental.historical_eps(symbol="AAPL") """ # noqa: E501 return self._run( @@ -1541,7 +1536,7 @@ def historical_splits( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.historical_splits(symbol="AAPL") + >>> obb.equity.fundamental.historical_splits(symbol='AAPL') """ # noqa: E501 return self._run( @@ -1897,7 +1892,7 @@ def income( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.income(symbol="AAPL", period="annual", limit=5) + >>> obb.equity.fundamental.income(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 return self._run( @@ -2030,7 +2025,7 @@ def income_growth( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.income_growth(symbol="AAPL", limit=10, period="annual") + >>> obb.equity.fundamental.income_growth(symbol='AAPL', limit=10, period='annual') """ # noqa: E501 return self._run( @@ -2194,7 +2189,7 @@ def management( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.management(symbol="AAPL") + >>> obb.equity.fundamental.management(symbol='AAPL') """ # noqa: E501 return self._run( @@ -2300,7 +2295,7 @@ def management_compensation( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.management_compensation(symbol="AAPL") + >>> obb.equity.fundamental.management_compensation(symbol='AAPL') """ # noqa: E501 return self._run( @@ -2566,7 +2561,7 @@ def metrics( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.metrics(symbol="AAPL", period="annual", limit=100) + >>> obb.equity.fundamental.metrics(symbol='AAPL', period='annual', limit=100) """ # noqa: E501 return self._run( @@ -2755,7 +2750,7 @@ def multiples( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.multiples(symbol="AAPL") + >>> obb.equity.fundamental.multiples(symbol='AAPL') """ # noqa: E501 return self._run( @@ -2893,7 +2888,7 @@ def overview( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.overview(symbol="AAPL") + >>> obb.equity.fundamental.overview(symbol='AAPL') """ # noqa: E501 simplefilter("always", DeprecationWarning) @@ -3092,7 +3087,7 @@ def ratios( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.ratios(symbol="AAPL", period="annual", limit=12) + >>> obb.equity.fundamental.ratios(symbol='AAPL', period='annual', limit=12) """ # noqa: E501 return self._run( @@ -3184,9 +3179,9 @@ def reported_financials( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.reported_financials(symbol="AAPL", period="annual", statement_type="balance", limit=100) + >>> obb.equity.fundamental.reported_financials(symbol='AAPL', period='annual', statement_type='balance', limit=100) >>> # Get reported income statement - >>> obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='income) + >>> obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='income') >>> # Get reported cash flow statement >>> obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='cash') """ # noqa: E501 @@ -3274,7 +3269,7 @@ def revenue_per_geography( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.revenue_per_geography(symbol="AAPL", period="annual", structure="flat") + >>> obb.equity.fundamental.revenue_per_geography(symbol='AAPL', period='annual', structure='flat') """ # noqa: E501 return self._run( @@ -3359,7 +3354,7 @@ def revenue_per_segment( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.revenue_per_segment(symbol="AAPL", period="annual", structure="flat") + >>> obb.equity.fundamental.revenue_per_segment(symbol='AAPL', period='annual', structure='flat') """ # noqa: E501 return self._run( @@ -3524,7 +3519,7 @@ def trailing_dividend_yield( Example ------- >>> from openbb import obb - >>> obb.equity.fundamental.trailing_dividend_yield(limit=252) + >>> obb.equity.fundamental.trailing_dividend_yield(symbol='AAPL', limit=252) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index 723605a73eef..4a19d2462b69 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -137,7 +137,7 @@ def insider_trading( Example ------- >>> from openbb import obb - >>> obb.equity.ownership.insider_trading(symbol="AAPL", limit=500) + >>> obb.equity.ownership.insider_trading(symbol='AAPL', limit=500) """ # noqa: E501 return self._run( @@ -275,7 +275,7 @@ def institutional( Example ------- >>> from openbb import obb - >>> obb.equity.ownership.institutional(symbol="AAPL") + >>> obb.equity.ownership.institutional(symbol='AAPL') """ # noqa: E501 return self._run( @@ -426,7 +426,7 @@ def major_holders( Example ------- >>> from openbb import obb - >>> obb.equity.ownership.major_holders(symbol="AAPL", page=0) + >>> obb.equity.ownership.major_holders(symbol='AAPL', page=0) """ # noqa: E501 return self._run( @@ -528,7 +528,7 @@ def share_statistics( Example ------- >>> from openbb import obb - >>> obb.equity.ownership.share_statistics(symbol="AAPL") + >>> obb.equity.ownership.share_statistics(symbol='AAPL') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py index 57506be8a8f7..35d15ca4f164 100644 --- a/openbb_platform/openbb/package/equity_price.py +++ b/openbb_platform/openbb/package/equity_price.py @@ -170,7 +170,7 @@ def historical( Example ------- >>> from openbb import obb - >>> obb.equity.price.historical(symbol="AAPL", interval="1d") + >>> obb.equity.price.historical(symbol='AAPL', interval='1d') """ # noqa: E501 return self._run( @@ -313,7 +313,7 @@ def nbbo( Example ------- >>> from openbb import obb - >>> obb.equity.price.nbbo(symbol="AAPL") + >>> obb.equity.price.nbbo(symbol='AAPL') """ # noqa: E501 return self._run( @@ -407,7 +407,7 @@ def performance( Example ------- >>> from openbb import obb - >>> obb.equity.price.performance(symbol="AAPL") + >>> obb.equity.price.performance(symbol='AAPL') """ # noqa: E501 return self._run( @@ -574,7 +574,7 @@ def quote( Example ------- >>> from openbb import obb - >>> obb.equity.price.quote(symbol="AAPL") + >>> obb.equity.price.quote(symbol='AAPL') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index 0ece89314d78..7ec598d9bda3 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -74,7 +74,7 @@ def countries( Example ------- >>> from openbb import obb - >>> obb.etf.countries("VT", provider="fmp") + >>> obb.etf.countries(symbol='VT', provider='fmp') """ # noqa: E501 return self._run( @@ -149,9 +149,9 @@ def equity_exposure( Example ------- >>> from openbb import obb - >>> obb.etf.equity_exposure("MSFT", provider="fmp") - >>> #### This function accepts multiple tickers. #### - >>> obb.etf.equity_exposure("MSFT,AAPL", provider="fmp") + >>> obb.etf.equity_exposure(symbol='MSFT', provider='fmp') + >>> # This function accepts multiple tickers. + >>> obb.etf.equity_exposure(symbol='MSFT,AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -243,10 +243,10 @@ def historical( Example ------- >>> from openbb import obb - >>> obb.etf.historical(symbol="SPY") - >>> obb.etf.historical("SPY", provider="yfinance") - >>> #### This function accepts multiple tickers. #### - >>> obb.etf.historical("SPY,IWM,QQQ,DJIA", provider="yfinance") + >>> obb.etf.historical(symbol='SPY') + >>> obb.etf.historical(symbol='SPY', provider='yfinance') + >>> # This function accepts multiple tickers. + >>> obb.etf.historical(symbol='SPY,IWM,QQQ,DJIA', provider='yfinance') """ # noqa: E501 return self._run( @@ -290,7 +290,7 @@ def holdings( no default. date : Optional[Union[str, datetime.date]] A specific date to get data for. Entering a date will attempt to return the NPORT-P filing for the entered date. This needs to be _exactly_ the date of the filing. Use the holdings_date command/endpoint to find available filing dates for the ETF. (provider: fmp); - A specific date to get data for. The date represents the period ending. The date entered will return the closest filing. (provider: sec) + A specific date to get data for. The date represents the period ending. The date entered will return the closest filing. (provider: sec) cik : Optional[str] The CIK of the filing entity. Overrides symbol. (provider: fmp) use_cache : bool @@ -382,7 +382,7 @@ def holdings( in_arrears : Optional[str] If the debt security is in arrears. (provider: sec) is_paid_kind : Optional[str] - If the debt security payments are are paid in kind. (provider: sec) + If the debt security payments are paid in kind. (provider: sec) derivative_category : Optional[str] The derivative category of the holding. (provider: sec) counterparty : Optional[str] @@ -477,11 +477,11 @@ def holdings( Example ------- >>> from openbb import obb - >>> obb.etf.holdings("XLK", provider="fmp").to_df() - >>> #### Including a date (FMP, SEC) will return the holdings as per NPORT-P filings. #### - >>> obb.etf.holdings("XLK", date="2022-03-31",provider="fmp").to_df() - >>> #### The same data can be returned from the SEC directly. #### - >>> obb.etf.holdings("XLK", date="2022-03-31",provider="sec").to_df() + >>> obb.etf.holdings(symbol='XLK', provider='fmp') + >>> # Including a date (FMP, SEC) will return the holdings as per NPORT-P filings. + >>> obb.etf.holdings(symbol='XLK', date='2022-03-31', provider='fmp') + >>> # The same data can be returned from the SEC directly. + >>> obb.etf.holdings(symbol='XLK', date='2022-03-31', provider='sec') """ # noqa: E501 return self._run( @@ -546,7 +546,7 @@ def holdings_date( Example ------- >>> from openbb import obb - >>> obb.etf.holdings_date("XLK", provider="fmp").results + >>> obb.etf.holdings_date(symbol='XLK', provider='fmp') """ # noqa: E501 return self._run( @@ -640,7 +640,7 @@ def holdings_performance( Example ------- >>> from openbb import obb - >>> obb.etf.holdings_performance("XLK", provider="fmp") + >>> obb.etf.holdings_performance(symbol='XLK', provider='fmp') """ # noqa: E501 return self._run( @@ -799,9 +799,9 @@ def info( Example ------- >>> from openbb import obb - >>> obb.etf.info("SPY", provider="fmp") - >>> #### This function accepts multiple tickers. #### - >>> obb.etf.info("SPY,IWM,QQQ,DJIA", provider="fmp") + >>> obb.etf.info(symbol='SPY', provider='fmp') + >>> # This function accepts multiple tickers. + >>> obb.etf.info(symbol='SPY,IWM,QQQ,DJIA', provider='fmp') """ # noqa: E501 return self._run( @@ -896,7 +896,7 @@ def price_performance( Example ------- >>> from openbb import obb - >>> obb.etf.price_performance("SPY,QQQ,IWM,DJIA", provider="fmp") + >>> obb.etf.price_performance(symbol='SPY,QQQ,IWM,DJIA', provider='fmp') """ # noqa: E501 return self._run( @@ -991,9 +991,10 @@ def search( Example ------- >>> from openbb import obb - >>> ### An empty query returns the full list of ETFs from the provider. ### - >>> obb.etf.search("", provider="fmp") - >>> #### The query will return results from text-based fields containing the term. ####obb.etf.search("commercial real estate", provider="fmp") + >>> # An empty query returns the full list of ETFs from the provider. + >>> obb.etf.search(provider='fmp') + >>> # The query will return results from text-based fields containing the term. + >>> obb.etf.search(query='commercial real estate', provider='fmp') """ # noqa: E501 return self._run( @@ -1058,7 +1059,7 @@ def sectors( Example ------- >>> from openbb import obb - >>> obb.etf.sectors("SPY", provider="fmp") + >>> obb.etf.sectors(symbol='SPY', provider='fmp') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index 65ec3f7ae62e..94d8b8c901d5 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -112,7 +112,7 @@ def sofr( Example ------- >>> from openbb import obb - >>> obb.fixedincome.fixedincome.sofr(period="overnight") + >>> obb.fixedincome.sofr(period='overnight') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index 6d8d8778a8d7..099824f8edad 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -102,7 +102,7 @@ def commercial_paper( Example ------- >>> from openbb import obb - >>> obb.fixedincome.corporate.commercial_paper(maturity="15d") + >>> obb.fixedincome.corporate.commercial_paper(maturity='15d') """ # noqa: E501 return self._run( @@ -190,7 +190,7 @@ def hqm( Example ------- >>> from openbb import obb - >>> obb.fixedincome.corporate.hqm(yield_curve="par") + >>> obb.fixedincome.corporate.hqm(yield_curve='par') """ # noqa: E501 return self._run( @@ -288,7 +288,7 @@ def ice_bofa( Example ------- >>> from openbb import obb - >>> obb.fixedincome.corporate.ice_bofa(index_type="yield_to_worst") + >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst') """ # noqa: E501 return self._run( @@ -380,7 +380,7 @@ def moody( Example ------- >>> from openbb import obb - >>> obb.fixedincome.corporate.moody(index_type="baa") + >>> obb.fixedincome.corporate.moody(index_type='baa') """ # noqa: E501 return self._run( @@ -475,7 +475,7 @@ def spot_rates( Example ------- >>> from openbb import obb - >>> obb.fixedincome.corporate.spot_rates(maturity=[10,20,30,50]) + >>> obb.fixedincome.corporate.spot_rates(maturity=[10, 20, 30, 50]) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_government.py b/openbb_platform/openbb/package/fixedincome_government.py index 68d7c9540513..5adc53259cc9 100644 --- a/openbb_platform/openbb/package/fixedincome_government.py +++ b/openbb_platform/openbb/package/fixedincome_government.py @@ -100,7 +100,7 @@ def treasury_rates( Example ------- >>> from openbb import obb - >>> obb.fixedincome.government.treasury_rates(provider="federal_reserve") + >>> obb.fixedincome.government.treasury_rates(provider='federal_reserve') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_rate.py b/openbb_platform/openbb/package/fixedincome_rate.py index 3049e7766494..4e60f246222f 100644 --- a/openbb_platform/openbb/package/fixedincome_rate.py +++ b/openbb_platform/openbb/package/fixedincome_rate.py @@ -89,7 +89,7 @@ def ameribor( Example ------- >>> from openbb import obb - >>> obb.fixedincome.rate.ameribor(parameter="30_day_ma").to_df() + >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma') """ # noqa: E501 return self._run( @@ -174,7 +174,7 @@ def dpcredit( Example ------- >>> from openbb import obb - >>> obb.fixedincome.rate.dpcredit(start_date="2023-02-01", end_date="2023-05-01").to_df() + >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') """ # noqa: E501 return self._run( @@ -265,7 +265,7 @@ def ecb( Example ------- >>> from openbb import obb - >>> obb.fixedincome.rate.ecb(interest_rate_type="refinancing") + >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing') """ # noqa: E501 return self._run( @@ -350,7 +350,7 @@ def effr( Example ------- >>> from openbb import obb - >>> obb.fixedincome.rate.effr(parameter="daily", provider="fred").to_df() + >>> obb.fixedincome.rate.effr(parameter='daily', provider='fred') """ # noqa: E501 return self._run( @@ -511,7 +511,7 @@ def estr( Example ------- >>> from openbb import obb - >>> obb.fixedincome.rate.estr(parameter="number_of_active_banks") + >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks') """ # noqa: E501 return self._run( @@ -677,7 +677,7 @@ def sonia( Example ------- >>> from openbb import obb - >>> obb.fixedincome.rate.sonia(parameter="total_nominal_value") + >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_spreads.py b/openbb_platform/openbb/package/fixedincome_spreads.py index 9c420f701cd0..a68b47b0c673 100644 --- a/openbb_platform/openbb/package/fixedincome_spreads.py +++ b/openbb_platform/openbb/package/fixedincome_spreads.py @@ -89,7 +89,7 @@ def tcm( Example ------- >>> from openbb import obb - >>> obb.fixedincome.fixedincome.spreads.tcm(maturity="2y") + >>> obb.fixedincome.spreads.tcm(maturity='2y') """ # noqa: E501 return self._run( @@ -179,7 +179,7 @@ def tcm_effr( Example ------- >>> from openbb import obb - >>> obb.fixedincome.fixedincome.spreads.tcm_effr(maturity="10y") + >>> obb.fixedincome.spreads.tcm_effr(maturity='10y') """ # noqa: E501 return self._run( @@ -270,7 +270,7 @@ def treasury_effr( Example ------- >>> from openbb import obb - >>> obb.fixedincome.fixedincome.spreads.treasury_effr(maturity="6m") + >>> obb.fixedincome.spreads.treasury_effr(maturity='6m') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index 60734afb166e..a7e01bb8899a 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -70,7 +70,7 @@ def available( Example ------- >>> from openbb import obb - >>> obb.index.available(provider="yfinance").to_df() + >>> obb.index.available(provider='yfinance') """ # noqa: E501 return self._run( @@ -145,9 +145,9 @@ def constituents( Example ------- >>> from openbb import obb - >>> obb.index.constituents("dowjones", provider="fmp").to_df() - >>> #### Providers other than FMP will use the ticker symbol. #### - >>> obb.index.constituents("BEP50P", provider="cboe").to_df() + >>> obb.index.constituents(symbol='dowjones', provider='fmp') + >>> # Providers other than FMP will use the ticker symbol. + >>> obb.index.constituents(symbol='BEP50P', provider='cboe') """ # noqa: E501 return self._run( @@ -283,7 +283,7 @@ def market( Example ------- >>> from openbb import obb - >>> obb.index.market(symbol="SPX") + >>> obb.index.market(symbol='SPX') """ # noqa: E501 simplefilter("always", DeprecationWarning) diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index 91c050b1badf..d2eaff49b2cd 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -66,8 +66,7 @@ def cik_map( Example ------- >>> from openbb import obb - >>> obb.regulators.sec.cik_map(symbol="MSFT").results.cik - >>> 0000789019 + >>> obb.regulators.sec.cik_map(symbol='MSFT') """ # noqa: E501 return self._run( @@ -138,7 +137,7 @@ def institutions_search( Example ------- >>> from openbb import obb - >>> obb.regulators.sec.institutions_search(query="blackstone real estate").to_df() + >>> obb.regulators.sec.institutions_search(query='blackstone real estate') """ # noqa: E501 return self._run( @@ -203,7 +202,7 @@ def rss_litigation( Example ------- >>> from openbb import obb - >>> obb.regulators.sec.rss_litigation().to_dict("records")[0] + >>> obb.regulators.sec.rss_litigation() """ # noqa: E501 return self._run( @@ -362,7 +361,7 @@ def sic_search( Example ------- >>> from openbb import obb - >>> obb.regulators.sec.sic_search("real estate investment trusts").results + >>> obb.regulators.sec.sic_search(query='real estate investment trusts') """ # noqa: E501 return self._run( @@ -432,8 +431,7 @@ def symbol_map( Example ------- >>> from openbb import obb - >>> obb.regulators.sec.symbol_map("0000789019").results.symbol - >>> MSFT + >>> obb.regulators.sec.symbol_map(cik='0000789019') """ # noqa: E501 return self._run( From 95a3c80a3a64443f72b1a761525c4d862601b1d5 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 12:22:59 +0000 Subject: [PATCH 002/133] add missing exampels --- openbb_platform/core/openbb_core/app/router.py | 2 +- .../core/openbb_core/app/static/package_builder.py | 4 ++-- .../extensions/currency/openbb_currency/price/price_router.py | 2 +- .../equity/openbb_equity/fundamental/fundamental_router.py | 4 +++- .../openbb_fixedincome/corporate/corporate_router.py | 2 +- .../extensions/regulators/openbb_regulators/sec/sec_router.py | 1 + 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index 2c6347e75460..8bdeadb4b074 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -234,7 +234,7 @@ def command( model = kwargs.pop("model", "") api_examples: List[Example] = kwargs.pop("api_examples", []) - python_examples = kwargs.pop("python_examples", None) + python_examples = kwargs.pop("python_examples", []) if func := SignatureInspector.complete(func, model): diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 38b578c09955..a9a593ee9a83 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -405,8 +405,8 @@ def build(path: str, ext_map: Optional[Dict[str, List[str]]] = None) -> str: if route.openapi_extra else None ), - examples=(route.openapi_extra.get("api_examples", []) or []) - + (route.openapi_extra.get("python_examples", []) or []), + examples=route.openapi_extra.get("api_examples", []) + + route.openapi_extra.get("python_examples", []), ) else: doc += " /" if path else " /" diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index 9e45e98eedaf..acccd3b033dd 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -2,6 +2,7 @@ # pylint: disable=unused-argument from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -10,7 +11,6 @@ ) from openbb_core.app.query import Query from openbb_core.app.router import Router -from openbb_core.app.model.example import Example router = Router(prefix="/price") diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index a3f573c4fb73..2932dfd45e1b 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -134,7 +134,9 @@ async def dividends( return await OBBject.from_query(Query(**locals())) -@router.command(model="HistoricalEps") +@router.command( + model="HistoricalEps", api_examples=[Example(parameters={"symbol": "AAPL"})] +) async def historical_eps( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index 62f1b04b6bdd..8000daf77269 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -117,7 +117,7 @@ async def commercial_paper( return await OBBject.from_query(Query(**locals())) -@router.command(model="BondPrices") +@router.command(model="BondPrices", api_examples=[Example(parameters={})]) async def bond_prices( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 3eb01e775561..e887a0fe716d 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -45,6 +45,7 @@ async def institutions_search( @router.command( model="SchemaFiles", + api_examples=[Example(parameters={})], python_examples=[ "data = obb.regulators.sec.schema_files()", "data.files[0]", From f5ca92ea4ab47f57e2b71703c76bd9843eb11f85 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 12:35:44 +0000 Subject: [PATCH 003/133] rebuild --- openbb_platform/core/openbb_core/app/router.py | 7 ++----- .../core/openbb_core/app/static/package_builder.py | 4 ++-- openbb_platform/openbb/package/equity_fundamental.py | 5 +++++ openbb_platform/openbb/package/regulators_sec.py | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index 8bdeadb4b074..640e57182bef 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -28,7 +28,6 @@ from openbb_core.app.extension_loader import ExtensionLoader from openbb_core.app.model.abstract.warning import OpenBBWarning from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -233,16 +232,14 @@ def command( api_router = self._api_router model = kwargs.pop("model", "") - api_examples: List[Example] = kwargs.pop("api_examples", []) - python_examples = kwargs.pop("python_examples", []) if func := SignatureInspector.complete(func, model): kwargs["response_model_exclude_unset"] = True kwargs["openapi_extra"] = kwargs.get("openapi_extra", {}) kwargs["openapi_extra"]["model"] = model - kwargs["openapi_extra"]["api_examples"] = api_examples - kwargs["openapi_extra"]["python_examples"] = python_examples + kwargs["openapi_extra"]["api_examples"] = kwargs.pop("api_examples", None) + kwargs["openapi_extra"]["python_examples"] = kwargs.pop("python_examples", None) kwargs["operation_id"] = kwargs.get( "operation_id", SignatureInspector.get_operation_id(func) ) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index a9a593ee9a83..38b578c09955 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -405,8 +405,8 @@ def build(path: str, ext_map: Optional[Dict[str, List[str]]] = None) -> str: if route.openapi_extra else None ), - examples=route.openapi_extra.get("api_examples", []) - + route.openapi_extra.get("python_examples", []), + examples=(route.openapi_extra.get("api_examples", []) or []) + + (route.openapi_extra.get("python_examples", []) or []), ) else: doc += " /" if path else " /" diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index 30de71b6353a..19c5e0b9d508 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -1468,6 +1468,11 @@ def historical_eps( The date when the data was last updated. (provider: fmp) period_ending : Optional[date] The fiscal period end date. (provider: fmp) + + Example + ------- + >>> from openbb import obb + >>> obb.equity.fundamental.historical_eps(symbol='AAPL') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index d2eaff49b2cd..2fed19c18e82 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -271,6 +271,7 @@ def schema_files( Example ------- >>> from openbb import obb + >>> obb.regulators.sec.schema_files() >>> data = obb.regulators.sec.schema_files() >>> data.files[0] >>> https://xbrl.fasb.org/us-gaap/ From 26bd1b2bea46e469057385512b8aeca5102a0376 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 12:44:02 +0000 Subject: [PATCH 004/133] query params focstring --- .../openbb_core/provider/abstract/query_params.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/provider/abstract/query_params.py b/openbb_platform/core/openbb_core/provider/abstract/query_params.py index 09714e3565a1..acca98737678 100644 --- a/openbb_platform/core/openbb_core/provider/abstract/query_params.py +++ b/openbb_platform/core/openbb_core/provider/abstract/query_params.py @@ -14,7 +14,9 @@ class QueryParams(BaseModel): Key Features: - Alias handling: Utilizes an aliasing mechanism to maintain compatibility with different naming conventions across various data formats. The alias is only applied when running `model_dump`. - - Json schema extra merging: Merge different json schema extra, identified by provider. + - Json schema extra merging: + + Merge different json schema extra, identified by provider. Example: FMP fetcher: __json_schema_extra__ = {"symbol": ["multiple_items_allowed"]} @@ -28,6 +30,13 @@ class QueryParams(BaseModel): ..., } + Multiple fields can be tagged with the same or multiple properties. + Example: + __json_schema_extra__ = { + "": ["some_prop", "another_prop"], + "": ["yet_another_prop"] + } + Attributes: __alias_dict__ (Dict[str, str]): A dictionary that maps field names to their aliases, From 0783aac9878ca95eda5cc19f2bdd1905413ff2fb Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 13:12:21 +0000 Subject: [PATCH 005/133] black --- openbb_platform/core/openbb_core/app/router.py | 4 +++- website/generate_excel_markdown.py | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index 640e57182bef..65598a49b6ae 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -239,7 +239,9 @@ def command( kwargs["openapi_extra"] = kwargs.get("openapi_extra", {}) kwargs["openapi_extra"]["model"] = model kwargs["openapi_extra"]["api_examples"] = kwargs.pop("api_examples", None) - kwargs["openapi_extra"]["python_examples"] = kwargs.pop("python_examples", None) + kwargs["openapi_extra"]["python_examples"] = kwargs.pop( + "python_examples", None + ) kwargs["operation_id"] = kwargs.get( "operation_id", SignatureInspector.get_operation_id(func) ) diff --git a/website/generate_excel_markdown.py b/website/generate_excel_markdown.py index fd672981a680..026e88d76835 100644 --- a/website/generate_excel_markdown.py +++ b/website/generate_excel_markdown.py @@ -4,10 +4,9 @@ from functools import reduce from pathlib import Path from textwrap import shorten -from typing import Any, Dict, List, Literal +from typing import Any, Dict, List, Literal, Optional import requests -from requests_cache import Optional # Paths WEBSITE_PATH = Path(__file__).parent.absolute() From 1ae2cbd71ff7eb6bf9a1aaa8a64e82c0737b2551 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 13:27:33 +0000 Subject: [PATCH 006/133] add scoped examples --- .../core/openbb_core/app/model/__init__.py | 3 +++ .../core/openbb_core/app/model/example.py | 5 ++++- .../extensions/etf/openbb_etf/etf_router.py | 13 +++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/__init__.py b/openbb_platform/core/openbb_core/app/model/__init__.py index e69de29bb2d1..83c01772f8e0 100644 --- a/openbb_platform/core/openbb_core/app/model/__init__.py +++ b/openbb_platform/core/openbb_core/app/model/__init__.py @@ -0,0 +1,3 @@ +from .command_context import CommandContext +from .example import Example +from .obbject import OBBject diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 35c7bdf6b36c..15c742e40097 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional +from typing import Any, Dict, Optional, Literal from pydantic import BaseModel, ConfigDict @@ -6,6 +6,9 @@ class Example(BaseModel): """Example model.""" + scope: Literal[ + "required", "standard", "other" + ] # Required parameters, standard parameters, or other description: Optional[str] = None parameters: Dict[str, Any] diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index 2f3ff6cd8539..b489ce533db8 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -1,8 +1,6 @@ """ETF Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -23,10 +21,12 @@ model="EtfSearch", api_examples=[ Example( + scope="required", description="An empty query returns the full list of ETFs from the provider.", - parameters={"provider": "fmp"}, + parameters={}, ), Example( + scope="standard", description="The query will return results from text-based fields containing the term.", parameters={"query": "commercial real estate", "provider": "fmp"}, ), @@ -49,9 +49,10 @@ async def search( model="EtfHistorical", operation_id="etf_historical", api_examples=[ - Example(parameters={"symbol": "SPY"}), - Example(parameters={"symbol": "SPY", "provider": "yfinance"}), + Example(scope="required", parameters={"symbol": "SPY"}), + Example(scope="other", parameters={"symbol": "SPY", "provider": "yfinance"}), Example( + scope="other", description="This function accepts multiple tickers.", parameters={"symbol": "SPY,IWM,QQQ,DJIA", "provider": "yfinance"}, ), From c5d7776b8ec4fd89d5782acfbb6b0931d5c3f1e5 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 13:59:58 +0000 Subject: [PATCH 007/133] group model imports in the router --- .../extensions/commodity/openbb_commodity/commodity_router.py | 4 +--- .../extensions/crypto/openbb_crypto/crypto_router.py | 4 +--- .../extensions/crypto/openbb_crypto/price/price_router.py | 4 +--- .../extensions/currency/openbb_currency/currency_router.py | 4 +--- .../extensions/currency/openbb_currency/price/price_router.py | 4 +--- .../derivatives/openbb_derivatives/futures/futures_router.py | 4 +--- .../derivatives/openbb_derivatives/options/options_router.py | 4 +--- .../extensions/economy/openbb_economy/economy_router.py | 4 +--- .../extensions/economy/openbb_economy/gdp/gdp_router.py | 4 +--- .../equity/openbb_equity/calendar/calendar_router.py | 4 +--- .../extensions/equity/openbb_equity/compare/compare_router.py | 4 +--- .../equity/openbb_equity/darkpool/darkpool_router.py | 4 +--- .../equity/openbb_equity/discovery/discovery_router.py | 4 +--- .../extensions/equity/openbb_equity/equity_router.py | 4 +--- .../equity/openbb_equity/estimates/estimates_router.py | 4 +--- .../equity/openbb_equity/fundamental/fundamental_router.py | 4 +--- .../equity/openbb_equity/ownership/ownership_router.py | 4 +--- .../extensions/equity/openbb_equity/price/price_router.py | 4 +--- .../extensions/equity/openbb_equity/shorts/shorts_router.py | 4 +--- .../extensions/etf/openbb_etf/discovery/discovery_router.py | 4 +--- .../openbb_fixedincome/corporate/corporate_router.py | 4 +--- .../fixedincome/openbb_fixedincome/fixedincome_router.py | 4 +--- .../openbb_fixedincome/government/government_router.py | 4 +--- .../fixedincome/openbb_fixedincome/rate/rate_router.py | 4 +--- .../fixedincome/openbb_fixedincome/spreads/spreads_router.py | 4 +--- openbb_platform/extensions/index/openbb_index/index_router.py | 4 +--- .../extensions/index/openbb_index/price/price_router.py | 4 +--- openbb_platform/extensions/news/openbb_news/news_router.py | 4 +--- .../regulators/openbb_regulators/cftc/cftc_router.py | 4 +--- .../extensions/regulators/openbb_regulators/sec/sec_router.py | 4 +--- 30 files changed, 30 insertions(+), 90 deletions(-) diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index 15189dae5733..2a904f0742fe 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -1,8 +1,6 @@ """The Commodity router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py index d22aa927f34e..bd2a3dfd4666 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py @@ -1,8 +1,6 @@ """Crypto Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index fb4e60f2aff5..e0b96c1eb76b 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -1,9 +1,7 @@ # pylint: disable=W0613:unused-argument """Crypto Price Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index 63fe18701587..defefa38c3e0 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -1,8 +1,6 @@ """The Currency router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index acccd3b033dd..2a5c5896ef4c 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -1,9 +1,7 @@ """Price router for Currency.""" # pylint: disable=unused-argument -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index 9834ff32d0ed..4039affb1877 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -1,8 +1,6 @@ """Futures Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index da46204c615d..97a522807067 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -1,8 +1,6 @@ """Options Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 6bb7aa71cc8e..c24c4c15a953 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -1,8 +1,6 @@ """Economy Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py index 039e0df56946..9654a3681fba 100644 --- a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py @@ -1,8 +1,6 @@ """Economy GDP Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py index 9625858cac89..a480f7a629c6 100644 --- a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py @@ -1,8 +1,6 @@ """Calendar Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py index a4d181a17d0f..d4bb41e95b0c 100644 --- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py @@ -1,9 +1,7 @@ # pylint: disable=W0613:unused-argument """Comparison Analysis Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py index 6e6658ea19ee..d7ef7dc2deac 100644 --- a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py @@ -1,8 +1,6 @@ """Dark Pool Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index 3f180612adb3..520e264f300a 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -1,9 +1,7 @@ """Disc router for Equities.""" # pylint: disable=unused-argument -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/equity_router.py b/openbb_platform/extensions/equity/openbb_equity/equity_router.py index 8c2283f231da..578b4e02cef4 100644 --- a/openbb_platform/extensions/equity/openbb_equity/equity_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/equity_router.py @@ -1,8 +1,6 @@ """Equity Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index 524328971da1..c4da08d41ea7 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -1,8 +1,6 @@ """Estimates Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index 2932dfd45e1b..545181682099 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -2,9 +2,7 @@ """Fundamental Analysis Router.""" from openbb_core.app.deprecation import OpenBBDeprecationWarning -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index 3a2534e4a47c..d9812301fcf9 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -1,8 +1,6 @@ """Ownership Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index aa1031225799..cbbdcfb61d20 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -1,8 +1,6 @@ """Price Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index 1ab8073aed43..6c4aac3ec7f3 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -1,8 +1,6 @@ """Shorts Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py index d334f97ff996..9a2ecb4cc81f 100644 --- a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py @@ -1,8 +1,6 @@ """Disc router for ETFs.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index 8000daf77269..3be77870a374 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -1,8 +1,6 @@ """Fixed Income Corporate Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py index ea4efb3518fa..e59b45967713 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py @@ -2,9 +2,7 @@ # pylint: disable=W0613:unused-argument -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index 5de66f7a6eb5..16e22cae06a0 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -1,8 +1,6 @@ """Fixed Income Government Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index 111108ea8f70..73d4db76eb52 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -1,8 +1,6 @@ """Fixed Income Rate Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py index 2b331eae5eb3..8399c66618bb 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py @@ -1,8 +1,6 @@ """Fixed Income Corporate Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index 5e8bb8ef1250..2f1c20b50fa2 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -1,9 +1,7 @@ """Index Router.""" from openbb_core.app.deprecation import OpenBBDeprecationWarning -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index 4843502e4c5b..c8c155f8355a 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -1,8 +1,6 @@ """Price Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index 2f43b365f8ba..c6f7e645aae6 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -1,9 +1,7 @@ # pylint: disable=import-outside-toplevel, W0613:unused-argument """News Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 1ee4923feaaa..69240646147f 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -1,9 +1,7 @@ # pylint: disable=W0613:unused-argument """Commodity Futures Trading Commission (CFTC) Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index e887a0fe716d..0a321f717b19 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -1,9 +1,7 @@ # pylint: disable=W0613:unused-argument """SEC Router.""" -from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import CommandContext, Example, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, From 3952c1cd4dcce5d39154b58da875a01f5603b754 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 14:00:43 +0000 Subject: [PATCH 008/133] unblock api --- openbb_platform/core/openbb_core/app/model/example.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 15c742e40097..15713215ab3f 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -6,9 +6,10 @@ class Example(BaseModel): """Example model.""" + # TODO: Evaluate making scope mandatory scope: Literal[ "required", "standard", "other" - ] # Required parameters, standard parameters, or other + ] = "other" # Required parameters, standard parameters, or other description: Optional[str] = None parameters: Dict[str, Any] From 70bd9ab672a949e3196f936b4a908fa6284b5454 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 15:28:19 +0000 Subject: [PATCH 009/133] fix --- openbb_platform/extensions/etf/openbb_etf/etf_router.py | 7 ++----- openbb_platform/openbb/package/etf.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index b489ce533db8..bc7cf050338d 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -21,12 +21,10 @@ model="EtfSearch", api_examples=[ Example( - scope="required", description="An empty query returns the full list of ETFs from the provider.", parameters={}, ), Example( - scope="standard", description="The query will return results from text-based fields containing the term.", parameters={"query": "commercial real estate", "provider": "fmp"}, ), @@ -49,10 +47,9 @@ async def search( model="EtfHistorical", operation_id="etf_historical", api_examples=[ - Example(scope="required", parameters={"symbol": "SPY"}), - Example(scope="other", parameters={"symbol": "SPY", "provider": "yfinance"}), + Example(parameters={"symbol": "SPY"}), + Example(parameters={"symbol": "SPY", "provider": "yfinance"}), Example( - scope="other", description="This function accepts multiple tickers.", parameters={"symbol": "SPY,IWM,QQQ,DJIA", "provider": "yfinance"}, ), diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index 7ec598d9bda3..939d3c529142 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -992,7 +992,7 @@ def search( ------- >>> from openbb import obb >>> # An empty query returns the full list of ETFs from the provider. - >>> obb.etf.search(provider='fmp') + >>> obb.etf.search() >>> # The query will return results from text-based fields containing the term. >>> obb.etf.search(query='commercial real estate', provider='fmp') """ # noqa: E501 From 52ed665be9bb6556c8eb48d41759cec319ad2246 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 17:44:06 +0000 Subject: [PATCH 010/133] classify examples --- .../core/openbb_core/app/model/example.py | 10 +- .../core/openbb_core/app/router.py | 7 +- .../openbb_core/app/static/package_builder.py | 20 +- .../openbb_commodity/commodity_router.py | 2 +- .../crypto/openbb_crypto/crypto_router.py | 2 +- .../openbb_crypto/price/price_router.py | 14 +- .../openbb_currency/currency_router.py | 4 +- .../openbb_currency/price/price_router.py | 2 +- .../futures/futures_router.py | 4 +- .../options/options_router.py | 4 +- .../econometrics_router.py | 94 ++++-- .../economy/openbb_economy/economy_router.py | 24 +- .../economy/openbb_economy/gdp/gdp_router.py | 6 +- .../openbb_equity/calendar/calendar_router.py | 8 +- .../openbb_equity/compare/compare_router.py | 4 +- .../openbb_equity/darkpool/darkpool_router.py | 2 +- .../discovery/discovery_router.py | 26 +- .../equity/openbb_equity/equity_router.py | 10 +- .../estimates/estimates_router.py | 8 +- .../fundamental/fundamental_router.py | 64 ++-- .../ownership/ownership_router.py | 8 +- .../openbb_equity/price/price_router.py | 12 +- .../openbb_equity/shorts/shorts_router.py | 6 +- .../openbb_etf/discovery/discovery_router.py | 6 +- .../extensions/etf/openbb_etf/etf_router.py | 22 +- .../corporate/corporate_router.py | 12 +- .../openbb_fixedincome/fixedincome_router.py | 2 +- .../government/government_router.py | 10 +- .../openbb_fixedincome/rate/rate_router.py | 16 +- .../spreads/spreads_router.py | 6 +- .../index/openbb_index/index_router.py | 14 +- .../index/openbb_index/price/price_router.py | 2 +- .../news/openbb_news/news_router.py | 4 +- .../performance/performance_router.py | 43 ++- .../quantitative_router.py | 24 +- .../rolling/rolling_router.py | 82 +++-- .../openbb_quantitative/stats/stats_router.py | 80 +++-- .../openbb_regulators/cftc/cftc_router.py | 4 +- .../openbb_regulators/sec/sec_router.py | 53 ++-- .../openbb_technical/technical_router.py | 288 +++++++++++++----- .../openbb/package/regulators_sec.py | 41 +-- 41 files changed, 627 insertions(+), 423 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 15713215ab3f..2166b61c291c 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, Optional, Literal +from typing import Any, Dict, List, Literal, Optional from pydantic import BaseModel, ConfigDict @@ -6,11 +6,9 @@ class Example(BaseModel): """Example model.""" - # TODO: Evaluate making scope mandatory - scope: Literal[ - "required", "standard", "other" - ] = "other" # Required parameters, standard parameters, or other + scope: Literal["api", "python"] = "api" description: Optional[str] = None - parameters: Dict[str, Any] + parameters: Optional[Dict[str, Any]] = None + code: Optional[List[str]] = None model_config = ConfigDict(validate_assignment=True) diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index 65598a49b6ae..79ee776870a7 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -238,10 +238,7 @@ def command( kwargs["response_model_exclude_unset"] = True kwargs["openapi_extra"] = kwargs.get("openapi_extra", {}) kwargs["openapi_extra"]["model"] = model - kwargs["openapi_extra"]["api_examples"] = kwargs.pop("api_examples", None) - kwargs["openapi_extra"]["python_examples"] = kwargs.pop( - "python_examples", None - ) + kwargs["openapi_extra"]["examples"] = kwargs.pop("examples", None) kwargs["operation_id"] = kwargs.get( "operation_id", SignatureInspector.get_operation_id(func) ) @@ -478,7 +475,7 @@ def get_description(func: Callable) -> str: if doc: description = doc.split(" Parameters\n ----------")[0] description = description.split(" Returns\n -------")[0] - description = description.split(" Example\n -------")[0] + description = description.split(" Examples\n -------")[0] description = "\n".join([line.strip() for line in description.split("\n")]) return description diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 38b578c09955..be9f4fd1adf7 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -405,8 +405,7 @@ def build(path: str, ext_map: Optional[Dict[str, List[str]]] = None) -> str: if route.openapi_extra else None ), - examples=(route.openapi_extra.get("api_examples", []) or []) - + (route.openapi_extra.get("python_examples", []) or []), + examples=(route.openapi_extra.get("examples", []) or []), ) else: doc += " /" if path else " /" @@ -707,7 +706,7 @@ def build_command_method_doc( func: Callable, formatted_params: OrderedDict[str, Parameter], model_name: Optional[str] = None, - examples: Optional[List[Union[Example, str]]] = None, + examples: Optional[List[Example]] = None, ): """Build the command method docstring.""" doc = func.__doc__ @@ -798,7 +797,7 @@ def build_command_method( path: str, func: Callable, model_name: Optional[str] = None, - examples: Optional[List[Union[Example, str]]] = None, + examples: Optional[List[Example]] = None, ) -> str: """Build the command method.""" func_name = func.__name__ @@ -859,15 +858,16 @@ def get_OBBject_description(results_type: str, providers: Optional[str]) -> str: def append_examples( func_name: str, func_params: dict[str, Field], - examples: Optional[List[Union[Example, str]]], + examples: Optional[List[Example]], ) -> str: """Get the example section from the examples.""" if examples: - doc = "\n Example\n -------\n" + doc = "\n Examples\n --------\n" doc += " >>> from openbb import obb\n" for e in examples: - if isinstance(e, Example): + if e.scope == "api" and e.parameters is not None: + # MOVE THIS TO example.py if e.description: doc += f" >>> # {e.description}\n" doc += f" >>> obb{func_name}(" @@ -888,8 +888,8 @@ def append_examples( doc += f"{k}='{v}', " doc = doc.strip(", ") + ")\n" - else: - doc += f" >>> {e}\n" + elif e.scope == "python" and e.code is not None: + doc += ">>> \n".join(e.code) + "\n" return doc return "" @@ -1015,7 +1015,7 @@ def generate( func: Callable, formatted_params: OrderedDict[str, Parameter], model_name: Optional[str] = None, - examples: Optional[List[Union[Example, str]]] = None, + examples: Optional[List[Example]] = None, ) -> Optional[str]: """Generate the docstring for the function.""" doc = func.__doc__ diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index 2a904f0742fe..3c6bce0c7bb2 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -16,7 +16,7 @@ # pylint: disable=unused-argument @router.command( model="LbmaFixing", - api_examples=[Example(parameters={"asset": "gold"})], + examples=[Example(parameters={"asset": "gold"})], ) async def lbma_fixing( cc: CommandContext, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py index bd2a3dfd4666..f70ef92a2592 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py @@ -18,7 +18,7 @@ # pylint: disable=unused-argument @router.command( model="CryptoSearch", - api_examples=[ + examples=[ Example(parameters={}), Example(parameters={"symbol": "BTCUSD"}), Example(parameters={"symbol": "ETH-USD"}), diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index e0b96c1eb76b..936236d8f64c 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -16,14 +16,14 @@ # pylint: disable=unused-argument,line-too-long @router.command( model="CryptoHistorical", - api_examples=[ + examples=[ Example(parameters={"symbol": "BTCUSD"}), Example( parameters={ "symbol": "BTCUSD", "start_date": "2024-01-01", "end_date": "2024-01-31", - } + }, ), Example( parameters={ @@ -32,8 +32,8 @@ "interval": "1mo", "start_date": "2024-01-01", "end_date": "2024-12-31", - } - ), # noqa: E501 + }, + ), Example( parameters={ "symbol": "BTCUSD,ETH-USD", @@ -41,14 +41,14 @@ "interval": "1d", "start_date": "2024-01-01", "end_date": "2024-01-31", - } - ), # noqa: E501 + }, + ), Example( parameters={ "symbol": "BTCUSD,ETH-USD", "start_date": "2024-01-01", "end_date": "2024-01-31", - } + }, ), ], ) diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index defefa38c3e0..c90b8c1ac9b6 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -18,7 +18,7 @@ # pylint: disable=unused-argument @router.command( model="CurrencyPairs", - api_examples=[ + examples=[ Example(parameters={}), Example( description="Search for 'EURUSD' currency pair using 'polygon' as provider.", @@ -56,7 +56,7 @@ async def search( @router.command( model="CurrencyReferenceRates", - api_examples=[Example(parameters={"symbol": "EURUSD"})], + examples=[Example(parameters={"symbol": "EURUSD"})], ) async def reference_rates( cc: CommandContext, diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index 2a5c5896ef4c..e955375eb1aa 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -16,7 +16,7 @@ # pylint: disable=unused-argument @router.command( model="CurrencyHistorical", - api_examples=[ + examples=[ Example(parameters={"symbol": "EURUSD"}), Example( description="Filter historical data with specific start and end date.", diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index 4039affb1877..49b5473436ef 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -15,7 +15,7 @@ # pylint: disable=unused-argument @router.command( model="FuturesHistorical", - api_examples=[ + examples=[ Example(parameters={"symbol": "ES", "provider": "yfinance"}), Example( description='Enter expiration dates as "YYYY-MM".', @@ -43,7 +43,7 @@ async def historical( @router.command( model="FuturesCurve", - api_examples=[ + examples=[ Example(parameters={"symbol": "NG", "provider": "yfinance"}), Example( description="Enter a date to get the term structure from a historical date.", diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index 97a522807067..31f645fcd8ee 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -16,7 +16,7 @@ @router.command( model="OptionsChains", - api_examples=[ + examples=[ Example(parameters={"symbol": "AAPL", "provider": "intrinio"}), Example( description='Use the "date" parameter to get the end-of-day-data for a specific date, where supported.', @@ -36,7 +36,7 @@ async def chains( @router.command( model="OptionsUnusual", - api_examples=[ + examples=[ Example(parameters={}), Example( description="Use the 'symbol' parameter to get the most recent activity for a specific symbol.", diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 376334b9ddfc..24521919bccc 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -15,7 +15,7 @@ PooledOLS, RandomEffects, ) -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import Example, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import basemodel_to_df, get_target_column, get_target_columns from openbb_core.provider.abstract.data import Data @@ -29,13 +29,7 @@ router = Router(prefix="") -@router.command( - methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - "obb.econometrics.correlation_matrix(data=stock_data)", - ], -) +@router.command(methods=["POST"]) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: """Get the correlation matrix of an input dataset. @@ -53,6 +47,11 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: ------- OBBject[List[Data]]: Correlation matrix. + + Examples + -------- + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "obb.econometrics.correlation_matrix(data=stock_data)", """ df = basemodel_to_df(data) # remove non float columns from the dataframe to perform the correlation @@ -73,9 +72,14 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: @router.command( methods=["POST"], include_in_schema=False, - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.ols_regression(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.ols_regression(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ) ], ) def ols_regression( @@ -113,9 +117,14 @@ def ols_regression( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ) ], ) def ols_regression_summary( @@ -186,9 +195,14 @@ def ols_regression_summary( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ) ], ) def autocorrelation( @@ -228,9 +242,14 @@ def autocorrelation( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ) ], ) def residual_autocorrelation( @@ -283,9 +302,14 @@ def residual_autocorrelation( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.cointegration(data=stock_data, columns=["open", "close"])', + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.cointegration(data=stock_data, columns=["open", "close"])', + ], + ) ], ) def cointegration( @@ -342,9 +366,14 @@ def cointegration( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.causality(data=stock_data, y_column="close", x_column="open")', + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.causality(data=stock_data, y_column="close", x_column="open")', + ], + ) ], ) def causality( @@ -399,10 +428,15 @@ def causality( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.unit_root(data=stock_data, column="close")', - 'obb.econometrics.unit_root(data=stock_data, column="close", regression="ct")', + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.unit_root(data=stock_data, column="close")', + 'obb.econometrics.unit_root(data=stock_data, column="close", regression="ct")', + ], + ) ], ) def unit_root( diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index c24c4c15a953..0a58c3cbf1da 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -19,7 +19,7 @@ @router.command( model="EconomicCalendar", - api_examples=[ + examples=[ Example( parameters={ "provider": "fmp", @@ -45,7 +45,7 @@ async def calendar( @router.command( model="ConsumerPriceIndex", - api_examples=[ + examples=[ Example(parameters={"country": "japan,china,turkey"}), Example( description="Use the `units` parameter to define the reference period for the change in values.", @@ -68,7 +68,7 @@ async def cpi( @router.command( model="RiskPremium", - api_examples=[Example(parameters={})], + examples=[Example(parameters={})], ) async def risk_premium( cc: CommandContext, @@ -82,7 +82,7 @@ async def risk_premium( @router.command( model="BalanceOfPayments", - api_examples=[ + examples=[ Example(parameters={"report_type": "summary"}), Example( description="The `country` parameter will override the `report_type`.", @@ -100,7 +100,7 @@ async def balance_of_payments( return await OBBject.from_query(Query(**locals())) -@router.command(model="FredSearch", api_examples=[Example(parameters={})]) +@router.command(model="FredSearch", examples=[Example(parameters={})]) async def fred_search( cc: CommandContext, provider_choices: ProviderChoices, @@ -117,7 +117,7 @@ async def fred_search( @router.command( model="FredSeries", - api_examples=[ + examples=[ Example(parameters={"series_id": "NFCI"}), Example( description="Multiple series can be passed in as a list.", @@ -141,7 +141,7 @@ async def fred_series( @router.command( model="MoneyMeasures", - api_examples=[Example(parameters={"adjusted": False})], + examples=[Example(parameters={"adjusted": False})], ) async def money_measures( cc: CommandContext, @@ -155,7 +155,7 @@ async def money_measures( @router.command( model="Unemployment", - api_examples=[ + examples=[ Example(parameters={"country": "all", "frequency": "quarterly"}), Example( description="Demographics for the statistics are selected with the `age` and `sex` parameters.", @@ -175,7 +175,7 @@ async def unemployment( @router.command( model="CLI", - api_examples=[Example(parameters={"country": "all"})], + examples=[Example(parameters={"country": "all"})], ) async def composite_leading_indicator( cc: CommandContext, @@ -192,7 +192,7 @@ async def composite_leading_indicator( @router.command( model="STIR", - api_examples=[Example(parameters={"country": "all", "frequency": "quarterly"})], + examples=[Example(parameters={"country": "all", "frequency": "quarterly"})], ) async def short_term_interest_rate( cc: CommandContext, @@ -212,7 +212,7 @@ async def short_term_interest_rate( @router.command( model="LTIR", - api_examples=[Example(parameters={"country": "all", "frequency": "quarterly"})], + examples=[Example(parameters={"country": "all", "frequency": "quarterly"})], ) async def long_term_interest_rate( cc: CommandContext, @@ -235,7 +235,7 @@ async def long_term_interest_rate( @router.command( model="FredRegional", - api_examples=[ + examples=[ Example( description="With no date, the most recent report is returned.", parameters={"series_id": "NYICLAIMS"}, diff --git a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py index 9654a3681fba..6623d09bf15a 100644 --- a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py @@ -16,7 +16,7 @@ @router.command( model="GdpForecast", - api_examples=[Example(parameters={"period": "annual", "type": "real"})], + examples=[Example(parameters={"period": "annual", "type": "real"})], ) async def forecast( cc: CommandContext, @@ -30,7 +30,7 @@ async def forecast( @router.command( model="GdpNominal", - api_examples=[Example(parameters={"units": "usd"})], + examples=[Example(parameters={"units": "usd"})], ) async def nominal( cc: CommandContext, @@ -44,7 +44,7 @@ async def nominal( @router.command( model="GdpReal", - api_examples=[Example(parameters={"units": "yoy"})], + examples=[Example(parameters={"units": "yoy"})], ) async def real( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py index a480f7a629c6..a4c539869892 100644 --- a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py @@ -16,7 +16,7 @@ @router.command( model="CalendarIpo", - api_examples=[ + examples=[ Example(parameters={"limit": 100}), Example(description="Get all IPOs available.", parameters={}), Example( @@ -37,7 +37,7 @@ async def ipo( @router.command( model="CalendarDividend", - api_examples=[ + examples=[ Example(parameters={}), Example( description="Get dividend calendar for specific dates.", @@ -60,7 +60,7 @@ async def dividend( @router.command( model="CalendarSplits", - api_examples=[ + examples=[ Example(parameters={}), Example( description="Get stock splits calendar for specific dates.", @@ -83,7 +83,7 @@ async def splits( @router.command( model="CalendarEarnings", - api_examples=[ + examples=[ Example(parameters={}), Example( description="Get earnings calendar for specific dates.", diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py index d4bb41e95b0c..4686e7218fd0 100644 --- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py @@ -15,7 +15,7 @@ @router.command( model="EquityPeers", - api_examples=[Example(parameters={"symbol": "AAPL"})], + examples=[Example(parameters={"symbol": "AAPL"})], ) async def peers( cc: CommandContext, @@ -32,7 +32,7 @@ async def peers( @router.command( model="CompareGroups", - api_examples=[ + examples=[ Example( description="Group by sector and analyze valuation.", parameters={"group": "sector", "metric": "valuation"}, diff --git a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py index d7ef7dc2deac..3a5e729edea3 100644 --- a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py @@ -16,7 +16,7 @@ @router.command( model="OTCAggregate", - api_examples=[ + examples=[ Example( description="Get OTC data for a symbol", parameters={"symbol": "AAPL"}, diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index 520e264f300a..071be9480e66 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -13,9 +13,7 @@ router = Router(prefix="/discovery") -@router.command( - model="EquityGainers", api_examples=[Example(parameters={"sort": "desc"})] -) +@router.command(model="EquityGainers", examples=[Example(parameters={"sort": "desc"})]) async def gainers( cc: CommandContext, provider_choices: ProviderChoices, @@ -26,9 +24,7 @@ async def gainers( return await OBBject.from_query(Query(**locals())) -@router.command( - model="EquityLosers", api_examples=[Example(parameters={"sort": "desc"})] -) +@router.command(model="EquityLosers", examples=[Example(parameters={"sort": "desc"})]) async def losers( cc: CommandContext, provider_choices: ProviderChoices, @@ -39,9 +35,7 @@ async def losers( return await OBBject.from_query(Query(**locals())) -@router.command( - model="EquityActive", api_examples=[Example(parameters={"sort": "desc"})] -) +@router.command(model="EquityActive", examples=[Example(parameters={"sort": "desc"})]) async def active( cc: CommandContext, provider_choices: ProviderChoices, @@ -54,7 +48,7 @@ async def active( @router.command( model="EquityUndervaluedLargeCaps", - api_examples=[Example(parameters={"sort": "desc"})], + examples=[Example(parameters={"sort": "desc"})], ) async def undervalued_large_caps( cc: CommandContext, @@ -67,7 +61,7 @@ async def undervalued_large_caps( @router.command( - model="EquityUndervaluedGrowth", api_examples=[Example(parameters={"sort": "desc"})] + model="EquityUndervaluedGrowth", examples=[Example(parameters={"sort": "desc"})] ) async def undervalued_growth( cc: CommandContext, @@ -81,7 +75,7 @@ async def undervalued_growth( @router.command( model="EquityAggressiveSmallCaps", - api_examples=[Example(parameters={"sort": "desc"})], + examples=[Example(parameters={"sort": "desc"})], ) async def aggressive_small_caps( cc: CommandContext, @@ -94,7 +88,7 @@ async def aggressive_small_caps( @router.command( - model="GrowthTechEquities", api_examples=[Example(parameters={"sort": "desc"})] + model="GrowthTechEquities", examples=[Example(parameters={"sort": "desc"})] ) async def growth_tech( cc: CommandContext, @@ -106,7 +100,7 @@ async def growth_tech( return await OBBject.from_query(Query(**locals())) -@router.command(model="TopRetail", api_examples=[Example(parameters={"sort": "desc"})]) +@router.command(model="TopRetail", examples=[Example(parameters={"sort": "desc"})]) async def top_retail( cc: CommandContext, provider_choices: ProviderChoices, @@ -121,7 +115,7 @@ async def top_retail( @router.command( - model="UpcomingReleaseDays", api_examples=[Example(parameters={"sort": "desc"})] + model="UpcomingReleaseDays", examples=[Example(parameters={"sort": "desc"})] ) async def upcoming_release_days( cc: CommandContext, @@ -135,7 +129,7 @@ async def upcoming_release_days( @router.command( model="DiscoveryFilings", - api_examples=[ + examples=[ Example(parameters={"limit": 100}), Example( description="Get filings for the year 2023, limited to 100 results", diff --git a/openbb_platform/extensions/equity/openbb_equity/equity_router.py b/openbb_platform/extensions/equity/openbb_equity/equity_router.py index 578b4e02cef4..f146add6024d 100644 --- a/openbb_platform/extensions/equity/openbb_equity/equity_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/equity_router.py @@ -35,7 +35,7 @@ @router.command( model="EquitySearch", - api_examples=[ + examples=[ Example(parameters={"query": "AAPL", "is_symbol": False, "use_cache": True}) ], ) @@ -49,7 +49,7 @@ async def search( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityScreener", api_examples=[Example(parameters={})]) +@router.command(model="EquityScreener", examples=[Example(parameters={})]) async def screener( cc: CommandContext, provider_choices: ProviderChoices, @@ -61,9 +61,7 @@ async def screener( return await OBBject.from_query(Query(**locals())) -@router.command( - model="EquityInfo", api_examples=[Example(parameters={"symbol": "AAPL"})] -) +@router.command(model="EquityInfo", examples=[Example(parameters={"symbol": "AAPL"})]) async def profile( cc: CommandContext, provider_choices: ProviderChoices, @@ -74,7 +72,7 @@ async def profile( return await OBBject.from_query(Query(**locals())) -@router.command(model="MarketSnapshots", api_examples=[Example(parameters={})]) +@router.command(model="MarketSnapshots", examples=[Example(parameters={})]) async def market_snapshots( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index c4da08d41ea7..c61e7330b448 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -16,7 +16,7 @@ @router.command( model="PriceTarget", - api_examples=[ + examples=[ Example( parameters={ "start_date": "2020-01-01", @@ -41,7 +41,7 @@ async def price_target( @router.command( model="AnalystEstimates", - api_examples=[Example(parameters={"symbol": "AAPL", "provider": "fmp"})], + examples=[Example(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def historical( cc: CommandContext, @@ -55,7 +55,7 @@ async def historical( @router.command( model="PriceTargetConsensus", - api_examples=[Example(parameters={"symbol": "AAPL,MSFT", "provider": "yfinance"})], + examples=[Example(parameters={"symbol": "AAPL,MSFT", "provider": "yfinance"})], ) async def consensus( cc: CommandContext, @@ -69,7 +69,7 @@ async def consensus( @router.command( model="AnalystSearch", - api_examples=[Example(parameters={"firm_name": "Wedbush", "provider": "benzinga"})], + examples=[Example(parameters={"firm_name": "Wedbush", "provider": "benzinga"})], ) async def analyst_search( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index 545181682099..9dd4e5cd5f65 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -16,7 +16,7 @@ @router.command( model="EquityValuationMultiples", - api_examples=[Example(parameters={"symbol": "AAPL"})], + examples=[Example(parameters={"symbol": "AAPL"})], ) async def multiples( cc: CommandContext, @@ -30,9 +30,7 @@ async def multiples( @router.command( model="BalanceSheet", - api_examples=[ - Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}) - ], + examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], ) async def balance( cc: CommandContext, @@ -46,7 +44,7 @@ async def balance( @router.command( model="BalanceSheetGrowth", - api_examples=[Example(parameters={"symbol": "AAPL", "limit": 10})], + examples=[Example(parameters={"symbol": "AAPL", "limit": 10})], ) async def balance_growth( cc: CommandContext, @@ -60,9 +58,7 @@ async def balance_growth( @router.command( model="CashFlowStatement", - api_examples=[ - Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}) - ], + examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], ) async def cash( cc: CommandContext, @@ -76,7 +72,7 @@ async def cash( @router.command( model="ReportedFinancials", - api_examples=[ + examples=[ Example( parameters={ "symbol": "AAPL", @@ -107,7 +103,7 @@ async def reported_financials( @router.command( model="CashFlowStatementGrowth", - api_examples=[Example(parameters={"symbol": "AAPL", "limit": 10})], + examples=[Example(parameters={"symbol": "AAPL", "limit": 10})], ) async def cash_growth( cc: CommandContext, @@ -120,7 +116,7 @@ async def cash_growth( @router.command( - model="HistoricalDividends", api_examples=[Example(parameters={"symbol": "AAPL"})] + model="HistoricalDividends", examples=[Example(parameters={"symbol": "AAPL"})] ) async def dividends( cc: CommandContext, @@ -133,7 +129,7 @@ async def dividends( @router.command( - model="HistoricalEps", api_examples=[Example(parameters={"symbol": "AAPL"})] + model="HistoricalEps", examples=[Example(parameters={"symbol": "AAPL"})] ) async def historical_eps( cc: CommandContext, @@ -146,7 +142,7 @@ async def historical_eps( @router.command( - model="HistoricalEmployees", api_examples=[Example(parameters={"symbol": "AAPL"})] + model="HistoricalEmployees", examples=[Example(parameters={"symbol": "AAPL"})] ) async def employee_count( cc: CommandContext, @@ -160,7 +156,7 @@ async def employee_count( @router.command( model="SearchAttributes", - api_examples=[Example(parameters={"query": "ebitda"})], + examples=[Example(parameters={"query": "ebitda"})], ) async def search_attributes( cc: CommandContext, @@ -174,7 +170,7 @@ async def search_attributes( @router.command( model="LatestAttributes", - api_examples=[Example(parameters={"tag": "ceo"})], + examples=[Example(parameters={"tag": "ceo"})], ) async def latest_attributes( cc: CommandContext, @@ -188,7 +184,7 @@ async def latest_attributes( @router.command( model="HistoricalAttributes", - api_examples=[Example(parameters={"tag": "ebitda"})], + examples=[Example(parameters={"tag": "ebitda"})], ) async def historical_attributes( cc: CommandContext, @@ -202,9 +198,7 @@ async def historical_attributes( @router.command( model="IncomeStatement", - api_examples=[ - Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}) - ], + examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], ) async def income( cc: CommandContext, @@ -218,9 +212,7 @@ async def income( @router.command( model="IncomeStatementGrowth", - api_examples=[ - Example(parameters={"symbol": "AAPL", "limit": 10, "period": "annual"}) - ], + examples=[Example(parameters={"symbol": "AAPL", "limit": 10, "period": "annual"})], ) async def income_growth( cc: CommandContext, @@ -234,9 +226,7 @@ async def income_growth( @router.command( model="KeyMetrics", - api_examples=[ - Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 100}) - ], + examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 100})], ) async def metrics( cc: CommandContext, @@ -249,7 +239,7 @@ async def metrics( @router.command( - model="KeyExecutives", api_examples=[Example(parameters={"symbol": "AAPL"})] + model="KeyExecutives", examples=[Example(parameters={"symbol": "AAPL"})] ) async def management( cc: CommandContext, @@ -262,7 +252,7 @@ async def management( @router.command( - model="ExecutiveCompensation", api_examples=[Example(parameters={"symbol": "AAPL"})] + model="ExecutiveCompensation", examples=[Example(parameters={"symbol": "AAPL"})] ) async def management_compensation( cc: CommandContext, @@ -282,7 +272,7 @@ async def management_compensation( since=(4, 1), expected_removal=(4, 3), ), - api_examples=[Example(parameters={"symbol": "AAPL"})], + examples=[Example(parameters={"symbol": "AAPL"})], ) async def overview( cc: CommandContext, @@ -296,9 +286,7 @@ async def overview( @router.command( model="FinancialRatios", - api_examples=[ - Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 12}) - ], + examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 12})], ) async def ratios( cc: CommandContext, @@ -312,7 +300,7 @@ async def ratios( @router.command( model="RevenueGeographic", - api_examples=[ + examples=[ Example(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) ], ) @@ -328,7 +316,7 @@ async def revenue_per_geography( @router.command( model="RevenueBusinessLine", - api_examples=[ + examples=[ Example(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) ], ) @@ -342,9 +330,7 @@ async def revenue_per_segment( return await OBBject.from_query(Query(**locals())) -@router.command( - model="CompanyFilings", api_examples=[Example(parameters={"limit": 100})] -) +@router.command(model="CompanyFilings", examples=[Example(parameters={"limit": 100})]) async def filings( cc: CommandContext, provider_choices: ProviderChoices, @@ -361,7 +347,7 @@ async def filings( @router.command( - model="HistoricalSplits", api_examples=[Example(parameters={"symbol": "AAPL"})] + model="HistoricalSplits", examples=[Example(parameters={"symbol": "AAPL"})] ) async def historical_splits( cc: CommandContext, @@ -375,7 +361,7 @@ async def historical_splits( @router.command( model="EarningsCallTranscript", - api_examples=[Example(parameters={"symbol": "AAPL", "year": 2020})], + examples=[Example(parameters={"symbol": "AAPL", "year": 2020})], ) async def transcript( cc: CommandContext, @@ -389,7 +375,7 @@ async def transcript( @router.command( model="TrailingDividendYield", - api_examples=[Example(parameters={"symbol": "AAPL", "limit": 252})], + examples=[Example(parameters={"symbol": "AAPL", "limit": 252})], ) async def trailing_dividend_yield( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index d9812301fcf9..8a19e90d9325 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -16,7 +16,7 @@ @router.command( model="EquityOwnership", - api_examples=[Example(parameters={"symbol": "AAPL", "page": 0})], + examples=[Example(parameters={"symbol": "AAPL", "page": 0})], ) async def major_holders( cc: CommandContext, @@ -30,7 +30,7 @@ async def major_holders( @router.command( model="InstitutionalOwnership", - api_examples=[Example(parameters={"symbol": "AAPL"})], + examples=[Example(parameters={"symbol": "AAPL"})], ) async def institutional( cc: CommandContext, @@ -44,7 +44,7 @@ async def institutional( @router.command( model="InsiderTrading", - api_examples=[Example(parameters={"symbol": "AAPL", "limit": 500})], + examples=[Example(parameters={"symbol": "AAPL", "limit": 500})], ) async def insider_trading( cc: CommandContext, @@ -57,7 +57,7 @@ async def insider_trading( @router.command( - model="ShareStatistics", api_examples=[Example(parameters={"symbol": "AAPL"})] + model="ShareStatistics", examples=[Example(parameters={"symbol": "AAPL"})] ) async def share_statistics( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index cbbdcfb61d20..379d0cf51546 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -14,9 +14,7 @@ # pylint: disable=unused-argument -@router.command( - model="EquityQuote", api_examples=[Example(parameters={"symbol": "AAPL"})] -) +@router.command(model="EquityQuote", examples=[Example(parameters={"symbol": "AAPL"})]) async def quote( cc: CommandContext, provider_choices: ProviderChoices, @@ -27,9 +25,7 @@ async def quote( return await OBBject.from_query(Query(**locals())) -@router.command( - model="EquityNBBO", api_examples=[Example(parameters={"symbol": "AAPL"})] -) +@router.command(model="EquityNBBO", examples=[Example(parameters={"symbol": "AAPL"})]) async def nbbo( cc: CommandContext, provider_choices: ProviderChoices, @@ -42,7 +38,7 @@ async def nbbo( @router.command( model="EquityHistorical", - api_examples=[Example(parameters={"symbol": "AAPL", "interval": "1d"})], + examples=[Example(parameters={"symbol": "AAPL", "interval": "1d"})], ) async def historical( cc: CommandContext, @@ -55,7 +51,7 @@ async def historical( @router.command( - model="PricePerformance", api_examples=[Example(parameters={"symbol": "AAPL"})] + model="PricePerformance", examples=[Example(parameters={"symbol": "AAPL"})] ) async def performance( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index 6c4aac3ec7f3..fce58c127382 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -16,7 +16,7 @@ @router.command( model="EquityFTD", - api_examples=[Example(parameters={"symbol": "AAPL"})], + examples=[Example(parameters={"symbol": "AAPL"})], ) async def fails_to_deliver( cc: CommandContext, @@ -30,7 +30,7 @@ async def fails_to_deliver( @router.command( model="ShortVolume", - api_examples=[Example(parameters={"symbol": "AAPL"})], + examples=[Example(parameters={"symbol": "AAPL"})], ) async def short_volume( cc: CommandContext, @@ -44,7 +44,7 @@ async def short_volume( @router.command( model="EquityShortInterest", - api_examples=[Example(parameters={"symbol": "AAPL"})], + examples=[Example(parameters={"symbol": "AAPL"})], ) async def short_interest( cc: CommandContext, diff --git a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py index 9a2ecb4cc81f..1b1b66bf51bf 100644 --- a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py @@ -17,7 +17,7 @@ @router.command( model="ETFGainers", operation_id="etf_gainers", - api_examples=[ + examples=[ Example(description="Get the top ETF gainers.", parameters={"provider": "wsj"}), ], ) @@ -34,7 +34,7 @@ async def gainers( @router.command( model="ETFLosers", operation_id="etf_losers", - api_examples=[ + examples=[ Example(description="Get the top ETF losers.", parameters={"provider": "wsj"}) ], ) @@ -51,7 +51,7 @@ async def losers( @router.command( model="ETFActive", operation_id="etf_active", - api_examples=[ + examples=[ Example(description="Get the most active ETFs.", parameters={"provider": "wsj"}) ], ) diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index bc7cf050338d..63e6020bb7c8 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -19,7 +19,7 @@ @router.command( model="EtfSearch", - api_examples=[ + examples=[ Example( description="An empty query returns the full list of ETFs from the provider.", parameters={}, @@ -46,7 +46,7 @@ async def search( @router.command( model="EtfHistorical", operation_id="etf_historical", - api_examples=[ + examples=[ Example(parameters={"symbol": "SPY"}), Example(parameters={"symbol": "SPY", "provider": "yfinance"}), Example( @@ -67,7 +67,7 @@ async def historical( @router.command( model="EtfInfo", - api_examples=[ + examples=[ Example(parameters={"symbol": "SPY", "provider": "fmp"}), Example( description="This function accepts multiple tickers.", @@ -87,7 +87,7 @@ async def info( @router.command( model="EtfSectors", - api_examples=[Example(parameters={"symbol": "SPY", "provider": "fmp"})], + examples=[Example(parameters={"symbol": "SPY", "provider": "fmp"})], ) async def sectors( cc: CommandContext, @@ -101,7 +101,7 @@ async def sectors( @router.command( model="EtfCountries", - api_examples=[Example(parameters={"symbol": "VT", "provider": "fmp"})], + examples=[Example(parameters={"symbol": "VT", "provider": "fmp"})], ) async def countries( cc: CommandContext, @@ -115,9 +115,7 @@ async def countries( @router.command( model="PricePerformance", - api_examples=[ - Example(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"}) - ], + examples=[Example(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"})], ) async def price_performance( cc: CommandContext, @@ -131,7 +129,7 @@ async def price_performance( @router.command( model="EtfHoldings", - api_examples=[ + examples=[ Example(parameters={"symbol": "XLK", "provider": "fmp"}), Example( description="Including a date (FMP, SEC) will return the holdings as per NPORT-P filings.", @@ -155,7 +153,7 @@ async def holdings( @router.command( model="EtfHoldingsDate", - api_examples=[Example(parameters={"symbol": "XLK", "provider": "fmp"})], + examples=[Example(parameters={"symbol": "XLK", "provider": "fmp"})], ) async def holdings_date( cc: CommandContext, @@ -169,7 +167,7 @@ async def holdings_date( @router.command( model="EtfHoldingsPerformance", - api_examples=[Example(parameters={"symbol": "XLK", "provider": "fmp"})], + examples=[Example(parameters={"symbol": "XLK", "provider": "fmp"})], ) async def holdings_performance( cc: CommandContext, @@ -183,7 +181,7 @@ async def holdings_performance( @router.command( model="EtfEquityExposure", - api_examples=[ + examples=[ Example(parameters={"symbol": "MSFT", "provider": "fmp"}), Example( description="This function accepts multiple tickers.", diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index 3be77870a374..99150618a5fe 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -16,7 +16,7 @@ @router.command( model="ICEBofA", - api_examples=[Example(parameters={"index_type": "yield_to_worst"})], + examples=[Example(parameters={"index_type": "yield_to_worst"})], ) async def ice_bofa( cc: CommandContext, @@ -37,7 +37,7 @@ async def ice_bofa( @router.command( model="MoodyCorporateBondIndex", - api_examples=[Example(parameters={"index_type": "baa"})], + examples=[Example(parameters={"index_type": "baa"})], ) async def moody( cc: CommandContext, @@ -57,7 +57,7 @@ async def moody( @router.command( model="HighQualityMarketCorporateBond", - api_examples=[Example(parameters={"yield_curve": "par"})], + examples=[Example(parameters={"yield_curve": "par"})], ) async def hqm( cc: CommandContext, @@ -77,7 +77,7 @@ async def hqm( @router.command( model="SpotRate", - api_examples=[Example(parameters={"maturity": [10, 20, 30, 50]})], + examples=[Example(parameters={"maturity": [10, 20, 30, 50]})], ) async def spot_rates( cc: CommandContext, @@ -97,7 +97,7 @@ async def spot_rates( @router.command( model="CommercialPaper", - api_examples=[Example(parameters={"maturity": "15d"})], + examples=[Example(parameters={"maturity": "15d"})], ) async def commercial_paper( cc: CommandContext, @@ -115,7 +115,7 @@ async def commercial_paper( return await OBBject.from_query(Query(**locals())) -@router.command(model="BondPrices", api_examples=[Example(parameters={})]) +@router.command(model="BondPrices", examples=[Example(parameters={})]) async def bond_prices( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py index e59b45967713..84f424d7f463 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py @@ -25,7 +25,7 @@ @router.command( model="SOFR", - api_examples=[Example(parameters={"period": "overnight"})], + examples=[Example(parameters={"period": "overnight"})], ) async def sofr( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index 16e22cae06a0..369800359bf2 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -16,7 +16,7 @@ @router.command( model="USYieldCurve", - api_examples=[Example(parameters={"inflation_adjusted": True})], + examples=[Example(parameters={"inflation_adjusted": True})], ) async def us_yield_curve( cc: CommandContext, @@ -30,7 +30,7 @@ async def us_yield_curve( @router.command( model="EUYieldCurve", - api_examples=[Example(parameters={"yield_curve_type": "spot_rate"})], + examples=[Example(parameters={"yield_curve_type": "spot_rate"})], ) async def eu_yield_curve( cc: CommandContext, @@ -63,7 +63,7 @@ async def eu_yield_curve( @router.command( model="TreasuryRates", - api_examples=[Example(parameters={"provider": "federal_reserve"})], + examples=[Example(parameters={"provider": "federal_reserve"})], ) async def treasury_rates( cc: CommandContext, @@ -77,7 +77,7 @@ async def treasury_rates( @router.command( model="TreasuryAuctions", - api_examples=[ + examples=[ Example( parameters={ "security_type": "Bill", @@ -99,7 +99,7 @@ async def treasury_auctions( @router.command( model="TreasuryPrices", - api_examples=[Example(parameters={"date": "2019-02-05"})], + examples=[Example(parameters={"date": "2019-02-05"})], ) async def treasury_prices( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index 73d4db76eb52..2e21d8f9442c 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -16,7 +16,7 @@ @router.command( model="AMERIBOR", - api_examples=[Example(parameters={"parameter": "30_day_ma"})], + examples=[Example(parameters={"parameter": "30_day_ma"})], ) async def ameribor( cc: CommandContext, @@ -35,7 +35,7 @@ async def ameribor( @router.command( model="SONIA", - api_examples=[Example(parameters={"parameter": "total_nominal_value"})], + examples=[Example(parameters={"parameter": "total_nominal_value"})], ) async def sonia( cc: CommandContext, @@ -54,7 +54,7 @@ async def sonia( @router.command( model="IORB", - api_examples=[Example(parameters={})], + examples=[Example(parameters={})], ) async def iorb( cc: CommandContext, @@ -73,7 +73,7 @@ async def iorb( @router.command( model="FEDFUNDS", - api_examples=[Example(parameters={"parameter": "daily", "provider": "fred"})], + examples=[Example(parameters={"parameter": "daily", "provider": "fred"})], ) async def effr( cc: CommandContext, @@ -92,7 +92,7 @@ async def effr( @router.command( model="PROJECTIONS", - api_examples=[Example(parameters={"long_run": True})], + examples=[Example(parameters={"long_run": True})], ) async def effr_forecast( cc: CommandContext, @@ -112,7 +112,7 @@ async def effr_forecast( @router.command( model="ESTR", - api_examples=[Example(parameters={"parameter": "number_of_active_banks"})], + examples=[Example(parameters={"parameter": "number_of_active_banks"})], ) async def estr( cc: CommandContext, @@ -132,7 +132,7 @@ async def estr( @router.command( model="EuropeanCentralBankInterestRates", - api_examples=[Example(parameters={"interest_rate_type": "refinancing"})], + examples=[Example(parameters={"interest_rate_type": "refinancing"})], ) async def ecb( cc: CommandContext, @@ -154,7 +154,7 @@ async def ecb( @router.command( model="DiscountWindowPrimaryCreditRate", - api_examples=[ + examples=[ Example(parameters={"start_date": "2023-02-01", "end_date": "2023-05-01"}) ], ) diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py index 8399c66618bb..f99948bcf757 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py @@ -16,7 +16,7 @@ @router.command( model="TreasuryConstantMaturity", - api_examples=[Example(parameters={"maturity": "2y"})], + examples=[Example(parameters={"maturity": "2y"})], ) async def tcm( cc: CommandContext, @@ -36,7 +36,7 @@ async def tcm( @router.command( model="SelectedTreasuryConstantMaturity", - api_examples=[Example(parameters={"maturity": "10y"})], + examples=[Example(parameters={"maturity": "10y"})], ) async def tcm_effr( cc: CommandContext, @@ -56,7 +56,7 @@ async def tcm_effr( @router.command( model="SelectedTreasuryBill", - api_examples=[Example(parameters={"maturity": "6m"})], + examples=[Example(parameters={"maturity": "6m"})], ) async def treasury_effr( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index 2f1c20b50fa2..e212ab1dd735 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -26,7 +26,7 @@ since=(4, 1), expected_removal=(4, 3), ), - api_examples=[Example(parameters={"symbol": "SPX"})], + examples=[Example(parameters={"symbol": "SPX"})], ) async def market( cc: CommandContext, @@ -40,7 +40,7 @@ async def market( @router.command( model="IndexConstituents", - api_examples=[ + examples=[ Example(parameters={"symbol": "dowjones", "provider": "fmp"}), Example( description="Providers other than FMP will use the ticker symbol.", @@ -60,7 +60,7 @@ async def constituents( @router.command( model="IndexSnapshots", - api_examples=[Example(parameters={"region": "us", "provider": "cboe"})], + examples=[Example(parameters={"region": "us", "provider": "cboe"})], ) async def snapshots( cc: CommandContext, @@ -74,7 +74,7 @@ async def snapshots( @router.command( model="AvailableIndices", - api_examples=[Example(parameters={"provider": "yfinance"})], + examples=[Example(parameters={"provider": "yfinance"})], ) async def available( cc: CommandContext, @@ -88,7 +88,7 @@ async def available( @router.command( model="IndexSearch", - api_examples=[Example(parameters={"query": "SPX", "provider": "cboe"})], + examples=[Example(parameters={"query": "SPX", "provider": "cboe"})], ) async def search( cc: CommandContext, @@ -102,7 +102,7 @@ async def search( @router.command( model="SP500Multiples", - api_examples=[ + examples=[ Example(parameters={"series_name": "shiller_pe_year", "provider": "nasdaq"}) ], ) @@ -118,7 +118,7 @@ async def sp500_multiples( @router.command( model="IndexSectors", - api_examples=[Example(parameters={"symbol": "^TX60", "provider": "tmx"})], + examples=[Example(parameters={"symbol": "^TX60", "provider": "tmx"})], ) async def sectors( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index c8c155f8355a..e0cfa1c6915b 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -16,7 +16,7 @@ @router.command( model="IndexHistorical", - api_examples=[ + examples=[ Example(parameters={"symbol": "^GSPC", "provider": "fmp"}), Example( description="Not all providers have the same symbols.", diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index c6f7e645aae6..ee005957031b 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -15,7 +15,7 @@ @router.command( model="WorldNews", - api_examples=[ + examples=[ Example(parameters={"limit": 2500}), Example( description="Get news on the specified dates.", @@ -51,7 +51,7 @@ async def world( @router.command( model="CompanyNews", - api_examples=[ + examples=[ Example(parameters={"limit": 2500}), Example( description="Get news on the specified dates.", diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 87a356deb0a1..c9588c51a363 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -2,7 +2,7 @@ import numpy as np import pandas as pd -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import Example, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -21,10 +21,15 @@ @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.omega_ratio(data=returns, target="close")', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.omega_ratio(data=returns, target="close")', + ], + ) ], ) def omega_ratio( @@ -80,10 +85,15 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.sharpe_ratio(data=returns, target="close")', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.sharpe_ratio(data=returns, target="close")', + ], + ) ], ) def sharpe_ratio( @@ -134,11 +144,16 @@ def sharpe_ratio( @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.sortino_ratio(data=stock_data, target="close")', - 'obb.quantitative.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.sortino_ratio(data=stock_data, target="close")', + 'obb.quantitative.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', + ], + ) ], ) def sortino_ratio( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 83c3f5a5bb6f..9cc7a6f26909 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -3,7 +3,7 @@ from typing import List, Literal import pandas as pd -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import Example, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -37,9 +37,14 @@ @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - "obb.quantitative.normality(data=stock_data, target='close')", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "obb.quantitative.normality(data=stock_data, target='close')", + ], + ) ], ) def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: @@ -87,9 +92,14 @@ def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - "obb.quantitative.capm(data=stock_data, target='close')", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "obb.quantitative.capm(data=stock_data, target='close')", + ], + ) ], ) def capm(data: List[Data], target: str) -> OBBject[CAPMModel]: diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 35103c2038c6..e7e03a88f630 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import Example, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -26,10 +26,15 @@ @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.rolling.skew(data=returns, target="close")', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.rolling.skew(data=returns, target="close")', + ], + ) ], ) def skew( @@ -75,10 +80,15 @@ def skew( @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.rolling.variance(data=returns, target="close", window=252)', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.rolling.variance(data=returns, target="close", window=252)', + ], + ) ], ) def variance( @@ -117,10 +127,15 @@ def variance( @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.rolling.stdev(data=returns, target="close", window=252)', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.rolling.stdev(data=returns, target="close", window=252)', + ], + ) ], ) def stdev( @@ -163,10 +178,15 @@ def stdev( @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.rolling.kurtosis(data=returns, target="close", window=252)', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.rolling.kurtosis(data=returns, target="close", window=252)', + ], + ) ], ) def kurtosis( @@ -211,11 +231,16 @@ def kurtosis( @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.25)', - 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.75)', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.25)', + 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.75)', + ], + ) ], ) def quantile( @@ -276,10 +301,15 @@ def quantile( @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.rolling.mean(data=returns, target="close", window=252)', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.rolling.mean(data=returns, target="close", window=252)', + ], + ) ], ) def mean( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index 5f13f502c62a..c99d73007d7d 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import Example, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -25,10 +25,15 @@ @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.stats.skew(data=returns, target="close")', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.stats.skew(data=returns, target="close")', + ], + ) ], ) def skew( @@ -66,10 +71,15 @@ def skew( @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.stats.variance(data=returns, target="close")', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.stats.variance(data=returns, target="close")', + ], + ) ], ) def variance(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -101,10 +111,15 @@ def variance(data: List[Data], target: str) -> OBBject[List[Data]]: @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.stats.stdev(data=returns, target="close")', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.stats.stdev(data=returns, target="close")', + ], + ) ], ) def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -138,10 +153,15 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.stats.kurtosis(data=returns, target="close")', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.stats.kurtosis(data=returns, target="close")', + ], + ) ], ) def kurtosis(data: List[Data], target) -> OBBject[List[Data]]: @@ -175,10 +195,15 @@ def kurtosis(data: List[Data], target) -> OBBject[List[Data]]: @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.stats.quantile(data=returns, target="close", quantile_pct=0.75)', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.stats.quantile(data=returns, target="close", quantile_pct=0.75)', + ], + ) ], ) def quantile( @@ -220,10 +245,15 @@ def quantile( @router.command( methods=["POST"], - api_examples=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', - 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.stats.mean(data=returns, target="close")', + examples=[ + Example( + scope="python", + code=[ + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'returns = stock_data["close"].pct_change().dropna()', + 'obb.quantitative.stats.mean(data=returns, target="close")', + ], + ) ], ) def mean( diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 69240646147f..26531d4df4d3 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -15,7 +15,7 @@ @router.command( model="COTSearch", - api_examples=[Example(parameters={"query": "gold"})], + examples=[Example(parameters={"query": "gold"})], ) async def cot_search( cc: CommandContext, @@ -32,7 +32,7 @@ async def cot_search( @router.command( model="COT", - api_examples=[ + examples=[ Example( description="Get the Commitment of Traders Report for Gold.", parameters={"series_id": "GC=F"}, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 0a321f717b19..598e42f4ec75 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -15,7 +15,7 @@ @router.command( model="CikMap", - api_examples=[Example(parameters={"symbol": "MSFT"})], + examples=[Example(parameters={"symbol": "MSFT"})], ) async def cik_map( cc: CommandContext, @@ -29,7 +29,7 @@ async def cik_map( @router.command( model="InstitutionsSearch", - api_examples=[Example(parameters={"query": "blackstone real estate"})], + examples=[Example(parameters={"query": "blackstone real estate"})], ) async def institutions_search( cc: CommandContext, @@ -43,25 +43,30 @@ async def institutions_search( @router.command( model="SchemaFiles", - api_examples=[Example(parameters={})], - python_examples=[ - "data = obb.regulators.sec.schema_files()", - "data.files[0]", - " https://xbrl.fasb.org/us-gaap/", - "#### The directory structure can be navigated by constructing a URL from the 'results' list. ####", - "url = data.files[0]+data.files[-1]", - "#### The URL base will always be the 0 position in the list, feed the URL back in as a parameter. ####", - "obb.regulators.sec.schema_files(url=url).results.files", - " ['https://xbrl.fasb.org/us-gaap/2024/'", - " 'USGAAP2024FileList.xml'", - " 'dis/'", - " 'dqcrules/'", - " 'ebp/'", - " 'elts/'", - " 'entire/'", - " 'meta/'", - " 'stm/'", - " 'us-gaap-2024.zip']", + examples=[ + Example(parameters={}), + # Example( + # scope="python", + # code=[ + # "data = obb.regulators.sec.schema_files()", + # "data.files[0]", + # " https://xbrl.fasb.org/us-gaap/", + # "#### The directory structure can be navigated by constructing a URL from the 'results' list. ####", + # "url = data.files[0]+data.files[-1]", + # "#### The URL base will always be the 0 position in the list, feed the URL back in as a parameter. ####", + # "obb.regulators.sec.schema_files(url=url).results.files", + # " ['https://xbrl.fasb.org/us-gaap/2024/'", + # " 'USGAAP2024FileList.xml'", + # " 'dis/'", + # " 'dqcrules/'", + # " 'ebp/'", + # " 'elts/'", + # " 'entire/'", + # " 'meta/'", + # " 'stm/'", + # " 'us-gaap-2024.zip']", + # ], + # ), ], ) async def schema_files( @@ -76,7 +81,7 @@ async def schema_files( @router.command( model="SymbolMap", - api_examples=[Example(parameters={"cik": "0000789019"})], + examples=[Example(parameters={"cik": "0000789019"})], ) async def symbol_map( cc: CommandContext, @@ -90,7 +95,7 @@ async def symbol_map( @router.command( model="RssLitigation", - api_examples=[Example(parameters={})], + examples=[Example(parameters={})], ) async def rss_litigation( cc: CommandContext, @@ -104,7 +109,7 @@ async def rss_litigation( @router.command( model="SicSearch", - api_examples=[Example(parameters={"query": "real estate investment trusts"})], + examples=[Example(parameters={"query": "real estate investment trusts"})], ) async def sic_search( cc: CommandContext, diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 5192170435a3..fe5490d991df 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -5,7 +5,7 @@ import pandas as pd import pandas_ta as ta -from openbb_core.app.model.obbject import OBBject +from openbb_core.app.model import Example, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -24,9 +24,14 @@ @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "atr_data = obb.technical.atr(data=stock_data.results)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "atr_data = obb.technical.atr(data=stock_data.results)", + ], + ) ], ) def atr( @@ -81,9 +86,14 @@ def atr( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "fib_data = obb.technical.fib(data=stock_data.results, period=120)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "fib_data = obb.technical.fib(data=stock_data.results, period=120)", + ], + ) ], ) def fib( @@ -146,9 +156,14 @@ def fib( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "obv_data = obb.technical.obv(data=stock_data.results, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "obv_data = obb.technical.obv(data=stock_data.results, offset=0)", + ], + ) ], ) def obv( @@ -193,9 +208,14 @@ def obv( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "fisher_data = obb.technical.fisher(data=stock_data.results, length=14, signal=1)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "fisher_data = obb.technical.fisher(data=stock_data.results, length=14, signal=1)", + ], + ) ], ) def fisher( @@ -240,9 +260,14 @@ def fisher( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "adosc_data = obb.technical.adosc(data=stock_data.results, fast=3, slow=10, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "adosc_data = obb.technical.adosc(data=stock_data.results, fast=3, slow=10, offset=0)", + ], + ) ], ) def adosc( @@ -290,9 +315,14 @@ def adosc( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", + ], + ) ], ) def bbands( @@ -362,9 +392,14 @@ def bbands( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "zlma_data = obb.technical.zlma(data=stock_data.results, target='close', length=50, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "zlma_data = obb.technical.zlma(data=stock_data.results, target='close', length=50, offset=0)", + ], + ) ], ) def zlma( @@ -420,9 +455,14 @@ def zlma( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "aaron_data = obb.technical.aroon(data=stock_data.results, length=25, scalar=100)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "aaron_data = obb.technical.aroon(data=stock_data.results, length=25, scalar=100)", + ], + ) ], ) def aroon( @@ -473,9 +513,14 @@ def aroon( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "sma_data = obb.technical.sma(data=stock_data.results, target='close', length=50, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "sma_data = obb.technical.sma(data=stock_data.results, target='close', length=50, offset=0)", + ], + ) ], ) def sma( @@ -532,9 +577,14 @@ def sma( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "demark_data = obb.technical.demark(data=stock_data.results, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "demark_data = obb.technical.demark(data=stock_data.results, offset=0)", + ], + ) ], ) def demark( @@ -586,9 +636,14 @@ def demark( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "vwap_data = obb.technical.vwap(data=stock_data.results, anchor='D', offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "vwap_data = obb.technical.vwap(data=stock_data.results, anchor='D', offset=0)", + ], + ) ], ) def vwap( @@ -634,9 +689,14 @@ def vwap( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "macd_data = obb.technical.macd(data=stock_data.results, target='close', fast=12, slow=26, signal=9)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "macd_data = obb.technical.macd(data=stock_data.results, target='close', fast=12, slow=26, signal=9)", + ], + ) ], ) def macd( @@ -697,9 +757,14 @@ def macd( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "hma_data = obb.technical.hma(data=stock_data.results, target='close', length=50, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "hma_data = obb.technical.hma(data=stock_data.results, target='close', length=50, offset=0)", + ], + ) ], ) def hma( @@ -753,9 +818,14 @@ def hma( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", + ], + ) ], ) def donchian( @@ -807,9 +877,14 @@ def donchian( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "ichimoku_data = obb.technical.ichimoku(data=stock_data.results, conversion=9, base=26, lookahead=False)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "ichimoku_data = obb.technical.ichimoku(data=stock_data.results, conversion=9, base=26, lookahead=False)", + ], + ) ], ) def ichimoku( @@ -871,9 +946,14 @@ def ichimoku( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "clenow_data = obb.technical.clenow(data=stock_data.results, period=90)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "clenow_data = obb.technical.clenow(data=stock_data.results, period=90)", + ], + ) ], ) def clenow( @@ -926,9 +1006,14 @@ def clenow( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", + ], + ) ], ) def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[Data]]: @@ -972,9 +1057,14 @@ def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[D @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "adx_data = obb.technical.adx(data=stock_data.results, length=50, scalar=100.0, drift=1)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "adx_data = obb.technical.adx(data=stock_data.results, length=50, scalar=100.0, drift=1)", + ], + ) ], ) def adx( @@ -1022,9 +1112,14 @@ def adx( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "wma_data = obb.technical.wma(data=stock_data.results, target='close', length=50, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "wma_data = obb.technical.wma(data=stock_data.results, target='close', length=50, offset=0)", + ], + ) ], ) def wma( @@ -1078,9 +1173,14 @@ def wma( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "cci_data = obb.technical.cci(data=stock_data.results, length=14, scalar=0.015)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "cci_data = obb.technical.cci(data=stock_data.results, length=14, scalar=0.015)", + ], + ) ], ) def cci( @@ -1125,9 +1225,14 @@ def cci( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "rsi_data = obb.technical.rsi(data=stock_data.results, target='close', length=14, scalar=100.0, drift=1)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "rsi_data = obb.technical.rsi(data=stock_data.results, target='close', length=14, scalar=100.0, drift=1)", + ], + ) ], ) def rsi( @@ -1186,9 +1291,14 @@ def rsi( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", + ], + ) ], ) def stoch( @@ -1243,9 +1353,14 @@ def stoch( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "kc_data = obb.technical.kc(data=stock_data.results, length=20, scalar=20, mamode='ema', offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "kc_data = obb.technical.kc(data=stock_data.results, length=20, scalar=20, mamode='ema', offset=0)", + ], + ) ], ) def kc( @@ -1302,9 +1417,14 @@ def kc( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "cg_data = obb.technical.cg(data=stock_data.results, length=14)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "cg_data = obb.technical.cg(data=stock_data.results, length=14)", + ], + ) ], ) def cg( @@ -1344,9 +1464,14 @@ def cg( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "cones_data = obb.technical.cones(data=stock_data.results, lower_q=0.25, upper_q=0.75, model='STD')", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "cones_data = obb.technical.cones(data=stock_data.results, lower_q=0.25, upper_q=0.75, model='STD')", + ], + ) ], ) def cones( @@ -1443,9 +1568,14 @@ def cones( @router.command( methods=["POST"], - python_examples=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "ema_data = obb.technical.ema(data=stock_data.results, target='close', length=50, offset=0)", + examples=[ + Example( + scope="python", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", + "ema_data = obb.technical.ema(data=stock_data.results, target='close', length=50, offset=0)", + ], + ) ], ) def ema( diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index 2fed19c18e82..b0b9dd3e8d86 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -63,8 +63,8 @@ def cik_map( cik : Optional[Union[int, str]] Central Index Key (CIK) for the requested entity. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.regulators.sec.cik_map(symbol='MSFT') """ # noqa: E501 @@ -134,8 +134,8 @@ def institutions_search( cik : Optional[Union[int, str]] Central Index Key (CIK) (provider: sec) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.regulators.sec.institutions_search(query='blackstone real estate') """ # noqa: E501 @@ -199,8 +199,8 @@ def rss_litigation( link : Optional[str] URL to the release. (provider: sec) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.regulators.sec.rss_litigation() """ # noqa: E501 @@ -268,27 +268,10 @@ def schema_files( files : Optional[List[str]] Dictionary of URLs to SEC Schema Files (provider: sec) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.regulators.sec.schema_files() - >>> data = obb.regulators.sec.schema_files() - >>> data.files[0] - >>> https://xbrl.fasb.org/us-gaap/ - >>> #### The directory structure can be navigated by constructing a URL from the 'results' list. #### - >>> url = data.files[0]+data.files[-1] - >>> #### The URL base will always be the 0 position in the list, feed the URL back in as a parameter. #### - >>> obb.regulators.sec.schema_files(url=url).results.files - >>> ['https://xbrl.fasb.org/us-gaap/2024/' - >>> 'USGAAP2024FileList.xml' - >>> 'dis/' - >>> 'dqcrules/' - >>> 'ebp/' - >>> 'elts/' - >>> 'entire/' - >>> 'meta/' - >>> 'stm/' - >>> 'us-gaap-2024.zip'] """ # noqa: E501 return self._run( @@ -359,8 +342,8 @@ def sic_search( office : Optional[str] Reporting office within the Corporate Finance Office (provider: sec) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.regulators.sec.sic_search(query='real estate investment trusts') """ # noqa: E501 @@ -429,8 +412,8 @@ def symbol_map( symbol : Optional[str] Symbol representing the entity requested in the data. (provider: sec) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.regulators.sec.symbol_map(cik='0000789019') """ # noqa: E501 From 3f855280cd37a1985a2a8c1e21b5790a4d652e04 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 18:58:58 +0000 Subject: [PATCH 011/133] fix package identation --- .../core/openbb_core/app/model/example.py | 28 + .../openbb_core/app/static/package_builder.py | 222 ++------ openbb_platform/openbb/package/crypto.py | 8 +- .../openbb/package/crypto_price.py | 29 +- openbb_platform/openbb/package/currency.py | 27 +- .../openbb/package/currency_price.py | 41 +- openbb_platform/openbb/package/derivatives.py | 8 +- .../openbb/package/derivatives_options.py | 19 +- openbb_platform/openbb/package/economy.py | 436 ++++++---------- openbb_platform/openbb/package/economy_gdp.py | 82 +-- openbb_platform/openbb/package/equity.py | 81 ++- .../openbb/package/equity_calendar.py | 151 ++---- .../openbb/package/equity_compare.py | 12 +- .../openbb/package/equity_discovery.py | 115 ++--- .../openbb/package/equity_estimates.py | 63 +-- .../openbb/package/equity_fundamental.py | 478 +++++------------- .../openbb/package/equity_ownership.py | 50 +- .../openbb/package/equity_price.py | 149 ++---- .../openbb/package/equity_shorts.py | 18 +- openbb_platform/openbb/package/etf.py | 119 ++--- openbb_platform/openbb/package/fixedincome.py | 38 +- .../openbb/package/fixedincome_corporate.py | 161 ++---- .../openbb/package/fixedincome_government.py | 34 +- .../openbb/package/fixedincome_rate.py | 200 +++----- .../openbb/package/fixedincome_spreads.py | 95 +--- openbb_platform/openbb/package/index.py | 54 +- openbb_platform/openbb/package/news.py | 89 +--- .../openbb/package/regulators_sec.py | 39 +- 28 files changed, 885 insertions(+), 1961 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 2166b61c291c..b31735121738 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,6 +1,7 @@ from typing import Any, Dict, List, Literal, Optional from pydantic import BaseModel, ConfigDict +from dataclasses import Field class Example(BaseModel): @@ -12,3 +13,30 @@ class Example(BaseModel): code: Optional[List[str]] = None model_config = ConfigDict(validate_assignment=True) + + def to_python(self, func_name: str, func_params: Dict[str, Field], indentation: str = "") -> str: + """Return a Python code representation of the examplself.""" + eg = "" + if self.scope == "api" and self.parameters is not None: + if self.description: + eg += f"{indentation}>>> # {self.description}\n" + eg += f"{indentation}>>> obb{func_name}(" + + for k, v in self.parameters.items(): + if k in func_params and (field := func_params.get(k)): + field_type_str = str(field.type) + # TODO: Handle types better, some edge cases + # like Union[str, List[str]] will be stringified + # even if the type is a list + if any(t in field_type_str for t in ["int", "float", "bool"]): + eg += f"{k}={v}, " + else: + eg += f"{k}='{v}', " + else: + eg += f"{k}='{v}', " + + eg = indentation + eg.strip(", ") + ")\n" + elif self.scope == "python" and self.code is not None: + eg += f"{indentation}>>> \n".join(self.code) + "\n" + + return eg diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index be9f4fd1adf7..fa21826a91cb 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -199,7 +199,7 @@ def _run_linters(self): self.console.log("\nRunning linters...") linters = Linters(self.directory / "package", self.verbose) linters.ruff() - linters.black() + # linters.black() def _write( self, code: str, name: str, extension: str = "py", folder: str = "package" @@ -710,14 +710,19 @@ def build_command_method_doc( ): """Build the command method docstring.""" doc = func.__doc__ + indent = 2 + tab = " " + indentation = tab * indent doc = DocstringGenerator.generate( path=path, func=func, formatted_params=formatted_params, model_name=model_name, examples=examples, + indentation=indentation, + tab=tab, ) - code = f' """{doc} """ # noqa: E501\n\n' if doc else "" + code = f'{indentation}"""{doc}{indentation}""" # noqa: E501\n\n' if doc else "" return code @@ -755,9 +760,9 @@ def build_command_method_body(path: str, func: Callable): available = field.type.__args__ code += " provider_choices={\n" code += ' "provider": self._get_provider(\n' - code += " provider,\n" - code += f' "{path}",\n' - code += f" {available},\n" + code += " provider,\n" + code += f' "{path}",\n' + code += f" {available},\n" code += " )\n" code += " },\n" elif MethodDefinition.is_annotated_dc(param.annotation): @@ -833,22 +838,24 @@ class DocstringGenerator: provider_interface = ProviderInterface() @staticmethod - def get_OBBject_description(results_type: str, providers: Optional[str]) -> str: + def get_OBBject_description( + results_type: str, providers: Optional[str], indentation: str = "", tab: str = " " + ) -> str: """Get the command output description.""" available_providers = providers or "Optional[str]" obbject_description = ( - " OBBject\n" - f" results : {results_type}\n" - " Serializable results.\n" - f" provider : {available_providers}\n" - " Provider name.\n" - " warnings : Optional[List[Warning_]]\n" - " List of warnings.\n" - " chart : Optional[Chart]\n" - " Chart object.\n" - " extra : Dict[str, Any]\n" - " Extra info.\n" + f"{indentation}OBBject\n" + f"{indentation+tab}results : {results_type}\n" + f"{indentation+2*tab}Serializable results.\n" + f"{indentation+tab}provider : {available_providers}\n" + f"{indentation+2*tab}Provider name.\n" + f"{indentation+tab}warnings : Optional[List[Warning_]]\n" + f"{indentation+2*tab}List of warnings.\n" + f"{indentation+tab}chart : Optional[Chart]\n" + f"{indentation+2*tab}Chart object.\n" + f"{indentation+tab}extra : Dict[str, Any]\n" + f"{indentation+2*tab}Extra info.\n" ) obbject_description = obbject_description.replace("NoneType", "None") @@ -857,39 +864,18 @@ def get_OBBject_description(results_type: str, providers: Optional[str]) -> str: @staticmethod def append_examples( func_name: str, - func_params: dict[str, Field], + func_params: Dict[str, Field], examples: Optional[List[Example]], + indentation: str = "", ) -> str: """Get the example section from the examples.""" if examples: - doc = "\n Examples\n --------\n" - doc += " >>> from openbb import obb\n" + doc = f"\n{indentation}Examples\n" + doc += f"{indentation}--------\n" + doc += f"{indentation}>>> from openbb import obb\n" for e in examples: - if e.scope == "api" and e.parameters is not None: - # MOVE THIS TO example.py - if e.description: - doc += f" >>> # {e.description}\n" - doc += f" >>> obb{func_name}(" - - for k, v in e.parameters.items(): - if k in func_params and (field := func_params.get(k)): - field_type_str = str(field.type) - # TODO: Handle types better, some edge cases - # like Union[str, List[str]] will be stringified - # even if the type is a list - if any( - t in field_type_str for t in ["int", "float", "bool"] - ): - doc += f"{k}={v}, " - else: - doc += f"{k}='{v}', " - else: - doc += f"{k}='{v}', " - - doc = doc.strip(", ") + ")\n" - elif e.scope == "python" and e.code is not None: - doc += ">>> \n".join(e.code) + "\n" + doc += e.to_python(func_name, func_params, indentation) return doc return "" @@ -902,6 +888,8 @@ def generate_model_docstring( kwarg_params: dict, returns: Dict[str, FieldInfo], results_type: str, + indentation: str = "", + tab: str = " ", ) -> str: """Create the docstring for model.""" @@ -917,13 +905,13 @@ def format_type(type_: str, char_limit: Optional[int] = None) -> str: def format_description(description: str) -> str: """Format description in docstrings.""" - description = description.replace("\n", "\n ") + description = description.replace("\n", f"\n{indentation+tab}") return description docstring = summary.strip("\n") docstring += "\n\n" - docstring += " Parameters\n" - docstring += " ----------\n" + docstring += f"{indentation}Parameters\n" + docstring += f"{indentation}----------\n" # Explicit parameters for param_name, param in explicit_params.items(): @@ -932,8 +920,8 @@ def format_description(description: str) -> str: type_ = param._annotation default = param._annotation.__args__[0].__args__[0] description = f"""The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or '{default}' if there is - no default.""" +If None, the provider specified in defaults is selected or '{default}' if there is +no default.""" elif param_name == "chart": type_ = "bool" description = "Whether to create a chart or not, by default False." @@ -946,8 +934,8 @@ def format_description(description: str) -> str: ) type_str = format_type(type_, char_limit=79) # type: ignore - docstring += f" {param_name} : {type_str}\n" - docstring += f" {format_description(description)}\n" + docstring += f"{indentation}{param_name} : {type_str}\n" + docstring += f"{indentation+tab}{format_description(description)}\n" # Kwargs for param_name, param in kwarg_params.items(): @@ -959,21 +947,24 @@ def format_description(description: str) -> str: description = getattr(param.default, "description", "") - docstring += f" {param_name} : {type_}\n" - docstring += f" {format_description(description)}\n" + docstring += f"{indentation}{param_name} : {type_}\n" + docstring += f"{indentation+tab}{format_description(description)}\n" # Returns docstring += "\n" - docstring += " Returns\n" - docstring += " -------\n" + docstring += f"{indentation}Returns\n" + docstring += f"{indentation}-------\n" provider_param = explicit_params.get("provider", None) available_providers = getattr(provider_param, "_annotation", None) - docstring += cls.get_OBBject_description(results_type, available_providers) + docstring += cls.get_OBBject_description( + results_type, available_providers, indentation, tab + ) # Schema underline = "-" * len(model_name) - docstring += f"\n {model_name}\n {underline}\n" + docstring += f"\n{indentation}{model_name}\n" + docstring += f"{indentation}{underline}\n" for name, field in returns.items(): try: @@ -1004,8 +995,8 @@ def format_description(description: str) -> str: description = getattr(field, "description", "") - docstring += f" {field.alias or name} : {field_type}\n" - docstring += f" {format_description(description)}\n" + docstring += f"{indentation}{field.alias or name} : {field_type}\n" + docstring += f"{indentation+tab}{format_description(description)}\n" return docstring @classmethod @@ -1016,6 +1007,8 @@ def generate( formatted_params: OrderedDict[str, Parameter], model_name: Optional[str] = None, examples: Optional[List[Example]] = None, + indentation: str = "", + tab: str = " ", ) -> Optional[str]: """Generate the docstring for the function.""" doc = func.__doc__ @@ -1043,6 +1036,8 @@ def generate( kwarg_params=kwarg_params, returns=returns, results_type=results_type, + indentation=indentation, + tab=tab, ) if doc and examples: @@ -1050,118 +1045,11 @@ def generate( path.replace("/", "."), func_params, examples, + indentation, ) return doc - @staticmethod - def get_model_standard_params(param_fields: Dict[str, FieldInfo]) -> Dict[str, Any]: - """Get the test params for the fetcher based on the required standard params.""" - test_params: Dict[str, Any] = {} - for field_name, field in param_fields.items(): - if field.default and field.default is not PydanticUndefined: - test_params[field_name] = field.default - elif field.default and field.default is PydanticUndefined: - example_dict = { - "symbol": "AAPL", - "symbols": "AAPL,MSFT", - "start_date": "2023-01-01", - "end_date": "2023-06-06", - "country": "Portugal", - "date": "2023-01-01", - "countries": ["portugal", "spain"], - } - if field_name in example_dict: - test_params[field_name] = example_dict[field_name] - elif field.annotation == str: - test_params[field_name] = "TEST_STRING" - elif field.annotation == int: - test_params[field_name] = 1 - elif field.annotation == float: - test_params[field_name] = 1.0 - elif field.annotation == bool: - test_params[field_name] = True - elif get_origin(field.annotation) is Literal: # type: ignore - option = field.annotation.__args__[0] # type: ignore - if isinstance(option, str): - test_params[field_name] = f'"{option}"' - else: - test_params[field_name] = option - - return test_params - - @staticmethod - def get_full_command_name(route: str) -> str: - """Get the full command name.""" - cmd_parts = route.split("/") - del cmd_parts[0] - - menu = cmd_parts[0] - command = cmd_parts[-1] - sub_menus = cmd_parts[1:-1] - - sub_menu_str_cmd = f".{'.'.join(sub_menus)}" if sub_menus else "" - - full_command = f"{menu}{sub_menu_str_cmd}.{command}" - - return full_command - - @classmethod - def generate_example( - cls, - model_name: str, - standard_params: Dict[str, FieldInfo], - ) -> str: - """Generate the example for the command.""" - # find the model router here - cm = CommandMap() - commands_model = cm.commands_model - route = [k for k, v in commands_model.items() if v == model_name] - - if not route: - return "" - - full_command_name = cls.get_full_command_name(route=route[0]) - example_params = cls.get_model_standard_params(param_fields=standard_params) - - # Edge cases (might find more) - if "crypto" in route[0] and "symbol" in example_params: - example_params["symbol"] = "BTCUSD" - elif "currency" in route[0] and "symbol" in example_params: - example_params["symbol"] = "EURUSD" - elif ( - "index" in route[0] - and "european" not in route[0] - and "symbol" in example_params - ): - example_params["symbol"] = "SPX" - elif ( - "index" in route[0] - and "european" in route[0] - and "symbol" in example_params - ): - example_params["symbol"] = "BUKBUS" - elif ( - "futures" in route[0] and "curve" in route[0] and "symbol" in example_params - ): - example_params["symbol"] = "VX" - elif "futures" in route[0] and "symbol" in example_params: - example_params["symbol"] = "ES" - - example = "\n Example\n -------\n" - example += " >>> from openbb import obb\n" - example += f" >>> obb.{full_command_name}(" - for param_name, param_value in example_params.items(): - if isinstance(param_value, str): - param_value = f'"{param_value}"' # noqa: PLW2901 - example += f"{param_name}={param_value}, " - if example_params: - example = example[:-2] + ")\n" - else: - example += ")\n" - - return example - class PathHandler: """Handle the paths for the Platform.""" diff --git a/openbb_platform/openbb/package/crypto.py b/openbb_platform/openbb/package/crypto.py index 7bdbf3f8716c..96621a5cc8ea 100644 --- a/openbb_platform/openbb/package/crypto.py +++ b/openbb_platform/openbb/package/crypto.py @@ -30,9 +30,7 @@ def price(self): @validate def search( self, - query: Annotated[ - Optional[str], OpenBBCustomParameter(description="Search query.") - ] = None, + query: Annotated[Optional[str], OpenBBCustomParameter(description="Search query.")] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -74,8 +72,8 @@ def search( exchange_name : Optional[str] The short name of the exchange the crypto trades on. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.crypto.search() >>> obb.crypto.search(symbol='BTCUSD') diff --git a/openbb_platform/openbb/package/crypto_price.py b/openbb_platform/openbb/package/crypto_price.py index 655dd265c38c..0da31fa13255 100644 --- a/openbb_platform/openbb/package/crypto_price.py +++ b/openbb_platform/openbb/package/crypto_price.py @@ -23,24 +23,9 @@ def __repr__(self) -> str: @validate def historical( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): fmp, polygon, yfinance." - ), - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): fmp, polygon, yfinance.")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp", "polygon", "tiingo", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -118,8 +103,8 @@ def historical( volume_notional : Optional[float] The last size done for the asset on the specific date in the quote currency. The volume of the asset on the specific date in the quote currency. (provider: tiingo) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.crypto.price.historical(symbol='BTCUSD') >>> obb.crypto.price.historical(symbol='BTCUSD', start_date='2024-01-01', end_date='2024-01-31') @@ -144,8 +129,6 @@ def historical( "end_date": end_date, }, extra_params=kwargs, - extra_info={ - "symbol": {"multiple_items_allowed": ["fmp", "polygon", "yfinance"]} - }, + extra_info={"symbol": {"multiple_items_allowed": ["fmp", "polygon", "yfinance"]}}, ) ) diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index c93faa2ebbbf..a8120fcd3131 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -27,17 +27,19 @@ def price(self): @exception_handler @validate def search( - self, provider: Optional[Literal["fmp", "intrinio", "polygon"]] = None, **kwargs + self, + provider: Optional[Literal["fmp", "intrinio", "polygon"]] = None, + **kwargs ) -> OBBject: - """Currency Search. + """ Currency Search. - Search available currency pairs. - Currency pairs are the national currencies from two countries coupled for trading on - the foreign exchange (FX) marketplace. - Both currencies will have exchange rates on which the trade will have its position basis. - All trading within the forex market, whether selling, buying, or trading, will take place through currency pairs. - (ref: Investopedia) - Major currency pairs include pairs such as EUR/USD, USD/JPY, GBP/USD, etc. + Search available currency pairs. + Currency pairs are the national currencies from two countries coupled for trading on + the foreign exchange (FX) marketplace. + Both currencies will have exchange rates on which the trade will have its position basis. + All trading within the forex market, whether selling, buying, or trading, will take place through currency pairs. + (ref: Investopedia) + Major currency pairs include pairs such as EUR/USD, USD/JPY, GBP/USD, etc. Parameters @@ -110,8 +112,8 @@ def search( delisted_utc : Optional[datetime] The delisted timestamp in UTC. (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.currency.search() >>> # Search for 'EURUSD' currency pair using 'polygon' as provider. @@ -132,7 +134,8 @@ def search( ("fmp", "intrinio", "polygon"), ) }, - standard_params={}, + standard_params={ + }, extra_params=kwargs, ) ) diff --git a/openbb_platform/openbb/package/currency_price.py b/openbb_platform/openbb/package/currency_price.py index ab13fd1b0c95..a1f4a1de947a 100644 --- a/openbb_platform/openbb/package/currency_price.py +++ b/openbb_platform/openbb/package/currency_price.py @@ -23,34 +23,19 @@ def __repr__(self) -> str: @validate def historical( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): polygon, yfinance." - ), - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): polygon, yfinance.")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp", "polygon", "tiingo", "yfinance"]] = None, **kwargs ) -> OBBject: - """Currency Historical Price. Currency historical data. + """ Currency Historical Price. Currency historical data. - Currency historical prices refer to the past exchange rates of one currency against - another over a specific period. - This data provides insight into the fluctuations and trends in the foreign exchange market, - helping analysts, traders, and economists understand currency performance, - evaluate economic health, and make predictions about future movements. + Currency historical prices refer to the past exchange rates of one currency against + another over a specific period. + This data provides insight into the fluctuations and trends in the foreign exchange market, + helping analysts, traders, and economists understand currency performance, + evaluate economic health, and make predictions about future movements. Parameters @@ -119,8 +104,8 @@ def historical( transactions : Optional[Annotated[int, Gt(gt=0)]] Number of transactions for the symbol in the time period. (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.currency.price.historical(symbol='EURUSD') >>> # Filter historical data with specific start and end date. @@ -145,8 +130,6 @@ def historical( "end_date": end_date, }, extra_params=kwargs, - extra_info={ - "symbol": {"multiple_items_allowed": ["polygon", "yfinance"]} - }, + extra_info={"symbol": {"multiple_items_allowed": ["polygon", "yfinance"]}}, ) ) diff --git a/openbb_platform/openbb/package/derivatives.py b/openbb_platform/openbb/package/derivatives.py index 09e666eb8606..902d76d62ab9 100644 --- a/openbb_platform/openbb/package/derivatives.py +++ b/openbb_platform/openbb/package/derivatives.py @@ -18,15 +18,11 @@ def futures(self): # pylint: disable=import-outside-toplevel from . import derivatives_futures - return derivatives_futures.ROUTER_derivatives_futures( - command_runner=self._command_runner - ) + return derivatives_futures.ROUTER_derivatives_futures(command_runner=self._command_runner) @property def options(self): # pylint: disable=import-outside-toplevel from . import derivatives_options - return derivatives_options.ROUTER_derivatives_options( - command_runner=self._command_runner - ) + return derivatives_options.ROUTER_derivatives_options(command_runner=self._command_runner) diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py index cc24cfda0cfd..ecebef6800ac 100644 --- a/openbb_platform/openbb/package/derivatives_options.py +++ b/openbb_platform/openbb/package/derivatives_options.py @@ -23,9 +23,7 @@ def __repr__(self) -> str: @validate def chains( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -147,8 +145,8 @@ def chains( exercise_style : Optional[str] The exercise style of the option, American or European. (provider: intrinio) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.derivatives.options.chains(symbol='AAPL', provider='intrinio') >>> # Use the "date" parameter to get the end-of-day-data for a specific date, where supported. @@ -176,12 +174,7 @@ def chains( @validate def unusual( self, - symbol: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="Symbol to get data for. (the underlying symbol)" - ), - ] = None, + symbol: Annotated[Optional[str], OpenBBCustomParameter(description="Symbol to get data for. (the underlying symbol)")] = None, provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -237,8 +230,8 @@ def unusual( timestamp : Optional[datetime] The UTC timestamp of order placement. (provider: intrinio) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.derivatives.options.unusual() >>> # Use the 'symbol' parameter to get the most recent activity for a specific symbol. diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 3a836462852c..392d7f428451 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -34,18 +34,8 @@ def __repr__(self) -> str: @validate def calendar( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp", "tradingeconomics"]] = None, **kwargs ) -> OBBject: @@ -121,8 +111,8 @@ def calendar( created_at : Optional[datetime] Created at timestamp. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.calendar(provider='fmp', start_date='2020-03-01', end_date='2020-03-31') >>> # By default, the calendar will be forward-looking. @@ -151,24 +141,14 @@ def calendar( @validate def composite_leading_indicator( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: """The composite leading indicator (CLI) is designed to provide early signals of turning points - in business cycles showing fluctuation of the economic activity around its long term potential level. - CLIs show short-term economic movements in qualitative rather than quantitative terms. + in business cycles showing fluctuation of the economic activity around its long term potential level. + CLIs show short-term economic movements in qualitative rather than quantitative terms. Parameters @@ -207,8 +187,8 @@ def composite_leading_indicator( country : Optional[str] Country for which CLI is given - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.composite_leading_indicator(country='all') """ # noqa: E501 @@ -235,42 +215,12 @@ def composite_leading_indicator( @validate def cpi( self, - country: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="The country to get data. Multiple items allowed for provider(s): fred." - ), - ], - units: Annotated[ - Literal["growth_previous", "growth_same", "index_2015"], - OpenBBCustomParameter( - description="The unit of measurement for the data.\n Options:\n - `growth_previous`: Percent growth from the previous period.\n If monthly data, this is month-over-month, etc\n - `growth_same`: Percent growth from the same period in the previous year.\n If looking at monthly data, this would be year-over-year, etc.\n - `index_2015`: Rescaled index value, such that the value in 2015 is 100." - ), - ] = "growth_same", - frequency: Annotated[ - Literal["monthly", "quarter", "annual"], - OpenBBCustomParameter( - description="The frequency of the data.\n Options: `monthly`, `quarter`, and `annual`." - ), - ] = "monthly", - harmonized: Annotated[ - bool, - OpenBBCustomParameter( - description="Whether you wish to obtain harmonized data." - ), - ] = False, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + country: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="The country to get data. Multiple items allowed for provider(s): fred.")], + units: Annotated[Literal["growth_previous", "growth_same", "index_2015"], OpenBBCustomParameter(description="The unit of measurement for the data.\n Options:\n - `growth_previous`: Percent growth from the previous period.\n If monthly data, this is month-over-month, etc\n - `growth_same`: Percent growth from the same period in the previous year.\n If looking at monthly data, this would be year-over-year, etc.\n - `index_2015`: Rescaled index value, such that the value in 2015 is 100.")] = "growth_same", + frequency: Annotated[Literal["monthly", "quarter", "annual"], OpenBBCustomParameter(description="The frequency of the data.\n Options: `monthly`, `quarter`, and `annual`.")] = "monthly", + harmonized: Annotated[bool, OpenBBCustomParameter(description="Whether you wish to obtain harmonized data.")] = False, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: @@ -282,15 +232,15 @@ def cpi( The country to get data. Multiple items allowed for provider(s): fred. units : Literal['growth_previous', 'growth_same', 'index_2015'] The unit of measurement for the data. - Options: - - `growth_previous`: Percent growth from the previous period. - If monthly data, this is month-over-month, etc - - `growth_same`: Percent growth from the same period in the previous year. - If looking at monthly data, this would be year-over-year, etc. - - `index_2015`: Rescaled index value, such that the value in 2015 is 100. + Options: + - `growth_previous`: Percent growth from the previous period. + If monthly data, this is month-over-month, etc + - `growth_same`: Percent growth from the same period in the previous year. + If looking at monthly data, this would be year-over-year, etc. + - `index_2015`: Rescaled index value, such that the value in 2015 is 100. frequency : Literal['monthly', 'quarter', 'annual'] The frequency of the data. - Options: `monthly`, `quarter`, and `annual`. + Options: `monthly`, `quarter`, and `annual`. harmonized : bool Whether you wish to obtain harmonized data. start_date : Union[datetime.date, None, str] @@ -321,8 +271,8 @@ def cpi( date : date The date of the data. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.cpi(country='japan,china,turkey') >>> # Use the `units` parameter to define the reference period for the change in values. @@ -356,33 +306,15 @@ def cpi( @validate def fred_regional( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fred." - ), - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - limit: Annotated[ - Optional[int], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 100000, + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fred.")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 100000, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: - """Query the Geo Fred API for regional economic data by series group. - The series group ID is found by using `fred_search` and the `series_id` parameter. + """ Query the Geo Fred API for regional economic data by series group. + The series group ID is found by using `fred_search` and the `series_id` parameter. Parameters @@ -409,46 +341,46 @@ def fred_regional( The units of the data. This should match the units returned from searching by series ID. An incorrect field will not necessarily return an error. Parameter is only valid when `is_series_group` is True. (provider: fred) frequency : Optional[Literal['d', 'w', 'bw', 'm', 'q', 'sa', 'a', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] - Frequency aggregation to convert high frequency data to lower frequency. - Parameter is only valid when `is_series_group` is True. - a = Annual - sa= Semiannual - q = Quarterly - m = Monthly - w = Weekly - d = Daily - wef = Weekly, Ending Friday - weth = Weekly, Ending Thursday - wew = Weekly, Ending Wednesday - wetu = Weekly, Ending Tuesday - wem = Weekly, Ending Monday - wesu = Weekly, Ending Sunday - wesa = Weekly, Ending Saturday - bwew = Biweekly, Ending Wednesday - bwem = Biweekly, Ending Monday - (provider: fred) + Frequency aggregation to convert high frequency data to lower frequency. + Parameter is only valid when `is_series_group` is True. + a = Annual + sa= Semiannual + q = Quarterly + m = Monthly + w = Weekly + d = Daily + wef = Weekly, Ending Friday + weth = Weekly, Ending Thursday + wew = Weekly, Ending Wednesday + wetu = Weekly, Ending Tuesday + wem = Weekly, Ending Monday + wesu = Weekly, Ending Sunday + wesa = Weekly, Ending Saturday + bwew = Biweekly, Ending Wednesday + bwem = Biweekly, Ending Monday + (provider: fred) aggregation_method : Literal['avg', 'sum', 'eop'] - A key that indicates the aggregation method used for frequency aggregation. - This parameter has no affect if the frequency parameter is not set. - Only valid when `is_series_group` is True. - avg = Average - sum = Sum - eop = End of Period - (provider: fred) + A key that indicates the aggregation method used for frequency aggregation. + This parameter has no affect if the frequency parameter is not set. + Only valid when `is_series_group` is True. + avg = Average + sum = Sum + eop = End of Period + (provider: fred) transform : Literal['lin', 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'] - Transformation type. Only valid when `is_series_group` is True. - lin = Levels (No transformation) - chg = Change - ch1 = Change from Year Ago - pch = Percent Change - pc1 = Percent Change from Year Ago - pca = Compounded Annual Rate of Change - cch = Continuously Compounded Rate of Change - cca = Continuously Compounded Annual Rate of Change - log = Natural Log - (provider: fred) + Transformation type. Only valid when `is_series_group` is True. + lin = Levels (No transformation) + chg = Change + ch1 = Change from Year Ago + pch = Percent Change + pc1 = Percent Change from Year Ago + pca = Compounded Annual Rate of Change + cch = Continuously Compounded Rate of Change + cca = Continuously Compounded Annual Rate of Change + log = Natural Log + (provider: fred) Returns ------- @@ -477,8 +409,8 @@ def fred_regional( series_id : Optional[str] The individual series ID for the region. (provider: fred) - Example - ------- + Examples + -------- >>> from openbb import obb >>> # With no date, the most recent report is returned. >>> obb.economy.fred_regional(series_id='NYICLAIMS') @@ -511,15 +443,13 @@ def fred_regional( @validate def fred_search( self, - query: Annotated[ - Optional[str], OpenBBCustomParameter(description="The search word(s).") - ] = None, + query: Annotated[Optional[str], OpenBBCustomParameter(description="The search word(s).")] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: - """Search for FRED series or economic releases by ID or string. - This does not return the observation values, only the metadata. - Use this function to find series IDs for `fred_series()`. + """ Search for FRED series or economic releases by ID or string. + This does not return the observation values, only the metadata. + Use this function to find series IDs for `fred_series()`. Parameters @@ -606,8 +536,8 @@ def fred_search( series_group : Optional[Union[int, str]] The series group ID of the series. This value is used to query for regional data. (provider: fred) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.fred_search() """ # noqa: E501 @@ -633,28 +563,10 @@ def fred_search( @validate def fred_series( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fred." - ), - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - limit: Annotated[ - Optional[int], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 100000, + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fred.")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 100000, provider: Optional[Literal["fred", "intrinio"]] = None, **kwargs ) -> OBBject: @@ -676,44 +588,44 @@ def fred_series( no default. frequency : Literal[None, 'a', 'q', 'm', 'w', 'd', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem'] - Frequency aggregation to convert high frequency data to lower frequency. - None = No change - a = Annual - q = Quarterly - m = Monthly - w = Weekly - d = Daily - wef = Weekly, Ending Friday - weth = Weekly, Ending Thursday - wew = Weekly, Ending Wednesday - wetu = Weekly, Ending Tuesday - wem = Weekly, Ending Monday - wesu = Weekly, Ending Sunday - wesa = Weekly, Ending Saturday - bwew = Biweekly, Ending Wednesday - bwem = Biweekly, Ending Monday - (provider: fred) + Frequency aggregation to convert high frequency data to lower frequency. + None = No change + a = Annual + q = Quarterly + m = Monthly + w = Weekly + d = Daily + wef = Weekly, Ending Friday + weth = Weekly, Ending Thursday + wew = Weekly, Ending Wednesday + wetu = Weekly, Ending Tuesday + wem = Weekly, Ending Monday + wesu = Weekly, Ending Sunday + wesa = Weekly, Ending Saturday + bwew = Biweekly, Ending Wednesday + bwem = Biweekly, Ending Monday + (provider: fred) aggregation_method : Literal[None, 'avg', 'sum', 'eop'] - A key that indicates the aggregation method used for frequency aggregation. - This parameter has no affect if the frequency parameter is not set. - avg = Average - sum = Sum - eop = End of Period - (provider: fred) + A key that indicates the aggregation method used for frequency aggregation. + This parameter has no affect if the frequency parameter is not set. + avg = Average + sum = Sum + eop = End of Period + (provider: fred) transform : Literal[None, 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'] - Transformation type - None = No transformation - chg = Change - ch1 = Change from Year Ago - pch = Percent Change - pc1 = Percent Change from Year Ago - pca = Compounded Annual Rate of Change - cch = Continuously Compounded Rate of Change - cca = Continuously Compounded Annual Rate of Change - log = Natural Log - (provider: fred) + Transformation type + None = No transformation + chg = Change + ch1 = Change from Year Ago + pch = Percent Change + pc1 = Percent Change from Year Ago + pca = Compounded Annual Rate of Change + cch = Continuously Compounded Rate of Change + cca = Continuously Compounded Annual Rate of Change + log = Natural Log + (provider: fred) all_pages : Optional[bool] Returns all pages of data from the API call at once. (provider: intrinio) sleep : Optional[float] @@ -740,8 +652,8 @@ def fred_series( value : Optional[float] Value of the index. (provider: intrinio) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.fred_series(series_id='NFCI') >>> # Multiple series can be passed in as a list. @@ -782,30 +694,20 @@ def gdp(self): @validate def long_term_interest_rate( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: - """Long-term interest rates refer to government bonds maturing in ten years. - Rates are mainly determined by the price charged by the lender, the risk from the borrower and the - fall in the capital value. Long-term interest rates are generally averages of daily rates, - measured as a percentage. These interest rates are implied by the prices at which the government bonds are - traded on financial markets, not the interest rates at which the loans were issued. - In all cases, they refer to bonds whose capital repayment is guaranteed by governments. - Long-term interest rates are one of the determinants of business investment. - Low long-term interest rates encourage investment in new equipment and high interest rates discourage it. - Investment is, in turn, a major source of economic growth. + """ Long-term interest rates refer to government bonds maturing in ten years. + Rates are mainly determined by the price charged by the lender, the risk from the borrower and the + fall in the capital value. Long-term interest rates are generally averages of daily rates, + measured as a percentage. These interest rates are implied by the prices at which the government bonds are + traded on financial markets, not the interest rates at which the loans were issued. + In all cases, they refer to bonds whose capital repayment is guaranteed by governments. + Long-term interest rates are one of the determinants of business investment. + Low long-term interest rates encourage investment in new equipment and high interest rates discourage it. + Investment is, in turn, a major source of economic growth. Parameters ---------- @@ -845,8 +747,8 @@ def long_term_interest_rate( country : Optional[str] Country for which interest rate is given - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 @@ -873,24 +775,9 @@ def long_term_interest_rate( @validate def money_measures( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - adjusted: Annotated[ - Optional[bool], - OpenBBCustomParameter( - description="Whether to return seasonally adjusted data." - ), - ] = True, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + adjusted: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether to return seasonally adjusted data.")] = True, provider: Optional[Literal["federal_reserve"]] = None, **kwargs ) -> OBBject: @@ -942,8 +829,8 @@ def money_measures( small_denomination_time_deposits : Optional[float] Value of small denomination time deposits in billions. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.money_measures(adjusted=False) """ # noqa: E501 @@ -970,7 +857,9 @@ def money_measures( @exception_handler @validate def risk_premium( - self, provider: Optional[Literal["fmp"]] = None, **kwargs + self, + provider: Optional[Literal["fmp"]] = None, + **kwargs ) -> OBBject: """Market Risk Premium by country. @@ -1006,8 +895,8 @@ def risk_premium( country_risk_premium : Optional[Annotated[float, Ge(ge=0)]] Country-specific risk premium. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.risk_premium() """ # noqa: E501 @@ -1022,7 +911,8 @@ def risk_premium( ("fmp",), ) }, - standard_params={}, + standard_params={ + }, extra_params=kwargs, ) ) @@ -1031,26 +921,16 @@ def risk_premium( @validate def short_term_interest_rate( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: - """Short-term interest rates are the rates at which short-term borrowings are effected between - financial institutions or the rate at which short-term government paper is issued or traded in the market. - Short-term interest rates are generally averages of daily rates, measured as a percentage. - Short-term interest rates are based on three-month money market rates where available. - Typical standardised names are "money market rate" and "treasury bill rate". + """ Short-term interest rates are the rates at which short-term borrowings are effected between + financial institutions or the rate at which short-term government paper is issued or traded in the market. + Short-term interest rates are generally averages of daily rates, measured as a percentage. + Short-term interest rates are based on three-month money market rates where available. + Typical standardised names are "money market rate" and "treasury bill rate". Parameters @@ -1091,8 +971,8 @@ def short_term_interest_rate( country : Optional[str] Country for which interest rate is given - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 @@ -1119,18 +999,8 @@ def short_term_interest_rate( @validate def unemployment( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: @@ -1180,8 +1050,8 @@ def unemployment( country : Optional[str] Country for which unemployment rate is given - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.unemployment(country='all', frequency='quarterly') >>> # Demographics for the statistics are selected with the `age` and `sex` parameters. diff --git a/openbb_platform/openbb/package/economy_gdp.py b/openbb_platform/openbb/package/economy_gdp.py index e02303b12bd5..7a4b23f76b65 100644 --- a/openbb_platform/openbb/package/economy_gdp.py +++ b/openbb_platform/openbb/package/economy_gdp.py @@ -25,30 +25,10 @@ def __repr__(self) -> str: @validate def forecast( self, - period: Annotated[ - Literal["quarter", "annual"], - OpenBBCustomParameter( - description="Time period of the data to return. Units for nominal GDP period. Either quarter or annual." - ), - ] = "annual", - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - type: Annotated[ - Literal["nominal", "real"], - OpenBBCustomParameter( - description="Type of GDP to get forecast of. Either nominal or real." - ), - ] = "real", + period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return. Units for nominal GDP period. Either quarter or annual.")] = "annual", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + type: Annotated[Literal["nominal", "real"], OpenBBCustomParameter(description="Type of GDP to get forecast of. Either nominal or real.")] = "real", provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: @@ -92,8 +72,8 @@ def forecast( value : Optional[float] Nominal GDP value on the date. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.gdp.forecast(period='annual', type='real') """ # noqa: E501 @@ -122,24 +102,9 @@ def forecast( @validate def nominal( self, - units: Annotated[ - Literal["usd", "usd_cap"], - OpenBBCustomParameter( - description="The unit of measurement for the data. Units to get nominal GDP in. Either usd or usd_cap indicating per capita." - ), - ] = "usd", - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + units: Annotated[Literal["usd", "usd_cap"], OpenBBCustomParameter(description="The unit of measurement for the data. Units to get nominal GDP in. Either usd or usd_cap indicating per capita.")] = "usd", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: @@ -181,8 +146,8 @@ def nominal( value : Optional[float] Nominal GDP value on the date. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.gdp.nominal(units='usd') """ # noqa: E501 @@ -210,24 +175,9 @@ def nominal( @validate def real( self, - units: Annotated[ - Literal["idx", "qoq", "yoy"], - OpenBBCustomParameter( - description="The unit of measurement for the data. Either idx (indicating 2015=100), qoq (previous period) or yoy (same period, previous year).)" - ), - ] = "yoy", - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + units: Annotated[Literal["idx", "qoq", "yoy"], OpenBBCustomParameter(description="The unit of measurement for the data. Either idx (indicating 2015=100), qoq (previous period) or yoy (same period, previous year).)")] = "yoy", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: @@ -269,8 +219,8 @@ def real( value : Optional[float] Nominal GDP value on the date. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.economy.gdp.real(units='yoy') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index 8747b9a57e9f..71671382bbe5 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -34,9 +34,7 @@ def calendar(self): # pylint: disable=import-outside-toplevel from . import equity_calendar - return equity_calendar.ROUTER_equity_calendar( - command_runner=self._command_runner - ) + return equity_calendar.ROUTER_equity_calendar(command_runner=self._command_runner) @property def compare(self): @@ -50,32 +48,28 @@ def discovery(self): # pylint: disable=import-outside-toplevel from . import equity_discovery - return equity_discovery.ROUTER_equity_discovery( - command_runner=self._command_runner - ) + return equity_discovery.ROUTER_equity_discovery(command_runner=self._command_runner) @property def estimates(self): # pylint: disable=import-outside-toplevel from . import equity_estimates - return equity_estimates.ROUTER_equity_estimates( - command_runner=self._command_runner - ) + return equity_estimates.ROUTER_equity_estimates(command_runner=self._command_runner) @property def fundamental(self): # pylint: disable=import-outside-toplevel from . import equity_fundamental - return equity_fundamental.ROUTER_equity_fundamental( - command_runner=self._command_runner - ) + return equity_fundamental.ROUTER_equity_fundamental(command_runner=self._command_runner) @exception_handler @validate def market_snapshots( - self, provider: Optional[Literal["fmp", "polygon"]] = None, **kwargs + self, + provider: Optional[Literal["fmp", "polygon"]] = None, + **kwargs ) -> OBBject: """Get an updated equity market snapshot. This includes price data for thousands of stocks. @@ -185,8 +179,8 @@ def market_snapshots( last_trade_timestamp : Optional[datetime] The last trade timestamp. (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.market_snapshots() """ # noqa: E501 @@ -201,7 +195,8 @@ def market_snapshots( ("fmp", "polygon"), ) }, - standard_params={}, + standard_params={ + }, extra_params=kwargs, ) ) @@ -211,9 +206,7 @@ def ownership(self): # pylint: disable=import-outside-toplevel from . import equity_ownership - return equity_ownership.ROUTER_equity_ownership( - command_runner=self._command_runner - ) + return equity_ownership.ROUTER_equity_ownership(command_runner=self._command_runner) @property def price(self): @@ -226,12 +219,7 @@ def price(self): @validate def profile( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance.")], provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -352,7 +340,7 @@ def profile( Currency in which the stock is traded. (provider: fmp, yfinance) market_cap : Optional[int] Market capitalization of the company. (provider: fmp); - The market capitalization of the asset. (provider: yfinance) + The market capitalization of the asset. (provider: yfinance) last_price : Optional[float] The last traded price. (provider: fmp) year_high : Optional[float] @@ -384,8 +372,8 @@ def profile( dividend_yield : Optional[float] The dividend yield of the asset, as a normalized percent. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.profile(symbol='AAPL') """ # noqa: E501 @@ -404,19 +392,19 @@ def profile( "symbol": symbol, }, extra_params=kwargs, - extra_info={ - "symbol": { - "multiple_items_allowed": ["fmp", "intrinio", "yfinance"] - } - }, + extra_info={"symbol": {"multiple_items_allowed": ["fmp", "intrinio", "yfinance"]}}, ) ) @exception_handler @validate - def screener(self, provider: Optional[Literal["fmp"]] = None, **kwargs) -> OBBject: + def screener( + self, + provider: Optional[Literal["fmp"]] = None, + **kwargs + ) -> OBBject: """Screen for companies meeting various criteria. These criteria include - market cap, price, beta, volume, and dividend yield. + market cap, price, beta, volume, and dividend yield. Parameters ---------- @@ -504,8 +492,8 @@ def screener(self, provider: Optional[Literal["fmp"]] = None, **kwargs) -> OBBje actively_trading : Optional[Literal[True, False]] Whether the ETF is actively trading. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.screener() """ # noqa: E501 @@ -520,7 +508,8 @@ def screener(self, provider: Optional[Literal["fmp"]] = None, **kwargs) -> OBBje ("fmp",), ) }, - standard_params={}, + standard_params={ + }, extra_params=kwargs, ) ) @@ -530,14 +519,8 @@ def screener(self, provider: Optional[Literal["fmp"]] = None, **kwargs) -> OBBje def search( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - is_symbol: Annotated[ - bool, - OpenBBCustomParameter(description="Whether to search by ticker symbol."), - ] = False, - use_cache: Annotated[ - Optional[bool], - OpenBBCustomParameter(description="Whether to use the cache or not."), - ] = True, + is_symbol: Annotated[bool, OpenBBCustomParameter(description="Whether to search by ticker symbol.")] = False, + use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether to use the cache or not.")] = True, provider: Optional[Literal["intrinio", "sec"]] = None, **kwargs ) -> OBBject: @@ -584,14 +567,14 @@ def search( Name of the company. cik : Optional[str] ; - Central Index Key (provider: sec) + Central Index Key (provider: sec) lei : Optional[str] The Legal Entity Identifier (LEI) of the company. (provider: intrinio) intrinio_id : Optional[str] The Intrinio ID of the company. (provider: intrinio) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.search(query='AAPL', is_symbol=False, use_cache=True) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_calendar.py b/openbb_platform/openbb/package/equity_calendar.py index e15af99bdbf9..fec06260a74d 100644 --- a/openbb_platform/openbb/package/equity_calendar.py +++ b/openbb_platform/openbb/package/equity_calendar.py @@ -26,18 +26,8 @@ def __repr__(self) -> str: @validate def dividend( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -89,8 +79,8 @@ def dividend( label : Optional[str] Ex-dividend date formatted for display. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.calendar.dividend() >>> # Get dividend calendar for specific dates. @@ -119,18 +109,8 @@ def dividend( @validate def earnings( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -186,8 +166,8 @@ def earnings( updated_date : Optional[date] The date the data was updated last. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.calendar.earnings() >>> # Get earnings calendar for specific dates. @@ -216,25 +196,10 @@ def earnings( @validate def ipo( self, - symbol: Annotated[ - Optional[str], OpenBBCustomParameter(description="Symbol to get data for.") - ] = None, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - limit: Annotated[ - Optional[int], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 100, + symbol: Annotated[Optional[str], OpenBBCustomParameter(description="Symbol to get data for.")] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 100, provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -283,52 +248,52 @@ def ipo( The date of the IPO, when the stock first trades on a major exchange. status : Optional[Literal['upcoming', 'priced', 'withdrawn']] - The status of the IPO. Upcoming IPOs have not taken place yet but are expected to. - Priced IPOs have taken place. - Withdrawn IPOs were expected to take place, but were subsequently withdrawn and did not take place - (provider: intrinio) + The status of the IPO. Upcoming IPOs have not taken place yet but are expected to. + Priced IPOs have taken place. + Withdrawn IPOs were expected to take place, but were subsequently withdrawn and did not take place + (provider: intrinio) exchange : Optional[str] - The acronym of the stock exchange that the company is going to trade publicly on. - Typically NYSE or NASDAQ. - (provider: intrinio) + The acronym of the stock exchange that the company is going to trade publicly on. + Typically NYSE or NASDAQ. + (provider: intrinio) offer_amount : Optional[float] The total dollar amount of shares offered in the IPO. Typically this is share price * share count (provider: intrinio) share_price : Optional[float] The price per share at which the IPO was offered. (provider: intrinio) share_price_lowest : Optional[float] - The expected lowest price per share at which the IPO will be offered. - Before an IPO is priced, companies typically provide a range of prices per share at which - they expect to offer the IPO (typically available for upcoming IPOs). - (provider: intrinio) + The expected lowest price per share at which the IPO will be offered. + Before an IPO is priced, companies typically provide a range of prices per share at which + they expect to offer the IPO (typically available for upcoming IPOs). + (provider: intrinio) share_price_highest : Optional[float] - The expected highest price per share at which the IPO will be offered. - Before an IPO is priced, companies typically provide a range of prices per share at which - they expect to offer the IPO (typically available for upcoming IPOs). - (provider: intrinio) + The expected highest price per share at which the IPO will be offered. + Before an IPO is priced, companies typically provide a range of prices per share at which + they expect to offer the IPO (typically available for upcoming IPOs). + (provider: intrinio) share_count : Optional[int] The number of shares offered in the IPO. (provider: intrinio) share_count_lowest : Optional[int] - The expected lowest number of shares that will be offered in the IPO. Before an IPO is priced, - companies typically provide a range of shares that they expect to offer in the IPO - (typically available for upcoming IPOs). - (provider: intrinio) + The expected lowest number of shares that will be offered in the IPO. Before an IPO is priced, + companies typically provide a range of shares that they expect to offer in the IPO + (typically available for upcoming IPOs). + (provider: intrinio) share_count_highest : Optional[int] - The expected highest number of shares that will be offered in the IPO. Before an IPO is priced, - companies typically provide a range of shares that they expect to offer in the IPO - (typically available for upcoming IPOs). - (provider: intrinio) + The expected highest number of shares that will be offered in the IPO. Before an IPO is priced, + companies typically provide a range of shares that they expect to offer in the IPO + (typically available for upcoming IPOs). + (provider: intrinio) announcement_url : Optional[str] The URL to the company's announcement of the IPO (provider: intrinio) sec_report_url : Optional[str] - The URL to the company's S-1, S-1/A, F-1, or F-1/A SEC filing, - which is required to be filed before an IPO takes place. - (provider: intrinio) + The URL to the company's S-1, S-1/A, F-1, or F-1/A SEC filing, + which is required to be filed before an IPO takes place. + (provider: intrinio) open_price : Optional[float] The opening price at the beginning of the first trading day (only available for priced IPOs). (provider: intrinio) close_price : Optional[float] @@ -337,19 +302,19 @@ def ipo( The volume at the end of the first trading day (only available for priced IPOs). (provider: intrinio) day_change : Optional[float] - The percentage change between the open price and the close price on the first trading day - (only available for priced IPOs). - (provider: intrinio) + The percentage change between the open price and the close price on the first trading day + (only available for priced IPOs). + (provider: intrinio) week_change : Optional[float] - The percentage change between the open price on the first trading day and the close price approximately - a week after the first trading day (only available for priced IPOs). - (provider: intrinio) + The percentage change between the open price on the first trading day and the close price approximately + a week after the first trading day (only available for priced IPOs). + (provider: intrinio) month_change : Optional[float] - The percentage change between the open price on the first trading day and the close price approximately - a month after the first trading day (only available for priced IPOs). - (provider: intrinio) + The percentage change between the open price on the first trading day and the close price approximately + a month after the first trading day (only available for priced IPOs). + (provider: intrinio) id : Optional[str] The Intrinio ID of the IPO. (provider: intrinio) company : Optional[openbb_intrinio.utils.references.IntrinioCompany] @@ -357,8 +322,8 @@ def ipo( security : Optional[openbb_intrinio.utils.references.IntrinioSecurity] The primary Security for the Company that is going public via the IPO (provider: intrinio) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.calendar.ipo(limit=100) >>> # Get all IPOs available. @@ -391,18 +356,8 @@ def ipo( @validate def splits( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -446,8 +401,8 @@ def splits( denominator : float Denominator of the stock splits. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.calendar.splits() >>> # Get stock splits calendar for specific dates. diff --git a/openbb_platform/openbb/package/equity_compare.py b/openbb_platform/openbb/package/equity_compare.py index 3079147dc789..4ce617241c67 100644 --- a/openbb_platform/openbb/package/equity_compare.py +++ b/openbb_platform/openbb/package/equity_compare.py @@ -22,16 +22,14 @@ def __repr__(self) -> str: @validate def peers( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Get the closest peers for a given company. - Peers consist of companies trading on the same exchange, operating within the same sector - and with comparable market capitalizations. + Peers consist of companies trading on the same exchange, operating within the same sector + and with comparable market capitalizations. Parameters ---------- @@ -61,8 +59,8 @@ def peers( peers_list : List[str] A list of equity peers based on sector, exchange and market cap. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.compare.peers(symbol='AAPL') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_discovery.py b/openbb_platform/openbb/package/equity_discovery.py index e1d2c19e4b02..1fbc8c7d1c5b 100644 --- a/openbb_platform/openbb/package/equity_discovery.py +++ b/openbb_platform/openbb/package/equity_discovery.py @@ -30,12 +30,7 @@ def __repr__(self) -> str: @validate def active( self, - sort: Annotated[ - str, - OpenBBCustomParameter( - description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." - ), - ] = "desc", + sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -85,8 +80,8 @@ def active( pe_ratio_ttm : Optional[float] PE Ratio (TTM). (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.discovery.active(sort='desc') """ # noqa: E501 @@ -112,12 +107,7 @@ def active( @validate def aggressive_small_caps( self, - sort: Annotated[ - str, - OpenBBCustomParameter( - description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." - ), - ] = "desc", + sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -167,8 +157,8 @@ def aggressive_small_caps( pe_ratio_ttm : Optional[float] PE Ratio (TTM). (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.discovery.aggressive_small_caps(sort='desc') """ # noqa: E501 @@ -194,36 +184,18 @@ def aggressive_small_caps( @validate def filings( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - form_type: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="Filter by form type. Visit https://www.sec.gov/forms for a list of supported form types." - ), - ] = None, - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 100, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + form_type: Annotated[Optional[str], OpenBBCustomParameter(description="Filter by form type. Visit https://www.sec.gov/forms for a list of supported form types.")] = None, + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 100, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Get the URLs to SEC filings reported to EDGAR database, such as 10-K, 10-Q, 8-K, and more. SEC - filings include Form 10-K, Form 10-Q, Form 8-K, the proxy statement, Forms 3, 4, and 5, Schedule 13, Form 114, - Foreign Investment Disclosures and others. The annual 10-K report is required to be - filed annually and includes the company's financial statements, management discussion and analysis, - and audited financial statements. + filings include Form 10-K, Form 10-Q, Form 8-K, the proxy statement, Forms 3, 4, and 5, Schedule 13, Form 114, + Foreign Investment Disclosures and others. The annual 10-K report is required to be + filed annually and includes the company's financial statements, management discussion and analysis, + and audited financial statements. Parameters @@ -272,8 +244,8 @@ def filings( link : str URL to the filing page on the SEC site. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.discovery.filings(limit=100) >>> # Get filings for the year 2023, limited to 100 results @@ -304,12 +276,7 @@ def filings( @validate def gainers( self, - sort: Annotated[ - str, - OpenBBCustomParameter( - description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." - ), - ] = "desc", + sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -359,8 +326,8 @@ def gainers( pe_ratio_ttm : Optional[float] PE Ratio (TTM). (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.discovery.gainers(sort='desc') """ # noqa: E501 @@ -386,12 +353,7 @@ def gainers( @validate def growth_tech( self, - sort: Annotated[ - str, - OpenBBCustomParameter( - description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." - ), - ] = "desc", + sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -441,8 +403,8 @@ def growth_tech( pe_ratio_ttm : Optional[float] PE Ratio (TTM). (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.discovery.growth_tech(sort='desc') """ # noqa: E501 @@ -468,12 +430,7 @@ def growth_tech( @validate def losers( self, - sort: Annotated[ - str, - OpenBBCustomParameter( - description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." - ), - ] = "desc", + sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -523,8 +480,8 @@ def losers( pe_ratio_ttm : Optional[float] PE Ratio (TTM). (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.discovery.losers(sort='desc') """ # noqa: E501 @@ -550,12 +507,7 @@ def losers( @validate def undervalued_growth( self, - sort: Annotated[ - str, - OpenBBCustomParameter( - description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." - ), - ] = "desc", + sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -605,8 +557,8 @@ def undervalued_growth( pe_ratio_ttm : Optional[float] PE Ratio (TTM). (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.discovery.undervalued_growth(sort='desc') """ # noqa: E501 @@ -632,12 +584,7 @@ def undervalued_growth( @validate def undervalued_large_caps( self, - sort: Annotated[ - str, - OpenBBCustomParameter( - description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." - ), - ] = "desc", + sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -687,8 +634,8 @@ def undervalued_large_caps( pe_ratio_ttm : Optional[float] PE Ratio (TTM). (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.discovery.undervalued_large_caps(sort='desc') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py index aca93d06d4cf..429b62dbbdd3 100644 --- a/openbb_platform/openbb/package/equity_estimates.py +++ b/openbb_platform/openbb/package/equity_estimates.py @@ -25,18 +25,8 @@ def __repr__(self) -> str: @validate def analyst_search( self, - analyst_name: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="A comma separated list of analyst names to bring back. Omitting will bring back all available analysts." - ), - ] = None, - firm_name: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="A comma separated list of firm names to bring back. Omitting will bring back all available firms." - ), - ] = None, + analyst_name: Annotated[Optional[str], OpenBBCustomParameter(description="A comma separated list of analyst names to bring back. Omitting will bring back all available analysts.")] = None, + firm_name: Annotated[Optional[str], OpenBBCustomParameter(description="A comma separated list of firm names to bring back. Omitting will bring back all available firms.")] = None, provider: Optional[Literal["benzinga"]] = None, **kwargs ) -> OBBject: @@ -168,8 +158,8 @@ def analyst_search( std_dev_3y : Optional[float] The standard deviation in percent (normalized) price difference in the analyst's ratings over the last 3 years (provider: benzinga) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.estimates.analyst_search(firm_name='Wedbush', provider='benzinga') """ # noqa: E501 @@ -196,12 +186,7 @@ def analyst_search( @validate def consensus( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): yfinance.")], provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -253,8 +238,8 @@ def consensus( currency : Optional[str] Currency the stock is priced in. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.estimates.consensus(symbol='AAPL,MSFT', provider='yfinance') """ # noqa: E501 @@ -281,17 +266,9 @@ def consensus( @validate def historical( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - period: Annotated[ - Literal["quarter", "annual"], - OpenBBCustomParameter(description="Time period of the data to return."), - ] = "annual", - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 30, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 30, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -371,8 +348,8 @@ def historical( number_analysts_estimated_eps : int Number of analysts who estimated EPS. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.estimates.historical(symbol='AAPL', provider='fmp') """ # noqa: E501 @@ -400,16 +377,8 @@ def historical( @validate def price_target( self, - symbol: Annotated[ - Union[str, None, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): benzinga." - ), - ] = None, - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 200, + symbol: Annotated[Union[str, None, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): benzinga.")] = None, + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 200, provider: Optional[Literal["benzinga", "fmp"]] = None, **kwargs ) -> OBBject: @@ -521,8 +490,8 @@ def price_target( news_base_url : Optional[str] News base URL of the price target. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.estimates.price_target(start_date='2020-01-01', end_date='2024-02-16', limit=10, symbol='msft', provider='benzinga', action=downgrades) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index 19c5e0b9d508..a694f8ec5e04 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -50,16 +50,9 @@ def __repr__(self) -> str: @validate def balance( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - period: Annotated[ - str, OpenBBCustomParameter(description="Time period of the data to return.") - ] = "annual", - limit: Annotated[ - Optional[Annotated[int, Ge(ge=0)]], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 5, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + limit: Annotated[Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return.")] = 5, provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -377,8 +370,8 @@ def balance( total_equity : Optional[int] Total equity (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.balance(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 @@ -406,13 +399,8 @@ def balance( @validate def balance_growth( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 10, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 10, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -530,8 +518,8 @@ def balance_growth( growth_net_debt : float Growth rate of net debt. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.balance_growth(symbol='AAPL', limit=10) """ # noqa: E501 @@ -558,16 +546,9 @@ def balance_growth( @validate def cash( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - period: Annotated[ - str, OpenBBCustomParameter(description="Time period of the data to return.") - ] = "annual", - limit: Annotated[ - Optional[Annotated[int, Ge(ge=0)]], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 5, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + limit: Annotated[Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return.")] = 5, provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -642,10 +623,10 @@ def cash( The date the filing was accepted. (provider: fmp) reported_currency : Optional[str] The currency in which the cash flow statement was reported. (provider: fmp); - The currency in which the balance sheet is reported. (provider: intrinio) + The currency in which the balance sheet is reported. (provider: intrinio) net_income : Optional[float] Net income. (provider: fmp); - Consolidated Net Income. (provider: intrinio) + Consolidated Net Income. (provider: intrinio) depreciation_and_amortization : Optional[float] Depreciation and amortization. (provider: fmp) deferred_income_tax : Optional[float] @@ -793,8 +774,8 @@ def cash( net_cash_flow : Optional[int] Net cash flow. (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.cash(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 @@ -822,13 +803,8 @@ def cash( @validate def cash_growth( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 10, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 10, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -928,8 +904,8 @@ def cash_growth( growth_free_cash_flow : float Growth rate of free cash flow. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.cash_growth(symbol='AAPL', limit=10) """ # noqa: E501 @@ -956,21 +932,9 @@ def cash_growth( @validate def dividends( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -1028,8 +992,8 @@ def dividends( split_ratio : Optional[float] The ratio of the stock split, if a stock split occurred. (provider: intrinio) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.dividends(symbol='AAPL') """ # noqa: E501 @@ -1057,9 +1021,7 @@ def dividends( @validate def employee_count( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -1109,8 +1071,8 @@ def employee_count( source : str Source URL which retrieves this data for the company. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.employee_count(symbol='AAPL') """ # noqa: E501 @@ -1136,27 +1098,17 @@ def employee_count( @validate def filings( self, - symbol: Annotated[ - Optional[str], OpenBBCustomParameter(description="Symbol to get data for.") - ] = None, - form_type: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="Filter by form type. Check the data provider for available types." - ), - ] = None, - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 100, + symbol: Annotated[Optional[str], OpenBBCustomParameter(description="Symbol to get data for.")] = None, + form_type: Annotated[Optional[str], OpenBBCustomParameter(description="Filter by form type. Check the data provider for available types.")] = None, + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 100, provider: Optional[Literal["fmp", "intrinio", "sec"]] = None, **kwargs ) -> OBBject: """Get the URLs to SEC filings reported to EDGAR database, such as 10-K, 10-Q, 8-K, and more. SEC - filings include Form 10-K, Form 10-Q, Form 8-K, the proxy statement, Forms 3, 4, and 5, Schedule 13, Form 114, - Foreign Investment Disclosures and others. The annual 10-K report is required to be - filed annually and includes the company's financial statements, management discussion and analysis, - and audited financial statements. + filings include Form 10-K, Form 10-Q, Form 8-K, the proxy statement, Forms 3, 4, and 5, Schedule 13, Form 114, + Foreign Investment Disclosures and others. The annual 10-K report is required to be + filed annually and includes the company's financial statements, management discussion and analysis, + and audited financial statements. Parameters @@ -1253,8 +1205,8 @@ def filings( filing_detail_url : Optional[str] The URL to the filing details. (provider: sec) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.filings(limit=100) """ # noqa: E501 @@ -1282,46 +1234,14 @@ def filings( @validate def historical_attributes( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): intrinio." - ), - ], - tag: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio." - ), - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - frequency: Annotated[ - Optional[Literal["daily", "weekly", "monthly", "quarterly", "yearly"]], - OpenBBCustomParameter(description="The frequency of the data."), - ] = "yearly", - limit: Annotated[ - Optional[int], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 1000, - tag_type: Annotated[ - Optional[str], - OpenBBCustomParameter(description="Filter by type, when applicable."), - ] = None, - sort: Annotated[ - Optional[Literal["asc", "desc"]], - OpenBBCustomParameter(description="Sort order."), - ] = "desc", + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): intrinio.")], + tag: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio.")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + frequency: Annotated[Optional[Literal["daily", "weekly", "monthly", "quarterly", "yearly"]], OpenBBCustomParameter(description="The frequency of the data.")] = "yearly", + limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 1000, + tag_type: Annotated[Optional[str], OpenBBCustomParameter(description="Filter by type, when applicable.")] = None, + sort: Annotated[Optional[Literal["asc", "desc"]], OpenBBCustomParameter(description="Sort order.")] = "desc", provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -1375,8 +1295,8 @@ def historical_attributes( value : Optional[float] The value of the data. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.historical_attributes(tag='ebitda') """ # noqa: E501 @@ -1402,10 +1322,7 @@ def historical_attributes( "sort": sort, }, extra_params=kwargs, - extra_info={ - "symbol": {"multiple_items_allowed": ["intrinio"]}, - "tag": {"multiple_items_allowed": ["intrinio"]}, - }, + extra_info={"symbol": {"multiple_items_allowed": ["intrinio"]}, "tag": {"multiple_items_allowed": ["intrinio"]}}, ) ) @@ -1413,9 +1330,7 @@ def historical_attributes( @validate def historical_eps( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -1469,8 +1384,8 @@ def historical_eps( period_ending : Optional[date] The fiscal period end date. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.historical_eps(symbol='AAPL') """ # noqa: E501 @@ -1496,9 +1411,7 @@ def historical_eps( @validate def historical_splits( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -1538,8 +1451,8 @@ def historical_splits( denominator : float Denominator of the historical stock splits. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.historical_splits(symbol='AAPL') """ # noqa: E501 @@ -1565,16 +1478,9 @@ def historical_splits( @validate def income( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - period: Annotated[ - str, OpenBBCustomParameter(description="Time period of the data to return.") - ] = "annual", - limit: Annotated[ - Optional[Annotated[int, Ge(ge=0)]], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 5, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + limit: Annotated[Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return.")] = 5, provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -1657,7 +1563,7 @@ def income( Gross profit. (provider: fmp, intrinio, polygon) gross_profit_margin : Optional[float] Gross profit margin. (provider: fmp); - Gross margin ratio. (provider: intrinio) + Gross margin ratio. (provider: intrinio) general_and_admin_expense : Optional[float] General and administrative expenses. (provider: fmp) research_and_development_expense : Optional[float] @@ -1676,15 +1582,15 @@ def income( Interest income. (provider: fmp) total_interest_expense : Optional[float] Total interest expenses. (provider: fmp, intrinio); - Interest Expense (provider: polygon) + Interest Expense (provider: polygon) depreciation_and_amortization : Optional[float] Depreciation and amortization. (provider: fmp, polygon) ebitda : Optional[float] EBITDA. (provider: fmp); - Earnings Before Interest, Taxes, Depreciation and Amortization. (provider: intrinio) + Earnings Before Interest, Taxes, Depreciation and Amortization. (provider: intrinio) ebitda_margin : Optional[float] EBITDA margin. (provider: fmp); - Margin on Earnings Before Interest, Taxes, Depreciation and Amortization. (provider: intrinio) + Margin on Earnings Before Interest, Taxes, Depreciation and Amortization. (provider: intrinio) total_operating_income : Optional[float] Total operating income. (provider: fmp, intrinio) operating_income_margin : Optional[float] @@ -1693,27 +1599,27 @@ def income( Total other income and expenses. (provider: fmp) total_pre_tax_income : Optional[float] Total pre-tax income. (provider: fmp, intrinio); - Income Before Tax (provider: polygon) + Income Before Tax (provider: polygon) pre_tax_income_margin : Optional[float] Pre-tax income margin. (provider: fmp, intrinio) income_tax_expense : Optional[float] Income tax expense. (provider: fmp, intrinio, polygon) consolidated_net_income : Optional[float] Consolidated net income. (provider: fmp, intrinio); - Net Income/Loss (provider: polygon) + Net Income/Loss (provider: polygon) net_income_margin : Optional[float] Net income margin. (provider: fmp) basic_earnings_per_share : Optional[float] Basic earnings per share. (provider: fmp, intrinio); - Earnings Per Share (provider: polygon) + Earnings Per Share (provider: polygon) diluted_earnings_per_share : Optional[float] Diluted earnings per share. (provider: fmp, intrinio, polygon) weighted_average_basic_shares_outstanding : Optional[float] Weighted average basic shares outstanding. (provider: fmp, intrinio); - Basic Average Shares (provider: polygon) + Basic Average Shares (provider: polygon) weighted_average_diluted_shares_outstanding : Optional[float] Weighted average diluted shares outstanding. (provider: fmp, intrinio); - Diluted Average Shares (provider: polygon) + Diluted Average Shares (provider: polygon) link : Optional[str] Link to the filing. (provider: fmp) final_link : Optional[str] @@ -1772,7 +1678,7 @@ def income( Other interest expense (provider: intrinio) net_interest_income : Optional[float] Net interest income (provider: intrinio); - Interest Income Net (provider: polygon) + Interest Income Net (provider: polygon) other_non_interest_income : Optional[float] Other non-interest income (provider: intrinio) investment_banking_income : Optional[float] @@ -1795,7 +1701,7 @@ def income( Other gains (provider: intrinio) non_operating_income : Optional[float] Non-operating income (provider: intrinio); - Non Operating Income/Loss (provider: polygon) + Non Operating Income/Loss (provider: polygon) other_income : Optional[float] Other income (provider: intrinio) other_revenue : Optional[float] @@ -1830,7 +1736,7 @@ def income( Net income attributable to noncontrolling interest (provider: intrinio) net_income_attributable_to_common_shareholders : Optional[float] Net income attributable to common shareholders (provider: intrinio); - Net Income/Loss Available To Common Stockholders Basic (provider: polygon) + Net Income/Loss Available To Common Stockholders Basic (provider: polygon) basic_and_diluted_earnings_per_share : Optional[float] Basic and diluted earnings per share (provider: intrinio) cash_dividends_to_common_per_share : Optional[float] @@ -1894,8 +1800,8 @@ def income( preferred_stock_dividends_and_other_adjustments : Optional[float] Preferred stock dividends and other adjustments (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.income(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 @@ -1923,17 +1829,9 @@ def income( @validate def income_growth( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 10, - period: Annotated[ - Literal["quarter", "annual"], - OpenBBCustomParameter(description="Time period of the data to return."), - ] = "annual", + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 10, + period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -2027,8 +1925,8 @@ def income_growth( growth_weighted_average_shs_out_dil : float Growth rate of diluted weighted average shares outstanding. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.income_growth(symbol='AAPL', limit=10, period='annual') """ # noqa: E501 @@ -2056,18 +1954,8 @@ def income_growth( @validate def latest_attributes( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): intrinio." - ), - ], - tag: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): intrinio.")], + tag: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio.")], provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -2107,8 +1995,8 @@ def latest_attributes( value : Optional[Union[str, float]] The value of the data. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.latest_attributes(tag='ceo') """ # noqa: E501 @@ -2128,10 +2016,7 @@ def latest_attributes( "tag": tag, }, extra_params=kwargs, - extra_info={ - "symbol": {"multiple_items_allowed": ["intrinio"]}, - "tag": {"multiple_items_allowed": ["intrinio"]}, - }, + extra_info={"symbol": {"multiple_items_allowed": ["intrinio"]}, "tag": {"multiple_items_allowed": ["intrinio"]}}, ) ) @@ -2139,9 +2024,7 @@ def latest_attributes( @validate def management( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -2191,8 +2074,8 @@ def management( unexercised_value : Optional[int] Value of shares not exercised. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.management(symbol='AAPL') """ # noqa: E501 @@ -2218,24 +2101,9 @@ def management( @validate def management_compensation( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp." - ), - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -2297,8 +2165,8 @@ def management_compensation( url : str URL of the filing data. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.management_compensation(symbol='AAPL') """ # noqa: E501 @@ -2327,20 +2195,9 @@ def management_compensation( @validate def metrics( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp, yfinance." - ), - ], - period: Annotated[ - Optional[Literal["annual", "quarter"]], - OpenBBCustomParameter(description="Time period of the data to return."), - ] = "annual", - limit: Annotated[ - Optional[int], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 100, + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp, yfinance.")], + period: Annotated[Optional[Literal["annual", "quarter"]], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 100, provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -2501,7 +2358,7 @@ def metrics( Capital expenditures per share (provider: fmp) beta : Optional[float] Beta relative to the broad market calculated on a rolling three-year basis. (provider: intrinio); - Beta relative to the broad market (5-year monthly). (provider: yfinance) + Beta relative to the broad market (5-year monthly). (provider: yfinance) volume : Optional[float] Volume (provider: intrinio) fifty_two_week_high : Optional[float] @@ -2563,8 +2420,8 @@ def metrics( currency : Optional[str] Currency in which the data is presented. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.metrics(symbol='AAPL', period='annual', limit=100) """ # noqa: E501 @@ -2593,12 +2450,7 @@ def metrics( @validate def multiples( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -2752,8 +2604,8 @@ def multiples( capex_per_share_ttm : Optional[float] Capital expenditures per share calculated as trailing twelve months. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.multiples(symbol='AAPL') """ # noqa: E501 @@ -2784,9 +2636,7 @@ def multiples( ) def overview( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -2890,18 +2740,14 @@ def overview( is_fund : bool If the company is a fund. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.overview(symbol='AAPL') """ # noqa: E501 simplefilter("always", DeprecationWarning) - warn( - "This endpoint is deprecated; use `/equity/profile` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.", - category=DeprecationWarning, - stacklevel=2, - ) + warn("This endpoint is deprecated; use `/equity/profile` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.", category=DeprecationWarning, stacklevel=2) return self._run( "/equity/fundamental/overview", @@ -2924,16 +2770,9 @@ def overview( @validate def ratios( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - period: Annotated[ - str, OpenBBCustomParameter(description="Time period of the data to return.") - ] = "annual", - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 12, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 12, provider: Optional[Literal["fmp", "intrinio"]] = None, **kwargs ) -> OBBject: @@ -3089,8 +2928,8 @@ def ratios( price_fair_value : Optional[float] Price fair value. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.ratios(symbol='AAPL', period='annual', limit=12) """ # noqa: E501 @@ -3118,24 +2957,10 @@ def ratios( @validate def reported_financials( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - period: Annotated[ - str, OpenBBCustomParameter(description="Time period of the data to return.") - ] = "annual", - statement_type: Annotated[ - str, - OpenBBCustomParameter( - description="The type of financial statement - i.e, balance, income, cash." - ), - ] = "balance", - limit: Annotated[ - Optional[int], - OpenBBCustomParameter( - description="The number of data entries to return. Although the response object contains multiple results, because of the variance in the fields, year-to-year and quarter-to-quarter, it is recommended to view results in small chunks." - ), - ] = 100, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + statement_type: Annotated[str, OpenBBCustomParameter(description="The type of financial statement - i.e, balance, income, cash.")] = "balance", + limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return. Although the response object contains multiple results, because of the variance in the fields, year-to-year and quarter-to-quarter, it is recommended to view results in small chunks.")] = 100, provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -3181,8 +3006,8 @@ def reported_financials( fiscal_year : Optional[int] The fiscal year of the fiscal period. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.reported_financials(symbol='AAPL', period='annual', statement_type='balance', limit=100) >>> # Get reported income statement @@ -3215,17 +3040,9 @@ def reported_financials( @validate def revenue_per_geography( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - period: Annotated[ - Literal["quarter", "annual"], - OpenBBCustomParameter(description="Time period of the data to return."), - ] = "annual", - structure: Annotated[ - Literal["hierarchical", "flat"], - OpenBBCustomParameter(description="Structure of the returned data."), - ] = "flat", + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + structure: Annotated[Literal["hierarchical", "flat"], OpenBBCustomParameter(description="Structure of the returned data.")] = "flat", provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -3271,8 +3088,8 @@ def revenue_per_geography( geographic_segment : int Dictionary of the revenue by geographic segment. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.revenue_per_geography(symbol='AAPL', period='annual', structure='flat') """ # noqa: E501 @@ -3300,17 +3117,9 @@ def revenue_per_geography( @validate def revenue_per_segment( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - period: Annotated[ - Literal["quarter", "annual"], - OpenBBCustomParameter(description="Time period of the data to return."), - ] = "annual", - structure: Annotated[ - Literal["hierarchical", "flat"], - OpenBBCustomParameter(description="Structure of the returned data."), - ] = "flat", + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + structure: Annotated[Literal["hierarchical", "flat"], OpenBBCustomParameter(description="Structure of the returned data.")] = "flat", provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -3356,8 +3165,8 @@ def revenue_per_segment( business_line : int Dictionary containing the revenue of the business line. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.revenue_per_segment(symbol='AAPL', period='annual', structure='flat') """ # noqa: E501 @@ -3385,13 +3194,8 @@ def revenue_per_segment( @validate def search_attributes( self, - query: Annotated[ - str, OpenBBCustomParameter(description="Query to search for.") - ], - limit: Annotated[ - Optional[int], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 1000, + query: Annotated[str, OpenBBCustomParameter(description="Query to search for.")], + limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 1000, provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -3447,8 +3251,8 @@ def search_attributes( unit : Optional[str] Unit of the financial attribute. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.search_attributes(query='ebitda') """ # noqa: E501 @@ -3475,15 +3279,8 @@ def search_attributes( @validate def trailing_dividend_yield( self, - symbol: Annotated[ - Optional[str], OpenBBCustomParameter(description="Symbol to get data for.") - ] = None, - limit: Annotated[ - Optional[int], - OpenBBCustomParameter( - description="The number of data entries to return. Default is 252, the number of trading days in a year." - ), - ] = 252, + symbol: Annotated[Optional[str], OpenBBCustomParameter(description="Symbol to get data for.")] = None, + limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return. Default is 252, the number of trading days in a year.")] = 252, provider: Optional[Literal["tiingo"]] = None, **kwargs ) -> OBBject: @@ -3521,8 +3318,8 @@ def trailing_dividend_yield( trailing_dividend_yield : float Trailing dividend yield. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.trailing_dividend_yield(symbol='AAPL', limit=252) """ # noqa: E501 @@ -3549,13 +3346,8 @@ def trailing_dividend_yield( @validate def transcript( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - year: Annotated[ - int, - OpenBBCustomParameter(description="Year of the earnings call transcript."), - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + year: Annotated[int, OpenBBCustomParameter(description="Year of the earnings call transcript.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -3599,8 +3391,8 @@ def transcript( content : str Content of the earnings call transcript. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.fundamental.transcript(symbol='AAPL', year=2020) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index 4a19d2462b69..8898ec2ef4cf 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -26,13 +26,8 @@ def __repr__(self) -> str: @validate def insider_trading( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 500, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 500, provider: Optional[Literal["fmp", "intrinio"]] = None, **kwargs ) -> OBBject: @@ -134,8 +129,8 @@ def insider_trading( report_line_number : Optional[int] Report line number of the insider trading. (provider: intrinio) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.ownership.insider_trading(symbol='AAPL', limit=500) """ # noqa: E501 @@ -162,9 +157,7 @@ def insider_trading( @validate def institutional( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -272,8 +265,8 @@ def institutional( put_call_ratio_change : Optional[float] Change in the put-call ratio between the current and previous reporting dates. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.ownership.institutional(symbol='AAPL') """ # noqa: E501 @@ -299,17 +292,9 @@ def institutional( @validate def major_holders( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter(description="A specific date to get data for."), - ] = None, - page: Annotated[ - Optional[int], - OpenBBCustomParameter(description="Page number of the data to fetch."), - ] = 0, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="A specific date to get data for.")] = None, + page: Annotated[Optional[int], OpenBBCustomParameter(description="Page number of the data to fetch.")] = 0, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -423,8 +408,8 @@ def major_holders( is_counted_for_performance : bool Is the stock ownership counted for performance. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.ownership.major_holders(symbol='AAPL', page=0) """ # noqa: E501 @@ -452,12 +437,7 @@ def major_holders( @validate def share_statistics( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): yfinance.")], provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -525,8 +505,8 @@ def share_statistics( institutions_count : Optional[int] Number of institutions holding shares. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.ownership.share_statistics(symbol='AAPL') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py index 35d15ca4f164..ef0d385a0070 100644 --- a/openbb_platform/openbb/package/equity_price.py +++ b/openbb_platform/openbb/package/equity_price.py @@ -26,31 +26,11 @@ def __repr__(self) -> str: @validate def historical( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance." - ), - ], - interval: Annotated[ - Optional[str], - OpenBBCustomParameter(description="Time interval of the data to return."), - ] = "1d", - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - provider: Optional[ - Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"] - ] = None, + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance.")], + interval: Annotated[Optional[str], OpenBBCustomParameter(description="Time interval of the data to return.")] = "1d", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + provider: Optional[Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"]] = None, **kwargs ) -> OBBject: """Get historical price data for a given stock. This includes open, high, low, close, and volume. @@ -71,7 +51,7 @@ def historical( no default. limit : Optional[Union[Annotated[int, Ge(ge=0)], int]] Number of days to look back (Only for interval 1d). (provider: fmp); - The number of data entries to return. (provider: polygon) + The number of data entries to return. (provider: polygon) start_time : Optional[datetime.time] Return intervals starting at the specified time on the `start_date` formatted as 'HH:MM:SS'. (provider: intrinio) end_time : Optional[datetime.time] @@ -84,7 +64,7 @@ def historical( Sort order of the data. (provider: polygon) adjusted : bool Output time series is adjusted by historical split and dividend events. (provider: polygon); - Adjust all OHLC data automatically. (provider: yfinance) + Adjust all OHLC data automatically. (provider: yfinance) prepost : bool Include Pre and Post market data. (provider: yfinance) include : bool @@ -126,8 +106,8 @@ def historical( Human readable format of the date. (provider: fmp) adj_close : Optional[float] The adjusted close price. (provider: fmp); - Adjusted closing price during the period. (provider: intrinio); - Adjusted closing price during the period. (provider: tiingo) + Adjusted closing price during the period. (provider: intrinio); + Adjusted closing price during the period. (provider: tiingo) unadjusted_volume : Optional[float] Unadjusted volume of the symbol. (provider: fmp) change : Optional[float] @@ -167,8 +147,8 @@ def historical( transactions : Optional[Annotated[int, Gt(gt=0)]] Number of transactions for the symbol in the time period. (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.price.historical(symbol='AAPL', interval='1d') """ # noqa: E501 @@ -190,16 +170,7 @@ def historical( "end_date": end_date, }, extra_params=kwargs, - extra_info={ - "symbol": { - "multiple_items_allowed": [ - "fmp", - "polygon", - "tiingo", - "yfinance", - ] - } - }, + extra_info={"symbol": {"multiple_items_allowed": ["fmp", "polygon", "tiingo", "yfinance"]}}, ) ) @@ -207,9 +178,7 @@ def historical( @validate def nbbo( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["polygon"]] = None, **kwargs ) -> OBBject: @@ -229,26 +198,26 @@ def nbbo( A specific date to get data for. Use bracketed the timestamp parameters to specify exact time ranges. (provider: polygon) timestamp_lt : Optional[Union[datetime.datetime, str]] - Query by datetime, less than. Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, - YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. - (provider: polygon) + Query by datetime, less than. Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, + YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. + (provider: polygon) timestamp_gt : Optional[Union[datetime.datetime, str]] - Query by datetime, greater than. Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, - YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. - (provider: polygon) + Query by datetime, greater than. Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, + YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. + (provider: polygon) timestamp_lte : Optional[Union[datetime.datetime, str]] - Query by datetime, less than or equal to. - Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, - YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. - (provider: polygon) + Query by datetime, less than or equal to. + Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, + YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. + (provider: polygon) timestamp_gte : Optional[Union[datetime.datetime, str]] - Query by datetime, greater than or equal to. - Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, - YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. - (provider: polygon) + Query by datetime, greater than or equal to. + Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, + YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. + (provider: polygon) Returns ------- @@ -272,9 +241,9 @@ def nbbo( The last ask price. ask_size : int - The ask size. This represents the number of round lot orders at the given ask price. - The normal round lot size is 100 shares. - An ask size of 2 means there are 200 shares available to purchase at the given ask price. + The ask size. This represents the number of round lot orders at the given ask price. + The normal round lot size is 100 shares. + An ask size of 2 means there are 200 shares available to purchase at the given ask price. bid_size : int The bid size in round lots. @@ -290,28 +259,28 @@ def nbbo( A list of indicator codes. (provider: polygon) sequence_num : Optional[int] - The sequence number represents the sequence in which message events happened. - These are increasing and unique per ticker symbol, but will not always be sequential - (e.g., 1, 2, 6, 9, 10, 11) - (provider: polygon) + The sequence number represents the sequence in which message events happened. + These are increasing and unique per ticker symbol, but will not always be sequential + (e.g., 1, 2, 6, 9, 10, 11) + (provider: polygon) participant_timestamp : Optional[datetime] - The nanosecond accuracy Participant/Exchange Unix Timestamp. - This is the timestamp of when the quote was actually generated at the exchange. - (provider: polygon) + The nanosecond accuracy Participant/Exchange Unix Timestamp. + This is the timestamp of when the quote was actually generated at the exchange. + (provider: polygon) sip_timestamp : Optional[datetime] - The nanosecond accuracy SIP Unix Timestamp. - This is the timestamp of when the SIP received this quote from the exchange which produced it. - (provider: polygon) + The nanosecond accuracy SIP Unix Timestamp. + This is the timestamp of when the SIP received this quote from the exchange which produced it. + (provider: polygon) trf_timestamp : Optional[datetime] - The nanosecond accuracy TRF (Trade Reporting Facility) Unix Timestamp. - This is the timestamp of when the trade reporting facility received this quote. - (provider: polygon) + The nanosecond accuracy TRF (Trade Reporting Facility) Unix Timestamp. + This is the timestamp of when the trade reporting facility received this quote. + (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.price.nbbo(symbol='AAPL') """ # noqa: E501 @@ -337,12 +306,7 @@ def nbbo( @validate def performance( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -404,8 +368,8 @@ def performance( symbol : Optional[str] The ticker symbol. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.price.performance(symbol='AAPL') """ # noqa: E501 @@ -432,12 +396,7 @@ def performance( @validate def quote( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance.")], provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -571,8 +530,8 @@ def quote( currency : Optional[str] Currency of the price. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.price.quote(symbol='AAPL') """ # noqa: E501 @@ -591,10 +550,6 @@ def quote( "symbol": symbol, }, extra_params=kwargs, - extra_info={ - "symbol": { - "multiple_items_allowed": ["fmp", "intrinio", "yfinance"] - } - }, + extra_info={"symbol": {"multiple_items_allowed": ["fmp", "intrinio", "yfinance"]}}, ) ) diff --git a/openbb_platform/openbb/package/equity_shorts.py b/openbb_platform/openbb/package/equity_shorts.py index 3bf1f10b5d1d..a3f3e7e53223 100644 --- a/openbb_platform/openbb/package/equity_shorts.py +++ b/openbb_platform/openbb/package/equity_shorts.py @@ -22,9 +22,7 @@ def __repr__(self) -> str: @validate def fails_to_deliver( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -40,13 +38,13 @@ def fails_to_deliver( no default. limit : Optional[int] - Limit the number of reports to parse, from most recent. - Approximately 24 reports per year, going back to 2009. - (provider: sec) + Limit the number of reports to parse, from most recent. + Approximately 24 reports per year, going back to 2009. + (provider: sec) skip_reports : Optional[int] - Skip N number of reports from current. A value of 1 will skip the most recent report. - (provider: sec) + Skip N number of reports from current. A value of 1 will skip the most recent report. + (provider: sec) Returns ------- @@ -77,8 +75,8 @@ def fails_to_deliver( description : Optional[str] The description of the Security. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.equity.shorts.fails_to_deliver(symbol='AAPL') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index 939d3c529142..f25d3109e71e 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -32,12 +32,7 @@ def __repr__(self) -> str: @validate def countries( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -71,8 +66,8 @@ def countries( country : str The country of the exposure. Corresponding values are normalized percentage points. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.countries(symbol='VT', provider='fmp') """ # noqa: E501 @@ -99,12 +94,7 @@ def countries( @validate def equity_exposure( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. (Stock) Multiple items allowed for provider(s): fmp." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. (Stock) Multiple items allowed for provider(s): fmp.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -146,8 +136,8 @@ def equity_exposure( market_value : Optional[Union[float, int]] The market value of the equity position in the ETF. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.equity_exposure(symbol='MSFT', provider='fmp') >>> # This function accepts multiple tickers. @@ -176,21 +166,9 @@ def equity_exposure( @validate def historical( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -240,8 +218,8 @@ def historical( adj_close : Optional[float] The adjusted closing price of the ETF. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.historical(symbol='SPY') >>> obb.etf.historical(symbol='SPY', provider='yfinance') @@ -272,9 +250,7 @@ def historical( @validate def holdings( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)")], provider: Optional[Literal["fmp", "sec"]] = None, **kwargs ) -> OBBject: @@ -290,7 +266,7 @@ def holdings( no default. date : Optional[Union[str, datetime.date]] A specific date to get data for. Entering a date will attempt to return the NPORT-P filing for the entered date. This needs to be _exactly_ the date of the filing. Use the holdings_date command/endpoint to find available filing dates for the ETF. (provider: fmp); - A specific date to get data for. The date represents the period ending. The date entered will return the closest filing. (provider: sec) + A specific date to get data for. The date represents the period ending. The date entered will return the closest filing. (provider: sec) cik : Optional[str] The CIK of the filing entity. Overrides symbol. (provider: fmp) use_cache : bool @@ -326,17 +302,17 @@ def holdings( The ISIN of the holding. (provider: fmp, sec) balance : Optional[int] The balance of the holding, in shares or units. (provider: fmp); - The balance of the holding. (provider: sec) + The balance of the holding. (provider: sec) units : Optional[Union[str, float]] The type of units. (provider: fmp); - The units of the holding. (provider: sec) + The units of the holding. (provider: sec) currency : Optional[str] The currency of the holding. (provider: fmp, sec) value : Optional[float] The value of the holding, in dollars. (provider: fmp, sec) weight : Optional[float] The weight of the holding, as a normalized percent. (provider: fmp); - The weight of the holding in ETF in %. (provider: sec) + The weight of the holding in ETF in %. (provider: sec) payoff_profile : Optional[str] The payoff profile of the holding. (provider: fmp, sec) asset_category : Optional[str] @@ -474,8 +450,8 @@ def holdings( unrealized_gain : Optional[float] The unrealized gain or loss on the derivative. (provider: sec) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.holdings(symbol='XLK', provider='fmp') >>> # Including a date (FMP, SEC) will return the holdings as per NPORT-P filings. @@ -505,9 +481,7 @@ def holdings( @validate def holdings_date( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -543,8 +517,8 @@ def holdings_date( date : date The date of the data. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.holdings_date(symbol='XLK', provider='fmp') """ # noqa: E501 @@ -570,12 +544,7 @@ def holdings_date( @validate def holdings_performance( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -637,8 +606,8 @@ def holdings_performance( symbol : Optional[str] The ticker symbol. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.holdings_performance(symbol='XLK', provider='fmp') """ # noqa: E501 @@ -665,12 +634,7 @@ def holdings_performance( @validate def info( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance.")], provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -796,8 +760,8 @@ def info( prev_close : Optional[float] The previous closing price. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.info(symbol='SPY', provider='fmp') >>> # This function accepts multiple tickers. @@ -826,12 +790,7 @@ def info( @validate def price_performance( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp." - ), - ], + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -893,8 +852,8 @@ def price_performance( symbol : Optional[str] The ticker symbol. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.price_performance(symbol='SPY,QQQ,IWM,DJIA', provider='fmp') """ # noqa: E501 @@ -921,15 +880,13 @@ def price_performance( @validate def search( self, - query: Annotated[ - Optional[str], OpenBBCustomParameter(description="Search query.") - ] = "", + query: Annotated[Optional[str], OpenBBCustomParameter(description="Search query.")] = "", provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Search for ETFs. - An empty query returns the full list of ETFs from the provider. + An empty query returns the full list of ETFs from the provider. Parameters @@ -988,8 +945,8 @@ def search( actively_trading : Optional[Literal[True, False]] Whether the ETF is actively trading. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> # An empty query returns the full list of ETFs from the provider. >>> obb.etf.search() @@ -1018,9 +975,7 @@ def search( @validate def sectors( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -1056,8 +1011,8 @@ def sectors( weight : Optional[float] Exposure of the ETF to the sector in normalized percentage points. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.etf.sectors(symbol='SPY', provider='fmp') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index 94d8b8c901d5..ece316bdd4e2 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -28,51 +28,35 @@ def corporate(self): # pylint: disable=import-outside-toplevel from . import fixedincome_corporate - return fixedincome_corporate.ROUTER_fixedincome_corporate( - command_runner=self._command_runner - ) + return fixedincome_corporate.ROUTER_fixedincome_corporate(command_runner=self._command_runner) @property def government(self): # pylint: disable=import-outside-toplevel from . import fixedincome_government - return fixedincome_government.ROUTER_fixedincome_government( - command_runner=self._command_runner - ) + return fixedincome_government.ROUTER_fixedincome_government(command_runner=self._command_runner) @property def rate(self): # pylint: disable=import-outside-toplevel from . import fixedincome_rate - return fixedincome_rate.ROUTER_fixedincome_rate( - command_runner=self._command_runner - ) + return fixedincome_rate.ROUTER_fixedincome_rate(command_runner=self._command_runner) @exception_handler @validate def sofr( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Secured Overnight Financing Rate. - The Secured Overnight Financing Rate (SOFR) is a broad measure of the cost of - borrowing cash overnight collateralizing by Treasury securities. + The Secured Overnight Financing Rate (SOFR) is a broad measure of the cost of + borrowing cash overnight collateralizing by Treasury securities. Parameters @@ -109,8 +93,8 @@ def sofr( rate : Optional[float] SOFR rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.sofr(period='overnight') """ # noqa: E501 @@ -138,6 +122,4 @@ def spreads(self): # pylint: disable=import-outside-toplevel from . import fixedincome_spreads - return fixedincome_spreads.ROUTER_fixedincome_spreads( - command_runner=self._command_runner - ) + return fixedincome_spreads.ROUTER_fixedincome_spreads(command_runner=self._command_runner) diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index 099824f8edad..9b4dbe615ab8 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -27,38 +27,20 @@ def __repr__(self) -> str: @validate def commercial_paper( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - maturity: Annotated[ - Literal["overnight", "7d", "15d", "30d", "60d", "90d"], - OpenBBCustomParameter(description="The maturity."), - ] = "30d", - category: Annotated[ - Literal["asset_backed", "financial", "nonfinancial"], - OpenBBCustomParameter(description="The category."), - ] = "financial", - grade: Annotated[ - Literal["aa", "a2_p2"], OpenBBCustomParameter(description="The grade.") - ] = "aa", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + maturity: Annotated[Literal["overnight", "7d", "15d", "30d", "60d", "90d"], OpenBBCustomParameter(description="The maturity.")] = "30d", + category: Annotated[Literal["asset_backed", "financial", "nonfinancial"], OpenBBCustomParameter(description="The category.")] = "financial", + grade: Annotated[Literal["aa", "a2_p2"], OpenBBCustomParameter(description="The grade.")] = "aa", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Commercial Paper. - Commercial paper (CP) consists of short-term, promissory notes issued primarily by corporations. - Maturities range up to 270 days but average about 30 days. - Many companies use CP to raise cash needed for current transactions, - and many find it to be a lower-cost alternative to bank loans. + Commercial paper (CP) consists of short-term, promissory notes issued primarily by corporations. + Maturities range up to 270 days but average about 30 days. + Many companies use CP to raise cash needed for current transactions, + and many find it to be a lower-cost alternative to bank loans. Parameters @@ -99,8 +81,8 @@ def commercial_paper( rate : Optional[float] Commercial Paper Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.corporate.commercial_paper(maturity='15d') """ # noqa: E501 @@ -130,23 +112,17 @@ def commercial_paper( @validate def hqm( self, - date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter(description="A specific date to get data for."), - ] = None, - yield_curve: Annotated[ - Literal["spot", "par"], - OpenBBCustomParameter(description="The yield curve type."), - ] = "spot", + date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="A specific date to get data for.")] = None, + yield_curve: Annotated[Literal["spot", "par"], OpenBBCustomParameter(description="The yield curve type.")] = "spot", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """High Quality Market Corporate Bond. - The HQM yield curve represents the high quality corporate bond market, i.e., - corporate bonds rated AAA, AA, or A. The HQM curve contains two regression terms. - These terms are adjustment factors that blend AAA, AA, and A bonds into a single HQM yield curve - that is the market-weighted average (MWA) quality of high quality bonds. + The HQM yield curve represents the high quality corporate bond market, i.e., + corporate bonds rated AAA, AA, or A. The HQM curve contains two regression terms. + These terms are adjustment factors that blend AAA, AA, and A bonds into a single HQM yield curve + that is the market-weighted average (MWA) quality of high quality bonds. Parameters @@ -187,8 +163,8 @@ def hqm( series_id : Optional[str] FRED series id. (provider: fred) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.corporate.hqm(yield_curve='par') """ # noqa: E501 @@ -215,32 +191,19 @@ def hqm( @validate def ice_bofa( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - index_type: Annotated[ - Literal["yield", "yield_to_worst", "total_return", "spread"], - OpenBBCustomParameter(description="The type of series."), - ] = "yield", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + index_type: Annotated[Literal["yield", "yield_to_worst", "total_return", "spread"], OpenBBCustomParameter(description="The type of series.")] = "yield", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """ICE BofA US Corporate Bond Indices. - The ICE BofA US Corporate Index tracks the performance of US dollar denominated investment grade corporate debt - publicly issued in the US domestic market. Qualifying securities must have an investment grade rating (based on an - average of Moody’s, S&P and Fitch), at least 18 months to final maturity at the time of issuance, at least one year - remaining term to final maturity as of the rebalance date, a fixed coupon schedule and a minimum amount - outstanding of $250 million. The ICE BofA US Corporate Index is a component of the US Corporate Master Index. + The ICE BofA US Corporate Index tracks the performance of US dollar denominated investment grade corporate debt + publicly issued in the US domestic market. Qualifying securities must have an investment grade rating (based on an + average of Moody’s, S&P and Fitch), at least 18 months to final maturity at the time of issuance, at least one year + remaining term to final maturity as of the rebalance date, a fixed coupon schedule and a minimum amount + outstanding of $250 million. The ICE BofA US Corporate Index is a component of the US Corporate Master Index. Parameters @@ -285,8 +248,8 @@ def ice_bofa( rate : Optional[float] ICE BofA US Corporate Bond Indices Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst') """ # noqa: E501 @@ -314,31 +277,18 @@ def ice_bofa( @validate def moody( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - index_type: Annotated[ - Literal["aaa", "baa"], - OpenBBCustomParameter(description="The type of series."), - ] = "aaa", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + index_type: Annotated[Literal["aaa", "baa"], OpenBBCustomParameter(description="The type of series.")] = "aaa", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Moody Corporate Bond Index. - Moody's Aaa and Baa are investment bonds that acts as an index of - the performance of all bonds given an Aaa or Baa rating by Moody's Investors Service respectively. - These corporate bonds often are used in macroeconomics as an alternative to the federal ten-year - Treasury Bill as an indicator of the interest rate. + Moody's Aaa and Baa are investment bonds that acts as an index of + the performance of all bonds given an Aaa or Baa rating by Moody's Investors Service respectively. + These corporate bonds often are used in macroeconomics as an alternative to the federal ten-year + Treasury Bill as an indicator of the interest rate. Parameters @@ -377,8 +327,8 @@ def moody( rate : Optional[float] Moody Corporate Bond Index Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.corporate.moody(index_type='baa') """ # noqa: E501 @@ -406,34 +356,19 @@ def moody( @validate def spot_rates( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - maturity: Annotated[ - List[float], OpenBBCustomParameter(description="The maturities in years.") - ] = [10.0], - category: Annotated[ - List[Literal["par_yield", "spot_rate"]], - OpenBBCustomParameter(description="The category."), - ] = ["spot_rate"], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + maturity: Annotated[List[float], OpenBBCustomParameter(description="The maturities in years.")] = [10.0], + category: Annotated[List[Literal["par_yield", "spot_rate"]], OpenBBCustomParameter(description="The category.")] = ["spot_rate"], provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Spot Rates. - The spot rates for any maturity is the yield on a bond that provides a single payment at that maturity. - This is a zero coupon bond. - Because each spot rate pertains to a single cashflow, it is the relevant interest rate - concept for discounting a pension liability at the same maturity. + The spot rates for any maturity is the yield on a bond that provides a single payment at that maturity. + This is a zero coupon bond. + Because each spot rate pertains to a single cashflow, it is the relevant interest rate + concept for discounting a pension liability at the same maturity. Parameters @@ -472,8 +407,8 @@ def spot_rates( rate : Optional[float] Spot Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.corporate.spot_rates(maturity=[10, 20, 30, 50]) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/fixedincome_government.py b/openbb_platform/openbb/package/fixedincome_government.py index 5adc53259cc9..d488f93554f8 100644 --- a/openbb_platform/openbb/package/fixedincome_government.py +++ b/openbb_platform/openbb/package/fixedincome_government.py @@ -24,18 +24,8 @@ def __repr__(self) -> str: @validate def treasury_rates( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["federal_reserve", "fmp"]] = None, **kwargs ) -> OBBject: @@ -97,8 +87,8 @@ def treasury_rates( year_30 : Optional[float] 30 year Treasury rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.government.treasury_rates(provider='federal_reserve') """ # noqa: E501 @@ -125,16 +115,8 @@ def treasury_rates( @validate def us_yield_curve( self, - date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="A specific date to get data for. Defaults to the most recent FRED entry." - ), - ] = None, - inflation_adjusted: Annotated[ - Optional[bool], - OpenBBCustomParameter(description="Get inflation adjusted rates."), - ] = False, + date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="A specific date to get data for. Defaults to the most recent FRED entry.")] = None, + inflation_adjusted: Annotated[Optional[bool], OpenBBCustomParameter(description="Get inflation adjusted rates.")] = False, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: @@ -172,8 +154,8 @@ def us_yield_curve( rate : float Associated rate given in decimal form (0.05 is 5%) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.government.us_yield_curve(inflation_adjusted=True) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/fixedincome_rate.py b/openbb_platform/openbb/package/fixedincome_rate.py index 4e60f246222f..971ea31f4837 100644 --- a/openbb_platform/openbb/package/fixedincome_rate.py +++ b/openbb_platform/openbb/package/fixedincome_rate.py @@ -30,26 +30,16 @@ def __repr__(self) -> str: @validate def ameribor( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Ameribor. - Ameribor (short for the American interbank offered rate) is a benchmark interest rate that reflects the true cost of - short-term interbank borrowing. This rate is based on transactions in overnight unsecured loans conducted on the - American Financial Exchange (AFX). + Ameribor (short for the American interbank offered rate) is a benchmark interest rate that reflects the true cost of + short-term interbank borrowing. This rate is based on transactions in overnight unsecured loans conducted on the + American Financial Exchange (AFX). Parameters @@ -86,8 +76,8 @@ def ameribor( rate : Optional[float] AMERIBOR rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma') """ # noqa: E501 @@ -114,27 +104,17 @@ def ameribor( @validate def dpcredit( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Discount Window Primary Credit Rate. - A bank rate is the interest rate a nation's central bank charges to its domestic banks to borrow money. - The rates central banks charge are set to stabilize the economy. - In the United States, the Federal Reserve System's Board of Governors set the bank rate, - also known as the discount rate. + A bank rate is the interest rate a nation's central bank charges to its domestic banks to borrow money. + The rates central banks charge are set to stabilize the economy. + In the United States, the Federal Reserve System's Board of Governors set the bank rate, + also known as the discount rate. Parameters @@ -171,8 +151,8 @@ def dpcredit( rate : Optional[float] Discount Window Primary Credit Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') """ # noqa: E501 @@ -199,33 +179,20 @@ def dpcredit( @validate def ecb( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - interest_rate_type: Annotated[ - Literal["deposit", "lending", "refinancing"], - OpenBBCustomParameter(description="The type of interest rate."), - ] = "lending", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + interest_rate_type: Annotated[Literal["deposit", "lending", "refinancing"], OpenBBCustomParameter(description="The type of interest rate.")] = "lending", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """European Central Bank Interest Rates. - The Governing Council of the ECB sets the key interest rates for the euro area: + The Governing Council of the ECB sets the key interest rates for the euro area: - - The interest rate on the main refinancing operations (MRO), which provide - the bulk of liquidity to the banking system. - - The rate on the deposit facility, which banks may use to make overnight deposits with the Eurosystem. - - The rate on the marginal lending facility, which offers overnight credit to banks from the Eurosystem. + - The interest rate on the main refinancing operations (MRO), which provide + the bulk of liquidity to the banking system. + - The rate on the deposit facility, which banks may use to make overnight deposits with the Eurosystem. + - The rate on the marginal lending facility, which offers overnight credit to banks from the Eurosystem. Parameters @@ -262,8 +229,8 @@ def ecb( rate : Optional[float] European Central Bank Interest Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing') """ # noqa: E501 @@ -291,26 +258,16 @@ def ecb( @validate def effr( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["federal_reserve", "fred"]] = None, **kwargs ) -> OBBject: """Fed Funds Rate. - Get Effective Federal Funds Rate data. A bank rate is the interest rate a nation's central bank charges to its - domestic banks to borrow money. The rates central banks charge are set to stabilize the economy. In the - United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. + Get Effective Federal Funds Rate data. A bank rate is the interest rate a nation's central bank charges to its + domestic banks to borrow money. The rates central banks charge are set to stabilize the economy. In the + United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. Parameters @@ -347,8 +304,8 @@ def effr( rate : Optional[float] FED rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.rate.effr(parameter='daily', provider='fred') """ # noqa: E501 @@ -374,14 +331,16 @@ def effr( @exception_handler @validate def effr_forecast( - self, provider: Optional[Literal["fred"]] = None, **kwargs + self, + provider: Optional[Literal["fred"]] = None, + **kwargs ) -> OBBject: """Fed Funds Rate Projections. - The projections for the federal funds rate are the value of the midpoint of the - projected appropriate target range for the federal funds rate or the projected - appropriate target level for the federal funds rate at the end of the specified - calendar year or over the longer run. + The projections for the federal funds rate are the value of the midpoint of the + projected appropriate target range for the federal funds rate or the projected + appropriate target level for the federal funds rate at the end of the specified + calendar year or over the longer run. Parameters @@ -426,8 +385,8 @@ def effr_forecast( central_tendency_low : Optional[float] Central tendency of low projection of rates. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.rate.effr_forecast(long_run=True) """ # noqa: E501 @@ -442,7 +401,8 @@ def effr_forecast( ("fred",), ) }, - standard_params={}, + standard_params={ + }, extra_params=kwargs, ) ) @@ -451,27 +411,17 @@ def effr_forecast( @validate def estr( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Euro Short-Term Rate. - The euro short-term rate (€STR) reflects the wholesale euro unsecured overnight borrowing costs of banks located in - the euro area. The €STR is published on each TARGET2 business day based on transactions conducted and settled on - the previous TARGET2 business day (the reporting date “T”) with a maturity date of T+1 which are deemed to have been - executed at arm’s length and thus reflect market rates in an unbiased way. + The euro short-term rate (€STR) reflects the wholesale euro unsecured overnight borrowing costs of banks located in + the euro area. The €STR is published on each TARGET2 business day based on transactions conducted and settled on + the previous TARGET2 business day (the reporting date “T”) with a maturity date of T+1 which are deemed to have been + executed at arm’s length and thus reflect market rates in an unbiased way. Parameters @@ -508,8 +458,8 @@ def estr( rate : Optional[float] ESTR rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks') """ # noqa: E501 @@ -536,26 +486,16 @@ def estr( @validate def iorb( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Interest on Reserve Balances. - Get Interest Rate on Reserve Balances data A bank rate is the interest rate a nation's central bank charges to its - domestic banks to borrow money. The rates central banks charge are set to stabilize the economy. In the - United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. + Get Interest Rate on Reserve Balances data A bank rate is the interest rate a nation's central bank charges to its + domestic banks to borrow money. The rates central banks charge are set to stabilize the economy. In the + United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. Parameters @@ -590,8 +530,8 @@ def iorb( rate : Optional[float] IORB rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.rate.iorb() """ # noqa: E501 @@ -618,26 +558,16 @@ def iorb( @validate def sonia( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Sterling Overnight Index Average. - SONIA (Sterling Overnight Index Average) is an important interest rate benchmark. SONIA is based on actual - transactions and reflects the average of the interest rates that banks pay to borrow sterling overnight from other - financial institutions and other institutional investors. + SONIA (Sterling Overnight Index Average) is an important interest rate benchmark. SONIA is based on actual + transactions and reflects the average of the interest rates that banks pay to borrow sterling overnight from other + financial institutions and other institutional investors. Parameters @@ -674,8 +604,8 @@ def sonia( rate : Optional[float] SONIA rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/fixedincome_spreads.py b/openbb_platform/openbb/package/fixedincome_spreads.py index a68b47b0c673..d9a91c00b670 100644 --- a/openbb_platform/openbb/package/fixedincome_spreads.py +++ b/openbb_platform/openbb/package/fixedincome_spreads.py @@ -25,31 +25,18 @@ def __repr__(self) -> str: @validate def tcm( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - maturity: Annotated[ - Optional[Literal["3m", "2y"]], - OpenBBCustomParameter(description="The maturity"), - ] = "3m", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + maturity: Annotated[Optional[Literal["3m", "2y"]], OpenBBCustomParameter(description="The maturity")] = "3m", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Treasury Constant Maturity. - Get data for 10-Year Treasury Constant Maturity Minus Selected Treasury Constant Maturity. - Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of auctioned U.S. - Treasuries. The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury - yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. + Get data for 10-Year Treasury Constant Maturity Minus Selected Treasury Constant Maturity. + Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of auctioned U.S. + Treasuries. The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury + yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. Parameters @@ -86,8 +73,8 @@ def tcm( rate : Optional[float] TreasuryConstantMaturity Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.spreads.tcm(maturity='2y') """ # noqa: E501 @@ -115,31 +102,18 @@ def tcm( @validate def tcm_effr( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - maturity: Annotated[ - Optional[Literal["10y", "5y", "1y", "6m", "3m"]], - OpenBBCustomParameter(description="The maturity"), - ] = "10y", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + maturity: Annotated[Optional[Literal["10y", "5y", "1y", "6m", "3m"]], OpenBBCustomParameter(description="The maturity")] = "10y", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Select Treasury Constant Maturity. - Get data for Selected Treasury Constant Maturity Minus Federal Funds Rate - Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of auctioned U.S. - Treasuries. The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury - yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. + Get data for Selected Treasury Constant Maturity Minus Federal Funds Rate + Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of auctioned U.S. + Treasuries. The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury + yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. Parameters @@ -176,8 +150,8 @@ def tcm_effr( rate : Optional[float] Selected Treasury Constant Maturity Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.spreads.tcm_effr(maturity='10y') """ # noqa: E501 @@ -205,32 +179,19 @@ def tcm_effr( @validate def treasury_effr( self, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - maturity: Annotated[ - Optional[Literal["3m", "6m"]], - OpenBBCustomParameter(description="The maturity"), - ] = "3m", + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + maturity: Annotated[Optional[Literal["3m", "6m"]], OpenBBCustomParameter(description="The maturity")] = "3m", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Select Treasury Bill. - Get Selected Treasury Bill Minus Federal Funds Rate. - Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of - auctioned U.S. Treasuries. - The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury - yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. + Get Selected Treasury Bill Minus Federal Funds Rate. + Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of + auctioned U.S. Treasuries. + The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury + yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. Parameters @@ -267,8 +228,8 @@ def treasury_effr( rate : Optional[float] SelectedTreasuryBill Rate. - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.fixedincome.spreads.treasury_effr(maturity='6m') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index a7e01bb8899a..91e942fc87fd 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -27,7 +27,9 @@ def __repr__(self) -> str: @exception_handler @validate def available( - self, provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs + self, + provider: Optional[Literal["fmp", "yfinance"]] = None, + **kwargs ) -> OBBject: """All indices available from a given provider. @@ -67,8 +69,8 @@ def available( symbol : Optional[str] Symbol for the index. (provider: yfinance) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.index.available(provider='yfinance') """ # noqa: E501 @@ -83,7 +85,8 @@ def available( ("fmp", "yfinance"), ) }, - standard_params={}, + standard_params={ + }, extra_params=kwargs, ) ) @@ -92,9 +95,7 @@ def available( @validate def constituents( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -142,8 +143,8 @@ def constituents( founded : Optional[Union[str, date]] Founding year of the constituent company in the index. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.index.constituents(symbol='dowjones', provider='fmp') >>> # Providers other than FMP will use the ticker symbol. @@ -175,24 +176,9 @@ def constituents( ) def market( self, - symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." - ), - ], - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): yfinance.")], + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -216,8 +202,8 @@ def market( Data granularity. (provider: fmp, yfinance) sort : Literal['asc', 'desc'] Sort the data in ascending or descending order. (provider: fmp); - Sort order. (provider: intrinio); - Sort order of the data. (provider: polygon) + Sort order. (provider: intrinio); + Sort order of the data. (provider: polygon) tag : Optional[str] Index tag. (provider: intrinio) type : Optional[str] @@ -280,18 +266,14 @@ def market( transactions : Optional[Annotated[int, Gt(gt=0)]] Number of transactions for the symbol in the time period. (provider: polygon) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.index.market(symbol='SPX') """ # noqa: E501 simplefilter("always", DeprecationWarning) - warn( - "This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.", - category=DeprecationWarning, - stacklevel=2, - ) + warn("This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.", category=DeprecationWarning, stacklevel=2) return self._run( "/index/market", diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index fcb394cb2caa..93bf3fc3f3d0 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -25,31 +25,11 @@ def __repr__(self) -> str: @validate def company( self, - symbol: Annotated[ - Union[str, None, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, yfinance." - ), - ] = None, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, - limit: Annotated[ - Optional[Annotated[int, Ge(ge=0)]], - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 2500, - provider: Optional[ - Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"] - ] = None, + symbol: Annotated[Union[str, None, List[str]], OpenBBCustomParameter(description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, yfinance.")] = None, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + limit: Annotated[Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return.")] = 2500, + provider: Optional[Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"]] = None, **kwargs ) -> OBBject: """Company News. Get news for one or more companies. @@ -80,7 +60,7 @@ def company( Key to sort the news by. (provider: benzinga) order : Optional[Literal['asc', 'desc']] Order to sort the news by. (provider: benzinga); - Sort order of the articles. (provider: polygon) + Sort order of the articles. (provider: polygon) isin : Optional[str] The company's ISIN. (provider: benzinga) cusip : Optional[str] @@ -144,9 +124,9 @@ def company( Updated date of the news. (provider: benzinga) source : Optional[str] Name of the news source. (provider: fmp); - Source of the article. (provider: polygon); - News source. (provider: tiingo); - Source of the news article (provider: yfinance) + Source of the article. (provider: polygon); + News source. (provider: tiingo); + Source of the news article (provider: yfinance) amp_url : Optional[str] AMP URL. (provider: polygon) publisher : Optional[openbb_polygon.models.company_news.PolygonPublisher] @@ -156,8 +136,8 @@ def company( crawl_date : Optional[datetime] Date the news article was crawled. (provider: tiingo) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.news.company(limit=2500) >>> # Get news on the specified dates. @@ -177,14 +157,7 @@ def company( "provider": self._get_provider( provider, "/news/company", - ( - "benzinga", - "fmp", - "intrinio", - "polygon", - "tiingo", - "yfinance", - ), + ("benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"), ) }, standard_params={ @@ -194,18 +167,7 @@ def company( "limit": limit, }, extra_params=kwargs, - extra_info={ - "symbol": { - "multiple_items_allowed": [ - "benzinga", - "fmp", - "intrinio", - "polygon", - "tiingo", - "yfinance", - ] - } - }, + extra_info={"symbol": {"multiple_items_allowed": ["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"]}}, ) ) @@ -213,24 +175,9 @@ def company( @validate def world( self, - limit: Annotated[ - int, - OpenBBCustomParameter( - description="The number of data entries to return. The number of articles to return." - ), - ] = 2500, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format." - ), - ] = None, + limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return. The number of articles to return.")] = 2500, + start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, + end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, provider: Optional[Literal["benzinga", "fmp", "intrinio", "tiingo"]] = None, **kwargs ) -> OBBject: @@ -328,8 +275,8 @@ def world( crawl_date : Optional[datetime] Date the news article was crawled. (provider: tiingo) - Example - ------- + Examples + -------- >>> from openbb import obb >>> obb.news.world(limit=2500) >>> # Get news on the specified dates. diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index b0b9dd3e8d86..b36887e72a05 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -27,9 +27,7 @@ def __repr__(self) -> str: @validate def cik_map( self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], + symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -91,12 +89,7 @@ def cik_map( def institutions_search( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - use_cache: Annotated[ - Optional[bool], - OpenBBCustomParameter( - description="Whether or not to use cache. If True, cache will store for seven days." - ), - ] = True, + use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether or not to use cache. If True, cache will store for seven days.")] = True, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -161,7 +154,9 @@ def institutions_search( @exception_handler @validate def rss_litigation( - self, provider: Optional[Literal["sec"]] = None, **kwargs + self, + provider: Optional[Literal["sec"]] = None, + **kwargs ) -> OBBject: """The RSS feed provides links to litigation releases concerning civil lawsuits brought by the Commission in federal court. @@ -215,7 +210,8 @@ def rss_litigation( ("sec",), ) }, - standard_params={}, + standard_params={ + }, extra_params=kwargs, ) ) @@ -225,12 +221,7 @@ def rss_litigation( def schema_files( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - use_cache: Annotated[ - Optional[bool], - OpenBBCustomParameter( - description="Whether or not to use cache. If True, cache will store for seven days." - ), - ] = True, + use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether or not to use cache. If True, cache will store for seven days.")] = True, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -297,12 +288,7 @@ def schema_files( def sic_search( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - use_cache: Annotated[ - Optional[bool], - OpenBBCustomParameter( - description="Whether or not to use cache. If True, cache will store for seven days." - ), - ] = True, + use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether or not to use cache. If True, cache will store for seven days.")] = True, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -371,12 +357,7 @@ def sic_search( def symbol_map( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - use_cache: Annotated[ - Optional[bool], - OpenBBCustomParameter( - description="Whether or not to use cache. If True, cache will store for seven days." - ), - ] = True, + use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether or not to use cache. If True, cache will store for seven days.")] = True, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: From 6b8e07c0d5ca24ef4cf84c32db7893b297a3382a Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 18:59:48 +0000 Subject: [PATCH 012/133] black sig --- .../openbb_core/app/static/package_builder.py | 2 +- openbb_platform/openbb/package/crypto.py | 4 +- .../openbb/package/crypto_price.py | 25 +- openbb_platform/openbb/package/currency.py | 177 ++-- .../openbb/package/currency_price.py | 179 ++-- openbb_platform/openbb/package/derivatives.py | 8 +- .../openbb/package/derivatives_options.py | 11 +- openbb_platform/openbb/package/economy.py | 860 ++++++++++-------- openbb_platform/openbb/package/economy_gdp.py | 70 +- openbb_platform/openbb/package/equity.py | 239 ++--- .../openbb/package/equity_calendar.py | 65 +- .../openbb/package/equity_compare.py | 66 +- .../openbb/package/equity_discovery.py | 189 ++-- .../openbb/package/equity_estimates.py | 47 +- .../openbb/package/equity_fundamental.py | 546 +++++++---- .../openbb/package/equity_ownership.py | 34 +- .../openbb/package/equity_price.py | 65 +- .../openbb/package/equity_shorts.py | 4 +- openbb_platform/openbb/package/etf.py | 195 ++-- openbb_platform/openbb/package/fixedincome.py | 112 ++- .../openbb/package/fixedincome_corporate.py | 571 ++++++------ .../openbb/package/fixedincome_government.py | 26 +- .../openbb/package/fixedincome_rate.py | 806 ++++++++-------- .../openbb/package/fixedincome_spreads.py | 317 ++++--- openbb_platform/openbb/package/index.py | 38 +- openbb_platform/openbb/package/news.py | 73 +- .../openbb/package/regulators_sec.py | 39 +- 27 files changed, 2880 insertions(+), 1888 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index fa21826a91cb..aaa3420502fb 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -199,7 +199,7 @@ def _run_linters(self): self.console.log("\nRunning linters...") linters = Linters(self.directory / "package", self.verbose) linters.ruff() - # linters.black() + linters.black() def _write( self, code: str, name: str, extension: str = "py", folder: str = "package" diff --git a/openbb_platform/openbb/package/crypto.py b/openbb_platform/openbb/package/crypto.py index 96621a5cc8ea..174839b7160f 100644 --- a/openbb_platform/openbb/package/crypto.py +++ b/openbb_platform/openbb/package/crypto.py @@ -30,7 +30,9 @@ def price(self): @validate def search( self, - query: Annotated[Optional[str], OpenBBCustomParameter(description="Search query.")] = None, + query: Annotated[ + Optional[str], OpenBBCustomParameter(description="Search query.") + ] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/crypto_price.py b/openbb_platform/openbb/package/crypto_price.py index 0da31fa13255..970cc2eeb8a8 100644 --- a/openbb_platform/openbb/package/crypto_price.py +++ b/openbb_platform/openbb/package/crypto_price.py @@ -23,9 +23,24 @@ def __repr__(self) -> str: @validate def historical( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): fmp, polygon, yfinance.")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): fmp, polygon, yfinance." + ), + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp", "polygon", "tiingo", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -129,6 +144,8 @@ def historical( "end_date": end_date, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp", "polygon", "yfinance"]}}, + extra_info={ + "symbol": {"multiple_items_allowed": ["fmp", "polygon", "yfinance"]} + }, ) ) diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index a8120fcd3131..1e29290a5f2b 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -27,101 +27,99 @@ def price(self): @exception_handler @validate def search( - self, - provider: Optional[Literal["fmp", "intrinio", "polygon"]] = None, - **kwargs + self, provider: Optional[Literal["fmp", "intrinio", "polygon"]] = None, **kwargs ) -> OBBject: - """ Currency Search. + """Currency Search. - Search available currency pairs. - Currency pairs are the national currencies from two countries coupled for trading on - the foreign exchange (FX) marketplace. - Both currencies will have exchange rates on which the trade will have its position basis. - All trading within the forex market, whether selling, buying, or trading, will take place through currency pairs. - (ref: Investopedia) - Major currency pairs include pairs such as EUR/USD, USD/JPY, GBP/USD, etc. + Search available currency pairs. + Currency pairs are the national currencies from two countries coupled for trading on + the foreign exchange (FX) marketplace. + Both currencies will have exchange rates on which the trade will have its position basis. + All trading within the forex market, whether selling, buying, or trading, will take place through currency pairs. + (ref: Investopedia) + Major currency pairs include pairs such as EUR/USD, USD/JPY, GBP/USD, etc. - Parameters - ---------- - provider : Optional[Literal['fmp', 'intrinio', 'polygon']] - 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. - symbol : Optional[str] - Symbol of the pair to search. (provider: polygon) - date : Optional[datetime.date] - A specific date to get data for. (provider: polygon) - search : Optional[str] - Search for terms within the ticker and/or company name. (provider: polygon) - active : Optional[bool] - Specify if the tickers returned should be actively traded on the queried date. (provider: polygon) - order : Optional[Literal['asc', 'desc']] - Order data by ascending or descending. (provider: polygon) - sort : Optional[Literal['ticker', 'name', 'market', 'locale', 'currency_symbol', 'currency_name', 'base_currency_symbol', 'base_currency_name', 'last_updated_utc', 'delisted_utc']] - Sort field used for ordering. (provider: polygon) - limit : Optional[Annotated[int, Gt(gt=0)]] - The number of data entries to return. (provider: polygon) - - Returns - ------- - OBBject - results : List[CurrencyPairs] - Serializable results. + Parameters + ---------- provider : Optional[Literal['fmp', 'intrinio', 'polygon']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + 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. + symbol : Optional[str] + Symbol of the pair to search. (provider: polygon) + date : Optional[datetime.date] + A specific date to get data for. (provider: polygon) + search : Optional[str] + Search for terms within the ticker and/or company name. (provider: polygon) + active : Optional[bool] + Specify if the tickers returned should be actively traded on the queried date. (provider: polygon) + order : Optional[Literal['asc', 'desc']] + Order data by ascending or descending. (provider: polygon) + sort : Optional[Literal['ticker', 'name', 'market', 'locale', 'currency_symbol', 'currency_name', 'base_currency_symbol', 'base_currency_name', 'last_updated_utc', 'delisted_utc']] + Sort field used for ordering. (provider: polygon) + limit : Optional[Annotated[int, Gt(gt=0)]] + The number of data entries to return. (provider: polygon) + + Returns + ------- + OBBject + results : List[CurrencyPairs] + Serializable results. + provider : Optional[Literal['fmp', 'intrinio', 'polygon']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - CurrencyPairs - ------------- - name : str - Name of the currency pair. - symbol : Optional[str] - Symbol of the currency pair. (provider: fmp) - currency : Optional[str] - Base currency of the currency pair. (provider: fmp) - stock_exchange : Optional[str] - Stock exchange of the currency pair. (provider: fmp) - exchange_short_name : Optional[str] - Short name of the stock exchange of the currency pair. (provider: fmp) - code : Optional[str] - Code of the currency pair. (provider: intrinio) - base_currency : Optional[str] - ISO 4217 currency code of the base currency. (provider: intrinio) - quote_currency : Optional[str] - ISO 4217 currency code of the quote currency. (provider: intrinio) - market : Optional[str] - Name of the trading market. Always 'fx'. (provider: polygon) - locale : Optional[str] - Locale of the currency pair. (provider: polygon) - currency_symbol : Optional[str] - The symbol of the quote currency. (provider: polygon) - currency_name : Optional[str] - Name of the quote currency. (provider: polygon) - base_currency_symbol : Optional[str] - The symbol of the base currency. (provider: polygon) - base_currency_name : Optional[str] - Name of the base currency. (provider: polygon) - last_updated_utc : Optional[datetime] - The last updated timestamp in UTC. (provider: polygon) - delisted_utc : Optional[datetime] - The delisted timestamp in UTC. (provider: polygon) + CurrencyPairs + ------------- + name : str + Name of the currency pair. + symbol : Optional[str] + Symbol of the currency pair. (provider: fmp) + currency : Optional[str] + Base currency of the currency pair. (provider: fmp) + stock_exchange : Optional[str] + Stock exchange of the currency pair. (provider: fmp) + exchange_short_name : Optional[str] + Short name of the stock exchange of the currency pair. (provider: fmp) + code : Optional[str] + Code of the currency pair. (provider: intrinio) + base_currency : Optional[str] + ISO 4217 currency code of the base currency. (provider: intrinio) + quote_currency : Optional[str] + ISO 4217 currency code of the quote currency. (provider: intrinio) + market : Optional[str] + Name of the trading market. Always 'fx'. (provider: polygon) + locale : Optional[str] + Locale of the currency pair. (provider: polygon) + currency_symbol : Optional[str] + The symbol of the quote currency. (provider: polygon) + currency_name : Optional[str] + Name of the quote currency. (provider: polygon) + base_currency_symbol : Optional[str] + The symbol of the base currency. (provider: polygon) + base_currency_name : Optional[str] + Name of the base currency. (provider: polygon) + last_updated_utc : Optional[datetime] + The last updated timestamp in UTC. (provider: polygon) + delisted_utc : Optional[datetime] + The delisted timestamp in UTC. (provider: polygon) - Examples - -------- - >>> from openbb import obb - >>> obb.currency.search() - >>> # Search for 'EURUSD' currency pair using 'polygon' as provider. - >>> obb.currency.search(provider='polygon', symbol='EURUSD') - >>> # Search for terms using 'polygon' as provider. - >>> obb.currency.search(provider='polygon', search='Euro zone') - >>> # Search for actively traded currency pairs on the queried date using 'polygon' as provider. - >>> obb.currency.search(provider='polygon', date='2024-01-02', active=True) + Examples + -------- + >>> from openbb import obb + >>> obb.currency.search() + >>> # Search for 'EURUSD' currency pair using 'polygon' as provider. + >>> obb.currency.search(provider='polygon', symbol='EURUSD') + >>> # Search for terms using 'polygon' as provider. + >>> obb.currency.search(provider='polygon', search='Euro zone') + >>> # Search for actively traded currency pairs on the queried date using 'polygon' as provider. + >>> obb.currency.search(provider='polygon', date='2024-01-02', active=True) """ # noqa: E501 return self._run( @@ -134,8 +132,7 @@ def search( ("fmp", "intrinio", "polygon"), ) }, - standard_params={ - }, + standard_params={}, extra_params=kwargs, ) ) diff --git a/openbb_platform/openbb/package/currency_price.py b/openbb_platform/openbb/package/currency_price.py index a1f4a1de947a..0d8f33f95693 100644 --- a/openbb_platform/openbb/package/currency_price.py +++ b/openbb_platform/openbb/package/currency_price.py @@ -23,95 +23,110 @@ def __repr__(self) -> str: @validate def historical( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): polygon, yfinance.")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): polygon, yfinance." + ), + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp", "polygon", "tiingo", "yfinance"]] = None, **kwargs ) -> OBBject: - """ Currency Historical Price. Currency historical data. + """Currency Historical Price. Currency historical data. - Currency historical prices refer to the past exchange rates of one currency against - another over a specific period. - This data provides insight into the fluctuations and trends in the foreign exchange market, - helping analysts, traders, and economists understand currency performance, - evaluate economic health, and make predictions about future movements. + Currency historical prices refer to the past exchange rates of one currency against + another over a specific period. + This data provides insight into the fluctuations and trends in the foreign exchange market, + helping analysts, traders, and economists understand currency performance, + evaluate economic health, and make predictions about future movements. - Parameters - ---------- - symbol : Union[str, List[str]] - Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): polygon, yfinance. - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'polygon', 'tiingo', 'yfinance']] - 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 : Optional[Union[Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], str, Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] - Data granularity. (provider: fmp, polygon, tiingo, yfinance) - sort : Literal['asc', 'desc'] - Sort order of the data. (provider: polygon) - limit : int - The number of data entries to return. (provider: polygon) - period : Optional[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']] - Time period of the data to return. (provider: yfinance) - - Returns - ------- - OBBject - results : List[CurrencyHistorical] - Serializable results. + Parameters + ---------- + symbol : Union[str, List[str]] + Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): polygon, yfinance. + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['fmp', 'polygon', 'tiingo', 'yfinance']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + 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 : Optional[Union[Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], str, Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] + Data granularity. (provider: fmp, polygon, tiingo, yfinance) + sort : Literal['asc', 'desc'] + Sort order of the data. (provider: polygon) + limit : int + The number of data entries to return. (provider: polygon) + period : Optional[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']] + Time period of the data to return. (provider: yfinance) + + Returns + ------- + OBBject + results : List[CurrencyHistorical] + Serializable results. + provider : Optional[Literal['fmp', 'polygon', 'tiingo', 'yfinance']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - CurrencyHistorical - ------------------ - date : Union[date, datetime] - The date of the data. - open : float - The open price. - high : float - The high price. - low : float - The low price. - close : float - The close price. - volume : Optional[float] - The trading volume. - vwap : Optional[Annotated[float, Gt(gt=0)]] - Volume Weighted Average Price over the period. - adj_close : Optional[float] - The adjusted close price. (provider: fmp) - unadjusted_volume : Optional[float] - Unadjusted volume of the symbol. (provider: fmp) - change : Optional[float] - Change in the price of the symbol from the previous day. (provider: fmp) - change_percent : Optional[float] - Change % in the price of the symbol. (provider: fmp) - label : Optional[str] - Human readable format of the date. (provider: fmp) - change_over_time : Optional[float] - Change % in the price of the symbol over a period of time. (provider: fmp) - transactions : Optional[Annotated[int, Gt(gt=0)]] - Number of transactions for the symbol in the time period. (provider: polygon) + CurrencyHistorical + ------------------ + date : Union[date, datetime] + The date of the data. + open : float + The open price. + high : float + The high price. + low : float + The low price. + close : float + The close price. + volume : Optional[float] + The trading volume. + vwap : Optional[Annotated[float, Gt(gt=0)]] + Volume Weighted Average Price over the period. + adj_close : Optional[float] + The adjusted close price. (provider: fmp) + unadjusted_volume : Optional[float] + Unadjusted volume of the symbol. (provider: fmp) + change : Optional[float] + Change in the price of the symbol from the previous day. (provider: fmp) + change_percent : Optional[float] + Change % in the price of the symbol. (provider: fmp) + label : Optional[str] + Human readable format of the date. (provider: fmp) + change_over_time : Optional[float] + Change % in the price of the symbol over a period of time. (provider: fmp) + transactions : Optional[Annotated[int, Gt(gt=0)]] + Number of transactions for the symbol in the time period. (provider: polygon) - Examples - -------- - >>> from openbb import obb - >>> obb.currency.price.historical(symbol='EURUSD') - >>> # Filter historical data with specific start and end date. - >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='2023-12-31') - >>> # Get data with different granularity. - >>> obb.currency.price.historical(symbol='EURUSD', interval='15m', provider='polygon') + Examples + -------- + >>> from openbb import obb + >>> obb.currency.price.historical(symbol='EURUSD') + >>> # Filter historical data with specific start and end date. + >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='2023-12-31') + >>> # Get data with different granularity. + >>> obb.currency.price.historical(symbol='EURUSD', interval='15m', provider='polygon') """ # noqa: E501 return self._run( @@ -130,6 +145,8 @@ def historical( "end_date": end_date, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["polygon", "yfinance"]}}, + extra_info={ + "symbol": {"multiple_items_allowed": ["polygon", "yfinance"]} + }, ) ) diff --git a/openbb_platform/openbb/package/derivatives.py b/openbb_platform/openbb/package/derivatives.py index 902d76d62ab9..09e666eb8606 100644 --- a/openbb_platform/openbb/package/derivatives.py +++ b/openbb_platform/openbb/package/derivatives.py @@ -18,11 +18,15 @@ def futures(self): # pylint: disable=import-outside-toplevel from . import derivatives_futures - return derivatives_futures.ROUTER_derivatives_futures(command_runner=self._command_runner) + return derivatives_futures.ROUTER_derivatives_futures( + command_runner=self._command_runner + ) @property def options(self): # pylint: disable=import-outside-toplevel from . import derivatives_options - return derivatives_options.ROUTER_derivatives_options(command_runner=self._command_runner) + return derivatives_options.ROUTER_derivatives_options( + command_runner=self._command_runner + ) diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py index ecebef6800ac..30f5d53aa12f 100644 --- a/openbb_platform/openbb/package/derivatives_options.py +++ b/openbb_platform/openbb/package/derivatives_options.py @@ -23,7 +23,9 @@ def __repr__(self) -> str: @validate def chains( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -174,7 +176,12 @@ def chains( @validate def unusual( self, - symbol: Annotated[Optional[str], OpenBBCustomParameter(description="Symbol to get data for. (the underlying symbol)")] = None, + symbol: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="Symbol to get data for. (the underlying symbol)" + ), + ] = None, provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 392d7f428451..327330008714 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -34,8 +34,18 @@ def __repr__(self) -> str: @validate def calendar( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp", "tradingeconomics"]] = None, **kwargs ) -> OBBject: @@ -141,56 +151,66 @@ def calendar( @validate def composite_leading_indicator( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: """The composite leading indicator (CLI) is designed to provide early signals of turning points - in business cycles showing fluctuation of the economic activity around its long term potential level. - CLIs show short-term economic movements in qualitative rather than quantitative terms. + in business cycles showing fluctuation of the economic activity around its long term potential level. + CLIs show short-term economic movements in qualitative rather than quantitative terms. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['oecd']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'oecd' if there is - no default. - country : Literal['united_states', 'united_kingdom', 'japan', 'mexico', 'indonesia', 'australia', 'brazil', 'canada', 'italy', 'germany', 'turkey', 'france', 'south_africa', 'south_korea', 'spain', 'india', 'china', 'g7', 'g20', 'all'] - Country to get GDP for. (provider: oecd) - - Returns - ------- - OBBject - results : List[CLI] - Serializable results. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['oecd']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - CLI - --- - date : Optional[date] - The date of the data. - value : Optional[float] - CLI value - country : Optional[str] - Country for which CLI is given - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.composite_leading_indicator(country='all') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'oecd' if there is + no default. + country : Literal['united_states', 'united_kingdom', 'japan', 'mexico', 'indonesia', 'australia', 'brazil', 'canada', 'italy', 'germany', 'turkey', 'france', 'south_africa', 'south_korea', 'spain', 'india', 'china', 'g7', 'g20', 'all'] + Country to get GDP for. (provider: oecd) + + Returns + ------- + OBBject + results : List[CLI] + Serializable results. + provider : Optional[Literal['oecd']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + CLI + --- + date : Optional[date] + The date of the data. + value : Optional[float] + CLI value + country : Optional[str] + Country for which CLI is given + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.composite_leading_indicator(country='all') """ # noqa: E501 return self._run( @@ -215,12 +235,42 @@ def composite_leading_indicator( @validate def cpi( self, - country: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="The country to get data. Multiple items allowed for provider(s): fred.")], - units: Annotated[Literal["growth_previous", "growth_same", "index_2015"], OpenBBCustomParameter(description="The unit of measurement for the data.\n Options:\n - `growth_previous`: Percent growth from the previous period.\n If monthly data, this is month-over-month, etc\n - `growth_same`: Percent growth from the same period in the previous year.\n If looking at monthly data, this would be year-over-year, etc.\n - `index_2015`: Rescaled index value, such that the value in 2015 is 100.")] = "growth_same", - frequency: Annotated[Literal["monthly", "quarter", "annual"], OpenBBCustomParameter(description="The frequency of the data.\n Options: `monthly`, `quarter`, and `annual`.")] = "monthly", - harmonized: Annotated[bool, OpenBBCustomParameter(description="Whether you wish to obtain harmonized data.")] = False, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + country: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="The country to get data. Multiple items allowed for provider(s): fred." + ), + ], + units: Annotated[ + Literal["growth_previous", "growth_same", "index_2015"], + OpenBBCustomParameter( + description="The unit of measurement for the data.\n Options:\n - `growth_previous`: Percent growth from the previous period.\n If monthly data, this is month-over-month, etc\n - `growth_same`: Percent growth from the same period in the previous year.\n If looking at monthly data, this would be year-over-year, etc.\n - `index_2015`: Rescaled index value, such that the value in 2015 is 100." + ), + ] = "growth_same", + frequency: Annotated[ + Literal["monthly", "quarter", "annual"], + OpenBBCustomParameter( + description="The frequency of the data.\n Options: `monthly`, `quarter`, and `annual`." + ), + ] = "monthly", + harmonized: Annotated[ + bool, + OpenBBCustomParameter( + description="Whether you wish to obtain harmonized data." + ), + ] = False, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: @@ -306,116 +356,134 @@ def cpi( @validate def fred_regional( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fred.")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 100000, + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fred." + ), + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + limit: Annotated[ + Optional[int], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 100000, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: - """ Query the Geo Fred API for regional economic data by series group. - The series group ID is found by using `fred_search` and the `series_id` parameter. - - - Parameters - ---------- - symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fred. - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - limit : Optional[int] - The number of data entries to return. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - is_series_group : bool - When True, the symbol provided is for a series_group, else it is for a series ID. (provider: fred) - region_type : Optional[Literal['bea', 'msa', 'frb', 'necta', 'state', 'country', 'county', 'censusregion']] - The type of regional data. Parameter is only valid when `is_series_group` is True. (provider: fred) - season : Optional[Literal['SA', 'NSA', 'SSA']] - The seasonal adjustments to the data. Parameter is only valid when `is_series_group` is True. (provider: fred) - units : Optional[str] - The units of the data. This should match the units returned from searching by series ID. An incorrect field will not necessarily return an error. Parameter is only valid when `is_series_group` is True. (provider: fred) - frequency : Optional[Literal['d', 'w', 'bw', 'm', 'q', 'sa', 'a', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] - - Frequency aggregation to convert high frequency data to lower frequency. - Parameter is only valid when `is_series_group` is True. - a = Annual - sa= Semiannual - q = Quarterly - m = Monthly - w = Weekly - d = Daily - wef = Weekly, Ending Friday - weth = Weekly, Ending Thursday - wew = Weekly, Ending Wednesday - wetu = Weekly, Ending Tuesday - wem = Weekly, Ending Monday - wesu = Weekly, Ending Sunday - wesa = Weekly, Ending Saturday - bwew = Biweekly, Ending Wednesday - bwem = Biweekly, Ending Monday - (provider: fred) - aggregation_method : Literal['avg', 'sum', 'eop'] - - A key that indicates the aggregation method used for frequency aggregation. - This parameter has no affect if the frequency parameter is not set. - Only valid when `is_series_group` is True. - avg = Average - sum = Sum - eop = End of Period - (provider: fred) - transform : Literal['lin', 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'] - - Transformation type. Only valid when `is_series_group` is True. - lin = Levels (No transformation) - chg = Change - ch1 = Change from Year Ago - pch = Percent Change - pc1 = Percent Change from Year Ago - pca = Compounded Annual Rate of Change - cch = Continuously Compounded Rate of Change - cca = Continuously Compounded Annual Rate of Change - log = Natural Log - (provider: fred) - - Returns - ------- - OBBject - results : List[FredRegional] - Serializable results. + """Query the Geo Fred API for regional economic data by series group. + The series group ID is found by using `fred_search` and the `series_id` parameter. + + + Parameters + ---------- + symbol : Union[str, List[str]] + Symbol to get data for. Multiple items allowed for provider(s): fred. + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + limit : Optional[int] + The number of data entries to return. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - FredRegional - ------------ - date : date - The date of the data. - region : Optional[str] - The name of the region. (provider: fred) - code : Optional[Union[int, str]] - The code of the region. (provider: fred) - value : Optional[Union[float, int]] - The obersvation value. The units are defined in the search results by series ID. (provider: fred) - series_id : Optional[str] - The individual series ID for the region. (provider: fred) - - Examples - -------- - >>> from openbb import obb - >>> # With no date, the most recent report is returned. - >>> obb.economy.fred_regional(series_id='NYICLAIMS') - >>> # With a date, time series data is returned. - >>> obb.economy.fred_regional(series_id='NYICLAIMS', start_date='2021-01-01') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + is_series_group : bool + When True, the symbol provided is for a series_group, else it is for a series ID. (provider: fred) + region_type : Optional[Literal['bea', 'msa', 'frb', 'necta', 'state', 'country', 'county', 'censusregion']] + The type of regional data. Parameter is only valid when `is_series_group` is True. (provider: fred) + season : Optional[Literal['SA', 'NSA', 'SSA']] + The seasonal adjustments to the data. Parameter is only valid when `is_series_group` is True. (provider: fred) + units : Optional[str] + The units of the data. This should match the units returned from searching by series ID. An incorrect field will not necessarily return an error. Parameter is only valid when `is_series_group` is True. (provider: fred) + frequency : Optional[Literal['d', 'w', 'bw', 'm', 'q', 'sa', 'a', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] + + Frequency aggregation to convert high frequency data to lower frequency. + Parameter is only valid when `is_series_group` is True. + a = Annual + sa= Semiannual + q = Quarterly + m = Monthly + w = Weekly + d = Daily + wef = Weekly, Ending Friday + weth = Weekly, Ending Thursday + wew = Weekly, Ending Wednesday + wetu = Weekly, Ending Tuesday + wem = Weekly, Ending Monday + wesu = Weekly, Ending Sunday + wesa = Weekly, Ending Saturday + bwew = Biweekly, Ending Wednesday + bwem = Biweekly, Ending Monday + (provider: fred) + aggregation_method : Literal['avg', 'sum', 'eop'] + + A key that indicates the aggregation method used for frequency aggregation. + This parameter has no affect if the frequency parameter is not set. + Only valid when `is_series_group` is True. + avg = Average + sum = Sum + eop = End of Period + (provider: fred) + transform : Literal['lin', 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'] + + Transformation type. Only valid when `is_series_group` is True. + lin = Levels (No transformation) + chg = Change + ch1 = Change from Year Ago + pch = Percent Change + pc1 = Percent Change from Year Ago + pca = Compounded Annual Rate of Change + cch = Continuously Compounded Rate of Change + cca = Continuously Compounded Annual Rate of Change + log = Natural Log + (provider: fred) + + Returns + ------- + OBBject + results : List[FredRegional] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + FredRegional + ------------ + date : date + The date of the data. + region : Optional[str] + The name of the region. (provider: fred) + code : Optional[Union[int, str]] + The code of the region. (provider: fred) + value : Optional[Union[float, int]] + The obersvation value. The units are defined in the search results by series ID. (provider: fred) + series_id : Optional[str] + The individual series ID for the region. (provider: fred) + + Examples + -------- + >>> from openbb import obb + >>> # With no date, the most recent report is returned. + >>> obb.economy.fred_regional(series_id='NYICLAIMS') + >>> # With a date, time series data is returned. + >>> obb.economy.fred_regional(series_id='NYICLAIMS', start_date='2021-01-01') """ # noqa: E501 return self._run( @@ -443,103 +511,105 @@ def fred_regional( @validate def fred_search( self, - query: Annotated[Optional[str], OpenBBCustomParameter(description="The search word(s).")] = None, + query: Annotated[ + Optional[str], OpenBBCustomParameter(description="The search word(s).") + ] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: - """ Search for FRED series or economic releases by ID or string. - This does not return the observation values, only the metadata. - Use this function to find series IDs for `fred_series()`. + """Search for FRED series or economic releases by ID or string. + This does not return the observation values, only the metadata. + Use this function to find series IDs for `fred_series()`. - Parameters - ---------- - query : Optional[str] - The search word(s). - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - is_release : Optional[bool] - Is release? If True, other search filter variables are ignored. If no query text or release_id is supplied, this defaults to True. (provider: fred) - release_id : Optional[Union[int, str]] - A specific release ID to target. (provider: fred) - limit : Optional[int] - The number of data entries to return. (1-1000) (provider: fred) - offset : Optional[Annotated[int, Ge(ge=0)]] - Offset the results in conjunction with limit. (provider: fred) - filter_variable : Literal[None, 'frequency', 'units', 'seasonal_adjustment'] - Filter by an attribute. (provider: fred) - filter_value : Optional[str] - String value to filter the variable by. Used in conjunction with filter_variable. (provider: fred) - tag_names : Optional[str] - A semicolon delimited list of tag names that series match all of. Example: 'japan;imports' (provider: fred) - exclude_tag_names : Optional[str] - A semicolon delimited list of tag names that series match none of. Example: 'imports;services'. Requires that variable tag_names also be set to limit the number of matching series. (provider: fred) - series_id : Optional[str] - A FRED Series ID to return series group information for. This returns the required information to query for regional data. Not all series that are in FRED have geographical data. Entering a value for series_id will override all other parameters. Multiple series_ids can be separated by commas. (provider: fred) - - Returns - ------- - OBBject - results : List[FredSearch] - Serializable results. + Parameters + ---------- + query : Optional[str] + The search word(s). provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - FredSearch - ---------- - release_id : Optional[Union[int, str]] - The release ID for queries. - series_id : Optional[str] - The series ID for the item in the release. - name : Optional[str] - The name of the release. - title : Optional[str] - The title of the series. - observation_start : Optional[date] - The date of the first observation in the series. - observation_end : Optional[date] - The date of the last observation in the series. - frequency : Optional[str] - The frequency of the data. - frequency_short : Optional[str] - Short form of the data frequency. - units : Optional[str] - The units of the data. - units_short : Optional[str] - Short form of the data units. - seasonal_adjustment : Optional[str] - The seasonal adjustment of the data. - seasonal_adjustment_short : Optional[str] - Short form of the data seasonal adjustment. - last_updated : Optional[datetime] - The datetime of the last update to the data. - notes : Optional[str] - Description of the release. - press_release : Optional[bool] - If the release is a press release. - url : Optional[str] - URL to the release. - popularity : Optional[int] - Popularity of the series (provider: fred) - group_popularity : Optional[int] - Group popularity of the release (provider: fred) - region_type : Optional[str] - The region type of the series. (provider: fred) - series_group : Optional[Union[int, str]] - The series group ID of the series. This value is used to query for regional data. (provider: fred) - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.fred_search() + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + is_release : Optional[bool] + Is release? If True, other search filter variables are ignored. If no query text or release_id is supplied, this defaults to True. (provider: fred) + release_id : Optional[Union[int, str]] + A specific release ID to target. (provider: fred) + limit : Optional[int] + The number of data entries to return. (1-1000) (provider: fred) + offset : Optional[Annotated[int, Ge(ge=0)]] + Offset the results in conjunction with limit. (provider: fred) + filter_variable : Literal[None, 'frequency', 'units', 'seasonal_adjustment'] + Filter by an attribute. (provider: fred) + filter_value : Optional[str] + String value to filter the variable by. Used in conjunction with filter_variable. (provider: fred) + tag_names : Optional[str] + A semicolon delimited list of tag names that series match all of. Example: 'japan;imports' (provider: fred) + exclude_tag_names : Optional[str] + A semicolon delimited list of tag names that series match none of. Example: 'imports;services'. Requires that variable tag_names also be set to limit the number of matching series. (provider: fred) + series_id : Optional[str] + A FRED Series ID to return series group information for. This returns the required information to query for regional data. Not all series that are in FRED have geographical data. Entering a value for series_id will override all other parameters. Multiple series_ids can be separated by commas. (provider: fred) + + Returns + ------- + OBBject + results : List[FredSearch] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + FredSearch + ---------- + release_id : Optional[Union[int, str]] + The release ID for queries. + series_id : Optional[str] + The series ID for the item in the release. + name : Optional[str] + The name of the release. + title : Optional[str] + The title of the series. + observation_start : Optional[date] + The date of the first observation in the series. + observation_end : Optional[date] + The date of the last observation in the series. + frequency : Optional[str] + The frequency of the data. + frequency_short : Optional[str] + Short form of the data frequency. + units : Optional[str] + The units of the data. + units_short : Optional[str] + Short form of the data units. + seasonal_adjustment : Optional[str] + The seasonal adjustment of the data. + seasonal_adjustment_short : Optional[str] + Short form of the data seasonal adjustment. + last_updated : Optional[datetime] + The datetime of the last update to the data. + notes : Optional[str] + Description of the release. + press_release : Optional[bool] + If the release is a press release. + url : Optional[str] + URL to the release. + popularity : Optional[int] + Popularity of the series (provider: fred) + group_popularity : Optional[int] + Group popularity of the release (provider: fred) + region_type : Optional[str] + The region type of the series. (provider: fred) + series_group : Optional[Union[int, str]] + The series group ID of the series. This value is used to query for regional data. (provider: fred) + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.fred_search() """ # noqa: E501 return self._run( @@ -563,10 +633,28 @@ def fred_search( @validate def fred_series( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fred.")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 100000, + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fred." + ), + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + limit: Annotated[ + Optional[int], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 100000, provider: Optional[Literal["fred", "intrinio"]] = None, **kwargs ) -> OBBject: @@ -694,63 +782,73 @@ def gdp(self): @validate def long_term_interest_rate( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: - """ Long-term interest rates refer to government bonds maturing in ten years. - Rates are mainly determined by the price charged by the lender, the risk from the borrower and the - fall in the capital value. Long-term interest rates are generally averages of daily rates, - measured as a percentage. These interest rates are implied by the prices at which the government bonds are - traded on financial markets, not the interest rates at which the loans were issued. - In all cases, they refer to bonds whose capital repayment is guaranteed by governments. - Long-term interest rates are one of the determinants of business investment. - Low long-term interest rates encourage investment in new equipment and high interest rates discourage it. - Investment is, in turn, a major source of economic growth. - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['oecd']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'oecd' if there is - no default. - country : Literal['belgium', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chile', 'canada', 'netherlands', 'united_states', 'south_korea', 'norway', 'austria', 'south_africa', 'denmark', 'switzerland', 'hungary', 'luxembourg', 'australia', 'germany', 'sweden', 'iceland', 'turkey', 'greece', 'israel', 'czech_republic', 'latvia', 'slovenia', 'poland', 'estonia', 'lithuania', 'portugal', 'costa_rica', 'slovakia', 'finland', 'spain', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all'] - Country to get GDP for. (provider: oecd) - frequency : Literal['monthly', 'quarterly', 'annual'] - Frequency to get interest rate for for. (provider: oecd) - - Returns - ------- - OBBject - results : List[LTIR] - Serializable results. + """Long-term interest rates refer to government bonds maturing in ten years. + Rates are mainly determined by the price charged by the lender, the risk from the borrower and the + fall in the capital value. Long-term interest rates are generally averages of daily rates, + measured as a percentage. These interest rates are implied by the prices at which the government bonds are + traded on financial markets, not the interest rates at which the loans were issued. + In all cases, they refer to bonds whose capital repayment is guaranteed by governments. + Long-term interest rates are one of the determinants of business investment. + Low long-term interest rates encourage investment in new equipment and high interest rates discourage it. + Investment is, in turn, a major source of economic growth. + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['oecd']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - LTIR - ---- - date : Optional[date] - The date of the data. - value : Optional[float] - Interest rate (given as a whole number, i.e 10=10%) - country : Optional[str] - Country for which interest rate is given - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'oecd' if there is + no default. + country : Literal['belgium', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chile', 'canada', 'netherlands', 'united_states', 'south_korea', 'norway', 'austria', 'south_africa', 'denmark', 'switzerland', 'hungary', 'luxembourg', 'australia', 'germany', 'sweden', 'iceland', 'turkey', 'greece', 'israel', 'czech_republic', 'latvia', 'slovenia', 'poland', 'estonia', 'lithuania', 'portugal', 'costa_rica', 'slovakia', 'finland', 'spain', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all'] + Country to get GDP for. (provider: oecd) + frequency : Literal['monthly', 'quarterly', 'annual'] + Frequency to get interest rate for for. (provider: oecd) + + Returns + ------- + OBBject + results : List[LTIR] + Serializable results. + provider : Optional[Literal['oecd']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + LTIR + ---- + date : Optional[date] + The date of the data. + value : Optional[float] + Interest rate (given as a whole number, i.e 10=10%) + country : Optional[str] + Country for which interest rate is given + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 return self._run( @@ -775,9 +873,24 @@ def long_term_interest_rate( @validate def money_measures( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - adjusted: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether to return seasonally adjusted data.")] = True, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + adjusted: Annotated[ + Optional[bool], + OpenBBCustomParameter( + description="Whether to return seasonally adjusted data." + ), + ] = True, provider: Optional[Literal["federal_reserve"]] = None, **kwargs ) -> OBBject: @@ -857,9 +970,7 @@ def money_measures( @exception_handler @validate def risk_premium( - self, - provider: Optional[Literal["fmp"]] = None, - **kwargs + self, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Market Risk Premium by country. @@ -911,8 +1022,7 @@ def risk_premium( ("fmp",), ) }, - standard_params={ - }, + standard_params={}, extra_params=kwargs, ) ) @@ -921,60 +1031,70 @@ def risk_premium( @validate def short_term_interest_rate( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: - """ Short-term interest rates are the rates at which short-term borrowings are effected between - financial institutions or the rate at which short-term government paper is issued or traded in the market. - Short-term interest rates are generally averages of daily rates, measured as a percentage. - Short-term interest rates are based on three-month money market rates where available. - Typical standardised names are "money market rate" and "treasury bill rate". - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['oecd']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'oecd' if there is - no default. - country : Literal['belgium', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chile', 'canada', 'netherlands', 'united_states', 'south_korea', 'norway', 'austria', 'south_africa', 'denmark', 'switzerland', 'hungary', 'luxembourg', 'australia', 'germany', 'sweden', 'iceland', 'turkey', 'greece', 'israel', 'czech_republic', 'latvia', 'slovenia', 'poland', 'estonia', 'lithuania', 'portugal', 'costa_rica', 'slovakia', 'finland', 'spain', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all'] - Country to get GDP for. (provider: oecd) - frequency : Literal['monthly', 'quarterly', 'annual'] - Frequency to get interest rate for for. (provider: oecd) - - Returns - ------- - OBBject - results : List[STIR] - Serializable results. + """Short-term interest rates are the rates at which short-term borrowings are effected between + financial institutions or the rate at which short-term government paper is issued or traded in the market. + Short-term interest rates are generally averages of daily rates, measured as a percentage. + Short-term interest rates are based on three-month money market rates where available. + Typical standardised names are "money market rate" and "treasury bill rate". + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['oecd']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - STIR - ---- - date : Optional[date] - The date of the data. - value : Optional[float] - Interest rate (given as a whole number, i.e 10=10%) - country : Optional[str] - Country for which interest rate is given - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'oecd' if there is + no default. + country : Literal['belgium', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chile', 'canada', 'netherlands', 'united_states', 'south_korea', 'norway', 'austria', 'south_africa', 'denmark', 'switzerland', 'hungary', 'luxembourg', 'australia', 'germany', 'sweden', 'iceland', 'turkey', 'greece', 'israel', 'czech_republic', 'latvia', 'slovenia', 'poland', 'estonia', 'lithuania', 'portugal', 'costa_rica', 'slovakia', 'finland', 'spain', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all'] + Country to get GDP for. (provider: oecd) + frequency : Literal['monthly', 'quarterly', 'annual'] + Frequency to get interest rate for for. (provider: oecd) + + Returns + ------- + OBBject + results : List[STIR] + Serializable results. + provider : Optional[Literal['oecd']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + STIR + ---- + date : Optional[date] + The date of the data. + value : Optional[float] + Interest rate (given as a whole number, i.e 10=10%) + country : Optional[str] + Country for which interest rate is given + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 return self._run( @@ -999,8 +1119,18 @@ def short_term_interest_rate( @validate def unemployment( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/economy_gdp.py b/openbb_platform/openbb/package/economy_gdp.py index 7a4b23f76b65..0da6ff4b972c 100644 --- a/openbb_platform/openbb/package/economy_gdp.py +++ b/openbb_platform/openbb/package/economy_gdp.py @@ -25,10 +25,30 @@ def __repr__(self) -> str: @validate def forecast( self, - period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return. Units for nominal GDP period. Either quarter or annual.")] = "annual", - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - type: Annotated[Literal["nominal", "real"], OpenBBCustomParameter(description="Type of GDP to get forecast of. Either nominal or real.")] = "real", + period: Annotated[ + Literal["quarter", "annual"], + OpenBBCustomParameter( + description="Time period of the data to return. Units for nominal GDP period. Either quarter or annual." + ), + ] = "annual", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + type: Annotated[ + Literal["nominal", "real"], + OpenBBCustomParameter( + description="Type of GDP to get forecast of. Either nominal or real." + ), + ] = "real", provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: @@ -102,9 +122,24 @@ def forecast( @validate def nominal( self, - units: Annotated[Literal["usd", "usd_cap"], OpenBBCustomParameter(description="The unit of measurement for the data. Units to get nominal GDP in. Either usd or usd_cap indicating per capita.")] = "usd", - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + units: Annotated[ + Literal["usd", "usd_cap"], + OpenBBCustomParameter( + description="The unit of measurement for the data. Units to get nominal GDP in. Either usd or usd_cap indicating per capita." + ), + ] = "usd", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: @@ -175,9 +210,24 @@ def nominal( @validate def real( self, - units: Annotated[Literal["idx", "qoq", "yoy"], OpenBBCustomParameter(description="The unit of measurement for the data. Either idx (indicating 2015=100), qoq (previous period) or yoy (same period, previous year).)")] = "yoy", - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + units: Annotated[ + Literal["idx", "qoq", "yoy"], + OpenBBCustomParameter( + description="The unit of measurement for the data. Either idx (indicating 2015=100), qoq (previous period) or yoy (same period, previous year).)" + ), + ] = "yoy", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["oecd"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index 71671382bbe5..ee694d6e17a7 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -34,7 +34,9 @@ def calendar(self): # pylint: disable=import-outside-toplevel from . import equity_calendar - return equity_calendar.ROUTER_equity_calendar(command_runner=self._command_runner) + return equity_calendar.ROUTER_equity_calendar( + command_runner=self._command_runner + ) @property def compare(self): @@ -48,28 +50,32 @@ def discovery(self): # pylint: disable=import-outside-toplevel from . import equity_discovery - return equity_discovery.ROUTER_equity_discovery(command_runner=self._command_runner) + return equity_discovery.ROUTER_equity_discovery( + command_runner=self._command_runner + ) @property def estimates(self): # pylint: disable=import-outside-toplevel from . import equity_estimates - return equity_estimates.ROUTER_equity_estimates(command_runner=self._command_runner) + return equity_estimates.ROUTER_equity_estimates( + command_runner=self._command_runner + ) @property def fundamental(self): # pylint: disable=import-outside-toplevel from . import equity_fundamental - return equity_fundamental.ROUTER_equity_fundamental(command_runner=self._command_runner) + return equity_fundamental.ROUTER_equity_fundamental( + command_runner=self._command_runner + ) @exception_handler @validate def market_snapshots( - self, - provider: Optional[Literal["fmp", "polygon"]] = None, - **kwargs + self, provider: Optional[Literal["fmp", "polygon"]] = None, **kwargs ) -> OBBject: """Get an updated equity market snapshot. This includes price data for thousands of stocks. @@ -195,8 +201,7 @@ def market_snapshots( ("fmp", "polygon"), ) }, - standard_params={ - }, + standard_params={}, extra_params=kwargs, ) ) @@ -206,7 +211,9 @@ def ownership(self): # pylint: disable=import-outside-toplevel from . import equity_ownership - return equity_ownership.ROUTER_equity_ownership(command_runner=self._command_runner) + return equity_ownership.ROUTER_equity_ownership( + command_runner=self._command_runner + ) @property def price(self): @@ -219,7 +226,12 @@ def price(self): @validate def profile( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance." + ), + ], provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -392,110 +404,110 @@ def profile( "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp", "intrinio", "yfinance"]}}, + extra_info={ + "symbol": { + "multiple_items_allowed": ["fmp", "intrinio", "yfinance"] + } + }, ) ) @exception_handler @validate - def screener( - self, - provider: Optional[Literal["fmp"]] = None, - **kwargs - ) -> OBBject: + def screener(self, provider: Optional[Literal["fmp"]] = None, **kwargs) -> OBBject: """Screen for companies meeting various criteria. These criteria include - market cap, price, beta, volume, and dividend yield. + market cap, price, beta, volume, and dividend yield. - Parameters - ---------- - provider : Optional[Literal['fmp']] - 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. - mktcap_min : Optional[int] - Filter by market cap greater than this value. (provider: fmp) - mktcap_max : Optional[int] - Filter by market cap less than this value. (provider: fmp) - price_min : Optional[float] - Filter by price greater than this value. (provider: fmp) - price_max : Optional[float] - Filter by price less than this value. (provider: fmp) - beta_min : Optional[float] - Filter by a beta greater than this value. (provider: fmp) - beta_max : Optional[float] - Filter by a beta less than this value. (provider: fmp) - volume_min : Optional[int] - Filter by volume greater than this value. (provider: fmp) - volume_max : Optional[int] - Filter by volume less than this value. (provider: fmp) - dividend_min : Optional[float] - Filter by dividend amount greater than this value. (provider: fmp) - dividend_max : Optional[float] - Filter by dividend amount less than this value. (provider: fmp) - is_etf : Optional[bool] - If true, returns only ETFs. (provider: fmp) - is_active : Optional[bool] - If false, returns only inactive tickers. (provider: fmp) - sector : Optional[Literal['Consumer Cyclical', 'Energy', 'Technology', 'Industrials', 'Financial Services', 'Basic Materials', 'Communication Services', 'Consumer Defensive', 'Healthcare', 'Real Estate', 'Utilities', 'Industrial Goods', 'Financial', 'Services', 'Conglomerates']] - Filter by sector. (provider: fmp) - industry : Optional[str] - Filter by industry. (provider: fmp) - country : Optional[str] - Filter by country, as a two-letter country code. (provider: fmp) - exchange : Optional[Literal['amex', 'ase', 'asx', 'ath', 'bme', 'bru', 'bud', 'bue', 'cai', 'cnq', 'cph', 'dfm', 'doh', 'etf', 'euronext', 'hel', 'hkse', 'ice', 'iob', 'ist', 'jkt', 'jnb', 'jpx', 'kls', 'koe', 'ksc', 'kuw', 'lse', 'mex', 'nasdaq', 'neo', 'nse', 'nyse', 'nze', 'osl', 'otc', 'pnk', 'pra', 'ris', 'sao', 'sau', 'set', 'sgo', 'shh', 'shz', 'six', 'sto', 'tai', 'tlv', 'tsx', 'two', 'vie', 'wse', 'xetra']] - Filter by exchange. (provider: fmp) - limit : Optional[int] - Limit the number of results to return. (provider: fmp) - - Returns - ------- - OBBject - results : List[EquityScreener] - Serializable results. + Parameters + ---------- provider : Optional[Literal['fmp']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - EquityScreener - -------------- - symbol : str - Symbol representing the entity requested in the data. - name : str - Name of the company. - market_cap : Optional[int] - The market cap of ticker. (provider: fmp) - sector : Optional[str] - The sector the ticker belongs to. (provider: fmp) - industry : Optional[str] - The industry ticker belongs to. (provider: fmp) - beta : Optional[float] - The beta of the ETF. (provider: fmp) - price : Optional[float] - The current price. (provider: fmp) - last_annual_dividend : Optional[float] - The last annual amount dividend paid. (provider: fmp) - volume : Optional[int] - The current trading volume. (provider: fmp) - exchange : Optional[str] - The exchange code the asset trades on. (provider: fmp) - exchange_name : Optional[str] - The full name of the primary exchange. (provider: fmp) - country : Optional[str] - The two-letter country abbreviation where the head office is located. (provider: fmp) - is_etf : Optional[Literal[True, False]] - Whether the ticker is an ETF. (provider: fmp) - actively_trading : Optional[Literal[True, False]] - Whether the ETF is actively trading. (provider: fmp) - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.screener() + 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. + mktcap_min : Optional[int] + Filter by market cap greater than this value. (provider: fmp) + mktcap_max : Optional[int] + Filter by market cap less than this value. (provider: fmp) + price_min : Optional[float] + Filter by price greater than this value. (provider: fmp) + price_max : Optional[float] + Filter by price less than this value. (provider: fmp) + beta_min : Optional[float] + Filter by a beta greater than this value. (provider: fmp) + beta_max : Optional[float] + Filter by a beta less than this value. (provider: fmp) + volume_min : Optional[int] + Filter by volume greater than this value. (provider: fmp) + volume_max : Optional[int] + Filter by volume less than this value. (provider: fmp) + dividend_min : Optional[float] + Filter by dividend amount greater than this value. (provider: fmp) + dividend_max : Optional[float] + Filter by dividend amount less than this value. (provider: fmp) + is_etf : Optional[bool] + If true, returns only ETFs. (provider: fmp) + is_active : Optional[bool] + If false, returns only inactive tickers. (provider: fmp) + sector : Optional[Literal['Consumer Cyclical', 'Energy', 'Technology', 'Industrials', 'Financial Services', 'Basic Materials', 'Communication Services', 'Consumer Defensive', 'Healthcare', 'Real Estate', 'Utilities', 'Industrial Goods', 'Financial', 'Services', 'Conglomerates']] + Filter by sector. (provider: fmp) + industry : Optional[str] + Filter by industry. (provider: fmp) + country : Optional[str] + Filter by country, as a two-letter country code. (provider: fmp) + exchange : Optional[Literal['amex', 'ase', 'asx', 'ath', 'bme', 'bru', 'bud', 'bue', 'cai', 'cnq', 'cph', 'dfm', 'doh', 'etf', 'euronext', 'hel', 'hkse', 'ice', 'iob', 'ist', 'jkt', 'jnb', 'jpx', 'kls', 'koe', 'ksc', 'kuw', 'lse', 'mex', 'nasdaq', 'neo', 'nse', 'nyse', 'nze', 'osl', 'otc', 'pnk', 'pra', 'ris', 'sao', 'sau', 'set', 'sgo', 'shh', 'shz', 'six', 'sto', 'tai', 'tlv', 'tsx', 'two', 'vie', 'wse', 'xetra']] + Filter by exchange. (provider: fmp) + limit : Optional[int] + Limit the number of results to return. (provider: fmp) + + Returns + ------- + OBBject + results : List[EquityScreener] + Serializable results. + provider : Optional[Literal['fmp']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + EquityScreener + -------------- + symbol : str + Symbol representing the entity requested in the data. + name : str + Name of the company. + market_cap : Optional[int] + The market cap of ticker. (provider: fmp) + sector : Optional[str] + The sector the ticker belongs to. (provider: fmp) + industry : Optional[str] + The industry ticker belongs to. (provider: fmp) + beta : Optional[float] + The beta of the ETF. (provider: fmp) + price : Optional[float] + The current price. (provider: fmp) + last_annual_dividend : Optional[float] + The last annual amount dividend paid. (provider: fmp) + volume : Optional[int] + The current trading volume. (provider: fmp) + exchange : Optional[str] + The exchange code the asset trades on. (provider: fmp) + exchange_name : Optional[str] + The full name of the primary exchange. (provider: fmp) + country : Optional[str] + The two-letter country abbreviation where the head office is located. (provider: fmp) + is_etf : Optional[Literal[True, False]] + Whether the ticker is an ETF. (provider: fmp) + actively_trading : Optional[Literal[True, False]] + Whether the ETF is actively trading. (provider: fmp) + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.screener() """ # noqa: E501 return self._run( @@ -508,8 +520,7 @@ def screener( ("fmp",), ) }, - standard_params={ - }, + standard_params={}, extra_params=kwargs, ) ) @@ -519,8 +530,14 @@ def screener( def search( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - is_symbol: Annotated[bool, OpenBBCustomParameter(description="Whether to search by ticker symbol.")] = False, - use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether to use the cache or not.")] = True, + is_symbol: Annotated[ + bool, + OpenBBCustomParameter(description="Whether to search by ticker symbol."), + ] = False, + use_cache: Annotated[ + Optional[bool], + OpenBBCustomParameter(description="Whether to use the cache or not."), + ] = True, provider: Optional[Literal["intrinio", "sec"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/equity_calendar.py b/openbb_platform/openbb/package/equity_calendar.py index fec06260a74d..bb1903abea82 100644 --- a/openbb_platform/openbb/package/equity_calendar.py +++ b/openbb_platform/openbb/package/equity_calendar.py @@ -26,8 +26,18 @@ def __repr__(self) -> str: @validate def dividend( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -109,8 +119,18 @@ def dividend( @validate def earnings( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -196,10 +216,25 @@ def earnings( @validate def ipo( self, - symbol: Annotated[Optional[str], OpenBBCustomParameter(description="Symbol to get data for.")] = None, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 100, + symbol: Annotated[ + Optional[str], OpenBBCustomParameter(description="Symbol to get data for.") + ] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + limit: Annotated[ + Optional[int], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 100, provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -356,8 +391,18 @@ def ipo( @validate def splits( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/equity_compare.py b/openbb_platform/openbb/package/equity_compare.py index 4ce617241c67..690622433ae8 100644 --- a/openbb_platform/openbb/package/equity_compare.py +++ b/openbb_platform/openbb/package/equity_compare.py @@ -22,47 +22,49 @@ def __repr__(self) -> str: @validate def peers( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Get the closest peers for a given company. - Peers consist of companies trading on the same exchange, operating within the same sector - and with comparable market capitalizations. + Peers consist of companies trading on the same exchange, operating within the same sector + and with comparable market capitalizations. - Parameters - ---------- - symbol : str - Symbol to get data for. - provider : Optional[Literal['fmp']] - 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. - - Returns - ------- - OBBject - results : EquityPeers - Serializable results. + Parameters + ---------- + symbol : str + Symbol to get data for. provider : Optional[Literal['fmp']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + 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. + + Returns + ------- + OBBject + results : EquityPeers + Serializable results. + provider : Optional[Literal['fmp']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - EquityPeers - ----------- - peers_list : List[str] - A list of equity peers based on sector, exchange and market cap. + EquityPeers + ----------- + peers_list : List[str] + A list of equity peers based on sector, exchange and market cap. - Examples - -------- - >>> from openbb import obb - >>> obb.equity.compare.peers(symbol='AAPL') + Examples + -------- + >>> from openbb import obb + >>> obb.equity.compare.peers(symbol='AAPL') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_discovery.py b/openbb_platform/openbb/package/equity_discovery.py index 1fbc8c7d1c5b..a543e940dd6b 100644 --- a/openbb_platform/openbb/package/equity_discovery.py +++ b/openbb_platform/openbb/package/equity_discovery.py @@ -30,7 +30,12 @@ def __repr__(self) -> str: @validate def active( self, - sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", + sort: Annotated[ + str, + OpenBBCustomParameter( + description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." + ), + ] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -107,7 +112,12 @@ def active( @validate def aggressive_small_caps( self, - sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", + sort: Annotated[ + str, + OpenBBCustomParameter( + description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." + ), + ] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -184,72 +194,90 @@ def aggressive_small_caps( @validate def filings( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - form_type: Annotated[Optional[str], OpenBBCustomParameter(description="Filter by form type. Visit https://www.sec.gov/forms for a list of supported form types.")] = None, - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 100, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + form_type: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="Filter by form type. Visit https://www.sec.gov/forms for a list of supported form types." + ), + ] = None, + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 100, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Get the URLs to SEC filings reported to EDGAR database, such as 10-K, 10-Q, 8-K, and more. SEC - filings include Form 10-K, Form 10-Q, Form 8-K, the proxy statement, Forms 3, 4, and 5, Schedule 13, Form 114, - Foreign Investment Disclosures and others. The annual 10-K report is required to be - filed annually and includes the company's financial statements, management discussion and analysis, - and audited financial statements. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - form_type : Optional[str] - Filter by form type. Visit https://www.sec.gov/forms for a list of supported form types. - limit : int - The number of data entries to return. - provider : Optional[Literal['fmp']] - 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. - is_done : Optional[bool] - Flag for whether or not the filing is done. (provider: fmp) - - Returns - ------- - OBBject - results : List[DiscoveryFilings] - Serializable results. + filings include Form 10-K, Form 10-Q, Form 8-K, the proxy statement, Forms 3, 4, and 5, Schedule 13, Form 114, + Foreign Investment Disclosures and others. The annual 10-K report is required to be + filed annually and includes the company's financial statements, management discussion and analysis, + and audited financial statements. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + form_type : Optional[str] + Filter by form type. Visit https://www.sec.gov/forms for a list of supported form types. + limit : int + The number of data entries to return. provider : Optional[Literal['fmp']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - DiscoveryFilings - ---------------- - symbol : str - Symbol representing the entity requested in the data. - cik : str - Central Index Key (CIK) for the requested entity. - title : str - Title of the filing. - date : datetime - The date of the data. - form_type : str - The form type of the filing - link : str - URL to the filing page on the SEC site. - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.discovery.filings(limit=100) - >>> # Get filings for the year 2023, limited to 100 results - >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31', limit=100) + 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. + is_done : Optional[bool] + Flag for whether or not the filing is done. (provider: fmp) + + Returns + ------- + OBBject + results : List[DiscoveryFilings] + Serializable results. + provider : Optional[Literal['fmp']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + DiscoveryFilings + ---------------- + symbol : str + Symbol representing the entity requested in the data. + cik : str + Central Index Key (CIK) for the requested entity. + title : str + Title of the filing. + date : datetime + The date of the data. + form_type : str + The form type of the filing + link : str + URL to the filing page on the SEC site. + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.discovery.filings(limit=100) + >>> # Get filings for the year 2023, limited to 100 results + >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31', limit=100) """ # noqa: E501 return self._run( @@ -276,7 +304,12 @@ def filings( @validate def gainers( self, - sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", + sort: Annotated[ + str, + OpenBBCustomParameter( + description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." + ), + ] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -353,7 +386,12 @@ def gainers( @validate def growth_tech( self, - sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", + sort: Annotated[ + str, + OpenBBCustomParameter( + description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." + ), + ] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -430,7 +468,12 @@ def growth_tech( @validate def losers( self, - sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", + sort: Annotated[ + str, + OpenBBCustomParameter( + description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." + ), + ] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -507,7 +550,12 @@ def losers( @validate def undervalued_growth( self, - sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", + sort: Annotated[ + str, + OpenBBCustomParameter( + description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." + ), + ] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -584,7 +632,12 @@ def undervalued_growth( @validate def undervalued_large_caps( self, - sort: Annotated[str, OpenBBCustomParameter(description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'.")] = "desc", + sort: Annotated[ + str, + OpenBBCustomParameter( + description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." + ), + ] = "desc", provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py index 429b62dbbdd3..a8d334037a40 100644 --- a/openbb_platform/openbb/package/equity_estimates.py +++ b/openbb_platform/openbb/package/equity_estimates.py @@ -25,8 +25,18 @@ def __repr__(self) -> str: @validate def analyst_search( self, - analyst_name: Annotated[Optional[str], OpenBBCustomParameter(description="A comma separated list of analyst names to bring back. Omitting will bring back all available analysts.")] = None, - firm_name: Annotated[Optional[str], OpenBBCustomParameter(description="A comma separated list of firm names to bring back. Omitting will bring back all available firms.")] = None, + analyst_name: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="A comma separated list of analyst names to bring back. Omitting will bring back all available analysts." + ), + ] = None, + firm_name: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="A comma separated list of firm names to bring back. Omitting will bring back all available firms." + ), + ] = None, provider: Optional[Literal["benzinga"]] = None, **kwargs ) -> OBBject: @@ -186,7 +196,12 @@ def analyst_search( @validate def consensus( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): yfinance.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." + ), + ], provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -266,9 +281,17 @@ def consensus( @validate def historical( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 30, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + period: Annotated[ + Literal["quarter", "annual"], + OpenBBCustomParameter(description="Time period of the data to return."), + ] = "annual", + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 30, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -377,8 +400,16 @@ def historical( @validate def price_target( self, - symbol: Annotated[Union[str, None, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): benzinga.")] = None, - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 200, + symbol: Annotated[ + Union[str, None, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): benzinga." + ), + ] = None, + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 200, provider: Optional[Literal["benzinga", "fmp"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index a694f8ec5e04..16386f0231f6 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -50,9 +50,16 @@ def __repr__(self) -> str: @validate def balance( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - limit: Annotated[Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return.")] = 5, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + period: Annotated[ + str, OpenBBCustomParameter(description="Time period of the data to return.") + ] = "annual", + limit: Annotated[ + Optional[Annotated[int, Ge(ge=0)]], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 5, provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -399,8 +406,13 @@ def balance( @validate def balance_growth( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 10, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 10, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -546,9 +558,16 @@ def balance_growth( @validate def cash( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - limit: Annotated[Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return.")] = 5, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + period: Annotated[ + str, OpenBBCustomParameter(description="Time period of the data to return.") + ] = "annual", + limit: Annotated[ + Optional[Annotated[int, Ge(ge=0)]], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 5, provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -803,8 +822,13 @@ def cash( @validate def cash_growth( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 10, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 10, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -932,9 +956,21 @@ def cash_growth( @validate def dividends( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -1021,7 +1057,9 @@ def dividends( @validate def employee_count( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -1098,117 +1136,127 @@ def employee_count( @validate def filings( self, - symbol: Annotated[Optional[str], OpenBBCustomParameter(description="Symbol to get data for.")] = None, - form_type: Annotated[Optional[str], OpenBBCustomParameter(description="Filter by form type. Check the data provider for available types.")] = None, - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 100, + symbol: Annotated[ + Optional[str], OpenBBCustomParameter(description="Symbol to get data for.") + ] = None, + form_type: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="Filter by form type. Check the data provider for available types." + ), + ] = None, + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 100, provider: Optional[Literal["fmp", "intrinio", "sec"]] = None, **kwargs ) -> OBBject: """Get the URLs to SEC filings reported to EDGAR database, such as 10-K, 10-Q, 8-K, and more. SEC - filings include Form 10-K, Form 10-Q, Form 8-K, the proxy statement, Forms 3, 4, and 5, Schedule 13, Form 114, - Foreign Investment Disclosures and others. The annual 10-K report is required to be - filed annually and includes the company's financial statements, management discussion and analysis, - and audited financial statements. - - - Parameters - ---------- - symbol : Optional[str] - Symbol to get data for. - form_type : Optional[str] - Filter by form type. Check the data provider for available types. - limit : int - The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio', 'sec']] - 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. - start_date : Optional[datetime.date] - Start date of the data, in YYYY-MM-DD format. (provider: intrinio) - end_date : Optional[datetime.date] - End date of the data, in YYYY-MM-DD format. (provider: intrinio) - thea_enabled : Optional[bool] - Return filings that have been read by Intrinio's Thea NLP. (provider: intrinio) - cik : Optional[Union[int, str]] - Lookup filings by Central Index Key (CIK) instead of by symbol. (provider: sec) - type : Optional[Literal['1', '1-A', '1-A POS', '1-A-W', '1-E', '1-E AD', '1-K', '1-SA', '1-U', '1-Z', '1-Z-W', '10-12B', '10-12G', '10-D', '10-K', '10-KT', '10-Q', '10-QT', '11-K', '11-KT', '13F-HR', '13F-NT', '13FCONP', '144', '15-12B', '15-12G', '15-15D', '15F-12B', '15F-12G', '15F-15D', '18-12B', '18-K', '19B-4E', '2-A', '2-AF', '2-E', '20-F', '20FR12B', '20FR12G', '24F-2NT', '25', '25-NSE', '253G1', '253G2', '253G3', '253G4', '3', '305B2', '34-12H', '4', '40-17F1', '40-17F2', '40-17G', '40-17GCS', '40-202A', '40-203A', '40-206A', '40-24B2', '40-33', '40-6B', '40-8B25', '40-8F-2', '40-APP', '40-F', '40-OIP', '40FR12B', '40FR12G', '424A', '424B1', '424B2', '424B3', '424B4', '424B5', '424B7', '424B8', '424H', '425', '485APOS', '485BPOS', '485BXT', '486APOS', '486BPOS', '486BXT', '487', '497', '497AD', '497H2', '497J', '497K', '497VPI', '497VPU', '5', '6-K', '6B NTC', '6B ORDR', '8-A12B', '8-A12G', '8-K', '8-K12B', '8-K12G3', '8-K15D5', '8-M', '8F-2 NTC', '8F-2 ORDR', '9-M', 'ABS-15G', 'ABS-EE', 'ADN-MTL', 'ADV-E', 'ADV-H-C', 'ADV-H-T', 'ADV-NR', 'ANNLRPT', 'APP NTC', 'APP ORDR', 'APP WD', 'APP WDG', 'ARS', 'ATS-N', 'ATS-N-C', 'ATS-N/UA', 'AW', 'AW WD', 'C', 'C-AR', 'C-AR-W', 'C-TR', 'C-TR-W', 'C-U', 'C-U-W', 'C-W', 'CB', 'CERT', 'CERTARCA', 'CERTBATS', 'CERTCBO', 'CERTNAS', 'CERTNYS', 'CERTPAC', 'CFPORTAL', 'CFPORTAL-W', 'CORRESP', 'CT ORDER', 'D', 'DEF 14A', 'DEF 14C', 'DEFA14A', 'DEFA14C', 'DEFC14A', 'DEFC14C', 'DEFM14A', 'DEFM14C', 'DEFN14A', 'DEFR14A', 'DEFR14C', 'DEL AM', 'DFAN14A', 'DFRN14A', 'DOS', 'DOSLTR', 'DRS', 'DRSLTR', 'DSTRBRPT', 'EFFECT', 'F-1', 'F-10', 'F-10EF', 'F-10POS', 'F-1MEF', 'F-3', 'F-3ASR', 'F-3D', 'F-3DPOS', 'F-3MEF', 'F-4', 'F-4 POS', 'F-4MEF', 'F-6', 'F-6 POS', 'F-6EF', 'F-7', 'F-7 POS', 'F-8', 'F-8 POS', 'F-80', 'F-80POS', 'F-9', 'F-9 POS', 'F-N', 'F-X', 'FOCUSN', 'FWP', 'G-405', 'G-405N', 'G-FIN', 'G-FINW', 'IRANNOTICE', 'MA', 'MA-A', 'MA-I', 'MA-W', 'MSD', 'MSDCO', 'MSDW', 'N-1', 'N-14', 'N-14 8C', 'N-14MEF', 'N-18F1', 'N-1A', 'N-2', 'N-2 POSASR', 'N-23C-2', 'N-23C3A', 'N-23C3B', 'N-23C3C', 'N-2ASR', 'N-2MEF', 'N-30B-2', 'N-30D', 'N-4', 'N-5', 'N-54A', 'N-54C', 'N-6', 'N-6F', 'N-8A', 'N-8B-2', 'N-8F', 'N-8F NTC', 'N-8F ORDR', 'N-CEN', 'N-CR', 'N-CSR', 'N-CSRS', 'N-MFP', 'N-MFP1', 'N-MFP2', 'N-PX', 'N-Q', 'N-VP', 'N-VPFS', 'NO ACT', 'NPORT-EX', 'NPORT-NP', 'NPORT-P', 'NRSRO-CE', 'NRSRO-UPD', 'NSAR-A', 'NSAR-AT', 'NSAR-B', 'NSAR-BT', 'NSAR-U', 'NT 10-D', 'NT 10-K', 'NT 10-Q', 'NT 11-K', 'NT 20-F', 'NT N-CEN', 'NT N-MFP', 'NT N-MFP1', 'NT N-MFP2', 'NT NPORT-EX', 'NT NPORT-P', 'NT-NCEN', 'NT-NCSR', 'NT-NSAR', 'NTFNCEN', 'NTFNCSR', 'NTFNSAR', 'NTN 10D', 'NTN 10K', 'NTN 10Q', 'NTN 20F', 'OIP NTC', 'OIP ORDR', 'POS 8C', 'POS AM', 'POS AMI', 'POS EX', 'POS462B', 'POS462C', 'POSASR', 'PRE 14A', 'PRE 14C', 'PREC14A', 'PREC14C', 'PREM14A', 'PREM14C', 'PREN14A', 'PRER14A', 'PRER14C', 'PRRN14A', 'PX14A6G', 'PX14A6N', 'QRTLYRPT', 'QUALIF', 'REG-NR', 'REVOKED', 'RW', 'RW WD', 'S-1', 'S-11', 'S-11MEF', 'S-1MEF', 'S-20', 'S-3', 'S-3ASR', 'S-3D', 'S-3DPOS', 'S-3MEF', 'S-4', 'S-4 POS', 'S-4EF', 'S-4MEF', 'S-6', 'S-8', 'S-8 POS', 'S-B', 'S-BMEF', 'SBSE', 'SBSE-A', 'SBSE-BD', 'SBSE-C', 'SBSE-W', 'SC 13D', 'SC 13E1', 'SC 13E3', 'SC 13G', 'SC 14D9', 'SC 14F1', 'SC 14N', 'SC TO-C', 'SC TO-I', 'SC TO-T', 'SC13E4F', 'SC14D1F', 'SC14D9C', 'SC14D9F', 'SD', 'SDR', 'SE', 'SEC ACTION', 'SEC STAFF ACTION', 'SEC STAFF LETTER', 'SF-1', 'SF-3', 'SL', 'SP 15D2', 'STOP ORDER', 'SUPPL', 'T-3', 'TA-1', 'TA-2', 'TA-W', 'TACO', 'TH', 'TTW', 'UNDER', 'UPLOAD', 'WDL-REQ', 'X-17A-5']] - Type of the SEC filing form. (provider: sec) - use_cache : bool - Whether or not to use cache. If True, cache will store for one day. (provider: sec) - - Returns - ------- - OBBject - results : List[CompanyFilings] - Serializable results. + filings include Form 10-K, Form 10-Q, Form 8-K, the proxy statement, Forms 3, 4, and 5, Schedule 13, Form 114, + Foreign Investment Disclosures and others. The annual 10-K report is required to be + filed annually and includes the company's financial statements, management discussion and analysis, + and audited financial statements. + + + Parameters + ---------- + symbol : Optional[str] + Symbol to get data for. + form_type : Optional[str] + Filter by form type. Check the data provider for available types. + limit : int + The number of data entries to return. provider : Optional[Literal['fmp', 'intrinio', 'sec']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - CompanyFilings - -------------- - filing_date : date - The date of the filing. - accepted_date : Optional[datetime] - Accepted date of the filing. - symbol : Optional[str] - Symbol representing the entity requested in the data. - cik : Optional[str] - Central Index Key (CIK) for the requested entity. - report_type : Optional[str] - Type of filing. - filing_url : Optional[str] - URL to the filing page. - report_url : str - URL to the actual report. - id : Optional[str] - Intrinio ID of the filing. (provider: intrinio) - period_end_date : Optional[date] - Ending date of the fiscal period for the filing. (provider: intrinio) - sec_unique_id : Optional[str] - SEC unique ID of the filing. (provider: intrinio) - instance_url : Optional[str] - URL for the XBRL filing for the report. (provider: intrinio) - industry_group : Optional[str] - Industry group of the company. (provider: intrinio) - industry_category : Optional[str] - Industry category of the company. (provider: intrinio) - report_date : Optional[date] - The date of the filing. (provider: sec) - act : Optional[Union[int, str]] - The SEC Act number. (provider: sec) - items : Optional[Union[str, float]] - The SEC Item numbers. (provider: sec) - primary_doc_description : Optional[str] - The description of the primary document. (provider: sec) - primary_doc : Optional[str] - The filename of the primary document. (provider: sec) - accession_number : Optional[Union[int, str]] - The accession number. (provider: sec) - file_number : Optional[Union[int, str]] - The file number. (provider: sec) - film_number : Optional[Union[int, str]] - The film number. (provider: sec) - is_inline_xbrl : Optional[Union[int, str]] - Whether the filing is an inline XBRL filing. (provider: sec) - is_xbrl : Optional[Union[int, str]] - Whether the filing is an XBRL filing. (provider: sec) - size : Optional[Union[int, str]] - The size of the filing. (provider: sec) - complete_submission_url : Optional[str] - The URL to the complete filing submission. (provider: sec) - filing_detail_url : Optional[str] - The URL to the filing details. (provider: sec) - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.fundamental.filings(limit=100) + 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. + start_date : Optional[datetime.date] + Start date of the data, in YYYY-MM-DD format. (provider: intrinio) + end_date : Optional[datetime.date] + End date of the data, in YYYY-MM-DD format. (provider: intrinio) + thea_enabled : Optional[bool] + Return filings that have been read by Intrinio's Thea NLP. (provider: intrinio) + cik : Optional[Union[int, str]] + Lookup filings by Central Index Key (CIK) instead of by symbol. (provider: sec) + type : Optional[Literal['1', '1-A', '1-A POS', '1-A-W', '1-E', '1-E AD', '1-K', '1-SA', '1-U', '1-Z', '1-Z-W', '10-12B', '10-12G', '10-D', '10-K', '10-KT', '10-Q', '10-QT', '11-K', '11-KT', '13F-HR', '13F-NT', '13FCONP', '144', '15-12B', '15-12G', '15-15D', '15F-12B', '15F-12G', '15F-15D', '18-12B', '18-K', '19B-4E', '2-A', '2-AF', '2-E', '20-F', '20FR12B', '20FR12G', '24F-2NT', '25', '25-NSE', '253G1', '253G2', '253G3', '253G4', '3', '305B2', '34-12H', '4', '40-17F1', '40-17F2', '40-17G', '40-17GCS', '40-202A', '40-203A', '40-206A', '40-24B2', '40-33', '40-6B', '40-8B25', '40-8F-2', '40-APP', '40-F', '40-OIP', '40FR12B', '40FR12G', '424A', '424B1', '424B2', '424B3', '424B4', '424B5', '424B7', '424B8', '424H', '425', '485APOS', '485BPOS', '485BXT', '486APOS', '486BPOS', '486BXT', '487', '497', '497AD', '497H2', '497J', '497K', '497VPI', '497VPU', '5', '6-K', '6B NTC', '6B ORDR', '8-A12B', '8-A12G', '8-K', '8-K12B', '8-K12G3', '8-K15D5', '8-M', '8F-2 NTC', '8F-2 ORDR', '9-M', 'ABS-15G', 'ABS-EE', 'ADN-MTL', 'ADV-E', 'ADV-H-C', 'ADV-H-T', 'ADV-NR', 'ANNLRPT', 'APP NTC', 'APP ORDR', 'APP WD', 'APP WDG', 'ARS', 'ATS-N', 'ATS-N-C', 'ATS-N/UA', 'AW', 'AW WD', 'C', 'C-AR', 'C-AR-W', 'C-TR', 'C-TR-W', 'C-U', 'C-U-W', 'C-W', 'CB', 'CERT', 'CERTARCA', 'CERTBATS', 'CERTCBO', 'CERTNAS', 'CERTNYS', 'CERTPAC', 'CFPORTAL', 'CFPORTAL-W', 'CORRESP', 'CT ORDER', 'D', 'DEF 14A', 'DEF 14C', 'DEFA14A', 'DEFA14C', 'DEFC14A', 'DEFC14C', 'DEFM14A', 'DEFM14C', 'DEFN14A', 'DEFR14A', 'DEFR14C', 'DEL AM', 'DFAN14A', 'DFRN14A', 'DOS', 'DOSLTR', 'DRS', 'DRSLTR', 'DSTRBRPT', 'EFFECT', 'F-1', 'F-10', 'F-10EF', 'F-10POS', 'F-1MEF', 'F-3', 'F-3ASR', 'F-3D', 'F-3DPOS', 'F-3MEF', 'F-4', 'F-4 POS', 'F-4MEF', 'F-6', 'F-6 POS', 'F-6EF', 'F-7', 'F-7 POS', 'F-8', 'F-8 POS', 'F-80', 'F-80POS', 'F-9', 'F-9 POS', 'F-N', 'F-X', 'FOCUSN', 'FWP', 'G-405', 'G-405N', 'G-FIN', 'G-FINW', 'IRANNOTICE', 'MA', 'MA-A', 'MA-I', 'MA-W', 'MSD', 'MSDCO', 'MSDW', 'N-1', 'N-14', 'N-14 8C', 'N-14MEF', 'N-18F1', 'N-1A', 'N-2', 'N-2 POSASR', 'N-23C-2', 'N-23C3A', 'N-23C3B', 'N-23C3C', 'N-2ASR', 'N-2MEF', 'N-30B-2', 'N-30D', 'N-4', 'N-5', 'N-54A', 'N-54C', 'N-6', 'N-6F', 'N-8A', 'N-8B-2', 'N-8F', 'N-8F NTC', 'N-8F ORDR', 'N-CEN', 'N-CR', 'N-CSR', 'N-CSRS', 'N-MFP', 'N-MFP1', 'N-MFP2', 'N-PX', 'N-Q', 'N-VP', 'N-VPFS', 'NO ACT', 'NPORT-EX', 'NPORT-NP', 'NPORT-P', 'NRSRO-CE', 'NRSRO-UPD', 'NSAR-A', 'NSAR-AT', 'NSAR-B', 'NSAR-BT', 'NSAR-U', 'NT 10-D', 'NT 10-K', 'NT 10-Q', 'NT 11-K', 'NT 20-F', 'NT N-CEN', 'NT N-MFP', 'NT N-MFP1', 'NT N-MFP2', 'NT NPORT-EX', 'NT NPORT-P', 'NT-NCEN', 'NT-NCSR', 'NT-NSAR', 'NTFNCEN', 'NTFNCSR', 'NTFNSAR', 'NTN 10D', 'NTN 10K', 'NTN 10Q', 'NTN 20F', 'OIP NTC', 'OIP ORDR', 'POS 8C', 'POS AM', 'POS AMI', 'POS EX', 'POS462B', 'POS462C', 'POSASR', 'PRE 14A', 'PRE 14C', 'PREC14A', 'PREC14C', 'PREM14A', 'PREM14C', 'PREN14A', 'PRER14A', 'PRER14C', 'PRRN14A', 'PX14A6G', 'PX14A6N', 'QRTLYRPT', 'QUALIF', 'REG-NR', 'REVOKED', 'RW', 'RW WD', 'S-1', 'S-11', 'S-11MEF', 'S-1MEF', 'S-20', 'S-3', 'S-3ASR', 'S-3D', 'S-3DPOS', 'S-3MEF', 'S-4', 'S-4 POS', 'S-4EF', 'S-4MEF', 'S-6', 'S-8', 'S-8 POS', 'S-B', 'S-BMEF', 'SBSE', 'SBSE-A', 'SBSE-BD', 'SBSE-C', 'SBSE-W', 'SC 13D', 'SC 13E1', 'SC 13E3', 'SC 13G', 'SC 14D9', 'SC 14F1', 'SC 14N', 'SC TO-C', 'SC TO-I', 'SC TO-T', 'SC13E4F', 'SC14D1F', 'SC14D9C', 'SC14D9F', 'SD', 'SDR', 'SE', 'SEC ACTION', 'SEC STAFF ACTION', 'SEC STAFF LETTER', 'SF-1', 'SF-3', 'SL', 'SP 15D2', 'STOP ORDER', 'SUPPL', 'T-3', 'TA-1', 'TA-2', 'TA-W', 'TACO', 'TH', 'TTW', 'UNDER', 'UPLOAD', 'WDL-REQ', 'X-17A-5']] + Type of the SEC filing form. (provider: sec) + use_cache : bool + Whether or not to use cache. If True, cache will store for one day. (provider: sec) + + Returns + ------- + OBBject + results : List[CompanyFilings] + Serializable results. + provider : Optional[Literal['fmp', 'intrinio', 'sec']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + CompanyFilings + -------------- + filing_date : date + The date of the filing. + accepted_date : Optional[datetime] + Accepted date of the filing. + symbol : Optional[str] + Symbol representing the entity requested in the data. + cik : Optional[str] + Central Index Key (CIK) for the requested entity. + report_type : Optional[str] + Type of filing. + filing_url : Optional[str] + URL to the filing page. + report_url : str + URL to the actual report. + id : Optional[str] + Intrinio ID of the filing. (provider: intrinio) + period_end_date : Optional[date] + Ending date of the fiscal period for the filing. (provider: intrinio) + sec_unique_id : Optional[str] + SEC unique ID of the filing. (provider: intrinio) + instance_url : Optional[str] + URL for the XBRL filing for the report. (provider: intrinio) + industry_group : Optional[str] + Industry group of the company. (provider: intrinio) + industry_category : Optional[str] + Industry category of the company. (provider: intrinio) + report_date : Optional[date] + The date of the filing. (provider: sec) + act : Optional[Union[int, str]] + The SEC Act number. (provider: sec) + items : Optional[Union[str, float]] + The SEC Item numbers. (provider: sec) + primary_doc_description : Optional[str] + The description of the primary document. (provider: sec) + primary_doc : Optional[str] + The filename of the primary document. (provider: sec) + accession_number : Optional[Union[int, str]] + The accession number. (provider: sec) + file_number : Optional[Union[int, str]] + The file number. (provider: sec) + film_number : Optional[Union[int, str]] + The film number. (provider: sec) + is_inline_xbrl : Optional[Union[int, str]] + Whether the filing is an inline XBRL filing. (provider: sec) + is_xbrl : Optional[Union[int, str]] + Whether the filing is an XBRL filing. (provider: sec) + size : Optional[Union[int, str]] + The size of the filing. (provider: sec) + complete_submission_url : Optional[str] + The URL to the complete filing submission. (provider: sec) + filing_detail_url : Optional[str] + The URL to the filing details. (provider: sec) + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.fundamental.filings(limit=100) """ # noqa: E501 return self._run( @@ -1234,14 +1282,46 @@ def filings( @validate def historical_attributes( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): intrinio.")], - tag: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio.")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - frequency: Annotated[Optional[Literal["daily", "weekly", "monthly", "quarterly", "yearly"]], OpenBBCustomParameter(description="The frequency of the data.")] = "yearly", - limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 1000, - tag_type: Annotated[Optional[str], OpenBBCustomParameter(description="Filter by type, when applicable.")] = None, - sort: Annotated[Optional[Literal["asc", "desc"]], OpenBBCustomParameter(description="Sort order.")] = "desc", + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): intrinio." + ), + ], + tag: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio." + ), + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + frequency: Annotated[ + Optional[Literal["daily", "weekly", "monthly", "quarterly", "yearly"]], + OpenBBCustomParameter(description="The frequency of the data."), + ] = "yearly", + limit: Annotated[ + Optional[int], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 1000, + tag_type: Annotated[ + Optional[str], + OpenBBCustomParameter(description="Filter by type, when applicable."), + ] = None, + sort: Annotated[ + Optional[Literal["asc", "desc"]], + OpenBBCustomParameter(description="Sort order."), + ] = "desc", provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -1322,7 +1402,10 @@ def historical_attributes( "sort": sort, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["intrinio"]}, "tag": {"multiple_items_allowed": ["intrinio"]}}, + extra_info={ + "symbol": {"multiple_items_allowed": ["intrinio"]}, + "tag": {"multiple_items_allowed": ["intrinio"]}, + }, ) ) @@ -1330,7 +1413,9 @@ def historical_attributes( @validate def historical_eps( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -1411,7 +1496,9 @@ def historical_eps( @validate def historical_splits( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -1478,9 +1565,16 @@ def historical_splits( @validate def income( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - limit: Annotated[Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return.")] = 5, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + period: Annotated[ + str, OpenBBCustomParameter(description="Time period of the data to return.") + ] = "annual", + limit: Annotated[ + Optional[Annotated[int, Ge(ge=0)]], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 5, provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -1829,9 +1923,17 @@ def income( @validate def income_growth( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 10, - period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 10, + period: Annotated[ + Literal["quarter", "annual"], + OpenBBCustomParameter(description="Time period of the data to return."), + ] = "annual", provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -1954,8 +2056,18 @@ def income_growth( @validate def latest_attributes( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): intrinio.")], - tag: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): intrinio." + ), + ], + tag: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio." + ), + ], provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -2016,7 +2128,10 @@ def latest_attributes( "tag": tag, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["intrinio"]}, "tag": {"multiple_items_allowed": ["intrinio"]}}, + extra_info={ + "symbol": {"multiple_items_allowed": ["intrinio"]}, + "tag": {"multiple_items_allowed": ["intrinio"]}, + }, ) ) @@ -2024,7 +2139,9 @@ def latest_attributes( @validate def management( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -2101,9 +2218,24 @@ def management( @validate def management_compensation( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fmp." + ), + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -2195,9 +2327,20 @@ def management_compensation( @validate def metrics( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp, yfinance.")], - period: Annotated[Optional[Literal["annual", "quarter"]], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 100, + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, yfinance." + ), + ], + period: Annotated[ + Optional[Literal["annual", "quarter"]], + OpenBBCustomParameter(description="Time period of the data to return."), + ] = "annual", + limit: Annotated[ + Optional[int], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 100, provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -2450,7 +2593,12 @@ def metrics( @validate def multiples( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fmp." + ), + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -2636,7 +2784,9 @@ def multiples( ) def overview( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -2747,7 +2897,11 @@ def overview( """ # noqa: E501 simplefilter("always", DeprecationWarning) - warn("This endpoint is deprecated; use `/equity/profile` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.", category=DeprecationWarning, stacklevel=2) + warn( + "This endpoint is deprecated; use `/equity/profile` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.", + category=DeprecationWarning, + stacklevel=2, + ) return self._run( "/equity/fundamental/overview", @@ -2770,9 +2924,16 @@ def overview( @validate def ratios( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 12, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + period: Annotated[ + str, OpenBBCustomParameter(description="Time period of the data to return.") + ] = "annual", + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 12, provider: Optional[Literal["fmp", "intrinio"]] = None, **kwargs ) -> OBBject: @@ -2957,10 +3118,24 @@ def ratios( @validate def reported_financials( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - period: Annotated[str, OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - statement_type: Annotated[str, OpenBBCustomParameter(description="The type of financial statement - i.e, balance, income, cash.")] = "balance", - limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return. Although the response object contains multiple results, because of the variance in the fields, year-to-year and quarter-to-quarter, it is recommended to view results in small chunks.")] = 100, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + period: Annotated[ + str, OpenBBCustomParameter(description="Time period of the data to return.") + ] = "annual", + statement_type: Annotated[ + str, + OpenBBCustomParameter( + description="The type of financial statement - i.e, balance, income, cash." + ), + ] = "balance", + limit: Annotated[ + Optional[int], + OpenBBCustomParameter( + description="The number of data entries to return. Although the response object contains multiple results, because of the variance in the fields, year-to-year and quarter-to-quarter, it is recommended to view results in small chunks." + ), + ] = 100, provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -3040,9 +3215,17 @@ def reported_financials( @validate def revenue_per_geography( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - structure: Annotated[Literal["hierarchical", "flat"], OpenBBCustomParameter(description="Structure of the returned data.")] = "flat", + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + period: Annotated[ + Literal["quarter", "annual"], + OpenBBCustomParameter(description="Time period of the data to return."), + ] = "annual", + structure: Annotated[ + Literal["hierarchical", "flat"], + OpenBBCustomParameter(description="Structure of the returned data."), + ] = "flat", provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -3117,9 +3300,17 @@ def revenue_per_geography( @validate def revenue_per_segment( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - period: Annotated[Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return.")] = "annual", - structure: Annotated[Literal["hierarchical", "flat"], OpenBBCustomParameter(description="Structure of the returned data.")] = "flat", + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + period: Annotated[ + Literal["quarter", "annual"], + OpenBBCustomParameter(description="Time period of the data to return."), + ] = "annual", + structure: Annotated[ + Literal["hierarchical", "flat"], + OpenBBCustomParameter(description="Structure of the returned data."), + ] = "flat", provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -3194,8 +3385,13 @@ def revenue_per_segment( @validate def search_attributes( self, - query: Annotated[str, OpenBBCustomParameter(description="Query to search for.")], - limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return.")] = 1000, + query: Annotated[ + str, OpenBBCustomParameter(description="Query to search for.") + ], + limit: Annotated[ + Optional[int], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 1000, provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: @@ -3279,8 +3475,15 @@ def search_attributes( @validate def trailing_dividend_yield( self, - symbol: Annotated[Optional[str], OpenBBCustomParameter(description="Symbol to get data for.")] = None, - limit: Annotated[Optional[int], OpenBBCustomParameter(description="The number of data entries to return. Default is 252, the number of trading days in a year.")] = 252, + symbol: Annotated[ + Optional[str], OpenBBCustomParameter(description="Symbol to get data for.") + ] = None, + limit: Annotated[ + Optional[int], + OpenBBCustomParameter( + description="The number of data entries to return. Default is 252, the number of trading days in a year." + ), + ] = 252, provider: Optional[Literal["tiingo"]] = None, **kwargs ) -> OBBject: @@ -3346,8 +3549,13 @@ def trailing_dividend_yield( @validate def transcript( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - year: Annotated[int, OpenBBCustomParameter(description="Year of the earnings call transcript.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + year: Annotated[ + int, + OpenBBCustomParameter(description="Year of the earnings call transcript."), + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index 8898ec2ef4cf..e43873bd1769 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -26,8 +26,13 @@ def __repr__(self) -> str: @validate def insider_trading( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return.")] = 500, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 500, provider: Optional[Literal["fmp", "intrinio"]] = None, **kwargs ) -> OBBject: @@ -157,7 +162,9 @@ def insider_trading( @validate def institutional( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -292,9 +299,17 @@ def institutional( @validate def major_holders( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], - date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="A specific date to get data for.")] = None, - page: Annotated[Optional[int], OpenBBCustomParameter(description="Page number of the data to fetch.")] = 0, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter(description="A specific date to get data for."), + ] = None, + page: Annotated[ + Optional[int], + OpenBBCustomParameter(description="Page number of the data to fetch."), + ] = 0, provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -437,7 +452,12 @@ def major_holders( @validate def share_statistics( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): yfinance.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." + ), + ], provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py index ef0d385a0070..1a79da00797d 100644 --- a/openbb_platform/openbb/package/equity_price.py +++ b/openbb_platform/openbb/package/equity_price.py @@ -26,11 +26,31 @@ def __repr__(self) -> str: @validate def historical( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance.")], - interval: Annotated[Optional[str], OpenBBCustomParameter(description="Time interval of the data to return.")] = "1d", - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - provider: Optional[Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"]] = None, + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance." + ), + ], + interval: Annotated[ + Optional[str], + OpenBBCustomParameter(description="Time interval of the data to return."), + ] = "1d", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + provider: Optional[ + Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"] + ] = None, **kwargs ) -> OBBject: """Get historical price data for a given stock. This includes open, high, low, close, and volume. @@ -170,7 +190,16 @@ def historical( "end_date": end_date, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp", "polygon", "tiingo", "yfinance"]}}, + extra_info={ + "symbol": { + "multiple_items_allowed": [ + "fmp", + "polygon", + "tiingo", + "yfinance", + ] + } + }, ) ) @@ -178,7 +207,9 @@ def historical( @validate def nbbo( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["polygon"]] = None, **kwargs ) -> OBBject: @@ -306,7 +337,12 @@ def nbbo( @validate def performance( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fmp." + ), + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -396,7 +432,12 @@ def performance( @validate def quote( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance." + ), + ], provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -550,6 +591,10 @@ def quote( "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp", "intrinio", "yfinance"]}}, + extra_info={ + "symbol": { + "multiple_items_allowed": ["fmp", "intrinio", "yfinance"] + } + }, ) ) diff --git a/openbb_platform/openbb/package/equity_shorts.py b/openbb_platform/openbb/package/equity_shorts.py index a3f3e7e53223..2ba386a6caa7 100644 --- a/openbb_platform/openbb/package/equity_shorts.py +++ b/openbb_platform/openbb/package/equity_shorts.py @@ -22,7 +22,9 @@ def __repr__(self) -> str: @validate def fails_to_deliver( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index f25d3109e71e..c4c7ce08a411 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -32,7 +32,12 @@ def __repr__(self) -> str: @validate def countries( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp." + ), + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -94,7 +99,12 @@ def countries( @validate def equity_exposure( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. (Stock) Multiple items allowed for provider(s): fmp.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. (Stock) Multiple items allowed for provider(s): fmp." + ), + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -166,9 +176,21 @@ def equity_exposure( @validate def historical( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: @@ -250,7 +272,9 @@ def historical( @validate def holdings( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") + ], provider: Optional[Literal["fmp", "sec"]] = None, **kwargs ) -> OBBject: @@ -481,7 +505,9 @@ def holdings( @validate def holdings_date( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -544,7 +570,12 @@ def holdings_date( @validate def holdings_performance( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fmp." + ), + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -634,7 +665,12 @@ def holdings_performance( @validate def info( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance." + ), + ], provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -790,7 +826,12 @@ def info( @validate def price_performance( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): fmp.")], + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): fmp." + ), + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -880,78 +921,80 @@ def price_performance( @validate def search( self, - query: Annotated[Optional[str], OpenBBCustomParameter(description="Search query.")] = "", + query: Annotated[ + Optional[str], OpenBBCustomParameter(description="Search query.") + ] = "", provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Search for ETFs. - An empty query returns the full list of ETFs from the provider. + An empty query returns the full list of ETFs from the provider. - Parameters - ---------- - query : Optional[str] - Search query. - provider : Optional[Literal['fmp']] - 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. - exchange : Optional[Literal['AMEX', 'NYSE', 'NASDAQ', 'ETF', 'TSX', 'EURONEXT']] - The exchange code the ETF trades on. (provider: fmp) - is_active : Optional[Literal[True, False]] - Whether the ETF is actively trading. (provider: fmp) - - Returns - ------- - OBBject - results : List[EtfSearch] - Serializable results. + Parameters + ---------- + query : Optional[str] + Search query. provider : Optional[Literal['fmp']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - EtfSearch - --------- - symbol : str - Symbol representing the entity requested in the data.(ETF) - name : Optional[str] - Name of the ETF. - market_cap : Optional[float] - The market cap of the ETF. (provider: fmp) - sector : Optional[str] - The sector of the ETF. (provider: fmp) - industry : Optional[str] - The industry of the ETF. (provider: fmp) - beta : Optional[float] - The beta of the ETF. (provider: fmp) - price : Optional[float] - The current price of the ETF. (provider: fmp) - last_annual_dividend : Optional[float] - The last annual dividend paid. (provider: fmp) - volume : Optional[float] - The current trading volume of the ETF. (provider: fmp) - exchange : Optional[str] - The exchange code the ETF trades on. (provider: fmp) - exchange_name : Optional[str] - The full name of the exchange the ETF trades on. (provider: fmp) - country : Optional[str] - The country the ETF is registered in. (provider: fmp) - actively_trading : Optional[Literal[True, False]] - Whether the ETF is actively trading. (provider: fmp) - - Examples - -------- - >>> from openbb import obb - >>> # An empty query returns the full list of ETFs from the provider. - >>> obb.etf.search() - >>> # The query will return results from text-based fields containing the term. - >>> obb.etf.search(query='commercial real estate', provider='fmp') + 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. + exchange : Optional[Literal['AMEX', 'NYSE', 'NASDAQ', 'ETF', 'TSX', 'EURONEXT']] + The exchange code the ETF trades on. (provider: fmp) + is_active : Optional[Literal[True, False]] + Whether the ETF is actively trading. (provider: fmp) + + Returns + ------- + OBBject + results : List[EtfSearch] + Serializable results. + provider : Optional[Literal['fmp']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + EtfSearch + --------- + symbol : str + Symbol representing the entity requested in the data.(ETF) + name : Optional[str] + Name of the ETF. + market_cap : Optional[float] + The market cap of the ETF. (provider: fmp) + sector : Optional[str] + The sector of the ETF. (provider: fmp) + industry : Optional[str] + The industry of the ETF. (provider: fmp) + beta : Optional[float] + The beta of the ETF. (provider: fmp) + price : Optional[float] + The current price of the ETF. (provider: fmp) + last_annual_dividend : Optional[float] + The last annual dividend paid. (provider: fmp) + volume : Optional[float] + The current trading volume of the ETF. (provider: fmp) + exchange : Optional[str] + The exchange code the ETF trades on. (provider: fmp) + exchange_name : Optional[str] + The full name of the exchange the ETF trades on. (provider: fmp) + country : Optional[str] + The country the ETF is registered in. (provider: fmp) + actively_trading : Optional[Literal[True, False]] + Whether the ETF is actively trading. (provider: fmp) + + Examples + -------- + >>> from openbb import obb + >>> # An empty query returns the full list of ETFs from the provider. + >>> obb.etf.search() + >>> # The query will return results from text-based fields containing the term. + >>> obb.etf.search(query='commercial real estate', provider='fmp') """ # noqa: E501 return self._run( @@ -975,7 +1018,9 @@ def search( @validate def sectors( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index ece316bdd4e2..80b74d5c1339 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -28,75 +28,91 @@ def corporate(self): # pylint: disable=import-outside-toplevel from . import fixedincome_corporate - return fixedincome_corporate.ROUTER_fixedincome_corporate(command_runner=self._command_runner) + return fixedincome_corporate.ROUTER_fixedincome_corporate( + command_runner=self._command_runner + ) @property def government(self): # pylint: disable=import-outside-toplevel from . import fixedincome_government - return fixedincome_government.ROUTER_fixedincome_government(command_runner=self._command_runner) + return fixedincome_government.ROUTER_fixedincome_government( + command_runner=self._command_runner + ) @property def rate(self): # pylint: disable=import-outside-toplevel from . import fixedincome_rate - return fixedincome_rate.ROUTER_fixedincome_rate(command_runner=self._command_runner) + return fixedincome_rate.ROUTER_fixedincome_rate( + command_runner=self._command_runner + ) @exception_handler @validate def sofr( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Secured Overnight Financing Rate. - The Secured Overnight Financing Rate (SOFR) is a broad measure of the cost of - borrowing cash overnight collateralizing by Treasury securities. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - period : Literal['overnight', '30_day', '90_day', '180_day', 'index'] - Period of SOFR rate. (provider: fred) - - Returns - ------- - OBBject - results : List[SOFR] - Serializable results. + The Secured Overnight Financing Rate (SOFR) is a broad measure of the cost of + borrowing cash overnight collateralizing by Treasury securities. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SOFR - ---- - date : date - The date of the data. - rate : Optional[float] - SOFR rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.sofr(period='overnight') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + period : Literal['overnight', '30_day', '90_day', '180_day', 'index'] + Period of SOFR rate. (provider: fred) + + Returns + ------- + OBBject + results : List[SOFR] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SOFR + ---- + date : date + The date of the data. + rate : Optional[float] + SOFR rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.sofr(period='overnight') """ # noqa: E501 return self._run( @@ -122,4 +138,6 @@ def spreads(self): # pylint: disable=import-outside-toplevel from . import fixedincome_spreads - return fixedincome_spreads.ROUTER_fixedincome_spreads(command_runner=self._command_runner) + return fixedincome_spreads.ROUTER_fixedincome_spreads( + command_runner=self._command_runner + ) diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index 9b4dbe615ab8..3fdcb2f9cba7 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -27,64 +27,82 @@ def __repr__(self) -> str: @validate def commercial_paper( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - maturity: Annotated[Literal["overnight", "7d", "15d", "30d", "60d", "90d"], OpenBBCustomParameter(description="The maturity.")] = "30d", - category: Annotated[Literal["asset_backed", "financial", "nonfinancial"], OpenBBCustomParameter(description="The category.")] = "financial", - grade: Annotated[Literal["aa", "a2_p2"], OpenBBCustomParameter(description="The grade.")] = "aa", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + maturity: Annotated[ + Literal["overnight", "7d", "15d", "30d", "60d", "90d"], + OpenBBCustomParameter(description="The maturity."), + ] = "30d", + category: Annotated[ + Literal["asset_backed", "financial", "nonfinancial"], + OpenBBCustomParameter(description="The category."), + ] = "financial", + grade: Annotated[ + Literal["aa", "a2_p2"], OpenBBCustomParameter(description="The grade.") + ] = "aa", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Commercial Paper. - Commercial paper (CP) consists of short-term, promissory notes issued primarily by corporations. - Maturities range up to 270 days but average about 30 days. - Many companies use CP to raise cash needed for current transactions, - and many find it to be a lower-cost alternative to bank loans. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : Literal['overnight', '7d', '15d', '30d', '60d', '90d'] - The maturity. - category : Literal['asset_backed', 'financial', 'nonfinancial'] - The category. - grade : Literal['aa', 'a2_p2'] - The grade. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[CommercialPaper] - Serializable results. + Commercial paper (CP) consists of short-term, promissory notes issued primarily by corporations. + Maturities range up to 270 days but average about 30 days. + Many companies use CP to raise cash needed for current transactions, + and many find it to be a lower-cost alternative to bank loans. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : Literal['overnight', '7d', '15d', '30d', '60d', '90d'] + The maturity. + category : Literal['asset_backed', 'financial', 'nonfinancial'] + The category. + grade : Literal['aa', 'a2_p2'] + The grade. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - CommercialPaper - --------------- - date : date - The date of the data. - rate : Optional[float] - Commercial Paper Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.commercial_paper(maturity='15d') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[CommercialPaper] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + CommercialPaper + --------------- + date : date + The date of the data. + rate : Optional[float] + Commercial Paper Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.commercial_paper(maturity='15d') """ # noqa: E501 return self._run( @@ -112,61 +130,67 @@ def commercial_paper( @validate def hqm( self, - date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="A specific date to get data for.")] = None, - yield_curve: Annotated[Literal["spot", "par"], OpenBBCustomParameter(description="The yield curve type.")] = "spot", + date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter(description="A specific date to get data for."), + ] = None, + yield_curve: Annotated[ + Literal["spot", "par"], + OpenBBCustomParameter(description="The yield curve type."), + ] = "spot", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """High Quality Market Corporate Bond. - The HQM yield curve represents the high quality corporate bond market, i.e., - corporate bonds rated AAA, AA, or A. The HQM curve contains two regression terms. - These terms are adjustment factors that blend AAA, AA, and A bonds into a single HQM yield curve - that is the market-weighted average (MWA) quality of high quality bonds. - - - Parameters - ---------- - date : Union[datetime.date, None, str] - A specific date to get data for. - yield_curve : Literal['spot', 'par'] - The yield curve type. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[HighQualityMarketCorporateBond] - Serializable results. + The HQM yield curve represents the high quality corporate bond market, i.e., + corporate bonds rated AAA, AA, or A. The HQM curve contains two regression terms. + These terms are adjustment factors that blend AAA, AA, and A bonds into a single HQM yield curve + that is the market-weighted average (MWA) quality of high quality bonds. + + + Parameters + ---------- + date : Union[datetime.date, None, str] + A specific date to get data for. + yield_curve : Literal['spot', 'par'] + The yield curve type. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - HighQualityMarketCorporateBond - ------------------------------ - date : date - The date of the data. - rate : Optional[float] - HighQualityMarketCorporateBond Rate. - maturity : str - Maturity. - yield_curve : Literal['spot', 'par'] - The yield curve type. - series_id : Optional[str] - FRED series id. (provider: fred) - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.hqm(yield_curve='par') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[HighQualityMarketCorporateBond] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + HighQualityMarketCorporateBond + ------------------------------ + date : date + The date of the data. + rate : Optional[float] + HighQualityMarketCorporateBond Rate. + maturity : str + Maturity. + yield_curve : Literal['spot', 'par'] + The yield curve type. + series_id : Optional[str] + FRED series id. (provider: fred) + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.hqm(yield_curve='par') """ # noqa: E501 return self._run( @@ -191,67 +215,80 @@ def hqm( @validate def ice_bofa( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - index_type: Annotated[Literal["yield", "yield_to_worst", "total_return", "spread"], OpenBBCustomParameter(description="The type of series.")] = "yield", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + index_type: Annotated[ + Literal["yield", "yield_to_worst", "total_return", "spread"], + OpenBBCustomParameter(description="The type of series."), + ] = "yield", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """ICE BofA US Corporate Bond Indices. - The ICE BofA US Corporate Index tracks the performance of US dollar denominated investment grade corporate debt - publicly issued in the US domestic market. Qualifying securities must have an investment grade rating (based on an - average of Moody’s, S&P and Fitch), at least 18 months to final maturity at the time of issuance, at least one year - remaining term to final maturity as of the rebalance date, a fixed coupon schedule and a minimum amount - outstanding of $250 million. The ICE BofA US Corporate Index is a component of the US Corporate Master Index. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - index_type : Literal['yield', 'yield_to_worst', 'total_return', 'spread'] - The type of series. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - category : Literal['all', 'duration', 'eur', 'usd'] - The type of category. (provider: fred) - area : Literal['asia', 'emea', 'eu', 'ex_g10', 'latin_america', 'us'] - The type of area. (provider: fred) - grade : Literal['a', 'aa', 'aaa', 'b', 'bb', 'bbb', 'ccc', 'crossover', 'high_grade', 'high_yield', 'non_financial', 'non_sovereign', 'private_sector', 'public_sector'] - The type of grade. (provider: fred) - options : bool - Whether to include options in the results. (provider: fred) - - Returns - ------- - OBBject - results : List[ICEBofA] - Serializable results. + The ICE BofA US Corporate Index tracks the performance of US dollar denominated investment grade corporate debt + publicly issued in the US domestic market. Qualifying securities must have an investment grade rating (based on an + average of Moody’s, S&P and Fitch), at least 18 months to final maturity at the time of issuance, at least one year + remaining term to final maturity as of the rebalance date, a fixed coupon schedule and a minimum amount + outstanding of $250 million. The ICE BofA US Corporate Index is a component of the US Corporate Master Index. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + index_type : Literal['yield', 'yield_to_worst', 'total_return', 'spread'] + The type of series. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - ICEBofA - ------- - date : date - The date of the data. - rate : Optional[float] - ICE BofA US Corporate Bond Indices Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + category : Literal['all', 'duration', 'eur', 'usd'] + The type of category. (provider: fred) + area : Literal['asia', 'emea', 'eu', 'ex_g10', 'latin_america', 'us'] + The type of area. (provider: fred) + grade : Literal['a', 'aa', 'aaa', 'b', 'bb', 'bbb', 'ccc', 'crossover', 'high_grade', 'high_yield', 'non_financial', 'non_sovereign', 'private_sector', 'public_sector'] + The type of grade. (provider: fred) + options : bool + Whether to include options in the results. (provider: fred) + + Returns + ------- + OBBject + results : List[ICEBofA] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + ICEBofA + ------- + date : date + The date of the data. + rate : Optional[float] + ICE BofA US Corporate Bond Indices Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst') """ # noqa: E501 return self._run( @@ -277,60 +314,73 @@ def ice_bofa( @validate def moody( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - index_type: Annotated[Literal["aaa", "baa"], OpenBBCustomParameter(description="The type of series.")] = "aaa", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + index_type: Annotated[ + Literal["aaa", "baa"], + OpenBBCustomParameter(description="The type of series."), + ] = "aaa", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Moody Corporate Bond Index. - Moody's Aaa and Baa are investment bonds that acts as an index of - the performance of all bonds given an Aaa or Baa rating by Moody's Investors Service respectively. - These corporate bonds often are used in macroeconomics as an alternative to the federal ten-year - Treasury Bill as an indicator of the interest rate. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - index_type : Literal['aaa', 'baa'] - The type of series. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - spread : Optional[Literal['treasury', 'fed_funds']] - The type of spread. (provider: fred) - - Returns - ------- - OBBject - results : List[MoodyCorporateBondIndex] - Serializable results. + Moody's Aaa and Baa are investment bonds that acts as an index of + the performance of all bonds given an Aaa or Baa rating by Moody's Investors Service respectively. + These corporate bonds often are used in macroeconomics as an alternative to the federal ten-year + Treasury Bill as an indicator of the interest rate. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + index_type : Literal['aaa', 'baa'] + The type of series. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - MoodyCorporateBondIndex - ----------------------- - date : date - The date of the data. - rate : Optional[float] - Moody Corporate Bond Index Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.moody(index_type='baa') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + spread : Optional[Literal['treasury', 'fed_funds']] + The type of spread. (provider: fred) + + Returns + ------- + OBBject + results : List[MoodyCorporateBondIndex] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + MoodyCorporateBondIndex + ----------------------- + date : date + The date of the data. + rate : Optional[float] + Moody Corporate Bond Index Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.moody(index_type='baa') """ # noqa: E501 return self._run( @@ -356,61 +406,76 @@ def moody( @validate def spot_rates( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - maturity: Annotated[List[float], OpenBBCustomParameter(description="The maturities in years.")] = [10.0], - category: Annotated[List[Literal["par_yield", "spot_rate"]], OpenBBCustomParameter(description="The category.")] = ["spot_rate"], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + maturity: Annotated[ + List[float], OpenBBCustomParameter(description="The maturities in years.") + ] = [10.0], + category: Annotated[ + List[Literal["par_yield", "spot_rate"]], + OpenBBCustomParameter(description="The category."), + ] = ["spot_rate"], provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Spot Rates. - The spot rates for any maturity is the yield on a bond that provides a single payment at that maturity. - This is a zero coupon bond. - Because each spot rate pertains to a single cashflow, it is the relevant interest rate - concept for discounting a pension liability at the same maturity. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : List[float] - The maturities in years. - category : List[Literal['par_yield', 'spot_rate']] - The category. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[SpotRate] - Serializable results. + The spot rates for any maturity is the yield on a bond that provides a single payment at that maturity. + This is a zero coupon bond. + Because each spot rate pertains to a single cashflow, it is the relevant interest rate + concept for discounting a pension liability at the same maturity. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : List[float] + The maturities in years. + category : List[Literal['par_yield', 'spot_rate']] + The category. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SpotRate - -------- - date : date - The date of the data. - rate : Optional[float] - Spot Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.spot_rates(maturity=[10, 20, 30, 50]) + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[SpotRate] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SpotRate + -------- + date : date + The date of the data. + rate : Optional[float] + Spot Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.spot_rates(maturity=[10, 20, 30, 50]) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_government.py b/openbb_platform/openbb/package/fixedincome_government.py index d488f93554f8..61c6d4086c44 100644 --- a/openbb_platform/openbb/package/fixedincome_government.py +++ b/openbb_platform/openbb/package/fixedincome_government.py @@ -24,8 +24,18 @@ def __repr__(self) -> str: @validate def treasury_rates( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["federal_reserve", "fmp"]] = None, **kwargs ) -> OBBject: @@ -115,8 +125,16 @@ def treasury_rates( @validate def us_yield_curve( self, - date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="A specific date to get data for. Defaults to the most recent FRED entry.")] = None, - inflation_adjusted: Annotated[Optional[bool], OpenBBCustomParameter(description="Get inflation adjusted rates.")] = False, + date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="A specific date to get data for. Defaults to the most recent FRED entry." + ), + ] = None, + inflation_adjusted: Annotated[ + Optional[bool], + OpenBBCustomParameter(description="Get inflation adjusted rates."), + ] = False, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/fixedincome_rate.py b/openbb_platform/openbb/package/fixedincome_rate.py index 971ea31f4837..6e19898cc51b 100644 --- a/openbb_platform/openbb/package/fixedincome_rate.py +++ b/openbb_platform/openbb/package/fixedincome_rate.py @@ -30,56 +30,66 @@ def __repr__(self) -> str: @validate def ameribor( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Ameribor. - Ameribor (short for the American interbank offered rate) is a benchmark interest rate that reflects the true cost of - short-term interbank borrowing. This rate is based on transactions in overnight unsecured loans conducted on the - American Financial Exchange (AFX). - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - parameter : Literal['overnight', 'term_30', 'term_90', '1_week_term_structure', '1_month_term_structure', '3_month_term_structure', '6_month_term_structure', '1_year_term_structure', '2_year_term_structure', '30_day_ma', '90_day_ma'] - Period of AMERIBOR rate. (provider: fred) - - Returns - ------- - OBBject - results : List[AMERIBOR] - Serializable results. + Ameribor (short for the American interbank offered rate) is a benchmark interest rate that reflects the true cost of + short-term interbank borrowing. This rate is based on transactions in overnight unsecured loans conducted on the + American Financial Exchange (AFX). + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - AMERIBOR - -------- - date : date - The date of the data. - rate : Optional[float] - AMERIBOR rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + parameter : Literal['overnight', 'term_30', 'term_90', '1_week_term_structure', '1_month_term_structure', '3_month_term_structure', '6_month_term_structure', '1_year_term_structure', '2_year_term_structure', '30_day_ma', '90_day_ma'] + Period of AMERIBOR rate. (provider: fred) + + Returns + ------- + OBBject + results : List[AMERIBOR] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + AMERIBOR + -------- + date : date + The date of the data. + rate : Optional[float] + AMERIBOR rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma') """ # noqa: E501 return self._run( @@ -104,57 +114,67 @@ def ameribor( @validate def dpcredit( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Discount Window Primary Credit Rate. - A bank rate is the interest rate a nation's central bank charges to its domestic banks to borrow money. - The rates central banks charge are set to stabilize the economy. - In the United States, the Federal Reserve System's Board of Governors set the bank rate, - also known as the discount rate. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - parameter : Literal['daily_excl_weekend', 'monthly', 'weekly', 'daily', 'annual'] - FRED series ID of DWPCR data. (provider: fred) - - Returns - ------- - OBBject - results : List[DiscountWindowPrimaryCreditRate] - Serializable results. + A bank rate is the interest rate a nation's central bank charges to its domestic banks to borrow money. + The rates central banks charge are set to stabilize the economy. + In the United States, the Federal Reserve System's Board of Governors set the bank rate, + also known as the discount rate. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - DiscountWindowPrimaryCreditRate - ------------------------------- - date : date - The date of the data. - rate : Optional[float] - Discount Window Primary Credit Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + parameter : Literal['daily_excl_weekend', 'monthly', 'weekly', 'daily', 'annual'] + FRED series ID of DWPCR data. (provider: fred) + + Returns + ------- + OBBject + results : List[DiscountWindowPrimaryCreditRate] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + DiscountWindowPrimaryCreditRate + ------------------------------- + date : date + The date of the data. + rate : Optional[float] + Discount Window Primary Credit Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') """ # noqa: E501 return self._run( @@ -179,60 +199,73 @@ def dpcredit( @validate def ecb( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - interest_rate_type: Annotated[Literal["deposit", "lending", "refinancing"], OpenBBCustomParameter(description="The type of interest rate.")] = "lending", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + interest_rate_type: Annotated[ + Literal["deposit", "lending", "refinancing"], + OpenBBCustomParameter(description="The type of interest rate."), + ] = "lending", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """European Central Bank Interest Rates. - The Governing Council of the ECB sets the key interest rates for the euro area: - - - The interest rate on the main refinancing operations (MRO), which provide - the bulk of liquidity to the banking system. - - The rate on the deposit facility, which banks may use to make overnight deposits with the Eurosystem. - - The rate on the marginal lending facility, which offers overnight credit to banks from the Eurosystem. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - interest_rate_type : Literal['deposit', 'lending', 'refinancing'] - The type of interest rate. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[EuropeanCentralBankInterestRates] - Serializable results. + The Governing Council of the ECB sets the key interest rates for the euro area: + + - The interest rate on the main refinancing operations (MRO), which provide + the bulk of liquidity to the banking system. + - The rate on the deposit facility, which banks may use to make overnight deposits with the Eurosystem. + - The rate on the marginal lending facility, which offers overnight credit to banks from the Eurosystem. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + interest_rate_type : Literal['deposit', 'lending', 'refinancing'] + The type of interest rate. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - EuropeanCentralBankInterestRates - -------------------------------- - date : date - The date of the data. - rate : Optional[float] - European Central Bank Interest Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[EuropeanCentralBankInterestRates] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + EuropeanCentralBankInterestRates + -------------------------------- + date : date + The date of the data. + rate : Optional[float] + European Central Bank Interest Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing') """ # noqa: E501 return self._run( @@ -258,56 +291,66 @@ def ecb( @validate def effr( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["federal_reserve", "fred"]] = None, **kwargs ) -> OBBject: """Fed Funds Rate. - Get Effective Federal Funds Rate data. A bank rate is the interest rate a nation's central bank charges to its - domestic banks to borrow money. The rates central banks charge are set to stabilize the economy. In the - United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['federal_reserve', 'fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'federal_reserve' if there is - no default. - parameter : Literal['monthly', 'daily', 'weekly', 'daily_excl_weekend', 'annual', 'biweekly', 'volume'] - Period of FED rate. (provider: fred) - - Returns - ------- - OBBject - results : List[FEDFUNDS] - Serializable results. + Get Effective Federal Funds Rate data. A bank rate is the interest rate a nation's central bank charges to its + domestic banks to borrow money. The rates central banks charge are set to stabilize the economy. In the + United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['federal_reserve', 'fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - FEDFUNDS - -------- - date : date - The date of the data. - rate : Optional[float] - FED rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.effr(parameter='daily', provider='fred') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'federal_reserve' if there is + no default. + parameter : Literal['monthly', 'daily', 'weekly', 'daily_excl_weekend', 'annual', 'biweekly', 'volume'] + Period of FED rate. (provider: fred) + + Returns + ------- + OBBject + results : List[FEDFUNDS] + Serializable results. + provider : Optional[Literal['federal_reserve', 'fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + FEDFUNDS + -------- + date : date + The date of the data. + rate : Optional[float] + FED rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.effr(parameter='daily', provider='fred') """ # noqa: E501 return self._run( @@ -331,64 +374,62 @@ def effr( @exception_handler @validate def effr_forecast( - self, - provider: Optional[Literal["fred"]] = None, - **kwargs + self, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Fed Funds Rate Projections. - The projections for the federal funds rate are the value of the midpoint of the - projected appropriate target range for the federal funds rate or the projected - appropriate target level for the federal funds rate at the end of the specified - calendar year or over the longer run. - - - Parameters - ---------- - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - long_run : bool - Flag to show long run projections (provider: fred) - - Returns - ------- - OBBject - results : List[PROJECTIONS] - Serializable results. + The projections for the federal funds rate are the value of the midpoint of the + projected appropriate target range for the federal funds rate or the projected + appropriate target level for the federal funds rate at the end of the specified + calendar year or over the longer run. + + + Parameters + ---------- provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - PROJECTIONS - ----------- - date : date - The date of the data. - range_high : Optional[float] - High projection of rates. - central_tendency_high : Optional[float] - Central tendency of high projection of rates. - median : Optional[float] - Median projection of rates. - range_midpoint : Optional[float] - Midpoint projection of rates. - central_tendency_midpoint : Optional[float] - Central tendency of midpoint projection of rates. - range_low : Optional[float] - Low projection of rates. - central_tendency_low : Optional[float] - Central tendency of low projection of rates. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.effr_forecast(long_run=True) + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + long_run : bool + Flag to show long run projections (provider: fred) + + Returns + ------- + OBBject + results : List[PROJECTIONS] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + PROJECTIONS + ----------- + date : date + The date of the data. + range_high : Optional[float] + High projection of rates. + central_tendency_high : Optional[float] + Central tendency of high projection of rates. + median : Optional[float] + Median projection of rates. + range_midpoint : Optional[float] + Midpoint projection of rates. + central_tendency_midpoint : Optional[float] + Central tendency of midpoint projection of rates. + range_low : Optional[float] + Low projection of rates. + central_tendency_low : Optional[float] + Central tendency of low projection of rates. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.effr_forecast(long_run=True) """ # noqa: E501 return self._run( @@ -401,8 +442,7 @@ def effr_forecast( ("fred",), ) }, - standard_params={ - }, + standard_params={}, extra_params=kwargs, ) ) @@ -411,57 +451,67 @@ def effr_forecast( @validate def estr( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Euro Short-Term Rate. - The euro short-term rate (€STR) reflects the wholesale euro unsecured overnight borrowing costs of banks located in - the euro area. The €STR is published on each TARGET2 business day based on transactions conducted and settled on - the previous TARGET2 business day (the reporting date “T”) with a maturity date of T+1 which are deemed to have been - executed at arm’s length and thus reflect market rates in an unbiased way. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - parameter : Literal['volume_weighted_trimmed_mean_rate', 'number_of_transactions', 'number_of_active_banks', 'total_volume', 'share_of_volume_of_the_5_largest_active_banks', 'rate_at_75th_percentile_of_volume', 'rate_at_25th_percentile_of_volume'] - Period of ESTR rate. (provider: fred) - - Returns - ------- - OBBject - results : List[ESTR] - Serializable results. + The euro short-term rate (€STR) reflects the wholesale euro unsecured overnight borrowing costs of banks located in + the euro area. The €STR is published on each TARGET2 business day based on transactions conducted and settled on + the previous TARGET2 business day (the reporting date “T”) with a maturity date of T+1 which are deemed to have been + executed at arm’s length and thus reflect market rates in an unbiased way. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - ESTR - ---- - date : date - The date of the data. - rate : Optional[float] - ESTR rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + parameter : Literal['volume_weighted_trimmed_mean_rate', 'number_of_transactions', 'number_of_active_banks', 'total_volume', 'share_of_volume_of_the_5_largest_active_banks', 'rate_at_75th_percentile_of_volume', 'rate_at_25th_percentile_of_volume'] + Period of ESTR rate. (provider: fred) + + Returns + ------- + OBBject + results : List[ESTR] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + ESTR + ---- + date : date + The date of the data. + rate : Optional[float] + ESTR rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks') """ # noqa: E501 return self._run( @@ -486,54 +536,64 @@ def estr( @validate def iorb( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Interest on Reserve Balances. - Get Interest Rate on Reserve Balances data A bank rate is the interest rate a nation's central bank charges to its - domestic banks to borrow money. The rates central banks charge are set to stabilize the economy. In the - United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[IORB] - Serializable results. + Get Interest Rate on Reserve Balances data A bank rate is the interest rate a nation's central bank charges to its + domestic banks to borrow money. The rates central banks charge are set to stabilize the economy. In the + United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - IORB - ---- - date : date - The date of the data. - rate : Optional[float] - IORB rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.iorb() + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[IORB] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + IORB + ---- + date : date + The date of the data. + rate : Optional[float] + IORB rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.iorb() """ # noqa: E501 return self._run( @@ -558,56 +618,66 @@ def iorb( @validate def sonia( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Sterling Overnight Index Average. - SONIA (Sterling Overnight Index Average) is an important interest rate benchmark. SONIA is based on actual - transactions and reflects the average of the interest rates that banks pay to borrow sterling overnight from other - financial institutions and other institutional investors. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - parameter : Literal['rate', 'index', '10th_percentile', '25th_percentile', '75th_percentile', '90th_percentile', 'total_nominal_value'] - Period of SONIA rate. (provider: fred) - - Returns - ------- - OBBject - results : List[SONIA] - Serializable results. + SONIA (Sterling Overnight Index Average) is an important interest rate benchmark. SONIA is based on actual + transactions and reflects the average of the interest rates that banks pay to borrow sterling overnight from other + financial institutions and other institutional investors. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SONIA - ----- - date : date - The date of the data. - rate : Optional[float] - SONIA rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + parameter : Literal['rate', 'index', '10th_percentile', '25th_percentile', '75th_percentile', '90th_percentile', 'total_nominal_value'] + Period of SONIA rate. (provider: fred) + + Returns + ------- + OBBject + results : List[SONIA] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SONIA + ----- + date : date + The date of the data. + rate : Optional[float] + SONIA rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_spreads.py b/openbb_platform/openbb/package/fixedincome_spreads.py index d9a91c00b670..8664cf7763e2 100644 --- a/openbb_platform/openbb/package/fixedincome_spreads.py +++ b/openbb_platform/openbb/package/fixedincome_spreads.py @@ -25,58 +25,71 @@ def __repr__(self) -> str: @validate def tcm( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - maturity: Annotated[Optional[Literal["3m", "2y"]], OpenBBCustomParameter(description="The maturity")] = "3m", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + maturity: Annotated[ + Optional[Literal["3m", "2y"]], + OpenBBCustomParameter(description="The maturity"), + ] = "3m", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Treasury Constant Maturity. - Get data for 10-Year Treasury Constant Maturity Minus Selected Treasury Constant Maturity. - Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of auctioned U.S. - Treasuries. The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury - yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : Optional[Literal['3m', '2y']] - The maturity - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[TreasuryConstantMaturity] - Serializable results. + Get data for 10-Year Treasury Constant Maturity Minus Selected Treasury Constant Maturity. + Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of auctioned U.S. + Treasuries. The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury + yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : Optional[Literal['3m', '2y']] + The maturity provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - TreasuryConstantMaturity - ------------------------ - date : date - The date of the data. - rate : Optional[float] - TreasuryConstantMaturity Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.spreads.tcm(maturity='2y') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[TreasuryConstantMaturity] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + TreasuryConstantMaturity + ------------------------ + date : date + The date of the data. + rate : Optional[float] + TreasuryConstantMaturity Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.spreads.tcm(maturity='2y') """ # noqa: E501 return self._run( @@ -102,58 +115,71 @@ def tcm( @validate def tcm_effr( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - maturity: Annotated[Optional[Literal["10y", "5y", "1y", "6m", "3m"]], OpenBBCustomParameter(description="The maturity")] = "10y", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + maturity: Annotated[ + Optional[Literal["10y", "5y", "1y", "6m", "3m"]], + OpenBBCustomParameter(description="The maturity"), + ] = "10y", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Select Treasury Constant Maturity. - Get data for Selected Treasury Constant Maturity Minus Federal Funds Rate - Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of auctioned U.S. - Treasuries. The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury - yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : Optional[Literal['10y', '5y', '1y', '6m', '3m']] - The maturity - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[SelectedTreasuryConstantMaturity] - Serializable results. + Get data for Selected Treasury Constant Maturity Minus Federal Funds Rate + Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of auctioned U.S. + Treasuries. The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury + yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : Optional[Literal['10y', '5y', '1y', '6m', '3m']] + The maturity provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SelectedTreasuryConstantMaturity - -------------------------------- - date : date - The date of the data. - rate : Optional[float] - Selected Treasury Constant Maturity Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.spreads.tcm_effr(maturity='10y') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[SelectedTreasuryConstantMaturity] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SelectedTreasuryConstantMaturity + -------------------------------- + date : date + The date of the data. + rate : Optional[float] + Selected Treasury Constant Maturity Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.spreads.tcm_effr(maturity='10y') """ # noqa: E501 return self._run( @@ -179,59 +205,72 @@ def tcm_effr( @validate def treasury_effr( self, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - maturity: Annotated[Optional[Literal["3m", "6m"]], OpenBBCustomParameter(description="The maturity")] = "3m", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + maturity: Annotated[ + Optional[Literal["3m", "6m"]], + OpenBBCustomParameter(description="The maturity"), + ] = "3m", provider: Optional[Literal["fred"]] = None, **kwargs ) -> OBBject: """Select Treasury Bill. - Get Selected Treasury Bill Minus Federal Funds Rate. - Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of - auctioned U.S. Treasuries. - The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury - yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. - - - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : Optional[Literal['3m', '6m']] - The maturity - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[SelectedTreasuryBill] - Serializable results. + Get Selected Treasury Bill Minus Federal Funds Rate. + Constant maturity is the theoretical value of a U.S. Treasury that is based on recent values of + auctioned U.S. Treasuries. + The value is obtained by the U.S. Treasury on a daily basis through interpolation of the Treasury + yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. + + + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : Optional[Literal['3m', '6m']] + The maturity provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SelectedTreasuryBill - -------------------- - date : date - The date of the data. - rate : Optional[float] - SelectedTreasuryBill Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.spreads.treasury_effr(maturity='6m') + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[SelectedTreasuryBill] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SelectedTreasuryBill + -------------------- + date : date + The date of the data. + rate : Optional[float] + SelectedTreasuryBill Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.spreads.treasury_effr(maturity='6m') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index 91e942fc87fd..8e1cbd0d7865 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -27,9 +27,7 @@ def __repr__(self) -> str: @exception_handler @validate def available( - self, - provider: Optional[Literal["fmp", "yfinance"]] = None, - **kwargs + self, provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: """All indices available from a given provider. @@ -85,8 +83,7 @@ def available( ("fmp", "yfinance"), ) }, - standard_params={ - }, + standard_params={}, extra_params=kwargs, ) ) @@ -95,7 +92,9 @@ def available( @validate def constituents( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: @@ -176,9 +175,24 @@ def constituents( ) def market( self, - symbol: Annotated[Union[str, List[str]], OpenBBCustomParameter(description="Symbol to get data for. Multiple items allowed for provider(s): yfinance.")], - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + symbol: Annotated[ + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." + ), + ], + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: @@ -273,7 +287,11 @@ def market( """ # noqa: E501 simplefilter("always", DeprecationWarning) - warn("This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.", category=DeprecationWarning, stacklevel=2) + warn( + "This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.", + category=DeprecationWarning, + stacklevel=2, + ) return self._run( "/index/market", diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index 93bf3fc3f3d0..b6e37e0b4cb8 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -25,11 +25,31 @@ def __repr__(self) -> str: @validate def company( self, - symbol: Annotated[Union[str, None, List[str]], OpenBBCustomParameter(description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, yfinance.")] = None, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, - limit: Annotated[Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return.")] = 2500, - provider: Optional[Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"]] = None, + symbol: Annotated[ + Union[str, None, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, yfinance." + ), + ] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, + limit: Annotated[ + Optional[Annotated[int, Ge(ge=0)]], + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 2500, + provider: Optional[ + Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"] + ] = None, **kwargs ) -> OBBject: """Company News. Get news for one or more companies. @@ -157,7 +177,14 @@ def company( "provider": self._get_provider( provider, "/news/company", - ("benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"), + ( + "benzinga", + "fmp", + "intrinio", + "polygon", + "tiingo", + "yfinance", + ), ) }, standard_params={ @@ -167,7 +194,18 @@ def company( "limit": limit, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"]}}, + extra_info={ + "symbol": { + "multiple_items_allowed": [ + "benzinga", + "fmp", + "intrinio", + "polygon", + "tiingo", + "yfinance", + ] + } + }, ) ) @@ -175,9 +213,24 @@ def company( @validate def world( self, - limit: Annotated[int, OpenBBCustomParameter(description="The number of data entries to return. The number of articles to return.")] = 2500, - start_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="Start date of the data, in YYYY-MM-DD format.")] = None, - end_date: Annotated[Union[datetime.date, None, str], OpenBBCustomParameter(description="End date of the data, in YYYY-MM-DD format.")] = None, + limit: Annotated[ + int, + OpenBBCustomParameter( + description="The number of data entries to return. The number of articles to return." + ), + ] = 2500, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format." + ), + ] = None, provider: Optional[Literal["benzinga", "fmp", "intrinio", "tiingo"]] = None, **kwargs ) -> OBBject: diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index b36887e72a05..b0b9dd3e8d86 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -27,7 +27,9 @@ def __repr__(self) -> str: @validate def cik_map( self, - symbol: Annotated[str, OpenBBCustomParameter(description="Symbol to get data for.")], + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -89,7 +91,12 @@ def cik_map( def institutions_search( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether or not to use cache. If True, cache will store for seven days.")] = True, + use_cache: Annotated[ + Optional[bool], + OpenBBCustomParameter( + description="Whether or not to use cache. If True, cache will store for seven days." + ), + ] = True, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -154,9 +161,7 @@ def institutions_search( @exception_handler @validate def rss_litigation( - self, - provider: Optional[Literal["sec"]] = None, - **kwargs + self, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: """The RSS feed provides links to litigation releases concerning civil lawsuits brought by the Commission in federal court. @@ -210,8 +215,7 @@ def rss_litigation( ("sec",), ) }, - standard_params={ - }, + standard_params={}, extra_params=kwargs, ) ) @@ -221,7 +225,12 @@ def rss_litigation( def schema_files( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether or not to use cache. If True, cache will store for seven days.")] = True, + use_cache: Annotated[ + Optional[bool], + OpenBBCustomParameter( + description="Whether or not to use cache. If True, cache will store for seven days." + ), + ] = True, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -288,7 +297,12 @@ def schema_files( def sic_search( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether or not to use cache. If True, cache will store for seven days.")] = True, + use_cache: Annotated[ + Optional[bool], + OpenBBCustomParameter( + description="Whether or not to use cache. If True, cache will store for seven days." + ), + ] = True, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: @@ -357,7 +371,12 @@ def sic_search( def symbol_map( self, query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - use_cache: Annotated[Optional[bool], OpenBBCustomParameter(description="Whether or not to use cache. If True, cache will store for seven days.")] = True, + use_cache: Annotated[ + Optional[bool], + OpenBBCustomParameter( + description="Whether or not to use cache. If True, cache will store for seven days." + ), + ] = True, provider: Optional[Literal["sec"]] = None, **kwargs ) -> OBBject: From 886ed135d200778897810a23c56ae586b6c87689 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 19:20:51 +0000 Subject: [PATCH 013/133] fix indentation without linter --- .../core/openbb_core/app/model/example.py | 6 +- .../openbb_core/app/static/package_builder.py | 7 +- .../openbb_currency/currency_router.py | 3 +- openbb_platform/openbb/package/currency.py | 154 ++--- .../openbb/package/currency_price.py | 142 ++-- openbb_platform/openbb/package/economy.py | 612 +++++++++--------- openbb_platform/openbb/package/equity.py | 178 ++--- .../openbb/package/equity_compare.py | 58 +- .../openbb/package/equity_discovery.py | 102 +-- .../openbb/package/equity_fundamental.py | 194 +++--- openbb_platform/openbb/package/etf.py | 124 ++-- openbb_platform/openbb/package/fixedincome.py | 74 +-- .../openbb/package/fixedincome_corporate.py | 410 ++++++------ .../openbb/package/fixedincome_rate.py | 604 ++++++++--------- .../openbb/package/fixedincome_spreads.py | 210 +++--- 15 files changed, 1441 insertions(+), 1437 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index b31735121738..147b95970ce3 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,7 +1,7 @@ +from dataclasses import Field from typing import Any, Dict, List, Literal, Optional from pydantic import BaseModel, ConfigDict -from dataclasses import Field class Example(BaseModel): @@ -14,7 +14,9 @@ class Example(BaseModel): model_config = ConfigDict(validate_assignment=True) - def to_python(self, func_name: str, func_params: Dict[str, Field], indentation: str = "") -> str: + def to_python( + self, func_name: str, func_params: Dict[str, Field], indentation: str = "" + ) -> str: """Return a Python code representation of the examplself.""" eg = "" if self.scope == "api" and self.parameters is not None: diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index aaa3420502fb..eb9c94d22d3b 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -839,7 +839,10 @@ class DocstringGenerator: @staticmethod def get_OBBject_description( - results_type: str, providers: Optional[str], indentation: str = "", tab: str = " " + results_type: str, + providers: Optional[str], + indentation: str = "", + tab: str = " ", ) -> str: """Get the command output description.""" available_providers = providers or "Optional[str]" @@ -908,7 +911,7 @@ def format_description(description: str) -> str: description = description.replace("\n", f"\n{indentation+tab}") return description - docstring = summary.strip("\n") + docstring = summary.replace("\n ",f"\n{indentation}").strip("\n") docstring += "\n\n" docstring += f"{indentation}Parameters\n" docstring += f"{indentation}----------\n" diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index c90b8c1ac9b6..cd6ff242af82 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -40,8 +40,7 @@ async def search( standard_params: StandardParams, extra_params: ExtraParams, ) -> OBBject: - """ - Currency Search. + """Currency Search. Search available currency pairs. Currency pairs are the national currencies from two countries coupled for trading on diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index 1e29290a5f2b..281541627d91 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -40,86 +40,86 @@ def search( Major currency pairs include pairs such as EUR/USD, USD/JPY, GBP/USD, etc. - Parameters - ---------- - provider : Optional[Literal['fmp', 'intrinio', 'polygon']] - 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. - symbol : Optional[str] - Symbol of the pair to search. (provider: polygon) - date : Optional[datetime.date] - A specific date to get data for. (provider: polygon) - search : Optional[str] - Search for terms within the ticker and/or company name. (provider: polygon) - active : Optional[bool] - Specify if the tickers returned should be actively traded on the queried date. (provider: polygon) - order : Optional[Literal['asc', 'desc']] - Order data by ascending or descending. (provider: polygon) - sort : Optional[Literal['ticker', 'name', 'market', 'locale', 'currency_symbol', 'currency_name', 'base_currency_symbol', 'base_currency_name', 'last_updated_utc', 'delisted_utc']] - Sort field used for ordering. (provider: polygon) - limit : Optional[Annotated[int, Gt(gt=0)]] - The number of data entries to return. (provider: polygon) + Parameters + ---------- + provider : Optional[Literal['fmp', 'intrinio', 'polygon']] + 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. + symbol : Optional[str] + Symbol of the pair to search. (provider: polygon) + date : Optional[datetime.date] + A specific date to get data for. (provider: polygon) + search : Optional[str] + Search for terms within the ticker and/or company name. (provider: polygon) + active : Optional[bool] + Specify if the tickers returned should be actively traded on the queried date. (provider: polygon) + order : Optional[Literal['asc', 'desc']] + Order data by ascending or descending. (provider: polygon) + sort : Optional[Literal['ticker', 'name', 'market', 'locale', 'currency_symbol', 'currency_name', 'base_currency_symbol', 'base_currency_name', 'last_updated_utc', 'delisted_utc']] + Sort field used for ordering. (provider: polygon) + limit : Optional[Annotated[int, Gt(gt=0)]] + The number of data entries to return. (provider: polygon) - Returns - ------- - OBBject - results : List[CurrencyPairs] - Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'polygon']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + Returns + ------- + OBBject + results : List[CurrencyPairs] + Serializable results. + provider : Optional[Literal['fmp', 'intrinio', 'polygon']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - CurrencyPairs - ------------- - name : str - Name of the currency pair. - symbol : Optional[str] - Symbol of the currency pair. (provider: fmp) - currency : Optional[str] - Base currency of the currency pair. (provider: fmp) - stock_exchange : Optional[str] - Stock exchange of the currency pair. (provider: fmp) - exchange_short_name : Optional[str] - Short name of the stock exchange of the currency pair. (provider: fmp) - code : Optional[str] - Code of the currency pair. (provider: intrinio) - base_currency : Optional[str] - ISO 4217 currency code of the base currency. (provider: intrinio) - quote_currency : Optional[str] - ISO 4217 currency code of the quote currency. (provider: intrinio) - market : Optional[str] - Name of the trading market. Always 'fx'. (provider: polygon) - locale : Optional[str] - Locale of the currency pair. (provider: polygon) - currency_symbol : Optional[str] - The symbol of the quote currency. (provider: polygon) - currency_name : Optional[str] - Name of the quote currency. (provider: polygon) - base_currency_symbol : Optional[str] - The symbol of the base currency. (provider: polygon) - base_currency_name : Optional[str] - Name of the base currency. (provider: polygon) - last_updated_utc : Optional[datetime] - The last updated timestamp in UTC. (provider: polygon) - delisted_utc : Optional[datetime] - The delisted timestamp in UTC. (provider: polygon) + CurrencyPairs + ------------- + name : str + Name of the currency pair. + symbol : Optional[str] + Symbol of the currency pair. (provider: fmp) + currency : Optional[str] + Base currency of the currency pair. (provider: fmp) + stock_exchange : Optional[str] + Stock exchange of the currency pair. (provider: fmp) + exchange_short_name : Optional[str] + Short name of the stock exchange of the currency pair. (provider: fmp) + code : Optional[str] + Code of the currency pair. (provider: intrinio) + base_currency : Optional[str] + ISO 4217 currency code of the base currency. (provider: intrinio) + quote_currency : Optional[str] + ISO 4217 currency code of the quote currency. (provider: intrinio) + market : Optional[str] + Name of the trading market. Always 'fx'. (provider: polygon) + locale : Optional[str] + Locale of the currency pair. (provider: polygon) + currency_symbol : Optional[str] + The symbol of the quote currency. (provider: polygon) + currency_name : Optional[str] + Name of the quote currency. (provider: polygon) + base_currency_symbol : Optional[str] + The symbol of the base currency. (provider: polygon) + base_currency_name : Optional[str] + Name of the base currency. (provider: polygon) + last_updated_utc : Optional[datetime] + The last updated timestamp in UTC. (provider: polygon) + delisted_utc : Optional[datetime] + The delisted timestamp in UTC. (provider: polygon) - Examples - -------- - >>> from openbb import obb - >>> obb.currency.search() - >>> # Search for 'EURUSD' currency pair using 'polygon' as provider. - >>> obb.currency.search(provider='polygon', symbol='EURUSD') - >>> # Search for terms using 'polygon' as provider. - >>> obb.currency.search(provider='polygon', search='Euro zone') - >>> # Search for actively traded currency pairs on the queried date using 'polygon' as provider. - >>> obb.currency.search(provider='polygon', date='2024-01-02', active=True) + Examples + -------- + >>> from openbb import obb + >>> obb.currency.search() + >>> # Search for 'EURUSD' currency pair using 'polygon' as provider. + >>> obb.currency.search(provider='polygon', symbol='EURUSD') + >>> # Search for terms using 'polygon' as provider. + >>> obb.currency.search(provider='polygon', search='Euro zone') + >>> # Search for actively traded currency pairs on the queried date using 'polygon' as provider. + >>> obb.currency.search(provider='polygon', date='2024-01-02', active=True) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/currency_price.py b/openbb_platform/openbb/package/currency_price.py index 0d8f33f95693..2e523e600986 100644 --- a/openbb_platform/openbb/package/currency_price.py +++ b/openbb_platform/openbb/package/currency_price.py @@ -53,80 +53,80 @@ def historical( evaluate economic health, and make predictions about future movements. - Parameters - ---------- - symbol : Union[str, List[str]] - Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): polygon, yfinance. - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'polygon', 'tiingo', 'yfinance']] - 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 : Optional[Union[Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], str, Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] - Data granularity. (provider: fmp, polygon, tiingo, yfinance) - sort : Literal['asc', 'desc'] - Sort order of the data. (provider: polygon) - limit : int - The number of data entries to return. (provider: polygon) - period : Optional[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']] - Time period of the data to return. (provider: yfinance) + Parameters + ---------- + symbol : Union[str, List[str]] + Symbol to get data for. Can use CURR1-CURR2 or CURR1CURR2 format. Multiple items allowed for provider(s): polygon, yfinance. + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['fmp', 'polygon', 'tiingo', 'yfinance']] + 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 : Optional[Union[Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], str, Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]] + Data granularity. (provider: fmp, polygon, tiingo, yfinance) + sort : Literal['asc', 'desc'] + Sort order of the data. (provider: polygon) + limit : int + The number of data entries to return. (provider: polygon) + period : Optional[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']] + Time period of the data to return. (provider: yfinance) - Returns - ------- - OBBject - results : List[CurrencyHistorical] - Serializable results. - provider : Optional[Literal['fmp', 'polygon', 'tiingo', 'yfinance']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + Returns + ------- + OBBject + results : List[CurrencyHistorical] + Serializable results. + provider : Optional[Literal['fmp', 'polygon', 'tiingo', 'yfinance']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - CurrencyHistorical - ------------------ - date : Union[date, datetime] - The date of the data. - open : float - The open price. - high : float - The high price. - low : float - The low price. - close : float - The close price. - volume : Optional[float] - The trading volume. - vwap : Optional[Annotated[float, Gt(gt=0)]] - Volume Weighted Average Price over the period. - adj_close : Optional[float] - The adjusted close price. (provider: fmp) - unadjusted_volume : Optional[float] - Unadjusted volume of the symbol. (provider: fmp) - change : Optional[float] - Change in the price of the symbol from the previous day. (provider: fmp) - change_percent : Optional[float] - Change % in the price of the symbol. (provider: fmp) - label : Optional[str] - Human readable format of the date. (provider: fmp) - change_over_time : Optional[float] - Change % in the price of the symbol over a period of time. (provider: fmp) - transactions : Optional[Annotated[int, Gt(gt=0)]] - Number of transactions for the symbol in the time period. (provider: polygon) + CurrencyHistorical + ------------------ + date : Union[date, datetime] + The date of the data. + open : float + The open price. + high : float + The high price. + low : float + The low price. + close : float + The close price. + volume : Optional[float] + The trading volume. + vwap : Optional[Annotated[float, Gt(gt=0)]] + Volume Weighted Average Price over the period. + adj_close : Optional[float] + The adjusted close price. (provider: fmp) + unadjusted_volume : Optional[float] + Unadjusted volume of the symbol. (provider: fmp) + change : Optional[float] + Change in the price of the symbol from the previous day. (provider: fmp) + change_percent : Optional[float] + Change % in the price of the symbol. (provider: fmp) + label : Optional[str] + Human readable format of the date. (provider: fmp) + change_over_time : Optional[float] + Change % in the price of the symbol over a period of time. (provider: fmp) + transactions : Optional[Annotated[int, Gt(gt=0)]] + Number of transactions for the symbol in the time period. (provider: polygon) - Examples - -------- - >>> from openbb import obb - >>> obb.currency.price.historical(symbol='EURUSD') - >>> # Filter historical data with specific start and end date. - >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='2023-12-31') - >>> # Get data with different granularity. - >>> obb.currency.price.historical(symbol='EURUSD', interval='15m', provider='polygon') + Examples + -------- + >>> from openbb import obb + >>> obb.currency.price.historical(symbol='EURUSD') + >>> # Filter historical data with specific start and end date. + >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='2023-12-31') + >>> # Get data with different granularity. + >>> obb.currency.price.historical(symbol='EURUSD', interval='15m', provider='polygon') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 327330008714..e19b728fb5d4 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -171,46 +171,46 @@ def composite_leading_indicator( CLIs show short-term economic movements in qualitative rather than quantitative terms. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['oecd']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'oecd' if there is + no default. + country : Literal['united_states', 'united_kingdom', 'japan', 'mexico', 'indonesia', 'australia', 'brazil', 'canada', 'italy', 'germany', 'turkey', 'france', 'south_africa', 'south_korea', 'spain', 'india', 'china', 'g7', 'g20', 'all'] + Country to get GDP for. (provider: oecd) + + Returns + ------- + OBBject + results : List[CLI] + Serializable results. provider : Optional[Literal['oecd']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'oecd' if there is - no default. - country : Literal['united_states', 'united_kingdom', 'japan', 'mexico', 'indonesia', 'australia', 'brazil', 'canada', 'italy', 'germany', 'turkey', 'france', 'south_africa', 'south_korea', 'spain', 'india', 'china', 'g7', 'g20', 'all'] - Country to get GDP for. (provider: oecd) - - Returns - ------- - OBBject - results : List[CLI] - Serializable results. - provider : Optional[Literal['oecd']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - CLI - --- - date : Optional[date] - The date of the data. - value : Optional[float] - CLI value - country : Optional[str] - Country for which CLI is given - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.composite_leading_indicator(country='all') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + CLI + --- + date : Optional[date] + The date of the data. + value : Optional[float] + CLI value + country : Optional[str] + Country for which CLI is given + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.composite_leading_indicator(country='all') """ # noqa: E501 return self._run( @@ -385,105 +385,105 @@ def fred_regional( The series group ID is found by using `fred_search` and the `series_id` parameter. - Parameters - ---------- - symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fred. - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - limit : Optional[int] - The number of data entries to return. + Parameters + ---------- + symbol : Union[str, List[str]] + Symbol to get data for. Multiple items allowed for provider(s): fred. + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + limit : Optional[int] + The number of data entries to return. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + is_series_group : bool + When True, the symbol provided is for a series_group, else it is for a series ID. (provider: fred) + region_type : Optional[Literal['bea', 'msa', 'frb', 'necta', 'state', 'country', 'county', 'censusregion']] + The type of regional data. Parameter is only valid when `is_series_group` is True. (provider: fred) + season : Optional[Literal['SA', 'NSA', 'SSA']] + The seasonal adjustments to the data. Parameter is only valid when `is_series_group` is True. (provider: fred) + units : Optional[str] + The units of the data. This should match the units returned from searching by series ID. An incorrect field will not necessarily return an error. Parameter is only valid when `is_series_group` is True. (provider: fred) + frequency : Optional[Literal['d', 'w', 'bw', 'm', 'q', 'sa', 'a', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] + + Frequency aggregation to convert high frequency data to lower frequency. + Parameter is only valid when `is_series_group` is True. + a = Annual + sa= Semiannual + q = Quarterly + m = Monthly + w = Weekly + d = Daily + wef = Weekly, Ending Friday + weth = Weekly, Ending Thursday + wew = Weekly, Ending Wednesday + wetu = Weekly, Ending Tuesday + wem = Weekly, Ending Monday + wesu = Weekly, Ending Sunday + wesa = Weekly, Ending Saturday + bwew = Biweekly, Ending Wednesday + bwem = Biweekly, Ending Monday + (provider: fred) + aggregation_method : Literal['avg', 'sum', 'eop'] + + A key that indicates the aggregation method used for frequency aggregation. + This parameter has no affect if the frequency parameter is not set. + Only valid when `is_series_group` is True. + avg = Average + sum = Sum + eop = End of Period + (provider: fred) + transform : Literal['lin', 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'] + + Transformation type. Only valid when `is_series_group` is True. + lin = Levels (No transformation) + chg = Change + ch1 = Change from Year Ago + pch = Percent Change + pc1 = Percent Change from Year Ago + pca = Compounded Annual Rate of Change + cch = Continuously Compounded Rate of Change + cca = Continuously Compounded Annual Rate of Change + log = Natural Log + (provider: fred) + + Returns + ------- + OBBject + results : List[FredRegional] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - is_series_group : bool - When True, the symbol provided is for a series_group, else it is for a series ID. (provider: fred) - region_type : Optional[Literal['bea', 'msa', 'frb', 'necta', 'state', 'country', 'county', 'censusregion']] - The type of regional data. Parameter is only valid when `is_series_group` is True. (provider: fred) - season : Optional[Literal['SA', 'NSA', 'SSA']] - The seasonal adjustments to the data. Parameter is only valid when `is_series_group` is True. (provider: fred) - units : Optional[str] - The units of the data. This should match the units returned from searching by series ID. An incorrect field will not necessarily return an error. Parameter is only valid when `is_series_group` is True. (provider: fred) - frequency : Optional[Literal['d', 'w', 'bw', 'm', 'q', 'sa', 'a', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] - - Frequency aggregation to convert high frequency data to lower frequency. - Parameter is only valid when `is_series_group` is True. - a = Annual - sa= Semiannual - q = Quarterly - m = Monthly - w = Weekly - d = Daily - wef = Weekly, Ending Friday - weth = Weekly, Ending Thursday - wew = Weekly, Ending Wednesday - wetu = Weekly, Ending Tuesday - wem = Weekly, Ending Monday - wesu = Weekly, Ending Sunday - wesa = Weekly, Ending Saturday - bwew = Biweekly, Ending Wednesday - bwem = Biweekly, Ending Monday - (provider: fred) - aggregation_method : Literal['avg', 'sum', 'eop'] - - A key that indicates the aggregation method used for frequency aggregation. - This parameter has no affect if the frequency parameter is not set. - Only valid when `is_series_group` is True. - avg = Average - sum = Sum - eop = End of Period - (provider: fred) - transform : Literal['lin', 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'] - - Transformation type. Only valid when `is_series_group` is True. - lin = Levels (No transformation) - chg = Change - ch1 = Change from Year Ago - pch = Percent Change - pc1 = Percent Change from Year Ago - pca = Compounded Annual Rate of Change - cch = Continuously Compounded Rate of Change - cca = Continuously Compounded Annual Rate of Change - log = Natural Log - (provider: fred) - - Returns - ------- - OBBject - results : List[FredRegional] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - FredRegional - ------------ - date : date - The date of the data. - region : Optional[str] - The name of the region. (provider: fred) - code : Optional[Union[int, str]] - The code of the region. (provider: fred) - value : Optional[Union[float, int]] - The obersvation value. The units are defined in the search results by series ID. (provider: fred) - series_id : Optional[str] - The individual series ID for the region. (provider: fred) - - Examples - -------- - >>> from openbb import obb - >>> # With no date, the most recent report is returned. - >>> obb.economy.fred_regional(series_id='NYICLAIMS') - >>> # With a date, time series data is returned. - >>> obb.economy.fred_regional(series_id='NYICLAIMS', start_date='2021-01-01') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + FredRegional + ------------ + date : date + The date of the data. + region : Optional[str] + The name of the region. (provider: fred) + code : Optional[Union[int, str]] + The code of the region. (provider: fred) + value : Optional[Union[float, int]] + The obersvation value. The units are defined in the search results by series ID. (provider: fred) + series_id : Optional[str] + The individual series ID for the region. (provider: fred) + + Examples + -------- + >>> from openbb import obb + >>> # With no date, the most recent report is returned. + >>> obb.economy.fred_regional(series_id='NYICLAIMS') + >>> # With a date, time series data is returned. + >>> obb.economy.fred_regional(series_id='NYICLAIMS', start_date='2021-01-01') """ # noqa: E501 return self._run( @@ -522,94 +522,94 @@ def fred_search( Use this function to find series IDs for `fred_series()`. - Parameters - ---------- - query : Optional[str] - The search word(s). + Parameters + ---------- + query : Optional[str] + The search word(s). + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + is_release : Optional[bool] + Is release? If True, other search filter variables are ignored. If no query text or release_id is supplied, this defaults to True. (provider: fred) + release_id : Optional[Union[int, str]] + A specific release ID to target. (provider: fred) + limit : Optional[int] + The number of data entries to return. (1-1000) (provider: fred) + offset : Optional[Annotated[int, Ge(ge=0)]] + Offset the results in conjunction with limit. (provider: fred) + filter_variable : Literal[None, 'frequency', 'units', 'seasonal_adjustment'] + Filter by an attribute. (provider: fred) + filter_value : Optional[str] + String value to filter the variable by. Used in conjunction with filter_variable. (provider: fred) + tag_names : Optional[str] + A semicolon delimited list of tag names that series match all of. Example: 'japan;imports' (provider: fred) + exclude_tag_names : Optional[str] + A semicolon delimited list of tag names that series match none of. Example: 'imports;services'. Requires that variable tag_names also be set to limit the number of matching series. (provider: fred) + series_id : Optional[str] + A FRED Series ID to return series group information for. This returns the required information to query for regional data. Not all series that are in FRED have geographical data. Entering a value for series_id will override all other parameters. Multiple series_ids can be separated by commas. (provider: fred) + + Returns + ------- + OBBject + results : List[FredSearch] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - is_release : Optional[bool] - Is release? If True, other search filter variables are ignored. If no query text or release_id is supplied, this defaults to True. (provider: fred) - release_id : Optional[Union[int, str]] - A specific release ID to target. (provider: fred) - limit : Optional[int] - The number of data entries to return. (1-1000) (provider: fred) - offset : Optional[Annotated[int, Ge(ge=0)]] - Offset the results in conjunction with limit. (provider: fred) - filter_variable : Literal[None, 'frequency', 'units', 'seasonal_adjustment'] - Filter by an attribute. (provider: fred) - filter_value : Optional[str] - String value to filter the variable by. Used in conjunction with filter_variable. (provider: fred) - tag_names : Optional[str] - A semicolon delimited list of tag names that series match all of. Example: 'japan;imports' (provider: fred) - exclude_tag_names : Optional[str] - A semicolon delimited list of tag names that series match none of. Example: 'imports;services'. Requires that variable tag_names also be set to limit the number of matching series. (provider: fred) - series_id : Optional[str] - A FRED Series ID to return series group information for. This returns the required information to query for regional data. Not all series that are in FRED have geographical data. Entering a value for series_id will override all other parameters. Multiple series_ids can be separated by commas. (provider: fred) - - Returns - ------- - OBBject - results : List[FredSearch] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - FredSearch - ---------- - release_id : Optional[Union[int, str]] - The release ID for queries. - series_id : Optional[str] - The series ID for the item in the release. - name : Optional[str] - The name of the release. - title : Optional[str] - The title of the series. - observation_start : Optional[date] - The date of the first observation in the series. - observation_end : Optional[date] - The date of the last observation in the series. - frequency : Optional[str] - The frequency of the data. - frequency_short : Optional[str] - Short form of the data frequency. - units : Optional[str] - The units of the data. - units_short : Optional[str] - Short form of the data units. - seasonal_adjustment : Optional[str] - The seasonal adjustment of the data. - seasonal_adjustment_short : Optional[str] - Short form of the data seasonal adjustment. - last_updated : Optional[datetime] - The datetime of the last update to the data. - notes : Optional[str] - Description of the release. - press_release : Optional[bool] - If the release is a press release. - url : Optional[str] - URL to the release. - popularity : Optional[int] - Popularity of the series (provider: fred) - group_popularity : Optional[int] - Group popularity of the release (provider: fred) - region_type : Optional[str] - The region type of the series. (provider: fred) - series_group : Optional[Union[int, str]] - The series group ID of the series. This value is used to query for regional data. (provider: fred) - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.fred_search() + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + FredSearch + ---------- + release_id : Optional[Union[int, str]] + The release ID for queries. + series_id : Optional[str] + The series ID for the item in the release. + name : Optional[str] + The name of the release. + title : Optional[str] + The title of the series. + observation_start : Optional[date] + The date of the first observation in the series. + observation_end : Optional[date] + The date of the last observation in the series. + frequency : Optional[str] + The frequency of the data. + frequency_short : Optional[str] + Short form of the data frequency. + units : Optional[str] + The units of the data. + units_short : Optional[str] + Short form of the data units. + seasonal_adjustment : Optional[str] + The seasonal adjustment of the data. + seasonal_adjustment_short : Optional[str] + Short form of the data seasonal adjustment. + last_updated : Optional[datetime] + The datetime of the last update to the data. + notes : Optional[str] + Description of the release. + press_release : Optional[bool] + If the release is a press release. + url : Optional[str] + URL to the release. + popularity : Optional[int] + Popularity of the series (provider: fred) + group_popularity : Optional[int] + Group popularity of the release (provider: fred) + region_type : Optional[str] + The region type of the series. (provider: fred) + series_group : Optional[Union[int, str]] + The series group ID of the series. This value is used to query for regional data. (provider: fred) + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.fred_search() """ # noqa: E501 return self._run( @@ -807,48 +807,48 @@ def long_term_interest_rate( Low long-term interest rates encourage investment in new equipment and high interest rates discourage it. Investment is, in turn, a major source of economic growth. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['oecd']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'oecd' if there is + no default. + country : Literal['belgium', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chile', 'canada', 'netherlands', 'united_states', 'south_korea', 'norway', 'austria', 'south_africa', 'denmark', 'switzerland', 'hungary', 'luxembourg', 'australia', 'germany', 'sweden', 'iceland', 'turkey', 'greece', 'israel', 'czech_republic', 'latvia', 'slovenia', 'poland', 'estonia', 'lithuania', 'portugal', 'costa_rica', 'slovakia', 'finland', 'spain', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all'] + Country to get GDP for. (provider: oecd) + frequency : Literal['monthly', 'quarterly', 'annual'] + Frequency to get interest rate for for. (provider: oecd) + + Returns + ------- + OBBject + results : List[LTIR] + Serializable results. provider : Optional[Literal['oecd']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'oecd' if there is - no default. - country : Literal['belgium', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chile', 'canada', 'netherlands', 'united_states', 'south_korea', 'norway', 'austria', 'south_africa', 'denmark', 'switzerland', 'hungary', 'luxembourg', 'australia', 'germany', 'sweden', 'iceland', 'turkey', 'greece', 'israel', 'czech_republic', 'latvia', 'slovenia', 'poland', 'estonia', 'lithuania', 'portugal', 'costa_rica', 'slovakia', 'finland', 'spain', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all'] - Country to get GDP for. (provider: oecd) - frequency : Literal['monthly', 'quarterly', 'annual'] - Frequency to get interest rate for for. (provider: oecd) - - Returns - ------- - OBBject - results : List[LTIR] - Serializable results. - provider : Optional[Literal['oecd']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - LTIR - ---- - date : Optional[date] - The date of the data. - value : Optional[float] - Interest rate (given as a whole number, i.e 10=10%) - country : Optional[str] - Country for which interest rate is given - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + LTIR + ---- + date : Optional[date] + The date of the data. + value : Optional[float] + Interest rate (given as a whole number, i.e 10=10%) + country : Optional[str] + Country for which interest rate is given + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 return self._run( @@ -1053,48 +1053,48 @@ def short_term_interest_rate( Typical standardised names are "money market rate" and "treasury bill rate". - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['oecd']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'oecd' if there is + no default. + country : Literal['belgium', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chile', 'canada', 'netherlands', 'united_states', 'south_korea', 'norway', 'austria', 'south_africa', 'denmark', 'switzerland', 'hungary', 'luxembourg', 'australia', 'germany', 'sweden', 'iceland', 'turkey', 'greece', 'israel', 'czech_republic', 'latvia', 'slovenia', 'poland', 'estonia', 'lithuania', 'portugal', 'costa_rica', 'slovakia', 'finland', 'spain', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all'] + Country to get GDP for. (provider: oecd) + frequency : Literal['monthly', 'quarterly', 'annual'] + Frequency to get interest rate for for. (provider: oecd) + + Returns + ------- + OBBject + results : List[STIR] + Serializable results. provider : Optional[Literal['oecd']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'oecd' if there is - no default. - country : Literal['belgium', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chile', 'canada', 'netherlands', 'united_states', 'south_korea', 'norway', 'austria', 'south_africa', 'denmark', 'switzerland', 'hungary', 'luxembourg', 'australia', 'germany', 'sweden', 'iceland', 'turkey', 'greece', 'israel', 'czech_republic', 'latvia', 'slovenia', 'poland', 'estonia', 'lithuania', 'portugal', 'costa_rica', 'slovakia', 'finland', 'spain', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all'] - Country to get GDP for. (provider: oecd) - frequency : Literal['monthly', 'quarterly', 'annual'] - Frequency to get interest rate for for. (provider: oecd) - - Returns - ------- - OBBject - results : List[STIR] - Serializable results. - provider : Optional[Literal['oecd']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - STIR - ---- - date : Optional[date] - The date of the data. - value : Optional[float] - Interest rate (given as a whole number, i.e 10=10%) - country : Optional[str] - Country for which interest rate is given - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + STIR + ---- + date : Optional[date] + The date of the data. + value : Optional[float] + Interest rate (given as a whole number, i.e 10=10%) + country : Optional[str] + Country for which interest rate is given + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index ee694d6e17a7..40a32ea008e9 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -418,96 +418,96 @@ def screener(self, provider: Optional[Literal["fmp"]] = None, **kwargs) -> OBBje """Screen for companies meeting various criteria. These criteria include market cap, price, beta, volume, and dividend yield. - Parameters - ---------- + Parameters + ---------- + provider : Optional[Literal['fmp']] + 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. + mktcap_min : Optional[int] + Filter by market cap greater than this value. (provider: fmp) + mktcap_max : Optional[int] + Filter by market cap less than this value. (provider: fmp) + price_min : Optional[float] + Filter by price greater than this value. (provider: fmp) + price_max : Optional[float] + Filter by price less than this value. (provider: fmp) + beta_min : Optional[float] + Filter by a beta greater than this value. (provider: fmp) + beta_max : Optional[float] + Filter by a beta less than this value. (provider: fmp) + volume_min : Optional[int] + Filter by volume greater than this value. (provider: fmp) + volume_max : Optional[int] + Filter by volume less than this value. (provider: fmp) + dividend_min : Optional[float] + Filter by dividend amount greater than this value. (provider: fmp) + dividend_max : Optional[float] + Filter by dividend amount less than this value. (provider: fmp) + is_etf : Optional[bool] + If true, returns only ETFs. (provider: fmp) + is_active : Optional[bool] + If false, returns only inactive tickers. (provider: fmp) + sector : Optional[Literal['Consumer Cyclical', 'Energy', 'Technology', 'Industrials', 'Financial Services', 'Basic Materials', 'Communication Services', 'Consumer Defensive', 'Healthcare', 'Real Estate', 'Utilities', 'Industrial Goods', 'Financial', 'Services', 'Conglomerates']] + Filter by sector. (provider: fmp) + industry : Optional[str] + Filter by industry. (provider: fmp) + country : Optional[str] + Filter by country, as a two-letter country code. (provider: fmp) + exchange : Optional[Literal['amex', 'ase', 'asx', 'ath', 'bme', 'bru', 'bud', 'bue', 'cai', 'cnq', 'cph', 'dfm', 'doh', 'etf', 'euronext', 'hel', 'hkse', 'ice', 'iob', 'ist', 'jkt', 'jnb', 'jpx', 'kls', 'koe', 'ksc', 'kuw', 'lse', 'mex', 'nasdaq', 'neo', 'nse', 'nyse', 'nze', 'osl', 'otc', 'pnk', 'pra', 'ris', 'sao', 'sau', 'set', 'sgo', 'shh', 'shz', 'six', 'sto', 'tai', 'tlv', 'tsx', 'two', 'vie', 'wse', 'xetra']] + Filter by exchange. (provider: fmp) + limit : Optional[int] + Limit the number of results to return. (provider: fmp) + + Returns + ------- + OBBject + results : List[EquityScreener] + Serializable results. provider : Optional[Literal['fmp']] - 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. - mktcap_min : Optional[int] - Filter by market cap greater than this value. (provider: fmp) - mktcap_max : Optional[int] - Filter by market cap less than this value. (provider: fmp) - price_min : Optional[float] - Filter by price greater than this value. (provider: fmp) - price_max : Optional[float] - Filter by price less than this value. (provider: fmp) - beta_min : Optional[float] - Filter by a beta greater than this value. (provider: fmp) - beta_max : Optional[float] - Filter by a beta less than this value. (provider: fmp) - volume_min : Optional[int] - Filter by volume greater than this value. (provider: fmp) - volume_max : Optional[int] - Filter by volume less than this value. (provider: fmp) - dividend_min : Optional[float] - Filter by dividend amount greater than this value. (provider: fmp) - dividend_max : Optional[float] - Filter by dividend amount less than this value. (provider: fmp) - is_etf : Optional[bool] - If true, returns only ETFs. (provider: fmp) - is_active : Optional[bool] - If false, returns only inactive tickers. (provider: fmp) - sector : Optional[Literal['Consumer Cyclical', 'Energy', 'Technology', 'Industrials', 'Financial Services', 'Basic Materials', 'Communication Services', 'Consumer Defensive', 'Healthcare', 'Real Estate', 'Utilities', 'Industrial Goods', 'Financial', 'Services', 'Conglomerates']] - Filter by sector. (provider: fmp) - industry : Optional[str] - Filter by industry. (provider: fmp) - country : Optional[str] - Filter by country, as a two-letter country code. (provider: fmp) - exchange : Optional[Literal['amex', 'ase', 'asx', 'ath', 'bme', 'bru', 'bud', 'bue', 'cai', 'cnq', 'cph', 'dfm', 'doh', 'etf', 'euronext', 'hel', 'hkse', 'ice', 'iob', 'ist', 'jkt', 'jnb', 'jpx', 'kls', 'koe', 'ksc', 'kuw', 'lse', 'mex', 'nasdaq', 'neo', 'nse', 'nyse', 'nze', 'osl', 'otc', 'pnk', 'pra', 'ris', 'sao', 'sau', 'set', 'sgo', 'shh', 'shz', 'six', 'sto', 'tai', 'tlv', 'tsx', 'two', 'vie', 'wse', 'xetra']] - Filter by exchange. (provider: fmp) - limit : Optional[int] - Limit the number of results to return. (provider: fmp) - - Returns - ------- - OBBject - results : List[EquityScreener] - Serializable results. - provider : Optional[Literal['fmp']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - EquityScreener - -------------- - symbol : str - Symbol representing the entity requested in the data. - name : str - Name of the company. - market_cap : Optional[int] - The market cap of ticker. (provider: fmp) - sector : Optional[str] - The sector the ticker belongs to. (provider: fmp) - industry : Optional[str] - The industry ticker belongs to. (provider: fmp) - beta : Optional[float] - The beta of the ETF. (provider: fmp) - price : Optional[float] - The current price. (provider: fmp) - last_annual_dividend : Optional[float] - The last annual amount dividend paid. (provider: fmp) - volume : Optional[int] - The current trading volume. (provider: fmp) - exchange : Optional[str] - The exchange code the asset trades on. (provider: fmp) - exchange_name : Optional[str] - The full name of the primary exchange. (provider: fmp) - country : Optional[str] - The two-letter country abbreviation where the head office is located. (provider: fmp) - is_etf : Optional[Literal[True, False]] - Whether the ticker is an ETF. (provider: fmp) - actively_trading : Optional[Literal[True, False]] - Whether the ETF is actively trading. (provider: fmp) - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.screener() + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + EquityScreener + -------------- + symbol : str + Symbol representing the entity requested in the data. + name : str + Name of the company. + market_cap : Optional[int] + The market cap of ticker. (provider: fmp) + sector : Optional[str] + The sector the ticker belongs to. (provider: fmp) + industry : Optional[str] + The industry ticker belongs to. (provider: fmp) + beta : Optional[float] + The beta of the ETF. (provider: fmp) + price : Optional[float] + The current price. (provider: fmp) + last_annual_dividend : Optional[float] + The last annual amount dividend paid. (provider: fmp) + volume : Optional[int] + The current trading volume. (provider: fmp) + exchange : Optional[str] + The exchange code the asset trades on. (provider: fmp) + exchange_name : Optional[str] + The full name of the primary exchange. (provider: fmp) + country : Optional[str] + The two-letter country abbreviation where the head office is located. (provider: fmp) + is_etf : Optional[Literal[True, False]] + Whether the ticker is an ETF. (provider: fmp) + actively_trading : Optional[Literal[True, False]] + Whether the ETF is actively trading. (provider: fmp) + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.screener() """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_compare.py b/openbb_platform/openbb/package/equity_compare.py index 690622433ae8..f2a3725fbfdc 100644 --- a/openbb_platform/openbb/package/equity_compare.py +++ b/openbb_platform/openbb/package/equity_compare.py @@ -33,38 +33,38 @@ def peers( Peers consist of companies trading on the same exchange, operating within the same sector and with comparable market capitalizations. - Parameters - ---------- - symbol : str - Symbol to get data for. - provider : Optional[Literal['fmp']] - 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. + Parameters + ---------- + symbol : str + Symbol to get data for. + provider : Optional[Literal['fmp']] + 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. - Returns - ------- - OBBject - results : EquityPeers - Serializable results. - provider : Optional[Literal['fmp']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + Returns + ------- + OBBject + results : EquityPeers + Serializable results. + provider : Optional[Literal['fmp']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - EquityPeers - ----------- - peers_list : List[str] - A list of equity peers based on sector, exchange and market cap. + EquityPeers + ----------- + peers_list : List[str] + A list of equity peers based on sector, exchange and market cap. - Examples - -------- - >>> from openbb import obb - >>> obb.equity.compare.peers(symbol='AAPL') + Examples + -------- + >>> from openbb import obb + >>> obb.equity.compare.peers(symbol='AAPL') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_discovery.py b/openbb_platform/openbb/package/equity_discovery.py index a543e940dd6b..cc8f0748b34f 100644 --- a/openbb_platform/openbb/package/equity_discovery.py +++ b/openbb_platform/openbb/package/equity_discovery.py @@ -226,58 +226,58 @@ def filings( and audited financial statements. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - form_type : Optional[str] - Filter by form type. Visit https://www.sec.gov/forms for a list of supported form types. - limit : int - The number of data entries to return. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + form_type : Optional[str] + Filter by form type. Visit https://www.sec.gov/forms for a list of supported form types. + limit : int + The number of data entries to return. + provider : Optional[Literal['fmp']] + 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. + is_done : Optional[bool] + Flag for whether or not the filing is done. (provider: fmp) + + Returns + ------- + OBBject + results : List[DiscoveryFilings] + Serializable results. provider : Optional[Literal['fmp']] - 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. - is_done : Optional[bool] - Flag for whether or not the filing is done. (provider: fmp) - - Returns - ------- - OBBject - results : List[DiscoveryFilings] - Serializable results. - provider : Optional[Literal['fmp']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - DiscoveryFilings - ---------------- - symbol : str - Symbol representing the entity requested in the data. - cik : str - Central Index Key (CIK) for the requested entity. - title : str - Title of the filing. - date : datetime - The date of the data. - form_type : str - The form type of the filing - link : str - URL to the filing page on the SEC site. - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.discovery.filings(limit=100) - >>> # Get filings for the year 2023, limited to 100 results - >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31', limit=100) + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + DiscoveryFilings + ---------------- + symbol : str + Symbol representing the entity requested in the data. + cik : str + Central Index Key (CIK) for the requested entity. + title : str + Title of the filing. + date : datetime + The date of the data. + form_type : str + The form type of the filing + link : str + URL to the filing page on the SEC site. + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.discovery.filings(limit=100) + >>> # Get filings for the year 2023, limited to 100 results + >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31', limit=100) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index 16386f0231f6..8c03a83c7ce3 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -1159,104 +1159,104 @@ def filings( and audited financial statements. - Parameters - ---------- - symbol : Optional[str] - Symbol to get data for. - form_type : Optional[str] - Filter by form type. Check the data provider for available types. - limit : int - The number of data entries to return. + Parameters + ---------- + symbol : Optional[str] + Symbol to get data for. + form_type : Optional[str] + Filter by form type. Check the data provider for available types. + limit : int + The number of data entries to return. + provider : Optional[Literal['fmp', 'intrinio', 'sec']] + 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. + start_date : Optional[datetime.date] + Start date of the data, in YYYY-MM-DD format. (provider: intrinio) + end_date : Optional[datetime.date] + End date of the data, in YYYY-MM-DD format. (provider: intrinio) + thea_enabled : Optional[bool] + Return filings that have been read by Intrinio's Thea NLP. (provider: intrinio) + cik : Optional[Union[int, str]] + Lookup filings by Central Index Key (CIK) instead of by symbol. (provider: sec) + type : Optional[Literal['1', '1-A', '1-A POS', '1-A-W', '1-E', '1-E AD', '1-K', '1-SA', '1-U', '1-Z', '1-Z-W', '10-12B', '10-12G', '10-D', '10-K', '10-KT', '10-Q', '10-QT', '11-K', '11-KT', '13F-HR', '13F-NT', '13FCONP', '144', '15-12B', '15-12G', '15-15D', '15F-12B', '15F-12G', '15F-15D', '18-12B', '18-K', '19B-4E', '2-A', '2-AF', '2-E', '20-F', '20FR12B', '20FR12G', '24F-2NT', '25', '25-NSE', '253G1', '253G2', '253G3', '253G4', '3', '305B2', '34-12H', '4', '40-17F1', '40-17F2', '40-17G', '40-17GCS', '40-202A', '40-203A', '40-206A', '40-24B2', '40-33', '40-6B', '40-8B25', '40-8F-2', '40-APP', '40-F', '40-OIP', '40FR12B', '40FR12G', '424A', '424B1', '424B2', '424B3', '424B4', '424B5', '424B7', '424B8', '424H', '425', '485APOS', '485BPOS', '485BXT', '486APOS', '486BPOS', '486BXT', '487', '497', '497AD', '497H2', '497J', '497K', '497VPI', '497VPU', '5', '6-K', '6B NTC', '6B ORDR', '8-A12B', '8-A12G', '8-K', '8-K12B', '8-K12G3', '8-K15D5', '8-M', '8F-2 NTC', '8F-2 ORDR', '9-M', 'ABS-15G', 'ABS-EE', 'ADN-MTL', 'ADV-E', 'ADV-H-C', 'ADV-H-T', 'ADV-NR', 'ANNLRPT', 'APP NTC', 'APP ORDR', 'APP WD', 'APP WDG', 'ARS', 'ATS-N', 'ATS-N-C', 'ATS-N/UA', 'AW', 'AW WD', 'C', 'C-AR', 'C-AR-W', 'C-TR', 'C-TR-W', 'C-U', 'C-U-W', 'C-W', 'CB', 'CERT', 'CERTARCA', 'CERTBATS', 'CERTCBO', 'CERTNAS', 'CERTNYS', 'CERTPAC', 'CFPORTAL', 'CFPORTAL-W', 'CORRESP', 'CT ORDER', 'D', 'DEF 14A', 'DEF 14C', 'DEFA14A', 'DEFA14C', 'DEFC14A', 'DEFC14C', 'DEFM14A', 'DEFM14C', 'DEFN14A', 'DEFR14A', 'DEFR14C', 'DEL AM', 'DFAN14A', 'DFRN14A', 'DOS', 'DOSLTR', 'DRS', 'DRSLTR', 'DSTRBRPT', 'EFFECT', 'F-1', 'F-10', 'F-10EF', 'F-10POS', 'F-1MEF', 'F-3', 'F-3ASR', 'F-3D', 'F-3DPOS', 'F-3MEF', 'F-4', 'F-4 POS', 'F-4MEF', 'F-6', 'F-6 POS', 'F-6EF', 'F-7', 'F-7 POS', 'F-8', 'F-8 POS', 'F-80', 'F-80POS', 'F-9', 'F-9 POS', 'F-N', 'F-X', 'FOCUSN', 'FWP', 'G-405', 'G-405N', 'G-FIN', 'G-FINW', 'IRANNOTICE', 'MA', 'MA-A', 'MA-I', 'MA-W', 'MSD', 'MSDCO', 'MSDW', 'N-1', 'N-14', 'N-14 8C', 'N-14MEF', 'N-18F1', 'N-1A', 'N-2', 'N-2 POSASR', 'N-23C-2', 'N-23C3A', 'N-23C3B', 'N-23C3C', 'N-2ASR', 'N-2MEF', 'N-30B-2', 'N-30D', 'N-4', 'N-5', 'N-54A', 'N-54C', 'N-6', 'N-6F', 'N-8A', 'N-8B-2', 'N-8F', 'N-8F NTC', 'N-8F ORDR', 'N-CEN', 'N-CR', 'N-CSR', 'N-CSRS', 'N-MFP', 'N-MFP1', 'N-MFP2', 'N-PX', 'N-Q', 'N-VP', 'N-VPFS', 'NO ACT', 'NPORT-EX', 'NPORT-NP', 'NPORT-P', 'NRSRO-CE', 'NRSRO-UPD', 'NSAR-A', 'NSAR-AT', 'NSAR-B', 'NSAR-BT', 'NSAR-U', 'NT 10-D', 'NT 10-K', 'NT 10-Q', 'NT 11-K', 'NT 20-F', 'NT N-CEN', 'NT N-MFP', 'NT N-MFP1', 'NT N-MFP2', 'NT NPORT-EX', 'NT NPORT-P', 'NT-NCEN', 'NT-NCSR', 'NT-NSAR', 'NTFNCEN', 'NTFNCSR', 'NTFNSAR', 'NTN 10D', 'NTN 10K', 'NTN 10Q', 'NTN 20F', 'OIP NTC', 'OIP ORDR', 'POS 8C', 'POS AM', 'POS AMI', 'POS EX', 'POS462B', 'POS462C', 'POSASR', 'PRE 14A', 'PRE 14C', 'PREC14A', 'PREC14C', 'PREM14A', 'PREM14C', 'PREN14A', 'PRER14A', 'PRER14C', 'PRRN14A', 'PX14A6G', 'PX14A6N', 'QRTLYRPT', 'QUALIF', 'REG-NR', 'REVOKED', 'RW', 'RW WD', 'S-1', 'S-11', 'S-11MEF', 'S-1MEF', 'S-20', 'S-3', 'S-3ASR', 'S-3D', 'S-3DPOS', 'S-3MEF', 'S-4', 'S-4 POS', 'S-4EF', 'S-4MEF', 'S-6', 'S-8', 'S-8 POS', 'S-B', 'S-BMEF', 'SBSE', 'SBSE-A', 'SBSE-BD', 'SBSE-C', 'SBSE-W', 'SC 13D', 'SC 13E1', 'SC 13E3', 'SC 13G', 'SC 14D9', 'SC 14F1', 'SC 14N', 'SC TO-C', 'SC TO-I', 'SC TO-T', 'SC13E4F', 'SC14D1F', 'SC14D9C', 'SC14D9F', 'SD', 'SDR', 'SE', 'SEC ACTION', 'SEC STAFF ACTION', 'SEC STAFF LETTER', 'SF-1', 'SF-3', 'SL', 'SP 15D2', 'STOP ORDER', 'SUPPL', 'T-3', 'TA-1', 'TA-2', 'TA-W', 'TACO', 'TH', 'TTW', 'UNDER', 'UPLOAD', 'WDL-REQ', 'X-17A-5']] + Type of the SEC filing form. (provider: sec) + use_cache : bool + Whether or not to use cache. If True, cache will store for one day. (provider: sec) + + Returns + ------- + OBBject + results : List[CompanyFilings] + Serializable results. provider : Optional[Literal['fmp', 'intrinio', 'sec']] - 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. - start_date : Optional[datetime.date] - Start date of the data, in YYYY-MM-DD format. (provider: intrinio) - end_date : Optional[datetime.date] - End date of the data, in YYYY-MM-DD format. (provider: intrinio) - thea_enabled : Optional[bool] - Return filings that have been read by Intrinio's Thea NLP. (provider: intrinio) - cik : Optional[Union[int, str]] - Lookup filings by Central Index Key (CIK) instead of by symbol. (provider: sec) - type : Optional[Literal['1', '1-A', '1-A POS', '1-A-W', '1-E', '1-E AD', '1-K', '1-SA', '1-U', '1-Z', '1-Z-W', '10-12B', '10-12G', '10-D', '10-K', '10-KT', '10-Q', '10-QT', '11-K', '11-KT', '13F-HR', '13F-NT', '13FCONP', '144', '15-12B', '15-12G', '15-15D', '15F-12B', '15F-12G', '15F-15D', '18-12B', '18-K', '19B-4E', '2-A', '2-AF', '2-E', '20-F', '20FR12B', '20FR12G', '24F-2NT', '25', '25-NSE', '253G1', '253G2', '253G3', '253G4', '3', '305B2', '34-12H', '4', '40-17F1', '40-17F2', '40-17G', '40-17GCS', '40-202A', '40-203A', '40-206A', '40-24B2', '40-33', '40-6B', '40-8B25', '40-8F-2', '40-APP', '40-F', '40-OIP', '40FR12B', '40FR12G', '424A', '424B1', '424B2', '424B3', '424B4', '424B5', '424B7', '424B8', '424H', '425', '485APOS', '485BPOS', '485BXT', '486APOS', '486BPOS', '486BXT', '487', '497', '497AD', '497H2', '497J', '497K', '497VPI', '497VPU', '5', '6-K', '6B NTC', '6B ORDR', '8-A12B', '8-A12G', '8-K', '8-K12B', '8-K12G3', '8-K15D5', '8-M', '8F-2 NTC', '8F-2 ORDR', '9-M', 'ABS-15G', 'ABS-EE', 'ADN-MTL', 'ADV-E', 'ADV-H-C', 'ADV-H-T', 'ADV-NR', 'ANNLRPT', 'APP NTC', 'APP ORDR', 'APP WD', 'APP WDG', 'ARS', 'ATS-N', 'ATS-N-C', 'ATS-N/UA', 'AW', 'AW WD', 'C', 'C-AR', 'C-AR-W', 'C-TR', 'C-TR-W', 'C-U', 'C-U-W', 'C-W', 'CB', 'CERT', 'CERTARCA', 'CERTBATS', 'CERTCBO', 'CERTNAS', 'CERTNYS', 'CERTPAC', 'CFPORTAL', 'CFPORTAL-W', 'CORRESP', 'CT ORDER', 'D', 'DEF 14A', 'DEF 14C', 'DEFA14A', 'DEFA14C', 'DEFC14A', 'DEFC14C', 'DEFM14A', 'DEFM14C', 'DEFN14A', 'DEFR14A', 'DEFR14C', 'DEL AM', 'DFAN14A', 'DFRN14A', 'DOS', 'DOSLTR', 'DRS', 'DRSLTR', 'DSTRBRPT', 'EFFECT', 'F-1', 'F-10', 'F-10EF', 'F-10POS', 'F-1MEF', 'F-3', 'F-3ASR', 'F-3D', 'F-3DPOS', 'F-3MEF', 'F-4', 'F-4 POS', 'F-4MEF', 'F-6', 'F-6 POS', 'F-6EF', 'F-7', 'F-7 POS', 'F-8', 'F-8 POS', 'F-80', 'F-80POS', 'F-9', 'F-9 POS', 'F-N', 'F-X', 'FOCUSN', 'FWP', 'G-405', 'G-405N', 'G-FIN', 'G-FINW', 'IRANNOTICE', 'MA', 'MA-A', 'MA-I', 'MA-W', 'MSD', 'MSDCO', 'MSDW', 'N-1', 'N-14', 'N-14 8C', 'N-14MEF', 'N-18F1', 'N-1A', 'N-2', 'N-2 POSASR', 'N-23C-2', 'N-23C3A', 'N-23C3B', 'N-23C3C', 'N-2ASR', 'N-2MEF', 'N-30B-2', 'N-30D', 'N-4', 'N-5', 'N-54A', 'N-54C', 'N-6', 'N-6F', 'N-8A', 'N-8B-2', 'N-8F', 'N-8F NTC', 'N-8F ORDR', 'N-CEN', 'N-CR', 'N-CSR', 'N-CSRS', 'N-MFP', 'N-MFP1', 'N-MFP2', 'N-PX', 'N-Q', 'N-VP', 'N-VPFS', 'NO ACT', 'NPORT-EX', 'NPORT-NP', 'NPORT-P', 'NRSRO-CE', 'NRSRO-UPD', 'NSAR-A', 'NSAR-AT', 'NSAR-B', 'NSAR-BT', 'NSAR-U', 'NT 10-D', 'NT 10-K', 'NT 10-Q', 'NT 11-K', 'NT 20-F', 'NT N-CEN', 'NT N-MFP', 'NT N-MFP1', 'NT N-MFP2', 'NT NPORT-EX', 'NT NPORT-P', 'NT-NCEN', 'NT-NCSR', 'NT-NSAR', 'NTFNCEN', 'NTFNCSR', 'NTFNSAR', 'NTN 10D', 'NTN 10K', 'NTN 10Q', 'NTN 20F', 'OIP NTC', 'OIP ORDR', 'POS 8C', 'POS AM', 'POS AMI', 'POS EX', 'POS462B', 'POS462C', 'POSASR', 'PRE 14A', 'PRE 14C', 'PREC14A', 'PREC14C', 'PREM14A', 'PREM14C', 'PREN14A', 'PRER14A', 'PRER14C', 'PRRN14A', 'PX14A6G', 'PX14A6N', 'QRTLYRPT', 'QUALIF', 'REG-NR', 'REVOKED', 'RW', 'RW WD', 'S-1', 'S-11', 'S-11MEF', 'S-1MEF', 'S-20', 'S-3', 'S-3ASR', 'S-3D', 'S-3DPOS', 'S-3MEF', 'S-4', 'S-4 POS', 'S-4EF', 'S-4MEF', 'S-6', 'S-8', 'S-8 POS', 'S-B', 'S-BMEF', 'SBSE', 'SBSE-A', 'SBSE-BD', 'SBSE-C', 'SBSE-W', 'SC 13D', 'SC 13E1', 'SC 13E3', 'SC 13G', 'SC 14D9', 'SC 14F1', 'SC 14N', 'SC TO-C', 'SC TO-I', 'SC TO-T', 'SC13E4F', 'SC14D1F', 'SC14D9C', 'SC14D9F', 'SD', 'SDR', 'SE', 'SEC ACTION', 'SEC STAFF ACTION', 'SEC STAFF LETTER', 'SF-1', 'SF-3', 'SL', 'SP 15D2', 'STOP ORDER', 'SUPPL', 'T-3', 'TA-1', 'TA-2', 'TA-W', 'TACO', 'TH', 'TTW', 'UNDER', 'UPLOAD', 'WDL-REQ', 'X-17A-5']] - Type of the SEC filing form. (provider: sec) - use_cache : bool - Whether or not to use cache. If True, cache will store for one day. (provider: sec) - - Returns - ------- - OBBject - results : List[CompanyFilings] - Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'sec']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - CompanyFilings - -------------- - filing_date : date - The date of the filing. - accepted_date : Optional[datetime] - Accepted date of the filing. - symbol : Optional[str] - Symbol representing the entity requested in the data. - cik : Optional[str] - Central Index Key (CIK) for the requested entity. - report_type : Optional[str] - Type of filing. - filing_url : Optional[str] - URL to the filing page. - report_url : str - URL to the actual report. - id : Optional[str] - Intrinio ID of the filing. (provider: intrinio) - period_end_date : Optional[date] - Ending date of the fiscal period for the filing. (provider: intrinio) - sec_unique_id : Optional[str] - SEC unique ID of the filing. (provider: intrinio) - instance_url : Optional[str] - URL for the XBRL filing for the report. (provider: intrinio) - industry_group : Optional[str] - Industry group of the company. (provider: intrinio) - industry_category : Optional[str] - Industry category of the company. (provider: intrinio) - report_date : Optional[date] - The date of the filing. (provider: sec) - act : Optional[Union[int, str]] - The SEC Act number. (provider: sec) - items : Optional[Union[str, float]] - The SEC Item numbers. (provider: sec) - primary_doc_description : Optional[str] - The description of the primary document. (provider: sec) - primary_doc : Optional[str] - The filename of the primary document. (provider: sec) - accession_number : Optional[Union[int, str]] - The accession number. (provider: sec) - file_number : Optional[Union[int, str]] - The file number. (provider: sec) - film_number : Optional[Union[int, str]] - The film number. (provider: sec) - is_inline_xbrl : Optional[Union[int, str]] - Whether the filing is an inline XBRL filing. (provider: sec) - is_xbrl : Optional[Union[int, str]] - Whether the filing is an XBRL filing. (provider: sec) - size : Optional[Union[int, str]] - The size of the filing. (provider: sec) - complete_submission_url : Optional[str] - The URL to the complete filing submission. (provider: sec) - filing_detail_url : Optional[str] - The URL to the filing details. (provider: sec) - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.fundamental.filings(limit=100) + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + CompanyFilings + -------------- + filing_date : date + The date of the filing. + accepted_date : Optional[datetime] + Accepted date of the filing. + symbol : Optional[str] + Symbol representing the entity requested in the data. + cik : Optional[str] + Central Index Key (CIK) for the requested entity. + report_type : Optional[str] + Type of filing. + filing_url : Optional[str] + URL to the filing page. + report_url : str + URL to the actual report. + id : Optional[str] + Intrinio ID of the filing. (provider: intrinio) + period_end_date : Optional[date] + Ending date of the fiscal period for the filing. (provider: intrinio) + sec_unique_id : Optional[str] + SEC unique ID of the filing. (provider: intrinio) + instance_url : Optional[str] + URL for the XBRL filing for the report. (provider: intrinio) + industry_group : Optional[str] + Industry group of the company. (provider: intrinio) + industry_category : Optional[str] + Industry category of the company. (provider: intrinio) + report_date : Optional[date] + The date of the filing. (provider: sec) + act : Optional[Union[int, str]] + The SEC Act number. (provider: sec) + items : Optional[Union[str, float]] + The SEC Item numbers. (provider: sec) + primary_doc_description : Optional[str] + The description of the primary document. (provider: sec) + primary_doc : Optional[str] + The filename of the primary document. (provider: sec) + accession_number : Optional[Union[int, str]] + The accession number. (provider: sec) + file_number : Optional[Union[int, str]] + The file number. (provider: sec) + film_number : Optional[Union[int, str]] + The film number. (provider: sec) + is_inline_xbrl : Optional[Union[int, str]] + Whether the filing is an inline XBRL filing. (provider: sec) + is_xbrl : Optional[Union[int, str]] + Whether the filing is an XBRL filing. (provider: sec) + size : Optional[Union[int, str]] + The size of the filing. (provider: sec) + complete_submission_url : Optional[str] + The URL to the complete filing submission. (provider: sec) + filing_detail_url : Optional[str] + The URL to the filing details. (provider: sec) + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.fundamental.filings(limit=100) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index c4c7ce08a411..4296454311e5 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -932,69 +932,69 @@ def search( An empty query returns the full list of ETFs from the provider. - Parameters - ---------- - query : Optional[str] - Search query. + Parameters + ---------- + query : Optional[str] + Search query. + provider : Optional[Literal['fmp']] + 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. + exchange : Optional[Literal['AMEX', 'NYSE', 'NASDAQ', 'ETF', 'TSX', 'EURONEXT']] + The exchange code the ETF trades on. (provider: fmp) + is_active : Optional[Literal[True, False]] + Whether the ETF is actively trading. (provider: fmp) + + Returns + ------- + OBBject + results : List[EtfSearch] + Serializable results. provider : Optional[Literal['fmp']] - 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. - exchange : Optional[Literal['AMEX', 'NYSE', 'NASDAQ', 'ETF', 'TSX', 'EURONEXT']] - The exchange code the ETF trades on. (provider: fmp) - is_active : Optional[Literal[True, False]] - Whether the ETF is actively trading. (provider: fmp) - - Returns - ------- - OBBject - results : List[EtfSearch] - Serializable results. - provider : Optional[Literal['fmp']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - EtfSearch - --------- - symbol : str - Symbol representing the entity requested in the data.(ETF) - name : Optional[str] - Name of the ETF. - market_cap : Optional[float] - The market cap of the ETF. (provider: fmp) - sector : Optional[str] - The sector of the ETF. (provider: fmp) - industry : Optional[str] - The industry of the ETF. (provider: fmp) - beta : Optional[float] - The beta of the ETF. (provider: fmp) - price : Optional[float] - The current price of the ETF. (provider: fmp) - last_annual_dividend : Optional[float] - The last annual dividend paid. (provider: fmp) - volume : Optional[float] - The current trading volume of the ETF. (provider: fmp) - exchange : Optional[str] - The exchange code the ETF trades on. (provider: fmp) - exchange_name : Optional[str] - The full name of the exchange the ETF trades on. (provider: fmp) - country : Optional[str] - The country the ETF is registered in. (provider: fmp) - actively_trading : Optional[Literal[True, False]] - Whether the ETF is actively trading. (provider: fmp) - - Examples - -------- - >>> from openbb import obb - >>> # An empty query returns the full list of ETFs from the provider. - >>> obb.etf.search() - >>> # The query will return results from text-based fields containing the term. - >>> obb.etf.search(query='commercial real estate', provider='fmp') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + EtfSearch + --------- + symbol : str + Symbol representing the entity requested in the data.(ETF) + name : Optional[str] + Name of the ETF. + market_cap : Optional[float] + The market cap of the ETF. (provider: fmp) + sector : Optional[str] + The sector of the ETF. (provider: fmp) + industry : Optional[str] + The industry of the ETF. (provider: fmp) + beta : Optional[float] + The beta of the ETF. (provider: fmp) + price : Optional[float] + The current price of the ETF. (provider: fmp) + last_annual_dividend : Optional[float] + The last annual dividend paid. (provider: fmp) + volume : Optional[float] + The current trading volume of the ETF. (provider: fmp) + exchange : Optional[str] + The exchange code the ETF trades on. (provider: fmp) + exchange_name : Optional[str] + The full name of the exchange the ETF trades on. (provider: fmp) + country : Optional[str] + The country the ETF is registered in. (provider: fmp) + actively_trading : Optional[Literal[True, False]] + Whether the ETF is actively trading. (provider: fmp) + + Examples + -------- + >>> from openbb import obb + >>> # An empty query returns the full list of ETFs from the provider. + >>> obb.etf.search() + >>> # The query will return results from text-based fields containing the term. + >>> obb.etf.search(query='commercial real estate', provider='fmp') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index 80b74d5c1339..20a01445454a 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -75,44 +75,44 @@ def sofr( borrowing cash overnight collateralizing by Treasury securities. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + period : Literal['overnight', '30_day', '90_day', '180_day', 'index'] + Period of SOFR rate. (provider: fred) + + Returns + ------- + OBBject + results : List[SOFR] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - period : Literal['overnight', '30_day', '90_day', '180_day', 'index'] - Period of SOFR rate. (provider: fred) - - Returns - ------- - OBBject - results : List[SOFR] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SOFR - ---- - date : date - The date of the data. - rate : Optional[float] - SOFR rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.sofr(period='overnight') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SOFR + ---- + date : date + The date of the data. + rate : Optional[float] + SOFR rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.sofr(period='overnight') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index 3fdcb2f9cba7..fa7cbf663708 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -61,48 +61,48 @@ def commercial_paper( and many find it to be a lower-cost alternative to bank loans. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : Literal['overnight', '7d', '15d', '30d', '60d', '90d'] - The maturity. - category : Literal['asset_backed', 'financial', 'nonfinancial'] - The category. - grade : Literal['aa', 'a2_p2'] - The grade. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : Literal['overnight', '7d', '15d', '30d', '60d', '90d'] + The maturity. + category : Literal['asset_backed', 'financial', 'nonfinancial'] + The category. + grade : Literal['aa', 'a2_p2'] + The grade. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[CommercialPaper] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[CommercialPaper] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - CommercialPaper - --------------- - date : date - The date of the data. - rate : Optional[float] - Commercial Paper Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.commercial_paper(maturity='15d') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + CommercialPaper + --------------- + date : date + The date of the data. + rate : Optional[float] + Commercial Paper Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.commercial_paper(maturity='15d') """ # noqa: E501 return self._run( @@ -149,48 +149,48 @@ def hqm( that is the market-weighted average (MWA) quality of high quality bonds. - Parameters - ---------- - date : Union[datetime.date, None, str] - A specific date to get data for. - yield_curve : Literal['spot', 'par'] - The yield curve type. + Parameters + ---------- + date : Union[datetime.date, None, str] + A specific date to get data for. + yield_curve : Literal['spot', 'par'] + The yield curve type. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[HighQualityMarketCorporateBond] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[HighQualityMarketCorporateBond] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - HighQualityMarketCorporateBond - ------------------------------ - date : date - The date of the data. - rate : Optional[float] - HighQualityMarketCorporateBond Rate. - maturity : str - Maturity. - yield_curve : Literal['spot', 'par'] - The yield curve type. - series_id : Optional[str] - FRED series id. (provider: fred) - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.hqm(yield_curve='par') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + HighQualityMarketCorporateBond + ------------------------------ + date : date + The date of the data. + rate : Optional[float] + HighQualityMarketCorporateBond Rate. + maturity : str + Maturity. + yield_curve : Literal['spot', 'par'] + The yield curve type. + series_id : Optional[str] + FRED series id. (provider: fred) + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.hqm(yield_curve='par') """ # noqa: E501 return self._run( @@ -243,52 +243,52 @@ def ice_bofa( outstanding of $250 million. The ICE BofA US Corporate Index is a component of the US Corporate Master Index. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - index_type : Literal['yield', 'yield_to_worst', 'total_return', 'spread'] - The type of series. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + index_type : Literal['yield', 'yield_to_worst', 'total_return', 'spread'] + The type of series. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + category : Literal['all', 'duration', 'eur', 'usd'] + The type of category. (provider: fred) + area : Literal['asia', 'emea', 'eu', 'ex_g10', 'latin_america', 'us'] + The type of area. (provider: fred) + grade : Literal['a', 'aa', 'aaa', 'b', 'bb', 'bbb', 'ccc', 'crossover', 'high_grade', 'high_yield', 'non_financial', 'non_sovereign', 'private_sector', 'public_sector'] + The type of grade. (provider: fred) + options : bool + Whether to include options in the results. (provider: fred) + + Returns + ------- + OBBject + results : List[ICEBofA] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - category : Literal['all', 'duration', 'eur', 'usd'] - The type of category. (provider: fred) - area : Literal['asia', 'emea', 'eu', 'ex_g10', 'latin_america', 'us'] - The type of area. (provider: fred) - grade : Literal['a', 'aa', 'aaa', 'b', 'bb', 'bbb', 'ccc', 'crossover', 'high_grade', 'high_yield', 'non_financial', 'non_sovereign', 'private_sector', 'public_sector'] - The type of grade. (provider: fred) - options : bool - Whether to include options in the results. (provider: fred) - - Returns - ------- - OBBject - results : List[ICEBofA] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - ICEBofA - ------- - date : date - The date of the data. - rate : Optional[float] - ICE BofA US Corporate Bond Indices Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + ICEBofA + ------- + date : date + The date of the data. + rate : Optional[float] + ICE BofA US Corporate Bond Indices Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst') """ # noqa: E501 return self._run( @@ -341,46 +341,46 @@ def moody( Treasury Bill as an indicator of the interest rate. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - index_type : Literal['aaa', 'baa'] - The type of series. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + index_type : Literal['aaa', 'baa'] + The type of series. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + spread : Optional[Literal['treasury', 'fed_funds']] + The type of spread. (provider: fred) + + Returns + ------- + OBBject + results : List[MoodyCorporateBondIndex] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - spread : Optional[Literal['treasury', 'fed_funds']] - The type of spread. (provider: fred) - - Returns - ------- - OBBject - results : List[MoodyCorporateBondIndex] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - MoodyCorporateBondIndex - ----------------------- - date : date - The date of the data. - rate : Optional[float] - Moody Corporate Bond Index Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.moody(index_type='baa') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + MoodyCorporateBondIndex + ----------------------- + date : date + The date of the data. + rate : Optional[float] + Moody Corporate Bond Index Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.moody(index_type='baa') """ # noqa: E501 return self._run( @@ -436,46 +436,46 @@ def spot_rates( concept for discounting a pension liability at the same maturity. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : List[float] - The maturities in years. - category : List[Literal['par_yield', 'spot_rate']] - The category. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : List[float] + The maturities in years. + category : List[Literal['par_yield', 'spot_rate']] + The category. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[SpotRate] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[SpotRate] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SpotRate - -------- - date : date - The date of the data. - rate : Optional[float] - Spot Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.spot_rates(maturity=[10, 20, 30, 50]) + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SpotRate + -------- + date : date + The date of the data. + rate : Optional[float] + Spot Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.spot_rates(maturity=[10, 20, 30, 50]) """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_rate.py b/openbb_platform/openbb/package/fixedincome_rate.py index 6e19898cc51b..b1fe1845df29 100644 --- a/openbb_platform/openbb/package/fixedincome_rate.py +++ b/openbb_platform/openbb/package/fixedincome_rate.py @@ -52,44 +52,44 @@ def ameribor( American Financial Exchange (AFX). - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + parameter : Literal['overnight', 'term_30', 'term_90', '1_week_term_structure', '1_month_term_structure', '3_month_term_structure', '6_month_term_structure', '1_year_term_structure', '2_year_term_structure', '30_day_ma', '90_day_ma'] + Period of AMERIBOR rate. (provider: fred) + + Returns + ------- + OBBject + results : List[AMERIBOR] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - parameter : Literal['overnight', 'term_30', 'term_90', '1_week_term_structure', '1_month_term_structure', '3_month_term_structure', '6_month_term_structure', '1_year_term_structure', '2_year_term_structure', '30_day_ma', '90_day_ma'] - Period of AMERIBOR rate. (provider: fred) - - Returns - ------- - OBBject - results : List[AMERIBOR] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - AMERIBOR - -------- - date : date - The date of the data. - rate : Optional[float] - AMERIBOR rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + AMERIBOR + -------- + date : date + The date of the data. + rate : Optional[float] + AMERIBOR rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma') """ # noqa: E501 return self._run( @@ -137,44 +137,44 @@ def dpcredit( also known as the discount rate. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + parameter : Literal['daily_excl_weekend', 'monthly', 'weekly', 'daily', 'annual'] + FRED series ID of DWPCR data. (provider: fred) + + Returns + ------- + OBBject + results : List[DiscountWindowPrimaryCreditRate] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - parameter : Literal['daily_excl_weekend', 'monthly', 'weekly', 'daily', 'annual'] - FRED series ID of DWPCR data. (provider: fred) - - Returns - ------- - OBBject - results : List[DiscountWindowPrimaryCreditRate] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - DiscountWindowPrimaryCreditRate - ------------------------------- - date : date - The date of the data. - rate : Optional[float] - Discount Window Primary Credit Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + DiscountWindowPrimaryCreditRate + ------------------------------- + date : date + The date of the data. + rate : Optional[float] + Discount Window Primary Credit Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') """ # noqa: E501 return self._run( @@ -228,44 +228,44 @@ def ecb( - The rate on the marginal lending facility, which offers overnight credit to banks from the Eurosystem. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - interest_rate_type : Literal['deposit', 'lending', 'refinancing'] - The type of interest rate. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + interest_rate_type : Literal['deposit', 'lending', 'refinancing'] + The type of interest rate. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[EuropeanCentralBankInterestRates] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[EuropeanCentralBankInterestRates] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - EuropeanCentralBankInterestRates - -------------------------------- - date : date - The date of the data. - rate : Optional[float] - European Central Bank Interest Rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + EuropeanCentralBankInterestRates + -------------------------------- + date : date + The date of the data. + rate : Optional[float] + European Central Bank Interest Rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing') """ # noqa: E501 return self._run( @@ -313,44 +313,44 @@ def effr( United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['federal_reserve', 'fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'federal_reserve' if there is + no default. + parameter : Literal['monthly', 'daily', 'weekly', 'daily_excl_weekend', 'annual', 'biweekly', 'volume'] + Period of FED rate. (provider: fred) + + Returns + ------- + OBBject + results : List[FEDFUNDS] + Serializable results. provider : Optional[Literal['federal_reserve', 'fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'federal_reserve' if there is - no default. - parameter : Literal['monthly', 'daily', 'weekly', 'daily_excl_weekend', 'annual', 'biweekly', 'volume'] - Period of FED rate. (provider: fred) - - Returns - ------- - OBBject - results : List[FEDFUNDS] - Serializable results. - provider : Optional[Literal['federal_reserve', 'fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - FEDFUNDS - -------- - date : date - The date of the data. - rate : Optional[float] - FED rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.effr(parameter='daily', provider='fred') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + FEDFUNDS + -------- + date : date + The date of the data. + rate : Optional[float] + FED rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.effr(parameter='daily', provider='fred') """ # noqa: E501 return self._run( @@ -384,52 +384,52 @@ def effr_forecast( calendar year or over the longer run. - Parameters - ---------- + Parameters + ---------- + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + long_run : bool + Flag to show long run projections (provider: fred) + + Returns + ------- + OBBject + results : List[PROJECTIONS] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - long_run : bool - Flag to show long run projections (provider: fred) - - Returns - ------- - OBBject - results : List[PROJECTIONS] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - PROJECTIONS - ----------- - date : date - The date of the data. - range_high : Optional[float] - High projection of rates. - central_tendency_high : Optional[float] - Central tendency of high projection of rates. - median : Optional[float] - Median projection of rates. - range_midpoint : Optional[float] - Midpoint projection of rates. - central_tendency_midpoint : Optional[float] - Central tendency of midpoint projection of rates. - range_low : Optional[float] - Low projection of rates. - central_tendency_low : Optional[float] - Central tendency of low projection of rates. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.effr_forecast(long_run=True) + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + PROJECTIONS + ----------- + date : date + The date of the data. + range_high : Optional[float] + High projection of rates. + central_tendency_high : Optional[float] + Central tendency of high projection of rates. + median : Optional[float] + Median projection of rates. + range_midpoint : Optional[float] + Midpoint projection of rates. + central_tendency_midpoint : Optional[float] + Central tendency of midpoint projection of rates. + range_low : Optional[float] + Low projection of rates. + central_tendency_low : Optional[float] + Central tendency of low projection of rates. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.effr_forecast(long_run=True) """ # noqa: E501 return self._run( @@ -474,44 +474,44 @@ def estr( executed at arm’s length and thus reflect market rates in an unbiased way. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + parameter : Literal['volume_weighted_trimmed_mean_rate', 'number_of_transactions', 'number_of_active_banks', 'total_volume', 'share_of_volume_of_the_5_largest_active_banks', 'rate_at_75th_percentile_of_volume', 'rate_at_25th_percentile_of_volume'] + Period of ESTR rate. (provider: fred) + + Returns + ------- + OBBject + results : List[ESTR] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - parameter : Literal['volume_weighted_trimmed_mean_rate', 'number_of_transactions', 'number_of_active_banks', 'total_volume', 'share_of_volume_of_the_5_largest_active_banks', 'rate_at_75th_percentile_of_volume', 'rate_at_25th_percentile_of_volume'] - Period of ESTR rate. (provider: fred) - - Returns - ------- - OBBject - results : List[ESTR] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - ESTR - ---- - date : date - The date of the data. - rate : Optional[float] - ESTR rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + ESTR + ---- + date : date + The date of the data. + rate : Optional[float] + ESTR rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks') """ # noqa: E501 return self._run( @@ -558,42 +558,42 @@ def iorb( United States, the Federal Reserve System's Board of Governors set the bank rate, also known as the discount rate. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + + Returns + ------- + OBBject + results : List[IORB] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - - Returns - ------- - OBBject - results : List[IORB] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - IORB - ---- - date : date - The date of the data. - rate : Optional[float] - IORB rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.iorb() + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + IORB + ---- + date : date + The date of the data. + rate : Optional[float] + IORB rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.iorb() """ # noqa: E501 return self._run( @@ -640,44 +640,44 @@ def sonia( financial institutions and other institutional investors. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. + parameter : Literal['rate', 'index', '10th_percentile', '25th_percentile', '75th_percentile', '90th_percentile', 'total_nominal_value'] + Period of SONIA rate. (provider: fred) + + Returns + ------- + OBBject + results : List[SONIA] + Serializable results. provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. - parameter : Literal['rate', 'index', '10th_percentile', '25th_percentile', '75th_percentile', '90th_percentile', 'total_nominal_value'] - Period of SONIA rate. (provider: fred) - - Returns - ------- - OBBject - results : List[SONIA] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SONIA - ----- - date : date - The date of the data. - rate : Optional[float] - SONIA rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value') + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SONIA + ----- + date : date + The date of the data. + rate : Optional[float] + SONIA rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_spreads.py b/openbb_platform/openbb/package/fixedincome_spreads.py index 8664cf7763e2..898b35109a9f 100644 --- a/openbb_platform/openbb/package/fixedincome_spreads.py +++ b/openbb_platform/openbb/package/fixedincome_spreads.py @@ -52,44 +52,44 @@ def tcm( yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : Optional[Literal['3m', '2y']] - The maturity - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : Optional[Literal['3m', '2y']] + The maturity + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. - Returns - ------- - OBBject - results : List[TreasuryConstantMaturity] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + Returns + ------- + OBBject + results : List[TreasuryConstantMaturity] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - TreasuryConstantMaturity - ------------------------ - date : date - The date of the data. - rate : Optional[float] - TreasuryConstantMaturity Rate. + TreasuryConstantMaturity + ------------------------ + date : date + The date of the data. + rate : Optional[float] + TreasuryConstantMaturity Rate. - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.spreads.tcm(maturity='2y') + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.spreads.tcm(maturity='2y') """ # noqa: E501 return self._run( @@ -142,44 +142,44 @@ def tcm_effr( yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : Optional[Literal['10y', '5y', '1y', '6m', '3m']] - The maturity - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : Optional[Literal['10y', '5y', '1y', '6m', '3m']] + The maturity + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. - Returns - ------- - OBBject - results : List[SelectedTreasuryConstantMaturity] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + Returns + ------- + OBBject + results : List[SelectedTreasuryConstantMaturity] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - SelectedTreasuryConstantMaturity - -------------------------------- - date : date - The date of the data. - rate : Optional[float] - Selected Treasury Constant Maturity Rate. + SelectedTreasuryConstantMaturity + -------------------------------- + date : date + The date of the data. + rate : Optional[float] + Selected Treasury Constant Maturity Rate. - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.spreads.tcm_effr(maturity='10y') + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.spreads.tcm_effr(maturity='10y') """ # noqa: E501 return self._run( @@ -233,44 +233,44 @@ def treasury_effr( yield curve which, in turn, is based on closing bid-yields of actively-traded Treasury securities. - Parameters - ---------- - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. - maturity : Optional[Literal['3m', '6m']] - The maturity - provider : Optional[Literal['fred']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'fred' if there is - no default. + Parameters + ---------- + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. + maturity : Optional[Literal['3m', '6m']] + The maturity + provider : Optional[Literal['fred']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'fred' if there is + no default. - Returns - ------- - OBBject - results : List[SelectedTreasuryBill] - Serializable results. - provider : Optional[Literal['fred']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. + Returns + ------- + OBBject + results : List[SelectedTreasuryBill] + Serializable results. + provider : Optional[Literal['fred']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. - SelectedTreasuryBill - -------------------- - date : date - The date of the data. - rate : Optional[float] - SelectedTreasuryBill Rate. + SelectedTreasuryBill + -------------------- + date : date + The date of the data. + rate : Optional[float] + SelectedTreasuryBill Rate. - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.spreads.treasury_effr(maturity='6m') + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.spreads.treasury_effr(maturity='6m') """ # noqa: E501 return self._run( From 3edcd91f473ffc527167506013e28e2d3de1053c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 19:26:06 +0000 Subject: [PATCH 014/133] fix python examples --- .../core/openbb_core/app/model/example.py | 3 +- .../openbb_regulators/sec/sec_router.py | 44 +++++++++---------- .../openbb/package/regulators_sec.py | 17 +++++++ 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 147b95970ce3..cecc760f3b36 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -39,6 +39,7 @@ def to_python( eg = indentation + eg.strip(", ") + ")\n" elif self.scope == "python" and self.code is not None: - eg += f"{indentation}>>> \n".join(self.code) + "\n" + for line in self.code: + eg += f"{indentation}>>> {line}\n" return eg diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 598e42f4ec75..adc0c29af15e 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -45,28 +45,28 @@ async def institutions_search( model="SchemaFiles", examples=[ Example(parameters={}), - # Example( - # scope="python", - # code=[ - # "data = obb.regulators.sec.schema_files()", - # "data.files[0]", - # " https://xbrl.fasb.org/us-gaap/", - # "#### The directory structure can be navigated by constructing a URL from the 'results' list. ####", - # "url = data.files[0]+data.files[-1]", - # "#### The URL base will always be the 0 position in the list, feed the URL back in as a parameter. ####", - # "obb.regulators.sec.schema_files(url=url).results.files", - # " ['https://xbrl.fasb.org/us-gaap/2024/'", - # " 'USGAAP2024FileList.xml'", - # " 'dis/'", - # " 'dqcrules/'", - # " 'ebp/'", - # " 'elts/'", - # " 'entire/'", - # " 'meta/'", - # " 'stm/'", - # " 'us-gaap-2024.zip']", - # ], - # ), + Example( + scope="python", + code=[ + "data = obb.regulators.sec.schema_files()", + "data.files[0]", + " https://xbrl.fasb.org/us-gaap/", + "#### The directory structure can be navigated by constructing a URL from the 'results' list. ####", + "url = data.files[0]+data.files[-1]", + "#### The URL base will always be the 0 position in the list, feed the URL back in as a parameter. ####", + "obb.regulators.sec.schema_files(url=url).results.files", + " ['https://xbrl.fasb.org/us-gaap/2024/'", + " 'USGAAP2024FileList.xml'", + " 'dis/'", + " 'dqcrules/'", + " 'ebp/'", + " 'elts/'", + " 'entire/'", + " 'meta/'", + " 'stm/'", + " 'us-gaap-2024.zip']", + ], + ), ], ) async def schema_files( diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index b0b9dd3e8d86..395f8d61f39c 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -272,6 +272,23 @@ def schema_files( -------- >>> from openbb import obb >>> obb.regulators.sec.schema_files() + >>> data = obb.regulators.sec.schema_files() + >>> data.files[0] + >>> https://xbrl.fasb.org/us-gaap/ + >>> #### The directory structure can be navigated by constructing a URL from the 'results' list. #### + >>> url = data.files[0]+data.files[-1] + >>> #### The URL base will always be the 0 position in the list, feed the URL back in as a parameter. #### + >>> obb.regulators.sec.schema_files(url=url).results.files + >>> ['https://xbrl.fasb.org/us-gaap/2024/' + >>> 'USGAAP2024FileList.xml' + >>> 'dis/' + >>> 'dqcrules/' + >>> 'ebp/' + >>> 'elts/' + >>> 'entire/' + >>> 'meta/' + >>> 'stm/' + >>> 'us-gaap-2024.zip'] """ # noqa: E501 return self._run( From d61c1e5c0433bdcac06619e5fcc9e4acfc29617f Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 19:27:00 +0000 Subject: [PATCH 015/133] remove doc --- .../econometrics/openbb_econometrics/econometrics_router.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 24521919bccc..2453c3109650 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -47,11 +47,6 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: ------- OBBject[List[Data]]: Correlation matrix. - - Examples - -------- - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - "obb.econometrics.correlation_matrix(data=stock_data)", """ df = basemodel_to_df(data) # remove non float columns from the dataframe to perform the correlation From 90517ebfa6bb53bc73c82f8b9c55d89f840348d3 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 19:31:01 +0000 Subject: [PATCH 016/133] pylint --- openbb_platform/core/openbb_core/app/model/example.py | 4 ++-- .../core/openbb_core/app/static/package_builder.py | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index cecc760f3b36..92e74f49314a 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -17,7 +17,7 @@ class Example(BaseModel): def to_python( self, func_name: str, func_params: Dict[str, Field], indentation: str = "" ) -> str: - """Return a Python code representation of the examplself.""" + """Return a Python code representation of the example.""" eg = "" if self.scope == "api" and self.parameters is not None: if self.description: @@ -39,7 +39,7 @@ def to_python( eg = indentation + eg.strip(", ") + ")\n" elif self.scope == "python" and self.code is not None: - for line in self.code: + for line in self.code: # pylint: disable=not-an-iterable eg += f"{indentation}>>> {line}\n" return eg diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index eb9c94d22d3b..29fcd0d5dd70 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -10,11 +10,9 @@ from json import dumps, load from pathlib import Path from typing import ( - Any, Callable, Dict, List, - Literal, Optional, OrderedDict, Set, @@ -23,7 +21,6 @@ TypeVar, Union, get_args, - get_origin, get_type_hints, ) @@ -39,7 +36,7 @@ from openbb_core.app.model.custom_parameter import OpenBBCustomParameter from openbb_core.app.model.example import Example from openbb_core.app.provider_interface import ProviderInterface -from openbb_core.app.router import CommandMap, RouterLoader +from openbb_core.app.router import RouterLoader from openbb_core.app.static.utils.console import Console from openbb_core.app.static.utils.linters import Linters from openbb_core.env import Env From eb6cc1f9155f84a5c46e64de1d51280f862c0745 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 20:02:13 +0000 Subject: [PATCH 017/133] again --- .../core/openbb_core/app/static/package_builder.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 29fcd0d5dd70..efbdf7ab17a2 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -908,7 +908,7 @@ def format_description(description: str) -> str: description = description.replace("\n", f"\n{indentation+tab}") return description - docstring = summary.replace("\n ",f"\n{indentation}").strip("\n") + docstring = summary.strip("\n").replace("\n ",f"\n{indentation}") docstring += "\n\n" docstring += f"{indentation}Parameters\n" docstring += f"{indentation}----------\n" @@ -1011,7 +1011,7 @@ def generate( tab: str = " ", ) -> Optional[str]: """Generate the docstring for the function.""" - doc = func.__doc__ + doc = func.__doc__ or "" func_params = {} if model_name: params = cls.provider_interface.params.get(model_name, {}) @@ -1039,6 +1039,8 @@ def generate( indentation=indentation, tab=tab, ) + else: + doc = doc.replace("\n ",f"\n{indentation}") if doc and examples: doc += cls.append_examples( From 5bcdc2de6611a0ee089623a3f0622a70e02c7db4 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 1 Mar 2024 21:16:21 +0000 Subject: [PATCH 018/133] add model validators --- .../core/openbb_core/app/model/example.py | 17 ++++++++++++++++- .../openbb_core/app/static/package_builder.py | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 92e74f49314a..87eaafedf7ca 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,7 +1,7 @@ from dataclasses import Field from typing import Any, Dict, List, Literal, Optional -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, model_validator class Example(BaseModel): @@ -14,6 +14,21 @@ class Example(BaseModel): model_config = ConfigDict(validate_assignment=True) + @model_validator(mode="before") + @classmethod + def validate_fields(cls, values) -> dict: + """Validate parameters and code based on scope.""" + scope = values.get("scope", "") + parameters = values.get("parameters") + code = values.get("code") + + if scope == "api" and not parameters: + raise ValueError("Parameters are required for API examples.") + if scope == "python" and not code: + raise ValueError("Code is required for Python examples.") + + return values + def to_python( self, func_name: str, func_params: Dict[str, Field], indentation: str = "" ) -> str: diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index efbdf7ab17a2..eecf18f2adad 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -908,7 +908,7 @@ def format_description(description: str) -> str: description = description.replace("\n", f"\n{indentation+tab}") return description - docstring = summary.strip("\n").replace("\n ",f"\n{indentation}") + docstring = summary.strip("\n").replace("\n ", f"\n{indentation}") docstring += "\n\n" docstring += f"{indentation}Parameters\n" docstring += f"{indentation}----------\n" @@ -1040,7 +1040,7 @@ def generate( tab=tab, ) else: - doc = doc.replace("\n ",f"\n{indentation}") + doc = doc.replace("\n ", f"\n{indentation}") if doc and examples: doc += cls.append_examples( From 7282af0b0dda9399149538c2d92a20565cefeef1 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 11:36:44 +0000 Subject: [PATCH 019/133] commodity, crypto, currency --- .../app/static/utils/decorators.py | 4 ++-- .../openbb_commodity/commodity_router.py | 12 +++++++++++- .../crypto/openbb_crypto/crypto_router.py | 3 +-- .../openbb_crypto/price/price_router.py | 19 +++++-------------- .../openbb_currency/currency_router.py | 10 +++++----- .../openbb_currency/price/price_router.py | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/utils/decorators.py b/openbb_platform/core/openbb_core/app/static/utils/decorators.py index febb23cd3b5d..fc4b14af45bb 100644 --- a/openbb_platform/core/openbb_core/app/static/utils/decorators.py +++ b/openbb_platform/core/openbb_core/app/static/utils/decorators.py @@ -62,9 +62,9 @@ def wrapper(*f_args, **f_kwargs): validation_error = f"{e.error_count()} validations errors in {e.title}" for error in e.errors(): - arg_error = f"Arg {error['loc'][0]} ->\n" + arg_error = f"Arg '{error['loc'][0]}' -> " error_details = ( - f" {error['msg']} " + f"{error['msg']} " f"[validation_error_type={error['type']}, " f"input_type={type(error['input']).__name__}, " f"input_value={error['input']}]\n" diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index 3c6bce0c7bb2..2060d21f20a6 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -16,7 +16,17 @@ # pylint: disable=unused-argument @router.command( model="LbmaFixing", - examples=[Example(parameters={"asset": "gold"})], + examples=[ + Example(parameters={"asset": "gold"}), + Example( + parameters={ + "asset": "silver", + "start_date": "2023-01-01", + "end_date": "2023-12-31", + "transform": "rdiff", + "collapse": "monthly", + }), + ], ) async def lbma_fixing( cc: CommandContext, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py index f70ef92a2592..23ef8fae2929 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py @@ -20,8 +20,7 @@ model="CryptoSearch", examples=[ Example(parameters={}), - Example(parameters={"symbol": "BTCUSD"}), - Example(parameters={"symbol": "ETH-USD"}), + Example(parameters={"query": "BTCUSD"}), ], ) async def search( diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index 936236d8f64c..1915513d3bff 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -27,27 +27,18 @@ ), Example( parameters={ - "symbol": "ETH-USD", - "provider": "yfinance", - "interval": "1mo", - "start_date": "2024-01-01", - "end_date": "2024-12-31", - }, - ), - Example( - parameters={ - "symbol": "BTCUSD,ETH-USD", - "provider": "yfinance", - "interval": "1d", + "symbol": "BTCUSD,ETHUSD", "start_date": "2024-01-01", "end_date": "2024-01-31", }, ), Example( parameters={ - "symbol": "BTCUSD,ETH-USD", + "symbol": "ETH-USD", + "provider": "yfinance", + "interval": "1mo", "start_date": "2024-01-01", - "end_date": "2024-01-31", + "end_date": "2024-12-31", }, ), ], diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index cd6ff242af82..51408f588c4b 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -24,14 +24,14 @@ description="Search for 'EURUSD' currency pair using 'polygon' as provider.", parameters={"provider": "polygon", "symbol": "EURUSD"}, ), - Example( - description="Search for terms using 'polygon' as provider.", - parameters={"provider": "polygon", "search": "Euro zone"}, - ), Example( description="Search for actively traded currency pairs on the queried date using 'polygon' as provider.", parameters={"provider": "polygon", "date": "2024-01-02", "active": True}, ), + Example( + description="Search for terms using 'polygon' as provider.", + parameters={"provider": "polygon", "search": "Euro zone"}, + ), ], ) async def search( @@ -55,7 +55,7 @@ async def search( @router.command( model="CurrencyReferenceRates", - examples=[Example(parameters={"symbol": "EURUSD"})], + examples=[Example(parameters={})], ) async def reference_rates( cc: CommandContext, diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index e955375eb1aa..568327875c96 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -28,7 +28,7 @@ ), Example( description="Get data with different granularity.", - parameters={"symbol": "EURUSD", "interval": "15m", "provider": "polygon"}, + parameters={"symbol": "EURUSD", "provider": "polygon", "interval": "15m"}, ), ], ) From 0ff76cbf888fbde7d4e63f90903b5fdbf9555c9a Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 12:20:18 +0000 Subject: [PATCH 020/133] filter examples --- .../core/openbb_core/app/model/example.py | 24 +++++++++++++++++++ .../core/openbb_core/app/router.py | 7 +++++- .../openbb_core/app/static/package_builder.py | 6 ++++- .../openbb_commodity/commodity_router.py | 3 ++- .../futures/futures_router.py | 10 ++++---- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 87eaafedf7ca..045f6aa17d06 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -29,6 +29,11 @@ def validate_fields(cls, values) -> dict: return values + @property + def provider(self) -> Optional[str]: + """Return the provider from the parameters.""" + return self.parameters.get("provider") if self.parameters else None + def to_python( self, func_name: str, func_params: Dict[str, Field], indentation: str = "" ) -> str: @@ -58,3 +63,22 @@ def to_python( eg += f"{indentation}>>> {line}\n" return eg + + @staticmethod + def filter_list( + examples: List["Example"], + scopes: List[str], + providers: Optional[List[str]] = None, + ) -> List["Example"]: + """Filter list of examples.""" + providers = providers or [] + filtered = [] + if examples: + for e in examples: + if e.scope in scopes: + if e.scope == "api": + if e.provider and e.provider in providers: + filtered.append(e) + else: + filtered.append(e) + return filtered diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index 79ee776870a7..cceacc010fed 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -28,6 +28,7 @@ from openbb_core.app.extension_loader import ExtensionLoader from openbb_core.app.model.abstract.warning import OpenBBWarning from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import Example from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -238,7 +239,11 @@ def command( kwargs["response_model_exclude_unset"] = True kwargs["openapi_extra"] = kwargs.get("openapi_extra", {}) kwargs["openapi_extra"]["model"] = model - kwargs["openapi_extra"]["examples"] = kwargs.pop("examples", None) + kwargs["openapi_extra"]["examples"] = None or Example.filter_list( + examples=kwargs.pop("examples", []), + scopes=["api"], + providers=ProviderInterface().available_providers, + ) kwargs["operation_id"] = kwargs.get( "operation_id", SignatureInspector.get_operation_id(func) ) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index eecf18f2adad..0c79d89a51e1 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -874,7 +874,11 @@ def append_examples( doc += f"{indentation}--------\n" doc += f"{indentation}>>> from openbb import obb\n" - for e in examples: + for e in Example.filter_list( + examples=examples, + scopes=["api", "python"], + providers=ProviderInterface().available_providers, + ): doc += e.to_python(func_name, func_params, indentation) return doc return "" diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index 2060d21f20a6..c3ad31e4c30c 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -25,7 +25,8 @@ "end_date": "2023-12-31", "transform": "rdiff", "collapse": "monthly", - }), + } + ), ], ) async def lbma_fixing( diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index 49b5473436ef..8b5468283578 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -16,7 +16,11 @@ @router.command( model="FuturesHistorical", examples=[ - Example(parameters={"symbol": "ES", "provider": "yfinance"}), + Example(parameters={"symbol": "ES"}), + Example( + description="Enter multiple symbols.", + parameters={"symbol": "ES,NQ", "provider": "yfinance"}, + ), Example( description='Enter expiration dates as "YYYY-MM".', parameters={ @@ -25,10 +29,6 @@ "expiration": "2025-12", }, ), - Example( - description="Enter multiple symbols as a list.", - parameters={"symbol": "ES,NQ,ESZ24.CME,NQZ24.CME", "provider": "yfinance"}, - ), ], ) async def historical( From c06927b42a488e89c500a8c4783c6dda7dbdf197 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 12:37:32 +0000 Subject: [PATCH 021/133] fix python examples --- .../core/openbb_core/app/model/example.py | 19 ++++++------------- .../core/openbb_core/app/router.py | 1 - .../openbb_core/app/static/package_builder.py | 6 +----- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 045f6aa17d06..181f2422bbc3 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -67,18 +67,11 @@ def to_python( @staticmethod def filter_list( examples: List["Example"], - scopes: List[str], - providers: Optional[List[str]] = None, + providers: List[str], ) -> List["Example"]: """Filter list of examples.""" - providers = providers or [] - filtered = [] - if examples: - for e in examples: - if e.scope in scopes: - if e.scope == "api": - if e.provider and e.provider in providers: - filtered.append(e) - else: - filtered.append(e) - return filtered + return [ + e + for e in examples + if (e.scope == "api" and e.provider in providers) or e.scope != "api" + ] diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index cceacc010fed..1a8a46423332 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -241,7 +241,6 @@ def command( kwargs["openapi_extra"]["model"] = model kwargs["openapi_extra"]["examples"] = None or Example.filter_list( examples=kwargs.pop("examples", []), - scopes=["api"], providers=ProviderInterface().available_providers, ) kwargs["operation_id"] = kwargs.get( diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 0c79d89a51e1..eecf18f2adad 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -874,11 +874,7 @@ def append_examples( doc += f"{indentation}--------\n" doc += f"{indentation}>>> from openbb import obb\n" - for e in Example.filter_list( - examples=examples, - scopes=["api", "python"], - providers=ProviderInterface().available_providers, - ): + for e in examples: doc += e.to_python(func_name, func_params, indentation) return doc return "" From a8f7ebc6f29ec99ca3abbb21cc15043f092f9028 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 13:13:16 +0000 Subject: [PATCH 022/133] fix filter and build --- .../core/openbb_core/app/model/example.py | 3 +- .../openbb_regulators/sec/sec_router.py | 1 + openbb_platform/openbb/package/crypto.py | 3 +- .../openbb/package/crypto_price.py | 3 +- openbb_platform/openbb/package/currency.py | 4 +- .../openbb/package/currency_price.py | 2 +- openbb_platform/openbb/package/economy.py | 2 - openbb_platform/openbb/package/economy_gdp.py | 4 +- openbb_platform/openbb/package/index.py | 2 - openbb_platform/openbb/package/news.py | 2 - .../openbb/package/regulators_sec.py | 1 + openbb_platform/pyproject.toml | 288 ++++++++++++------ 12 files changed, 214 insertions(+), 101 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 181f2422bbc3..b843f6c5801b 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -73,5 +73,6 @@ def filter_list( return [ e for e in examples - if (e.scope == "api" and e.provider in providers) or e.scope != "api" + if (e.scope == "api" and (not e.provider or e.provider in providers)) + or e.scope != "api" ] diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index adc0c29af15e..4f1f2ca95c3d 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -48,6 +48,7 @@ async def institutions_search( Example( scope="python", code=[ + "#### Get a list of schema files. ####", "data = obb.regulators.sec.schema_files()", "data.files[0]", " https://xbrl.fasb.org/us-gaap/", diff --git a/openbb_platform/openbb/package/crypto.py b/openbb_platform/openbb/package/crypto.py index 174839b7160f..9eb7d77e6042 100644 --- a/openbb_platform/openbb/package/crypto.py +++ b/openbb_platform/openbb/package/crypto.py @@ -78,8 +78,7 @@ def search( -------- >>> from openbb import obb >>> obb.crypto.search() - >>> obb.crypto.search(symbol='BTCUSD') - >>> obb.crypto.search(symbol='ETH-USD') + >>> obb.crypto.search(query='BTCUSD') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/crypto_price.py b/openbb_platform/openbb/package/crypto_price.py index 970cc2eeb8a8..3f11ad7dfca7 100644 --- a/openbb_platform/openbb/package/crypto_price.py +++ b/openbb_platform/openbb/package/crypto_price.py @@ -123,9 +123,8 @@ def historical( >>> from openbb import obb >>> obb.crypto.price.historical(symbol='BTCUSD') >>> obb.crypto.price.historical(symbol='BTCUSD', start_date='2024-01-01', end_date='2024-01-31') + >>> obb.crypto.price.historical(symbol='BTCUSD,ETHUSD', start_date='2024-01-01', end_date='2024-01-31') >>> obb.crypto.price.historical(symbol='ETH-USD', provider='yfinance', interval='1mo', start_date='2024-01-01', end_date='2024-12-31') - >>> obb.crypto.price.historical(symbol='BTCUSD,ETH-USD', provider='yfinance', interval='1d', start_date='2024-01-01', end_date='2024-01-31') - >>> obb.crypto.price.historical(symbol='BTCUSD,ETH-USD', start_date='2024-01-01', end_date='2024-01-31') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index 281541627d91..8d7334684a6e 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -116,10 +116,10 @@ def search( >>> obb.currency.search() >>> # Search for 'EURUSD' currency pair using 'polygon' as provider. >>> obb.currency.search(provider='polygon', symbol='EURUSD') - >>> # Search for terms using 'polygon' as provider. - >>> obb.currency.search(provider='polygon', search='Euro zone') >>> # Search for actively traded currency pairs on the queried date using 'polygon' as provider. >>> obb.currency.search(provider='polygon', date='2024-01-02', active=True) + >>> # Search for terms using 'polygon' as provider. + >>> obb.currency.search(provider='polygon', search='Euro zone') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/currency_price.py b/openbb_platform/openbb/package/currency_price.py index 2e523e600986..dd7a0f3e9116 100644 --- a/openbb_platform/openbb/package/currency_price.py +++ b/openbb_platform/openbb/package/currency_price.py @@ -126,7 +126,7 @@ def historical( >>> # Filter historical data with specific start and end date. >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='2023-12-31') >>> # Get data with different granularity. - >>> obb.currency.price.historical(symbol='EURUSD', interval='15m', provider='polygon') + >>> obb.currency.price.historical(symbol='EURUSD', provider='polygon', interval='15m') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index e19b728fb5d4..bbc4ba31711e 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -125,8 +125,6 @@ def calendar( -------- >>> from openbb import obb >>> obb.economy.calendar(provider='fmp', start_date='2020-03-01', end_date='2020-03-31') - >>> # By default, the calendar will be forward-looking. - >>> obb.economy.calendar(provider='nasdaq') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/economy_gdp.py b/openbb_platform/openbb/package/economy_gdp.py index 0da6ff4b972c..3884d5004ff6 100644 --- a/openbb_platform/openbb/package/economy_gdp.py +++ b/openbb_platform/openbb/package/economy_gdp.py @@ -157,7 +157,7 @@ def nominal( The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'oecd' if there is no default. - country : Literal['australia', 'austria', 'belgium', 'brazil', 'canada', 'chile', 'colombia', 'costa_rica', 'czech_republic', 'denmark', 'estonia', 'euro_area', 'european_union', 'finland', 'france', 'germany', 'greece', 'hungary', 'iceland', 'indonesia', 'ireland', 'israel', 'italy', 'japan', 'korea', 'latvia', 'lithuania', 'luxembourg', 'mexico', 'netherlands', 'new_zealand', 'norway', 'poland', 'portugal', 'russia', 'slovak_republic', 'slovenia', 'south_africa', 'spain', 'sweden', 'switzerland', 'turkey', 'united_kingdom', 'united_states'] + country : Literal['australia', 'austria', 'belgium', 'brazil', 'canada', 'chile', 'colombia', 'costa_rica', 'czech_republic', 'denmark', 'estonia', 'euro_area', 'european_union', 'finland', 'france', 'germany', 'greece', 'hungary', 'iceland', 'indonesia', 'ireland', 'israel', 'italy', 'japan', 'korea', 'latvia', 'lithuania', 'luxembourg', 'mexico', 'netherlands', 'new_zealand', 'norway', 'poland', 'portugal', 'russia', 'slovak_republic', 'slovenia', 'south_africa', 'spain', 'sweden', 'switzerland', 'turkey', 'united_kingdom', 'united_states', 'all'] Country to get GDP for. (provider: oecd) Returns @@ -245,7 +245,7 @@ def real( The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'oecd' if there is no default. - country : Literal['G20', 'G7', 'argentina', 'australia', 'austria', 'belgium', 'brazil', 'bulgaria', 'canada', 'chile', 'china', 'colombia', 'costa_rica', 'croatia', 'czech_republic', 'denmark', 'estonia', 'euro_area_19', 'europe', 'european_union_27', 'finland', 'france', 'germany', 'greece', 'hungary', 'iceland', 'india', 'indonesia', 'ireland', 'israel', 'italy', 'japan', 'korea', 'latvia', 'lithuania', 'luxembourg', 'mexico', 'netherlands', 'new_zealand', 'norway', 'oecd_total', 'poland', 'portugal', 'romania', 'russia', 'saudi_arabia', 'slovak_republic', 'slovenia', 'south_africa', 'spain', 'sweden', 'switzerland', 'turkey', 'united_kingdom', 'united_states'] + country : Literal['G20', 'G7', 'argentina', 'australia', 'austria', 'belgium', 'brazil', 'bulgaria', 'canada', 'chile', 'china', 'colombia', 'costa_rica', 'croatia', 'czech_republic', 'denmark', 'estonia', 'euro_area_19', 'europe', 'european_union_27', 'finland', 'france', 'germany', 'greece', 'hungary', 'iceland', 'india', 'indonesia', 'ireland', 'israel', 'italy', 'japan', 'korea', 'latvia', 'lithuania', 'luxembourg', 'mexico', 'netherlands', 'new_zealand', 'norway', 'oecd_total', 'poland', 'portugal', 'romania', 'russia', 'saudi_arabia', 'slovak_republic', 'slovenia', 'south_africa', 'spain', 'sweden', 'switzerland', 'turkey', 'united_kingdom', 'united_states', 'all'] Country to get GDP for. (provider: oecd) Returns diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index 8e1cbd0d7865..f1bf615d2234 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -146,8 +146,6 @@ def constituents( -------- >>> from openbb import obb >>> obb.index.constituents(symbol='dowjones', provider='fmp') - >>> # Providers other than FMP will use the ticker symbol. - >>> obb.index.constituents(symbol='BEP50P', provider='cboe') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index b6e37e0b4cb8..a5118aa54112 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -340,8 +340,6 @@ def world( >>> obb.news.world(topics='finance', provider='benzinga') >>> # Get news by source using 'tingo' as provider. >>> obb.news.world(provider='tiingo', source='bloomberg') - >>> # Filter aticles by term using 'biztoc' as provider. - >>> obb.news.world(provider='biztoc', term='apple') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index 395f8d61f39c..39587c3113f3 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -272,6 +272,7 @@ def schema_files( -------- >>> from openbb import obb >>> obb.regulators.sec.schema_files() + >>> #### Get a list of schema files. #### >>> data = obb.regulators.sec.schema_files() >>> data.files[0] >>> https://xbrl.fasb.org/us-gaap/ diff --git a/openbb_platform/pyproject.toml b/openbb_platform/pyproject.toml index 1c40190bae58..0c13e0067f80 100644 --- a/openbb_platform/pyproject.toml +++ b/openbb_platform/pyproject.toml @@ -1,96 +1,214 @@ +[build-system] +requires = [ "poetry-core",] +build-backend = "poetry.core.masonry.api" + [tool.poetry] name = "openbb" version = "4.1.4" description = "OpenBB" -authors = ["OpenBB Team "] +authors = [ "OpenBB Team ",] readme = "README.md" -packages = [{ include = "openbb" }] +[[tool.poetry.packages]] +include = "openbb" [tool.poetry.dependencies] python = ">=3.8,<3.12" -openbb-core = "^1.1.2" - -openbb-benzinga = "^1.1.2" -openbb-federal-reserve = "^1.1.2" -openbb-fmp = "^1.1.2" -openbb-fred = "^1.1.2" -openbb-intrinio = "^1.1.2" -openbb-oecd = "^1.1.2" -openbb-polygon = "^1.1.2" -openbb-sec = "^1.1.2" -openbb-tiingo = "^1.1.2" -openbb-tradingeconomics = "^1.1.2" -openbb-yfinance = "^1.1.2" - -openbb-commodity = "^1.0.0" -openbb-crypto = "^1.1.2" -openbb-currency = "^1.1.2" -openbb-derivatives = "^1.1.2" -openbb-economy = "^1.1.2" -openbb-equity = "^1.1.2" -openbb-etf = "^1.1.2" -openbb-fixedincome = "^1.1.2" -openbb-index = "^1.1.2" -openbb-news = "^1.1.2" -openbb-regulators = "^1.1.2" - -# Community dependencies -openbb-alpha-vantage = { version = "^1.1.2", optional = true } -openbb-biztoc = { version = "^1.1.2", optional = true } -openbb-cboe = { version = "^1.1.2", optional = true } -openbb-ecb = { version = "^1.1.2", optional = true } -openbb-finra = { version = "^1.1.2", optional = true } -openbb-finviz = { version = "^1.0.1", optional = true } -openbb-government-us = { version = "^1.1.2", optional = true } -openbb-nasdaq = { version = "^1.1.3", optional = true } -openbb-seeking-alpha = { version = "^1.1.2", optional = true } -openbb-stockgrid = { version = "^1.1.2", optional = true } -openbb-tmx = { version = "^1.0.0", optional = true } -openbb-wsj = { version = "^1.1.2", optional = true } - -openbb-charting = { version = "^2.0.0", optional = true } -openbb-econometrics = { version = "^1.1.2", optional = true } -openbb-quantitative = { version = "^1.1.2", optional = true } -openbb-technical = { version = "^1.1.3", optional = true } [tool.poetry.extras] -alpha_vantage = ["openbb-alpha-vantage"] -biztoc = ["openbb-biztoc"] -cboe = ["openbb-cboe"] -charting = ["openbb-charting"] -ecb = ["openbb-ecb"] -econometrics = ["openbb-econometrics"] -finra = ["openbb-finra"] -finviz = ["openbb-finviz"] -government_us = ["openbb-government-us"] -nasdaq = ["openbb-nasdaq"] -quantitative = ["openbb-quantitative"] -seeking_alpha = ["openbb-seeking-alpha"] -stockgrid = ["openbb-stockgrid"] -technical = ["openbb-technical"] -tmx = ["openbb-tmx"] -wsj = ["openbb-wsj"] - - -all = [ - "openbb-alpha-vantage", - "openbb-biztoc", - "openbb-cboe", - "openbb-charting", - "openbb-ecb", - "openbb-econometrics", - "openbb-finra", - "openbb-finviz", - "openbb-government-us", - "openbb-nasdaq", - "openbb-quantitative", - "openbb-seeking-alpha", - "openbb-stockgrid", - "openbb-technical", - "openbb-tmx", - "openbb-wsj", -] +alpha_vantage = [ "openbb-alpha-vantage",] +biztoc = [ "openbb-biztoc",] +cboe = [ "openbb-cboe",] +charting = [ "openbb-charting",] +ecb = [ "openbb-ecb",] +econometrics = [ "openbb-econometrics",] +finra = [ "openbb-finra",] +finviz = [ "openbb-finviz",] +government_us = [ "openbb-government-us",] +nasdaq = [ "openbb-nasdaq",] +quantitative = [ "openbb-quantitative",] +seeking_alpha = [ "openbb-seeking-alpha",] +stockgrid = [ "openbb-stockgrid",] +technical = [ "openbb-technical",] +tmx = [ "openbb-tmx",] +wsj = [ "openbb-wsj",] +all = [ "openbb-alpha-vantage", "openbb-biztoc", "openbb-cboe", "openbb-charting", "openbb-ecb", "openbb-econometrics", "openbb-finra", "openbb-finviz", "openbb-government-us", "openbb-nasdaq", "openbb-quantitative", "openbb-seeking-alpha", "openbb-stockgrid", "openbb-technical", "openbb-tmx", "openbb-wsj",] -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +[tool.poetry.dependencies.openbb-core] +path = "./core" +develop = true + +[tool.poetry.dependencies.openbb-benzinga] +path = "./providers/benzinga" +develop = true + +[tool.poetry.dependencies.openbb-federal-reserve] +path = "./providers/federal_reserve" +develop = true + +[tool.poetry.dependencies.openbb-fmp] +path = "./providers/fmp" +develop = true + +[tool.poetry.dependencies.openbb-fred] +path = "./providers/fred" +develop = true + +[tool.poetry.dependencies.openbb-intrinio] +path = "./providers/intrinio" +develop = true + +[tool.poetry.dependencies.openbb-oecd] +path = "./providers/oecd" +develop = true + +[tool.poetry.dependencies.openbb-polygon] +path = "./providers/polygon" +develop = true + +[tool.poetry.dependencies.openbb-sec] +path = "./providers/sec" +develop = true + +[tool.poetry.dependencies.openbb-tiingo] +path = "./providers/tiingo" +develop = true + +[tool.poetry.dependencies.openbb-tradingeconomics] +path = "./providers/tradingeconomics" +develop = true + +[tool.poetry.dependencies.openbb-yfinance] +path = "./providers/yfinance" +develop = true + +[tool.poetry.dependencies.openbb-commodity] +path = "./extensions/commodity" +develop = true + +[tool.poetry.dependencies.openbb-crypto] +path = "./extensions/crypto" +develop = true + +[tool.poetry.dependencies.openbb-currency] +path = "./extensions/currency" +develop = true + +[tool.poetry.dependencies.openbb-derivatives] +path = "./extensions/derivatives" +develop = true + +[tool.poetry.dependencies.openbb-economy] +path = "./extensions/economy" +develop = true + +[tool.poetry.dependencies.openbb-equity] +path = "./extensions/equity" +develop = true + +[tool.poetry.dependencies.openbb-etf] +path = "./extensions/etf" +develop = true + +[tool.poetry.dependencies.openbb-fixedincome] +path = "./extensions/fixedincome" +develop = true + +[tool.poetry.dependencies.openbb-index] +path = "./extensions/index" +develop = true + +[tool.poetry.dependencies.openbb-news] +path = "./extensions/news" +develop = true + +[tool.poetry.dependencies.openbb-regulators] +path = "./extensions/regulators" +develop = true + +[tool.poetry.dependencies.openbb-alpha-vantage] +path = "./providers/alpha_vantage" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-biztoc] +path = "./providers/biztoc" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-cboe] +path = "./providers/cboe" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-ecb] +path = "./providers/ecb" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-finra] +path = "./providers/finra" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-finviz] +path = "./providers/finviz" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-government-us] +path = "./providers/government_us" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-nasdaq] +path = "./providers/nasdaq" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-seeking-alpha] +path = "./providers/seeking_alpha" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-stockgrid] +path = "./providers/stockgrid" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-tmx] +version = "^1.0.0" +optional = true + +[tool.poetry.dependencies.openbb-wsj] +path = "./providers/wsj" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-charting] +path = "./obbject_extensions/charting" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-econometrics] +path = "./extensions/econometrics" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-quantitative] +path = "./extensions/quantitative" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-technical] +path = "./extensions/technical" +optional = true +develop = true + +[tool.poetry.dependencies.openbb-devtools] +path = "./extensions/devtools" +develop = true + +[tool.poetry.dependencies.openbb_tmx] +path = "./providers/tmx" +optional = true +develop = true From 378cd05aeed2cbacaf57b191c87e4be1c268b39a Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 13:14:10 +0000 Subject: [PATCH 023/133] undo toml change --- openbb_platform/pyproject.toml | 288 ++++++++++----------------------- 1 file changed, 85 insertions(+), 203 deletions(-) diff --git a/openbb_platform/pyproject.toml b/openbb_platform/pyproject.toml index 0c13e0067f80..1c40190bae58 100644 --- a/openbb_platform/pyproject.toml +++ b/openbb_platform/pyproject.toml @@ -1,214 +1,96 @@ -[build-system] -requires = [ "poetry-core",] -build-backend = "poetry.core.masonry.api" - [tool.poetry] name = "openbb" version = "4.1.4" description = "OpenBB" -authors = [ "OpenBB Team ",] +authors = ["OpenBB Team "] readme = "README.md" -[[tool.poetry.packages]] -include = "openbb" +packages = [{ include = "openbb" }] [tool.poetry.dependencies] python = ">=3.8,<3.12" +openbb-core = "^1.1.2" + +openbb-benzinga = "^1.1.2" +openbb-federal-reserve = "^1.1.2" +openbb-fmp = "^1.1.2" +openbb-fred = "^1.1.2" +openbb-intrinio = "^1.1.2" +openbb-oecd = "^1.1.2" +openbb-polygon = "^1.1.2" +openbb-sec = "^1.1.2" +openbb-tiingo = "^1.1.2" +openbb-tradingeconomics = "^1.1.2" +openbb-yfinance = "^1.1.2" + +openbb-commodity = "^1.0.0" +openbb-crypto = "^1.1.2" +openbb-currency = "^1.1.2" +openbb-derivatives = "^1.1.2" +openbb-economy = "^1.1.2" +openbb-equity = "^1.1.2" +openbb-etf = "^1.1.2" +openbb-fixedincome = "^1.1.2" +openbb-index = "^1.1.2" +openbb-news = "^1.1.2" +openbb-regulators = "^1.1.2" + +# Community dependencies +openbb-alpha-vantage = { version = "^1.1.2", optional = true } +openbb-biztoc = { version = "^1.1.2", optional = true } +openbb-cboe = { version = "^1.1.2", optional = true } +openbb-ecb = { version = "^1.1.2", optional = true } +openbb-finra = { version = "^1.1.2", optional = true } +openbb-finviz = { version = "^1.0.1", optional = true } +openbb-government-us = { version = "^1.1.2", optional = true } +openbb-nasdaq = { version = "^1.1.3", optional = true } +openbb-seeking-alpha = { version = "^1.1.2", optional = true } +openbb-stockgrid = { version = "^1.1.2", optional = true } +openbb-tmx = { version = "^1.0.0", optional = true } +openbb-wsj = { version = "^1.1.2", optional = true } + +openbb-charting = { version = "^2.0.0", optional = true } +openbb-econometrics = { version = "^1.1.2", optional = true } +openbb-quantitative = { version = "^1.1.2", optional = true } +openbb-technical = { version = "^1.1.3", optional = true } [tool.poetry.extras] -alpha_vantage = [ "openbb-alpha-vantage",] -biztoc = [ "openbb-biztoc",] -cboe = [ "openbb-cboe",] -charting = [ "openbb-charting",] -ecb = [ "openbb-ecb",] -econometrics = [ "openbb-econometrics",] -finra = [ "openbb-finra",] -finviz = [ "openbb-finviz",] -government_us = [ "openbb-government-us",] -nasdaq = [ "openbb-nasdaq",] -quantitative = [ "openbb-quantitative",] -seeking_alpha = [ "openbb-seeking-alpha",] -stockgrid = [ "openbb-stockgrid",] -technical = [ "openbb-technical",] -tmx = [ "openbb-tmx",] -wsj = [ "openbb-wsj",] -all = [ "openbb-alpha-vantage", "openbb-biztoc", "openbb-cboe", "openbb-charting", "openbb-ecb", "openbb-econometrics", "openbb-finra", "openbb-finviz", "openbb-government-us", "openbb-nasdaq", "openbb-quantitative", "openbb-seeking-alpha", "openbb-stockgrid", "openbb-technical", "openbb-tmx", "openbb-wsj",] - -[tool.poetry.dependencies.openbb-core] -path = "./core" -develop = true - -[tool.poetry.dependencies.openbb-benzinga] -path = "./providers/benzinga" -develop = true - -[tool.poetry.dependencies.openbb-federal-reserve] -path = "./providers/federal_reserve" -develop = true - -[tool.poetry.dependencies.openbb-fmp] -path = "./providers/fmp" -develop = true - -[tool.poetry.dependencies.openbb-fred] -path = "./providers/fred" -develop = true - -[tool.poetry.dependencies.openbb-intrinio] -path = "./providers/intrinio" -develop = true - -[tool.poetry.dependencies.openbb-oecd] -path = "./providers/oecd" -develop = true - -[tool.poetry.dependencies.openbb-polygon] -path = "./providers/polygon" -develop = true - -[tool.poetry.dependencies.openbb-sec] -path = "./providers/sec" -develop = true - -[tool.poetry.dependencies.openbb-tiingo] -path = "./providers/tiingo" -develop = true - -[tool.poetry.dependencies.openbb-tradingeconomics] -path = "./providers/tradingeconomics" -develop = true - -[tool.poetry.dependencies.openbb-yfinance] -path = "./providers/yfinance" -develop = true - -[tool.poetry.dependencies.openbb-commodity] -path = "./extensions/commodity" -develop = true - -[tool.poetry.dependencies.openbb-crypto] -path = "./extensions/crypto" -develop = true - -[tool.poetry.dependencies.openbb-currency] -path = "./extensions/currency" -develop = true - -[tool.poetry.dependencies.openbb-derivatives] -path = "./extensions/derivatives" -develop = true - -[tool.poetry.dependencies.openbb-economy] -path = "./extensions/economy" -develop = true - -[tool.poetry.dependencies.openbb-equity] -path = "./extensions/equity" -develop = true - -[tool.poetry.dependencies.openbb-etf] -path = "./extensions/etf" -develop = true - -[tool.poetry.dependencies.openbb-fixedincome] -path = "./extensions/fixedincome" -develop = true +alpha_vantage = ["openbb-alpha-vantage"] +biztoc = ["openbb-biztoc"] +cboe = ["openbb-cboe"] +charting = ["openbb-charting"] +ecb = ["openbb-ecb"] +econometrics = ["openbb-econometrics"] +finra = ["openbb-finra"] +finviz = ["openbb-finviz"] +government_us = ["openbb-government-us"] +nasdaq = ["openbb-nasdaq"] +quantitative = ["openbb-quantitative"] +seeking_alpha = ["openbb-seeking-alpha"] +stockgrid = ["openbb-stockgrid"] +technical = ["openbb-technical"] +tmx = ["openbb-tmx"] +wsj = ["openbb-wsj"] + + +all = [ + "openbb-alpha-vantage", + "openbb-biztoc", + "openbb-cboe", + "openbb-charting", + "openbb-ecb", + "openbb-econometrics", + "openbb-finra", + "openbb-finviz", + "openbb-government-us", + "openbb-nasdaq", + "openbb-quantitative", + "openbb-seeking-alpha", + "openbb-stockgrid", + "openbb-technical", + "openbb-tmx", + "openbb-wsj", +] -[tool.poetry.dependencies.openbb-index] -path = "./extensions/index" -develop = true - -[tool.poetry.dependencies.openbb-news] -path = "./extensions/news" -develop = true - -[tool.poetry.dependencies.openbb-regulators] -path = "./extensions/regulators" -develop = true - -[tool.poetry.dependencies.openbb-alpha-vantage] -path = "./providers/alpha_vantage" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-biztoc] -path = "./providers/biztoc" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-cboe] -path = "./providers/cboe" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-ecb] -path = "./providers/ecb" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-finra] -path = "./providers/finra" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-finviz] -path = "./providers/finviz" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-government-us] -path = "./providers/government_us" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-nasdaq] -path = "./providers/nasdaq" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-seeking-alpha] -path = "./providers/seeking_alpha" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-stockgrid] -path = "./providers/stockgrid" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-tmx] -version = "^1.0.0" -optional = true - -[tool.poetry.dependencies.openbb-wsj] -path = "./providers/wsj" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-charting] -path = "./obbject_extensions/charting" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-econometrics] -path = "./extensions/econometrics" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-quantitative] -path = "./extensions/quantitative" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-technical] -path = "./extensions/technical" -optional = true -develop = true - -[tool.poetry.dependencies.openbb-devtools] -path = "./extensions/devtools" -develop = true - -[tool.poetry.dependencies.openbb_tmx] -path = "./providers/tmx" -optional = true -develop = true +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" From ddbb77b4e754ddeb429e03c5e1e16a9251027e67 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 13:49:26 +0000 Subject: [PATCH 024/133] add comment --- openbb_platform/core/openbb_core/app/model/example.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index b843f6c5801b..544a60f9cbc6 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -18,6 +18,8 @@ class Example(BaseModel): @classmethod def validate_fields(cls, values) -> dict: """Validate parameters and code based on scope.""" + # We could have used pydantic discriminators instead, but makes the code more + # complex. We can revisit this in the future. scope = values.get("scope", "") parameters = values.get("parameters") code = values.get("code") From 4fbe369595651f085f8dc41cac7bd1e028066aa0 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 14:18:45 +0000 Subject: [PATCH 025/133] oop --- .../core/openbb_core/app/model/__init__.py | 2 +- .../core/openbb_core/app/model/example.py | 78 +++++++++--------- .../core/openbb_core/app/router.py | 4 +- .../openbb_core/app/static/package_builder.py | 6 +- .../openbb_commodity/commodity_router.py | 6 +- .../crypto/openbb_crypto/crypto_router.py | 6 +- .../openbb_crypto/price/price_router.py | 10 +-- .../openbb_currency/currency_router.py | 12 +-- .../openbb_currency/price/price_router.py | 8 +- .../futures/futures_router.py | 12 +-- .../options/options_router.py | 10 +-- .../econometrics_router.py | 23 ++---- .../economy/openbb_economy/economy_router.py | 40 +++++----- .../economy/openbb_economy/gdp/gdp_router.py | 8 +- .../openbb_equity/calendar/calendar_router.py | 20 ++--- .../openbb_equity/compare/compare_router.py | 10 +-- .../openbb_equity/darkpool/darkpool_router.py | 4 +- .../discovery/discovery_router.py | 24 +++--- .../equity/openbb_equity/equity_router.py | 10 +-- .../estimates/estimates_router.py | 10 +-- .../fundamental/fundamental_router.py | 60 +++++++------- .../ownership/ownership_router.py | 10 +-- .../openbb_equity/price/price_router.py | 10 +-- .../openbb_equity/shorts/shorts_router.py | 8 +- .../openbb_etf/discovery/discovery_router.py | 8 +- .../extensions/etf/openbb_etf/etf_router.py | 36 ++++----- .../corporate/corporate_router.py | 14 ++-- .../openbb_fixedincome/fixedincome_router.py | 4 +- .../government/government_router.py | 12 +-- .../openbb_fixedincome/rate/rate_router.py | 20 +++-- .../spreads/spreads_router.py | 8 +- .../index/openbb_index/index_router.py | 18 ++--- .../index/openbb_index/price/price_router.py | 6 +- .../news/openbb_news/news_router.py | 24 +++--- .../performance/performance_router.py | 11 +-- .../quantitative_router.py | 8 +- .../rolling/rolling_router.py | 20 ++--- .../openbb_quantitative/stats/stats_router.py | 20 ++--- .../openbb_regulators/cftc/cftc_router.py | 10 +-- .../openbb_regulators/sec/sec_router.py | 17 ++-- .../openbb_technical/technical_router.py | 80 +++++++------------ 41 files changed, 330 insertions(+), 377 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/__init__.py b/openbb_platform/core/openbb_core/app/model/__init__.py index 83c01772f8e0..32578d28cf02 100644 --- a/openbb_platform/core/openbb_core/app/model/__init__.py +++ b/openbb_platform/core/openbb_core/app/model/__init__.py @@ -1,3 +1,3 @@ from .command_context import CommandContext -from .example import Example +from .example import Example, APIEx, PythonEx from .obbject import OBBject diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 544a60f9cbc6..3cff7f56e7b1 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,47 +1,40 @@ -from dataclasses import Field +from abc import abstractmethod from typing import Any, Dict, List, Literal, Optional -from pydantic import BaseModel, ConfigDict, model_validator +from pydantic import BaseModel, ConfigDict class Example(BaseModel): """Example model.""" - scope: Literal["api", "python"] = "api" + scope: str description: Optional[str] = None - parameters: Optional[Dict[str, Any]] = None - code: Optional[List[str]] = None model_config = ConfigDict(validate_assignment=True) - @model_validator(mode="before") - @classmethod - def validate_fields(cls, values) -> dict: - """Validate parameters and code based on scope.""" - # We could have used pydantic discriminators instead, but makes the code more - # complex. We can revisit this in the future. - scope = values.get("scope", "") - parameters = values.get("parameters") - code = values.get("code") + @abstractmethod + def to_python(self, **kwargs) -> str: + """Return a Python code representation of the example.""" + - if scope == "api" and not parameters: - raise ValueError("Parameters are required for API examples.") - if scope == "python" and not code: - raise ValueError("Code is required for Python examples.") +class APIEx(Example): + """API Example model.""" - return values + scope: Literal["api"] = "api" + parameters: Dict[str, Any] @property def provider(self) -> Optional[str]: """Return the provider from the parameters.""" return self.parameters.get("provider") if self.parameters else None - def to_python( - self, func_name: str, func_params: Dict[str, Field], indentation: str = "" - ) -> str: + def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" + indentation = kwargs.get("indentation", "") + func_name = kwargs.get("func_name", "") + func_params = kwargs.get("func_params", {}) eg = "" - if self.scope == "api" and self.parameters is not None: + if self.parameters is not None: if self.description: eg += f"{indentation}>>> # {self.description}\n" eg += f"{indentation}>>> obb{func_name}(" @@ -60,21 +53,34 @@ def to_python( eg += f"{k}='{v}', " eg = indentation + eg.strip(", ") + ")\n" - elif self.scope == "python" and self.code is not None: + return eg + + +class PythonEx(Example): + """Python Example model.""" + + scope: Literal["python"] = "python" + code: List[str] + + def to_python(self, **kwargs) -> str: + """Return a Python code representation of the example.""" + indentation = kwargs.get("indentation", "") + eg = "" + if self.code is not None: for line in self.code: # pylint: disable=not-an-iterable eg += f"{indentation}>>> {line}\n" return eg - @staticmethod - def filter_list( - examples: List["Example"], - providers: List[str], - ) -> List["Example"]: - """Filter list of examples.""" - return [ - e - for e in examples - if (e.scope == "api" and (not e.provider or e.provider in providers)) - or e.scope != "api" - ] + +def filter_list( + examples: List[Example], + providers: List[str], +) -> List[Example]: + """Filter list of examples.""" + return [ + e + for e in examples + if (isinstance(e, APIEx) and (not e.provider or e.provider in providers)) + or e.scope != "api" + ] diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index 1a8a46423332..fea92f3aaad2 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -28,7 +28,7 @@ from openbb_core.app.extension_loader import ExtensionLoader from openbb_core.app.model.abstract.warning import OpenBBWarning from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import Example +from openbb_core.app.model.example import filter_list from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -239,7 +239,7 @@ def command( kwargs["response_model_exclude_unset"] = True kwargs["openapi_extra"] = kwargs.get("openapi_extra", {}) kwargs["openapi_extra"]["model"] = model - kwargs["openapi_extra"]["examples"] = None or Example.filter_list( + kwargs["openapi_extra"]["examples"] = None or filter_list( examples=kwargs.pop("examples", []), providers=ProviderInterface().available_providers, ) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index eecf18f2adad..8196082d6df5 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -875,7 +875,11 @@ def append_examples( doc += f"{indentation}>>> from openbb import obb\n" for e in examples: - doc += e.to_python(func_name, func_params, indentation) + doc += e.to_python( + func_name=func_name, + func_params=func_params, + indentation=indentation, + ) return doc return "" diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index c3ad31e4c30c..93aa99c2bf29 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -1,6 +1,6 @@ """The Commodity router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -17,8 +17,8 @@ @router.command( model="LbmaFixing", examples=[ - Example(parameters={"asset": "gold"}), - Example( + APIEx(parameters={"asset": "gold"}), + APIEx( parameters={ "asset": "silver", "start_date": "2023-01-01", diff --git a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py index 23ef8fae2929..4ef43a7a04e2 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py @@ -1,6 +1,6 @@ """Crypto Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -19,8 +19,8 @@ @router.command( model="CryptoSearch", examples=[ - Example(parameters={}), - Example(parameters={"query": "BTCUSD"}), + APIEx(parameters={}), + APIEx(parameters={"query": "BTCUSD"}), ], ) async def search( diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index 1915513d3bff..08ad2b724a06 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -1,7 +1,7 @@ # pylint: disable=W0613:unused-argument """Crypto Price Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -17,22 +17,22 @@ @router.command( model="CryptoHistorical", examples=[ - Example(parameters={"symbol": "BTCUSD"}), - Example( + APIEx(parameters={"symbol": "BTCUSD"}), + APIEx( parameters={ "symbol": "BTCUSD", "start_date": "2024-01-01", "end_date": "2024-01-31", }, ), - Example( + APIEx( parameters={ "symbol": "BTCUSD,ETHUSD", "start_date": "2024-01-01", "end_date": "2024-01-31", }, ), - Example( + APIEx( parameters={ "symbol": "ETH-USD", "provider": "yfinance", diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index 51408f588c4b..2c9d91f5e702 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -1,6 +1,6 @@ """The Currency router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -19,16 +19,16 @@ @router.command( model="CurrencyPairs", examples=[ - Example(parameters={}), - Example( + APIEx(parameters={}), + APIEx( description="Search for 'EURUSD' currency pair using 'polygon' as provider.", parameters={"provider": "polygon", "symbol": "EURUSD"}, ), - Example( + APIEx( description="Search for actively traded currency pairs on the queried date using 'polygon' as provider.", parameters={"provider": "polygon", "date": "2024-01-02", "active": True}, ), - Example( + APIEx( description="Search for terms using 'polygon' as provider.", parameters={"provider": "polygon", "search": "Euro zone"}, ), @@ -55,7 +55,7 @@ async def search( @router.command( model="CurrencyReferenceRates", - examples=[Example(parameters={})], + examples=[APIEx(parameters={})], ) async def reference_rates( cc: CommandContext, diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index 568327875c96..14971cc6a97e 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -1,7 +1,7 @@ """Price router for Currency.""" # pylint: disable=unused-argument -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -17,8 +17,8 @@ @router.command( model="CurrencyHistorical", examples=[ - Example(parameters={"symbol": "EURUSD"}), - Example( + APIEx(parameters={"symbol": "EURUSD"}), + APIEx( description="Filter historical data with specific start and end date.", parameters={ "symbol": "EURUSD", @@ -26,7 +26,7 @@ "end_date": "2023-12-31", }, ), - Example( + APIEx( description="Get data with different granularity.", parameters={"symbol": "EURUSD", "provider": "polygon", "interval": "15m"}, ), diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index 8b5468283578..c719067d62cd 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -1,6 +1,6 @@ """Futures Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,12 +16,12 @@ @router.command( model="FuturesHistorical", examples=[ - Example(parameters={"symbol": "ES"}), - Example( + APIEx(parameters={"symbol": "ES"}), + APIEx( description="Enter multiple symbols.", parameters={"symbol": "ES,NQ", "provider": "yfinance"}, ), - Example( + APIEx( description='Enter expiration dates as "YYYY-MM".', parameters={ "symbol": "ES", @@ -44,8 +44,8 @@ async def historical( @router.command( model="FuturesCurve", examples=[ - Example(parameters={"symbol": "NG", "provider": "yfinance"}), - Example( + APIEx(parameters={"symbol": "NG", "provider": "yfinance"}), + APIEx( description="Enter a date to get the term structure from a historical date.", parameters={"symbol": "NG", "provider": "yfinance", "date": "2023-01-01"}, ), diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index 31f645fcd8ee..f1320ab8837c 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -1,6 +1,6 @@ """Options Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -17,8 +17,8 @@ @router.command( model="OptionsChains", examples=[ - Example(parameters={"symbol": "AAPL", "provider": "intrinio"}), - Example( + APIEx(parameters={"symbol": "AAPL", "provider": "intrinio"}), + APIEx( description='Use the "date" parameter to get the end-of-day-data for a specific date, where supported.', parameters={"symbol": "AAPL", "date": "2023-01-25", "provider": "intrinio"}, ), @@ -37,8 +37,8 @@ async def chains( @router.command( model="OptionsUnusual", examples=[ - Example(parameters={}), - Example( + APIEx(parameters={}), + APIEx( description="Use the 'symbol' parameter to get the most recent activity for a specific symbol.", parameters={"symbol": "TSLA"}, ), diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 2453c3109650..b21db0387f98 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -15,7 +15,7 @@ PooledOLS, RandomEffects, ) -from openbb_core.app.model import Example, OBBject +from openbb_core.app.model import PythonEx, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import basemodel_to_df, get_target_column, get_target_columns from openbb_core.provider.abstract.data import Data @@ -68,8 +68,7 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: methods=["POST"], include_in_schema=False, examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.ols_regression(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', @@ -113,8 +112,7 @@ def ols_regression( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', @@ -191,8 +189,7 @@ def ols_regression_summary( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', @@ -238,8 +235,7 @@ def autocorrelation( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', @@ -298,8 +294,7 @@ def residual_autocorrelation( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.cointegration(data=stock_data, columns=["open", "close"])', @@ -362,8 +357,7 @@ def cointegration( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.causality(data=stock_data, y_column="close", x_column="open")', @@ -424,8 +418,7 @@ def causality( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.unit_root(data=stock_data, column="close")', diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 0a58c3cbf1da..371eb178d2c3 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -1,6 +1,6 @@ """Economy Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -20,14 +20,14 @@ @router.command( model="EconomicCalendar", examples=[ - Example( + APIEx( parameters={ "provider": "fmp", "start_date": "2020-03-01", "end_date": "2020-03-31", } ), - Example( + APIEx( description="By default, the calendar will be forward-looking.", parameters={"provider": "nasdaq"}, ), @@ -46,8 +46,8 @@ async def calendar( @router.command( model="ConsumerPriceIndex", examples=[ - Example(parameters={"country": "japan,china,turkey"}), - Example( + APIEx(parameters={"country": "japan,china,turkey"}), + APIEx( description="Use the `units` parameter to define the reference period for the change in values.", parameters={ "country": "united_states,united_kingdom", @@ -68,7 +68,7 @@ async def cpi( @router.command( model="RiskPremium", - examples=[Example(parameters={})], + examples=[APIEx(parameters={})], ) async def risk_premium( cc: CommandContext, @@ -83,8 +83,8 @@ async def risk_premium( @router.command( model="BalanceOfPayments", examples=[ - Example(parameters={"report_type": "summary"}), - Example( + APIEx(parameters={"report_type": "summary"}), + APIEx( description="The `country` parameter will override the `report_type`.", parameters={"country": "united_states", "provider": "ecb"}, ), @@ -100,7 +100,7 @@ async def balance_of_payments( return await OBBject.from_query(Query(**locals())) -@router.command(model="FredSearch", examples=[Example(parameters={})]) +@router.command(model="FredSearch", examples=[APIEx(parameters={})]) async def fred_search( cc: CommandContext, provider_choices: ProviderChoices, @@ -118,12 +118,12 @@ async def fred_search( @router.command( model="FredSeries", examples=[ - Example(parameters={"series_id": "NFCI"}), - Example( + APIEx(parameters={"series_id": "NFCI"}), + APIEx( description="Multiple series can be passed in as a list.", parameters={"series_id": "NFCI,STLFSI4"}, ), - Example( + APIEx( description="Use the `transform` parameter to transform the data as change, log, or percent change.", parameters={"series_id": "CBBTCUSD", "transform": "pc1"}, ), @@ -141,7 +141,7 @@ async def fred_series( @router.command( model="MoneyMeasures", - examples=[Example(parameters={"adjusted": False})], + examples=[APIEx(parameters={"adjusted": False})], ) async def money_measures( cc: CommandContext, @@ -156,8 +156,8 @@ async def money_measures( @router.command( model="Unemployment", examples=[ - Example(parameters={"country": "all", "frequency": "quarterly"}), - Example( + APIEx(parameters={"country": "all", "frequency": "quarterly"}), + APIEx( description="Demographics for the statistics are selected with the `age` and `sex` parameters.", parameters={"country": "all", "frequency": "quarterly", "age": "25-54"}, ), @@ -175,7 +175,7 @@ async def unemployment( @router.command( model="CLI", - examples=[Example(parameters={"country": "all"})], + examples=[APIEx(parameters={"country": "all"})], ) async def composite_leading_indicator( cc: CommandContext, @@ -192,7 +192,7 @@ async def composite_leading_indicator( @router.command( model="STIR", - examples=[Example(parameters={"country": "all", "frequency": "quarterly"})], + examples=[APIEx(parameters={"country": "all", "frequency": "quarterly"})], ) async def short_term_interest_rate( cc: CommandContext, @@ -212,7 +212,7 @@ async def short_term_interest_rate( @router.command( model="LTIR", - examples=[Example(parameters={"country": "all", "frequency": "quarterly"})], + examples=[APIEx(parameters={"country": "all", "frequency": "quarterly"})], ) async def long_term_interest_rate( cc: CommandContext, @@ -236,11 +236,11 @@ async def long_term_interest_rate( @router.command( model="FredRegional", examples=[ - Example( + APIEx( description="With no date, the most recent report is returned.", parameters={"series_id": "NYICLAIMS"}, ), - Example( + APIEx( description="With a date, time series data is returned.", parameters={"series_id": "NYICLAIMS", "start_date": "2021-01-01"}, ), diff --git a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py index 6623d09bf15a..ab620b590e63 100644 --- a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py @@ -1,6 +1,6 @@ """Economy GDP Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,7 +16,7 @@ @router.command( model="GdpForecast", - examples=[Example(parameters={"period": "annual", "type": "real"})], + examples=[APIEx(parameters={"period": "annual", "type": "real"})], ) async def forecast( cc: CommandContext, @@ -30,7 +30,7 @@ async def forecast( @router.command( model="GdpNominal", - examples=[Example(parameters={"units": "usd"})], + examples=[APIEx(parameters={"units": "usd"})], ) async def nominal( cc: CommandContext, @@ -44,7 +44,7 @@ async def nominal( @router.command( model="GdpReal", - examples=[Example(parameters={"units": "yoy"})], + examples=[APIEx(parameters={"units": "yoy"})], ) async def real( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py index a4c539869892..23f3feb2bc84 100644 --- a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py @@ -1,6 +1,6 @@ """Calendar Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -17,9 +17,9 @@ @router.command( model="CalendarIpo", examples=[ - Example(parameters={"limit": 100}), - Example(description="Get all IPOs available.", parameters={}), - Example( + APIEx(parameters={"limit": 100}), + APIEx(description="Get all IPOs available.", parameters={}), + APIEx( description="Get IPOs for specific dates.", parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, ), @@ -38,8 +38,8 @@ async def ipo( @router.command( model="CalendarDividend", examples=[ - Example(parameters={}), - Example( + APIEx(parameters={}), + APIEx( description="Get dividend calendar for specific dates.", parameters={ "start_date": "2024-02-01", @@ -61,8 +61,8 @@ async def dividend( @router.command( model="CalendarSplits", examples=[ - Example(parameters={}), - Example( + APIEx(parameters={}), + APIEx( description="Get stock splits calendar for specific dates.", parameters={ "start_date": "2024-02-01", @@ -84,8 +84,8 @@ async def splits( @router.command( model="CalendarEarnings", examples=[ - Example(parameters={}), - Example( + APIEx(parameters={}), + APIEx( description="Get earnings calendar for specific dates.", parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, ), diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py index 4686e7218fd0..9cdd5d2d5554 100644 --- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py @@ -1,7 +1,7 @@ # pylint: disable=W0613:unused-argument """Comparison Analysis Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -15,7 +15,7 @@ @router.command( model="EquityPeers", - examples=[Example(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL"})], ) async def peers( cc: CommandContext, @@ -33,15 +33,15 @@ async def peers( @router.command( model="CompareGroups", examples=[ - Example( + APIEx( description="Group by sector and analyze valuation.", parameters={"group": "sector", "metric": "valuation"}, ), - Example( + APIEx( description="Group by industry and analyze performance.", parameters={"group": "industry", "metric": "performance"}, ), - Example( + APIEx( description="Group by country and analyze valuation.", parameters={"group": "country", "metric": "valuation"}, ), diff --git a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py index 3a5e729edea3..fb7a93237ac6 100644 --- a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py @@ -1,6 +1,6 @@ """Dark Pool Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -17,7 +17,7 @@ @router.command( model="OTCAggregate", examples=[ - Example( + APIEx( description="Get OTC data for a symbol", parameters={"symbol": "AAPL"}, ), diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index 071be9480e66..7f7bbbe11073 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -1,7 +1,7 @@ """Disc router for Equities.""" # pylint: disable=unused-argument -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -13,7 +13,7 @@ router = Router(prefix="/discovery") -@router.command(model="EquityGainers", examples=[Example(parameters={"sort": "desc"})]) +@router.command(model="EquityGainers", examples=[APIEx(parameters={"sort": "desc"})]) async def gainers( cc: CommandContext, provider_choices: ProviderChoices, @@ -24,7 +24,7 @@ async def gainers( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityLosers", examples=[Example(parameters={"sort": "desc"})]) +@router.command(model="EquityLosers", examples=[APIEx(parameters={"sort": "desc"})]) async def losers( cc: CommandContext, provider_choices: ProviderChoices, @@ -35,7 +35,7 @@ async def losers( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityActive", examples=[Example(parameters={"sort": "desc"})]) +@router.command(model="EquityActive", examples=[APIEx(parameters={"sort": "desc"})]) async def active( cc: CommandContext, provider_choices: ProviderChoices, @@ -48,7 +48,7 @@ async def active( @router.command( model="EquityUndervaluedLargeCaps", - examples=[Example(parameters={"sort": "desc"})], + examples=[APIEx(parameters={"sort": "desc"})], ) async def undervalued_large_caps( cc: CommandContext, @@ -61,7 +61,7 @@ async def undervalued_large_caps( @router.command( - model="EquityUndervaluedGrowth", examples=[Example(parameters={"sort": "desc"})] + model="EquityUndervaluedGrowth", examples=[APIEx(parameters={"sort": "desc"})] ) async def undervalued_growth( cc: CommandContext, @@ -75,7 +75,7 @@ async def undervalued_growth( @router.command( model="EquityAggressiveSmallCaps", - examples=[Example(parameters={"sort": "desc"})], + examples=[APIEx(parameters={"sort": "desc"})], ) async def aggressive_small_caps( cc: CommandContext, @@ -88,7 +88,7 @@ async def aggressive_small_caps( @router.command( - model="GrowthTechEquities", examples=[Example(parameters={"sort": "desc"})] + model="GrowthTechEquities", examples=[APIEx(parameters={"sort": "desc"})] ) async def growth_tech( cc: CommandContext, @@ -100,7 +100,7 @@ async def growth_tech( return await OBBject.from_query(Query(**locals())) -@router.command(model="TopRetail", examples=[Example(parameters={"sort": "desc"})]) +@router.command(model="TopRetail", examples=[APIEx(parameters={"sort": "desc"})]) async def top_retail( cc: CommandContext, provider_choices: ProviderChoices, @@ -115,7 +115,7 @@ async def top_retail( @router.command( - model="UpcomingReleaseDays", examples=[Example(parameters={"sort": "desc"})] + model="UpcomingReleaseDays", examples=[APIEx(parameters={"sort": "desc"})] ) async def upcoming_release_days( cc: CommandContext, @@ -130,8 +130,8 @@ async def upcoming_release_days( @router.command( model="DiscoveryFilings", examples=[ - Example(parameters={"limit": 100}), - Example( + APIEx(parameters={"limit": 100}), + APIEx( description="Get filings for the year 2023, limited to 100 results", parameters={ "start_date": "2023-01-01", diff --git a/openbb_platform/extensions/equity/openbb_equity/equity_router.py b/openbb_platform/extensions/equity/openbb_equity/equity_router.py index f146add6024d..65eb609b20e9 100644 --- a/openbb_platform/extensions/equity/openbb_equity/equity_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/equity_router.py @@ -1,6 +1,6 @@ """Equity Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -36,7 +36,7 @@ @router.command( model="EquitySearch", examples=[ - Example(parameters={"query": "AAPL", "is_symbol": False, "use_cache": True}) + APIEx(parameters={"query": "AAPL", "is_symbol": False, "use_cache": True}) ], ) async def search( @@ -49,7 +49,7 @@ async def search( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityScreener", examples=[Example(parameters={})]) +@router.command(model="EquityScreener", examples=[APIEx(parameters={})]) async def screener( cc: CommandContext, provider_choices: ProviderChoices, @@ -61,7 +61,7 @@ async def screener( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityInfo", examples=[Example(parameters={"symbol": "AAPL"})]) +@router.command(model="EquityInfo", examples=[APIEx(parameters={"symbol": "AAPL"})]) async def profile( cc: CommandContext, provider_choices: ProviderChoices, @@ -72,7 +72,7 @@ async def profile( return await OBBject.from_query(Query(**locals())) -@router.command(model="MarketSnapshots", examples=[Example(parameters={})]) +@router.command(model="MarketSnapshots", examples=[APIEx(parameters={})]) async def market_snapshots( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index c61e7330b448..31bfab24bd45 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -1,6 +1,6 @@ """Estimates Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -17,7 +17,7 @@ @router.command( model="PriceTarget", examples=[ - Example( + APIEx( parameters={ "start_date": "2020-01-01", "end_date": "2024-02-16", @@ -41,7 +41,7 @@ async def price_target( @router.command( model="AnalystEstimates", - examples=[Example(parameters={"symbol": "AAPL", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def historical( cc: CommandContext, @@ -55,7 +55,7 @@ async def historical( @router.command( model="PriceTargetConsensus", - examples=[Example(parameters={"symbol": "AAPL,MSFT", "provider": "yfinance"})], + examples=[APIEx(parameters={"symbol": "AAPL,MSFT", "provider": "yfinance"})], ) async def consensus( cc: CommandContext, @@ -69,7 +69,7 @@ async def consensus( @router.command( model="AnalystSearch", - examples=[Example(parameters={"firm_name": "Wedbush", "provider": "benzinga"})], + examples=[APIEx(parameters={"firm_name": "Wedbush", "provider": "benzinga"})], ) async def analyst_search( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index 9dd4e5cd5f65..74355e20e074 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -2,7 +2,7 @@ """Fundamental Analysis Router.""" from openbb_core.app.deprecation import OpenBBDeprecationWarning -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,7 +16,7 @@ @router.command( model="EquityValuationMultiples", - examples=[Example(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL"})], ) async def multiples( cc: CommandContext, @@ -30,7 +30,7 @@ async def multiples( @router.command( model="BalanceSheet", - examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], + examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], ) async def balance( cc: CommandContext, @@ -44,7 +44,7 @@ async def balance( @router.command( model="BalanceSheetGrowth", - examples=[Example(parameters={"symbol": "AAPL", "limit": 10})], + examples=[APIEx(parameters={"symbol": "AAPL", "limit": 10})], ) async def balance_growth( cc: CommandContext, @@ -58,7 +58,7 @@ async def balance_growth( @router.command( model="CashFlowStatement", - examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], + examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], ) async def cash( cc: CommandContext, @@ -73,7 +73,7 @@ async def cash( @router.command( model="ReportedFinancials", examples=[ - Example( + APIEx( parameters={ "symbol": "AAPL", "period": "annual", @@ -81,11 +81,11 @@ async def cash( "limit": 100, } ), - Example( + APIEx( description="Get reported income statement", parameters={"symbol": "AAPL", "statement_type": "income"}, ), - Example( + APIEx( description="Get reported cash flow statement", parameters={"symbol": "AAPL", "statement_type": "cash"}, ), @@ -103,7 +103,7 @@ async def reported_financials( @router.command( model="CashFlowStatementGrowth", - examples=[Example(parameters={"symbol": "AAPL", "limit": 10})], + examples=[APIEx(parameters={"symbol": "AAPL", "limit": 10})], ) async def cash_growth( cc: CommandContext, @@ -116,7 +116,7 @@ async def cash_growth( @router.command( - model="HistoricalDividends", examples=[Example(parameters={"symbol": "AAPL"})] + model="HistoricalDividends", examples=[APIEx(parameters={"symbol": "AAPL"})] ) async def dividends( cc: CommandContext, @@ -128,9 +128,7 @@ async def dividends( return await OBBject.from_query(Query(**locals())) -@router.command( - model="HistoricalEps", examples=[Example(parameters={"symbol": "AAPL"})] -) +@router.command(model="HistoricalEps", examples=[APIEx(parameters={"symbol": "AAPL"})]) async def historical_eps( cc: CommandContext, provider_choices: ProviderChoices, @@ -142,7 +140,7 @@ async def historical_eps( @router.command( - model="HistoricalEmployees", examples=[Example(parameters={"symbol": "AAPL"})] + model="HistoricalEmployees", examples=[APIEx(parameters={"symbol": "AAPL"})] ) async def employee_count( cc: CommandContext, @@ -156,7 +154,7 @@ async def employee_count( @router.command( model="SearchAttributes", - examples=[Example(parameters={"query": "ebitda"})], + examples=[APIEx(parameters={"query": "ebitda"})], ) async def search_attributes( cc: CommandContext, @@ -170,7 +168,7 @@ async def search_attributes( @router.command( model="LatestAttributes", - examples=[Example(parameters={"tag": "ceo"})], + examples=[APIEx(parameters={"tag": "ceo"})], ) async def latest_attributes( cc: CommandContext, @@ -184,7 +182,7 @@ async def latest_attributes( @router.command( model="HistoricalAttributes", - examples=[Example(parameters={"tag": "ebitda"})], + examples=[APIEx(parameters={"tag": "ebitda"})], ) async def historical_attributes( cc: CommandContext, @@ -198,7 +196,7 @@ async def historical_attributes( @router.command( model="IncomeStatement", - examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], + examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], ) async def income( cc: CommandContext, @@ -212,7 +210,7 @@ async def income( @router.command( model="IncomeStatementGrowth", - examples=[Example(parameters={"symbol": "AAPL", "limit": 10, "period": "annual"})], + examples=[APIEx(parameters={"symbol": "AAPL", "limit": 10, "period": "annual"})], ) async def income_growth( cc: CommandContext, @@ -226,7 +224,7 @@ async def income_growth( @router.command( model="KeyMetrics", - examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 100})], + examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 100})], ) async def metrics( cc: CommandContext, @@ -238,9 +236,7 @@ async def metrics( return await OBBject.from_query(Query(**locals())) -@router.command( - model="KeyExecutives", examples=[Example(parameters={"symbol": "AAPL"})] -) +@router.command(model="KeyExecutives", examples=[APIEx(parameters={"symbol": "AAPL"})]) async def management( cc: CommandContext, provider_choices: ProviderChoices, @@ -252,7 +248,7 @@ async def management( @router.command( - model="ExecutiveCompensation", examples=[Example(parameters={"symbol": "AAPL"})] + model="ExecutiveCompensation", examples=[APIEx(parameters={"symbol": "AAPL"})] ) async def management_compensation( cc: CommandContext, @@ -272,7 +268,7 @@ async def management_compensation( since=(4, 1), expected_removal=(4, 3), ), - examples=[Example(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL"})], ) async def overview( cc: CommandContext, @@ -286,7 +282,7 @@ async def overview( @router.command( model="FinancialRatios", - examples=[Example(parameters={"symbol": "AAPL", "period": "annual", "limit": 12})], + examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 12})], ) async def ratios( cc: CommandContext, @@ -301,7 +297,7 @@ async def ratios( @router.command( model="RevenueGeographic", examples=[ - Example(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) + APIEx(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) ], ) async def revenue_per_geography( @@ -317,7 +313,7 @@ async def revenue_per_geography( @router.command( model="RevenueBusinessLine", examples=[ - Example(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) + APIEx(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) ], ) async def revenue_per_segment( @@ -330,7 +326,7 @@ async def revenue_per_segment( return await OBBject.from_query(Query(**locals())) -@router.command(model="CompanyFilings", examples=[Example(parameters={"limit": 100})]) +@router.command(model="CompanyFilings", examples=[APIEx(parameters={"limit": 100})]) async def filings( cc: CommandContext, provider_choices: ProviderChoices, @@ -347,7 +343,7 @@ async def filings( @router.command( - model="HistoricalSplits", examples=[Example(parameters={"symbol": "AAPL"})] + model="HistoricalSplits", examples=[APIEx(parameters={"symbol": "AAPL"})] ) async def historical_splits( cc: CommandContext, @@ -361,7 +357,7 @@ async def historical_splits( @router.command( model="EarningsCallTranscript", - examples=[Example(parameters={"symbol": "AAPL", "year": 2020})], + examples=[APIEx(parameters={"symbol": "AAPL", "year": 2020})], ) async def transcript( cc: CommandContext, @@ -375,7 +371,7 @@ async def transcript( @router.command( model="TrailingDividendYield", - examples=[Example(parameters={"symbol": "AAPL", "limit": 252})], + examples=[APIEx(parameters={"symbol": "AAPL", "limit": 252})], ) async def trailing_dividend_yield( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index 8a19e90d9325..6a1815c6d831 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -1,6 +1,6 @@ """Ownership Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,7 +16,7 @@ @router.command( model="EquityOwnership", - examples=[Example(parameters={"symbol": "AAPL", "page": 0})], + examples=[APIEx(parameters={"symbol": "AAPL", "page": 0})], ) async def major_holders( cc: CommandContext, @@ -30,7 +30,7 @@ async def major_holders( @router.command( model="InstitutionalOwnership", - examples=[Example(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL"})], ) async def institutional( cc: CommandContext, @@ -44,7 +44,7 @@ async def institutional( @router.command( model="InsiderTrading", - examples=[Example(parameters={"symbol": "AAPL", "limit": 500})], + examples=[APIEx(parameters={"symbol": "AAPL", "limit": 500})], ) async def insider_trading( cc: CommandContext, @@ -57,7 +57,7 @@ async def insider_trading( @router.command( - model="ShareStatistics", examples=[Example(parameters={"symbol": "AAPL"})] + model="ShareStatistics", examples=[APIEx(parameters={"symbol": "AAPL"})] ) async def share_statistics( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index 379d0cf51546..cb41cde7b27d 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -1,6 +1,6 @@ """Price Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -14,7 +14,7 @@ # pylint: disable=unused-argument -@router.command(model="EquityQuote", examples=[Example(parameters={"symbol": "AAPL"})]) +@router.command(model="EquityQuote", examples=[APIEx(parameters={"symbol": "AAPL"})]) async def quote( cc: CommandContext, provider_choices: ProviderChoices, @@ -25,7 +25,7 @@ async def quote( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityNBBO", examples=[Example(parameters={"symbol": "AAPL"})]) +@router.command(model="EquityNBBO", examples=[APIEx(parameters={"symbol": "AAPL"})]) async def nbbo( cc: CommandContext, provider_choices: ProviderChoices, @@ -38,7 +38,7 @@ async def nbbo( @router.command( model="EquityHistorical", - examples=[Example(parameters={"symbol": "AAPL", "interval": "1d"})], + examples=[APIEx(parameters={"symbol": "AAPL", "interval": "1d"})], ) async def historical( cc: CommandContext, @@ -51,7 +51,7 @@ async def historical( @router.command( - model="PricePerformance", examples=[Example(parameters={"symbol": "AAPL"})] + model="PricePerformance", examples=[APIEx(parameters={"symbol": "AAPL"})] ) async def performance( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index fce58c127382..990838a42643 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -1,6 +1,6 @@ """Shorts Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,7 +16,7 @@ @router.command( model="EquityFTD", - examples=[Example(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL"})], ) async def fails_to_deliver( cc: CommandContext, @@ -30,7 +30,7 @@ async def fails_to_deliver( @router.command( model="ShortVolume", - examples=[Example(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL"})], ) async def short_volume( cc: CommandContext, @@ -44,7 +44,7 @@ async def short_volume( @router.command( model="EquityShortInterest", - examples=[Example(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL"})], ) async def short_interest( cc: CommandContext, diff --git a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py index 1b1b66bf51bf..895384e1902a 100644 --- a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py @@ -1,6 +1,6 @@ """Disc router for ETFs.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -18,7 +18,7 @@ model="ETFGainers", operation_id="etf_gainers", examples=[ - Example(description="Get the top ETF gainers.", parameters={"provider": "wsj"}), + APIEx(description="Get the top ETF gainers.", parameters={"provider": "wsj"}), ], ) async def gainers( @@ -35,7 +35,7 @@ async def gainers( model="ETFLosers", operation_id="etf_losers", examples=[ - Example(description="Get the top ETF losers.", parameters={"provider": "wsj"}) + APIEx(description="Get the top ETF losers.", parameters={"provider": "wsj"}) ], ) async def losers( @@ -52,7 +52,7 @@ async def losers( model="ETFActive", operation_id="etf_active", examples=[ - Example(description="Get the most active ETFs.", parameters={"provider": "wsj"}) + APIEx(description="Get the most active ETFs.", parameters={"provider": "wsj"}) ], ) async def active( diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index 63e6020bb7c8..03d97209ae22 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -1,6 +1,6 @@ """ETF Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -20,11 +20,11 @@ @router.command( model="EtfSearch", examples=[ - Example( + APIEx( description="An empty query returns the full list of ETFs from the provider.", parameters={}, ), - Example( + APIEx( description="The query will return results from text-based fields containing the term.", parameters={"query": "commercial real estate", "provider": "fmp"}, ), @@ -47,9 +47,9 @@ async def search( model="EtfHistorical", operation_id="etf_historical", examples=[ - Example(parameters={"symbol": "SPY"}), - Example(parameters={"symbol": "SPY", "provider": "yfinance"}), - Example( + APIEx(parameters={"symbol": "SPY"}), + APIEx(parameters={"symbol": "SPY", "provider": "yfinance"}), + APIEx( description="This function accepts multiple tickers.", parameters={"symbol": "SPY,IWM,QQQ,DJIA", "provider": "yfinance"}, ), @@ -68,8 +68,8 @@ async def historical( @router.command( model="EtfInfo", examples=[ - Example(parameters={"symbol": "SPY", "provider": "fmp"}), - Example( + APIEx(parameters={"symbol": "SPY", "provider": "fmp"}), + APIEx( description="This function accepts multiple tickers.", parameters={"symbol": "SPY,IWM,QQQ,DJIA", "provider": "fmp"}, ), @@ -87,7 +87,7 @@ async def info( @router.command( model="EtfSectors", - examples=[Example(parameters={"symbol": "SPY", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "SPY", "provider": "fmp"})], ) async def sectors( cc: CommandContext, @@ -101,7 +101,7 @@ async def sectors( @router.command( model="EtfCountries", - examples=[Example(parameters={"symbol": "VT", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "VT", "provider": "fmp"})], ) async def countries( cc: CommandContext, @@ -115,7 +115,7 @@ async def countries( @router.command( model="PricePerformance", - examples=[Example(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"})], ) async def price_performance( cc: CommandContext, @@ -130,12 +130,12 @@ async def price_performance( @router.command( model="EtfHoldings", examples=[ - Example(parameters={"symbol": "XLK", "provider": "fmp"}), - Example( + APIEx(parameters={"symbol": "XLK", "provider": "fmp"}), + APIEx( description="Including a date (FMP, SEC) will return the holdings as per NPORT-P filings.", parameters={"symbol": "XLK", "date": "2022-03-31", "provider": "fmp"}, ), - Example( + APIEx( description="The same data can be returned from the SEC directly.", parameters={"symbol": "XLK", "date": "2022-03-31", "provider": "sec"}, ), @@ -153,7 +153,7 @@ async def holdings( @router.command( model="EtfHoldingsDate", - examples=[Example(parameters={"symbol": "XLK", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "XLK", "provider": "fmp"})], ) async def holdings_date( cc: CommandContext, @@ -167,7 +167,7 @@ async def holdings_date( @router.command( model="EtfHoldingsPerformance", - examples=[Example(parameters={"symbol": "XLK", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "XLK", "provider": "fmp"})], ) async def holdings_performance( cc: CommandContext, @@ -182,8 +182,8 @@ async def holdings_performance( @router.command( model="EtfEquityExposure", examples=[ - Example(parameters={"symbol": "MSFT", "provider": "fmp"}), - Example( + APIEx(parameters={"symbol": "MSFT", "provider": "fmp"}), + APIEx( description="This function accepts multiple tickers.", parameters={"symbol": "MSFT,AAPL", "provider": "fmp"}, ), diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index 99150618a5fe..b6a42d633104 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -1,6 +1,6 @@ """Fixed Income Corporate Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,7 +16,7 @@ @router.command( model="ICEBofA", - examples=[Example(parameters={"index_type": "yield_to_worst"})], + examples=[APIEx(parameters={"index_type": "yield_to_worst"})], ) async def ice_bofa( cc: CommandContext, @@ -37,7 +37,7 @@ async def ice_bofa( @router.command( model="MoodyCorporateBondIndex", - examples=[Example(parameters={"index_type": "baa"})], + examples=[APIEx(parameters={"index_type": "baa"})], ) async def moody( cc: CommandContext, @@ -57,7 +57,7 @@ async def moody( @router.command( model="HighQualityMarketCorporateBond", - examples=[Example(parameters={"yield_curve": "par"})], + examples=[APIEx(parameters={"yield_curve": "par"})], ) async def hqm( cc: CommandContext, @@ -77,7 +77,7 @@ async def hqm( @router.command( model="SpotRate", - examples=[Example(parameters={"maturity": [10, 20, 30, 50]})], + examples=[APIEx(parameters={"maturity": [10, 20, 30, 50]})], ) async def spot_rates( cc: CommandContext, @@ -97,7 +97,7 @@ async def spot_rates( @router.command( model="CommercialPaper", - examples=[Example(parameters={"maturity": "15d"})], + examples=[APIEx(parameters={"maturity": "15d"})], ) async def commercial_paper( cc: CommandContext, @@ -115,7 +115,7 @@ async def commercial_paper( return await OBBject.from_query(Query(**locals())) -@router.command(model="BondPrices", examples=[Example(parameters={})]) +@router.command(model="BondPrices", examples=[APIEx(parameters={})]) async def bond_prices( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py index 84f424d7f463..9521e049a3b6 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py @@ -2,7 +2,7 @@ # pylint: disable=W0613:unused-argument -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -25,7 +25,7 @@ @router.command( model="SOFR", - examples=[Example(parameters={"period": "overnight"})], + examples=[APIEx(parameters={"period": "overnight"})], ) async def sofr( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index 369800359bf2..263470e9985a 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -1,6 +1,6 @@ """Fixed Income Government Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,7 +16,7 @@ @router.command( model="USYieldCurve", - examples=[Example(parameters={"inflation_adjusted": True})], + examples=[APIEx(parameters={"inflation_adjusted": True})], ) async def us_yield_curve( cc: CommandContext, @@ -30,7 +30,7 @@ async def us_yield_curve( @router.command( model="EUYieldCurve", - examples=[Example(parameters={"yield_curve_type": "spot_rate"})], + examples=[APIEx(parameters={"yield_curve_type": "spot_rate"})], ) async def eu_yield_curve( cc: CommandContext, @@ -63,7 +63,7 @@ async def eu_yield_curve( @router.command( model="TreasuryRates", - examples=[Example(parameters={"provider": "federal_reserve"})], + examples=[APIEx(parameters={"provider": "federal_reserve"})], ) async def treasury_rates( cc: CommandContext, @@ -78,7 +78,7 @@ async def treasury_rates( @router.command( model="TreasuryAuctions", examples=[ - Example( + APIEx( parameters={ "security_type": "Bill", "start_date": "2022-01-01", @@ -99,7 +99,7 @@ async def treasury_auctions( @router.command( model="TreasuryPrices", - examples=[Example(parameters={"date": "2019-02-05"})], + examples=[APIEx(parameters={"date": "2019-02-05"})], ) async def treasury_prices( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index 2e21d8f9442c..3957980b19bb 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -1,6 +1,6 @@ """Fixed Income Rate Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,7 +16,7 @@ @router.command( model="AMERIBOR", - examples=[Example(parameters={"parameter": "30_day_ma"})], + examples=[APIEx(parameters={"parameter": "30_day_ma"})], ) async def ameribor( cc: CommandContext, @@ -35,7 +35,7 @@ async def ameribor( @router.command( model="SONIA", - examples=[Example(parameters={"parameter": "total_nominal_value"})], + examples=[APIEx(parameters={"parameter": "total_nominal_value"})], ) async def sonia( cc: CommandContext, @@ -54,7 +54,7 @@ async def sonia( @router.command( model="IORB", - examples=[Example(parameters={})], + examples=[APIEx(parameters={})], ) async def iorb( cc: CommandContext, @@ -73,7 +73,7 @@ async def iorb( @router.command( model="FEDFUNDS", - examples=[Example(parameters={"parameter": "daily", "provider": "fred"})], + examples=[APIEx(parameters={"parameter": "daily", "provider": "fred"})], ) async def effr( cc: CommandContext, @@ -92,7 +92,7 @@ async def effr( @router.command( model="PROJECTIONS", - examples=[Example(parameters={"long_run": True})], + examples=[APIEx(parameters={"long_run": True})], ) async def effr_forecast( cc: CommandContext, @@ -112,7 +112,7 @@ async def effr_forecast( @router.command( model="ESTR", - examples=[Example(parameters={"parameter": "number_of_active_banks"})], + examples=[APIEx(parameters={"parameter": "number_of_active_banks"})], ) async def estr( cc: CommandContext, @@ -132,7 +132,7 @@ async def estr( @router.command( model="EuropeanCentralBankInterestRates", - examples=[Example(parameters={"interest_rate_type": "refinancing"})], + examples=[APIEx(parameters={"interest_rate_type": "refinancing"})], ) async def ecb( cc: CommandContext, @@ -154,9 +154,7 @@ async def ecb( @router.command( model="DiscountWindowPrimaryCreditRate", - examples=[ - Example(parameters={"start_date": "2023-02-01", "end_date": "2023-05-01"}) - ], + examples=[APIEx(parameters={"start_date": "2023-02-01", "end_date": "2023-05-01"})], ) async def dpcredit( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py index f99948bcf757..10c1ca809076 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py @@ -1,6 +1,6 @@ """Fixed Income Corporate Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,7 +16,7 @@ @router.command( model="TreasuryConstantMaturity", - examples=[Example(parameters={"maturity": "2y"})], + examples=[APIEx(parameters={"maturity": "2y"})], ) async def tcm( cc: CommandContext, @@ -36,7 +36,7 @@ async def tcm( @router.command( model="SelectedTreasuryConstantMaturity", - examples=[Example(parameters={"maturity": "10y"})], + examples=[APIEx(parameters={"maturity": "10y"})], ) async def tcm_effr( cc: CommandContext, @@ -56,7 +56,7 @@ async def tcm_effr( @router.command( model="SelectedTreasuryBill", - examples=[Example(parameters={"maturity": "6m"})], + examples=[APIEx(parameters={"maturity": "6m"})], ) async def treasury_effr( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index e212ab1dd735..a76204e95d32 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -1,7 +1,7 @@ """Index Router.""" from openbb_core.app.deprecation import OpenBBDeprecationWarning -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -26,7 +26,7 @@ since=(4, 1), expected_removal=(4, 3), ), - examples=[Example(parameters={"symbol": "SPX"})], + examples=[APIEx(parameters={"symbol": "SPX"})], ) async def market( cc: CommandContext, @@ -41,8 +41,8 @@ async def market( @router.command( model="IndexConstituents", examples=[ - Example(parameters={"symbol": "dowjones", "provider": "fmp"}), - Example( + APIEx(parameters={"symbol": "dowjones", "provider": "fmp"}), + APIEx( description="Providers other than FMP will use the ticker symbol.", parameters={"symbol": "BEP50P", "provider": "cboe"}, ), @@ -60,7 +60,7 @@ async def constituents( @router.command( model="IndexSnapshots", - examples=[Example(parameters={"region": "us", "provider": "cboe"})], + examples=[APIEx(parameters={"region": "us", "provider": "cboe"})], ) async def snapshots( cc: CommandContext, @@ -74,7 +74,7 @@ async def snapshots( @router.command( model="AvailableIndices", - examples=[Example(parameters={"provider": "yfinance"})], + examples=[APIEx(parameters={"provider": "yfinance"})], ) async def available( cc: CommandContext, @@ -88,7 +88,7 @@ async def available( @router.command( model="IndexSearch", - examples=[Example(parameters={"query": "SPX", "provider": "cboe"})], + examples=[APIEx(parameters={"query": "SPX", "provider": "cboe"})], ) async def search( cc: CommandContext, @@ -103,7 +103,7 @@ async def search( @router.command( model="SP500Multiples", examples=[ - Example(parameters={"series_name": "shiller_pe_year", "provider": "nasdaq"}) + APIEx(parameters={"series_name": "shiller_pe_year", "provider": "nasdaq"}) ], ) async def sp500_multiples( @@ -118,7 +118,7 @@ async def sp500_multiples( @router.command( model="IndexSectors", - examples=[Example(parameters={"symbol": "^TX60", "provider": "tmx"})], + examples=[APIEx(parameters={"symbol": "^TX60", "provider": "tmx"})], ) async def sectors( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index e0cfa1c6915b..5e74aa695b1f 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -1,6 +1,6 @@ """Price Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -17,8 +17,8 @@ @router.command( model="IndexHistorical", examples=[ - Example(parameters={"symbol": "^GSPC", "provider": "fmp"}), - Example( + APIEx(parameters={"symbol": "^GSPC", "provider": "fmp"}), + APIEx( description="Not all providers have the same symbols.", parameters={"symbol": "SPX", "provider": "intrinio"}, ), diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index ee005957031b..3d26fde8045e 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -1,7 +1,7 @@ # pylint: disable=import-outside-toplevel, W0613:unused-argument """News Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -16,24 +16,24 @@ @router.command( model="WorldNews", examples=[ - Example(parameters={"limit": 2500}), - Example( + APIEx(parameters={"limit": 2500}), + APIEx( description="Get news on the specified dates.", parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, ), - Example( + APIEx( description="Display the headlines of the news.", parameters={"display": "headline", "provider": "benzinga"}, ), - Example( + APIEx( description="Get news by topics.", parameters={"topics": "finance", "provider": "benzinga"}, ), - Example( + APIEx( description="Get news by source using 'tingo' as provider.", parameters={"provider": "tiingo", "source": "bloomberg"}, ), - Example( + APIEx( description="Filter aticles by term using 'biztoc' as provider.", parameters={"provider": "biztoc", "term": "apple"}, ), @@ -52,8 +52,8 @@ async def world( @router.command( model="CompanyNews", examples=[ - Example(parameters={"limit": 2500}), - Example( + APIEx(parameters={"limit": 2500}), + APIEx( description="Get news on the specified dates.", parameters={ "symbol": "AAPL", @@ -61,7 +61,7 @@ async def world( "end_date": "2024-02-07", }, ), - Example( + APIEx( description="Display the headlines of the news.", parameters={ "symbol": "AAPL", @@ -69,11 +69,11 @@ async def world( "provider": "benzinga", }, ), - Example( + APIEx( description="Get news for multiple symbols.", parameters={"symbol": "aapl,tsla"}, ), - Example( + APIEx( description="Get news company's ISIN.", parameters={"symbol": "NVDA", "isin": "US0378331005"}, ), diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index c9588c51a363..758ab7c3cd77 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -2,7 +2,7 @@ import numpy as np import pandas as pd -from openbb_core.app.model import Example, OBBject +from openbb_core.app.model import PythonEx, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -22,8 +22,7 @@ @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -86,8 +85,7 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -145,8 +143,7 @@ def sharpe_ratio( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 9cc7a6f26909..45a0eaebaff5 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -3,7 +3,7 @@ from typing import List, Literal import pandas as pd -from openbb_core.app.model import Example, OBBject +from openbb_core.app.model import PythonEx, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -38,8 +38,7 @@ @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.quantitative.normality(data=stock_data, target='close')", @@ -93,8 +92,7 @@ def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.quantitative.capm(data=stock_data, target='close')", diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index e7e03a88f630..068c4489456e 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model import Example, OBBject +from openbb_core.app.model import PythonEx, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -27,8 +27,7 @@ @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -81,8 +80,7 @@ def skew( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -128,8 +126,7 @@ def variance( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -179,8 +176,7 @@ def stdev( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -232,8 +228,7 @@ def kurtosis( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -302,8 +297,7 @@ def quantile( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index c99d73007d7d..12039b6f7ddd 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model import Example, OBBject +from openbb_core.app.model import PythonEx, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -26,8 +26,7 @@ @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -72,8 +71,7 @@ def skew( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -112,8 +110,7 @@ def variance(data: List[Data], target: str) -> OBBject[List[Data]]: @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -154,8 +151,7 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -196,8 +192,7 @@ def kurtosis(data: List[Data], target) -> OBBject[List[Data]]: @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -246,8 +241,7 @@ def quantile( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 26531d4df4d3..195ac295028a 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -1,7 +1,7 @@ # pylint: disable=W0613:unused-argument """Commodity Futures Trading Commission (CFTC) Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -15,7 +15,7 @@ @router.command( model="COTSearch", - examples=[Example(parameters={"query": "gold"})], + examples=[APIEx(parameters={"query": "gold"})], ) async def cot_search( cc: CommandContext, @@ -33,15 +33,15 @@ async def cot_search( @router.command( model="COT", examples=[ - Example( + APIEx( description="Get the Commitment of Traders Report for Gold.", parameters={"series_id": "GC=F"}, ), - Example( + APIEx( description="Enter the report ID by the Nasdaq Data Link Code.", parameters={"series_id": "088691"}, ), - Example( + APIEx( description="Get the report for futures only.", parameters={"series_id": "088691", "data_type": "F"}, ), diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 4f1f2ca95c3d..38f967726322 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -1,7 +1,7 @@ # pylint: disable=W0613:unused-argument """SEC Router.""" -from openbb_core.app.model import CommandContext, Example, OBBject +from openbb_core.app.model import CommandContext, APIEx, PythonEx, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, @@ -15,7 +15,7 @@ @router.command( model="CikMap", - examples=[Example(parameters={"symbol": "MSFT"})], + examples=[APIEx(parameters={"symbol": "MSFT"})], ) async def cik_map( cc: CommandContext, @@ -29,7 +29,7 @@ async def cik_map( @router.command( model="InstitutionsSearch", - examples=[Example(parameters={"query": "blackstone real estate"})], + examples=[APIEx(parameters={"query": "blackstone real estate"})], ) async def institutions_search( cc: CommandContext, @@ -44,9 +44,8 @@ async def institutions_search( @router.command( model="SchemaFiles", examples=[ - Example(parameters={}), - Example( - scope="python", + APIEx(parameters={}), + PythonEx( code=[ "#### Get a list of schema files. ####", "data = obb.regulators.sec.schema_files()", @@ -82,7 +81,7 @@ async def schema_files( @router.command( model="SymbolMap", - examples=[Example(parameters={"cik": "0000789019"})], + examples=[APIEx(parameters={"cik": "0000789019"})], ) async def symbol_map( cc: CommandContext, @@ -96,7 +95,7 @@ async def symbol_map( @router.command( model="RssLitigation", - examples=[Example(parameters={})], + examples=[APIEx(parameters={})], ) async def rss_litigation( cc: CommandContext, @@ -110,7 +109,7 @@ async def rss_litigation( @router.command( model="SicSearch", - examples=[Example(parameters={"query": "real estate investment trusts"})], + examples=[APIEx(parameters={"query": "real estate investment trusts"})], ) async def sic_search( cc: CommandContext, diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index fe5490d991df..e2624f724d8b 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -5,7 +5,7 @@ import pandas as pd import pandas_ta as ta -from openbb_core.app.model import Example, OBBject +from openbb_core.app.model import PythonEx, OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, @@ -25,8 +25,7 @@ @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "atr_data = obb.technical.atr(data=stock_data.results)", @@ -87,8 +86,7 @@ def atr( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "fib_data = obb.technical.fib(data=stock_data.results, period=120)", @@ -157,8 +155,7 @@ def fib( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "obv_data = obb.technical.obv(data=stock_data.results, offset=0)", @@ -209,8 +206,7 @@ def obv( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "fisher_data = obb.technical.fisher(data=stock_data.results, length=14, signal=1)", @@ -261,8 +257,7 @@ def fisher( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "adosc_data = obb.technical.adosc(data=stock_data.results, fast=3, slow=10, offset=0)", @@ -316,8 +311,7 @@ def adosc( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", @@ -393,8 +387,7 @@ def bbands( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "zlma_data = obb.technical.zlma(data=stock_data.results, target='close', length=50, offset=0)", @@ -456,8 +449,7 @@ def zlma( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "aaron_data = obb.technical.aroon(data=stock_data.results, length=25, scalar=100)", @@ -514,8 +506,7 @@ def aroon( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "sma_data = obb.technical.sma(data=stock_data.results, target='close', length=50, offset=0)", @@ -578,8 +569,7 @@ def sma( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "demark_data = obb.technical.demark(data=stock_data.results, offset=0)", @@ -637,8 +627,7 @@ def demark( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "vwap_data = obb.technical.vwap(data=stock_data.results, anchor='D', offset=0)", @@ -690,8 +679,7 @@ def vwap( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "macd_data = obb.technical.macd(data=stock_data.results, target='close', fast=12, slow=26, signal=9)", @@ -758,8 +746,7 @@ def macd( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "hma_data = obb.technical.hma(data=stock_data.results, target='close', length=50, offset=0)", @@ -819,8 +806,7 @@ def hma( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", @@ -878,8 +864,7 @@ def donchian( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ichimoku_data = obb.technical.ichimoku(data=stock_data.results, conversion=9, base=26, lookahead=False)", @@ -947,8 +932,7 @@ def ichimoku( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "clenow_data = obb.technical.clenow(data=stock_data.results, period=90)", @@ -1007,8 +991,7 @@ def clenow( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", @@ -1058,8 +1041,7 @@ def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[D @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "adx_data = obb.technical.adx(data=stock_data.results, length=50, scalar=100.0, drift=1)", @@ -1113,8 +1095,7 @@ def adx( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "wma_data = obb.technical.wma(data=stock_data.results, target='close', length=50, offset=0)", @@ -1174,8 +1155,7 @@ def wma( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cci_data = obb.technical.cci(data=stock_data.results, length=14, scalar=0.015)", @@ -1226,8 +1206,7 @@ def cci( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "rsi_data = obb.technical.rsi(data=stock_data.results, target='close', length=14, scalar=100.0, drift=1)", @@ -1292,8 +1271,7 @@ def rsi( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", @@ -1354,8 +1332,7 @@ def stoch( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "kc_data = obb.technical.kc(data=stock_data.results, length=20, scalar=20, mamode='ema', offset=0)", @@ -1418,8 +1395,7 @@ def kc( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cg_data = obb.technical.cg(data=stock_data.results, length=14)", @@ -1465,8 +1441,7 @@ def cg( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cones_data = obb.technical.cones(data=stock_data.results, lower_q=0.25, upper_q=0.75, model='STD')", @@ -1569,8 +1544,7 @@ def cones( @router.command( methods=["POST"], examples=[ - Example( - scope="python", + PythonEx( code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ema_data = obb.technical.ema(data=stock_data.results, target='close', length=50, offset=0)", From 1b4623a1d9a2b0b49548e8d112ba15166b6370b3 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 14:21:50 +0000 Subject: [PATCH 026/133] comment --- openbb_platform/core/openbb_core/app/model/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 3cff7f56e7b1..3edd71f43dc6 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -8,7 +8,7 @@ class Example(BaseModel): """Example model.""" scope: str - description: Optional[str] = None + description: Optional[str] = None # Should this be required? Would help to create example titles model_config = ConfigDict(validate_assignment=True) From e2a1c4bb5ee496497d34adce161c8a72494bd888 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 14:23:36 +0000 Subject: [PATCH 027/133] typing --- openbb_platform/core/openbb_core/app/model/example.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 3edd71f43dc6..939a2a716f19 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,4 +1,5 @@ from abc import abstractmethod +from dataclasses import Field from typing import Any, Dict, List, Literal, Optional from pydantic import BaseModel, ConfigDict @@ -32,7 +33,7 @@ def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") func_name = kwargs.get("func_name", "") - func_params = kwargs.get("func_params", {}) + func_params: Dict[str, Field] = kwargs.get("func_params", {}) eg = "" if self.parameters is not None: if self.description: From 2f5e25d125e3d286b3f2c342a07690626b8d4e6a Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sun, 3 Mar 2024 14:24:13 +0000 Subject: [PATCH 028/133] lint --- openbb_platform/core/openbb_core/app/model/__init__.py | 2 +- openbb_platform/core/openbb_core/app/model/example.py | 4 +++- .../extensions/commodity/openbb_commodity/commodity_router.py | 2 +- .../extensions/crypto/openbb_crypto/crypto_router.py | 2 +- .../extensions/crypto/openbb_crypto/price/price_router.py | 2 +- .../extensions/currency/openbb_currency/currency_router.py | 2 +- .../extensions/currency/openbb_currency/price/price_router.py | 2 +- .../derivatives/openbb_derivatives/futures/futures_router.py | 2 +- .../derivatives/openbb_derivatives/options/options_router.py | 2 +- .../econometrics/openbb_econometrics/econometrics_router.py | 2 +- .../extensions/economy/openbb_economy/economy_router.py | 2 +- .../extensions/economy/openbb_economy/gdp/gdp_router.py | 2 +- .../equity/openbb_equity/calendar/calendar_router.py | 2 +- .../extensions/equity/openbb_equity/compare/compare_router.py | 2 +- .../equity/openbb_equity/darkpool/darkpool_router.py | 2 +- .../equity/openbb_equity/discovery/discovery_router.py | 2 +- .../extensions/equity/openbb_equity/equity_router.py | 2 +- .../equity/openbb_equity/estimates/estimates_router.py | 2 +- .../equity/openbb_equity/fundamental/fundamental_router.py | 2 +- .../equity/openbb_equity/ownership/ownership_router.py | 2 +- .../extensions/equity/openbb_equity/price/price_router.py | 2 +- .../extensions/equity/openbb_equity/shorts/shorts_router.py | 2 +- .../extensions/etf/openbb_etf/discovery/discovery_router.py | 2 +- openbb_platform/extensions/etf/openbb_etf/etf_router.py | 2 +- .../openbb_fixedincome/corporate/corporate_router.py | 2 +- .../fixedincome/openbb_fixedincome/fixedincome_router.py | 2 +- .../openbb_fixedincome/government/government_router.py | 2 +- .../fixedincome/openbb_fixedincome/rate/rate_router.py | 2 +- .../fixedincome/openbb_fixedincome/spreads/spreads_router.py | 2 +- openbb_platform/extensions/index/openbb_index/index_router.py | 2 +- .../extensions/index/openbb_index/price/price_router.py | 2 +- openbb_platform/extensions/news/openbb_news/news_router.py | 2 +- .../openbb_quantitative/performance/performance_router.py | 2 +- .../quantitative/openbb_quantitative/quantitative_router.py | 2 +- .../openbb_quantitative/rolling/rolling_router.py | 2 +- .../quantitative/openbb_quantitative/stats/stats_router.py | 2 +- .../regulators/openbb_regulators/cftc/cftc_router.py | 2 +- .../extensions/regulators/openbb_regulators/sec/sec_router.py | 2 +- .../extensions/technical/openbb_technical/technical_router.py | 2 +- 39 files changed, 41 insertions(+), 39 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/__init__.py b/openbb_platform/core/openbb_core/app/model/__init__.py index 32578d28cf02..e85119b2b96a 100644 --- a/openbb_platform/core/openbb_core/app/model/__init__.py +++ b/openbb_platform/core/openbb_core/app/model/__init__.py @@ -1,3 +1,3 @@ from .command_context import CommandContext -from .example import Example, APIEx, PythonEx +from .example import APIEx, Example, PythonEx from .obbject import OBBject diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 939a2a716f19..92dea98bcdfe 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -9,7 +9,9 @@ class Example(BaseModel): """Example model.""" scope: str - description: Optional[str] = None # Should this be required? Would help to create example titles + description: Optional[str] = ( + None # Should this be required? Would help to create example titles + ) model_config = ConfigDict(validate_assignment=True) diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index 93aa99c2bf29..dc2ea243c816 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -1,6 +1,6 @@ """The Commodity router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py index 4ef43a7a04e2..a652f901a981 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py @@ -1,6 +1,6 @@ """Crypto Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index 08ad2b724a06..c22be0b49370 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -1,7 +1,7 @@ # pylint: disable=W0613:unused-argument """Crypto Price Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index 2c9d91f5e702..7d09a967d43e 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -1,6 +1,6 @@ """The Currency router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index 14971cc6a97e..af2281212e4f 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -1,7 +1,7 @@ """Price router for Currency.""" # pylint: disable=unused-argument -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index c719067d62cd..73bb44cd9e8e 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -1,6 +1,6 @@ """Futures Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index f1320ab8837c..c7b6745ec675 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -1,6 +1,6 @@ """Options Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index b21db0387f98..6658590f1b54 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -15,7 +15,7 @@ PooledOLS, RandomEffects, ) -from openbb_core.app.model import PythonEx, OBBject +from openbb_core.app.model import OBBject, PythonEx from openbb_core.app.router import Router from openbb_core.app.utils import basemodel_to_df, get_target_column, get_target_columns from openbb_core.provider.abstract.data import Data diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 371eb178d2c3..64ee5b4a7921 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -1,6 +1,6 @@ """Economy Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py index ab620b590e63..b0449c69c037 100644 --- a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py @@ -1,6 +1,6 @@ """Economy GDP Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py index 23f3feb2bc84..e0b87b9a5266 100644 --- a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py @@ -1,6 +1,6 @@ """Calendar Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py index 9cdd5d2d5554..4506149157c2 100644 --- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py @@ -1,7 +1,7 @@ # pylint: disable=W0613:unused-argument """Comparison Analysis Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py index fb7a93237ac6..a198ffee7396 100644 --- a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py @@ -1,6 +1,6 @@ """Dark Pool Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index 7f7bbbe11073..708282a6fede 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -1,7 +1,7 @@ """Disc router for Equities.""" # pylint: disable=unused-argument -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/equity_router.py b/openbb_platform/extensions/equity/openbb_equity/equity_router.py index 65eb609b20e9..8fe3ec9e242c 100644 --- a/openbb_platform/extensions/equity/openbb_equity/equity_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/equity_router.py @@ -1,6 +1,6 @@ """Equity Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index 31bfab24bd45..43ec5141905d 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -1,6 +1,6 @@ """Estimates Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index 74355e20e074..3daf6539bf82 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -2,7 +2,7 @@ """Fundamental Analysis Router.""" from openbb_core.app.deprecation import OpenBBDeprecationWarning -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index 6a1815c6d831..2d24fff0396a 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -1,6 +1,6 @@ """Ownership Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index cb41cde7b27d..ff41f63e58ff 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -1,6 +1,6 @@ """Price Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index 990838a42643..f6e876cc75f6 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -1,6 +1,6 @@ """Shorts Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py index 895384e1902a..19fca43d1448 100644 --- a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py @@ -1,6 +1,6 @@ """Disc router for ETFs.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index 03d97209ae22..e0ab62b6508f 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -1,6 +1,6 @@ """ETF Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index b6a42d633104..a3ab447caba8 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -1,6 +1,6 @@ """Fixed Income Corporate Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py index 9521e049a3b6..bfbe2fa64cde 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py @@ -2,7 +2,7 @@ # pylint: disable=W0613:unused-argument -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index 263470e9985a..466b10f5bd3c 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -1,6 +1,6 @@ """Fixed Income Government Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index 3957980b19bb..81073ba0c671 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -1,6 +1,6 @@ """Fixed Income Rate Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py index 10c1ca809076..880300ed6a2b 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py @@ -1,6 +1,6 @@ """Fixed Income Corporate Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index a76204e95d32..4770960eb18c 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -1,7 +1,7 @@ """Index Router.""" from openbb_core.app.deprecation import OpenBBDeprecationWarning -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index 5e74aa695b1f..419200bb0ece 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -1,6 +1,6 @@ """Price Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index 3d26fde8045e..85b5dca91f07 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -1,7 +1,7 @@ # pylint: disable=import-outside-toplevel, W0613:unused-argument """News Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 758ab7c3cd77..0ea93e17238a 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -2,7 +2,7 @@ import numpy as np import pandas as pd -from openbb_core.app.model import PythonEx, OBBject +from openbb_core.app.model import OBBject, PythonEx from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 45a0eaebaff5..0d5b9eb4c061 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -3,7 +3,7 @@ from typing import List, Literal import pandas as pd -from openbb_core.app.model import PythonEx, OBBject +from openbb_core.app.model import OBBject, PythonEx from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 068c4489456e..26cb576ae125 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model import PythonEx, OBBject +from openbb_core.app.model import OBBject, PythonEx from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index 12039b6f7ddd..e0997b197de0 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model import PythonEx, OBBject +from openbb_core.app.model import OBBject, PythonEx from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 195ac295028a..6a57f7c08e48 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -1,7 +1,7 @@ # pylint: disable=W0613:unused-argument """Commodity Futures Trading Commission (CFTC) Router.""" -from openbb_core.app.model import CommandContext, APIEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 38f967726322..561eaddc73aa 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -1,7 +1,7 @@ # pylint: disable=W0613:unused-argument """SEC Router.""" -from openbb_core.app.model import CommandContext, APIEx, PythonEx, OBBject +from openbb_core.app.model import APIEx, CommandContext, OBBject, PythonEx from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index e2624f724d8b..e11f0e6e79b7 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -5,7 +5,7 @@ import pandas as pd import pandas_ta as ta -from openbb_core.app.model import PythonEx, OBBject +from openbb_core.app.model import OBBject, PythonEx from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, From 849e0589003d05a86b50bd8b8bbb03a7fa59bd62 Mon Sep 17 00:00:00 2001 From: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Date: Sun, 3 Mar 2024 23:23:35 +0000 Subject: [PATCH 029/133] Update router.py --- openbb_platform/core/openbb_core/app/router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py index fea92f3aaad2..3968d5892a03 100644 --- a/openbb_platform/core/openbb_core/app/router.py +++ b/openbb_platform/core/openbb_core/app/router.py @@ -239,7 +239,7 @@ def command( kwargs["response_model_exclude_unset"] = True kwargs["openapi_extra"] = kwargs.get("openapi_extra", {}) kwargs["openapi_extra"]["model"] = model - kwargs["openapi_extra"]["examples"] = None or filter_list( + kwargs["openapi_extra"]["examples"] = filter_list( examples=kwargs.pop("examples", []), providers=ProviderInterface().available_providers, ) From 346397fc586a376f022d6e56fec6e553d2ba8c97 Mon Sep 17 00:00:00 2001 From: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Date: Sun, 3 Mar 2024 23:27:23 +0000 Subject: [PATCH 030/133] Update econometrics_router.py --- .../openbb_econometrics/econometrics_router.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 6658590f1b54..1e357cfff094 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -29,7 +29,17 @@ router = Router(prefix="") -@router.command(methods=["POST"]) +@router.command( + methods=["POST"], + examples=[ + PythonEx( + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "obb.econometrics.correlation_matrix(data=stock_data)", + ] + ) + ] +) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: """Get the correlation matrix of an input dataset. From c1f47b3d31e25718ad124b0809ce88c75eba6562 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Mon, 4 Mar 2024 11:16:25 +0000 Subject: [PATCH 031/133] fix to_python --- openbb_platform/core/openbb_core/app/model/example.py | 4 ++-- .../core/openbb_core/app/static/package_builder.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 92dea98bcdfe..c27e5a40cc1d 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -34,13 +34,13 @@ def provider(self) -> Optional[str]: def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") - func_name = kwargs.get("func_name", "") + func_path = kwargs.get("func_path", ".func_router.func_name") func_params: Dict[str, Field] = kwargs.get("func_params", {}) eg = "" if self.parameters is not None: if self.description: eg += f"{indentation}>>> # {self.description}\n" - eg += f"{indentation}>>> obb{func_name}(" + eg += f"{indentation}>>> obb{func_path}(" for k, v in self.parameters.items(): if k in func_params and (field := func_params.get(k)): diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 8196082d6df5..cf710782e517 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -863,7 +863,7 @@ def get_OBBject_description( @staticmethod def append_examples( - func_name: str, + func_path: str, func_params: Dict[str, Field], examples: Optional[List[Example]], indentation: str = "", @@ -876,7 +876,7 @@ def append_examples( for e in examples: doc += e.to_python( - func_name=func_name, + func_path=func_path, func_params=func_params, indentation=indentation, ) From a5db02b705f8ce83eddc3897ad6998c11f1a99b9 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Mon, 4 Mar 2024 11:22:13 +0000 Subject: [PATCH 032/133] to_python --- .../core/openbb_core/app/model/example.py | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index c27e5a40cc1d..fba33e347fd6 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -29,33 +29,33 @@ class APIEx(Example): @property def provider(self) -> Optional[str]: """Return the provider from the parameters.""" - return self.parameters.get("provider") if self.parameters else None + return self.parameters.get("provider") def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") func_path = kwargs.get("func_path", ".func_router.func_name") func_params: Dict[str, Field] = kwargs.get("func_params", {}) + eg = "" - if self.parameters is not None: - if self.description: - eg += f"{indentation}>>> # {self.description}\n" - eg += f"{indentation}>>> obb{func_path}(" - - for k, v in self.parameters.items(): - if k in func_params and (field := func_params.get(k)): - field_type_str = str(field.type) - # TODO: Handle types better, some edge cases - # like Union[str, List[str]] will be stringified - # even if the type is a list - if any(t in field_type_str for t in ["int", "float", "bool"]): - eg += f"{k}={v}, " - else: - eg += f"{k}='{v}', " + if self.description: + eg += f"{indentation}>>> # {self.description}\n" + + eg += f"{indentation}>>> obb{func_path}(" + for k, v in self.parameters.items(): + if k in func_params and (field := func_params.get(k)): + field_type_str = str(field.type) + # TODO: Handle types better, some edge cases + # like Union[str, List[str]] will be stringified + # even if the type is a list + if any(t in field_type_str for t in ["int", "float", "bool"]): + eg += f"{k}={v}, " else: eg += f"{k}='{v}', " + else: + eg += f"{k}='{v}', " - eg = indentation + eg.strip(", ") + ")\n" + eg = indentation + eg.strip(", ") + ")\n" return eg @@ -69,10 +69,8 @@ def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") eg = "" - if self.code is not None: - for line in self.code: # pylint: disable=not-an-iterable - eg += f"{indentation}>>> {line}\n" - + for line in self.code: + eg += f"{indentation}>>> {line}\n" return eg From aeda34b01cc5a260bc7ecc890b5b4b96827d6932 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Mon, 4 Mar 2024 11:25:34 +0000 Subject: [PATCH 033/133] to_python --- openbb_platform/core/openbb_core/app/model/example.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index fba33e347fd6..dd1f4bf7daa2 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -68,7 +68,11 @@ class PythonEx(Example): def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") + eg = "" + if self.description: + eg += f"{indentation}>>> # {self.description}\n" + for line in self.code: eg += f"{indentation}>>> {line}\n" return eg From 1a6a15a61242892d045747f545e2acad01a803dd Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Mon, 4 Mar 2024 11:25:56 +0000 Subject: [PATCH 034/133] black --- .../econometrics/openbb_econometrics/econometrics_router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 1e357cfff094..d9efe6c15445 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -38,7 +38,7 @@ "obb.econometrics.correlation_matrix(data=stock_data)", ] ) - ] + ], ) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: """Get the correlation matrix of an input dataset. From 36437d1b2c53d8445dfd5a060424d4eb34385d39 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Mon, 4 Mar 2024 11:41:00 +0000 Subject: [PATCH 035/133] fix multiple line field descriptions --- .../openbb_core/app/static/package_builder.py | 6 +- openbb_platform/openbb/package/economy.py | 154 +++++++++--------- openbb_platform/openbb/package/equity.py | 4 +- .../openbb/package/equity_calendar.py | 70 ++++---- .../openbb/package/equity_fundamental.py | 30 ++-- .../openbb/package/equity_price.py | 68 ++++---- .../openbb/package/equity_shorts.py | 10 +- openbb_platform/openbb/package/etf.py | 8 +- openbb_platform/openbb/package/index.py | 4 +- openbb_platform/openbb/package/news.py | 8 +- 10 files changed, 181 insertions(+), 181 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index cf710782e517..dcc4be84b2a4 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -909,7 +909,7 @@ def format_type(type_: str, char_limit: Optional[int] = None) -> str: def format_description(description: str) -> str: """Format description in docstrings.""" - description = description.replace("\n", f"\n{indentation+tab}") + description = description.replace("\n", f"\n{indentation}") return description docstring = summary.strip("\n").replace("\n ", f"\n{indentation}") @@ -924,8 +924,8 @@ def format_description(description: str) -> str: type_ = param._annotation default = param._annotation.__args__[0].__args__[0] description = f"""The provider to use for the query, by default None. -If None, the provider specified in defaults is selected or '{default}' if there is -no default.""" + If None, the provider specified in defaults is selected or '{default}' if there is + no default.""" elif param_name == "chart": type_ = "bool" description = "Whether to create a chart or not, by default False." diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index bbc4ba31711e..2f233e9eaac7 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -280,15 +280,15 @@ def cpi( The country to get data. Multiple items allowed for provider(s): fred. units : Literal['growth_previous', 'growth_same', 'index_2015'] The unit of measurement for the data. - Options: - - `growth_previous`: Percent growth from the previous period. - If monthly data, this is month-over-month, etc - - `growth_same`: Percent growth from the same period in the previous year. - If looking at monthly data, this would be year-over-year, etc. - - `index_2015`: Rescaled index value, such that the value in 2015 is 100. + Options: + - `growth_previous`: Percent growth from the previous period. + If monthly data, this is month-over-month, etc + - `growth_same`: Percent growth from the same period in the previous year. + If looking at monthly data, this would be year-over-year, etc. + - `index_2015`: Rescaled index value, such that the value in 2015 is 100. frequency : Literal['monthly', 'quarter', 'annual'] The frequency of the data. - Options: `monthly`, `quarter`, and `annual`. + Options: `monthly`, `quarter`, and `annual`. harmonized : bool Whether you wish to obtain harmonized data. start_date : Union[datetime.date, None, str] @@ -407,46 +407,46 @@ def fred_regional( The units of the data. This should match the units returned from searching by series ID. An incorrect field will not necessarily return an error. Parameter is only valid when `is_series_group` is True. (provider: fred) frequency : Optional[Literal['d', 'w', 'bw', 'm', 'q', 'sa', 'a', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] - Frequency aggregation to convert high frequency data to lower frequency. - Parameter is only valid when `is_series_group` is True. - a = Annual - sa= Semiannual - q = Quarterly - m = Monthly - w = Weekly - d = Daily - wef = Weekly, Ending Friday - weth = Weekly, Ending Thursday - wew = Weekly, Ending Wednesday - wetu = Weekly, Ending Tuesday - wem = Weekly, Ending Monday - wesu = Weekly, Ending Sunday - wesa = Weekly, Ending Saturday - bwew = Biweekly, Ending Wednesday - bwem = Biweekly, Ending Monday - (provider: fred) + Frequency aggregation to convert high frequency data to lower frequency. + Parameter is only valid when `is_series_group` is True. + a = Annual + sa= Semiannual + q = Quarterly + m = Monthly + w = Weekly + d = Daily + wef = Weekly, Ending Friday + weth = Weekly, Ending Thursday + wew = Weekly, Ending Wednesday + wetu = Weekly, Ending Tuesday + wem = Weekly, Ending Monday + wesu = Weekly, Ending Sunday + wesa = Weekly, Ending Saturday + bwew = Biweekly, Ending Wednesday + bwem = Biweekly, Ending Monday + (provider: fred) aggregation_method : Literal['avg', 'sum', 'eop'] - A key that indicates the aggregation method used for frequency aggregation. - This parameter has no affect if the frequency parameter is not set. - Only valid when `is_series_group` is True. - avg = Average - sum = Sum - eop = End of Period - (provider: fred) + A key that indicates the aggregation method used for frequency aggregation. + This parameter has no affect if the frequency parameter is not set. + Only valid when `is_series_group` is True. + avg = Average + sum = Sum + eop = End of Period + (provider: fred) transform : Literal['lin', 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'] - Transformation type. Only valid when `is_series_group` is True. - lin = Levels (No transformation) - chg = Change - ch1 = Change from Year Ago - pch = Percent Change - pc1 = Percent Change from Year Ago - pca = Compounded Annual Rate of Change - cch = Continuously Compounded Rate of Change - cca = Continuously Compounded Annual Rate of Change - log = Natural Log - (provider: fred) + Transformation type. Only valid when `is_series_group` is True. + lin = Levels (No transformation) + chg = Change + ch1 = Change from Year Ago + pch = Percent Change + pc1 = Percent Change from Year Ago + pca = Compounded Annual Rate of Change + cch = Continuously Compounded Rate of Change + cca = Continuously Compounded Annual Rate of Change + log = Natural Log + (provider: fred) Returns ------- @@ -674,44 +674,44 @@ def fred_series( no default. frequency : Literal[None, 'a', 'q', 'm', 'w', 'd', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem'] - Frequency aggregation to convert high frequency data to lower frequency. - None = No change - a = Annual - q = Quarterly - m = Monthly - w = Weekly - d = Daily - wef = Weekly, Ending Friday - weth = Weekly, Ending Thursday - wew = Weekly, Ending Wednesday - wetu = Weekly, Ending Tuesday - wem = Weekly, Ending Monday - wesu = Weekly, Ending Sunday - wesa = Weekly, Ending Saturday - bwew = Biweekly, Ending Wednesday - bwem = Biweekly, Ending Monday - (provider: fred) + Frequency aggregation to convert high frequency data to lower frequency. + None = No change + a = Annual + q = Quarterly + m = Monthly + w = Weekly + d = Daily + wef = Weekly, Ending Friday + weth = Weekly, Ending Thursday + wew = Weekly, Ending Wednesday + wetu = Weekly, Ending Tuesday + wem = Weekly, Ending Monday + wesu = Weekly, Ending Sunday + wesa = Weekly, Ending Saturday + bwew = Biweekly, Ending Wednesday + bwem = Biweekly, Ending Monday + (provider: fred) aggregation_method : Literal[None, 'avg', 'sum', 'eop'] - A key that indicates the aggregation method used for frequency aggregation. - This parameter has no affect if the frequency parameter is not set. - avg = Average - sum = Sum - eop = End of Period - (provider: fred) + A key that indicates the aggregation method used for frequency aggregation. + This parameter has no affect if the frequency parameter is not set. + avg = Average + sum = Sum + eop = End of Period + (provider: fred) transform : Literal[None, 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log'] - Transformation type - None = No transformation - chg = Change - ch1 = Change from Year Ago - pch = Percent Change - pc1 = Percent Change from Year Ago - pca = Compounded Annual Rate of Change - cch = Continuously Compounded Rate of Change - cca = Continuously Compounded Annual Rate of Change - log = Natural Log - (provider: fred) + Transformation type + None = No transformation + chg = Change + ch1 = Change from Year Ago + pch = Percent Change + pc1 = Percent Change from Year Ago + pca = Compounded Annual Rate of Change + cch = Continuously Compounded Rate of Change + cca = Continuously Compounded Annual Rate of Change + log = Natural Log + (provider: fred) all_pages : Optional[bool] Returns all pages of data from the API call at once. (provider: intrinio) sleep : Optional[float] diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index 40a32ea008e9..b13494861a9e 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -352,7 +352,7 @@ def profile( Currency in which the stock is traded. (provider: fmp, yfinance) market_cap : Optional[int] Market capitalization of the company. (provider: fmp); - The market capitalization of the asset. (provider: yfinance) + The market capitalization of the asset. (provider: yfinance) last_price : Optional[float] The last traded price. (provider: fmp) year_high : Optional[float] @@ -584,7 +584,7 @@ def search( Name of the company. cik : Optional[str] ; - Central Index Key (provider: sec) + Central Index Key (provider: sec) lei : Optional[str] The Legal Entity Identifier (LEI) of the company. (provider: intrinio) intrinio_id : Optional[str] diff --git a/openbb_platform/openbb/package/equity_calendar.py b/openbb_platform/openbb/package/equity_calendar.py index bb1903abea82..739aa001ad51 100644 --- a/openbb_platform/openbb/package/equity_calendar.py +++ b/openbb_platform/openbb/package/equity_calendar.py @@ -283,52 +283,52 @@ def ipo( The date of the IPO, when the stock first trades on a major exchange. status : Optional[Literal['upcoming', 'priced', 'withdrawn']] - The status of the IPO. Upcoming IPOs have not taken place yet but are expected to. - Priced IPOs have taken place. - Withdrawn IPOs were expected to take place, but were subsequently withdrawn and did not take place - (provider: intrinio) + The status of the IPO. Upcoming IPOs have not taken place yet but are expected to. + Priced IPOs have taken place. + Withdrawn IPOs were expected to take place, but were subsequently withdrawn and did not take place + (provider: intrinio) exchange : Optional[str] - The acronym of the stock exchange that the company is going to trade publicly on. - Typically NYSE or NASDAQ. - (provider: intrinio) + The acronym of the stock exchange that the company is going to trade publicly on. + Typically NYSE or NASDAQ. + (provider: intrinio) offer_amount : Optional[float] The total dollar amount of shares offered in the IPO. Typically this is share price * share count (provider: intrinio) share_price : Optional[float] The price per share at which the IPO was offered. (provider: intrinio) share_price_lowest : Optional[float] - The expected lowest price per share at which the IPO will be offered. - Before an IPO is priced, companies typically provide a range of prices per share at which - they expect to offer the IPO (typically available for upcoming IPOs). - (provider: intrinio) + The expected lowest price per share at which the IPO will be offered. + Before an IPO is priced, companies typically provide a range of prices per share at which + they expect to offer the IPO (typically available for upcoming IPOs). + (provider: intrinio) share_price_highest : Optional[float] - The expected highest price per share at which the IPO will be offered. - Before an IPO is priced, companies typically provide a range of prices per share at which - they expect to offer the IPO (typically available for upcoming IPOs). - (provider: intrinio) + The expected highest price per share at which the IPO will be offered. + Before an IPO is priced, companies typically provide a range of prices per share at which + they expect to offer the IPO (typically available for upcoming IPOs). + (provider: intrinio) share_count : Optional[int] The number of shares offered in the IPO. (provider: intrinio) share_count_lowest : Optional[int] - The expected lowest number of shares that will be offered in the IPO. Before an IPO is priced, - companies typically provide a range of shares that they expect to offer in the IPO - (typically available for upcoming IPOs). - (provider: intrinio) + The expected lowest number of shares that will be offered in the IPO. Before an IPO is priced, + companies typically provide a range of shares that they expect to offer in the IPO + (typically available for upcoming IPOs). + (provider: intrinio) share_count_highest : Optional[int] - The expected highest number of shares that will be offered in the IPO. Before an IPO is priced, - companies typically provide a range of shares that they expect to offer in the IPO - (typically available for upcoming IPOs). - (provider: intrinio) + The expected highest number of shares that will be offered in the IPO. Before an IPO is priced, + companies typically provide a range of shares that they expect to offer in the IPO + (typically available for upcoming IPOs). + (provider: intrinio) announcement_url : Optional[str] The URL to the company's announcement of the IPO (provider: intrinio) sec_report_url : Optional[str] - The URL to the company's S-1, S-1/A, F-1, or F-1/A SEC filing, - which is required to be filed before an IPO takes place. - (provider: intrinio) + The URL to the company's S-1, S-1/A, F-1, or F-1/A SEC filing, + which is required to be filed before an IPO takes place. + (provider: intrinio) open_price : Optional[float] The opening price at the beginning of the first trading day (only available for priced IPOs). (provider: intrinio) close_price : Optional[float] @@ -337,19 +337,19 @@ def ipo( The volume at the end of the first trading day (only available for priced IPOs). (provider: intrinio) day_change : Optional[float] - The percentage change between the open price and the close price on the first trading day - (only available for priced IPOs). - (provider: intrinio) + The percentage change between the open price and the close price on the first trading day + (only available for priced IPOs). + (provider: intrinio) week_change : Optional[float] - The percentage change between the open price on the first trading day and the close price approximately - a week after the first trading day (only available for priced IPOs). - (provider: intrinio) + The percentage change between the open price on the first trading day and the close price approximately + a week after the first trading day (only available for priced IPOs). + (provider: intrinio) month_change : Optional[float] - The percentage change between the open price on the first trading day and the close price approximately - a month after the first trading day (only available for priced IPOs). - (provider: intrinio) + The percentage change between the open price on the first trading day and the close price approximately + a month after the first trading day (only available for priced IPOs). + (provider: intrinio) id : Optional[str] The Intrinio ID of the IPO. (provider: intrinio) company : Optional[openbb_intrinio.utils.references.IntrinioCompany] diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index 8c03a83c7ce3..cc707b3eafa1 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -642,10 +642,10 @@ def cash( The date the filing was accepted. (provider: fmp) reported_currency : Optional[str] The currency in which the cash flow statement was reported. (provider: fmp); - The currency in which the balance sheet is reported. (provider: intrinio) + The currency in which the balance sheet is reported. (provider: intrinio) net_income : Optional[float] Net income. (provider: fmp); - Consolidated Net Income. (provider: intrinio) + Consolidated Net Income. (provider: intrinio) depreciation_and_amortization : Optional[float] Depreciation and amortization. (provider: fmp) deferred_income_tax : Optional[float] @@ -1657,7 +1657,7 @@ def income( Gross profit. (provider: fmp, intrinio, polygon) gross_profit_margin : Optional[float] Gross profit margin. (provider: fmp); - Gross margin ratio. (provider: intrinio) + Gross margin ratio. (provider: intrinio) general_and_admin_expense : Optional[float] General and administrative expenses. (provider: fmp) research_and_development_expense : Optional[float] @@ -1676,15 +1676,15 @@ def income( Interest income. (provider: fmp) total_interest_expense : Optional[float] Total interest expenses. (provider: fmp, intrinio); - Interest Expense (provider: polygon) + Interest Expense (provider: polygon) depreciation_and_amortization : Optional[float] Depreciation and amortization. (provider: fmp, polygon) ebitda : Optional[float] EBITDA. (provider: fmp); - Earnings Before Interest, Taxes, Depreciation and Amortization. (provider: intrinio) + Earnings Before Interest, Taxes, Depreciation and Amortization. (provider: intrinio) ebitda_margin : Optional[float] EBITDA margin. (provider: fmp); - Margin on Earnings Before Interest, Taxes, Depreciation and Amortization. (provider: intrinio) + Margin on Earnings Before Interest, Taxes, Depreciation and Amortization. (provider: intrinio) total_operating_income : Optional[float] Total operating income. (provider: fmp, intrinio) operating_income_margin : Optional[float] @@ -1693,27 +1693,27 @@ def income( Total other income and expenses. (provider: fmp) total_pre_tax_income : Optional[float] Total pre-tax income. (provider: fmp, intrinio); - Income Before Tax (provider: polygon) + Income Before Tax (provider: polygon) pre_tax_income_margin : Optional[float] Pre-tax income margin. (provider: fmp, intrinio) income_tax_expense : Optional[float] Income tax expense. (provider: fmp, intrinio, polygon) consolidated_net_income : Optional[float] Consolidated net income. (provider: fmp, intrinio); - Net Income/Loss (provider: polygon) + Net Income/Loss (provider: polygon) net_income_margin : Optional[float] Net income margin. (provider: fmp) basic_earnings_per_share : Optional[float] Basic earnings per share. (provider: fmp, intrinio); - Earnings Per Share (provider: polygon) + Earnings Per Share (provider: polygon) diluted_earnings_per_share : Optional[float] Diluted earnings per share. (provider: fmp, intrinio, polygon) weighted_average_basic_shares_outstanding : Optional[float] Weighted average basic shares outstanding. (provider: fmp, intrinio); - Basic Average Shares (provider: polygon) + Basic Average Shares (provider: polygon) weighted_average_diluted_shares_outstanding : Optional[float] Weighted average diluted shares outstanding. (provider: fmp, intrinio); - Diluted Average Shares (provider: polygon) + Diluted Average Shares (provider: polygon) link : Optional[str] Link to the filing. (provider: fmp) final_link : Optional[str] @@ -1772,7 +1772,7 @@ def income( Other interest expense (provider: intrinio) net_interest_income : Optional[float] Net interest income (provider: intrinio); - Interest Income Net (provider: polygon) + Interest Income Net (provider: polygon) other_non_interest_income : Optional[float] Other non-interest income (provider: intrinio) investment_banking_income : Optional[float] @@ -1795,7 +1795,7 @@ def income( Other gains (provider: intrinio) non_operating_income : Optional[float] Non-operating income (provider: intrinio); - Non Operating Income/Loss (provider: polygon) + Non Operating Income/Loss (provider: polygon) other_income : Optional[float] Other income (provider: intrinio) other_revenue : Optional[float] @@ -1830,7 +1830,7 @@ def income( Net income attributable to noncontrolling interest (provider: intrinio) net_income_attributable_to_common_shareholders : Optional[float] Net income attributable to common shareholders (provider: intrinio); - Net Income/Loss Available To Common Stockholders Basic (provider: polygon) + Net Income/Loss Available To Common Stockholders Basic (provider: polygon) basic_and_diluted_earnings_per_share : Optional[float] Basic and diluted earnings per share (provider: intrinio) cash_dividends_to_common_per_share : Optional[float] @@ -2501,7 +2501,7 @@ def metrics( Capital expenditures per share (provider: fmp) beta : Optional[float] Beta relative to the broad market calculated on a rolling three-year basis. (provider: intrinio); - Beta relative to the broad market (5-year monthly). (provider: yfinance) + Beta relative to the broad market (5-year monthly). (provider: yfinance) volume : Optional[float] Volume (provider: intrinio) fifty_two_week_high : Optional[float] diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py index 1a79da00797d..b4dd83aa0b8e 100644 --- a/openbb_platform/openbb/package/equity_price.py +++ b/openbb_platform/openbb/package/equity_price.py @@ -71,7 +71,7 @@ def historical( no default. limit : Optional[Union[Annotated[int, Ge(ge=0)], int]] Number of days to look back (Only for interval 1d). (provider: fmp); - The number of data entries to return. (provider: polygon) + The number of data entries to return. (provider: polygon) start_time : Optional[datetime.time] Return intervals starting at the specified time on the `start_date` formatted as 'HH:MM:SS'. (provider: intrinio) end_time : Optional[datetime.time] @@ -84,7 +84,7 @@ def historical( Sort order of the data. (provider: polygon) adjusted : bool Output time series is adjusted by historical split and dividend events. (provider: polygon); - Adjust all OHLC data automatically. (provider: yfinance) + Adjust all OHLC data automatically. (provider: yfinance) prepost : bool Include Pre and Post market data. (provider: yfinance) include : bool @@ -126,8 +126,8 @@ def historical( Human readable format of the date. (provider: fmp) adj_close : Optional[float] The adjusted close price. (provider: fmp); - Adjusted closing price during the period. (provider: intrinio); - Adjusted closing price during the period. (provider: tiingo) + Adjusted closing price during the period. (provider: intrinio); + Adjusted closing price during the period. (provider: tiingo) unadjusted_volume : Optional[float] Unadjusted volume of the symbol. (provider: fmp) change : Optional[float] @@ -229,26 +229,26 @@ def nbbo( A specific date to get data for. Use bracketed the timestamp parameters to specify exact time ranges. (provider: polygon) timestamp_lt : Optional[Union[datetime.datetime, str]] - Query by datetime, less than. Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, - YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. - (provider: polygon) + Query by datetime, less than. Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, + YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. + (provider: polygon) timestamp_gt : Optional[Union[datetime.datetime, str]] - Query by datetime, greater than. Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, - YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. - (provider: polygon) + Query by datetime, greater than. Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, + YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. + (provider: polygon) timestamp_lte : Optional[Union[datetime.datetime, str]] - Query by datetime, less than or equal to. - Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, - YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. - (provider: polygon) + Query by datetime, less than or equal to. + Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, + YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. + (provider: polygon) timestamp_gte : Optional[Union[datetime.datetime, str]] - Query by datetime, greater than or equal to. - Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, - YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. - (provider: polygon) + Query by datetime, greater than or equal to. + Either a date with the format YYYY-MM-DD or a TZ-aware timestamp string, + YYYY-MM-DDTH:M:S.000000000-04:00". Include all nanoseconds and the 'T' between the day and hour. + (provider: polygon) Returns ------- @@ -272,9 +272,9 @@ def nbbo( The last ask price. ask_size : int - The ask size. This represents the number of round lot orders at the given ask price. - The normal round lot size is 100 shares. - An ask size of 2 means there are 200 shares available to purchase at the given ask price. + The ask size. This represents the number of round lot orders at the given ask price. + The normal round lot size is 100 shares. + An ask size of 2 means there are 200 shares available to purchase at the given ask price. bid_size : int The bid size in round lots. @@ -290,25 +290,25 @@ def nbbo( A list of indicator codes. (provider: polygon) sequence_num : Optional[int] - The sequence number represents the sequence in which message events happened. - These are increasing and unique per ticker symbol, but will not always be sequential - (e.g., 1, 2, 6, 9, 10, 11) - (provider: polygon) + The sequence number represents the sequence in which message events happened. + These are increasing and unique per ticker symbol, but will not always be sequential + (e.g., 1, 2, 6, 9, 10, 11) + (provider: polygon) participant_timestamp : Optional[datetime] - The nanosecond accuracy Participant/Exchange Unix Timestamp. - This is the timestamp of when the quote was actually generated at the exchange. - (provider: polygon) + The nanosecond accuracy Participant/Exchange Unix Timestamp. + This is the timestamp of when the quote was actually generated at the exchange. + (provider: polygon) sip_timestamp : Optional[datetime] - The nanosecond accuracy SIP Unix Timestamp. - This is the timestamp of when the SIP received this quote from the exchange which produced it. - (provider: polygon) + The nanosecond accuracy SIP Unix Timestamp. + This is the timestamp of when the SIP received this quote from the exchange which produced it. + (provider: polygon) trf_timestamp : Optional[datetime] - The nanosecond accuracy TRF (Trade Reporting Facility) Unix Timestamp. - This is the timestamp of when the trade reporting facility received this quote. - (provider: polygon) + The nanosecond accuracy TRF (Trade Reporting Facility) Unix Timestamp. + This is the timestamp of when the trade reporting facility received this quote. + (provider: polygon) Examples -------- diff --git a/openbb_platform/openbb/package/equity_shorts.py b/openbb_platform/openbb/package/equity_shorts.py index 2ba386a6caa7..23fcded89cfd 100644 --- a/openbb_platform/openbb/package/equity_shorts.py +++ b/openbb_platform/openbb/package/equity_shorts.py @@ -40,13 +40,13 @@ def fails_to_deliver( no default. limit : Optional[int] - Limit the number of reports to parse, from most recent. - Approximately 24 reports per year, going back to 2009. - (provider: sec) + Limit the number of reports to parse, from most recent. + Approximately 24 reports per year, going back to 2009. + (provider: sec) skip_reports : Optional[int] - Skip N number of reports from current. A value of 1 will skip the most recent report. - (provider: sec) + Skip N number of reports from current. A value of 1 will skip the most recent report. + (provider: sec) Returns ------- diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index 4296454311e5..73db0f3f3edd 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -290,7 +290,7 @@ def holdings( no default. date : Optional[Union[str, datetime.date]] A specific date to get data for. Entering a date will attempt to return the NPORT-P filing for the entered date. This needs to be _exactly_ the date of the filing. Use the holdings_date command/endpoint to find available filing dates for the ETF. (provider: fmp); - A specific date to get data for. The date represents the period ending. The date entered will return the closest filing. (provider: sec) + A specific date to get data for. The date represents the period ending. The date entered will return the closest filing. (provider: sec) cik : Optional[str] The CIK of the filing entity. Overrides symbol. (provider: fmp) use_cache : bool @@ -326,17 +326,17 @@ def holdings( The ISIN of the holding. (provider: fmp, sec) balance : Optional[int] The balance of the holding, in shares or units. (provider: fmp); - The balance of the holding. (provider: sec) + The balance of the holding. (provider: sec) units : Optional[Union[str, float]] The type of units. (provider: fmp); - The units of the holding. (provider: sec) + The units of the holding. (provider: sec) currency : Optional[str] The currency of the holding. (provider: fmp, sec) value : Optional[float] The value of the holding, in dollars. (provider: fmp, sec) weight : Optional[float] The weight of the holding, as a normalized percent. (provider: fmp); - The weight of the holding in ETF in %. (provider: sec) + The weight of the holding in ETF in %. (provider: sec) payoff_profile : Optional[str] The payoff profile of the holding. (provider: fmp, sec) asset_category : Optional[str] diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index f1bf615d2234..7e1db0c481c5 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -214,8 +214,8 @@ def market( Data granularity. (provider: fmp, yfinance) sort : Literal['asc', 'desc'] Sort the data in ascending or descending order. (provider: fmp); - Sort order. (provider: intrinio); - Sort order of the data. (provider: polygon) + Sort order. (provider: intrinio); + Sort order of the data. (provider: polygon) tag : Optional[str] Index tag. (provider: intrinio) type : Optional[str] diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index a5118aa54112..6bff7e8156dd 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -80,7 +80,7 @@ def company( Key to sort the news by. (provider: benzinga) order : Optional[Literal['asc', 'desc']] Order to sort the news by. (provider: benzinga); - Sort order of the articles. (provider: polygon) + Sort order of the articles. (provider: polygon) isin : Optional[str] The company's ISIN. (provider: benzinga) cusip : Optional[str] @@ -144,9 +144,9 @@ def company( Updated date of the news. (provider: benzinga) source : Optional[str] Name of the news source. (provider: fmp); - Source of the article. (provider: polygon); - News source. (provider: tiingo); - Source of the news article (provider: yfinance) + Source of the article. (provider: polygon); + News source. (provider: tiingo); + Source of the news article (provider: yfinance) amp_url : Optional[str] AMP URL. (provider: polygon) publisher : Optional[openbb_polygon.models.company_news.PolygonPublisher] From e00a0e350bd6e62958cdad72e829823e208bcdba Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 5 Mar 2024 16:48:52 +0000 Subject: [PATCH 036/133] remove circular import --- openbb_platform/core/openbb_core/app/model/__init__.py | 3 --- .../extensions/commodity/openbb_commodity/commodity_router.py | 4 +++- .../extensions/crypto/openbb_crypto/crypto_router.py | 4 +++- .../extensions/crypto/openbb_crypto/price/price_router.py | 4 +++- .../extensions/currency/openbb_currency/currency_router.py | 4 +++- .../extensions/currency/openbb_currency/price/price_router.py | 4 +++- .../derivatives/openbb_derivatives/futures/futures_router.py | 4 +++- .../derivatives/openbb_derivatives/options/options_router.py | 4 +++- .../econometrics/openbb_econometrics/econometrics_router.py | 2 +- .../extensions/economy/openbb_economy/economy_router.py | 4 +++- .../extensions/economy/openbb_economy/gdp/gdp_router.py | 4 +++- .../equity/openbb_equity/calendar/calendar_router.py | 4 +++- .../extensions/equity/openbb_equity/compare/compare_router.py | 4 +++- .../equity/openbb_equity/darkpool/darkpool_router.py | 4 +++- .../equity/openbb_equity/discovery/discovery_router.py | 4 +++- .../extensions/equity/openbb_equity/equity_router.py | 4 +++- .../equity/openbb_equity/estimates/estimates_router.py | 4 +++- .../equity/openbb_equity/fundamental/fundamental_router.py | 4 +++- .../equity/openbb_equity/ownership/ownership_router.py | 4 +++- .../extensions/equity/openbb_equity/price/price_router.py | 4 +++- .../extensions/equity/openbb_equity/shorts/shorts_router.py | 4 +++- .../extensions/etf/openbb_etf/discovery/discovery_router.py | 4 +++- openbb_platform/extensions/etf/openbb_etf/etf_router.py | 4 +++- .../openbb_fixedincome/corporate/corporate_router.py | 4 +++- .../fixedincome/openbb_fixedincome/fixedincome_router.py | 4 +++- .../openbb_fixedincome/government/government_router.py | 4 +++- .../fixedincome/openbb_fixedincome/rate/rate_router.py | 4 +++- .../fixedincome/openbb_fixedincome/spreads/spreads_router.py | 4 +++- openbb_platform/extensions/index/openbb_index/index_router.py | 4 +++- .../extensions/index/openbb_index/price/price_router.py | 4 +++- openbb_platform/extensions/news/openbb_news/news_router.py | 4 +++- .../openbb_quantitative/performance/performance_router.py | 2 +- .../quantitative/openbb_quantitative/quantitative_router.py | 2 +- .../openbb_quantitative/rolling/rolling_router.py | 2 +- .../quantitative/openbb_quantitative/stats/stats_router.py | 2 +- .../regulators/openbb_regulators/cftc/cftc_router.py | 4 +++- .../extensions/regulators/openbb_regulators/sec/sec_router.py | 4 +++- .../extensions/technical/openbb_technical/technical_router.py | 2 +- 38 files changed, 99 insertions(+), 40 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/__init__.py b/openbb_platform/core/openbb_core/app/model/__init__.py index e85119b2b96a..e69de29bb2d1 100644 --- a/openbb_platform/core/openbb_core/app/model/__init__.py +++ b/openbb_platform/core/openbb_core/app/model/__init__.py @@ -1,3 +0,0 @@ -from .command_context import CommandContext -from .example import APIEx, Example, PythonEx -from .obbject import OBBject diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index dc2ea243c816..2d490dfc893b 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -1,6 +1,8 @@ """The Commodity router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py index a652f901a981..145d2c4d9ec0 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py @@ -1,6 +1,8 @@ """Crypto Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index c22be0b49370..45f40844d1ca 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -1,7 +1,9 @@ # pylint: disable=W0613:unused-argument """Crypto Price Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index 7d09a967d43e..b5126d751032 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -1,6 +1,8 @@ """The Currency router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index af2281212e4f..037ce2323daa 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -1,7 +1,9 @@ """Price router for Currency.""" # pylint: disable=unused-argument -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index 73bb44cd9e8e..435c26b67362 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -1,6 +1,8 @@ """Futures Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index c7b6745ec675..62ac081ee5cc 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -1,6 +1,8 @@ """Options Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index d9efe6c15445..a772f0c98a3b 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -15,7 +15,7 @@ PooledOLS, RandomEffects, ) -from openbb_core.app.model import OBBject, PythonEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import basemodel_to_df, get_target_column, get_target_columns from openbb_core.provider.abstract.data import Data diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 64ee5b4a7921..bdece3840978 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -1,6 +1,8 @@ """Economy Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py index b0449c69c037..37c09854f71b 100644 --- a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py @@ -1,6 +1,8 @@ """Economy GDP Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py index e0b87b9a5266..92b0a76b5e11 100644 --- a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py @@ -1,6 +1,8 @@ """Calendar Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py index 4506149157c2..50a4a75e5edc 100644 --- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py @@ -1,7 +1,9 @@ # pylint: disable=W0613:unused-argument """Comparison Analysis Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py index a198ffee7396..b7a9f9ea2886 100644 --- a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py @@ -1,6 +1,8 @@ """Dark Pool Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index 708282a6fede..f1c1f8a92284 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -1,7 +1,9 @@ """Disc router for Equities.""" # pylint: disable=unused-argument -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/equity_router.py b/openbb_platform/extensions/equity/openbb_equity/equity_router.py index 8fe3ec9e242c..08bd7f2ea110 100644 --- a/openbb_platform/extensions/equity/openbb_equity/equity_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/equity_router.py @@ -1,6 +1,8 @@ """Equity Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index 43ec5141905d..a5d9ffaa3cdf 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -1,6 +1,8 @@ """Estimates Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index 3daf6539bf82..c04175cda4a5 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -2,7 +2,9 @@ """Fundamental Analysis Router.""" from openbb_core.app.deprecation import OpenBBDeprecationWarning -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index 2d24fff0396a..abdce2828769 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -1,6 +1,8 @@ """Ownership Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index ff41f63e58ff..e5ac1ecf1fbc 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -1,6 +1,8 @@ """Price Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index f6e876cc75f6..d917c1a8fd38 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -1,6 +1,8 @@ """Shorts Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py index 19fca43d1448..c77c5b98f316 100644 --- a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py @@ -1,6 +1,8 @@ """Disc router for ETFs.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index e0ab62b6508f..9657ac8128b9 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -1,6 +1,8 @@ """ETF Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index a3ab447caba8..3d02ee0f8571 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -1,6 +1,8 @@ """Fixed Income Corporate Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py index bfbe2fa64cde..e99d9b7cf0d3 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py @@ -2,7 +2,9 @@ # pylint: disable=W0613:unused-argument -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index 466b10f5bd3c..1fbaaa0ccad7 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -1,6 +1,8 @@ """Fixed Income Government Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index 81073ba0c671..b17f83cd3209 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -1,6 +1,8 @@ """Fixed Income Rate Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py index 880300ed6a2b..0a9f77fc1bdc 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py @@ -1,6 +1,8 @@ """Fixed Income Corporate Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index 4770960eb18c..21bb96e37676 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -1,7 +1,9 @@ """Index Router.""" from openbb_core.app.deprecation import OpenBBDeprecationWarning -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index 419200bb0ece..883427d5f4cc 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -1,6 +1,8 @@ """Price Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index 85b5dca91f07..2d3ba496f5ad 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -1,7 +1,9 @@ # pylint: disable=import-outside-toplevel, W0613:unused-argument """News Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 0ea93e17238a..b53a8f98534b 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -2,7 +2,7 @@ import numpy as np import pandas as pd -from openbb_core.app.model import OBBject, PythonEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 0d5b9eb4c061..7fc44407f2c3 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -3,7 +3,7 @@ from typing import List, Literal import pandas as pd -from openbb_core.app.model import OBBject, PythonEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 26cb576ae125..575b521c7e05 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model import OBBject, PythonEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index e0997b197de0..be2c83b47fd5 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model import OBBject, PythonEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 6a57f7c08e48..9159021d5c64 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -1,7 +1,9 @@ # pylint: disable=W0613:unused-argument """Commodity Futures Trading Commission (CFTC) Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 561eaddc73aa..67a2f35fa5dc 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -1,7 +1,9 @@ # pylint: disable=W0613:unused-argument """SEC Router.""" -from openbb_core.app.model import APIEx, CommandContext, OBBject, PythonEx +from openbb_core.app.model.command_context import CommandContext +from openbb_core.app.model.example import APIEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, ProviderChoices, diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index e11f0e6e79b7..abc23dcbf8ae 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -5,7 +5,7 @@ import pandas as pd import pandas_ta as ta -from openbb_core.app.model import OBBject, PythonEx +from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( basemodel_to_df, From b906f79f4d42955d786bc76fecd9d12e57ecfcb7 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 5 Mar 2024 16:51:45 +0000 Subject: [PATCH 037/133] add missing import --- .../econometrics/openbb_econometrics/econometrics_router.py | 1 + .../openbb_quantitative/performance/performance_router.py | 1 + .../quantitative/openbb_quantitative/quantitative_router.py | 1 + .../quantitative/openbb_quantitative/rolling/rolling_router.py | 1 + .../quantitative/openbb_quantitative/stats/stats_router.py | 1 + .../extensions/regulators/openbb_regulators/sec/sec_router.py | 2 +- .../extensions/technical/openbb_technical/technical_router.py | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index a772f0c98a3b..b983e95d5d2f 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -15,6 +15,7 @@ PooledOLS, RandomEffects, ) +from openbb_core.app.model.example import PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import basemodel_to_df, get_target_column, get_target_columns diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index b53a8f98534b..6f935aa4f3a8 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -2,6 +2,7 @@ import numpy as np import pandas as pd +from openbb_core.app.model.example import PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 7fc44407f2c3..6d07396cd2fd 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -3,6 +3,7 @@ from typing import List, Literal import pandas as pd +from openbb_core.app.model.example import PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 575b521c7e05..6db047e06a22 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -3,6 +3,7 @@ from typing import List import pandas as pd +from openbb_core.app.model.example import PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index be2c83b47fd5..9a191cdd3406 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -3,6 +3,7 @@ from typing import List import pandas as pd +from openbb_core.app.model.example import PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 67a2f35fa5dc..342af899ef4c 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -2,7 +2,7 @@ """SEC Router.""" from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import APIEx +from openbb_core.app.model.example import APIEx, PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index abc23dcbf8ae..0e2a79756b7a 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -5,6 +5,7 @@ import pandas as pd import pandas_ta as ta +from openbb_core.app.model.example import PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( From d194791e04ebbc0d4b7f124799c7969522c15ad7 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 12:22:29 +0000 Subject: [PATCH 038/133] pass indent as object attr --- .../openbb_core/app/static/package_builder.py | 110 ++++++++---------- 1 file changed, 51 insertions(+), 59 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index dcc4be84b2a4..8b80a298a8f0 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -707,19 +707,16 @@ def build_command_method_doc( ): """Build the command method docstring.""" doc = func.__doc__ - indent = 2 tab = " " - indentation = tab * indent - doc = DocstringGenerator.generate( + indent = 2 + doc = DocstringGenerator(tab, indent).generate( path=path, func=func, formatted_params=formatted_params, model_name=model_name, examples=examples, - indentation=indentation, - tab=tab, ) - code = f'{indentation}"""{doc}{indentation}""" # noqa: E501\n\n' if doc else "" + code = f'{tab*indent}"""{doc}{tab*indent}""" # noqa: E501\n\n' if doc else "" return code @@ -834,66 +831,69 @@ class DocstringGenerator: provider_interface = ProviderInterface() - @staticmethod + def __init__(self, tab: str = "", indent: int = 0): + """Initialize the docstring generator.""" + self.tab = tab + self.base_indentation = tab * indent + + def indent(self, n: int) -> str: + """Indent the string.""" + return self.base_indentation + self.tab * n + def get_OBBject_description( + self, results_type: str, providers: Optional[str], - indentation: str = "", - tab: str = " ", ) -> str: """Get the command output description.""" available_providers = providers or "Optional[str]" obbject_description = ( - f"{indentation}OBBject\n" - f"{indentation+tab}results : {results_type}\n" - f"{indentation+2*tab}Serializable results.\n" - f"{indentation+tab}provider : {available_providers}\n" - f"{indentation+2*tab}Provider name.\n" - f"{indentation+tab}warnings : Optional[List[Warning_]]\n" - f"{indentation+2*tab}List of warnings.\n" - f"{indentation+tab}chart : Optional[Chart]\n" - f"{indentation+2*tab}Chart object.\n" - f"{indentation+tab}extra : Dict[str, Any]\n" - f"{indentation+2*tab}Extra info.\n" + f"{self.indent(0)}OBBject\n" + f"{self.indent(1)}results : {results_type}\n" + f"{self.indent(2)}Serializable results.\n" + f"{self.indent(1)}provider : {available_providers}\n" + f"{self.indent(2)}Provider name.\n" + f"{self.indent(1)}warnings : Optional[List[Warning_]]\n" + f"{self.indent(2)}List of warnings.\n" + f"{self.indent(1)}chart : Optional[Chart]\n" + f"{self.indent(2)}Chart object.\n" + f"{self.indent(1)}extra : Dict[str, Any]\n" + f"{self.indent(2)}Extra info.\n" ) obbject_description = obbject_description.replace("NoneType", "None") return obbject_description - @staticmethod def append_examples( + self, func_path: str, func_params: Dict[str, Field], examples: Optional[List[Example]], - indentation: str = "", ) -> str: """Get the example section from the examples.""" if examples: - doc = f"\n{indentation}Examples\n" - doc += f"{indentation}--------\n" - doc += f"{indentation}>>> from openbb import obb\n" + doc = f"\n{self.indent(0)}Examples\n" + doc += f"{self.indent(0)}--------\n" + doc += f"{self.indent(0)}>>> from openbb import obb\n" for e in examples: doc += e.to_python( func_path=func_path, func_params=func_params, - indentation=indentation, + indentation=self.indent(0), ) return doc return "" - @classmethod def generate_model_docstring( - cls, + self, model_name: str, summary: str, explicit_params: dict, kwarg_params: dict, returns: Dict[str, FieldInfo], results_type: str, - indentation: str = "", - tab: str = " ", ) -> str: """Create the docstring for model.""" @@ -909,13 +909,13 @@ def format_type(type_: str, char_limit: Optional[int] = None) -> str: def format_description(description: str) -> str: """Format description in docstrings.""" - description = description.replace("\n", f"\n{indentation}") + description = description.replace("\n", f"\n{self.indent(0)}") return description - docstring = summary.strip("\n").replace("\n ", f"\n{indentation}") + docstring = summary.strip("\n").replace("\n ", f"\n{self.indent(0)}") docstring += "\n\n" - docstring += f"{indentation}Parameters\n" - docstring += f"{indentation}----------\n" + docstring += f"{self.indent(0)}Parameters\n" + docstring += f"{self.indent(0)}----------\n" # Explicit parameters for param_name, param in explicit_params.items(): @@ -938,8 +938,8 @@ def format_description(description: str) -> str: ) type_str = format_type(type_, char_limit=79) # type: ignore - docstring += f"{indentation}{param_name} : {type_str}\n" - docstring += f"{indentation+tab}{format_description(description)}\n" + docstring += f"{self.indent(0)}{param_name} : {type_str}\n" + docstring += f"{self.indent(1)}{format_description(description)}\n" # Kwargs for param_name, param in kwarg_params.items(): @@ -951,24 +951,22 @@ def format_description(description: str) -> str: description = getattr(param.default, "description", "") - docstring += f"{indentation}{param_name} : {type_}\n" - docstring += f"{indentation+tab}{format_description(description)}\n" + docstring += f"{self.indent(0)}{param_name} : {type_}\n" + docstring += f"{self.indent(1)}{format_description(description)}\n" # Returns docstring += "\n" - docstring += f"{indentation}Returns\n" - docstring += f"{indentation}-------\n" + docstring += f"{self.indent(0)}Returns\n" + docstring += f"{self.indent(0)}-------\n" provider_param = explicit_params.get("provider", None) available_providers = getattr(provider_param, "_annotation", None) - docstring += cls.get_OBBject_description( - results_type, available_providers, indentation, tab - ) + docstring += self.get_OBBject_description(results_type, available_providers) # Schema underline = "-" * len(model_name) - docstring += f"\n{indentation}{model_name}\n" - docstring += f"{indentation}{underline}\n" + docstring += f"\n{self.indent(0)}{model_name}\n" + docstring += f"{self.indent(0)}{underline}\n" for name, field in returns.items(): try: @@ -999,27 +997,24 @@ def format_description(description: str) -> str: description = getattr(field, "description", "") - docstring += f"{indentation}{field.alias or name} : {field_type}\n" - docstring += f"{indentation+tab}{format_description(description)}\n" + docstring += f"{self.indent(0)}{field.alias or name} : {field_type}\n" + docstring += f"{self.indent(1)}{format_description(description)}\n" return docstring - @classmethod def generate( - cls, + self, path: str, func: Callable, formatted_params: OrderedDict[str, Parameter], model_name: Optional[str] = None, examples: Optional[List[Example]] = None, - indentation: str = "", - tab: str = " ", ) -> Optional[str]: """Generate the docstring for the function.""" doc = func.__doc__ or "" func_params = {} if model_name: - params = cls.provider_interface.params.get(model_name, {}) - return_schema = cls.provider_interface.return_schema.get(model_name, None) + params = self.provider_interface.params.get(model_name, {}) + return_schema = self.provider_interface.return_schema.get(model_name, None) if params and return_schema: explicit_dict = dict(formatted_params) explicit_dict.pop("extra_params", None) @@ -1033,25 +1028,22 @@ def generate( if hasattr(results_type, "results_type_repr"): results_type = results_type.results_type_repr() - doc = cls.generate_model_docstring( + doc = self.generate_model_docstring( model_name=model_name, summary=func.__doc__ or "", explicit_params=explicit_dict, kwarg_params=kwarg_params, returns=returns, results_type=results_type, - indentation=indentation, - tab=tab, ) else: - doc = doc.replace("\n ", f"\n{indentation}") + doc = doc.replace("\n ", f"\n{self.indent(0)}") if doc and examples: - doc += cls.append_examples( + doc += self.append_examples( path.replace("/", "."), func_params, examples, - indentation, ) return doc From 936982475d4f99a413faf8316d2e8b7661b1d296 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 12:24:11 +0000 Subject: [PATCH 039/133] doc --- openbb_platform/core/openbb_core/app/static/package_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 8b80a298a8f0..64bc07b8ed01 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -837,7 +837,7 @@ def __init__(self, tab: str = "", indent: int = 0): self.base_indentation = tab * indent def indent(self, n: int) -> str: - """Indent the string.""" + """Create n indentation space.""" return self.base_indentation + self.tab * n def get_OBBject_description( From 71cdd614791e6bd987701b8d6742a86325e955ca Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 12:24:44 +0000 Subject: [PATCH 040/133] doc --- openbb_platform/core/openbb_core/app/static/package_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 64bc07b8ed01..17c10d7aa028 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -837,7 +837,7 @@ def __init__(self, tab: str = "", indent: int = 0): self.base_indentation = tab * indent def indent(self, n: int) -> str: - """Create n indentation space.""" + """Create n indentation space on top of the base indentation.""" return self.base_indentation + self.tab * n def get_OBBject_description( From f6f442f3ebcb75d3b0fa787b85bbeb3f1498c711 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 12:38:40 +0000 Subject: [PATCH 041/133] this looks better --- .../openbb_core/app/static/package_builder.py | 97 ++++++++++--------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 17c10d7aa028..c141f2c91c5a 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -61,6 +61,14 @@ Data, ) +TAB = " " +BASE_INDENTATION = TAB * 2 + + +def indent(n: int) -> str: + """Create n indentation space on top of the base indentation.""" + return BASE_INDENTATION + TAB * n + class PackageBuilder: """Build the extension package for the Platform.""" @@ -831,17 +839,8 @@ class DocstringGenerator: provider_interface = ProviderInterface() - def __init__(self, tab: str = "", indent: int = 0): - """Initialize the docstring generator.""" - self.tab = tab - self.base_indentation = tab * indent - - def indent(self, n: int) -> str: - """Create n indentation space on top of the base indentation.""" - return self.base_indentation + self.tab * n - + @staticmethod def get_OBBject_description( - self, results_type: str, providers: Optional[str], ) -> str: @@ -849,45 +848,46 @@ def get_OBBject_description( available_providers = providers or "Optional[str]" obbject_description = ( - f"{self.indent(0)}OBBject\n" - f"{self.indent(1)}results : {results_type}\n" - f"{self.indent(2)}Serializable results.\n" - f"{self.indent(1)}provider : {available_providers}\n" - f"{self.indent(2)}Provider name.\n" - f"{self.indent(1)}warnings : Optional[List[Warning_]]\n" - f"{self.indent(2)}List of warnings.\n" - f"{self.indent(1)}chart : Optional[Chart]\n" - f"{self.indent(2)}Chart object.\n" - f"{self.indent(1)}extra : Dict[str, Any]\n" - f"{self.indent(2)}Extra info.\n" + f"{indent(0)}OBBject\n" + f"{indent(1)}results : {results_type}\n" + f"{indent(2)}Serializable results.\n" + f"{indent(1)}provider : {available_providers}\n" + f"{indent(2)}Provider name.\n" + f"{indent(1)}warnings : Optional[List[Warning_]]\n" + f"{indent(2)}List of warnings.\n" + f"{indent(1)}chart : Optional[Chart]\n" + f"{indent(2)}Chart object.\n" + f"{indent(1)}extra : Dict[str, Any]\n" + f"{indent(2)}Extra info.\n" ) obbject_description = obbject_description.replace("NoneType", "None") return obbject_description + @staticmethod def append_examples( - self, func_path: str, func_params: Dict[str, Field], examples: Optional[List[Example]], ) -> str: """Get the example section from the examples.""" if examples: - doc = f"\n{self.indent(0)}Examples\n" - doc += f"{self.indent(0)}--------\n" - doc += f"{self.indent(0)}>>> from openbb import obb\n" + doc = f"\n{indent(0)}Examples\n" + doc += f"{indent(0)}--------\n" + doc += f"{indent(0)}>>> from openbb import obb\n" for e in examples: doc += e.to_python( func_path=func_path, func_params=func_params, - indentation=self.indent(0), + indentation=indent(0), ) return doc return "" + @classmethod def generate_model_docstring( - self, + cls, model_name: str, summary: str, explicit_params: dict, @@ -909,13 +909,13 @@ def format_type(type_: str, char_limit: Optional[int] = None) -> str: def format_description(description: str) -> str: """Format description in docstrings.""" - description = description.replace("\n", f"\n{self.indent(0)}") + description = description.replace("\n", f"\n{indent(0)}") return description - docstring = summary.strip("\n").replace("\n ", f"\n{self.indent(0)}") + docstring = summary.strip("\n").replace("\n ", f"\n{indent(0)}") docstring += "\n\n" - docstring += f"{self.indent(0)}Parameters\n" - docstring += f"{self.indent(0)}----------\n" + docstring += f"{indent(0)}Parameters\n" + docstring += f"{indent(0)}----------\n" # Explicit parameters for param_name, param in explicit_params.items(): @@ -938,8 +938,8 @@ def format_description(description: str) -> str: ) type_str = format_type(type_, char_limit=79) # type: ignore - docstring += f"{self.indent(0)}{param_name} : {type_str}\n" - docstring += f"{self.indent(1)}{format_description(description)}\n" + docstring += f"{indent(0)}{param_name} : {type_str}\n" + docstring += f"{indent(1)}{format_description(description)}\n" # Kwargs for param_name, param in kwarg_params.items(): @@ -951,22 +951,22 @@ def format_description(description: str) -> str: description = getattr(param.default, "description", "") - docstring += f"{self.indent(0)}{param_name} : {type_}\n" - docstring += f"{self.indent(1)}{format_description(description)}\n" + docstring += f"{indent(0)}{param_name} : {type_}\n" + docstring += f"{indent(1)}{format_description(description)}\n" # Returns docstring += "\n" - docstring += f"{self.indent(0)}Returns\n" - docstring += f"{self.indent(0)}-------\n" + docstring += f"{indent(0)}Returns\n" + docstring += f"{indent(0)}-------\n" provider_param = explicit_params.get("provider", None) available_providers = getattr(provider_param, "_annotation", None) - docstring += self.get_OBBject_description(results_type, available_providers) + docstring += cls.get_OBBject_description(results_type, available_providers) # Schema underline = "-" * len(model_name) - docstring += f"\n{self.indent(0)}{model_name}\n" - docstring += f"{self.indent(0)}{underline}\n" + docstring += f"\n{indent(0)}{model_name}\n" + docstring += f"{indent(0)}{underline}\n" for name, field in returns.items(): try: @@ -997,12 +997,13 @@ def format_description(description: str) -> str: description = getattr(field, "description", "") - docstring += f"{self.indent(0)}{field.alias or name} : {field_type}\n" - docstring += f"{self.indent(1)}{format_description(description)}\n" + docstring += f"{indent(0)}{field.alias or name} : {field_type}\n" + docstring += f"{indent(1)}{format_description(description)}\n" return docstring + @classmethod def generate( - self, + cls, path: str, func: Callable, formatted_params: OrderedDict[str, Parameter], @@ -1013,8 +1014,8 @@ def generate( doc = func.__doc__ or "" func_params = {} if model_name: - params = self.provider_interface.params.get(model_name, {}) - return_schema = self.provider_interface.return_schema.get(model_name, None) + params = cls.provider_interface.params.get(model_name, {}) + return_schema = cls.provider_interface.return_schema.get(model_name, None) if params and return_schema: explicit_dict = dict(formatted_params) explicit_dict.pop("extra_params", None) @@ -1028,7 +1029,7 @@ def generate( if hasattr(results_type, "results_type_repr"): results_type = results_type.results_type_repr() - doc = self.generate_model_docstring( + doc = cls.generate_model_docstring( model_name=model_name, summary=func.__doc__ or "", explicit_params=explicit_dict, @@ -1037,10 +1038,10 @@ def generate( results_type=results_type, ) else: - doc = doc.replace("\n ", f"\n{self.indent(0)}") + doc = doc.replace("\n ", f"\n{indent(0)}") if doc and examples: - doc += self.append_examples( + doc += cls.append_examples( path.replace("/", "."), func_params, examples, From 26aa114f4611c0b5f4c61eabb988d115b6e70655 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 12:39:53 +0000 Subject: [PATCH 042/133] forgot this --- .../core/openbb_core/app/static/package_builder.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index c141f2c91c5a..f79cd94352c4 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -715,16 +715,14 @@ def build_command_method_doc( ): """Build the command method docstring.""" doc = func.__doc__ - tab = " " - indent = 2 - doc = DocstringGenerator(tab, indent).generate( + doc = DocstringGenerator.generate( path=path, func=func, formatted_params=formatted_params, model_name=model_name, examples=examples, ) - code = f'{tab*indent}"""{doc}{tab*indent}""" # noqa: E501\n\n' if doc else "" + code = f'{indent(0)}"""{doc}{indent(0)}""" # noqa: E501\n\n' if doc else "" return code From c93a7ab88d75ab984fc9ac0881b8295e7d7ea753 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 12:47:09 +0000 Subject: [PATCH 043/133] fix: new examples adapted --- .../openbb_currency/currency_router.py | 12 +++++--- .../ownership/ownership_router.py | 30 ++++++++++++------- openbb_platform/openbb/package/currency.py | 8 ++--- .../openbb/package/equity_fundamental.py | 8 ++--- .../openbb/package/equity_ownership.py | 17 ++++++----- 5 files changed, 44 insertions(+), 31 deletions(-) diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index 90932b361f12..c8dfaf088b6e 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -80,11 +80,15 @@ async def reference_rates( @router.command( model="CurrencySnapshots", - exclude_auto_examples=True, examples=[ - "obb.currency.snapshots(", - 'provider="fmp", base="USD,XAU", counter_currencies="EUR,JPY,GBP", quote_type="indirect"', - ")", + APIEx( + parameters={ + "provider": "fmp", + "base": "USD,XAU", + "counter_currencies": "EUR,JPY,GBP", + "quote_type": "indirect", + } + ), ], ) async def snapshots( diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index a1ffd8d29e65..a9341c7f6baf 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -1,7 +1,7 @@ """Ownership Router.""" from openbb_core.app.model.command_context import CommandContext -from openbb_core.app.model.example import APIEx +from openbb_core.app.model.example import APIEx, PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.provider_interface import ( ExtraParams, @@ -73,16 +73,26 @@ async def share_statistics( @router.command( model="Form13FHR", - exclude_auto_examples=True, examples=[ - "### Enter the symbol as either the stock ticker or the CIK number as a string. ###", - 'obb.equity.ownership.form_13f(symbol="NVDA").to_df()', - "### Enter a date (calendar quarter ending) for a specific report. ###", - 'obb.equity.ownership.form_13f(symbol="BRK-A", date="2016-09-30")', - "### Use the `limit` parameter to return N number of reports from the most recent. ###", - "### Example finding Michael Burry's filings. ###", - 'cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik', - "obb.equity.ownership.form_13f(cik, limit=2).to_df()", + APIEx( + description="Enter the symbol as either the stock ticker or the CIK number as a string.", + parameters={"symbol": "NVDA"}, + ), + APIEx( + description="Enter a date (calendar quarter ending) for a specific report.", + parameters={"symbol": "BRK-A", "date": "2016-09-30"}, + ), + APIEx( + description="Use the `limit` parameter to return N number of reports from the most recent.", + parameters={"symbol": "AAPL", "limit": 2}, + ), + PythonEx( + description="Example finding Michael Burry's filings.", + code=[ + 'cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik', + "obb.equity.ownership.form_13f(cik, limit=2).to_df()", + ], + ), ], ) async def form_13f( diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index df78a15f405e..d6a2f7d239f1 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -229,12 +229,10 @@ def snapshots( last_rate_timestamp : Optional[datetime] The timestamp of the last rate. (provider: fmp) - Example - ------- + Examples + -------- >>> from openbb import obb - >>> obb.currency.snapshots( - >>> provider="fmp", base="USD,XAU", counter_currencies="EUR,JPY,GBP", quote_type="indirect" - >>> ) + >>> obb.currency.snapshots(provider='fmp', base='USD,XAU', counter_currencies='EUR,JPY,GBP', quote_type='indirect') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index cc707b3eafa1..bbebc70d3279 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -708,6 +708,10 @@ def cash( Link to the filing. (provider: fmp) final_link : Optional[str] Link to the filing document. (provider: fmp) + net_income_continuing_operations : Optional[float] + Net Income (Continuing Operations) (provider: intrinio) + net_income_discontinued_operations : Optional[float] + Net Income (Discontinued Operations) (provider: intrinio) provision_for_loan_losses : Optional[float] Provision for Loan Losses (provider: intrinio) provision_for_credit_losses : Optional[float] @@ -726,10 +730,6 @@ def cash( Net Cash from Continuing Operating Activities (provider: intrinio) net_cash_from_discontinued_operating_activities : Optional[float] Net Cash from Discontinued Operating Activities (provider: intrinio) - net_income_continuing_operations : Optional[float] - Net Income (Continuing Operations) (provider: intrinio) - net_income_discontinued_operations : Optional[float] - Net Income (Discontinued Operations) (provider: intrinio) divestitures : Optional[float] Divestitures (provider: intrinio) sale_of_property_plant_and_equipment : Optional[float] diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index 000f20fdd73f..86727c0444c1 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -110,15 +110,16 @@ def form_13f( weight : Optional[float] The weight of the security relative to the market value of all securities in the filing , as a normalized percent. (provider: sec) - Example - ------- + Examples + -------- >>> from openbb import obb - >>> ### Enter the symbol as either the stock ticker or the CIK number as a string. ### - >>> obb.equity.ownership.form_13f(symbol="NVDA").to_df() - >>> ### Enter a date (calendar quarter ending) for a specific report. ### - >>> obb.equity.ownership.form_13f(symbol="BRK-A", date="2016-09-30") - >>> ### Use the `limit` parameter to return N number of reports from the most recent. ### - >>> ### Example finding Michael Burry's filings. ### + >>> # Enter the symbol as either the stock ticker or the CIK number as a string. + >>> obb.equity.ownership.form_13f(symbol='NVDA') + >>> # Enter a date (calendar quarter ending) for a specific report. + >>> obb.equity.ownership.form_13f(symbol='BRK-A', date='2016-09-30') + >>> # Use the `limit` parameter to return N number of reports from the most recent. + >>> obb.equity.ownership.form_13f(symbol='AAPL', limit=2) + >>> # Example finding Michael Burry's filings. >>> cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik >>> obb.equity.ownership.form_13f(cik, limit=2).to_df() """ # noqa: E501 From 55d199d4d68f23800d5d5d55c379e7e7f4ba31ab Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 12:50:48 +0000 Subject: [PATCH 044/133] fix prev commit --- .../equity/openbb_equity/ownership/ownership_router.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index a9341c7f6baf..19f9169f8331 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -82,14 +82,11 @@ async def share_statistics( description="Enter a date (calendar quarter ending) for a specific report.", parameters={"symbol": "BRK-A", "date": "2016-09-30"}, ), - APIEx( - description="Use the `limit` parameter to return N number of reports from the most recent.", - parameters={"symbol": "AAPL", "limit": 2}, - ), PythonEx( description="Example finding Michael Burry's filings.", code=[ 'cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik', + '# Use the `limit` parameter to return N number of reports from the most recent.' "obb.equity.ownership.form_13f(cik, limit=2).to_df()", ], ), From 342e9777ecf5e9a5adc2444807be05ad65360f72 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 13:01:07 +0000 Subject: [PATCH 045/133] avoid future problems --- .../core/openbb_core/app/model/example.py | 13 +++++++++---- .../openbb_equity/ownership/ownership_router.py | 2 +- .../corporate/corporate_router.py | 2 +- openbb_platform/openbb/package/equity_ownership.py | 4 +--- .../openbb/package/fixedincome_corporate.py | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index dd1f4bf7daa2..fc1d4621f149 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,8 +1,8 @@ from abc import abstractmethod from dataclasses import Field -from typing import Any, Dict, List, Literal, Optional +from typing import Dict, List, Literal, Optional, Union -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, computed_field class Example(BaseModel): @@ -24,12 +24,17 @@ class APIEx(Example): """API Example model.""" scope: Literal["api"] = "api" - parameters: Dict[str, Any] + parameters: Dict[str, Union[str, int, float, bool, None]] + @computed_field # type: ignore[misc] @property def provider(self) -> Optional[str]: """Return the provider from the parameters.""" - return self.parameters.get("provider") + if provider := self.parameters.get("provider"): + if isinstance(provider, str): + return provider + raise ValueError(f"Provider must be a string, not {type(provider)}") + return None def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index 19f9169f8331..09677f91748c 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -86,7 +86,7 @@ async def share_statistics( description="Example finding Michael Burry's filings.", code=[ 'cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik', - '# Use the `limit` parameter to return N number of reports from the most recent.' + "# Use the `limit` parameter to return N number of reports from the most recent." "obb.equity.ownership.form_13f(cik, limit=2).to_df()", ], ), diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index 3d02ee0f8571..8d4b9c27709a 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -79,7 +79,7 @@ async def hqm( @router.command( model="SpotRate", - examples=[APIEx(parameters={"maturity": [10, 20, 30, 50]})], + examples=[APIEx(parameters={"maturity": "10,20,30,50"})], ) async def spot_rates( cc: CommandContext, diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index 86727c0444c1..04c5c42b6aad 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -117,11 +117,9 @@ def form_13f( >>> obb.equity.ownership.form_13f(symbol='NVDA') >>> # Enter a date (calendar quarter ending) for a specific report. >>> obb.equity.ownership.form_13f(symbol='BRK-A', date='2016-09-30') - >>> # Use the `limit` parameter to return N number of reports from the most recent. - >>> obb.equity.ownership.form_13f(symbol='AAPL', limit=2) >>> # Example finding Michael Burry's filings. >>> cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik - >>> obb.equity.ownership.form_13f(cik, limit=2).to_df() + >>> # Use the `limit` parameter to return N number of reports from the most recent.obb.equity.ownership.form_13f(cik, limit=2).to_df() """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index fa7cbf663708..425b3616990a 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -475,7 +475,7 @@ def spot_rates( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.corporate.spot_rates(maturity=[10, 20, 30, 50]) + >>> obb.fixedincome.corporate.spot_rates(maturity=10,20,30,50) """ # noqa: E501 return self._run( From f5f1fe5daeb1f67457d8a881218e30d394197d3e Mon Sep 17 00:00:00 2001 From: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Date: Wed, 6 Mar 2024 13:02:43 +0000 Subject: [PATCH 046/133] Update ownership_router.py --- .../equity/openbb_equity/ownership/ownership_router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index 09677f91748c..bc5346f50bc4 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -86,7 +86,7 @@ async def share_statistics( description="Example finding Michael Burry's filings.", code=[ 'cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik', - "# Use the `limit` parameter to return N number of reports from the most recent." + "# Use the `limit` parameter to return N number of reports from the most recent.", "obb.equity.ownership.form_13f(cik, limit=2).to_df()", ], ), From 98f236876f6e0df2ccb36263b2de08835d5c0bfc Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 13:07:20 +0000 Subject: [PATCH 047/133] rebuild + remove todo --- openbb_platform/core/openbb_core/app/model/example.py | 3 --- openbb_platform/openbb/package/equity_ownership.py | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index fc1d4621f149..1f1efa3b07b2 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -50,9 +50,6 @@ def to_python(self, **kwargs) -> str: for k, v in self.parameters.items(): if k in func_params and (field := func_params.get(k)): field_type_str = str(field.type) - # TODO: Handle types better, some edge cases - # like Union[str, List[str]] will be stringified - # even if the type is a list if any(t in field_type_str for t in ["int", "float", "bool"]): eg += f"{k}={v}, " else: diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index 04c5c42b6aad..813170284442 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -119,7 +119,8 @@ def form_13f( >>> obb.equity.ownership.form_13f(symbol='BRK-A', date='2016-09-30') >>> # Example finding Michael Burry's filings. >>> cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik - >>> # Use the `limit` parameter to return N number of reports from the most recent.obb.equity.ownership.form_13f(cik, limit=2).to_df() + >>> # Use the `limit` parameter to return N number of reports from the most recent. + >>> obb.equity.ownership.form_13f(cik, limit=2).to_df() """ # noqa: E501 return self._run( From 75f466e2ab4057901197ba9863fbf5b6127c94e2 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 13:21:03 +0000 Subject: [PATCH 048/133] make description mandatory for python examples --- .../core/openbb_core/app/model/example.py | 5 ++-- .../econometrics_router.py | 10 ++++++- .../performance/performance_router.py | 3 +++ .../quantitative_router.py | 2 ++ .../rolling/rolling_router.py | 6 +++++ .../openbb_quantitative/stats/stats_router.py | 6 +++++ .../openbb_regulators/sec/sec_router.py | 2 +- .../openbb_technical/technical_router.py | 26 +++++++++++++++++++ .../openbb/package/regulators_sec.py | 2 +- 9 files changed, 56 insertions(+), 6 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 1f1efa3b07b2..9c8b1cc41da7 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -9,9 +9,6 @@ class Example(BaseModel): """Example model.""" scope: str - description: Optional[str] = ( - None # Should this be required? Would help to create example titles - ) model_config = ConfigDict(validate_assignment=True) @@ -24,6 +21,7 @@ class APIEx(Example): """API Example model.""" scope: Literal["api"] = "api" + description: Optional[str] = None parameters: Dict[str, Union[str, int, float, bool, None]] @computed_field # type: ignore[misc] @@ -65,6 +63,7 @@ class PythonEx(Example): """Python Example model.""" scope: Literal["python"] = "python" + description: str code: List[str] def to_python(self, **kwargs) -> str: diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index b983e95d5d2f..c61f8fee8a05 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -34,10 +34,11 @@ methods=["POST"], examples=[ PythonEx( + description="Get the correlation matrix of a dataset.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.econometrics.correlation_matrix(data=stock_data)", - ] + ], ) ], ) @@ -80,6 +81,7 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: include_in_schema=False, examples=[ PythonEx( + description="Perform Ordinary Least Squares (OLS) regression.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.ols_regression(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', @@ -124,6 +126,7 @@ def ols_regression( methods=["POST"], examples=[ PythonEx( + description="Perform Ordinary Least Squares (OLS) regression and return the summary.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', @@ -201,6 +204,7 @@ def ols_regression_summary( methods=["POST"], examples=[ PythonEx( + description="Perform Durbin-Watson test for autocorrelation.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', @@ -247,6 +251,7 @@ def autocorrelation( methods=["POST"], examples=[ PythonEx( + description="Perform Breusch-Godfrey Lagrange Multiplier tests for residual autocorrelation.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', @@ -306,6 +311,7 @@ def residual_autocorrelation( methods=["POST"], examples=[ PythonEx( + description="Perform co-integration test between two timeseries.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.cointegration(data=stock_data, columns=["open", "close"])', @@ -369,6 +375,7 @@ def cointegration( methods=["POST"], examples=[ PythonEx( + description="Perform Granger causality test to determine if X 'causes' y.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.causality(data=stock_data, y_column="close", x_column="open")', @@ -430,6 +437,7 @@ def causality( methods=["POST"], examples=[ PythonEx( + description="Perform Augmented Dickey-Fuller (ADF) unit root test.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.unit_root(data=stock_data, column="close")', diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 6f935aa4f3a8..2a20fff54454 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -24,6 +24,7 @@ methods=["POST"], examples=[ PythonEx( + description="Get Omega Ratio.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -87,6 +88,7 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: methods=["POST"], examples=[ PythonEx( + description="Get Rolling Sharpe Ratio.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -145,6 +147,7 @@ def sharpe_ratio( methods=["POST"], examples=[ PythonEx( + description="Get Rolling Sortino Ratio.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 6d07396cd2fd..c6afe6583de7 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -40,6 +40,7 @@ methods=["POST"], examples=[ PythonEx( + description="Get Normality Statistics.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.quantitative.normality(data=stock_data, target='close')", @@ -94,6 +95,7 @@ def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: methods=["POST"], examples=[ PythonEx( + description="Get Capital Asset Pricing Model (CAPM).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.quantitative.capm(data=stock_data, target='close')", diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 6db047e06a22..9d42eaa010d3 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -29,6 +29,7 @@ methods=["POST"], examples=[ PythonEx( + description="Get Rolling Mean.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -82,6 +83,7 @@ def skew( methods=["POST"], examples=[ PythonEx( + description="Get Rolling Variance.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -128,6 +130,7 @@ def variance( methods=["POST"], examples=[ PythonEx( + description="Get Rolling Standard Deviation.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -178,6 +181,7 @@ def stdev( methods=["POST"], examples=[ PythonEx( + description="Get Rolling Kurtosis.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -230,6 +234,7 @@ def kurtosis( methods=["POST"], examples=[ PythonEx( + description="Get Rolling Quantile.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -299,6 +304,7 @@ def quantile( methods=["POST"], examples=[ PythonEx( + description="Get Rolling Mean.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index 9a191cdd3406..3dd00472e2bb 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -28,6 +28,7 @@ methods=["POST"], examples=[ PythonEx( + description="Get Skewness.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -73,6 +74,7 @@ def skew( methods=["POST"], examples=[ PythonEx( + description="Get Variance.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -112,6 +114,7 @@ def variance(data: List[Data], target: str) -> OBBject[List[Data]]: methods=["POST"], examples=[ PythonEx( + description="Get Standard Deviation.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -153,6 +156,7 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: methods=["POST"], examples=[ PythonEx( + description="Get Kurtosis.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -194,6 +198,7 @@ def kurtosis(data: List[Data], target) -> OBBject[List[Data]]: methods=["POST"], examples=[ PythonEx( + description="Get Quantile.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', @@ -243,6 +248,7 @@ def quantile( methods=["POST"], examples=[ PythonEx( + description="Get Mean.", code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 342af899ef4c..eb6340a3184b 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -48,8 +48,8 @@ async def institutions_search( examples=[ APIEx(parameters={}), PythonEx( + description="Get a list of schema files.", code=[ - "#### Get a list of schema files. ####", "data = obb.regulators.sec.schema_files()", "data.files[0]", " https://xbrl.fasb.org/us-gaap/", diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 0e2a79756b7a..5975f54e9698 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -27,6 +27,7 @@ methods=["POST"], examples=[ PythonEx( + description="Get the Average True Range.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "atr_data = obb.technical.atr(data=stock_data.results)", @@ -88,6 +89,7 @@ def atr( methods=["POST"], examples=[ PythonEx( + description="Get the Bollinger Band Width.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "fib_data = obb.technical.fib(data=stock_data.results, period=120)", @@ -157,6 +159,7 @@ def fib( methods=["POST"], examples=[ PythonEx( + description="Get the On Balance Volume (OBV).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "obv_data = obb.technical.obv(data=stock_data.results, offset=0)", @@ -208,6 +211,7 @@ def obv( methods=["POST"], examples=[ PythonEx( + description="Perform the Fisher Transform.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "fisher_data = obb.technical.fisher(data=stock_data.results, length=14, signal=1)", @@ -259,6 +263,7 @@ def fisher( methods=["POST"], examples=[ PythonEx( + description="Get the Accumulation/Distribution Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "adosc_data = obb.technical.adosc(data=stock_data.results, fast=3, slow=10, offset=0)", @@ -313,6 +318,7 @@ def adosc( methods=["POST"], examples=[ PythonEx( + description="Get the Chande Momentum Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", @@ -389,6 +395,7 @@ def bbands( methods=["POST"], examples=[ PythonEx( + description="Get the Chande Momentum Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "zlma_data = obb.technical.zlma(data=stock_data.results, target='close', length=50, offset=0)", @@ -451,6 +458,7 @@ def zlma( methods=["POST"], examples=[ PythonEx( + description="Get the Chande Momentum Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "aaron_data = obb.technical.aroon(data=stock_data.results, length=25, scalar=100)", @@ -508,6 +516,7 @@ def aroon( methods=["POST"], examples=[ PythonEx( + description="Get the Chande Momentum Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "sma_data = obb.technical.sma(data=stock_data.results, target='close', length=50, offset=0)", @@ -571,6 +580,7 @@ def sma( methods=["POST"], examples=[ PythonEx( + description="Get the Demark Sequential Indicator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "demark_data = obb.technical.demark(data=stock_data.results, offset=0)", @@ -629,6 +639,7 @@ def demark( methods=["POST"], examples=[ PythonEx( + description="Get the Volume Weighted Average Price (VWAP).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "vwap_data = obb.technical.vwap(data=stock_data.results, anchor='D', offset=0)", @@ -681,6 +692,7 @@ def vwap( methods=["POST"], examples=[ PythonEx( + description="Get the Moving Average Convergence Divergence (MACD).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "macd_data = obb.technical.macd(data=stock_data.results, target='close', fast=12, slow=26, signal=9)", @@ -748,6 +760,7 @@ def macd( methods=["POST"], examples=[ PythonEx( + description="Get the Relative Strength Index (RSI).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "hma_data = obb.technical.hma(data=stock_data.results, target='close', length=50, offset=0)", @@ -808,6 +821,7 @@ def hma( methods=["POST"], examples=[ PythonEx( + description="Get the Donchian Channels.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", @@ -866,6 +880,7 @@ def donchian( methods=["POST"], examples=[ PythonEx( + description="Get the Ichimoku Cloud.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ichimoku_data = obb.technical.ichimoku(data=stock_data.results, conversion=9, base=26, lookahead=False)", @@ -934,6 +949,7 @@ def ichimoku( methods=["POST"], examples=[ PythonEx( + description="Get the Clenow Volatility Adjusted Momentum.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "clenow_data = obb.technical.clenow(data=stock_data.results, period=90)", @@ -993,6 +1009,7 @@ def clenow( methods=["POST"], examples=[ PythonEx( + description="Get the Accumulation/Distribution Line.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", @@ -1043,6 +1060,7 @@ def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[D methods=["POST"], examples=[ PythonEx( + description="Get the Average Directional Index (ADX).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "adx_data = obb.technical.adx(data=stock_data.results, length=50, scalar=100.0, drift=1)", @@ -1097,6 +1115,7 @@ def adx( methods=["POST"], examples=[ PythonEx( + description="Get the Average True Range (ATR).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "wma_data = obb.technical.wma(data=stock_data.results, target='close', length=50, offset=0)", @@ -1157,6 +1176,7 @@ def wma( methods=["POST"], examples=[ PythonEx( + description="Get the Commodity Channel Index (CCI).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cci_data = obb.technical.cci(data=stock_data.results, length=14, scalar=0.015)", @@ -1208,6 +1228,7 @@ def cci( methods=["POST"], examples=[ PythonEx( + description="Get the Relative Strength Index (RSI).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "rsi_data = obb.technical.rsi(data=stock_data.results, target='close', length=14, scalar=100.0, drift=1)", @@ -1273,6 +1294,7 @@ def rsi( methods=["POST"], examples=[ PythonEx( + description="Get the Stochastic Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", @@ -1334,6 +1356,7 @@ def stoch( methods=["POST"], examples=[ PythonEx( + description="Get the Keltner Channels.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "kc_data = obb.technical.kc(data=stock_data.results, length=20, scalar=20, mamode='ema', offset=0)", @@ -1397,6 +1420,7 @@ def kc( methods=["POST"], examples=[ PythonEx( + description="Get the Center of Gravity (CG).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cg_data = obb.technical.cg(data=stock_data.results, length=14)", @@ -1443,6 +1467,7 @@ def cg( methods=["POST"], examples=[ PythonEx( + description="Get the cones indicator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cones_data = obb.technical.cones(data=stock_data.results, lower_q=0.25, upper_q=0.75, model='STD')", @@ -1546,6 +1571,7 @@ def cones( methods=["POST"], examples=[ PythonEx( + description="Get the Exponential Moving Average (EMA).", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ema_data = obb.technical.ema(data=stock_data.results, target='close', length=50, offset=0)", diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index 39587c3113f3..b728828c9e41 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -272,7 +272,7 @@ def schema_files( -------- >>> from openbb import obb >>> obb.regulators.sec.schema_files() - >>> #### Get a list of schema files. #### + >>> # Get a list of schema files. >>> data = obb.regulators.sec.schema_files() >>> data.files[0] >>> https://xbrl.fasb.org/us-gaap/ From 2f6440aaa1777199c452de7183e1416821a5de9b Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 13:40:02 +0000 Subject: [PATCH 049/133] simple indent --- .../openbb_core/app/static/package_builder.py | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index f79cd94352c4..51b62a98e9bc 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -62,12 +62,11 @@ ) TAB = " " -BASE_INDENTATION = TAB * 2 def indent(n: int) -> str: - """Create n indentation space on top of the base indentation.""" - return BASE_INDENTATION + TAB * n + """Create n indentation space.""" + return TAB * n class PackageBuilder: @@ -722,7 +721,7 @@ def build_command_method_doc( model_name=model_name, examples=examples, ) - code = f'{indent(0)}"""{doc}{indent(0)}""" # noqa: E501\n\n' if doc else "" + code = f'{indent(2)}"""{doc}{indent(2)}""" # noqa: E501\n\n' if doc else "" return code @@ -846,17 +845,17 @@ def get_OBBject_description( available_providers = providers or "Optional[str]" obbject_description = ( - f"{indent(0)}OBBject\n" - f"{indent(1)}results : {results_type}\n" - f"{indent(2)}Serializable results.\n" - f"{indent(1)}provider : {available_providers}\n" - f"{indent(2)}Provider name.\n" - f"{indent(1)}warnings : Optional[List[Warning_]]\n" - f"{indent(2)}List of warnings.\n" - f"{indent(1)}chart : Optional[Chart]\n" - f"{indent(2)}Chart object.\n" - f"{indent(1)}extra : Dict[str, Any]\n" - f"{indent(2)}Extra info.\n" + f"{indent(2)}OBBject\n" + f"{indent(3)}results : {results_type}\n" + f"{indent(4)}Serializable results.\n" + f"{indent(3)}provider : {available_providers}\n" + f"{indent(4)}Provider name.\n" + f"{indent(3)}warnings : Optional[List[Warning_]]\n" + f"{indent(4)}List of warnings.\n" + f"{indent(3)}chart : Optional[Chart]\n" + f"{indent(4)}Chart object.\n" + f"{indent(3)}extra : Dict[str, Any]\n" + f"{indent(4)}Extra info.\n" ) obbject_description = obbject_description.replace("NoneType", "None") @@ -870,15 +869,15 @@ def append_examples( ) -> str: """Get the example section from the examples.""" if examples: - doc = f"\n{indent(0)}Examples\n" - doc += f"{indent(0)}--------\n" - doc += f"{indent(0)}>>> from openbb import obb\n" + doc = f"\n{indent(2)}Examples\n" + doc += f"{indent(2)}--------\n" + doc += f"{indent(2)}>>> from openbb import obb\n" for e in examples: doc += e.to_python( func_path=func_path, func_params=func_params, - indentation=indent(0), + indentation=indent(2), ) return doc return "" @@ -907,13 +906,13 @@ def format_type(type_: str, char_limit: Optional[int] = None) -> str: def format_description(description: str) -> str: """Format description in docstrings.""" - description = description.replace("\n", f"\n{indent(0)}") + description = description.replace("\n", f"\n{indent(2)}") return description - docstring = summary.strip("\n").replace("\n ", f"\n{indent(0)}") + docstring = summary.strip("\n").replace("\n ", f"\n{indent(2)}") docstring += "\n\n" - docstring += f"{indent(0)}Parameters\n" - docstring += f"{indent(0)}----------\n" + docstring += f"{indent(2)}Parameters\n" + docstring += f"{indent(2)}----------\n" # Explicit parameters for param_name, param in explicit_params.items(): @@ -936,8 +935,8 @@ def format_description(description: str) -> str: ) type_str = format_type(type_, char_limit=79) # type: ignore - docstring += f"{indent(0)}{param_name} : {type_str}\n" - docstring += f"{indent(1)}{format_description(description)}\n" + docstring += f"{indent(2)}{param_name} : {type_str}\n" + docstring += f"{indent(3)}{format_description(description)}\n" # Kwargs for param_name, param in kwarg_params.items(): @@ -949,13 +948,13 @@ def format_description(description: str) -> str: description = getattr(param.default, "description", "") - docstring += f"{indent(0)}{param_name} : {type_}\n" - docstring += f"{indent(1)}{format_description(description)}\n" + docstring += f"{indent(2)}{param_name} : {type_}\n" + docstring += f"{indent(3)}{format_description(description)}\n" # Returns docstring += "\n" - docstring += f"{indent(0)}Returns\n" - docstring += f"{indent(0)}-------\n" + docstring += f"{indent(2)}Returns\n" + docstring += f"{indent(2)}-------\n" provider_param = explicit_params.get("provider", None) available_providers = getattr(provider_param, "_annotation", None) @@ -963,8 +962,8 @@ def format_description(description: str) -> str: # Schema underline = "-" * len(model_name) - docstring += f"\n{indent(0)}{model_name}\n" - docstring += f"{indent(0)}{underline}\n" + docstring += f"\n{indent(2)}{model_name}\n" + docstring += f"{indent(2)}{underline}\n" for name, field in returns.items(): try: @@ -995,8 +994,8 @@ def format_description(description: str) -> str: description = getattr(field, "description", "") - docstring += f"{indent(0)}{field.alias or name} : {field_type}\n" - docstring += f"{indent(1)}{format_description(description)}\n" + docstring += f"{indent(2)}{field.alias or name} : {field_type}\n" + docstring += f"{indent(3)}{format_description(description)}\n" return docstring @classmethod @@ -1036,7 +1035,7 @@ def generate( results_type=results_type, ) else: - doc = doc.replace("\n ", f"\n{indent(0)}") + doc = doc.replace("\n ", f"\n{indent(2)}") if doc and examples: doc += cls.append_examples( From 9695ead3197fb4339d1c24079b735c64b988e25e Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Wed, 6 Mar 2024 21:15:34 +0530 Subject: [PATCH 050/133] append_examples func works for both website and docstring --- .../core/openbb_core/app/model/example.py | 18 ++++- .../openbb_core/app/static/package_builder.py | 80 +++++++++++-------- 2 files changed, 61 insertions(+), 37 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 9c8b1cc41da7..22d78850e795 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,3 +1,5 @@ +"""Example class to represent endpoint examples.""" + from abc import abstractmethod from dataclasses import Field from typing import Dict, List, Literal, Optional, Union @@ -39,12 +41,15 @@ def to_python(self, **kwargs) -> str: indentation = kwargs.get("indentation", "") func_path = kwargs.get("func_path", ".func_router.func_name") func_params: Dict[str, Field] = kwargs.get("func_params", {}) + target: str = kwargs.get("target", "docstring") + + prompt = ">>> " if target == "docstring" else "" eg = "" if self.description: - eg += f"{indentation}>>> # {self.description}\n" + eg += f"{indentation}{prompt}# {self.description}\n" - eg += f"{indentation}>>> obb{func_path}(" + eg += f"{indentation}{prompt}obb{func_path}(" for k, v in self.parameters.items(): if k in func_params and (field := func_params.get(k)): field_type_str = str(field.type) @@ -56,6 +61,7 @@ def to_python(self, **kwargs) -> str: eg += f"{k}='{v}', " eg = indentation + eg.strip(", ") + ")\n" + return eg @@ -69,13 +75,17 @@ class PythonEx(Example): def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") + target: str = kwargs.get("target", "docstring") + + prompt = ">>> " if target == "docstring" else "" eg = "" if self.description: - eg += f"{indentation}>>> # {self.description}\n" + eg += f"{indentation}{prompt}# {self.description}\n" for line in self.code: - eg += f"{indentation}>>> {line}\n" + eg += f"{indentation}{prompt}{line}\n" + return eg diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 51b62a98e9bc..75a3f94bba36 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -13,6 +13,7 @@ Callable, Dict, List, + Literal, Optional, OrderedDict, Set, @@ -64,7 +65,7 @@ TAB = " " -def indent(n: int) -> str: +def create_indent(n: int) -> str: """Create n indentation space.""" return TAB * n @@ -721,7 +722,11 @@ def build_command_method_doc( model_name=model_name, examples=examples, ) - code = f'{indent(2)}"""{doc}{indent(2)}""" # noqa: E501\n\n' if doc else "" + code = ( + f'{create_indent(2)}"""{doc}{create_indent(2)}""" # noqa: E501\n\n' + if doc + else "" + ) return code @@ -845,17 +850,17 @@ def get_OBBject_description( available_providers = providers or "Optional[str]" obbject_description = ( - f"{indent(2)}OBBject\n" - f"{indent(3)}results : {results_type}\n" - f"{indent(4)}Serializable results.\n" - f"{indent(3)}provider : {available_providers}\n" - f"{indent(4)}Provider name.\n" - f"{indent(3)}warnings : Optional[List[Warning_]]\n" - f"{indent(4)}List of warnings.\n" - f"{indent(3)}chart : Optional[Chart]\n" - f"{indent(4)}Chart object.\n" - f"{indent(3)}extra : Dict[str, Any]\n" - f"{indent(4)}Extra info.\n" + f"{create_indent(2)}OBBject\n" + f"{create_indent(3)}results : {results_type}\n" + f"{create_indent(4)}Serializable results.\n" + f"{create_indent(3)}provider : {available_providers}\n" + f"{create_indent(4)}Provider name.\n" + f"{create_indent(3)}warnings : Optional[List[Warning_]]\n" + f"{create_indent(4)}List of warnings.\n" + f"{create_indent(3)}chart : Optional[Chart]\n" + f"{create_indent(4)}Chart object.\n" + f"{create_indent(3)}extra : Dict[str, Any]\n" + f"{create_indent(4)}Extra info.\n" ) obbject_description = obbject_description.replace("NoneType", "None") @@ -866,20 +871,29 @@ def append_examples( func_path: str, func_params: Dict[str, Field], examples: Optional[List[Example]], + target: Literal["docstring", "website"] = "docstring", ) -> str: """Get the example section from the examples.""" if examples: - doc = f"\n{indent(2)}Examples\n" - doc += f"{indent(2)}--------\n" - doc += f"{indent(2)}>>> from openbb import obb\n" + if target == "docstring": + prompt = ">>> " + indent = create_indent(2) + else: + prompt = "\n```python\n" + indent = create_indent(0) + + doc = f"\n{indent}Examples\n" + doc += f"{indent}--------\n" + doc += f"{indent}{prompt}from openbb import obb\n" for e in examples: doc += e.to_python( func_path=func_path, func_params=func_params, - indentation=indent(2), + indentation=indent, + target=target, ) - return doc + return doc if target == "docstring" else doc + "```\n\n" return "" @classmethod @@ -906,13 +920,13 @@ def format_type(type_: str, char_limit: Optional[int] = None) -> str: def format_description(description: str) -> str: """Format description in docstrings.""" - description = description.replace("\n", f"\n{indent(2)}") + description = description.replace("\n", f"\n{create_indent(2)}") return description - docstring = summary.strip("\n").replace("\n ", f"\n{indent(2)}") + docstring = summary.strip("\n").replace("\n ", f"\n{create_indent(2)}") docstring += "\n\n" - docstring += f"{indent(2)}Parameters\n" - docstring += f"{indent(2)}----------\n" + docstring += f"{create_indent(2)}Parameters\n" + docstring += f"{create_indent(2)}----------\n" # Explicit parameters for param_name, param in explicit_params.items(): @@ -935,8 +949,8 @@ def format_description(description: str) -> str: ) type_str = format_type(type_, char_limit=79) # type: ignore - docstring += f"{indent(2)}{param_name} : {type_str}\n" - docstring += f"{indent(3)}{format_description(description)}\n" + docstring += f"{create_indent(2)}{param_name} : {type_str}\n" + docstring += f"{create_indent(3)}{format_description(description)}\n" # Kwargs for param_name, param in kwarg_params.items(): @@ -948,13 +962,13 @@ def format_description(description: str) -> str: description = getattr(param.default, "description", "") - docstring += f"{indent(2)}{param_name} : {type_}\n" - docstring += f"{indent(3)}{format_description(description)}\n" + docstring += f"{create_indent(2)}{param_name} : {type_}\n" + docstring += f"{create_indent(3)}{format_description(description)}\n" # Returns docstring += "\n" - docstring += f"{indent(2)}Returns\n" - docstring += f"{indent(2)}-------\n" + docstring += f"{create_indent(2)}Returns\n" + docstring += f"{create_indent(2)}-------\n" provider_param = explicit_params.get("provider", None) available_providers = getattr(provider_param, "_annotation", None) @@ -962,8 +976,8 @@ def format_description(description: str) -> str: # Schema underline = "-" * len(model_name) - docstring += f"\n{indent(2)}{model_name}\n" - docstring += f"{indent(2)}{underline}\n" + docstring += f"\n{create_indent(2)}{model_name}\n" + docstring += f"{create_indent(2)}{underline}\n" for name, field in returns.items(): try: @@ -994,8 +1008,8 @@ def format_description(description: str) -> str: description = getattr(field, "description", "") - docstring += f"{indent(2)}{field.alias or name} : {field_type}\n" - docstring += f"{indent(3)}{format_description(description)}\n" + docstring += f"{create_indent(2)}{field.alias or name} : {field_type}\n" + docstring += f"{create_indent(3)}{format_description(description)}\n" return docstring @classmethod @@ -1035,7 +1049,7 @@ def generate( results_type=results_type, ) else: - doc = doc.replace("\n ", f"\n{indent(2)}") + doc = doc.replace("\n ", f"\n{create_indent(2)}") if doc and examples: doc += cls.append_examples( From 1aef9aac4b0a75844dbbaa1920e5b73a6bd2fadd Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Wed, 6 Mar 2024 18:36:39 +0100 Subject: [PATCH 051/133] Add example unit tests --- .../extensions/tests/test_routers.py | 7 + .../extensions/tests/utils/helpers.py | 208 ++++++++++++- .../extensions/tests/utils/router_testers.py | 289 ++++++++++++------ 3 files changed, 407 insertions(+), 97 deletions(-) diff --git a/openbb_platform/extensions/tests/test_routers.py b/openbb_platform/extensions/tests/test_routers.py index 31c690ce1b91..136ec4720e03 100644 --- a/openbb_platform/extensions/tests/test_routers.py +++ b/openbb_platform/extensions/tests/test_routers.py @@ -1,6 +1,7 @@ """Test the routers.""" from extensions.tests.utils.router_testers import ( + check_router_command_examples, check_router_function_models, check_router_model_functions_signature, ) @@ -16,3 +17,9 @@ def test_router_model_functions_signature() -> None: """Test if the router functions have the correct signature.""" missing_args = check_router_model_functions_signature() assert not missing_args, "\n".join(missing_args) + + +def test_router_examples() -> None: + """Test if the router examples are valid.""" + invalid_examples = check_router_command_examples() + assert not invalid_examples, "\n".join(invalid_examples) diff --git a/openbb_platform/extensions/tests/utils/helpers.py b/openbb_platform/extensions/tests/utils/helpers.py index 264bdb4958d5..dd41008e8aeb 100644 --- a/openbb_platform/extensions/tests/utils/helpers.py +++ b/openbb_platform/extensions/tests/utils/helpers.py @@ -1,12 +1,20 @@ """Test helpers.""" +import ast import doctest import glob import importlib +import inspect import logging import os +import re from importlib.metadata import entry_points -from typing import Dict, List, Set, Tuple +from inspect import getmembers, isfunction +from typing import Any, Dict, List, Set, Tuple + +from openbb_core.app.provider_interface import ProviderInterface + +pi = ProviderInterface() logging.basicConfig(level=logging.INFO) @@ -72,9 +80,8 @@ def check_docstring_examples() -> List[str]: return errors -def list_openbb_extensions() -> Tuple[Set[str], Set[str], Set[str]]: - """ - Lists installed openbb extensions and providers. +def list_openbb_extensions() -> Tuple[Set[str], Set[str]]: + """List installed openbb extensions and providers. Returns ------- @@ -95,7 +102,194 @@ def list_openbb_extensions() -> Tuple[Set[str], Set[str], Set[str]]: for entry_point in entry_points_dict["openbb_provider_extension"]: provider_extensions.add(f"{entry_point.name}") - for entry_point in entry_points_dict["openbb_obbject_extension"]: - obbject_extensions.add(f"{entry_point.name}") + return core_extensions, provider_extensions + + +def collect_routers(target_dir: str) -> List[str]: + """Collect all routers in the target directory.""" + current_dir = os.path.dirname(__file__) + base_path = os.path.abspath(os.path.join(current_dir, "../../../")) + + full_target_path = os.path.abspath(os.path.join(base_path, target_dir)) + routers = [] + + for root, _, files in os.walk(full_target_path): + for name in files: + if name.endswith("_router.py"): + full_path = os.path.join(root, name) + # Convert the full path to a module path + relative_path = os.path.relpath(full_path, base_path) + module_path = relative_path.replace("/", ".").replace(".py", "") + routers.append(module_path) + + return routers + + +def import_routers(routers: List) -> List: + """Import all routers.""" + loaded_routers: List = [] + for router in routers: + module = importlib.import_module(router) + loaded_routers.append(module) + + return loaded_routers + + +def collect_router_functions(loaded_routers: List) -> Dict: + """Collect all router functions.""" + router_functions = {} + for router in loaded_routers: + router_functions[router.__name__] = [ + function[1] + for function in getmembers(router, isfunction) + if function[0] != "router" + ] + + return router_functions + + +def find_decorator(file_path: str, function_name: str) -> str: + """Find the @router.command decorator of the function in the file, supporting multiline decorators.""" + this_dir = os.path.dirname(os.path.abspath(__file__)) + file_path = os.path.join( + this_dir.split("openbb_platform/")[0], "openbb_platform", file_path + ) + + with open(file_path) as file: + lines = file.readlines() + + decorator_lines = [] + capturing_decorator = False + for line in lines: + stripped_line = line.strip() + # Start capturing lines if we encounter a decorator + if stripped_line.startswith("@router.command"): + capturing_decorator = True + decorator_lines.append(stripped_line) + elif capturing_decorator: + # If we're currently capturing a decorator and the line is part of it (indentation or open parenthesis) + if ( + stripped_line.startswith("@") + or "def" in stripped_line + and function_name in stripped_line + ): + # If we've reached another decorator or the function definition, stop capturing + capturing_decorator = False + # If it's the target function, break, else clear decorator_lines for the next decorator + if "def" in stripped_line and function_name in stripped_line: + break + decorator_lines = [] + else: + # It's part of the multiline decorator + decorator_lines.append(stripped_line) + + decorator = " ".join(decorator_lines) + return decorator + + +def get_decorator_details(function): + """Extract decorators and their arguments from a function as dictionaries.""" + source = inspect.getsource(function) + parsed_source = ast.parse(source) + + if isinstance(parsed_source.body[0], (ast.FunctionDef, ast.AsyncFunctionDef)): + func_def = parsed_source.body[0] + for decorator in func_def.decorator_list: + decorator_detail = {"decorator": "", "args": {}, "keywords": {}} + if isinstance(decorator, ast.Call): + decorator_detail["decorator"] = ( + decorator.func.id + if isinstance(decorator.func, ast.Name) + else ast.unparse(decorator.func) + ) + decorator_detail["args"] = { + i: ast.unparse(arg) for i, arg in enumerate(decorator.args) + } + decorator_detail["keywords"] = { + kw.arg: ast.unparse(kw.value) for kw in decorator.keywords + } + else: + decorator_detail["decorator"] = ( + decorator.id + if isinstance(decorator, ast.Name) + else ast.unparse(decorator) + ) + + return decorator_detail + + +def find_missing_router_function_models( + router_functions: Dict, pi_map: Dict +) -> List[str]: + """Find the missing models in the router functions.""" + missing_models: List[str] = [] + for router_name, functions in router_functions.items(): + for function in functions: + decorator = find_decorator( + os.path.join(*router_name.split(".")) + ".py", + function.__name__, + ) + if ( + decorator + and "model" in decorator + and "POST" not in decorator + and "GET" not in decorator + ): + model = decorator.split("model=")[1].split(",")[0].strip('"') + if ( + model not in pi_map + and "POST" not in decorator + and "GET" not in decorator + ): + missing_models.append( + f"{function.__name__} in {router_name} model doesn't exist in the provider interface map." + ) + + return missing_models + + +def parse_example_string(example_string: str) -> Dict[str, Any]: + """Parses a string of examples into nested dictionaries. + + This is capturing all instances of PythonEx and APIEx, including their "parameters", "code", and "description". + """ + # Initialize the result dictionary + result = {} + + # Regular expression patterns to find PythonEx and APIEx examples, including optional descriptions + pythonex_pattern = r"PythonEx\(code=\[(.*?)\](?:, description=['\"](.*?)['\"])?\)" + apiex_pattern = r"APIEx\(parameters=(\{.*?\})(?:, description=['\"](.*?)['\"])?\)" + + # Function to parse individual examples + def parse_examples(matches, example_type): + examples = [] + for match in matches: + if example_type == "PythonEx": + code, description = match + # Treat code as a raw string without evaluating it + example = {"code": [code]} + else: # APIEx + parameters, description = match + # Directly use parameters without evaluating + example = {"params": parameters} + + if description: + example["description"] = description + examples.append(example) + return examples + + # Find and parse all PythonEx examples + pythonex_matches = re.findall(pythonex_pattern, example_string, re.DOTALL) + result["PythonEx"] = parse_examples(pythonex_matches, "PythonEx") + + # Find and parse all APIEx examples + apiex_matches = re.findall(apiex_pattern, example_string, re.DOTALL) + result["APIEx"] = parse_examples(apiex_matches, "APIEx") + + return result + - return core_extensions, provider_extensions, obbject_extensions +def get_required_fields(model: str) -> List[str]: + """Get the required fields of a model.""" + fields = pi.map[model]["openbb"]["QueryParams"]["fields"] + return [field for field, info in fields.items() if info.is_required()] diff --git a/openbb_platform/extensions/tests/utils/router_testers.py b/openbb_platform/extensions/tests/utils/router_testers.py index bbc9ff3b7ec5..d44bdb7c7815 100644 --- a/openbb_platform/extensions/tests/utils/router_testers.py +++ b/openbb_platform/extensions/tests/utils/router_testers.py @@ -1,97 +1,21 @@ """Router testers.""" -import importlib +import ast import os -from inspect import getmembers, isfunction -from typing import Dict, List, Optional +from typing import Any, Dict, List, Optional from openbb_core.app.provider_interface import ProviderInterface - -def collect_routers(target_dir: str) -> List[str]: - """Collect all routers in the target directory.""" - current_dir = os.path.dirname(__file__) - base_path = os.path.abspath(os.path.join(current_dir, "../../../")) - - full_target_path = os.path.abspath(os.path.join(base_path, target_dir)) - routers = [] - - for root, _, files in os.walk(full_target_path): - for name in files: - if name.endswith("_router.py"): - full_path = os.path.join(root, name) - # Convert the full path to a module path - relative_path = os.path.relpath(full_path, base_path) - module_path = relative_path.replace("/", ".").replace(".py", "") - routers.append(module_path) - - return routers - - -def import_routers(routers: List) -> List: - """Import all routers.""" - loaded_routers: List = [] - for router in routers: - module = importlib.import_module(router) - loaded_routers.append(module) - - return loaded_routers - - -def collect_router_functions(loaded_routers: List) -> Dict: - """Collect all router functions.""" - router_functions = {} - for router in loaded_routers: - router_functions[router.__name__] = [ - function[1] - for function in getmembers(router, isfunction) - if function[0] != "router" - ] - - return router_functions - - -def find_decorator(file_path: str, function_name: str) -> Optional[str]: - """Find the decorator of the function in the file.""" - this_dir = os.path.dirname(os.path.abspath(__file__)) - file_path = os.path.join( - this_dir.split("openbb_platform/")[0], "openbb_platform", file_path - ) - with open(file_path) as file: - lines = file.readlines() - for index, line in enumerate(lines): - if function_name in line: - decorator = lines[index - 1] - if "@" not in decorator: - continue - decorator = decorator.split('"')[1] - return decorator - - return None - - -def find_missing_router_function_models( - router_functions: Dict, pi_map: Dict -) -> List[str]: - """Find the missing models in the router functions.""" - missing_models: List[str] = [] - for router_name, functions in router_functions.items(): - for function in functions: - decorator = find_decorator( - os.path.join(*router_name.split(".")) + ".py", - function.__name__, - ) - if ( - decorator not in pi_map - and decorator is not None - and "POST" not in decorator - and "GET" not in decorator - ): - missing_models.append( - f"{function.__name__} in {router_name} model doesn't exist in the provider interface map." - ) - - return missing_models +from extensions.tests.utils.helpers import ( + collect_router_functions, + collect_routers, + find_decorator, + find_missing_router_function_models, + get_decorator_details, + get_required_fields, + import_routers, + parse_example_string, +) def check_router_function_models() -> List[str]: @@ -119,14 +43,15 @@ def check_router_model_functions_signature() -> List[str]: for router_name, functions in router_functions.items(): for function in functions: - decorator_filer = ["POST", "GET", None] decorator = find_decorator( os.path.join(*router_name.split(".")) + ".py", function.__name__, ) if decorator: + if "POST" in decorator or "GET" in decorator: + continue args = list(function.__code__.co_varnames) - if args != expected_args and decorator not in decorator_filer: + if args != expected_args and "model" in decorator: missing_args.append( f"{function.__name__} in {router_name} doesn't have the expected args: {expected_args}" ) @@ -137,3 +62,187 @@ def check_router_model_functions_signature() -> List[str]: ) return missing_args + missing_return_type + + +def check_general_example_violations( + keywords: Dict, examples: List, router_name: str, function: Any +) -> List[str]: + """Check for general violations in the router command examples. + + Criteria + -------- + - All endpoints should have examples. + - If any endpoint is excluded from the schema it only needs to contain a Python example. + - POST method examples should have both API and Python examples, + unless they are excluded from the schema. + """ + general_violation: List[str] = [] + + # Check if the endpoint has examples + if "examples" not in keywords or not examples: + general_violation.append( + f"{function.__name__} in {router_name} doesn't have examples." + ) + return general_violation + # Check if a POST method has both API and Python examples + if ( + "POST" in keywords.get("methods", "") + and keywords.get("include_in_schema", "") != "False" + ): + if "APIEx" not in examples: + general_violation.append( + f"{function.__name__} in {router_name} doesn't have an API example." + ) + if "PythonEx" not in examples: + general_violation.append( + f"{function.__name__} in {router_name} doesn't have a Python example." + ) + # Check if a POST endpoint excluded from the schema has a Python example + if ( + (keywords.get("include_in_schema", "") == "False") + and ("POST" in keywords.get("methods", "")) + and ("PythonEx" not in examples) + ): + general_violation.append( + f"{function.__name__} in {router_name} is excluded from the" + f"schema but doesn't have a Python example." + ) + if "APIEx" in examples: + general_violation.append( + f"{function.__name__} in {router_name} is excluded from the" + f"schema but has an API example." + ) + + return general_violation + + +def check_python_example_violations( + examples: str, router_name: str, function: Any +) -> List[str]: + """Check for Python violations in the router command examples. + + Criteria + -------- + - Description is mandatory for PythonEx examples. + """ + python_example_violation: List[str] = [] + + parsed_examples = parse_example_string(examples) + + # Check if there are PythonEx examples + if "PythonEx" in parsed_examples: + for python_example in parsed_examples["PythonEx"]: + # Check if the Python example has a description + if ( + "description" not in python_example + or not python_example["description"].strip() + ): + python_example_violation.append( + f"{function.__name__} in {router_name} Python example doesn't have a description." + ) + + return python_example_violation + + +def check_api_example_violations( + examples: str, router_name: str, model: Optional[str], function: Any +) -> List[str]: + """Check for API example violations in the router command examples. + + Criteria + -------- + - When using models, at least one example using all required standard parameters. + It cannot use any provider specific parameters here. + It should not specify the provider field. + - If there’s more than 3 parameters we ask to have a description in the example. + """ + api_example_violation: List[str] = [] + + parsed_examples = parse_example_string(examples) + + # Check if description is added + if "APIEx" in parsed_examples: + for api_example in parsed_examples["APIEx"]: + if len(api_example.get("params", {})) > 3 and not api_example.get( + "description" + ): + api_example_violation.append( + f"{function.__name__} in {router_name} API example has more than 3 parameters " + "but doesn't have a description." + ) + # Check model endpoint example criteria + if model and "APIEx" in parsed_examples: + required_fields = get_required_fields(model.strip("'")) + for api_example in parsed_examples["APIEx"]: + params = ast.literal_eval(api_example.get("params", "{}")) + if set(params.keys()) == set(required_fields): + break + else: + api_example_violation.append( + f"{function.__name__} in {router_name} doesn't have an example using only" + f" the required standard parameters." + ) + + return api_example_violation + + +def check_router_command_examples() -> List[str]: + """Check if the router command examples satisfy criteria. + + Criteria + -------- + General: + - All endpoints should have examples. + - If any endpoint is excluded from the schema it only needs to contain a Python example. + - POST method examples should have both API and Python examples, + unless they are excluded from the schema. + + API examples: + - At least one example using all required parameters. + It cannot use any provider specific parameters here. + It should not specify the provider field. + - If there’s more than 3 parameters we ask to have a description in the example. + + Python examples: + - Description is mandatory + """ + general_violation: List[str] = [] + api_example_violation: List[str] = [] + python_example_violation: List[str] = [] + + routers = collect_routers("extensions") + loaded_routers = import_routers(routers) + router_functions = collect_router_functions(loaded_routers) + + for router_name, functions in router_functions.items(): + for function in functions: + if ( + "basemodel_to_df" in function.__name__ + or "router" not in function.__module__ + ): + continue + decorator = find_decorator( + os.path.join(*router_name.split(".")) + ".py", + function.__name__, + ) + if decorator: + decorator_details = get_decorator_details(function) + if decorator_details["decorator"] == "router.command": + keywords = decorator_details["keywords"] + examples = keywords.get("examples", []) + ### General checks ### + general_violation += check_general_example_violations( + keywords, examples, router_name, function + ) + if examples: + ### API example checks ### + model = keywords.get("model", None) + api_example_violation += check_api_example_violations( + examples, router_name, model, function + ) + ### Python example checks ### + python_example_violation += check_python_example_violations( + examples, router_name, function + ) + + return general_violation + api_example_violation + python_example_violation From d1343cc51e256fbcb7b70d3b5763e53856f12633 Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Wed, 6 Mar 2024 19:17:54 +0100 Subject: [PATCH 052/133] Edit example unit tests --- .../core/openbb_core/app/model/example.py | 11 ++++- .../extensions/tests/utils/router_testers.py | 47 ------------------- 2 files changed, 10 insertions(+), 48 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 22d78850e795..bbfbc8bb8b1f 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -4,7 +4,7 @@ from dataclasses import Field from typing import Dict, List, Literal, Optional, Union -from pydantic import BaseModel, ConfigDict, computed_field +from pydantic import BaseModel, ConfigDict, computed_field, field_validator class Example(BaseModel): @@ -36,6 +36,15 @@ def provider(self) -> Optional[str]: raise ValueError(f"Provider must be a string, not {type(provider)}") return None + @field_validator("description") + @classmethod + def check_description(cls, v, values): + """Check if there are more than 3 parameters and a description is not added.""" + if len(values.get("parameters", {})) > 3 and not v: + raise ValueError( + "API example has more than 3 parameters but doesn't have a description." + ) + def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") diff --git a/openbb_platform/extensions/tests/utils/router_testers.py b/openbb_platform/extensions/tests/utils/router_testers.py index d44bdb7c7815..1cd6c2ef6483 100644 --- a/openbb_platform/extensions/tests/utils/router_testers.py +++ b/openbb_platform/extensions/tests/utils/router_testers.py @@ -116,34 +116,6 @@ def check_general_example_violations( return general_violation -def check_python_example_violations( - examples: str, router_name: str, function: Any -) -> List[str]: - """Check for Python violations in the router command examples. - - Criteria - -------- - - Description is mandatory for PythonEx examples. - """ - python_example_violation: List[str] = [] - - parsed_examples = parse_example_string(examples) - - # Check if there are PythonEx examples - if "PythonEx" in parsed_examples: - for python_example in parsed_examples["PythonEx"]: - # Check if the Python example has a description - if ( - "description" not in python_example - or not python_example["description"].strip() - ): - python_example_violation.append( - f"{function.__name__} in {router_name} Python example doesn't have a description." - ) - - return python_example_violation - - def check_api_example_violations( examples: str, router_name: str, model: Optional[str], function: Any ) -> List[str]: @@ -154,22 +126,11 @@ def check_api_example_violations( - When using models, at least one example using all required standard parameters. It cannot use any provider specific parameters here. It should not specify the provider field. - - If there’s more than 3 parameters we ask to have a description in the example. """ api_example_violation: List[str] = [] parsed_examples = parse_example_string(examples) - # Check if description is added - if "APIEx" in parsed_examples: - for api_example in parsed_examples["APIEx"]: - if len(api_example.get("params", {})) > 3 and not api_example.get( - "description" - ): - api_example_violation.append( - f"{function.__name__} in {router_name} API example has more than 3 parameters " - "but doesn't have a description." - ) # Check model endpoint example criteria if model and "APIEx" in parsed_examples: required_fields = get_required_fields(model.strip("'")) @@ -201,10 +162,6 @@ def check_router_command_examples() -> List[str]: - At least one example using all required parameters. It cannot use any provider specific parameters here. It should not specify the provider field. - - If there’s more than 3 parameters we ask to have a description in the example. - - Python examples: - - Description is mandatory """ general_violation: List[str] = [] api_example_violation: List[str] = [] @@ -240,9 +197,5 @@ def check_router_command_examples() -> List[str]: api_example_violation += check_api_example_violations( examples, router_name, model, function ) - ### Python example checks ### - python_example_violation += check_python_example_violations( - examples, router_name, function - ) return general_violation + api_example_violation + python_example_violation From 65c08d5f40d13f27aee14f77698c144e83a5afbe Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 22:16:22 +0000 Subject: [PATCH 053/133] fix validator --- openbb_platform/core/openbb_core/app/model/example.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index bbfbc8bb8b1f..8f41cf00ea83 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -4,7 +4,7 @@ from dataclasses import Field from typing import Dict, List, Literal, Optional, Union -from pydantic import BaseModel, ConfigDict, computed_field, field_validator +from pydantic import BaseModel, ConfigDict, computed_field, model_validator class Example(BaseModel): @@ -36,14 +36,15 @@ def provider(self) -> Optional[str]: raise ValueError(f"Provider must be a string, not {type(provider)}") return None - @field_validator("description") + @model_validator(mode="before") @classmethod - def check_description(cls, v, values): + def check_model(cls, values: dict) -> dict: """Check if there are more than 3 parameters and a description is not added.""" - if len(values.get("parameters", {})) > 3 and not v: + if len(values.get("parameters", {})) > 3: raise ValueError( "API example has more than 3 parameters but doesn't have a description." ) + return values def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" From 03046fc29c2e38b68a9d9b4cf4ce58887bcca84c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 22:24:42 +0000 Subject: [PATCH 054/133] this works --- openbb_platform/core/openbb_core/app/model/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 8f41cf00ea83..fa671a96ddeb 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -40,7 +40,7 @@ def provider(self) -> Optional[str]: @classmethod def check_model(cls, values: dict) -> dict: """Check if there are more than 3 parameters and a description is not added.""" - if len(values.get("parameters", {})) > 3: + if len(values.get("parameters", {})) > 3 and not values.get("description"): raise ValueError( "API example has more than 3 parameters but doesn't have a description." ) From c01feeb8ad5775d6e995bef9131ef79359332ddf Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 23:14:50 +0000 Subject: [PATCH 055/133] fix to_python --- .../core/openbb_core/app/model/example.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index fa671a96ddeb..177a8840916c 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -42,12 +42,14 @@ def check_model(cls, values: dict) -> dict: """Check if there are more than 3 parameters and a description is not added.""" if len(values.get("parameters", {})) > 3 and not values.get("description"): raise ValueError( - "API example has more than 3 parameters but doesn't have a description." + "API example with more than 3 parameters must have a description." ) return values def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" + BASIC_TYPES = {int, float, bool} + indentation = kwargs.get("indentation", "") func_path = kwargs.get("func_path", ".func_router.func_name") func_params: Dict[str, Field] = kwargs.get("func_params", {}) @@ -62,8 +64,7 @@ def to_python(self, **kwargs) -> str: eg += f"{indentation}{prompt}obb{func_path}(" for k, v in self.parameters.items(): if k in func_params and (field := func_params.get(k)): - field_type_str = str(field.type) - if any(t in field_type_str for t in ["int", "float", "bool"]): + if BASIC_TYPES.intersection(unpack_types(field.type)): eg += f"{k}={v}, " else: eg += f"{k}='{v}', " @@ -110,3 +111,10 @@ def filter_list( if (isinstance(e, APIEx) and (not e.provider or e.provider in providers)) or e.scope != "api" ] + + +def unpack_types(type_: type): + """Unpack types.""" + if hasattr(type_, "__args__"): + return set().union(*map(unpack_types, type_.__args__)) + return {type_} From ee2272a8ea67dbb7b7481f6a18c6657b4159e3f4 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 23:15:06 +0000 Subject: [PATCH 056/133] fix mandatory docstrings --- .../commodity/openbb_commodity/commodity_router.py | 3 ++- .../extensions/crypto/openbb_crypto/price/price_router.py | 1 + .../extensions/currency/openbb_currency/currency_router.py | 3 ++- .../equity/openbb_equity/estimates/estimates_router.py | 3 ++- .../equity/openbb_equity/fundamental/fundamental_router.py | 5 +++-- openbb_platform/openbb/package/crypto_price.py | 1 + openbb_platform/openbb/package/currency.py | 1 + openbb_platform/openbb/package/equity_estimates.py | 3 ++- openbb_platform/openbb/package/equity_fundamental.py | 3 ++- 9 files changed, 16 insertions(+), 7 deletions(-) diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index 2d490dfc893b..f910c4d00f21 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -21,13 +21,14 @@ examples=[ APIEx(parameters={"asset": "gold"}), APIEx( + description="Get the daily LBMA fixing prices for silver in 2023.", parameters={ "asset": "silver", "start_date": "2023-01-01", "end_date": "2023-12-31", "transform": "rdiff", "collapse": "monthly", - } + }, ), ], ) diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index 45f40844d1ca..27130dfbf52b 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -35,6 +35,7 @@ }, ), APIEx( + description="Get monthly historical prices from Yahoo Finance for Ethereum.", parameters={ "symbol": "ETH-USD", "provider": "yfinance", diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index c8dfaf088b6e..fb746b776c76 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -82,12 +82,13 @@ async def reference_rates( model="CurrencySnapshots", examples=[ APIEx( + description="Get exchange rates from USD and XAU to EUR, JPY, and GBP using 'fmp' as provider.", parameters={ "provider": "fmp", "base": "USD,XAU", "counter_currencies": "EUR,JPY,GBP", "quote_type": "indirect", - } + }, ), ], ) diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index a5d9ffaa3cdf..f18a2cf0479b 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -20,6 +20,7 @@ model="PriceTarget", examples=[ APIEx( + description="Get price targets for Microsoft using 'benzinga' as provider.", parameters={ "start_date": "2020-01-01", "end_date": "2024-02-16", @@ -27,7 +28,7 @@ "symbol": "msft", "provider": "benzinga", "action": "downgrades", - } + }, ), ], ) diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index c04175cda4a5..dd0144fcf6ac 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -76,12 +76,13 @@ async def cash( model="ReportedFinancials", examples=[ APIEx( + description="Get AAPL balance sheet with a limit of 10 items.", parameters={ "symbol": "AAPL", "period": "annual", "statement_type": "balance", - "limit": 100, - } + "limit": 10, + }, ), APIEx( description="Get reported income statement", diff --git a/openbb_platform/openbb/package/crypto_price.py b/openbb_platform/openbb/package/crypto_price.py index 3f11ad7dfca7..87a9a329d56c 100644 --- a/openbb_platform/openbb/package/crypto_price.py +++ b/openbb_platform/openbb/package/crypto_price.py @@ -124,6 +124,7 @@ def historical( >>> obb.crypto.price.historical(symbol='BTCUSD') >>> obb.crypto.price.historical(symbol='BTCUSD', start_date='2024-01-01', end_date='2024-01-31') >>> obb.crypto.price.historical(symbol='BTCUSD,ETHUSD', start_date='2024-01-01', end_date='2024-01-31') + >>> # Get monthly historical prices from Yahoo Finance for Ethereum. >>> obb.crypto.price.historical(symbol='ETH-USD', provider='yfinance', interval='1mo', start_date='2024-01-01', end_date='2024-12-31') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index d6a2f7d239f1..f656b8ce4206 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -232,6 +232,7 @@ def snapshots( Examples -------- >>> from openbb import obb + >>> # Get exchange rates from USD and XAU to EUR, JPY, and GBP using 'fmp' as provider. >>> obb.currency.snapshots(provider='fmp', base='USD,XAU', counter_currencies='EUR,JPY,GBP', quote_type='indirect') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py index 603649d09bec..74cf57e4f7a2 100644 --- a/openbb_platform/openbb/package/equity_estimates.py +++ b/openbb_platform/openbb/package/equity_estimates.py @@ -524,7 +524,8 @@ def price_target( Examples -------- >>> from openbb import obb - >>> obb.equity.estimates.price_target(start_date='2020-01-01', end_date='2024-02-16', limit=10, symbol='msft', provider='benzinga', action=downgrades) + >>> # Get price targets for Microsoft using 'benzinga' as provider. + >>> obb.equity.estimates.price_target(start_date='2020-01-01', end_date='2024-02-16', limit=10, symbol='msft', provider='benzinga', action='downgrades') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index bbebc70d3279..23badef45df8 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -3184,7 +3184,8 @@ def reported_financials( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.reported_financials(symbol='AAPL', period='annual', statement_type='balance', limit=100) + >>> # Get AAPL balance sheet with a limit of 10 items. + >>> obb.equity.fundamental.reported_financials(symbol='AAPL', period='annual', statement_type='balance', limit=10) >>> # Get reported income statement >>> obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='income') >>> # Get reported cash flow statement From 2926f27710530763bfc92d7084ccf885f90afdf4 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Wed, 6 Mar 2024 23:17:19 +0000 Subject: [PATCH 057/133] typing --- openbb_platform/core/openbb_core/app/model/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 177a8840916c..8a2f8da4c77b 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -53,7 +53,7 @@ def to_python(self, **kwargs) -> str: indentation = kwargs.get("indentation", "") func_path = kwargs.get("func_path", ".func_router.func_name") func_params: Dict[str, Field] = kwargs.get("func_params", {}) - target: str = kwargs.get("target", "docstring") + target: Literal["doctring", "website"] = kwargs.get("target", "docstring") prompt = ">>> " if target == "docstring" else "" From 994982b650fc59763e242f98adcca9b323f74e13 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 00:01:25 +0000 Subject: [PATCH 058/133] shorter error msgs --- .../economy/openbb_economy/economy_router.py | 24 ++++++++++++------- .../extensions/tests/utils/router_testers.py | 19 +++++++-------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index bdece3840978..68ddb1d45190 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -22,6 +22,10 @@ @router.command( model="EconomicCalendar", examples=[ + APIEx( + parameters={}, + description="By default, the calendar will be forward-looking.", + ), APIEx( parameters={ "provider": "fmp", @@ -85,6 +89,7 @@ async def risk_premium( @router.command( model="BalanceOfPayments", examples=[ + APIEx(parameters={}), APIEx(parameters={"report_type": "summary"}), APIEx( description="The `country` parameter will override the `report_type`.", @@ -120,14 +125,14 @@ async def fred_search( @router.command( model="FredSeries", examples=[ - APIEx(parameters={"series_id": "NFCI"}), + APIEx(parameters={"symbol": "NFCI"}), APIEx( description="Multiple series can be passed in as a list.", - parameters={"series_id": "NFCI,STLFSI4"}, + parameters={"symbol": "NFCI,STLFSI4"}, ), APIEx( description="Use the `transform` parameter to transform the data as change, log, or percent change.", - parameters={"series_id": "CBBTCUSD", "transform": "pc1"}, + parameters={"symbol": "CBBTCUSD", "transform": "pc1"}, ), ], ) @@ -177,7 +182,7 @@ async def unemployment( @router.command( model="CLI", - examples=[APIEx(parameters={"country": "all"})], + examples=[APIEx(parameters={}), APIEx(parameters={"country": "all"})], ) async def composite_leading_indicator( cc: CommandContext, @@ -238,13 +243,14 @@ async def long_term_interest_rate( @router.command( model="FredRegional", examples=[ - APIEx( - description="With no date, the most recent report is returned.", - parameters={"series_id": "NYICLAIMS"}, - ), APIEx( description="With a date, time series data is returned.", - parameters={"series_id": "NYICLAIMS", "start_date": "2021-01-01"}, + parameters={ + "symbol": "NYICLAIMS", + "start_date": "2021-01-01", + "end_date": "2021-12-31", + "limit": 10, + }, ), ], ) diff --git a/openbb_platform/extensions/tests/utils/router_testers.py b/openbb_platform/extensions/tests/utils/router_testers.py index 1cd6c2ef6483..bc8af3f210da 100644 --- a/openbb_platform/extensions/tests/utils/router_testers.py +++ b/openbb_platform/extensions/tests/utils/router_testers.py @@ -53,7 +53,7 @@ def check_router_model_functions_signature() -> List[str]: args = list(function.__code__.co_varnames) if args != expected_args and "model" in decorator: missing_args.append( - f"{function.__name__} in {router_name} doesn't have the expected args: {expected_args}" + f"{function.__name__} in {router_name} missing expected args: {expected_args}" ) if expected_return_type not in str(function.__annotations__["return"]): missing_return_type.append( @@ -81,7 +81,7 @@ def check_general_example_violations( # Check if the endpoint has examples if "examples" not in keywords or not examples: general_violation.append( - f"{function.__name__} in {router_name} doesn't have examples." + f"'{router_name}' > '{function.__name__}': missing examples" ) return general_violation # Check if a POST method has both API and Python examples @@ -91,11 +91,11 @@ def check_general_example_violations( ): if "APIEx" not in examples: general_violation.append( - f"{function.__name__} in {router_name} doesn't have an API example." + f"'{router_name}' > '{function.__name__}': missing API example" ) if "PythonEx" not in examples: general_violation.append( - f"{function.__name__} in {router_name} doesn't have a Python example." + f"'{router_name}' > '{function.__name__}': missing Python example" ) # Check if a POST endpoint excluded from the schema has a Python example if ( @@ -104,13 +104,13 @@ def check_general_example_violations( and ("PythonEx" not in examples) ): general_violation.append( - f"{function.__name__} in {router_name} is excluded from the" - f"schema but doesn't have a Python example." + f"'{router_name}' > '{function.__name__}': is excluded from the" + "api schema but doesn't have a Python example." ) if "APIEx" in examples: general_violation.append( - f"{function.__name__} in {router_name} is excluded from the" - f"schema but has an API example." + f"'{router_name}' > '{function.__name__}': endpoint excluded from the" + "api schema but has an API example." ) return general_violation @@ -140,8 +140,7 @@ def check_api_example_violations( break else: api_example_violation.append( - f"{function.__name__} in {router_name} doesn't have an example using only" - f" the required standard parameters." + f"'{router_name}' > '{function.__name__}': missing example with required fields only" ) return api_example_violation From 307ac0aeed1417c097326856a584bf28a8196759 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 00:08:55 +0000 Subject: [PATCH 059/133] economy router --- .../economy/openbb_economy/economy_router.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 68ddb1d45190..88b4d8318190 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -148,7 +148,7 @@ async def fred_series( @router.command( model="MoneyMeasures", - examples=[APIEx(parameters={"adjusted": False})], + examples=[APIEx(parameters={}), APIEx(parameters={"adjusted": False})], ) async def money_measures( cc: CommandContext, @@ -163,6 +163,7 @@ async def money_measures( @router.command( model="Unemployment", examples=[ + APIEx(parameters={}), APIEx(parameters={"country": "all", "frequency": "quarterly"}), APIEx( description="Demographics for the statistics are selected with the `age` and `sex` parameters.", @@ -199,7 +200,10 @@ async def composite_leading_indicator( @router.command( model="STIR", - examples=[APIEx(parameters={"country": "all", "frequency": "quarterly"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"country": "all", "frequency": "quarterly"}), + ], ) async def short_term_interest_rate( cc: CommandContext, @@ -219,7 +223,10 @@ async def short_term_interest_rate( @router.command( model="LTIR", - examples=[APIEx(parameters={"country": "all", "frequency": "quarterly"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"country": "all", "frequency": "quarterly"}), + ], ) async def long_term_interest_rate( cc: CommandContext, @@ -243,6 +250,9 @@ async def long_term_interest_rate( @router.command( model="FredRegional", examples=[ + APIEx( + parameters={"symbol": "NYICLAIMS"}, + ), APIEx( description="With a date, time series data is returned.", parameters={ From 161cd021f7b73e616bddab3fa2aab4d975e88c6c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 00:30:29 +0000 Subject: [PATCH 060/133] fix more examples --- .../openbb_commodity/commodity_router.py | 2 +- .../openbb_currency/currency_router.py | 1 + .../futures/futures_router.py | 2 +- .../options/options_router.py | 2 +- .../economy/openbb_economy/gdp/gdp_router.py | 9 ++++--- .../corporate/corporate_router.py | 10 +++---- .../openbb_fixedincome/fixedincome_router.py | 2 +- .../government/government_router.py | 4 +-- .../openbb_fixedincome/rate/rate_router.py | 26 ++++++++++++++----- .../news/openbb_news/news_router.py | 6 +++-- .../extensions/tests/test_routers.py | 2 +- 11 files changed, 42 insertions(+), 24 deletions(-) diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index f910c4d00f21..4f74f3fb5495 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -19,7 +19,7 @@ @router.command( model="LbmaFixing", examples=[ - APIEx(parameters={"asset": "gold"}), + APIEx(parameters={}), APIEx( description="Get the daily LBMA fixing prices for silver in 2023.", parameters={ diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index fb746b776c76..ae43d65b9dcc 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -81,6 +81,7 @@ async def reference_rates( @router.command( model="CurrencySnapshots", examples=[ + APIEx(parameters={}), APIEx( description="Get exchange rates from USD and XAU to EUR, JPY, and GBP using 'fmp' as provider.", parameters={ diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index 435c26b67362..e82294832105 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -46,7 +46,7 @@ async def historical( @router.command( model="FuturesCurve", examples=[ - APIEx(parameters={"symbol": "NG", "provider": "yfinance"}), + APIEx(parameters={"symbol": "NG"}), APIEx( description="Enter a date to get the term structure from a historical date.", parameters={"symbol": "NG", "provider": "yfinance", "date": "2023-01-01"}, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index 62ac081ee5cc..fb68ae4ab47f 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -19,7 +19,7 @@ @router.command( model="OptionsChains", examples=[ - APIEx(parameters={"symbol": "AAPL", "provider": "intrinio"}), + APIEx(parameters={"symbol": "AAPL"}), APIEx( description='Use the "date" parameter to get the end-of-day-data for a specific date, where supported.', parameters={"symbol": "AAPL", "date": "2023-01-25", "provider": "intrinio"}, diff --git a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py index 37c09854f71b..d9cb95a273d4 100644 --- a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py @@ -18,7 +18,10 @@ @router.command( model="GdpForecast", - examples=[APIEx(parameters={"period": "annual", "type": "real"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"period": "annual", "type": "real"}), + ], ) async def forecast( cc: CommandContext, @@ -32,7 +35,7 @@ async def forecast( @router.command( model="GdpNominal", - examples=[APIEx(parameters={"units": "usd"})], + examples=[APIEx(parameters={}), APIEx(parameters={"units": "usd"})], ) async def nominal( cc: CommandContext, @@ -46,7 +49,7 @@ async def nominal( @router.command( model="GdpReal", - examples=[APIEx(parameters={"units": "yoy"})], + examples=[APIEx(parameters={}), APIEx(parameters={"units": "yoy"})], ) async def real( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index 8d4b9c27709a..39b650da7a1e 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -18,7 +18,7 @@ @router.command( model="ICEBofA", - examples=[APIEx(parameters={"index_type": "yield_to_worst"})], + examples=[APIEx(parameters={}), APIEx(parameters={"index_type": "yield_to_worst"})], ) async def ice_bofa( cc: CommandContext, @@ -39,7 +39,7 @@ async def ice_bofa( @router.command( model="MoodyCorporateBondIndex", - examples=[APIEx(parameters={"index_type": "baa"})], + examples=[APIEx(parameters={}), APIEx(parameters={"index_type": "baa"})], ) async def moody( cc: CommandContext, @@ -59,7 +59,7 @@ async def moody( @router.command( model="HighQualityMarketCorporateBond", - examples=[APIEx(parameters={"yield_curve": "par"})], + examples=[APIEx(parameters={}), APIEx(parameters={"yield_curve": "par"})], ) async def hqm( cc: CommandContext, @@ -79,7 +79,7 @@ async def hqm( @router.command( model="SpotRate", - examples=[APIEx(parameters={"maturity": "10,20,30,50"})], + examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "10,20,30,50"})], ) async def spot_rates( cc: CommandContext, @@ -99,7 +99,7 @@ async def spot_rates( @router.command( model="CommercialPaper", - examples=[APIEx(parameters={"maturity": "15d"})], + examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "15d"})], ) async def commercial_paper( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py index e99d9b7cf0d3..8b34db4430b5 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py @@ -27,7 +27,7 @@ @router.command( model="SOFR", - examples=[APIEx(parameters={"period": "overnight"})], + examples=[APIEx(parameters={}), APIEx(parameters={"period": "overnight"})], ) async def sofr( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index 1fbaaa0ccad7..afa960148077 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -18,7 +18,7 @@ @router.command( model="USYieldCurve", - examples=[APIEx(parameters={"inflation_adjusted": True})], + examples=[APIEx(parameters={}), APIEx(parameters={"inflation_adjusted": True})], ) async def us_yield_curve( cc: CommandContext, @@ -32,7 +32,7 @@ async def us_yield_curve( @router.command( model="EUYieldCurve", - examples=[APIEx(parameters={"yield_curve_type": "spot_rate"})], + examples=[APIEx(parameters={}), APIEx(parameters={"yield_curve_type": "spot_rate"})], ) async def eu_yield_curve( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index b17f83cd3209..42a77ec76ef4 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -18,7 +18,7 @@ @router.command( model="AMERIBOR", - examples=[APIEx(parameters={"parameter": "30_day_ma"})], + examples=[APIEx(parameters={}), APIEx(parameters={"parameter": "30_day_ma"})], ) async def ameribor( cc: CommandContext, @@ -37,7 +37,7 @@ async def ameribor( @router.command( model="SONIA", - examples=[APIEx(parameters={"parameter": "total_nominal_value"})], + examples=[APIEx(parameters={}), APIEx(parameters={"parameter": "total_nominal_value"})], ) async def sonia( cc: CommandContext, @@ -75,7 +75,10 @@ async def iorb( @router.command( model="FEDFUNDS", - examples=[APIEx(parameters={"parameter": "daily", "provider": "fred"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"parameter": "daily", "provider": "fred"}), + ], ) async def effr( cc: CommandContext, @@ -94,7 +97,7 @@ async def effr( @router.command( model="PROJECTIONS", - examples=[APIEx(parameters={"long_run": True})], + examples=[APIEx(parameters={}), APIEx(parameters={"long_run": True})], ) async def effr_forecast( cc: CommandContext, @@ -114,7 +117,10 @@ async def effr_forecast( @router.command( model="ESTR", - examples=[APIEx(parameters={"parameter": "number_of_active_banks"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"parameter": "number_of_active_banks"}), + ], ) async def estr( cc: CommandContext, @@ -134,7 +140,10 @@ async def estr( @router.command( model="EuropeanCentralBankInterestRates", - examples=[APIEx(parameters={"interest_rate_type": "refinancing"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"interest_rate_type": "refinancing"}), + ], ) async def ecb( cc: CommandContext, @@ -156,7 +165,10 @@ async def ecb( @router.command( model="DiscountWindowPrimaryCreditRate", - examples=[APIEx(parameters={"start_date": "2023-02-01", "end_date": "2023-05-01"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"start_date": "2023-02-01", "end_date": "2023-05-01"}), + ], ) async def dpcredit( cc: CommandContext, diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index 2d3ba496f5ad..9aaf6274e69a 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -18,7 +18,8 @@ @router.command( model="WorldNews", examples=[ - APIEx(parameters={"limit": 2500}), + APIEx(parameters={}), + APIEx(parameters={"limit": 100}), APIEx( description="Get news on the specified dates.", parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, @@ -54,7 +55,8 @@ async def world( @router.command( model="CompanyNews", examples=[ - APIEx(parameters={"limit": 2500}), + APIEx(parameters={}), + APIEx(parameters={"limit": 100}), APIEx( description="Get news on the specified dates.", parameters={ diff --git a/openbb_platform/extensions/tests/test_routers.py b/openbb_platform/extensions/tests/test_routers.py index 136ec4720e03..19515e04523f 100644 --- a/openbb_platform/extensions/tests/test_routers.py +++ b/openbb_platform/extensions/tests/test_routers.py @@ -22,4 +22,4 @@ def test_router_model_functions_signature() -> None: def test_router_examples() -> None: """Test if the router examples are valid.""" invalid_examples = check_router_command_examples() - assert not invalid_examples, "\n".join(invalid_examples) + assert not invalid_examples, "\n".join(sorted(invalid_examples)) From dbc19affb525fcd7e1801d81c5dc9adf58e8ae69 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 00:51:33 +0000 Subject: [PATCH 061/133] more examples --- .../openbb_equity/calendar/calendar_router.py | 1 + .../openbb_equity/compare/compare_router.py | 1 + .../openbb_equity/darkpool/darkpool_router.py | 1 + .../discovery/discovery_router.py | 35 +++++++++++++------ .../equity/openbb_equity/equity_router.py | 3 +- .../estimates/estimates_router.py | 16 +++++++-- .../ownership/ownership_router.py | 10 ++++-- .../government/government_router.py | 5 ++- .../openbb_fixedincome/rate/rate_router.py | 5 ++- 9 files changed, 59 insertions(+), 18 deletions(-) diff --git a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py index 92b0a76b5e11..dac46203256c 100644 --- a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py @@ -19,6 +19,7 @@ @router.command( model="CalendarIpo", examples=[ + APIEx(parameters={}), APIEx(parameters={"limit": 100}), APIEx(description="Get all IPOs available.", parameters={}), APIEx( diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py index 50a4a75e5edc..76262f3e72d3 100644 --- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py @@ -35,6 +35,7 @@ async def peers( @router.command( model="CompareGroups", examples=[ + APIEx(parameters={}), APIEx( description="Group by sector and analyze valuation.", parameters={"group": "sector", "metric": "valuation"}, diff --git a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py index b7a9f9ea2886..2a4f54478fd5 100644 --- a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py @@ -19,6 +19,7 @@ @router.command( model="OTCAggregate", examples=[ + APIEx(parameters={}), APIEx( description="Get OTC data for a symbol", parameters={"symbol": "AAPL"}, diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index f1c1f8a92284..596665fa4576 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -15,7 +15,10 @@ router = Router(prefix="/discovery") -@router.command(model="EquityGainers", examples=[APIEx(parameters={"sort": "desc"})]) +@router.command( + model="EquityGainers", + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], +) async def gainers( cc: CommandContext, provider_choices: ProviderChoices, @@ -26,7 +29,10 @@ async def gainers( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityLosers", examples=[APIEx(parameters={"sort": "desc"})]) +@router.command( + model="EquityLosers", + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], +) async def losers( cc: CommandContext, provider_choices: ProviderChoices, @@ -37,7 +43,10 @@ async def losers( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityActive", examples=[APIEx(parameters={"sort": "desc"})]) +@router.command( + model="EquityActive", + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], +) async def active( cc: CommandContext, provider_choices: ProviderChoices, @@ -50,7 +59,7 @@ async def active( @router.command( model="EquityUndervaluedLargeCaps", - examples=[APIEx(parameters={"sort": "desc"})], + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], ) async def undervalued_large_caps( cc: CommandContext, @@ -63,7 +72,8 @@ async def undervalued_large_caps( @router.command( - model="EquityUndervaluedGrowth", examples=[APIEx(parameters={"sort": "desc"})] + model="EquityUndervaluedGrowth", + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], ) async def undervalued_growth( cc: CommandContext, @@ -77,7 +87,7 @@ async def undervalued_growth( @router.command( model="EquityAggressiveSmallCaps", - examples=[APIEx(parameters={"sort": "desc"})], + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], ) async def aggressive_small_caps( cc: CommandContext, @@ -90,7 +100,8 @@ async def aggressive_small_caps( @router.command( - model="GrowthTechEquities", examples=[APIEx(parameters={"sort": "desc"})] + model="GrowthTechEquities", + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], ) async def growth_tech( cc: CommandContext, @@ -102,7 +113,10 @@ async def growth_tech( return await OBBject.from_query(Query(**locals())) -@router.command(model="TopRetail", examples=[APIEx(parameters={"sort": "desc"})]) +@router.command( + model="TopRetail", + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], +) async def top_retail( cc: CommandContext, provider_choices: ProviderChoices, @@ -117,7 +131,8 @@ async def top_retail( @router.command( - model="UpcomingReleaseDays", examples=[APIEx(parameters={"sort": "desc"})] + model="UpcomingReleaseDays", + examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], ) async def upcoming_release_days( cc: CommandContext, @@ -132,7 +147,7 @@ async def upcoming_release_days( @router.command( model="DiscoveryFilings", examples=[ - APIEx(parameters={"limit": 100}), + APIEx(parameters={}), APIEx( description="Get filings for the year 2023, limited to 100 results", parameters={ diff --git a/openbb_platform/extensions/equity/openbb_equity/equity_router.py b/openbb_platform/extensions/equity/openbb_equity/equity_router.py index 08bd7f2ea110..766ee2f8a9a2 100644 --- a/openbb_platform/extensions/equity/openbb_equity/equity_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/equity_router.py @@ -38,7 +38,8 @@ @router.command( model="EquitySearch", examples=[ - APIEx(parameters={"query": "AAPL", "is_symbol": False, "use_cache": True}) + APIEx(parameters={}), + APIEx(parameters={"query": "AAPL", "is_symbol": False, "use_cache": True}), ], ) async def search( diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index f18a2cf0479b..0aa16d91d5b7 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -19,6 +19,7 @@ @router.command( model="PriceTarget", examples=[ + APIEx(parameters={}), APIEx( description="Get price targets for Microsoft using 'benzinga' as provider.", parameters={ @@ -44,7 +45,10 @@ async def price_target( @router.command( model="AnalystEstimates", - examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + ], ) async def historical( cc: CommandContext, @@ -58,7 +62,10 @@ async def historical( @router.command( model="PriceTargetConsensus", - examples=[APIEx(parameters={"symbol": "AAPL,MSFT", "provider": "yfinance"})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL,MSFT", "provider": "yfinance"}), + ], ) async def consensus( cc: CommandContext, @@ -72,7 +79,10 @@ async def consensus( @router.command( model="AnalystSearch", - examples=[APIEx(parameters={"firm_name": "Wedbush", "provider": "benzinga"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"firm_name": "Wedbush", "provider": "benzinga"}), + ], ) async def analyst_search( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index bc5346f50bc4..e360ecb6a27a 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -18,7 +18,10 @@ @router.command( model="EquityOwnership", - examples=[APIEx(parameters={"symbol": "AAPL", "page": 0})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "page": 0}), + ], ) async def major_holders( cc: CommandContext, @@ -46,7 +49,10 @@ async def institutional( @router.command( model="InsiderTrading", - examples=[APIEx(parameters={"symbol": "AAPL", "limit": 500})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "limit": 500}), + ], ) async def insider_trading( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index afa960148077..a22c86e0ae5c 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -32,7 +32,10 @@ async def us_yield_curve( @router.command( model="EUYieldCurve", - examples=[APIEx(parameters={}), APIEx(parameters={"yield_curve_type": "spot_rate"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"yield_curve_type": "spot_rate"}), + ], ) async def eu_yield_curve( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index 42a77ec76ef4..251169d5ebcb 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -37,7 +37,10 @@ async def ameribor( @router.command( model="SONIA", - examples=[APIEx(parameters={}), APIEx(parameters={"parameter": "total_nominal_value"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"parameter": "total_nominal_value"}), + ], ) async def sonia( cc: CommandContext, From 629a7a58edd27824f2f602b1e6f91993ece5acd5 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 01:28:34 +0000 Subject: [PATCH 062/133] more examples --- .../trailing_dividend_yield.py | 4 +- .../fundamental/fundamental_router.py | 61 ++++++++++++++----- .../ownership/ownership_router.py | 5 +- .../openbb_equity/price/price_router.py | 2 +- .../extensions/etf/openbb_etf/etf_router.py | 20 +++--- .../government/government_router.py | 7 ++- .../spreads/spreads_router.py | 6 +- .../index/openbb_index/index_router.py | 13 ++-- .../index/openbb_index/price/price_router.py | 1 + .../openbb_regulators/cftc/cftc_router.py | 3 +- .../openbb_regulators/sec/sec_router.py | 12 +++- 11 files changed, 90 insertions(+), 44 deletions(-) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/trailing_dividend_yield.py b/openbb_platform/core/openbb_core/provider/standard_models/trailing_dividend_yield.py index 473d276d5e65..b3aa8ebed660 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/trailing_dividend_yield.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/trailing_dividend_yield.py @@ -16,9 +16,7 @@ class TrailingDivYieldQueryParams(QueryParams): """Trailing Dividend Yield Query.""" - symbol: Optional[str] = Field( - default=None, description=QUERY_DESCRIPTIONS.get("symbol", "") - ) + symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) limit: Optional[int] = Field( default=252, description=f"{QUERY_DESCRIPTIONS.get('limit', '')}" diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index dd0144fcf6ac..265e6bad0eaf 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -32,7 +32,10 @@ async def multiples( @router.command( model="BalanceSheet", - examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}), + ], ) async def balance( cc: CommandContext, @@ -46,7 +49,10 @@ async def balance( @router.command( model="BalanceSheetGrowth", - examples=[APIEx(parameters={"symbol": "AAPL", "limit": 10})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "limit": 10}), + ], ) async def balance_growth( cc: CommandContext, @@ -60,7 +66,10 @@ async def balance_growth( @router.command( model="CashFlowStatement", - examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}), + ], ) async def cash( cc: CommandContext, @@ -75,6 +84,7 @@ async def cash( @router.command( model="ReportedFinancials", examples=[ + APIEx(parameters={"symbol": "AAPL"}), APIEx( description="Get AAPL balance sheet with a limit of 10 items.", parameters={ @@ -106,7 +116,10 @@ async def reported_financials( @router.command( model="CashFlowStatementGrowth", - examples=[APIEx(parameters={"symbol": "AAPL", "limit": 10})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "limit": 10}), + ], ) async def cash_growth( cc: CommandContext, @@ -171,7 +184,7 @@ async def search_attributes( @router.command( model="LatestAttributes", - examples=[APIEx(parameters={"tag": "ceo"})], + examples=[APIEx(parameters={"symbol": "AAPL", "tag": "ceo"})], ) async def latest_attributes( cc: CommandContext, @@ -185,7 +198,7 @@ async def latest_attributes( @router.command( model="HistoricalAttributes", - examples=[APIEx(parameters={"tag": "ebitda"})], + examples=[APIEx(parameters={"symbol": "AAPL", "tag": "ebitda"})], ) async def historical_attributes( cc: CommandContext, @@ -199,7 +212,10 @@ async def historical_attributes( @router.command( model="IncomeStatement", - examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}), + ], ) async def income( cc: CommandContext, @@ -213,7 +229,10 @@ async def income( @router.command( model="IncomeStatementGrowth", - examples=[APIEx(parameters={"symbol": "AAPL", "limit": 10, "period": "annual"})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "limit": 10, "period": "annual"}), + ], ) async def income_growth( cc: CommandContext, @@ -227,7 +246,10 @@ async def income_growth( @router.command( model="KeyMetrics", - examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 100})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 100}), + ], ) async def metrics( cc: CommandContext, @@ -285,7 +307,10 @@ async def overview( @router.command( model="FinancialRatios", - examples=[APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 12})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 12}), + ], ) async def ratios( cc: CommandContext, @@ -300,7 +325,8 @@ async def ratios( @router.command( model="RevenueGeographic", examples=[ - APIEx(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}), ], ) async def revenue_per_geography( @@ -316,7 +342,8 @@ async def revenue_per_geography( @router.command( model="RevenueBusinessLine", examples=[ - APIEx(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}) + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}), ], ) async def revenue_per_segment( @@ -329,7 +356,10 @@ async def revenue_per_segment( return await OBBject.from_query(Query(**locals())) -@router.command(model="CompanyFilings", examples=[APIEx(parameters={"limit": 100})]) +@router.command( + model="CompanyFilings", + examples=[APIEx(parameters={}), APIEx(parameters={"limit": 100})], +) async def filings( cc: CommandContext, provider_choices: ProviderChoices, @@ -374,7 +404,10 @@ async def transcript( @router.command( model="TrailingDividendYield", - examples=[APIEx(parameters={"symbol": "AAPL", "limit": 252})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "limit": 252}), + ], ) async def trailing_dividend_yield( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index e360ecb6a27a..552fd3f3b95b 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -80,10 +80,7 @@ async def share_statistics( @router.command( model="Form13FHR", examples=[ - APIEx( - description="Enter the symbol as either the stock ticker or the CIK number as a string.", - parameters={"symbol": "NVDA"}, - ), + APIEx(parameters={"symbol": "NVDA"}), APIEx( description="Enter a date (calendar quarter ending) for a specific report.", parameters={"symbol": "BRK-A", "date": "2016-09-30"}, diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index e5ac1ecf1fbc..776fc3e60d11 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -40,7 +40,7 @@ async def nbbo( @router.command( model="EquityHistorical", - examples=[APIEx(parameters={"symbol": "AAPL", "interval": "1d"})], + examples=[APIEx(parameters={"symbol": "AAPL"}), APIEx(parameters={"symbol": "AAPL", "interval": "1d"})], ) async def historical( cc: CommandContext, diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index 9657ac8128b9..9fa9240ea42b 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -22,6 +22,7 @@ @router.command( model="EtfSearch", examples=[ + APIEx(parameters={}), APIEx( description="An empty query returns the full list of ETFs from the provider.", parameters={}, @@ -70,7 +71,7 @@ async def historical( @router.command( model="EtfInfo", examples=[ - APIEx(parameters={"symbol": "SPY", "provider": "fmp"}), + APIEx(parameters={"symbol": "SPY"}), APIEx( description="This function accepts multiple tickers.", parameters={"symbol": "SPY,IWM,QQQ,DJIA", "provider": "fmp"}, @@ -89,7 +90,7 @@ async def info( @router.command( model="EtfSectors", - examples=[APIEx(parameters={"symbol": "SPY", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "SPY"})], ) async def sectors( cc: CommandContext, @@ -103,7 +104,7 @@ async def sectors( @router.command( model="EtfCountries", - examples=[APIEx(parameters={"symbol": "VT", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "VT"})], ) async def countries( cc: CommandContext, @@ -117,7 +118,10 @@ async def countries( @router.command( model="PricePerformance", - examples=[APIEx(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"})], + examples=[ + APIEx(parameters={"symbol": "QQQ"}), + APIEx(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"}), + ], ) async def price_performance( cc: CommandContext, @@ -132,7 +136,7 @@ async def price_performance( @router.command( model="EtfHoldings", examples=[ - APIEx(parameters={"symbol": "XLK", "provider": "fmp"}), + APIEx(parameters={"symbol": "XLK"}), APIEx( description="Including a date (FMP, SEC) will return the holdings as per NPORT-P filings.", parameters={"symbol": "XLK", "date": "2022-03-31", "provider": "fmp"}, @@ -155,7 +159,7 @@ async def holdings( @router.command( model="EtfHoldingsDate", - examples=[APIEx(parameters={"symbol": "XLK", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "XLK"})], ) async def holdings_date( cc: CommandContext, @@ -169,7 +173,7 @@ async def holdings_date( @router.command( model="EtfHoldingsPerformance", - examples=[APIEx(parameters={"symbol": "XLK", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "XLK"})], ) async def holdings_performance( cc: CommandContext, @@ -184,7 +188,7 @@ async def holdings_performance( @router.command( model="EtfEquityExposure", examples=[ - APIEx(parameters={"symbol": "MSFT", "provider": "fmp"}), + APIEx(parameters={"symbol": "MSFT"}), APIEx( description="This function accepts multiple tickers.", parameters={"symbol": "MSFT,AAPL", "provider": "fmp"}, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index a22c86e0ae5c..bb8f5ea9125a 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -68,7 +68,7 @@ async def eu_yield_curve( @router.command( model="TreasuryRates", - examples=[APIEx(parameters={"provider": "federal_reserve"})], + examples=[APIEx(parameters={}), APIEx(parameters={"provider": "federal_reserve"})], ) async def treasury_rates( cc: CommandContext, @@ -83,13 +83,14 @@ async def treasury_rates( @router.command( model="TreasuryAuctions", examples=[ + APIEx(parameters={}), APIEx( parameters={ "security_type": "Bill", "start_date": "2022-01-01", "end_date": "2023-01-01", } - ) + ), ], ) async def treasury_auctions( @@ -104,7 +105,7 @@ async def treasury_auctions( @router.command( model="TreasuryPrices", - examples=[APIEx(parameters={"date": "2019-02-05"})], + examples=[APIEx(parameters={}), APIEx(parameters={"date": "2019-02-05"})], ) async def treasury_prices( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py index 0a9f77fc1bdc..c69f9ec7ec9f 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py @@ -18,7 +18,7 @@ @router.command( model="TreasuryConstantMaturity", - examples=[APIEx(parameters={"maturity": "2y"})], + examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "2y"})], ) async def tcm( cc: CommandContext, @@ -38,7 +38,7 @@ async def tcm( @router.command( model="SelectedTreasuryConstantMaturity", - examples=[APIEx(parameters={"maturity": "10y"})], + examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "10y"})], ) async def tcm_effr( cc: CommandContext, @@ -58,7 +58,7 @@ async def tcm_effr( @router.command( model="SelectedTreasuryBill", - examples=[APIEx(parameters={"maturity": "6m"})], + examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "6m"})], ) async def treasury_effr( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index 21bb96e37676..130d2f283678 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -43,6 +43,7 @@ async def market( @router.command( model="IndexConstituents", examples=[ + APIEx(parameters={"symbol": "dowjones"}), APIEx(parameters={"symbol": "dowjones", "provider": "fmp"}), APIEx( description="Providers other than FMP will use the ticker symbol.", @@ -76,7 +77,7 @@ async def snapshots( @router.command( model="AvailableIndices", - examples=[APIEx(parameters={"provider": "yfinance"})], + examples=[APIEx(parameters={}), APIEx(parameters={"provider": "yfinance"})], ) async def available( cc: CommandContext, @@ -90,7 +91,10 @@ async def available( @router.command( model="IndexSearch", - examples=[APIEx(parameters={"query": "SPX", "provider": "cboe"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"query": "SPX", "provider": "cboe"}), + ], ) async def search( cc: CommandContext, @@ -105,7 +109,8 @@ async def search( @router.command( model="SP500Multiples", examples=[ - APIEx(parameters={"series_name": "shiller_pe_year", "provider": "nasdaq"}) + APIEx(parameters={}), + APIEx(parameters={"series_name": "shiller_pe_year", "provider": "nasdaq"}), ], ) async def sp500_multiples( @@ -120,7 +125,7 @@ async def sp500_multiples( @router.command( model="IndexSectors", - examples=[APIEx(parameters={"symbol": "^TX60", "provider": "tmx"})], + examples=[APIEx(parameters={"symbol": "^TX60"})], ) async def sectors( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index 883427d5f4cc..4e3595b64726 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -19,6 +19,7 @@ @router.command( model="IndexHistorical", examples=[ + APIEx(parameters={"symbol": "^GSPC"}), APIEx(parameters={"symbol": "^GSPC", "provider": "fmp"}), APIEx( description="Not all providers have the same symbols.", diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 9159021d5c64..386ab0cce125 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -17,7 +17,7 @@ @router.command( model="COTSearch", - examples=[APIEx(parameters={"query": "gold"})], + examples=[APIEx(parameters={}), APIEx(parameters={"query": "gold"})], ) async def cot_search( cc: CommandContext, @@ -35,6 +35,7 @@ async def cot_search( @router.command( model="COT", examples=[ + APIEx(parameters={}), APIEx( description="Get the Commitment of Traders Report for Gold.", parameters={"series_id": "GC=F"}, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index eb6340a3184b..fea9d3a86ccb 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -31,7 +31,10 @@ async def cik_map( @router.command( model="InstitutionsSearch", - examples=[APIEx(parameters={"query": "blackstone real estate"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"query": "blackstone real estate"}), + ], ) async def institutions_search( cc: CommandContext, @@ -83,7 +86,7 @@ async def schema_files( @router.command( model="SymbolMap", - examples=[APIEx(parameters={"cik": "0000789019"})], + examples=[APIEx(parameters={}), APIEx(parameters={"cik": "0000789019"})], ) async def symbol_map( cc: CommandContext, @@ -111,7 +114,10 @@ async def rss_litigation( @router.command( model="SicSearch", - examples=[APIEx(parameters={"query": "real estate investment trusts"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"query": "real estate investment trusts"}), + ], ) async def sic_search( cc: CommandContext, From 31f96e402d26fa9c4ae7fc98a844c48b97d67ed8 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 01:39:37 +0000 Subject: [PATCH 063/133] more examples --- .../provider/standard_models/equity_short_interest.py | 3 ++- .../openbb_core/provider/standard_models/short_volume.py | 2 +- .../extensions/equity/openbb_equity/price/price_router.py | 5 ++++- .../extensions/equity/openbb_equity/shorts/shorts_router.py | 2 +- .../extensions/index/openbb_index/index_router.py | 5 ++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/equity_short_interest.py b/openbb_platform/core/openbb_core/provider/standard_models/equity_short_interest.py index 7f841a5849f8..5cd60bb3de3b 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/equity_short_interest.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/equity_short_interest.py @@ -1,6 +1,7 @@ """Equity Short Interest Standard Model.""" from datetime import date as dateType +from typing import Optional from pydantic import Field @@ -15,7 +16,7 @@ class ShortInterestQueryParams(QueryParams): """Equity Short Interest Query.""" - symbol: str = Field( + symbol: Optional[str] = Field( description=QUERY_DESCRIPTIONS.get("symbol", ""), default=None, ) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/short_volume.py b/openbb_platform/core/openbb_core/provider/standard_models/short_volume.py index d836e186085b..020f819da157 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/short_volume.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/short_volume.py @@ -16,7 +16,7 @@ class ShortVolumeQueryParams(QueryParams): """Short Volume Query.""" - symbol: str = Field(default=None, description=QUERY_DESCRIPTIONS.get("symbol")) + symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol")) class ShortVolumeData(Data): diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index 776fc3e60d11..f2268fe92dbf 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -40,7 +40,10 @@ async def nbbo( @router.command( model="EquityHistorical", - examples=[APIEx(parameters={"symbol": "AAPL"}), APIEx(parameters={"symbol": "AAPL", "interval": "1d"})], + examples=[ + APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "interval": "1d"}), + ], ) async def historical( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index d917c1a8fd38..ff88d06f9111 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -46,7 +46,7 @@ async def short_volume( @router.command( model="EquityShortInterest", - examples=[APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={}), APIEx(parameters={"symbol": "AAPL"})], ) async def short_interest( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index 130d2f283678..0e207de9c5f0 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -63,7 +63,10 @@ async def constituents( @router.command( model="IndexSnapshots", - examples=[APIEx(parameters={"region": "us", "provider": "cboe"})], + examples=[ + APIEx(parameters={}), + APIEx(parameters={"region": "us", "provider": "cboe"}), + ], ) async def snapshots( cc: CommandContext, From 99476a3e75aa62786b0a043238d8d7ed6a3284fa Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 09:59:43 +0000 Subject: [PATCH 064/133] field desc --- .../core/openbb_core/app/model/example.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 8a2f8da4c77b..882fb375e1ad 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -4,7 +4,13 @@ from dataclasses import Field from typing import Dict, List, Literal, Optional, Union -from pydantic import BaseModel, ConfigDict, computed_field, model_validator +from pydantic import ( + BaseModel, + ConfigDict, + computed_field, + model_validator, + Field as PydanticField, +) class Example(BaseModel): @@ -23,7 +29,9 @@ class APIEx(Example): """API Example model.""" scope: Literal["api"] = "api" - description: Optional[str] = None + description: Optional[str] = PydanticField( + None, description="Optional description unless more than 3 parameters" + ) parameters: Dict[str, Union[str, int, float, bool, None]] @computed_field # type: ignore[misc] From ad2d8c396e8a9ae03b0e2a20e98f6073caf4dbfe Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 10:31:45 +0000 Subject: [PATCH 065/133] minor fix --- openbb_platform/core/openbb_core/app/model/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 882fb375e1ad..e6f96e595006 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -30,7 +30,7 @@ class APIEx(Example): scope: Literal["api"] = "api" description: Optional[str] = PydanticField( - None, description="Optional description unless more than 3 parameters" + default=None, description="Optional description unless more than 3 parameters" ) parameters: Dict[str, Union[str, int, float, bool, None]] From b4f5a6c8fa491b8be5fa8bc2d9a59d59defc51dc Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 10:51:47 +0000 Subject: [PATCH 066/133] fix etf examples --- .../etf/openbb_etf/discovery/discovery_router.py | 7 +++++-- .../extensions/tests/utils/router_testers.py | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py index c77c5b98f316..f177f95453d1 100644 --- a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py @@ -20,6 +20,7 @@ model="ETFGainers", operation_id="etf_gainers", examples=[ + APIEx(parameters={}), APIEx(description="Get the top ETF gainers.", parameters={"provider": "wsj"}), ], ) @@ -37,7 +38,8 @@ async def gainers( model="ETFLosers", operation_id="etf_losers", examples=[ - APIEx(description="Get the top ETF losers.", parameters={"provider": "wsj"}) + APIEx(parameters={}), + APIEx(description="Get the top ETF losers.", parameters={"provider": "wsj"}), ], ) async def losers( @@ -54,7 +56,8 @@ async def losers( model="ETFActive", operation_id="etf_active", examples=[ - APIEx(description="Get the most active ETFs.", parameters={"provider": "wsj"}) + APIEx(parameters={}), + APIEx(description="Get the most active ETFs.", parameters={"provider": "wsj"}), ], ) async def active( diff --git a/openbb_platform/extensions/tests/utils/router_testers.py b/openbb_platform/extensions/tests/utils/router_testers.py index bc8af3f210da..2a5e52cddee0 100644 --- a/openbb_platform/extensions/tests/utils/router_testers.py +++ b/openbb_platform/extensions/tests/utils/router_testers.py @@ -124,8 +124,8 @@ def check_api_example_violations( Criteria -------- - When using models, at least one example using all required standard parameters. - It cannot use any provider specific parameters here. - It should not specify the provider field. + - It cannot use any provider specific parameters here. + - It should not specify the provider field. """ api_example_violation: List[str] = [] @@ -140,7 +140,7 @@ def check_api_example_violations( break else: api_example_violation.append( - f"'{router_name}' > '{function.__name__}': missing example with required fields only" + f"'{router_name}' > '{function.__name__}': missing example with required fields only > {required_fields}" ) return api_example_violation @@ -159,8 +159,8 @@ def check_router_command_examples() -> List[str]: API examples: - At least one example using all required parameters. - It cannot use any provider specific parameters here. - It should not specify the provider field. + - It cannot use any provider specific parameters here. + - It should not specify the provider field. """ general_violation: List[str] = [] api_example_violation: List[str] = [] From b3e547374c5574ebaf9c9e1df57f8595f3e51445 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 11:44:44 +0000 Subject: [PATCH 067/133] handling types better --- .../core/openbb_core/app/model/example.py | 28 +++++++++---------- .../openbb_core/app/static/package_builder.py | 16 +++++------ .../econometrics_router.py | 3 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index e6f96e595006..a5b062958885 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,7 +1,7 @@ """Example class to represent endpoint examples.""" from abc import abstractmethod -from dataclasses import Field +import datetime from typing import Dict, List, Literal, Optional, Union from pydantic import ( @@ -9,9 +9,10 @@ ConfigDict, computed_field, model_validator, - Field as PydanticField, + Field, ) +QUOTE_TYPES = {str, datetime.date} class Example(BaseModel): """Example model.""" @@ -29,10 +30,10 @@ class APIEx(Example): """API Example model.""" scope: Literal["api"] = "api" - description: Optional[str] = PydanticField( + description: Optional[str] = Field( default=None, description="Optional description unless more than 3 parameters" ) - parameters: Dict[str, Union[str, int, float, bool, None]] + parameters: Dict[str, Union[str, int, float, bool, list, None]] @computed_field # type: ignore[misc] @property @@ -56,11 +57,10 @@ def check_model(cls, values: dict) -> dict: def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" - BASIC_TYPES = {int, float, bool} indentation = kwargs.get("indentation", "") func_path = kwargs.get("func_path", ".func_router.func_name") - func_params: Dict[str, Field] = kwargs.get("func_params", {}) + param_types: Dict[str, type] = kwargs.get("param_types", {}) target: Literal["doctring", "website"] = kwargs.get("target", "docstring") prompt = ">>> " if target == "docstring" else "" @@ -71,13 +71,13 @@ def to_python(self, **kwargs) -> str: eg += f"{indentation}{prompt}obb{func_path}(" for k, v in self.parameters.items(): - if k in func_params and (field := func_params.get(k)): - if BASIC_TYPES.intersection(unpack_types(field.type)): - eg += f"{k}={v}, " - else: + if k in param_types and (type_ := param_types.get(k)): + if QUOTE_TYPES.intersection(unpack_type(type_)): eg += f"{k}='{v}', " + else: + eg += f"{k}={v}, " else: - eg += f"{k}='{v}', " + eg += f"{k}={v}, " eg = indentation + eg.strip(", ") + ")\n" @@ -121,8 +121,8 @@ def filter_list( ] -def unpack_types(type_: type): +def unpack_type(type_: type): """Unpack types.""" if hasattr(type_, "__args__"): - return set().union(*map(unpack_types, type_.__args__)) - return {type_} + return set().union(*map(unpack_type, type_.__args__)) + return {type_} if isinstance(type_, type) else {type(type_)} diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 2c9a86e01b07..71f4877ec712 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -880,7 +880,7 @@ def get_OBBject_description( @staticmethod def append_examples( func_path: str, - func_params: Dict[str, Field], + param_types: Dict[str, type], examples: Optional[List[Example]], target: Literal["docstring", "website"] = "docstring", ) -> str: @@ -900,7 +900,7 @@ def append_examples( for e in examples: doc += e.to_python( func_path=func_path, - func_params=func_params, + param_types=param_types, indentation=indent, target=target, ) @@ -1034,7 +1034,7 @@ def generate( ) -> Optional[str]: """Generate the docstring for the function.""" doc = func.__doc__ or "" - func_params = {} + param_types = {} if model_name: params = cls.provider_interface.params.get(model_name, {}) return_schema = cls.provider_interface.return_schema.get(model_name, None) @@ -1042,10 +1042,10 @@ def generate( explicit_dict = dict(formatted_params) explicit_dict.pop("extra_params", None) kwarg_params = params["extra"].__dataclass_fields__ - func_params = { - **params["standard"].__dataclass_fields__, - **params["extra"].__dataclass_fields__, - } + + param_types = {k: v.annotation for k, v in explicit_dict.items()} + param_types.update({k: v.type for k, v in kwarg_params.items()}) + returns = return_schema.model_fields results_type = func.__annotations__.get("return", model_name) if hasattr(results_type, "results_type_repr"): @@ -1065,7 +1065,7 @@ def generate( if doc and examples: doc += cls.append_examples( path.replace("/", "."), - func_params, + param_types, examples, ) diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index c61f8fee8a05..a42a8720f174 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -15,7 +15,7 @@ PooledOLS, RandomEffects, ) -from openbb_core.app.model.example import PythonEx +from openbb_core.app.model.example import APIEx, PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import basemodel_to_df, get_target_column, get_target_columns @@ -33,6 +33,7 @@ @router.command( methods=["POST"], examples=[ + APIEx(parameters={"data": [{"x": 1, "y": 2}, {"x": 2, "y": 3}, {"x": 3, "y": 4}]}), PythonEx( description="Get the correlation matrix of a dataset.", code=[ From b7f181c44c9b313481a6446d01997519f51e3e43 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 11:45:09 +0000 Subject: [PATCH 068/133] lint --- openbb_platform/core/openbb_core/app/model/example.py | 5 +++-- .../econometrics/openbb_econometrics/econometrics_router.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index a5b062958885..48ac02fb470c 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,19 +1,20 @@ """Example class to represent endpoint examples.""" -from abc import abstractmethod import datetime +from abc import abstractmethod from typing import Dict, List, Literal, Optional, Union from pydantic import ( BaseModel, ConfigDict, + Field, computed_field, model_validator, - Field, ) QUOTE_TYPES = {str, datetime.date} + class Example(BaseModel): """Example model.""" diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index a42a8720f174..e42f5a07488e 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -33,14 +33,16 @@ @router.command( methods=["POST"], examples=[ - APIEx(parameters={"data": [{"x": 1, "y": 2}, {"x": 2, "y": 3}, {"x": 3, "y": 4}]}), + APIEx( + parameters={"data": [{"x": 1, "y": 2}, {"x": 2, "y": 3}, {"x": 3, "y": 4}]} + ), PythonEx( description="Get the correlation matrix of a dataset.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.econometrics.correlation_matrix(data=stock_data)", ], - ) + ), ], ) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: From 07ef010e178c274b77d9d6ec18abb0ecc4022a5b Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 11:46:46 +0000 Subject: [PATCH 069/133] rename method --- .../core/openbb_core/app/static/package_builder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 71f4877ec712..4b19b72377a3 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -878,7 +878,7 @@ def get_OBBject_description( return obbject_description @staticmethod - def append_examples( + def build_examples( func_path: str, param_types: Dict[str, type], examples: Optional[List[Example]], @@ -1063,7 +1063,7 @@ def generate( doc = doc.replace("\n ", f"\n{create_indent(2)}") if doc and examples: - doc += cls.append_examples( + doc += cls.build_examples( path.replace("/", "."), param_types, examples, From 06ee1d4d6e9ee5f280bbe1d8d1706f4e3b5552eb Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 11:47:53 +0000 Subject: [PATCH 070/133] rename var --- .../core/openbb_core/app/static/package_builder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 4b19b72377a3..71776a3206b1 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -1039,11 +1039,11 @@ def generate( params = cls.provider_interface.params.get(model_name, {}) return_schema = cls.provider_interface.return_schema.get(model_name, None) if params and return_schema: - explicit_dict = dict(formatted_params) - explicit_dict.pop("extra_params", None) + explicit_params = dict(formatted_params) + explicit_params.pop("extra_params", None) kwarg_params = params["extra"].__dataclass_fields__ - param_types = {k: v.annotation for k, v in explicit_dict.items()} + param_types = {k: v.annotation for k, v in explicit_params.items()} param_types.update({k: v.type for k, v in kwarg_params.items()}) returns = return_schema.model_fields @@ -1054,7 +1054,7 @@ def generate( doc = cls.generate_model_docstring( model_name=model_name, summary=func.__doc__ or "", - explicit_params=explicit_dict, + explicit_params=explicit_params, kwarg_params=kwarg_params, returns=returns, results_type=results_type, From 0ed69e90febb0cd907c40dbb19314fd3ef9f4a6c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 11:55:09 +0000 Subject: [PATCH 071/133] docstring + move method --- .../core/openbb_core/app/model/example.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 48ac02fb470c..dd6e187ba32f 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -56,6 +56,13 @@ def check_model(cls, values: dict) -> dict: ) return values + @staticmethod + def unpack_type(type_: type): + """Unpack types from types, works with nested types, like Union[List[str], int].""" + if hasattr(type_, "__args__"): + return set().union(*map(APIEx.unpack_type, type_.__args__)) + return {type_} if isinstance(type_, type) else {type(type_)} + def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" @@ -73,7 +80,7 @@ def to_python(self, **kwargs) -> str: eg += f"{indentation}{prompt}obb{func_path}(" for k, v in self.parameters.items(): if k in param_types and (type_ := param_types.get(k)): - if QUOTE_TYPES.intersection(unpack_type(type_)): + if QUOTE_TYPES.intersection(self.unpack_type(type_)): eg += f"{k}='{v}', " else: eg += f"{k}={v}, " @@ -120,10 +127,3 @@ def filter_list( if (isinstance(e, APIEx) and (not e.provider or e.provider in providers)) or e.scope != "api" ] - - -def unpack_type(type_: type): - """Unpack types.""" - if hasattr(type_, "__args__"): - return set().union(*map(unpack_type, type_.__args__)) - return {type_} if isinstance(type_, type) else {type(type_)} From d4d6d6dede7dcfc35098b85a0054d601811ac6da Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 11:56:16 +0000 Subject: [PATCH 072/133] typing --- openbb_platform/core/openbb_core/app/model/example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index dd6e187ba32f..627b7552e619 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -57,8 +57,8 @@ def check_model(cls, values: dict) -> dict: return values @staticmethod - def unpack_type(type_: type): - """Unpack types from types, works with nested types, like Union[List[str], int].""" + def unpack_type(type_: type) -> set: + """Unpack types from types, example Union[List[str], int] -> {str, int}.""" if hasattr(type_, "__args__"): return set().union(*map(APIEx.unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} From d0a610b39ac6bd5153c5a352213ff366bcf1c3a8 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 12:03:00 +0000 Subject: [PATCH 073/133] prompt --- openbb_platform/core/openbb_core/app/model/example.py | 4 +--- .../core/openbb_core/app/static/package_builder.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 627b7552e619..97544d630729 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -69,9 +69,7 @@ def to_python(self, **kwargs) -> str: indentation = kwargs.get("indentation", "") func_path = kwargs.get("func_path", ".func_router.func_name") param_types: Dict[str, type] = kwargs.get("param_types", {}) - target: Literal["doctring", "website"] = kwargs.get("target", "docstring") - - prompt = ">>> " if target == "docstring" else "" + prompt = kwargs.get("prompt", "") eg = "" if self.description: diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 71776a3206b1..e69dea82b674 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -902,7 +902,7 @@ def build_examples( func_path=func_path, param_types=param_types, indentation=indent, - target=target, + prompt=">>> " if target == "docstring" else "", ) return doc if target == "docstring" else doc + "```\n\n" return "" From 5d16a0f2d591a7c92e73fb770938d519d8a6c83f Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 12:17:05 +0000 Subject: [PATCH 074/133] rebuild --- .../openbb_regulators/sec/sec_router.py | 2 +- openbb_platform/openbb/package/currency.py | 1 + .../openbb/package/derivatives_options.py | 2 +- openbb_platform/openbb/package/economy.py | 18 ++++++++++----- openbb_platform/openbb/package/economy_gdp.py | 3 +++ openbb_platform/openbb/package/equity.py | 1 + .../openbb/package/equity_calendar.py | 1 + .../openbb/package/equity_discovery.py | 9 +++++++- .../openbb/package/equity_estimates.py | 4 ++++ .../openbb/package/equity_fundamental.py | 23 +++++++++++++++---- .../openbb/package/equity_ownership.py | 3 ++- .../openbb/package/equity_price.py | 1 + openbb_platform/openbb/package/etf.py | 16 +++++++------ openbb_platform/openbb/package/fixedincome.py | 1 + .../openbb/package/fixedincome_corporate.py | 7 +++++- .../openbb/package/fixedincome_government.py | 2 ++ .../openbb/package/fixedincome_rate.py | 7 ++++++ .../openbb/package/fixedincome_spreads.py | 3 +++ openbb_platform/openbb/package/index.py | 2 ++ openbb_platform/openbb/package/news.py | 6 +++-- .../openbb/package/regulators_sec.py | 5 +++- 21 files changed, 91 insertions(+), 26 deletions(-) diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index fea9d3a86ccb..574d43e218d1 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -86,7 +86,7 @@ async def schema_files( @router.command( model="SymbolMap", - examples=[APIEx(parameters={}), APIEx(parameters={"cik": "0000789019"})], + examples=[APIEx(parameters={}), APIEx(parameters={"query": "0000789019"})], ) async def symbol_map( cc: CommandContext, diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index f656b8ce4206..36e892f198d5 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -232,6 +232,7 @@ def snapshots( Examples -------- >>> from openbb import obb + >>> obb.currency.snapshots() >>> # Get exchange rates from USD and XAU to EUR, JPY, and GBP using 'fmp' as provider. >>> obb.currency.snapshots(provider='fmp', base='USD,XAU', counter_currencies='EUR,JPY,GBP', quote_type='indirect') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py index 30f5d53aa12f..6eca8895451a 100644 --- a/openbb_platform/openbb/package/derivatives_options.py +++ b/openbb_platform/openbb/package/derivatives_options.py @@ -150,7 +150,7 @@ def chains( Examples -------- >>> from openbb import obb - >>> obb.derivatives.options.chains(symbol='AAPL', provider='intrinio') + >>> obb.derivatives.options.chains(symbol='AAPL') >>> # Use the "date" parameter to get the end-of-day-data for a specific date, where supported. >>> obb.derivatives.options.chains(symbol='AAPL', date='2023-01-25', provider='intrinio') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 2f233e9eaac7..c72cc56b5ffd 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -124,6 +124,8 @@ def calendar( Examples -------- >>> from openbb import obb + >>> # By default, the calendar will be forward-looking. + >>> obb.economy.calendar() >>> obb.economy.calendar(provider='fmp', start_date='2020-03-01', end_date='2020-03-31') """ # noqa: E501 @@ -208,6 +210,7 @@ def composite_leading_indicator( Examples -------- >>> from openbb import obb + >>> obb.economy.composite_leading_indicator() >>> obb.economy.composite_leading_indicator(country='all') """ # noqa: E501 @@ -478,10 +481,9 @@ def fred_regional( Examples -------- >>> from openbb import obb - >>> # With no date, the most recent report is returned. - >>> obb.economy.fred_regional(series_id='NYICLAIMS') + >>> obb.economy.fred_regional(symbol='NYICLAIMS') >>> # With a date, time series data is returned. - >>> obb.economy.fred_regional(series_id='NYICLAIMS', start_date='2021-01-01') + >>> obb.economy.fred_regional(symbol='NYICLAIMS', start_date='2021-01-01', end_date='2021-12-31', limit=10) """ # noqa: E501 return self._run( @@ -741,11 +743,11 @@ def fred_series( Examples -------- >>> from openbb import obb - >>> obb.economy.fred_series(series_id='NFCI') + >>> obb.economy.fred_series(symbol='NFCI') >>> # Multiple series can be passed in as a list. - >>> obb.economy.fred_series(series_id='NFCI,STLFSI4') + >>> obb.economy.fred_series(symbol='NFCI,STLFSI4') >>> # Use the `transform` parameter to transform the data as change, log, or percent change. - >>> obb.economy.fred_series(series_id='CBBTCUSD', transform='pc1') + >>> obb.economy.fred_series(symbol='CBBTCUSD', transform='pc1') """ # noqa: E501 return self._run( @@ -846,6 +848,7 @@ def long_term_interest_rate( Examples -------- >>> from openbb import obb + >>> obb.economy.long_term_interest_rate() >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 @@ -943,6 +946,7 @@ def money_measures( Examples -------- >>> from openbb import obb + >>> obb.economy.money_measures() >>> obb.economy.money_measures(adjusted=False) """ # noqa: E501 @@ -1092,6 +1096,7 @@ def short_term_interest_rate( Examples -------- >>> from openbb import obb + >>> obb.economy.short_term_interest_rate() >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly') """ # noqa: E501 @@ -1181,6 +1186,7 @@ def unemployment( Examples -------- >>> from openbb import obb + >>> obb.economy.unemployment() >>> obb.economy.unemployment(country='all', frequency='quarterly') >>> # Demographics for the statistics are selected with the `age` and `sex` parameters. >>> obb.economy.unemployment(country='all', frequency='quarterly', age='25-54') diff --git a/openbb_platform/openbb/package/economy_gdp.py b/openbb_platform/openbb/package/economy_gdp.py index 3884d5004ff6..9e1d7ca27a50 100644 --- a/openbb_platform/openbb/package/economy_gdp.py +++ b/openbb_platform/openbb/package/economy_gdp.py @@ -95,6 +95,7 @@ def forecast( Examples -------- >>> from openbb import obb + >>> obb.economy.gdp.forecast() >>> obb.economy.gdp.forecast(period='annual', type='real') """ # noqa: E501 @@ -184,6 +185,7 @@ def nominal( Examples -------- >>> from openbb import obb + >>> obb.economy.gdp.nominal() >>> obb.economy.gdp.nominal(units='usd') """ # noqa: E501 @@ -272,6 +274,7 @@ def real( Examples -------- >>> from openbb import obb + >>> obb.economy.gdp.real() >>> obb.economy.gdp.real(units='yoy') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index 0d7204c8a61b..e1a2f8db3c0a 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -593,6 +593,7 @@ def search( Examples -------- >>> from openbb import obb + >>> obb.equity.search() >>> obb.equity.search(query='AAPL', is_symbol=False, use_cache=True) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_calendar.py b/openbb_platform/openbb/package/equity_calendar.py index 739aa001ad51..ff1bff9237f9 100644 --- a/openbb_platform/openbb/package/equity_calendar.py +++ b/openbb_platform/openbb/package/equity_calendar.py @@ -360,6 +360,7 @@ def ipo( Examples -------- >>> from openbb import obb + >>> obb.equity.calendar.ipo() >>> obb.equity.calendar.ipo(limit=100) >>> # Get all IPOs available. >>> obb.equity.calendar.ipo() diff --git a/openbb_platform/openbb/package/equity_discovery.py b/openbb_platform/openbb/package/equity_discovery.py index cc8f0748b34f..acb41dab1c5e 100644 --- a/openbb_platform/openbb/package/equity_discovery.py +++ b/openbb_platform/openbb/package/equity_discovery.py @@ -88,6 +88,7 @@ def active( Examples -------- >>> from openbb import obb + >>> obb.equity.discovery.active() >>> obb.equity.discovery.active(sort='desc') """ # noqa: E501 @@ -170,6 +171,7 @@ def aggressive_small_caps( Examples -------- >>> from openbb import obb + >>> obb.equity.discovery.aggressive_small_caps() >>> obb.equity.discovery.aggressive_small_caps(sort='desc') """ # noqa: E501 @@ -275,7 +277,7 @@ def filings( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.filings(limit=100) + >>> obb.equity.discovery.filings() >>> # Get filings for the year 2023, limited to 100 results >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31', limit=100) """ # noqa: E501 @@ -362,6 +364,7 @@ def gainers( Examples -------- >>> from openbb import obb + >>> obb.equity.discovery.gainers() >>> obb.equity.discovery.gainers(sort='desc') """ # noqa: E501 @@ -444,6 +447,7 @@ def growth_tech( Examples -------- >>> from openbb import obb + >>> obb.equity.discovery.growth_tech() >>> obb.equity.discovery.growth_tech(sort='desc') """ # noqa: E501 @@ -526,6 +530,7 @@ def losers( Examples -------- >>> from openbb import obb + >>> obb.equity.discovery.losers() >>> obb.equity.discovery.losers(sort='desc') """ # noqa: E501 @@ -608,6 +613,7 @@ def undervalued_growth( Examples -------- >>> from openbb import obb + >>> obb.equity.discovery.undervalued_growth() >>> obb.equity.discovery.undervalued_growth(sort='desc') """ # noqa: E501 @@ -690,6 +696,7 @@ def undervalued_large_caps( Examples -------- >>> from openbb import obb + >>> obb.equity.discovery.undervalued_large_caps() >>> obb.equity.discovery.undervalued_large_caps(sort='desc') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py index 74cf57e4f7a2..7ba1fbc603bc 100644 --- a/openbb_platform/openbb/package/equity_estimates.py +++ b/openbb_platform/openbb/package/equity_estimates.py @@ -171,6 +171,7 @@ def analyst_search( Examples -------- >>> from openbb import obb + >>> obb.equity.estimates.analyst_search() >>> obb.equity.estimates.analyst_search(firm_name='Wedbush', provider='benzinga') """ # noqa: E501 @@ -256,6 +257,7 @@ def consensus( Examples -------- >>> from openbb import obb + >>> obb.equity.estimates.consensus(symbol='AAPL') >>> obb.equity.estimates.consensus(symbol='AAPL,MSFT', provider='yfinance') """ # noqa: E501 @@ -374,6 +376,7 @@ def historical( Examples -------- >>> from openbb import obb + >>> obb.equity.estimates.historical(symbol='AAPL') >>> obb.equity.estimates.historical(symbol='AAPL', provider='fmp') """ # noqa: E501 @@ -524,6 +527,7 @@ def price_target( Examples -------- >>> from openbb import obb + >>> obb.equity.estimates.price_target() >>> # Get price targets for Microsoft using 'benzinga' as provider. >>> obb.equity.estimates.price_target(start_date='2020-01-01', end_date='2024-02-16', limit=10, symbol='msft', provider='benzinga', action='downgrades') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index 23badef45df8..caea2e6c5fa8 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -380,6 +380,7 @@ def balance( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.balance(symbol='AAPL') >>> obb.equity.fundamental.balance(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 @@ -533,6 +534,7 @@ def balance_growth( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.balance_growth(symbol='AAPL') >>> obb.equity.fundamental.balance_growth(symbol='AAPL', limit=10) """ # noqa: E501 @@ -796,6 +798,7 @@ def cash( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.cash(symbol='AAPL') >>> obb.equity.fundamental.cash(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 @@ -931,6 +934,7 @@ def cash_growth( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.cash_growth(symbol='AAPL') >>> obb.equity.fundamental.cash_growth(symbol='AAPL', limit=10) """ # noqa: E501 @@ -1256,6 +1260,7 @@ def filings( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.filings() >>> obb.equity.fundamental.filings(limit=100) """ # noqa: E501 @@ -1378,7 +1383,7 @@ def historical_attributes( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.historical_attributes(tag='ebitda') + >>> obb.equity.fundamental.historical_attributes(symbol='AAPL', tag='ebitda') """ # noqa: E501 return self._run( @@ -1897,6 +1902,7 @@ def income( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.income(symbol='AAPL') >>> obb.equity.fundamental.income(symbol='AAPL', period='annual', limit=5) """ # noqa: E501 @@ -2030,6 +2036,7 @@ def income_growth( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.income_growth(symbol='AAPL') >>> obb.equity.fundamental.income_growth(symbol='AAPL', limit=10, period='annual') """ # noqa: E501 @@ -2110,7 +2117,7 @@ def latest_attributes( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.latest_attributes(tag='ceo') + >>> obb.equity.fundamental.latest_attributes(symbol='AAPL', tag='ceo') """ # noqa: E501 return self._run( @@ -2566,6 +2573,7 @@ def metrics( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.metrics(symbol='AAPL') >>> obb.equity.fundamental.metrics(symbol='AAPL', period='annual', limit=100) """ # noqa: E501 @@ -3092,6 +3100,7 @@ def ratios( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.ratios(symbol='AAPL') >>> obb.equity.fundamental.ratios(symbol='AAPL', period='annual', limit=12) """ # noqa: E501 @@ -3184,6 +3193,7 @@ def reported_financials( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.reported_financials(symbol='AAPL') >>> # Get AAPL balance sheet with a limit of 10 items. >>> obb.equity.fundamental.reported_financials(symbol='AAPL', period='annual', statement_type='balance', limit=10) >>> # Get reported income statement @@ -3275,6 +3285,7 @@ def revenue_per_geography( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.revenue_per_geography(symbol='AAPL') >>> obb.equity.fundamental.revenue_per_geography(symbol='AAPL', period='annual', structure='flat') """ # noqa: E501 @@ -3360,6 +3371,7 @@ def revenue_per_segment( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.revenue_per_segment(symbol='AAPL') >>> obb.equity.fundamental.revenue_per_segment(symbol='AAPL', period='annual', structure='flat') """ # noqa: E501 @@ -3477,8 +3489,8 @@ def search_attributes( def trailing_dividend_yield( self, symbol: Annotated[ - Optional[str], OpenBBCustomParameter(description="Symbol to get data for.") - ] = None, + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], limit: Annotated[ Optional[int], OpenBBCustomParameter( @@ -3492,7 +3504,7 @@ def trailing_dividend_yield( Parameters ---------- - symbol : Optional[str] + symbol : str Symbol to get data for. limit : Optional[int] The number of data entries to return. Default is 252, the number of trading days in a year. @@ -3525,6 +3537,7 @@ def trailing_dividend_yield( Examples -------- >>> from openbb import obb + >>> obb.equity.fundamental.trailing_dividend_yield(symbol='AAPL') >>> obb.equity.fundamental.trailing_dividend_yield(symbol='AAPL', limit=252) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index 813170284442..4a9da4db311d 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -113,7 +113,6 @@ def form_13f( Examples -------- >>> from openbb import obb - >>> # Enter the symbol as either the stock ticker or the CIK number as a string. >>> obb.equity.ownership.form_13f(symbol='NVDA') >>> # Enter a date (calendar quarter ending) for a specific report. >>> obb.equity.ownership.form_13f(symbol='BRK-A', date='2016-09-30') @@ -257,6 +256,7 @@ def insider_trading( Examples -------- >>> from openbb import obb + >>> obb.equity.ownership.insider_trading(symbol='AAPL') >>> obb.equity.ownership.insider_trading(symbol='AAPL', limit=500) """ # noqa: E501 @@ -546,6 +546,7 @@ def major_holders( Examples -------- >>> from openbb import obb + >>> obb.equity.ownership.major_holders(symbol='AAPL') >>> obb.equity.ownership.major_holders(symbol='AAPL', page=0) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py index b4dd83aa0b8e..d4027015a027 100644 --- a/openbb_platform/openbb/package/equity_price.py +++ b/openbb_platform/openbb/package/equity_price.py @@ -170,6 +170,7 @@ def historical( Examples -------- >>> from openbb import obb + >>> obb.equity.price.historical(symbol='AAPL') >>> obb.equity.price.historical(symbol='AAPL', interval='1d') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index 73db0f3f3edd..08cffd78a2d5 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -74,7 +74,7 @@ def countries( Examples -------- >>> from openbb import obb - >>> obb.etf.countries(symbol='VT', provider='fmp') + >>> obb.etf.countries(symbol='VT') """ # noqa: E501 return self._run( @@ -149,7 +149,7 @@ def equity_exposure( Examples -------- >>> from openbb import obb - >>> obb.etf.equity_exposure(symbol='MSFT', provider='fmp') + >>> obb.etf.equity_exposure(symbol='MSFT') >>> # This function accepts multiple tickers. >>> obb.etf.equity_exposure(symbol='MSFT,AAPL', provider='fmp') """ # noqa: E501 @@ -477,7 +477,7 @@ def holdings( Examples -------- >>> from openbb import obb - >>> obb.etf.holdings(symbol='XLK', provider='fmp') + >>> obb.etf.holdings(symbol='XLK') >>> # Including a date (FMP, SEC) will return the holdings as per NPORT-P filings. >>> obb.etf.holdings(symbol='XLK', date='2022-03-31', provider='fmp') >>> # The same data can be returned from the SEC directly. @@ -546,7 +546,7 @@ def holdings_date( Examples -------- >>> from openbb import obb - >>> obb.etf.holdings_date(symbol='XLK', provider='fmp') + >>> obb.etf.holdings_date(symbol='XLK') """ # noqa: E501 return self._run( @@ -640,7 +640,7 @@ def holdings_performance( Examples -------- >>> from openbb import obb - >>> obb.etf.holdings_performance(symbol='XLK', provider='fmp') + >>> obb.etf.holdings_performance(symbol='XLK') """ # noqa: E501 return self._run( @@ -799,7 +799,7 @@ def info( Examples -------- >>> from openbb import obb - >>> obb.etf.info(symbol='SPY', provider='fmp') + >>> obb.etf.info(symbol='SPY') >>> # This function accepts multiple tickers. >>> obb.etf.info(symbol='SPY,IWM,QQQ,DJIA', provider='fmp') """ # noqa: E501 @@ -896,6 +896,7 @@ def price_performance( Examples -------- >>> from openbb import obb + >>> obb.etf.price_performance(symbol='QQQ') >>> obb.etf.price_performance(symbol='SPY,QQQ,IWM,DJIA', provider='fmp') """ # noqa: E501 @@ -991,6 +992,7 @@ def search( Examples -------- >>> from openbb import obb + >>> obb.etf.search() >>> # An empty query returns the full list of ETFs from the provider. >>> obb.etf.search() >>> # The query will return results from text-based fields containing the term. @@ -1059,7 +1061,7 @@ def sectors( Examples -------- >>> from openbb import obb - >>> obb.etf.sectors(symbol='SPY', provider='fmp') + >>> obb.etf.sectors(symbol='SPY') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index 20a01445454a..2c4923c45f5e 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -112,6 +112,7 @@ def sofr( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.sofr() >>> obb.fixedincome.sofr(period='overnight') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index fa7f23ffb559..61fa7f74f76b 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -102,6 +102,7 @@ def commercial_paper( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.corporate.commercial_paper() >>> obb.fixedincome.corporate.commercial_paper(maturity='15d') """ # noqa: E501 @@ -190,6 +191,7 @@ def hqm( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.corporate.hqm() >>> obb.fixedincome.corporate.hqm(yield_curve='par') """ # noqa: E501 @@ -288,6 +290,7 @@ def ice_bofa( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.corporate.ice_bofa() >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst') """ # noqa: E501 @@ -380,6 +383,7 @@ def moody( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.corporate.moody() >>> obb.fixedincome.corporate.moody(index_type='baa') """ # noqa: E501 @@ -480,7 +484,8 @@ def spot_rates( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.corporate.spot_rates(maturity=10,20,30,50) + >>> obb.fixedincome.corporate.spot_rates() + >>> obb.fixedincome.corporate.spot_rates(maturity='10,20,30,50') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_government.py b/openbb_platform/openbb/package/fixedincome_government.py index 61c6d4086c44..d9031659b6d8 100644 --- a/openbb_platform/openbb/package/fixedincome_government.py +++ b/openbb_platform/openbb/package/fixedincome_government.py @@ -100,6 +100,7 @@ def treasury_rates( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.government.treasury_rates() >>> obb.fixedincome.government.treasury_rates(provider='federal_reserve') """ # noqa: E501 @@ -175,6 +176,7 @@ def us_yield_curve( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.government.us_yield_curve() >>> obb.fixedincome.government.us_yield_curve(inflation_adjusted=True) """ # noqa: E501 diff --git a/openbb_platform/openbb/package/fixedincome_rate.py b/openbb_platform/openbb/package/fixedincome_rate.py index b1fe1845df29..b6f17f9f5a4f 100644 --- a/openbb_platform/openbb/package/fixedincome_rate.py +++ b/openbb_platform/openbb/package/fixedincome_rate.py @@ -89,6 +89,7 @@ def ameribor( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.rate.ameribor() >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma') """ # noqa: E501 @@ -174,6 +175,7 @@ def dpcredit( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.rate.dpcredit() >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') """ # noqa: E501 @@ -265,6 +267,7 @@ def ecb( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.rate.ecb() >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing') """ # noqa: E501 @@ -350,6 +353,7 @@ def effr( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.rate.effr() >>> obb.fixedincome.rate.effr(parameter='daily', provider='fred') """ # noqa: E501 @@ -429,6 +433,7 @@ def effr_forecast( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.rate.effr_forecast() >>> obb.fixedincome.rate.effr_forecast(long_run=True) """ # noqa: E501 @@ -511,6 +516,7 @@ def estr( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.rate.estr() >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks') """ # noqa: E501 @@ -677,6 +683,7 @@ def sonia( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.rate.sonia() >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/fixedincome_spreads.py b/openbb_platform/openbb/package/fixedincome_spreads.py index 898b35109a9f..3195690a3a9d 100644 --- a/openbb_platform/openbb/package/fixedincome_spreads.py +++ b/openbb_platform/openbb/package/fixedincome_spreads.py @@ -89,6 +89,7 @@ def tcm( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.spreads.tcm() >>> obb.fixedincome.spreads.tcm(maturity='2y') """ # noqa: E501 @@ -179,6 +180,7 @@ def tcm_effr( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.spreads.tcm_effr() >>> obb.fixedincome.spreads.tcm_effr(maturity='10y') """ # noqa: E501 @@ -270,6 +272,7 @@ def treasury_effr( Examples -------- >>> from openbb import obb + >>> obb.fixedincome.spreads.treasury_effr() >>> obb.fixedincome.spreads.treasury_effr(maturity='6m') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index 7e1db0c481c5..e7db0d7ff8ff 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -70,6 +70,7 @@ def available( Examples -------- >>> from openbb import obb + >>> obb.index.available() >>> obb.index.available(provider='yfinance') """ # noqa: E501 @@ -145,6 +146,7 @@ def constituents( Examples -------- >>> from openbb import obb + >>> obb.index.constituents(symbol='dowjones') >>> obb.index.constituents(symbol='dowjones', provider='fmp') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index 2c409846b44b..a2b3df302a7b 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -159,7 +159,8 @@ def company( Examples -------- >>> from openbb import obb - >>> obb.news.company(limit=2500) + >>> obb.news.company() + >>> obb.news.company(limit=100) >>> # Get news on the specified dates. >>> obb.news.company(symbol='AAPL', start_date='2024-02-01', end_date='2024-02-07') >>> # Display the headlines of the news. @@ -331,7 +332,8 @@ def world( Examples -------- >>> from openbb import obb - >>> obb.news.world(limit=2500) + >>> obb.news.world() + >>> obb.news.world(limit=100) >>> # Get news on the specified dates. >>> obb.news.world(start_date='2024-02-01', end_date='2024-02-07') >>> # Display the headlines of the news. diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index b728828c9e41..4c64ca89a515 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -137,6 +137,7 @@ def institutions_search( Examples -------- >>> from openbb import obb + >>> obb.regulators.sec.institutions_search() >>> obb.regulators.sec.institutions_search(query='blackstone real estate') """ # noqa: E501 @@ -363,6 +364,7 @@ def sic_search( Examples -------- >>> from openbb import obb + >>> obb.regulators.sec.sic_search() >>> obb.regulators.sec.sic_search(query='real estate investment trusts') """ # noqa: E501 @@ -433,7 +435,8 @@ def symbol_map( Examples -------- >>> from openbb import obb - >>> obb.regulators.sec.symbol_map(cik='0000789019') + >>> obb.regulators.sec.symbol_map() + >>> obb.regulators.sec.symbol_map(query='0000789019') """ # noqa: E501 return self._run( From cc1fe435d9e0df7f5231e2674ea24fbd86c32887 Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Thu, 7 Mar 2024 17:58:45 +0530 Subject: [PATCH 075/133] prompt fix in PythonEx --- openbb_platform/core/openbb_core/app/model/example.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 97544d630729..b28ec5fc67bb 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -65,7 +65,6 @@ def unpack_type(type_: type) -> set: def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" - indentation = kwargs.get("indentation", "") func_path = kwargs.get("func_path", ".func_router.func_name") param_types: Dict[str, type] = kwargs.get("param_types", {}) @@ -100,9 +99,7 @@ class PythonEx(Example): def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") - target: str = kwargs.get("target", "docstring") - - prompt = ">>> " if target == "docstring" else "" + prompt = kwargs.get("prompt", "") eg = "" if self.description: From 881aa5bcb8ec7fe2c2200af922cb9182f673a4d2 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 13:02:24 +0000 Subject: [PATCH 076/133] fix examples without model --- .../core/openbb_core/app/model/example.py | 34 +++++++++++++++++-- .../openbb_core/app/static/package_builder.py | 13 ++++--- .../econometrics_router.py | 20 ++++++++++- 3 files changed, 60 insertions(+), 7 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index b28ec5fc67bb..6802389e4504 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -2,7 +2,7 @@ import datetime from abc import abstractmethod -from typing import Dict, List, Literal, Optional, Union +from typing import Any, Dict, List, Literal, Optional, Union from pydantic import ( BaseModel, @@ -26,6 +26,36 @@ class Example(BaseModel): def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" + @staticmethod + def mock_ohlc_data() -> list: + """Return mock data for the example.""" + return [ + { + "date": "2023-01-03", + "open": 118.47, + "high": 118.80, + "low": 104.64, + "close": 118.1, + "volume": 231402800, + }, + { + "date": "2023-01-04", + "open": 109.11, + "high": 114.59, + "low": 107.52, + "close": 113.64, + "volume": 180389000, + }, + { + "date": "2023-01-05", + "open": 110.51, + "high": 111.75, + "low": 107.16, + "close": 110.34, + "volume": 157986300, + }, + ] + class APIEx(Example): """API Example model.""" @@ -34,7 +64,7 @@ class APIEx(Example): description: Optional[str] = Field( default=None, description="Optional description unless more than 3 parameters" ) - parameters: Dict[str, Union[str, int, float, bool, list, None]] + parameters: Dict[str, Union[str, int, float, bool, List[Dict[str, Any]], None]] @computed_field # type: ignore[misc] @property diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index e69dea82b674..135a5caa6b01 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -1035,15 +1035,20 @@ def generate( """Generate the docstring for the function.""" doc = func.__doc__ or "" param_types = {} + + # Parameters explicit in the function signature + explicit_params = dict(formatted_params) + explicit_params.pop("extra_params", None) + # Map of parameter names to types + param_types = {k: v.annotation for k, v in explicit_params.items()} + if model_name: params = cls.provider_interface.params.get(model_name, {}) return_schema = cls.provider_interface.return_schema.get(model_name, None) if params and return_schema: - explicit_params = dict(formatted_params) - explicit_params.pop("extra_params", None) - kwarg_params = params["extra"].__dataclass_fields__ - param_types = {k: v.annotation for k, v in explicit_params.items()} + # Parameters passed as **kwargs + kwarg_params = params["extra"].__dataclass_fields__ param_types.update({k: v.type for k, v in kwarg_params.items()}) returns = return_schema.model_fields diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index e42f5a07488e..3dff29183297 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -34,7 +34,25 @@ methods=["POST"], examples=[ APIEx( - parameters={"data": [{"x": 1, "y": 2}, {"x": 2, "y": 3}, {"x": 3, "y": 4}]} + parameters={ + "data": [ + { + "date": "2023-01-03", + "open": 118.47, + "close": 118.1, + }, + { + "date": "2023-01-04", + "open": 109.11, + "close": 113.64, + }, + { + "date": "2023-01-05", + "open": 110.51, + "close": 110.34, + }, + ] + } ), PythonEx( description="Get the correlation matrix of a dataset.", From 1440b10bd44e1883de8be63d17c308103747e684 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 13:07:02 +0000 Subject: [PATCH 077/133] example mock data --- .../core/openbb_core/app/model/example.py | 43 ++++++++++++++++++- .../econometrics_router.py | 22 +--------- .../quantitative_router.py | 5 ++- .../openbb_technical/technical_router.py | 7 +-- 4 files changed, 50 insertions(+), 27 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 6802389e4504..c3ed80bcbcb0 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -29,6 +29,7 @@ def to_python(self, **kwargs) -> str: @staticmethod def mock_ohlc_data() -> list: """Return mock data for the example.""" + # Pass number of observations as a parameter return [ { "date": "2023-01-03", @@ -47,7 +48,47 @@ def mock_ohlc_data() -> list: "volume": 180389000, }, { - "date": "2023-01-05", + "date": "2023-01-06", + "open": 110.51, + "high": 111.75, + "low": 107.16, + "close": 110.34, + "volume": 157986300, + }, + { + "date": "2023-01-07", + "open": 110.51, + "high": 111.75, + "low": 107.16, + "close": 110.34, + "volume": 157986300, + }, + { + "date": "2023-01-08", + "open": 110.51, + "high": 111.75, + "low": 107.16, + "close": 110.34, + "volume": 157986300, + }, + { + "date": "2023-01-09", + "open": 110.51, + "high": 111.75, + "low": 107.16, + "close": 110.34, + "volume": 157986300, + }, + { + "date": "2023-01-10", + "open": 110.51, + "high": 111.75, + "low": 107.16, + "close": 110.34, + "volume": 157986300, + }, + { + "date": "2023-01-11", "open": 110.51, "high": 111.75, "low": 107.16, diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 3dff29183297..ad7d070cc509 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -33,27 +33,6 @@ @router.command( methods=["POST"], examples=[ - APIEx( - parameters={ - "data": [ - { - "date": "2023-01-03", - "open": 118.47, - "close": 118.1, - }, - { - "date": "2023-01-04", - "open": 109.11, - "close": 113.64, - }, - { - "date": "2023-01-05", - "open": 110.51, - "close": 110.34, - }, - ] - } - ), PythonEx( description="Get the correlation matrix of a dataset.", code=[ @@ -61,6 +40,7 @@ "obb.econometrics.correlation_matrix(data=stock_data)", ], ), + APIEx(parameters={"data": APIEx.mock_ohlc_data()}), ], ) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index c6afe6583de7..09ee5773d63d 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -3,7 +3,7 @@ from typing import List, Literal import pandas as pd -from openbb_core.app.model.example import PythonEx +from openbb_core.app.model.example import APIEx, PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( @@ -45,7 +45,8 @@ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.quantitative.normality(data=stock_data, target='close')", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_ohlc_data(), "target": "open"}), ], ) def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index ec6225251fba..892df1afc8c6 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -5,7 +5,7 @@ import pandas as pd import pandas_ta as ta -from openbb_core.app.model.example import PythonEx +from openbb_core.app.model.example import APIEx, PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( @@ -956,7 +956,7 @@ def ichimoku( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "clenow_data = obb.technical.clenow(data=stock_data.results, period=90)", ], - ) + ), ], ) def clenow( @@ -1016,7 +1016,8 @@ def clenow( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_ohlc_data()}), ], ) def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[Data]]: From 890c310d9c0a55be9c88b8e8412f24aea7dacbce Mon Sep 17 00:00:00 2001 From: Pratyush Shukla Date: Thu, 7 Mar 2024 19:00:40 +0530 Subject: [PATCH 078/133] add get_field_type func to get field data type --- .../openbb_core/app/static/package_builder.py | 76 ++++++++++++------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 135a5caa6b01..8c97bf1eb7bc 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -808,7 +808,7 @@ def get_expanded_type( raise ValueError( "multiple_items_allowed requires the original type to be specified." ) - return List[original_type] + return List[original_type] # type: ignore return cls.TYPE_EXPANSION.get(field_name, ...) @classmethod @@ -852,6 +852,51 @@ class DocstringGenerator: provider_interface = ProviderInterface() + @staticmethod + def get_field_type( + field: FieldInfo, target: Literal["docstring", "website"] = "docstring" + ) -> str: + """Get the implicit data type of a defined Pydantic field. + + Args + ---- + field (FieldInfo): Pydantic field object containing field information. + target (Literal["docstring", "website"], optional): Target to return type for. Defaults to "docstring". + + Returns + ------- + str: String representation of the field type. + """ + is_optional = not field.is_required() if target == "docstring" else False + + try: + _type = field.annotation + + if "BeforeValidator" in str(_type): + _type = "Optional[int]" if is_optional else "int" # type: ignore + + field_type = ( + str(_type) + .replace("", "") + .replace("typing.", "") + .replace("pydantic.types.", "") + .replace("datetime.datetime", "datetime") + .replace("datetime.date", "date") + .replace("NoneType", "None") + .replace(", None", "") + ) + field_type = ( + f"Optional[{field_type}]" + if is_optional and "Optional" not in str(_type) + else field_type + ) + except TypeError: + # Fallback to the annotation if the repr fails + field_type = field.annotation # type: ignore + + return field_type + @staticmethod def get_OBBject_description( results_type: str, @@ -991,34 +1036,8 @@ def format_description(description: str) -> str: docstring += f"{create_indent(2)}{underline}\n" for name, field in returns.items(): - try: - _type = field.annotation - is_optional = not field.is_required() - if "BeforeValidator" in str(_type): - _type = "Optional[int]" if is_optional else "int" # type: ignore - - field_type = ( - str(_type) - .replace("", "") - .replace("typing.", "") - .replace("pydantic.types.", "") - .replace("datetime.datetime", "datetime") - .replace("datetime.date", "date") - .replace("NoneType", "None") - .replace(", None", "") - ) - field_type = ( - f"Optional[{field_type}]" - if is_optional and "Optional" not in str(_type) - else field_type - ) - except TypeError: - # Fallback to the annotation if the repr fails - field_type = field.annotation # type: ignore - + field_type = cls.get_field_type(field) description = getattr(field, "description", "") - docstring += f"{create_indent(2)}{field.alias or name} : {field_type}\n" docstring += f"{create_indent(3)}{format_description(description)}\n" return docstring @@ -1046,7 +1065,6 @@ def generate( params = cls.provider_interface.params.get(model_name, {}) return_schema = cls.provider_interface.return_schema.get(model_name, None) if params and return_schema: - # Parameters passed as **kwargs kwarg_params = params["extra"].__dataclass_fields__ param_types.update({k: v.type for k, v in kwarg_params.items()}) From 010a04f1a84b15474b48c73551e9a583abe2c17c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 13:40:57 +0000 Subject: [PATCH 079/133] panel data --- .../core/openbb_core/app/model/example.py | 47 +++++++++++++++++-- .../econometrics_router.py | 15 +++++- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index c3ed80bcbcb0..b0b9aede163e 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -2,7 +2,7 @@ import datetime from abc import abstractmethod -from typing import Any, Dict, List, Literal, Optional, Union +from typing import Any, Dict, List, Literal, Optional, Union, _UnionGenericAlias from pydantic import ( BaseModel, @@ -26,6 +26,45 @@ class Example(BaseModel): def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" + @staticmethod + def mock_multi_index_data() -> list: + """Return mock data for the example.""" + return [ + { + "asset_manager": "BlackRock", + "time": 1, + "portfolio_value": 100000, + "stock_a_return": 0.05, + "stock_b_return": 0.03, + "market_volatility": 0.1, + "risk_free_rate": 0.02, + "is_multiindex": True, + "multiindex_names": "['asset_manager', 'time']", + }, + { + "asset_manager": "BlackRock", + "time": 2, + "portfolio_value": 110000, + "stock_a_return": 0.03, + "stock_b_return": 0.04, + "market_volatility": 0.12, + "risk_free_rate": 0.025, + "is_multiindex": True, + "multiindex_names": "['asset_manager', 'time']", + }, + { + "asset_manager": "BlackRock", + "time": 3, + "portfolio_value": 105000, + "stock_a_return": 0.04, + "stock_b_return": 0.02, + "market_volatility": 0.11, + "risk_free_rate": 0.03, + "is_multiindex": True, + "multiindex_names": "['asset_manager', 'time']", + }, + ] + @staticmethod def mock_ohlc_data() -> list: """Return mock data for the example.""" @@ -105,7 +144,9 @@ class APIEx(Example): description: Optional[str] = Field( default=None, description="Optional description unless more than 3 parameters" ) - parameters: Dict[str, Union[str, int, float, bool, List[Dict[str, Any]], None]] + parameters: Dict[ + str, Union[str, int, float, bool, List[str], List[Dict[str, Any]], None] + ] @computed_field # type: ignore[misc] @property @@ -130,7 +171,7 @@ def check_model(cls, values: dict) -> dict: @staticmethod def unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" - if hasattr(type_, "__args__"): + if hasattr(type_, "__args__") and type(type_) is _UnionGenericAlias: # type: ignore[misc] return set().union(*map(APIEx.unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index ad7d070cc509..3cd59d12d381 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -490,7 +490,18 @@ def unit_root( return OBBject(results=results) -@router.command(methods=["POST"], include_in_schema=False) +@router.command( + methods=["POST"], + examples=[ + APIEx( + parameters={ + "y_column": "portfolio_value", + "x_columns": ["risk_free_rate"], + "data": APIEx.mock_multi_index_data(), + } + ) + ], +) def panel_random_effects( data: List[Data], y_column: str, @@ -518,6 +529,8 @@ def panel_random_effects( OBBject with the fit model returned """ X = get_target_columns(basemodel_to_df(data), x_columns) + if len(X) < 3: + raise ValueError("This analysis requires at least 3 items in the dataset.") y = get_target_column(basemodel_to_df(data), y_column) exogenous = sm.add_constant(X) results = RandomEffects(y, exogenous).fit() From 3ab5d317a0aeb5041c88fd76a43d854aac0e0d15 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 16:18:08 +0000 Subject: [PATCH 080/133] mock data --- .../core/openbb_core/app/model/example.py | 180 +++++++----------- .../econometrics_router.py | 4 +- .../quantitative_router.py | 2 +- .../openbb_technical/technical_router.py | 2 +- 4 files changed, 70 insertions(+), 118 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index b0b9aede163e..3bae6d5205ca 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -26,116 +26,6 @@ class Example(BaseModel): def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" - @staticmethod - def mock_multi_index_data() -> list: - """Return mock data for the example.""" - return [ - { - "asset_manager": "BlackRock", - "time": 1, - "portfolio_value": 100000, - "stock_a_return": 0.05, - "stock_b_return": 0.03, - "market_volatility": 0.1, - "risk_free_rate": 0.02, - "is_multiindex": True, - "multiindex_names": "['asset_manager', 'time']", - }, - { - "asset_manager": "BlackRock", - "time": 2, - "portfolio_value": 110000, - "stock_a_return": 0.03, - "stock_b_return": 0.04, - "market_volatility": 0.12, - "risk_free_rate": 0.025, - "is_multiindex": True, - "multiindex_names": "['asset_manager', 'time']", - }, - { - "asset_manager": "BlackRock", - "time": 3, - "portfolio_value": 105000, - "stock_a_return": 0.04, - "stock_b_return": 0.02, - "market_volatility": 0.11, - "risk_free_rate": 0.03, - "is_multiindex": True, - "multiindex_names": "['asset_manager', 'time']", - }, - ] - - @staticmethod - def mock_ohlc_data() -> list: - """Return mock data for the example.""" - # Pass number of observations as a parameter - return [ - { - "date": "2023-01-03", - "open": 118.47, - "high": 118.80, - "low": 104.64, - "close": 118.1, - "volume": 231402800, - }, - { - "date": "2023-01-04", - "open": 109.11, - "high": 114.59, - "low": 107.52, - "close": 113.64, - "volume": 180389000, - }, - { - "date": "2023-01-06", - "open": 110.51, - "high": 111.75, - "low": 107.16, - "close": 110.34, - "volume": 157986300, - }, - { - "date": "2023-01-07", - "open": 110.51, - "high": 111.75, - "low": 107.16, - "close": 110.34, - "volume": 157986300, - }, - { - "date": "2023-01-08", - "open": 110.51, - "high": 111.75, - "low": 107.16, - "close": 110.34, - "volume": 157986300, - }, - { - "date": "2023-01-09", - "open": 110.51, - "high": 111.75, - "low": 107.16, - "close": 110.34, - "volume": 157986300, - }, - { - "date": "2023-01-10", - "open": 110.51, - "high": 111.75, - "low": 107.16, - "close": 110.34, - "volume": 157986300, - }, - { - "date": "2023-01-11", - "open": 110.51, - "high": 111.75, - "low": 107.16, - "close": 110.34, - "volume": 157986300, - }, - ] - class APIEx(Example): """API Example model.""" @@ -169,12 +59,74 @@ def check_model(cls, values: dict) -> dict: return values @staticmethod - def unpack_type(type_: type) -> set: + def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" - if hasattr(type_, "__args__") and type(type_) is _UnionGenericAlias: # type: ignore[misc] - return set().union(*map(APIEx.unpack_type, type_.__args__)) + if ( + hasattr(type_, "__args__") and type(type_) is _UnionGenericAlias + ): # pylint: disable=unidiomatic-typecheck + return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} + @staticmethod + def _shift(i: int) -> float: + """Return a shift value.""" + return 2 * (i + 1) / (2 * i + 1) % 1 + + @staticmethod + def mock_data(dataset: Literal["ts_ohlc", "panel_am"], size: int = 3) -> List[Dict]: + """Return mock data for the example. + + Parameters + ---------- + dataset : str + The type of data to return: + - 'ts_ohlc': Time series OHLC data + - 'panel_am': Panel data asset manager (multiindex) + + size : int + The size of the data to return. + + Returns + ------- + List[Dict] + A list of dictionaries with the mock data. + """ + if dataset == "ts_ohlc": + result = [] + for i in range(size): + s = APIEx._shift(i) + start_date = datetime.date(2023, 1, 1) + result.append( + { + "date": (start_date + datetime.timedelta(days=i)).isoformat(), + "open": round(118.47 * s, 2), + "high": round(118.80 * s, 2), + "low": round(104.64 * s, 2), + "close": round(118.1 * s, 2), + "volume": 231402800 + i * 1000000, + } + ) + return result + elif dataset == "panel_am": + result = [] + for i in range(size): + s = APIEx._shift(i) + result.append( + { + "asset_manager": "BlackRock", + "time": i + 1, + "portfolio_value": 100000 + i * 1000, + "stock_a_return": round(0.05 * s, 2), + "stock_b_return": round(0.03 * s, 2), + "market_volatility": round(0.1 * s, 2), + "risk_free_rate": round(0.02 * s, 2), + "is_multiindex": True, + "multiindex_names": "['asset_manager', 'time']", + } + ) + return result + raise ValueError(f"Dataset '{dataset}' not found.") + def to_python(self, **kwargs) -> str: """Return a Python code representation of the example.""" indentation = kwargs.get("indentation", "") @@ -189,7 +141,7 @@ def to_python(self, **kwargs) -> str: eg += f"{indentation}{prompt}obb{func_path}(" for k, v in self.parameters.items(): if k in param_types and (type_ := param_types.get(k)): - if QUOTE_TYPES.intersection(self.unpack_type(type_)): + if QUOTE_TYPES.intersection(self._unpack_type(type_)): eg += f"{k}='{v}', " else: eg += f"{k}={v}, " diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 3cd59d12d381..a88942d95482 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -40,7 +40,7 @@ "obb.econometrics.correlation_matrix(data=stock_data)", ], ), - APIEx(parameters={"data": APIEx.mock_ohlc_data()}), + APIEx(parameters={"data": APIEx.mock_data("ts_ohlc")}), ], ) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: @@ -497,7 +497,7 @@ def unit_root( parameters={ "y_column": "portfolio_value", "x_columns": ["risk_free_rate"], - "data": APIEx.mock_multi_index_data(), + "data": APIEx.mock_data("panel_am"), } ) ], diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 09ee5773d63d..99c27a3f79b4 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -46,7 +46,7 @@ "obb.quantitative.normality(data=stock_data, target='close')", ], ), - APIEx(parameters={"data": APIEx.mock_ohlc_data(), "target": "open"}), + APIEx(parameters={"data": APIEx.mock_data("ts_ohlc", 10), "target": "open"}), ], ) def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 892df1afc8c6..7b9c336c7297 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -1017,7 +1017,7 @@ def clenow( "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_ohlc_data()}), + APIEx(parameters={"data": APIEx.mock_data("ts_ohlc")}), ], ) def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[Data]]: From eba5b1a48ce14c6580d8fa31984293c52ec16826 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 16:24:40 +0000 Subject: [PATCH 081/133] fix --- openbb_platform/core/openbb_core/app/model/example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 3bae6d5205ca..08360a1ed676 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -69,8 +69,8 @@ def _unpack_type(type_: type) -> set: @staticmethod def _shift(i: int) -> float: - """Return a shift value.""" - return 2 * (i + 1) / (2 * i + 1) % 1 + """Return a shifted value.""" + return 2 * (i + 1) / (2 * i + 1) % 1 + 1 @staticmethod def mock_data(dataset: Literal["ts_ohlc", "panel_am"], size: int = 3) -> List[Dict]: From 7cbc2ab64fed6e557705aae9594d8a1a53dfee95 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 16:26:54 +0000 Subject: [PATCH 082/133] fix --- openbb_platform/core/openbb_core/app/model/example.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 08360a1ed676..9724a9a9e5e3 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -70,7 +70,7 @@ def _unpack_type(type_: type) -> set: @staticmethod def _shift(i: int) -> float: """Return a shifted value.""" - return 2 * (i + 1) / (2 * i + 1) % 1 + 1 + return 2 * (i + 1) / (2 * i) % 1 + 1 @staticmethod def mock_data(dataset: Literal["ts_ohlc", "panel_am"], size: int = 3) -> List[Dict]: @@ -93,7 +93,7 @@ def mock_data(dataset: Literal["ts_ohlc", "panel_am"], size: int = 3) -> List[Di """ if dataset == "ts_ohlc": result = [] - for i in range(size): + for i in range(1, size + 1): s = APIEx._shift(i) start_date = datetime.date(2023, 1, 1) result.append( @@ -109,7 +109,7 @@ def mock_data(dataset: Literal["ts_ohlc", "panel_am"], size: int = 3) -> List[Di return result elif dataset == "panel_am": result = [] - for i in range(size): + for i in range(1, size + 1): s = APIEx._shift(i) result.append( { From c74dc3cf4b047788327b8d7977832888ea62ae9c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 16:28:35 +0000 Subject: [PATCH 083/133] docstring --- openbb_platform/core/openbb_core/app/model/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 9724a9a9e5e3..cf77e944da7d 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -69,7 +69,7 @@ def _unpack_type(type_: type) -> set: @staticmethod def _shift(i: int) -> float: - """Return a shifted value.""" + """Return a transformation of the integer.""" return 2 * (i + 1) / (2 * i) % 1 + 1 @staticmethod From 98dc42c8ddf9c9da30aff6fc6e2a66fef25a9dfc Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 16:30:00 +0000 Subject: [PATCH 084/133] ohlcv --- openbb_platform/core/openbb_core/app/model/example.py | 6 +++--- .../econometrics/openbb_econometrics/econometrics_router.py | 2 +- .../quantitative/openbb_quantitative/quantitative_router.py | 2 +- .../technical/openbb_technical/technical_router.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index cf77e944da7d..bef81785afaf 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -73,14 +73,14 @@ def _shift(i: int) -> float: return 2 * (i + 1) / (2 * i) % 1 + 1 @staticmethod - def mock_data(dataset: Literal["ts_ohlc", "panel_am"], size: int = 3) -> List[Dict]: + def mock_data(dataset: Literal["ts_ohlcv", "panel_am"], size: int = 3) -> List[Dict]: """Return mock data for the example. Parameters ---------- dataset : str The type of data to return: - - 'ts_ohlc': Time series OHLC data + - 'ts_ohlcv': Time series OHLC data - 'panel_am': Panel data asset manager (multiindex) size : int @@ -91,7 +91,7 @@ def mock_data(dataset: Literal["ts_ohlc", "panel_am"], size: int = 3) -> List[Di List[Dict] A list of dictionaries with the mock data. """ - if dataset == "ts_ohlc": + if dataset == "ts_ohlcv": result = [] for i in range(1, size + 1): s = APIEx._shift(i) diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index a88942d95482..f28191ad9282 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -40,7 +40,7 @@ "obb.econometrics.correlation_matrix(data=stock_data)", ], ), - APIEx(parameters={"data": APIEx.mock_data("ts_ohlc")}), + APIEx(parameters={"data": APIEx.mock_data("ts_ohlcv")}), ], ) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 99c27a3f79b4..f9ecfbaf700a 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -46,7 +46,7 @@ "obb.quantitative.normality(data=stock_data, target='close')", ], ), - APIEx(parameters={"data": APIEx.mock_data("ts_ohlc", 10), "target": "open"}), + APIEx(parameters={"data": APIEx.mock_data("ts_ohlcv", 10), "target": "open"}), ], ) def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 7b9c336c7297..c57938f7a2c4 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -1017,7 +1017,7 @@ def clenow( "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("ts_ohlc")}), + APIEx(parameters={"data": APIEx.mock_data("ts_ohlcv")}), ], ) def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[Data]]: From f7f01d694679fabeb6df3307df8766f8c9911cc1 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 16:31:28 +0000 Subject: [PATCH 085/133] pylint --- openbb_platform/core/openbb_core/app/model/example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index bef81785afaf..4ea7d1cf85f2 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -62,8 +62,8 @@ def check_model(cls, values: dict) -> dict: def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" if ( - hasattr(type_, "__args__") and type(type_) is _UnionGenericAlias - ): # pylint: disable=unidiomatic-typecheck + hasattr(type_, "__args__") and type(type_) is _UnionGenericAlias # pylint: disable=unidiomatic-typecheck + ): return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} From d50eef1d51a9584449a9d51a970154fcff3b93a0 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 16:41:08 +0000 Subject: [PATCH 086/133] quantitaive router --- .../core/openbb_core/app/model/example.py | 4 +-- .../quantitative_router.py | 33 ++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 4ea7d1cf85f2..0a704982c918 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -73,7 +73,7 @@ def _shift(i: int) -> float: return 2 * (i + 1) / (2 * i) % 1 + 1 @staticmethod - def mock_data(dataset: Literal["ts_ohlcv", "panel_am"], size: int = 3) -> List[Dict]: + def mock_data(dataset: Literal["ts_ohlcv", "panel_am"], size: int = 5) -> List[Dict]: """Return mock data for the example. Parameters @@ -84,7 +84,7 @@ def mock_data(dataset: Literal["ts_ohlcv", "panel_am"], size: int = 3) -> List[D - 'panel_am': Panel data asset manager (multiindex) size : int - The size of the data to return. + The size of the data to return, default is 5. Returns ------- diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index f9ecfbaf700a..f962e454e776 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -46,7 +46,7 @@ "obb.quantitative.normality(data=stock_data, target='close')", ], ), - APIEx(parameters={"data": APIEx.mock_data("ts_ohlcv", 10), "target": "open"}), + APIEx(parameters={"target": "open", "data": APIEx.mock_data("ts_ohlcv", 8)}), ], ) def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: @@ -101,7 +101,8 @@ def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", "obb.quantitative.capm(data=stock_data, target='close')", ], - ) + ), + APIEx(parameters={"target": "open", "data": APIEx.mock_data("ts_ohlcv", 31)}), ], ) def capm(data: List[Data], target: str) -> OBBject[CAPMModel]: @@ -154,7 +155,19 @@ def capm(data: List[Data], target: str) -> OBBject[CAPMModel]: return OBBject(results=results) -@router.command(methods=["POST"]) +@router.command( + methods=["POST"], + examples=[ + PythonEx( + description="Get Unit Root Test.", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "obb.quantitative.unitroot_test(data=stock_data, target='close')", + ], + ), + APIEx(parameters={"target": "open", "data": APIEx.mock_data("ts_ohlcv", 5)}), + ], + ) def unitroot_test( data: List[Data], target: str, @@ -213,7 +226,19 @@ def unitroot_test( return OBBject(results=unitroot_summary) -@router.command(methods=["POST"]) +@router.command( + methods=["POST"], + examples=[ + PythonEx( + description="Get Summary Statistics.", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "obb.quantitative.summary(data=stock_data, target='close')", + ], + ), + APIEx(parameters={"target": "open", "data": APIEx.mock_data("ts_ohlcv", 5)}), + ], +) def summary(data: List[Data], target: str) -> OBBject[SummaryModel]: """Get Summary Statistics. From 362db00b62f3b3029ff54f4dce84c06b1d26171c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 16:57:07 +0000 Subject: [PATCH 087/133] simplify mock data --- .../core/openbb_core/app/model/example.py | 15 ++++++++------- .../openbb_econometrics/econometrics_router.py | 2 +- .../performance/performance_router.py | 7 +++++-- .../openbb_quantitative/quantitative_router.py | 18 +++++++++++++----- .../openbb_technical/technical_router.py | 2 +- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 0a704982c918..37aa36e69395 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -62,7 +62,9 @@ def check_model(cls, values: dict) -> dict: def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" if ( - hasattr(type_, "__args__") and type(type_) is _UnionGenericAlias # pylint: disable=unidiomatic-typecheck + hasattr(type_, "__args__") + and type(type_) + is _UnionGenericAlias # pylint: disable=unidiomatic-typecheck ): return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} @@ -73,14 +75,16 @@ def _shift(i: int) -> float: return 2 * (i + 1) / (2 * i) % 1 + 1 @staticmethod - def mock_data(dataset: Literal["ts_ohlcv", "panel_am"], size: int = 5) -> List[Dict]: + def mock_data( + dataset: Literal["ts_close_vol", "panel_am"], size: int = 5 + ) -> List[Dict]: """Return mock data for the example. Parameters ---------- dataset : str The type of data to return: - - 'ts_ohlcv': Time series OHLC data + - 'ts_close_vol': Time series OHLC data - 'panel_am': Panel data asset manager (multiindex) size : int @@ -91,7 +95,7 @@ def mock_data(dataset: Literal["ts_ohlcv", "panel_am"], size: int = 5) -> List[D List[Dict] A list of dictionaries with the mock data. """ - if dataset == "ts_ohlcv": + if dataset == "ts_close_vol": result = [] for i in range(1, size + 1): s = APIEx._shift(i) @@ -99,9 +103,6 @@ def mock_data(dataset: Literal["ts_ohlcv", "panel_am"], size: int = 5) -> List[D result.append( { "date": (start_date + datetime.timedelta(days=i)).isoformat(), - "open": round(118.47 * s, 2), - "high": round(118.80 * s, 2), - "low": round(104.64 * s, 2), "close": round(118.1 * s, 2), "volume": 231402800 + i * 1000000, } diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index f28191ad9282..1551b72d2706 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -40,7 +40,7 @@ "obb.econometrics.correlation_matrix(data=stock_data)", ], ), - APIEx(parameters={"data": APIEx.mock_data("ts_ohlcv")}), + APIEx(parameters={"data": APIEx.mock_data("ts_close_vol")}), ], ) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 2a20fff54454..a222953831e1 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -2,7 +2,7 @@ import numpy as np import pandas as pd -from openbb_core.app.model.example import PythonEx +from openbb_core.app.model.example import PythonEx, APIEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( @@ -30,7 +30,10 @@ 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.omega_ratio(data=returns, target="close")', ], - ) + ), + APIEx( + parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}, + ), ], ) def omega_ratio( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index f962e454e776..3d3931f0d910 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -46,7 +46,9 @@ "obb.quantitative.normality(data=stock_data, target='close')", ], ), - APIEx(parameters={"target": "open", "data": APIEx.mock_data("ts_ohlcv", 8)}), + APIEx( + parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol", 8)} + ), ], ) def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: @@ -102,7 +104,9 @@ def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: "obb.quantitative.capm(data=stock_data, target='close')", ], ), - APIEx(parameters={"target": "open", "data": APIEx.mock_data("ts_ohlcv", 31)}), + APIEx( + parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol", 31)} + ), ], ) def capm(data: List[Data], target: str) -> OBBject[CAPMModel]: @@ -165,9 +169,11 @@ def capm(data: List[Data], target: str) -> OBBject[CAPMModel]: "obb.quantitative.unitroot_test(data=stock_data, target='close')", ], ), - APIEx(parameters={"target": "open", "data": APIEx.mock_data("ts_ohlcv", 5)}), + APIEx( + parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol", 5)} + ), ], - ) +) def unitroot_test( data: List[Data], target: str, @@ -236,7 +242,9 @@ def unitroot_test( "obb.quantitative.summary(data=stock_data, target='close')", ], ), - APIEx(parameters={"target": "open", "data": APIEx.mock_data("ts_ohlcv", 5)}), + APIEx( + parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol", 5)} + ), ], ) def summary(data: List[Data], target: str) -> OBBject[SummaryModel]: diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index c57938f7a2c4..88f26c30655f 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -1017,7 +1017,7 @@ def clenow( "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("ts_ohlcv")}), + APIEx(parameters={"data": APIEx.mock_data("ts_close_vol")}), ], ) def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[Data]]: From 73aec6106a58e12fb309640b44e89791c44b8066 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 17:05:42 +0000 Subject: [PATCH 088/133] fix remaining quantitative routers --- .../core/openbb_core/app/model/example.py | 4 ++-- .../performance/performance_router.py | 10 ++++++++-- .../rolling/rolling_router.py | 20 ++++++++++++------- .../openbb_quantitative/stats/stats_router.py | 20 ++++++++++++------- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 37aa36e69395..8d3b39b64bf2 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -63,8 +63,8 @@ def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" if ( hasattr(type_, "__args__") - and type(type_) - is _UnionGenericAlias # pylint: disable=unidiomatic-typecheck + and type(type_) # pylint: disable=unidiomatic-typecheck + is _UnionGenericAlias ): return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index a222953831e1..a81062816e53 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -97,7 +97,10 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.sharpe_ratio(data=returns, target="close")', ], - ) + ), + APIEx( + parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}, + ), ], ) def sharpe_ratio( @@ -157,7 +160,10 @@ def sharpe_ratio( 'obb.quantitative.sortino_ratio(data=stock_data, target="close")', 'obb.quantitative.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', ], - ) + ), + APIEx( + parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}, + ), ], ) def sortino_ratio( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 9d42eaa010d3..30fa66eadd32 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model.example import PythonEx +from openbb_core.app.model.example import APIEx, PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( @@ -35,7 +35,8 @@ 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.skew(data=returns, target="close")', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def skew( @@ -89,7 +90,8 @@ def skew( 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.variance(data=returns, target="close", window=252)', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def variance( @@ -136,7 +138,8 @@ def variance( 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.stdev(data=returns, target="close", window=252)', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def stdev( @@ -187,7 +190,8 @@ def stdev( 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.kurtosis(data=returns, target="close", window=252)', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def kurtosis( @@ -241,7 +245,8 @@ def kurtosis( 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.25)', 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.75)', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def quantile( @@ -310,7 +315,8 @@ def quantile( 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.mean(data=returns, target="close", window=252)', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def mean( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index 66f68e7524fa..2087d6e1e3b1 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -3,7 +3,7 @@ from typing import List import pandas as pd -from openbb_core.app.model.example import PythonEx +from openbb_core.app.model.example import APIEx, PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( @@ -34,7 +34,8 @@ 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.skew(data=returns, target="close")', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def skew( @@ -80,7 +81,8 @@ def skew( 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.variance(data=returns, target="close")', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def variance(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -120,7 +122,8 @@ def variance(data: List[Data], target: str) -> OBBject[List[Data]]: 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.stdev(data=returns, target="close")', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -162,7 +165,8 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.kurtosis(data=returns, target="close")', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def kurtosis(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -205,7 +209,8 @@ def kurtosis(data: List[Data], target: str) -> OBBject[List[Data]]: 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.quantile(data=returns, target="close", quantile_pct=0.75)', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def quantile( @@ -255,7 +260,8 @@ def quantile( 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.mean(data=returns, target="close")', ], - ) + ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), ], ) def mean( From 93fac128fed8dc9ccb6e63f494a3f200f6cafdc9 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 17:11:11 +0000 Subject: [PATCH 089/133] a bit more flexibility for examples --- .../core/openbb_core/app/model/example.py | 31 +++++++++++-------- .../econometrics_router.py | 4 +-- .../performance/performance_router.py | 6 ++-- .../quantitative_router.py | 8 ++--- .../rolling/rolling_router.py | 12 +++---- .../openbb_quantitative/stats/stats_router.py | 12 +++---- .../openbb_technical/technical_router.py | 2 +- 7 files changed, 40 insertions(+), 35 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 8d3b39b64bf2..64ebf4f989ae 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -76,7 +76,7 @@ def _shift(i: int) -> float: @staticmethod def mock_data( - dataset: Literal["ts_close_vol", "panel_am"], size: int = 5 + dataset: Literal["timeseries", "panel"], size: int = 5, field_list: List[str] = None ) -> List[Dict]: """Return mock data for the example. @@ -84,18 +84,24 @@ def mock_data( ---------- dataset : str The type of data to return: - - 'ts_close_vol': Time series OHLC data - - 'panel_am': Panel data asset manager (multiindex) + - 'timeseries': Time series OHLC data + - 'panel': Panel data asset manager (multiindex) size : int The size of the data to return, default is 5. + field_list : List[str], optional + The list of fields to return, default: + - 'timeseries': ['close', 'volume'] + - 'panel': ['asset_manager', 'portfolio_value', 'risk_free_rate'] Returns ------- List[Dict] A list of dictionaries with the mock data. """ - if dataset == "ts_close_vol": + if dataset == "timeseries": + field_list = field_list or ["close", "volume"] + assert len(field_list) == 2, "field_list must have 2 elements" result = [] for i in range(1, size + 1): s = APIEx._shift(i) @@ -103,24 +109,23 @@ def mock_data( result.append( { "date": (start_date + datetime.timedelta(days=i)).isoformat(), - "close": round(118.1 * s, 2), - "volume": 231402800 + i * 1000000, + field_list[0]: round(118.1 * s, 2), + field_list[1]: 231402800 + i * 1000000, } ) return result - elif dataset == "panel_am": + elif dataset == "panel": + field_list = field_list or ["asset_manager", "portfolio_value", "risk_free_rate"] + assert len(field_list) == 3, "field_list must have 3 elements" result = [] for i in range(1, size + 1): s = APIEx._shift(i) result.append( { - "asset_manager": "BlackRock", + field_list[0]: "BlackRock", "time": i + 1, - "portfolio_value": 100000 + i * 1000, - "stock_a_return": round(0.05 * s, 2), - "stock_b_return": round(0.03 * s, 2), - "market_volatility": round(0.1 * s, 2), - "risk_free_rate": round(0.02 * s, 2), + field_list[1]: 100000 + i * 1000, + field_list[2]: round(0.02 * s, 2), "is_multiindex": True, "multiindex_names": "['asset_manager', 'time']", } diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 1551b72d2706..37ee7e87b041 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -40,7 +40,7 @@ "obb.econometrics.correlation_matrix(data=stock_data)", ], ), - APIEx(parameters={"data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: @@ -497,7 +497,7 @@ def unit_root( parameters={ "y_column": "portfolio_value", "x_columns": ["risk_free_rate"], - "data": APIEx.mock_data("panel_am"), + "data": APIEx.mock_data("panel"), } ) ], diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index a81062816e53..d2802ec90109 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -32,7 +32,7 @@ ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}, + parameters={"target": "close", "data": APIEx.mock_data("timeseries")}, ), ], ) @@ -99,7 +99,7 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}, + parameters={"target": "close", "data": APIEx.mock_data("timeseries")}, ), ], ) @@ -162,7 +162,7 @@ def sharpe_ratio( ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}, + parameters={"target": "close", "data": APIEx.mock_data("timeseries")}, ), ], ) diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 3d3931f0d910..fb173cac59f1 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -47,7 +47,7 @@ ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol", 8)} + parameters={"target": "close", "data": APIEx.mock_data("timeseries", 8)} ), ], ) @@ -105,7 +105,7 @@ def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol", 31)} + parameters={"target": "close", "data": APIEx.mock_data("timeseries", 31)} ), ], ) @@ -170,7 +170,7 @@ def capm(data: List[Data], target: str) -> OBBject[CAPMModel]: ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol", 5)} + parameters={"target": "close", "data": APIEx.mock_data("timeseries", 5)} ), ], ) @@ -243,7 +243,7 @@ def unitroot_test( ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol", 5)} + parameters={"target": "close", "data": APIEx.mock_data("timeseries", 5)} ), ], ) diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 30fa66eadd32..3f9ac91d6a31 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -36,7 +36,7 @@ 'obb.quantitative.rolling.skew(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def skew( @@ -91,7 +91,7 @@ def skew( 'obb.quantitative.rolling.variance(data=returns, target="close", window=252)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def variance( @@ -139,7 +139,7 @@ def variance( 'obb.quantitative.rolling.stdev(data=returns, target="close", window=252)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def stdev( @@ -191,7 +191,7 @@ def stdev( 'obb.quantitative.rolling.kurtosis(data=returns, target="close", window=252)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def kurtosis( @@ -246,7 +246,7 @@ def kurtosis( 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.75)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def quantile( @@ -316,7 +316,7 @@ def quantile( 'obb.quantitative.rolling.mean(data=returns, target="close", window=252)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def mean( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index 2087d6e1e3b1..6e9258eaaf96 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -35,7 +35,7 @@ 'obb.quantitative.stats.skew(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def skew( @@ -82,7 +82,7 @@ def skew( 'obb.quantitative.stats.variance(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def variance(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -123,7 +123,7 @@ def variance(data: List[Data], target: str) -> OBBject[List[Data]]: 'obb.quantitative.stats.stdev(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -166,7 +166,7 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: 'obb.quantitative.stats.kurtosis(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def kurtosis(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -210,7 +210,7 @@ def kurtosis(data: List[Data], target: str) -> OBBject[List[Data]]: 'obb.quantitative.stats.quantile(data=returns, target="close", quantile_pct=0.75)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def quantile( @@ -261,7 +261,7 @@ def quantile( 'obb.quantitative.stats.mean(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), ], ) def mean( diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 88f26c30655f..e27b5f86c741 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -1017,7 +1017,7 @@ def clenow( "ad_data = obb.technical.ad(data=stock_data.results, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("ts_close_vol")}), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[Data]]: From 2d580159edb85e5c9d31b8aa31e08b468e3592c7 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 17:11:32 +0000 Subject: [PATCH 090/133] lint --- .../core/openbb_core/app/model/example.py | 10 ++++++++-- .../core/openbb_core/app/static/package_builder.py | 2 +- .../performance/performance_router.py | 2 +- .../openbb_quantitative/quantitative_router.py | 12 +++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 64ebf4f989ae..98344ee8db9b 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -76,7 +76,9 @@ def _shift(i: int) -> float: @staticmethod def mock_data( - dataset: Literal["timeseries", "panel"], size: int = 5, field_list: List[str] = None + dataset: Literal["timeseries", "panel"], + size: int = 5, + field_list: List[str] = None, ) -> List[Dict]: """Return mock data for the example. @@ -115,7 +117,11 @@ def mock_data( ) return result elif dataset == "panel": - field_list = field_list or ["asset_manager", "portfolio_value", "risk_free_rate"] + field_list = field_list or [ + "asset_manager", + "portfolio_value", + "risk_free_rate", + ] assert len(field_list) == 3, "field_list must have 3 elements" result = [] for i in range(1, size + 1): diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 68f3bc9cdeca..5f1135a27df3 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -34,11 +34,11 @@ from typing_extensions import Annotated, _AnnotatedAlias from openbb_core.app.extension_loader import ExtensionLoader, OpenBBGroups -from openbb_core.app.model.example import Example from openbb_core.app.model.custom_parameter import ( OpenBBCustomChoices, OpenBBCustomParameter, ) +from openbb_core.app.model.example import Example from openbb_core.app.provider_interface import ProviderInterface from openbb_core.app.router import RouterLoader from openbb_core.app.static.utils.console import Console diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index d2802ec90109..78e18b1f2689 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -2,7 +2,7 @@ import numpy as np import pandas as pd -from openbb_core.app.model.example import PythonEx, APIEx +from openbb_core.app.model.example import APIEx, PythonEx from openbb_core.app.model.obbject import OBBject from openbb_core.app.router import Router from openbb_core.app.utils import ( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index fb173cac59f1..7963b39b66b8 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -46,9 +46,7 @@ "obb.quantitative.normality(data=stock_data, target='close')", ], ), - APIEx( - parameters={"target": "close", "data": APIEx.mock_data("timeseries", 8)} - ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries", 8)}), ], ) def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: @@ -169,9 +167,7 @@ def capm(data: List[Data], target: str) -> OBBject[CAPMModel]: "obb.quantitative.unitroot_test(data=stock_data, target='close')", ], ), - APIEx( - parameters={"target": "close", "data": APIEx.mock_data("timeseries", 5)} - ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries", 5)}), ], ) def unitroot_test( @@ -242,9 +238,7 @@ def unitroot_test( "obb.quantitative.summary(data=stock_data, target='close')", ], ), - APIEx( - parameters={"target": "close", "data": APIEx.mock_data("timeseries", 5)} - ), + APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries", 5)}), ], ) def summary(data: List[Data], target: str) -> OBBject[SummaryModel]: From 76e97dee75c2572dd787439e2f9d2fc2c70ce701 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 17:29:21 +0000 Subject: [PATCH 091/133] mock dat from sample --- .../core/openbb_core/app/model/example.py | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 98344ee8db9b..efdec20c95a8 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,6 +1,6 @@ """Example class to represent endpoint examples.""" -import datetime +from datetime import date, datetime, timedelta from abc import abstractmethod from typing import Any, Dict, List, Literal, Optional, Union, _UnionGenericAlias @@ -12,7 +12,7 @@ model_validator, ) -QUOTE_TYPES = {str, datetime.date} +QUOTE_TYPES = {str, date} class Example(BaseModel): @@ -78,7 +78,8 @@ def _shift(i: int) -> float: def mock_data( dataset: Literal["timeseries", "panel"], size: int = 5, - field_list: List[str] = None, + sample: Optional[Dict[str, Any]] = None, + multiindex_names: Optional[List[str]] = None, ) -> List[Dict]: """Return mock data for the example. @@ -102,40 +103,45 @@ def mock_data( A list of dictionaries with the mock data. """ if dataset == "timeseries": - field_list = field_list or ["close", "volume"] - assert len(field_list) == 2, "field_list must have 2 elements" + sample = sample or { + "date": "2023-01-01", + "close": 118.1, + "volume": 231402800, + } result = [] for i in range(1, size + 1): s = APIEx._shift(i) - start_date = datetime.date(2023, 1, 1) - result.append( - { - "date": (start_date + datetime.timedelta(days=i)).isoformat(), - field_list[0]: round(118.1 * s, 2), - field_list[1]: 231402800 + i * 1000000, - } - ) + obs = {} + for k, v in sample.items(): + if k == "date": + obs[k] = ( + datetime.strptime(v, "%Y-%m-%d") + timedelta(days=i) + ).strftime("%Y-%m-%d") + else: + obs[k] = round(v * s, 2) + result.append(obs) return result elif dataset == "panel": - field_list = field_list or [ - "asset_manager", - "portfolio_value", - "risk_free_rate", - ] - assert len(field_list) == 3, "field_list must have 3 elements" + sample = sample or { + "asset_manager": "BlackRock", + "time": 1, + "portfolio_value": 100000, + "risk_free_rate": 0.02, + } + multiindex_names = multiindex_names or ["asset_manager", "time"] result = [] for i in range(1, size + 1): s = APIEx._shift(i) - result.append( - { - field_list[0]: "BlackRock", - "time": i + 1, - field_list[1]: 100000 + i * 1000, - field_list[2]: round(0.02 * s, 2), - "is_multiindex": True, - "multiindex_names": "['asset_manager', 'time']", - } - ) + item: Dict[str, Any] = { + "is_multiindex": True, + "multiindex_names": str(multiindex_names), + } + for k, v in sample.items(): + if k == "asset_manager": + item[k] = v + else: + item[k] = round(v + i * 1000, 2) + result.append(item) return result raise ValueError(f"Dataset '{dataset}' not found.") From 88b97faa9d880409dddc481f58b1afd4e2ae1955 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 17:30:56 +0000 Subject: [PATCH 092/133] docstring --- .../core/openbb_core/app/model/example.py | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index efdec20c95a8..950f7fd1bbf4 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -92,10 +92,26 @@ def mock_data( size : int The size of the data to return, default is 5. - field_list : List[str], optional - The list of fields to return, default: - - 'timeseries': ['close', 'volume'] - - 'panel': ['asset_manager', 'portfolio_value', 'risk_free_rate'] + sample : Dict[str, Any], optional + A sample of the data to return, by default None. + multiindex_names : List[str], optional + The names of the multiindex, by default None. + + Timeseries default sample: + { + "date": "2023-01-01", + "close": 118.1, + "volume": 231402800, + } + + Panel default sample: + { + "asset_manager": "BlackRock", + "time": 1, + "portfolio_value": 100000, + "risk_free_rate": 0.02, + } + multiindex_names: ["asset_manager", "time"] Returns ------- From 26f04e2f83a6a567642c1cd25079fa76acd93b4f Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 17:33:37 +0000 Subject: [PATCH 093/133] assertion --- openbb_platform/core/openbb_core/app/model/example.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 950f7fd1bbf4..88c0d2bf741f 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -130,6 +130,7 @@ def mock_data( obs = {} for k, v in sample.items(): if k == "date": + assert isinstance(v, str) obs[k] = ( datetime.strptime(v, "%Y-%m-%d") + timedelta(days=i) ).strftime("%Y-%m-%d") From 29b41c3a9e3d983dcedb3d3de15ddb0d7de0bb7e Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 17:49:38 +0000 Subject: [PATCH 094/133] bugfix --- openbb_platform/core/openbb_core/app/model/example.py | 10 +++------- .../openbb/package/fixedincome_corporate.py | 11 ++++++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 88c0d2bf741f..5f2aa8fa2ba5 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -2,7 +2,7 @@ from datetime import date, datetime, timedelta from abc import abstractmethod -from typing import Any, Dict, List, Literal, Optional, Union, _UnionGenericAlias +from typing import Any, Dict, List, Literal, Optional, Union, _GenericAlias from pydantic import ( BaseModel, @@ -61,11 +61,7 @@ def check_model(cls, values: dict) -> dict: @staticmethod def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" - if ( - hasattr(type_, "__args__") - and type(type_) # pylint: disable=unidiomatic-typecheck - is _UnionGenericAlias - ): + if hasattr(type_, "__args__") and not (type(type_) is _GenericAlias): # pylint: disable=unidiomatic-typecheck return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} @@ -157,7 +153,7 @@ def mock_data( if k == "asset_manager": item[k] = v else: - item[k] = round(v + i * 1000, 2) + item[k] = round(v * s, 2) result.append(item) return result raise ValueError(f"Dataset '{dataset}' not found.") diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index 61fa7f74f76b..fbddb3d5a637 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -3,7 +3,10 @@ import datetime from typing import List, Literal, Optional, Union -from openbb_core.app.model.custom_parameter import OpenBBCustomParameter +from openbb_core.app.model.custom_parameter import ( + OpenBBCustomChoices, + OpenBBCustomParameter, +) from openbb_core.app.model.obbject import OBBject from openbb_core.app.static.container import Container from openbb_core.app.static.utils.decorators import exception_handler, validate @@ -433,6 +436,7 @@ def spot_rates( OpenBBCustomParameter( description="Rate category. Options: spot_rate, par_yield. Multiple items allowed for provider(s): fred." ), + OpenBBCustomChoices(choices=["par_yield", "spot_rate"]), ] = "spot_rate", provider: Optional[Literal["fred"]] = None, **kwargs @@ -507,10 +511,7 @@ def spot_rates( extra_params=kwargs, extra_info={ "maturity": {"multiple_items_allowed": ["fred"]}, - "category": { - "choices": ["par_yield", "spot_rate"], - "multiple_items_allowed": ["fred"], - }, + "category": {"multiple_items_allowed": ["fred"]}, }, ) ) From 6955062f6d3e16aa526711c315564ac86e17b31b Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 17:59:47 +0000 Subject: [PATCH 095/133] minor fix --- openbb_platform/core/openbb_core/app/model/example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 5f2aa8fa2ba5..beeb863e3927 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -150,7 +150,7 @@ def mock_data( "multiindex_names": str(multiindex_names), } for k, v in sample.items(): - if k == "asset_manager": + if isinstance(v, str): item[k] = v else: item[k] = round(v * s, 2) From 186a5360cbaf59fbee23719778e121e43c9642d7 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 18:10:19 +0000 Subject: [PATCH 096/133] technical --- .../core/openbb_core/app/model/example.py | 10 +++--- .../openbb_technical/technical_router.py | 36 ++++++++++++------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index beeb863e3927..dea2ecf04a90 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -1,7 +1,7 @@ """Example class to represent endpoint examples.""" -from datetime import date, datetime, timedelta from abc import abstractmethod +from datetime import date, datetime, timedelta from typing import Any, Dict, List, Literal, Optional, Union, _GenericAlias from pydantic import ( @@ -61,7 +61,7 @@ def check_model(cls, values: dict) -> dict: @staticmethod def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" - if hasattr(type_, "__args__") and not (type(type_) is _GenericAlias): # pylint: disable=unidiomatic-typecheck + if hasattr(type_, "__args__") and type(type_) is not _GenericAlias: # pylint: disable=unidiomatic-typecheck return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} @@ -77,14 +77,14 @@ def mock_data( sample: Optional[Dict[str, Any]] = None, multiindex_names: Optional[List[str]] = None, ) -> List[Dict]: - """Return mock data for the example. + """Generate mock data from a sample. Parameters ---------- dataset : str The type of data to return: - - 'timeseries': Time series OHLC data - - 'panel': Panel data asset manager (multiindex) + - 'timeseries': Time series data + - 'panel': Panel data (multiindex) size : int The size of the data to return, default is 5. diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index e27b5f86c741..199cb10c498e 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -164,7 +164,8 @@ def fib( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "obv_data = obb.technical.obv(data=stock_data.results, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def obv( @@ -216,7 +217,8 @@ def obv( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "fisher_data = obb.technical.fisher(data=stock_data.results, length=14, signal=1)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def fisher( @@ -400,7 +402,8 @@ def bbands( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "zlma_data = obb.technical.zlma(data=stock_data.results, target='close', length=50, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def zlma( @@ -521,7 +524,8 @@ def aroon( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "sma_data = obb.technical.sma(data=stock_data.results, target='close', length=50, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def sma( @@ -644,7 +648,8 @@ def demark( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "vwap_data = obb.technical.vwap(data=stock_data.results, anchor='D', offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def vwap( @@ -699,7 +704,8 @@ def vwap( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "macd_data = obb.technical.macd(data=stock_data.results, target='close', fast=12, slow=26, signal=9)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def macd( @@ -767,7 +773,8 @@ def macd( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "hma_data = obb.technical.hma(data=stock_data.results, target='close', length=50, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def hma( @@ -887,7 +894,8 @@ def donchian( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ichimoku_data = obb.technical.ichimoku(data=stock_data.results, conversion=9, base=26, lookahead=False)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def ichimoku( @@ -1123,7 +1131,8 @@ def adx( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "wma_data = obb.technical.wma(data=stock_data.results, target='close', length=50, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def wma( @@ -1236,7 +1245,8 @@ def cci( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "rsi_data = obb.technical.rsi(data=stock_data.results, target='close', length=14, scalar=100.0, drift=1)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def rsi( @@ -1302,7 +1312,8 @@ def rsi( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def stoch( @@ -1364,7 +1375,8 @@ def stoch( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "kc_data = obb.technical.kc(data=stock_data.results, length=20, scalar=20, mamode='ema', offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def kc( From 66bde2a7d2885deeefeda9d0f78e74cb82e24ce3 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 18:13:56 +0000 Subject: [PATCH 097/133] fix integration tests --- openbb_platform/extensions/tests/utils/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/extensions/tests/utils/helpers.py b/openbb_platform/extensions/tests/utils/helpers.py index ecc335da10ed..b98561e6f003 100644 --- a/openbb_platform/extensions/tests/utils/helpers.py +++ b/openbb_platform/extensions/tests/utils/helpers.py @@ -80,7 +80,7 @@ def check_docstring_examples() -> List[str]: return errors -def list_openbb_extensions() -> Tuple[Set[str], Set[str]]: +def list_openbb_extensions() -> Tuple[Set[str], Set[str], Set[str]]: """List installed openbb extensions and providers. Returns @@ -105,7 +105,7 @@ def list_openbb_extensions() -> Tuple[Set[str], Set[str]]: for entry_point in entry_points_dict.get("openbb_obbject_extension", []): obbject_extensions.add(f"{entry_point.name}") - return core_extensions, provider_extensions + return core_extensions, provider_extensions, obbject_extensions def collect_routers(target_dir: str) -> List[str]: From 3d371651454bc2fd108fef26de1c9fae56122d9b Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 18:18:43 +0000 Subject: [PATCH 098/133] fix docstring --- openbb_platform/core/openbb_core/app/model/example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index dea2ecf04a90..2feb10596a8b 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -88,9 +88,9 @@ def mock_data( size : int The size of the data to return, default is 5. - sample : Dict[str, Any], optional + sample : Optional[Dict[str, Any]], optional A sample of the data to return, by default None. - multiindex_names : List[str], optional + multiindex_names : Optional[List[str]], optional The names of the multiindex, by default None. Timeseries default sample: From 0773024cddd4dbfa64f613840608c166b93451b2 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 19:08:35 +0000 Subject: [PATCH 099/133] econometrics examples --- .../core/openbb_core/app/model/example.py | 18 +++++++++---- .../econometrics_router.py | 27 ++++++++++++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 2feb10596a8b..27cb73383a10 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -61,7 +61,9 @@ def check_model(cls, values: dict) -> dict: @staticmethod def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" - if hasattr(type_, "__args__") and type(type_) is not _GenericAlias: # pylint: disable=unidiomatic-typecheck + if ( + hasattr(type_, "__args__") and type(type_) is not _GenericAlias + ): # pylint: disable=unidiomatic-typecheck return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} @@ -96,8 +98,11 @@ def mock_data( Timeseries default sample: { "date": "2023-01-01", - "close": 118.1, - "volume": 231402800, + "open": 110.0, + "high": 120.0, + "low": 100.0, + "close": 115.0, + "volume": 10000, } Panel default sample: @@ -117,8 +122,11 @@ def mock_data( if dataset == "timeseries": sample = sample or { "date": "2023-01-01", - "close": 118.1, - "volume": 231402800, + "open": 110.0, + "high": 120.0, + "low": 100.0, + "close": 115.0, + "volume": 10000, } result = [] for i in range(1, size + 1): diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 37ee7e87b041..a42aac7f8adb 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -87,7 +87,14 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.ols_regression(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], - ) + ), + APIEx( + parameters={ + "y_column": "close", + "x_columns": ["open", "high", "low"], + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def ols_regression( @@ -132,7 +139,14 @@ def ols_regression( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], - ) + ), + APIEx( + parameters={ + "y_column": "close", + "x_columns": ["open", "high", "low"], + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def ols_regression_summary( @@ -210,7 +224,14 @@ def ols_regression_summary( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], - ) + ), + APIEx( + parameters={ + "y_column": "close", + "x_columns": ["open", "high", "low"], + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def autocorrelation( From b298b12d95a6563d357fa323e2dca76003537070 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 19:25:32 +0000 Subject: [PATCH 100/133] econometrics examples --- .../core/openbb_core/app/model/example.py | 6 + .../econometrics_router.py | 141 ++++++++++++++++-- 2 files changed, 138 insertions(+), 9 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 27cb73383a10..539659b4b146 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -3,6 +3,8 @@ from abc import abstractmethod from datetime import date, datetime, timedelta from typing import Any, Dict, List, Literal, Optional, Union, _GenericAlias +from warnings import warn +from openbb_core.app.model.abstract.warning import OpenBBWarning from pydantic import ( BaseModel, @@ -185,6 +187,10 @@ def to_python(self, **kwargs) -> str: else: eg += f"{k}={v}, " else: + warn( + message=f"Parameter '{k}' not found in 'obb{func_path}'", + category=OpenBBWarning, + ) eg += f"{k}={v}, " eg = indentation + eg.strip(", ") + ")\n" diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index a42aac7f8adb..778fb9df8273 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -278,7 +278,14 @@ def autocorrelation( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], - ) + ), + APIEx( + parameters={ + "y_column": "close", + "x_columns": ["open", "high", "low"], + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def residual_autocorrelation( @@ -338,7 +345,13 @@ def residual_autocorrelation( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.cointegration(data=stock_data, columns=["open", "close"])', ], - ) + ), + APIEx( + parameters={ + "columns": ["open", "close"], + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def cointegration( @@ -402,7 +415,14 @@ def cointegration( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", 'obb.econometrics.causality(data=stock_data, y_column="close", x_column="open")', ], - ) + ), + APIEx( + parameters={ + "y_column": "close", + "x_column": "open", + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def causality( @@ -465,7 +485,13 @@ def causality( 'obb.econometrics.unit_root(data=stock_data, column="close")', 'obb.econometrics.unit_root(data=stock_data, column="close", regression="ct")', ], - ) + ), + APIEx( + parameters={ + "column": "close", + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def unit_root( @@ -514,6 +540,13 @@ def unit_root( @router.command( methods=["POST"], examples=[ + PythonEx( + description="Perform One-way Random Effects model for panel data.", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.panel_random_effects(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ), APIEx( parameters={ "y_column": "portfolio_value", @@ -558,7 +591,25 @@ def panel_random_effects( return OBBject(results={"results": results}) -@router.command(methods=["POST"], include_in_schema=False) +@router.command( + methods=["POST"], + examples=[ + PythonEx( + description="Perform a Between estimator regression on panel data.", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.panel_between(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ), + APIEx( + parameters={ + "y_column": "portfolio_value", + "x_columns": ["risk_free_rate"], + "data": APIEx.mock_data("panel"), + } + ), + ], +) def panel_between( data: List[Data], y_column: str, @@ -592,7 +643,25 @@ def panel_between( return OBBject(results={"results": results}) -@router.command(methods=["POST"], include_in_schema=False) +@router.command( + methods=["POST"], + examples=[ + PythonEx( + description="Perform a Pooled coefficient estimator regression on panel data.", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.panel_pooled(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ), + APIEx( + parameters={ + "y_column": "portfolio_value", + "x_columns": ["risk_free_rate"], + "data": APIEx.mock_data("panel"), + } + ), + ], +) def panel_pooled( data: List[Data], y_column: str, @@ -627,7 +696,25 @@ def panel_pooled( return OBBject(results={"results": results}) -@router.command(methods=["POST"], include_in_schema=False) +@router.command( + methods=["POST"], + examples=[ + PythonEx( + description="Perform One- and two-way fixed effects estimator for panel data.", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.panel_fixed(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ), + APIEx( + parameters={ + "y_column": "portfolio_value", + "x_columns": ["risk_free_rate"], + "data": APIEx.mock_data("panel"), + } + ), + ], +) def panel_fixed( data: List[Data], y_column: str, @@ -661,7 +748,25 @@ def panel_fixed( return OBBject(results={"results": results}) -@router.command(methods=["POST"], include_in_schema=False) +@router.command( + methods=["POST"], + examples=[ + PythonEx( + description="Perform a first-difference estimate for panel data.", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.panel_first_difference(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ), + APIEx( + parameters={ + "y_column": "portfolio_value", + "x_columns": ["risk_free_rate"], + "data": APIEx.mock_data("panel"), + } + ), + ], +) def panel_first_difference( data: List[Data], y_column: str, @@ -695,7 +800,25 @@ def panel_first_difference( return OBBject(results={"results": results}) -@router.command(methods=["POST"], include_in_schema=False) +@router.command( + methods=["POST"], + examples=[ + PythonEx( + description="Fama-MacBeth estimator for panel data.", + code=[ + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + 'obb.econometrics.panel_fmac(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + ], + ), + APIEx( + parameters={ + "y_column": "portfolio_value", + "x_columns": ["risk_free_rate"], + "data": APIEx.mock_data("panel"), + } + ), + ], +) def panel_fmac( data: List[Data], y_column: str, From 6c9e7f7de71a292faf92b5388ef2e0009248ba20 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 19:28:31 +0000 Subject: [PATCH 101/133] remove warning --- openbb_platform/core/openbb_core/app/model/example.py | 6 ------ .../econometrics/openbb_econometrics/econometrics_router.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 539659b4b146..27cb73383a10 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -3,8 +3,6 @@ from abc import abstractmethod from datetime import date, datetime, timedelta from typing import Any, Dict, List, Literal, Optional, Union, _GenericAlias -from warnings import warn -from openbb_core.app.model.abstract.warning import OpenBBWarning from pydantic import ( BaseModel, @@ -187,10 +185,6 @@ def to_python(self, **kwargs) -> str: else: eg += f"{k}={v}, " else: - warn( - message=f"Parameter '{k}' not found in 'obb{func_path}'", - category=OpenBBWarning, - ) eg += f"{k}={v}, " eg = indentation + eg.strip(", ") + ")\n" diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 778fb9df8273..70d9e5617fc7 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -553,7 +553,7 @@ def unit_root( "x_columns": ["risk_free_rate"], "data": APIEx.mock_data("panel"), } - ) + ), ], ) def panel_random_effects( From 8efc40d21fad2fe8ee3f8fbd6accf2be67eec4fd Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 7 Mar 2024 19:33:20 +0000 Subject: [PATCH 102/133] add technical examples --- .../openbb_technical/technical_router.py | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 199cb10c498e..53d5e8d5efbf 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -32,7 +32,8 @@ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "atr_data = obb.technical.atr(data=stock_data.results)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def atr( @@ -94,7 +95,8 @@ def atr( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "fib_data = obb.technical.fib(data=stock_data.results, period=120)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def fib( @@ -270,7 +272,8 @@ def fisher( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "adosc_data = obb.technical.adosc(data=stock_data.results, fast=3, slow=10, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def adosc( @@ -325,7 +328,8 @@ def adosc( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def bbands( @@ -466,7 +470,8 @@ def zlma( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "aaron_data = obb.technical.aroon(data=stock_data.results, length=25, scalar=100)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def aroon( @@ -589,7 +594,8 @@ def sma( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "demark_data = obb.technical.demark(data=stock_data.results, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def demark( @@ -835,7 +841,8 @@ def hma( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def donchian( @@ -965,6 +972,7 @@ def ichimoku( "clenow_data = obb.technical.clenow(data=stock_data.results, period=90)", ], ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def clenow( @@ -1076,7 +1084,8 @@ def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[D "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "adx_data = obb.technical.adx(data=stock_data.results, length=50, scalar=100.0, drift=1)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def adx( @@ -1193,7 +1202,8 @@ def wma( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cci_data = obb.technical.cci(data=stock_data.results, length=14, scalar=0.015)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def cci( @@ -1440,7 +1450,8 @@ def kc( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cg_data = obb.technical.cg(data=stock_data.results, length=14)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def cg( @@ -1487,7 +1498,8 @@ def cg( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "cones_data = obb.technical.cones(data=stock_data.results, lower_q=0.25, upper_q=0.75, model='STD')", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def cones( @@ -1591,7 +1603,8 @@ def cones( "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "ema_data = obb.technical.ema(data=stock_data.results, target='close', length=50, offset=0)", ], - ) + ), + APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def ema( From 03d314a3cb4a9722103446861e6bf41a50bd2ea4 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 10:27:29 +0000 Subject: [PATCH 103/133] fix bad examples --- .../openbb_derivatives/futures/futures_router.py | 2 +- .../regulators/openbb_regulators/cftc/cftc_router.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index e82294832105..d5549a991db3 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -46,7 +46,7 @@ async def historical( @router.command( model="FuturesCurve", examples=[ - APIEx(parameters={"symbol": "NG"}), + APIEx(parameters={"symbol": "VX"}), APIEx( description="Enter a date to get the term structure from a historical date.", parameters={"symbol": "NG", "provider": "yfinance", "date": "2023-01-01"}, diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 386ab0cce125..9867df0f92ae 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -38,15 +38,15 @@ async def cot_search( APIEx(parameters={}), APIEx( description="Get the Commitment of Traders Report for Gold.", - parameters={"series_id": "GC=F"}, + parameters={"id": "GC=F"}, ), APIEx( description="Enter the report ID by the Nasdaq Data Link Code.", - parameters={"series_id": "088691"}, + parameters={"id": "088691"}, ), APIEx( description="Get the report for futures only.", - parameters={"series_id": "088691", "data_type": "F"}, + parameters={"id": "088691", "data_type": "F"}, ), ], ) From 517691ad303514f9ae327b1ee0d4bcf5eb57ff28 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 11:29:46 +0000 Subject: [PATCH 104/133] fix more examples --- .../index/openbb_index/price/price_router.py | 2 +- .../performance/performance_router.py | 8 +- .../rolling/rolling_router.py | 147 +++++++++++------- .../extensions/tests/utils/helpers.py | 32 +--- 4 files changed, 107 insertions(+), 82 deletions(-) diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index 4e3595b64726..6d16f353e134 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -19,7 +19,7 @@ @router.command( model="IndexHistorical", examples=[ - APIEx(parameters={"symbol": "^GSPC"}), + APIEx(parameters={"symbol": "SPX"}), APIEx(parameters={"symbol": "^GSPC", "provider": "fmp"}), APIEx( description="Not all providers have the same symbols.", diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 78e18b1f2689..25661f0a8a2a 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -28,7 +28,7 @@ code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.omega_ratio(data=returns, target="close")', + 'obb.quantitative.performance.omega_ratio(data=returns, target="close")', ], ), APIEx( @@ -95,7 +95,7 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.sharpe_ratio(data=returns, target="close")', + 'obb.quantitative.performance.sharpe_ratio(data=returns, target="close")', ], ), APIEx( @@ -157,8 +157,8 @@ def sharpe_ratio( code=[ 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', 'returns = stock_data["close"].pct_change().dropna()', - 'obb.quantitative.sortino_ratio(data=stock_data, target="close")', - 'obb.quantitative.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', + 'obb.quantitative.performance.sortino_ratio(data=stock_data, target="close")', + 'obb.quantitative.performance.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', ], ), APIEx( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 3f9ac91d6a31..620529536b91 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -36,7 +36,13 @@ 'obb.quantitative.rolling.skew(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "window": 5, + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def skew( @@ -91,7 +97,13 @@ def skew( 'obb.quantitative.rolling.variance(data=returns, target="close", window=252)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "window": 5, + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def variance( @@ -103,15 +115,16 @@ def variance( Variance measures the dispersion of a set of data points around their mean. It is a key metric for assessing the volatility and stability of financial returns or other time series data over a specified rolling window. - Parameters: - data: List[Data] - The time series data as a list of data points. - target: str - The name of the column for which to calculate variance. - window: PositiveInt - The number of observations used for calculating the rolling measure. - index: str, optional - The name of the index column, default is "date". + Parameters + ---------- + data: List[Data] + The time series data as a list of data points. + target: str + The name of the column for which to calculate variance. + window: PositiveInt + The number of observations used for calculating the rolling measure. + index: str, optional + The name of the index column, default is "date". Returns: ------- @@ -139,7 +152,13 @@ def variance( 'obb.quantitative.rolling.stdev(data=returns, target="close", window=252)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "window": 5, + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def stdev( @@ -152,15 +171,16 @@ def stdev( It is widely used to assess the risk and volatility of financial returns or other time series data over a specified rolling window. It is the square root of the variance. - Parameters: - data: List[Data] - The time series data as a list of data points. - target: str - The name of the column for which to calculate standard deviation. - window: PositiveInt - The number of observations used for calculating the rolling measure. - index: str, optional - The name of the index column, default is "date". + Parameters + ---------- + data: List[Data] + The time series data as a list of data points. + target: str + The name of the column for which to calculate standard deviation. + window: PositiveInt + The number of observations used for calculating the rolling measure. + index: str, optional + The name of the index column, default is "date". Returns: ------- @@ -191,7 +211,13 @@ def stdev( 'obb.quantitative.rolling.kurtosis(data=returns, target="close", window=252)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "window": 5, + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def kurtosis( @@ -206,15 +232,16 @@ def kurtosis( This function helps in assessing the risk of outliers in financial returns or other time series data over a specified rolling window. - Parameters: - data: List[Data] - The time series data as a list of data points. - target: str - The name of the column for which to calculate kurtosis. - window: PositiveInt - The number of observations used for calculating the rolling measure. - index: str, optional - The name of the index column, default is "date". + Parameters + ---------- + data: List[Data] + The time series data as a list of data points. + target: str + The name of the column for which to calculate kurtosis. + window: PositiveInt + The number of observations used for calculating the rolling measure. + index: str, optional + The name of the index column, default is "date". Returns: ------- @@ -246,7 +273,13 @@ def kurtosis( 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.75)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "window": 5, + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def quantile( @@ -263,17 +296,18 @@ def quantile( or dividing the sample in the same way. This function is useful for understanding the distribution of data within a specified window, allowing for analysis of trends, identification of outliers, and assessment of risk. - Parameters: - data: List[Data] - The time series data as a list of data points. - target: str - The name of the column for which to calculate the quantile. - window: PositiveInt - The number of observations used for calculating the rolling measure. - quantile_pct: NonNegativeFloat, optional - The quantile percentage to calculate (e.g., 0.5 for median), default is 0.5. - index: str, optional - The name of the index column, default is "date". + Parameters + ---------- + data: List[Data] + The time series data as a list of data points. + target: str + The name of the column for which to calculate the quantile. + window: PositiveInt + The number of observations used for calculating the rolling measure. + quantile_pct: NonNegativeFloat, optional + The quantile percentage to calculate (e.g., 0.5 for median), default is 0.5. + index: str, optional + The name of the index column, default is "date". Returns: ------- @@ -316,7 +350,13 @@ def quantile( 'obb.quantitative.rolling.mean(data=returns, target="close", window=252)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "window": 5, + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def mean( @@ -329,15 +369,16 @@ def mean( This function is widely used in financial analysis to smooth short-term fluctuations and highlight longer-term trends or cycles in time series data. - Parameters: - data: List[Data] - The time series data as a list of data points. - target: str - The name of the column for which to calculate the mean. - window: PositiveInt - The number of observations used for calculating the rolling measure. - index: str, optional - The name of the index column, default is "date". + Parameters + ---------- + data: List[Data] + The time series data as a list of data points. + target: str + The name of the column for which to calculate the mean. + window: PositiveInt + The number of observations used for calculating the rolling measure. + index: str, optional + The name of the index column, default is "date". Returns: OBBject[List[Data]] diff --git a/openbb_platform/extensions/tests/utils/helpers.py b/openbb_platform/extensions/tests/utils/helpers.py index b98561e6f003..65baa2a17b36 100644 --- a/openbb_platform/extensions/tests/utils/helpers.py +++ b/openbb_platform/extensions/tests/utils/helpers.py @@ -33,37 +33,21 @@ def get_packages_info() -> Dict[str, str]: return paths_and_names -def execute_docstring_examples( - module_name: str, file_path: str, verbose: bool = False -) -> List[str]: +def execute_docstring_examples(module_name: str, path: str) -> List[str]: """Execute the docstring examples of a module.""" errors = [] - module_name = f"openbb.package.{module_name}" - module = importlib.import_module(module_name) - examples = doctest.DocTestFinder().find(module) + module = importlib.import_module(f"openbb.package.{module_name}") + doc_tests = doctest.DocTestFinder().find(module) - def execute_script(script, source_info): + for dt in doc_tests: + code = "".join([ex.source for ex in dt.examples]) try: - local_namespace = {} - exec( # noqa: S102 pylint: disable=exec-used - script, local_namespace, local_namespace - ) - if verbose: - logging.info("Executed a test from %s", source_info) + exec(code) # pylint: disable=exec-used except Exception as e: errors.append( - f"An exception occurred while executing script from {source_info} - {str(e)}" + f"\n\n{'_'*136}\nPath: {path}\nCode:\n{code}\nError: {str(e)}" ) - for example in examples: - script_lines = [] - - for test in example.examples: - script_lines.append(test.source) - - script_content = "".join(script_lines) - execute_script(script_content, file_path) - return errors @@ -73,7 +57,7 @@ def check_docstring_examples() -> List[str]: paths_and_names = get_packages_info() for path, name in paths_and_names.items(): - result = execute_docstring_examples(name, path, verbose=True) + result = execute_docstring_examples(name, path) if result: errors.extend(result) From 450b2bbd5153b70283bfa096a88edacbd7871925 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 11:55:50 +0000 Subject: [PATCH 105/133] update test rules --- .../core/openbb_core/app/model/example.py | 4 ++-- .../index/openbb_index/index_router.py | 1 - .../extensions/tests/test_routers.py | 13 ++++++++++++- .../extensions/tests/utils/router_testers.py | 18 ++---------------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 27cb73383a10..e9f1415ac04a 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -62,8 +62,8 @@ def check_model(cls, values: dict) -> dict: def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" if ( - hasattr(type_, "__args__") and type(type_) is not _GenericAlias - ): # pylint: disable=unidiomatic-typecheck + hasattr(type_, "__args__") and type(type_) is not _GenericAlias # pylint: disable=unidiomatic-typecheck + ): return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index 0e207de9c5f0..e075ceb00330 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -43,7 +43,6 @@ async def market( @router.command( model="IndexConstituents", examples=[ - APIEx(parameters={"symbol": "dowjones"}), APIEx(parameters={"symbol": "dowjones", "provider": "fmp"}), APIEx( description="Providers other than FMP will use the ticker symbol.", diff --git a/openbb_platform/extensions/tests/test_routers.py b/openbb_platform/extensions/tests/test_routers.py index 19515e04523f..0b4223783e34 100644 --- a/openbb_platform/extensions/tests/test_routers.py +++ b/openbb_platform/extensions/tests/test_routers.py @@ -20,6 +20,17 @@ def test_router_model_functions_signature() -> None: def test_router_examples() -> None: - """Test if the router examples are valid.""" + """Test if the router examples follow certain criteria. + + Criteria + -------- + General: + - All endpoints should have examples. + - If any endpoint is excluded from the schema it only needs to contain a Python example. + - POST method examples should have both API and Python examples, unless they are excluded from the schema. + + API examples: + - At least one example using all required parameters. + """ invalid_examples = check_router_command_examples() assert not invalid_examples, "\n".join(sorted(invalid_examples)) diff --git a/openbb_platform/extensions/tests/utils/router_testers.py b/openbb_platform/extensions/tests/utils/router_testers.py index 2a5e52cddee0..39b1c4170f47 100644 --- a/openbb_platform/extensions/tests/utils/router_testers.py +++ b/openbb_platform/extensions/tests/utils/router_testers.py @@ -136,7 +136,7 @@ def check_api_example_violations( required_fields = get_required_fields(model.strip("'")) for api_example in parsed_examples["APIEx"]: params = ast.literal_eval(api_example.get("params", "{}")) - if set(params.keys()) == set(required_fields): + if len(set(params.keys()) - set(required_fields) - {"provider"}) == 0: break else: api_example_violation.append( @@ -147,21 +147,7 @@ def check_api_example_violations( def check_router_command_examples() -> List[str]: - """Check if the router command examples satisfy criteria. - - Criteria - -------- - General: - - All endpoints should have examples. - - If any endpoint is excluded from the schema it only needs to contain a Python example. - - POST method examples should have both API and Python examples, - unless they are excluded from the schema. - - API examples: - - At least one example using all required parameters. - - It cannot use any provider specific parameters here. - - It should not specify the provider field. - """ + """Check if the router command examples satisfy criteria.""" general_violation: List[str] = [] api_example_violation: List[str] = [] python_example_violation: List[str] = [] From d72c2e6ea815b151aba7f0c3c4b6740e91e9a5f1 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 12:09:45 +0000 Subject: [PATCH 106/133] remoce old pydantic referenc --- openbb_platform/core/openbb_core/app/model/metadata.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/metadata.py b/openbb_platform/core/openbb_core/app/model/metadata.py index 27a6b8eb0dfa..e5ea6a0f5bf2 100644 --- a/openbb_platform/core/openbb_core/app/model/metadata.py +++ b/openbb_platform/core/openbb_core/app/model/metadata.py @@ -42,12 +42,12 @@ def scale_arguments(cls, v): if isclass(type(arg_val)) and issubclass(type(arg_val), Data): new_arg_val = { "type": f"{type(arg_val).__name__}", - "columns": list(arg_val.dict().keys()), + "columns": list(arg_val.model_dump().keys()), } # List[Data] if isinstance(arg_val, list) and issubclass(type(arg_val[0]), Data): - columns = [list(d.dict().keys()) for d in arg_val] + columns = [list(d.model_dump().keys()) for d in arg_val] columns = (item for sublist in columns for item in sublist) # flatten new_arg_val = { "type": f"List[{type(arg_val[0]).__name__}]", From 85ab01cce99e6d0f461811be1ea9f8a643ab780f Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 12:10:03 +0000 Subject: [PATCH 107/133] fix bug in treasury prices --- .../core/openbb_core/app/model/example.py | 4 ++- .../extensions/tests/test_routers.py | 8 ++---- .../models/treasury_prices.py | 28 +++++++++++-------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index e9f1415ac04a..48c946c1663f 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -62,7 +62,9 @@ def check_model(cls, values: dict) -> dict: def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" if ( - hasattr(type_, "__args__") and type(type_) is not _GenericAlias # pylint: disable=unidiomatic-typecheck + hasattr(type_, "__args__") + and type(type_) + is not _GenericAlias # pylint: disable=unidiomatic-typecheck ): return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} diff --git a/openbb_platform/extensions/tests/test_routers.py b/openbb_platform/extensions/tests/test_routers.py index 0b4223783e34..70e79bd33d9f 100644 --- a/openbb_platform/extensions/tests/test_routers.py +++ b/openbb_platform/extensions/tests/test_routers.py @@ -19,12 +19,10 @@ def test_router_model_functions_signature() -> None: assert not missing_args, "\n".join(missing_args) -def test_router_examples() -> None: - """Test if the router examples follow certain criteria. +def test_router_examples_rules() -> None: + """Test if the router examples follow certain rules. - Criteria - -------- - General: + General rules: - All endpoints should have examples. - If any endpoint is excluded from the schema it only needs to contain a Python example. - POST method examples should have both API and Python examples, unless they are excluded from the schema. diff --git a/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py b/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py index fceb35b327b9..5f22a49be467 100644 --- a/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py +++ b/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py @@ -5,6 +5,7 @@ from datetime import datetime, timedelta from io import StringIO from typing import Any, Dict, List, Literal, Optional +from openbb_core.provider.utils.errors import EmptyDataError import requests from openbb_core.provider.abstract.fetcher import Fetcher @@ -13,7 +14,7 @@ TreasuryPricesQueryParams, ) from openbb_government_us.utils.helpers import get_random_agent -from pandas import read_csv, to_datetime +from pandas import Index, read_csv, to_datetime from pydantic import Field @@ -111,18 +112,21 @@ def transform_data( """Transform the data.""" try: + if not data: + raise EmptyDataError("Data not found") results = read_csv(StringIO(data), header=0) - columns = [ - "cusip", - "security_type", - "rate", - "maturity_date", - "call_date", - "bid", - "offer", - "eod_price", - ] - results.columns = columns + results.columns = Index( + [ + "cusip", + "security_type", + "rate", + "maturity_date", + "call_date", + "bid", + "offer", + "eod_price", + ] + ) results["date"] = query.date.strftime("%Y-%m-%d") # type: ignore for col in ["maturity_date", "call_date"]: results[col] = ( From 936dc54da508886714b9a4d3df1cff5ec079ab40 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 12:31:53 +0000 Subject: [PATCH 108/133] fix quantitative examples --- .../performance/performance_router.py | 25 +++++++- .../rolling/rolling_router.py | 30 +++++++-- .../openbb_quantitative/stats/stats_router.py | 64 ++++++++++++++++--- 3 files changed, 102 insertions(+), 17 deletions(-) diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 25661f0a8a2a..0d5c24a152cb 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -32,7 +32,13 @@ ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("timeseries")}, + parameters={ + "target": "close", + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + }, ), ], ) @@ -99,7 +105,14 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("timeseries")}, + parameters={ + "target": "close", + "window": 5, + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + }, ), ], ) @@ -162,7 +175,13 @@ def sharpe_ratio( ], ), APIEx( - parameters={"target": "close", "data": APIEx.mock_data("timeseries")}, + parameters={ + "target": "close", + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + }, ), ], ) diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 620529536b91..54e62f45c2f2 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -40,7 +40,10 @@ parameters={ "target": "close", "window": 5, - "data": APIEx.mock_data("timeseries"), + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), } ), ], @@ -101,7 +104,10 @@ def skew( parameters={ "target": "close", "window": 5, - "data": APIEx.mock_data("timeseries"), + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), } ), ], @@ -156,7 +162,10 @@ def variance( parameters={ "target": "close", "window": 5, - "data": APIEx.mock_data("timeseries"), + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), } ), ], @@ -215,7 +224,10 @@ def stdev( parameters={ "target": "close", "window": 5, - "data": APIEx.mock_data("timeseries"), + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), } ), ], @@ -277,7 +289,10 @@ def kurtosis( parameters={ "target": "close", "window": 5, - "data": APIEx.mock_data("timeseries"), + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), } ), ], @@ -354,7 +369,10 @@ def quantile( parameters={ "target": "close", "window": 5, - "data": APIEx.mock_data("timeseries"), + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), } ), ], diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index 6e9258eaaf96..4a59e544ff87 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -35,7 +35,15 @@ 'obb.quantitative.stats.skew(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + } + ), ], ) def skew( @@ -82,7 +90,15 @@ def skew( 'obb.quantitative.stats.variance(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + } + ), ], ) def variance(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -123,7 +139,15 @@ def variance(data: List[Data], target: str) -> OBBject[List[Data]]: 'obb.quantitative.stats.stdev(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + } + ), ], ) def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -131,8 +155,8 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: Calculate the rolling standard deviation of a target column. Standard deviation is a measure of the amount of variation or dispersion of a set of values. - It is widely used to assess the risk and volatility of financial returns or other time series data - It is the square root of the variance. + It is widely used to assess the risk and volatility of financial returns or other time series data + It is the square root of the variance. Parameters ---------- @@ -166,7 +190,15 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: 'obb.quantitative.stats.kurtosis(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + } + ), ], ) def kurtosis(data: List[Data], target: str) -> OBBject[List[Data]]: @@ -210,7 +242,15 @@ def kurtosis(data: List[Data], target: str) -> OBBject[List[Data]]: 'obb.quantitative.stats.quantile(data=returns, target="close", quantile_pct=0.75)', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + } + ), ], ) def quantile( @@ -261,7 +301,15 @@ def quantile( 'obb.quantitative.stats.mean(data=returns, target="close")', ], ), - APIEx(parameters={"target": "close", "data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "target": "close", + "data": APIEx.mock_data( + "timeseries", + sample={"date": "2023-01-01", "close": 0.05}, + ), + } + ), ], ) def mean( From 36e011173bc69993a7023bda9615427bfb95c5ab Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 12:37:27 +0000 Subject: [PATCH 109/133] discovery router --- .../equity/openbb_equity/discovery/discovery_router.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index 596665fa4576..9ae09e12b1c4 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -115,7 +115,7 @@ async def growth_tech( @router.command( model="TopRetail", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[APIEx(parameters={})], ) async def top_retail( cc: CommandContext, @@ -132,7 +132,7 @@ async def top_retail( @router.command( model="UpcomingReleaseDays", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[APIEx(parameters={})], ) async def upcoming_release_days( cc: CommandContext, From 63927a7950c4084c961b399b5c516f5f08c8cf87 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 15:09:07 +0000 Subject: [PATCH 110/133] equity shorts --- .../provider/standard_models/equity_short_interest.py | 6 +----- .../openbb_finra/models/equity_short_interest.py | 11 +++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/equity_short_interest.py b/openbb_platform/core/openbb_core/provider/standard_models/equity_short_interest.py index 5cd60bb3de3b..8d1ef4b34a2c 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/equity_short_interest.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/equity_short_interest.py @@ -1,7 +1,6 @@ """Equity Short Interest Standard Model.""" from datetime import date as dateType -from typing import Optional from pydantic import Field @@ -16,10 +15,7 @@ class ShortInterestQueryParams(QueryParams): """Equity Short Interest Query.""" - symbol: Optional[str] = Field( - description=QUERY_DESCRIPTIONS.get("symbol", ""), - default=None, - ) + symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) class ShortInterestData(Data): diff --git a/openbb_platform/providers/finra/openbb_finra/models/equity_short_interest.py b/openbb_platform/providers/finra/openbb_finra/models/equity_short_interest.py index d63e67540ea9..dc9507a3768e 100644 --- a/openbb_platform/providers/finra/openbb_finra/models/equity_short_interest.py +++ b/openbb_platform/providers/finra/openbb_finra/models/equity_short_interest.py @@ -54,12 +54,11 @@ def extract_data( # Get the data from the cache cnx = sqlite3.connect(DB_PATH) cursor = cnx.cursor() - if query.symbol: - cursor.execute( - "SELECT * FROM short_interest where symbolCode = ?", (query.symbol,) - ) - else: - cursor.execute("SELECT * FROM short_interest") + cursor.execute( + "SELECT * FROM short_interest where symbolCode = ?", (query.symbol,) + ) + # TODO: Check if we should allow general queries, it's more than 500k rows + # cursor.execute("SELECT * FROM short_interest") result = cursor.fetchall() titles = [ From be027e9399aeae915c3dad7c3eadd5d4632551ba Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 15:09:31 +0000 Subject: [PATCH 111/133] equity shorts --- .../extensions/equity/openbb_equity/shorts/shorts_router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index ff88d06f9111..d917c1a8fd38 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -46,7 +46,7 @@ async def short_volume( @router.command( model="EquityShortInterest", - examples=[APIEx(parameters={}), APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL"})], ) async def short_interest( cc: CommandContext, From fe772a44926c58afc2f001531c674c3e3bf17e46 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 15:20:32 +0000 Subject: [PATCH 112/133] fix currency pairs --- openbb_platform/core/openbb_core/app/model/example.py | 2 +- .../providers/polygon/openbb_polygon/models/currency_pairs.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 48c946c1663f..11665e2a251a 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -139,7 +139,7 @@ def mock_data( assert isinstance(v, str) obs[k] = ( datetime.strptime(v, "%Y-%m-%d") + timedelta(days=i) - ).strftime("%Y-%m-%d") + ).isoformat() else: obs[k] = round(v * s, 2) result.append(obs) diff --git a/openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py b/openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py index 2ea951781d2f..965878c06c3b 100644 --- a/openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py +++ b/openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py @@ -105,12 +105,12 @@ class PolygonCurrencyPairsFetcher( def transform_query(params: Dict[str, Any]) -> PolygonCurrencyPairsQueryParams: """Transform the query parameters. Ticker is set if symbol is provided.""" transform_params = params - now = datetime.now().date() + now = datetime.now().date().isoformat() transform_params["symbol"] = ( f"ticker=C:{params.get('symbol').upper()}" if params.get("symbol") else "" ) if params.get("date") is None: - transform_params["start_date"] = now + transform_params["date"] = now return PolygonCurrencyPairsQueryParams(**transform_params) From 6a31fa61e27db2bb98d4a9ed9778228cb6a65674 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 15:58:32 +0000 Subject: [PATCH 113/133] fix sec_router example --- .../provider/standard_models/symbol_map.py | 17 +++++++++++ .../openbb_regulators/sec/sec_router.py | 30 +++++++++---------- .../sec/openbb_sec/models/symbol_map.py | 8 +++-- 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 openbb_platform/core/openbb_core/provider/standard_models/symbol_map.py diff --git a/openbb_platform/core/openbb_core/provider/standard_models/symbol_map.py b/openbb_platform/core/openbb_core/provider/standard_models/symbol_map.py new file mode 100644 index 000000000000..b47d43827672 --- /dev/null +++ b/openbb_platform/core/openbb_core/provider/standard_models/symbol_map.py @@ -0,0 +1,17 @@ +"""Commitment of Traders Reports Search Standard Model.""" + +from typing import Optional + +from pydantic import Field + +from openbb_core.provider.abstract.query_params import QueryParams + + +class SymbolMapQueryParams(QueryParams): + """Commitment of Traders Reports Search Query.""" + + query: str = Field(description="Search query.") + use_cache: Optional[bool] = Field( + default=True, + description="Whether or not to use cache. If True, cache will store for seven days.", + ) diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index 574d43e218d1..db85d8041e30 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -53,23 +53,23 @@ async def institutions_search( PythonEx( description="Get a list of schema files.", code=[ - "data = obb.regulators.sec.schema_files()", + "data = obb.regulators.sec.schema_files().results", "data.files[0]", - " https://xbrl.fasb.org/us-gaap/", - "#### The directory structure can be navigated by constructing a URL from the 'results' list. ####", + "'https://xbrl.fasb.org/us-gaap/'", + "# The directory structure can be navigated by constructing a URL from the 'results' list.", "url = data.files[0]+data.files[-1]", - "#### The URL base will always be the 0 position in the list, feed the URL back in as a parameter. ####", + "# The URL base will always be the 0 position in the list, feed the URL back in as a parameter.", "obb.regulators.sec.schema_files(url=url).results.files", - " ['https://xbrl.fasb.org/us-gaap/2024/'", - " 'USGAAP2024FileList.xml'", - " 'dis/'", - " 'dqcrules/'", - " 'ebp/'", - " 'elts/'", - " 'entire/'", - " 'meta/'", - " 'stm/'", - " 'us-gaap-2024.zip']", + "['https://xbrl.fasb.org/us-gaap/2024/'", + "'USGAAP2024FileList.xml'", + "'dis/'", + "'dqcrules/'", + "'ebp/'", + "'elts/'", + "'entire/'", + "'meta/'", + "'stm/'", + "'us-gaap-2024.zip']", ], ), ], @@ -86,7 +86,7 @@ async def schema_files( @router.command( model="SymbolMap", - examples=[APIEx(parameters={}), APIEx(parameters={"query": "0000789019"})], + examples=[APIEx(parameters={"query": "0000789019"})], ) async def symbol_map( cc: CommandContext, diff --git a/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py b/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py index 7d977093a5b0..7feef714ce86 100644 --- a/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py +++ b/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py @@ -4,13 +4,13 @@ from openbb_core.provider.abstract.data import Data from openbb_core.provider.abstract.fetcher import Fetcher -from openbb_core.provider.standard_models.cot_search import CotSearchQueryParams +from openbb_core.provider.standard_models.symbol_map import SymbolMapQueryParams from openbb_core.provider.utils.descriptions import DATA_DESCRIPTIONS from openbb_sec.utils.helpers import cik_map from pydantic import Field -class SecSymbolMapQueryParams(CotSearchQueryParams): +class SecSymbolMapQueryParams(SymbolMapQueryParams): """SEC Symbol Mapping Query. Source: https://sec.gov/ @@ -43,9 +43,11 @@ def extract_data( **kwargs: Any, ) -> Dict: """Return the raw data from the SEC endpoint.""" + if not query.query.isdigit(): + raise ValueError("Query is required and must be a valid CIK.") return {"symbol": cik_map(int(query.query))} @staticmethod - def transform_data(data: Dict, **kwargs: Any) -> SecSymbolMapData: + def transform_data(query: SecSymbolMapQueryParams, data: Dict, **kwargs: Any) -> SecSymbolMapData: """Transform the data to the standard format.""" return SecSymbolMapData.model_validate(data) From b8324f895f04998670df3d81f266bb6114812a46 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 17:10:47 +0000 Subject: [PATCH 114/133] fix panel data to support all funcs --- .../core/openbb_core/app/model/example.py | 37 +++++++++------- .../econometrics_router.py | 42 ------------------- 2 files changed, 21 insertions(+), 58 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 11665e2a251a..174004c2c2fd 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -79,7 +79,7 @@ def mock_data( dataset: Literal["timeseries", "panel"], size: int = 5, sample: Optional[Dict[str, Any]] = None, - multiindex_names: Optional[List[str]] = None, + multiindex: Optional[Dict[str, Any]] = None, ) -> List[Dict]: """Generate mock data from a sample. @@ -146,25 +146,30 @@ def mock_data( return result elif dataset == "panel": sample = sample or { - "asset_manager": "BlackRock", - "time": 1, - "portfolio_value": 100000, + "portfolio_value": 100000.0, "risk_free_rate": 0.02, } - multiindex_names = multiindex_names or ["asset_manager", "time"] + multiindex = multiindex or {"asset_manager": "AM", "time": 0} + multiindex_names = list(multiindex.keys()) + idx_1 = multiindex_names[0] + idx_2 = multiindex_names[1] + items_per_idx = 2 + item: Dict[str, Any] = { + "is_multiindex": True, + "multiindex_names": str(multiindex_names), + } + # Iterate over the number of items to create and add items to the result result = [] for i in range(1, size + 1): - s = APIEx._shift(i) - item: Dict[str, Any] = { - "is_multiindex": True, - "multiindex_names": str(multiindex_names), - } - for k, v in sample.items(): - if isinstance(v, str): - item[k] = v - else: - item[k] = round(v * s, 2) - result.append(item) + item[idx_1] = f"{idx_1}_{i}" + for j in range(items_per_idx): + item[idx_2] = j + for k, v in sample.items(): + if isinstance(v, str): + item[k] = f"{v}_{j}" + else: + item[k] = round(v * APIEx._shift(i + j), 2) + result.append(item.copy()) return result raise ValueError(f"Dataset '{dataset}' not found.") diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 70d9e5617fc7..a77c50560602 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -540,13 +540,6 @@ def unit_root( @router.command( methods=["POST"], examples=[ - PythonEx( - description="Perform One-way Random Effects model for panel data.", - code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.panel_random_effects(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', - ], - ), APIEx( parameters={ "y_column": "portfolio_value", @@ -594,13 +587,6 @@ def panel_random_effects( @router.command( methods=["POST"], examples=[ - PythonEx( - description="Perform a Between estimator regression on panel data.", - code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.panel_between(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', - ], - ), APIEx( parameters={ "y_column": "portfolio_value", @@ -646,13 +632,6 @@ def panel_between( @router.command( methods=["POST"], examples=[ - PythonEx( - description="Perform a Pooled coefficient estimator regression on panel data.", - code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.panel_pooled(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', - ], - ), APIEx( parameters={ "y_column": "portfolio_value", @@ -699,13 +678,6 @@ def panel_pooled( @router.command( methods=["POST"], examples=[ - PythonEx( - description="Perform One- and two-way fixed effects estimator for panel data.", - code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.panel_fixed(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', - ], - ), APIEx( parameters={ "y_column": "portfolio_value", @@ -751,13 +723,6 @@ def panel_fixed( @router.command( methods=["POST"], examples=[ - PythonEx( - description="Perform a first-difference estimate for panel data.", - code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.panel_first_difference(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', - ], - ), APIEx( parameters={ "y_column": "portfolio_value", @@ -803,13 +768,6 @@ def panel_first_difference( @router.command( methods=["POST"], examples=[ - PythonEx( - description="Fama-MacBeth estimator for panel data.", - code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.panel_fmac(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', - ], - ), APIEx( parameters={ "y_column": "portfolio_value", From 05f5f088dff71ab1cc7f55387ff0e1f0be58d10c Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 17:11:05 +0000 Subject: [PATCH 115/133] black --- openbb_platform/providers/sec/openbb_sec/models/symbol_map.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py b/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py index 7feef714ce86..2ba2e2858661 100644 --- a/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py +++ b/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py @@ -48,6 +48,8 @@ def extract_data( return {"symbol": cik_map(int(query.query))} @staticmethod - def transform_data(query: SecSymbolMapQueryParams, data: Dict, **kwargs: Any) -> SecSymbolMapData: + def transform_data( + query: SecSymbolMapQueryParams, data: Dict, **kwargs: Any + ) -> SecSymbolMapData: """Transform the data to the standard format.""" return SecSymbolMapData.model_validate(data) From 92bc044c79878c4e7f6a9273760cca735c2ebbb2 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 19:53:12 +0000 Subject: [PATCH 116/133] more examples fixes --- .../core/openbb_core/app/model/example.py | 8 +- .../econometrics_router.py | 4 +- .../performance/performance_router.py | 10 +- .../rolling/rolling_router.py | 12 +-- .../technical/openbb_technical/helpers.py | 13 ++- .../openbb_technical/technical_router.py | 98 +++++++++++++------ .../models/treasury_prices.py | 2 +- 7 files changed, 98 insertions(+), 49 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 174004c2c2fd..4d09d8c63f5c 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -109,12 +109,10 @@ def mock_data( Panel default sample: { - "asset_manager": "BlackRock", - "time": 1, "portfolio_value": 100000, "risk_free_rate": 0.02, } - multiindex_names: ["asset_manager", "time"] + multiindex: {"asset_manager": "AM", "time": 0} Returns ------- @@ -139,7 +137,7 @@ def mock_data( assert isinstance(v, str) obs[k] = ( datetime.strptime(v, "%Y-%m-%d") + timedelta(days=i) - ).isoformat() + ).strftime("%Y-%m-%d") else: obs[k] = round(v * s, 2) result.append(obs) @@ -158,7 +156,7 @@ def mock_data( "is_multiindex": True, "multiindex_names": str(multiindex_names), } - # Iterate over the number of items to create and add items to the result + # Iterate over the number of items to create and add them to the result result = [] for i in range(1, size + 1): item[idx_1] = f"{idx_1}_{i}" diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index a77c50560602..47cbf7fa6495 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -417,11 +417,13 @@ def cointegration( ], ), APIEx( + description="Example with mock data.", parameters={ "y_column": "close", "x_column": "open", + "lag": 1, "data": APIEx.mock_data("timeseries"), - } + }, ), ], ) diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 0d5c24a152cb..46951a5e3393 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -107,7 +107,7 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: APIEx( parameters={ "target": "close", - "window": 5, + "window": 2, "data": APIEx.mock_data( "timeseries", sample={"date": "2023-01-01", "close": 0.05}, @@ -177,6 +177,7 @@ def sharpe_ratio( APIEx( parameters={ "target": "close", + "window": 2, "data": APIEx.mock_data( "timeseries", sample={"date": "2023-01-01", "close": 0.05}, @@ -229,7 +230,7 @@ def sortino_ratio( df = basemodel_to_df(data, index=index) series_target = get_target_column(df, target) validate_window(series_target, window) - returns = series_target.pct_change().dropna().rolling(window).sum() + returns = series_target.pct_change().dropna().rolling(window).sum().dropna() downside_deviation = returns.rolling(window).apply( lambda x: (x.values[x.values < 0]).std() / np.sqrt(252) * 100 ) @@ -240,8 +241,9 @@ def sortino_ratio( ) if adjusted: - results = results / np.sqrt(2) - + results = results.applymap( + lambda x: x / np.sqrt(2) if isinstance(x, float) else x + ) results_ = df_to_basemodel(results) return OBBject(results=results_) diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index 54e62f45c2f2..c5c7824ebbb0 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -39,7 +39,7 @@ APIEx( parameters={ "target": "close", - "window": 5, + "window": 2, "data": APIEx.mock_data( "timeseries", sample={"date": "2023-01-01", "close": 0.05}, @@ -103,7 +103,7 @@ def skew( APIEx( parameters={ "target": "close", - "window": 5, + "window": 2, "data": APIEx.mock_data( "timeseries", sample={"date": "2023-01-01", "close": 0.05}, @@ -161,7 +161,7 @@ def variance( APIEx( parameters={ "target": "close", - "window": 5, + "window": 2, "data": APIEx.mock_data( "timeseries", sample={"date": "2023-01-01", "close": 0.05}, @@ -223,7 +223,7 @@ def stdev( APIEx( parameters={ "target": "close", - "window": 5, + "window": 2, "data": APIEx.mock_data( "timeseries", sample={"date": "2023-01-01", "close": 0.05}, @@ -288,7 +288,7 @@ def kurtosis( APIEx( parameters={ "target": "close", - "window": 5, + "window": 2, "data": APIEx.mock_data( "timeseries", sample={"date": "2023-01-01", "close": 0.05}, @@ -368,7 +368,7 @@ def quantile( APIEx( parameters={ "target": "close", - "window": 5, + "window": 2, "data": APIEx.mock_data( "timeseries", sample={"date": "2023-01-01", "close": 0.05}, diff --git a/openbb_platform/extensions/technical/openbb_technical/helpers.py b/openbb_platform/extensions/technical/openbb_technical/helpers.py index 3bf3363665e6..ae1ad19ea6f4 100644 --- a/openbb_platform/extensions/technical/openbb_technical/helpers.py +++ b/openbb_platform/extensions/technical/openbb_technical/helpers.py @@ -1,7 +1,7 @@ """Technical Analysis Helpers.""" import warnings -from typing import Any, Literal, Optional, Tuple +from typing import Any, List, Literal, Optional, Tuple, Union import numpy as np import pandas as pd @@ -9,6 +9,17 @@ _warn = warnings.warn +def validate_data(data: list, length: Union[int, List[int]]) -> None: + """Validate data.""" + if isinstance(length, int): + length = [length] + for l in length: + if l > len(data): + raise ValueError( + f"Data length is less than required by parameters: {max(length)}" + ) + + def parkinson( data: pd.DataFrame, window: int = 30, diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 53d5e8d5efbf..4863d006429b 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -17,7 +17,12 @@ from openbb_core.provider.abstract.data import Data from pydantic import NonNegativeFloat, NonNegativeInt, PositiveFloat, PositiveInt -from . import helpers +from .helpers import ( + calculate_cones, + calculate_fib_levels, + clenow_momentum, + validate_data, +) # TODO: Split this into multiple files router = Router(prefix="") @@ -33,7 +38,7 @@ "atr_data = obb.technical.atr(data=stock_data.results)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def atr( @@ -74,6 +79,7 @@ def atr( OBBject[List[Data]] List of data with the indicator applied. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["high", "low", "close"]) df_atr = pd.DataFrame( @@ -138,7 +144,7 @@ def fib( min_pr, max_pr, lvl_text, - ) = helpers.calculate_fib_levels( + ) = calculate_fib_levels( data=df, close_col=close_column, limit=period, @@ -220,7 +226,7 @@ def obv( "fisher_data = obb.technical.fisher(data=stock_data.results, length=14, signal=1)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def fisher( @@ -253,6 +259,7 @@ def fisher( OBBject[List[Data]] List of data with the indicator applied. """ + validate_data(data, [length, signal]) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["high", "low"]) df_fisher = pd.DataFrame(df_target.ta.fisher(length=length, signal=signal)) @@ -273,7 +280,7 @@ def fisher( "adosc_data = obb.technical.adosc(data=stock_data.results, fast=3, slow=10, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"fast": 2, "slow": 4, "data": APIEx.mock_data("timeseries")}), ], ) def adosc( @@ -309,8 +316,9 @@ def adosc( ------- OBBject[List[Data]] """ + validate_data(data, [fast, slow]) df = basemodel_to_df(data, index=index) - df_target = get_target_columns(df, ["high", "low", "close", "volume", "open"]) + df_target = get_target_columns(df, ["open", "high", "low", "close", "volume"]) df_adosc = pd.DataFrame(df_target.ta.adosc(fast=fast, slow=slow, offset=offset)) output = pd.concat([df, df_adosc], axis=1) @@ -329,7 +337,7 @@ def adosc( "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def bbands( @@ -378,6 +386,7 @@ def bbands( OBBject[List[Data]] The calculated data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() bbands_df = pd.DataFrame( @@ -407,7 +416,7 @@ def bbands( "zlma_data = obb.technical.zlma(data=stock_data.results, target='close', length=50, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def zlma( @@ -444,6 +453,7 @@ def zlma( OBBject[List[Data]] The calculated data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() zlma_df = pd.DataFrame( @@ -471,7 +481,7 @@ def zlma( "aaron_data = obb.technical.aroon(data=stock_data.results, length=25, scalar=100)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def aroon( @@ -510,11 +520,12 @@ def aroon( OBBject[List[Data]] The calculated data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["high", "low", "close"]) - aroon_df = pd.DataFrame(df_target.ta.aroon(length=length, scalar=scalar)).dropna() + df_aroon = pd.DataFrame(df_target.ta.aroon(length=length, scalar=scalar)).dropna() - output = pd.concat([df, aroon_df], axis=1) + output = pd.concat([df, df_aroon], axis=1) results = df_to_basemodel(output.reset_index()) return OBBject(results=results) @@ -530,7 +541,7 @@ def aroon( "sma_data = obb.technical.sma(data=stock_data.results, target='close', length=50, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def sma( @@ -568,6 +579,7 @@ def sma( OBBject[List[Data]] The calculated data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() sma_df = pd.DataFrame( @@ -711,7 +723,15 @@ def vwap( "macd_data = obb.technical.macd(data=stock_data.results, target='close', fast=12, slow=26, signal=9)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx( + description="Example with mock data.", + parameters={ + "fast": 2, + "slow": 3, + "signal": 1, + "data": APIEx.mock_data("timeseries"), + }, + ), ], ) def macd( @@ -753,6 +773,7 @@ def macd( OBBject[List[Data]] The calculated data. """ + validate_data(data, [fast, slow, signal]) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() macd_df = pd.DataFrame( @@ -774,13 +795,12 @@ def macd( methods=["POST"], examples=[ PythonEx( - description="Get the Relative Strength Index (RSI).", + description="Calculate HMA with historical stock data.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", "hma_data = obb.technical.hma(data=stock_data.results, target='close', length=50, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def hma( @@ -815,6 +835,7 @@ def hma( OBBject[List[Data]] The calculated data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() hma_df = pd.DataFrame( @@ -842,7 +863,13 @@ def hma( "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx( + parameters={ + "lower_length": 1, + "upper_length": 3, + "data": APIEx.mock_data("timeseries"), + } + ), ], ) def donchian( @@ -878,6 +905,7 @@ def donchian( OBBject[List[Data]] The calculated data. """ + validate_data(data, [lower_length, upper_length]) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["high", "low"]) donchian_df = pd.DataFrame( @@ -972,7 +1000,7 @@ def ichimoku( "clenow_data = obb.technical.clenow(data=stock_data.results, period=90)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"period": 2, "data": APIEx.mock_data("timeseries")}), ], ) def clenow( @@ -1003,10 +1031,11 @@ def clenow( OBBject[List[Data]] The calculated data. """ + validate_data(data, period) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target) - r2, coef, _ = helpers.clenow_momentum(df_target, period) + r2, coef, _ = clenow_momentum(df_target, period) df_clenow = pd.DataFrame.from_dict( { @@ -1085,7 +1114,7 @@ def ad(data: List[Data], index: str = "date", offset: int = 0) -> OBBject[List[D "adx_data = obb.technical.adx(data=stock_data.results, length=50, scalar=100.0, drift=1)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def adx( @@ -1119,13 +1148,14 @@ def adx( OBBject[List[Data]] The calculated data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["close", "high", "low"]) - adx_df = pd.DataFrame( + df_adx = pd.DataFrame( df_target.ta.adx(length=length, scalar=scalar, drift=drift).dropna() ) - output = pd.concat([df, adx_df], axis=1) + output = pd.concat([df, df_adx], axis=1) results = df_to_basemodel(output.reset_index()) return OBBject(results=results) @@ -1141,7 +1171,7 @@ def adx( "wma_data = obb.technical.wma(data=stock_data.results, target='close', length=50, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def wma( @@ -1176,9 +1206,10 @@ def wma( OBBject[List[Data]] The WMA data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() - wma_df = pd.DataFrame( + df_wma = pd.DataFrame( df_target.ta.wma( length=length, offset=offset, @@ -1187,7 +1218,7 @@ def wma( ).dropna() ) - output = pd.concat([df, wma_df], axis=1) + output = pd.concat([df, df_wma], axis=1) results = df_to_basemodel(output.reset_index()) return OBBject(results=results) @@ -1203,7 +1234,7 @@ def wma( "cci_data = obb.technical.cci(data=stock_data.results, length=14, scalar=0.015)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def cci( @@ -1236,6 +1267,7 @@ def cci( OBBject[List[Data]] The CCI data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["close", "high", "low"]) cci_df = pd.DataFrame(df_target.ta.cci(length=length, scalar=scalar).dropna()) @@ -1256,7 +1288,7 @@ def cci( "rsi_data = obb.technical.rsi(data=stock_data.results, target='close', length=14, scalar=100.0, drift=1)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def rsi( @@ -1295,6 +1327,7 @@ def rsi( OBBject[List[Data]] The RSI data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() rsi_df = pd.DataFrame( @@ -1323,7 +1356,6 @@ def rsi( "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), ], ) def stoch( @@ -1360,6 +1392,7 @@ def stoch( OBBject[List[Data]] The Stochastic Oscillator data. """ + validate_data(data, [fast_k_period, slow_d_period, slow_k_period]) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["close", "high", "low"]) stoch_df = pd.DataFrame( @@ -1386,7 +1419,7 @@ def stoch( "kc_data = obb.technical.kc(data=stock_data.results, length=20, scalar=20, mamode='ema', offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def kc( @@ -1425,6 +1458,7 @@ def kc( OBBject[List[Data]] The Keltner Channels data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["high", "low", "close"]) kc_df = pd.DataFrame( @@ -1451,7 +1485,7 @@ def kc( "cg_data = obb.technical.cg(data=stock_data.results, length=14)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def cg( @@ -1479,6 +1513,7 @@ def cg( OBBject[List[Data]] The COG data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_columns(df, ["high", "low", "close"]) cg_df = pd.DataFrame(df_target.ta.cg(length=length).dropna()) @@ -1580,7 +1615,7 @@ def cones( lower_q, upper_q = upper_q, lower_q df = basemodel_to_df(data, index=index) - df_cones = helpers.calculate_cones( + df_cones = calculate_cones( data=df, lower_q=lower_q, upper_q=upper_q, @@ -1604,7 +1639,7 @@ def cones( "ema_data = obb.technical.ema(data=stock_data.results, target='close', length=50, offset=0)", ], ), - APIEx(parameters={"data": APIEx.mock_data("timeseries")}), + APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), ], ) def ema( @@ -1639,6 +1674,7 @@ def ema( OBBject[List[Data]] The calculated data. """ + validate_data(data, length) df = basemodel_to_df(data, index=index) df_target = get_target_column(df, target).to_frame() ema_df = pd.DataFrame( diff --git a/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py b/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py index 5f22a49be467..15e7e1bb0d01 100644 --- a/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py +++ b/openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py @@ -5,7 +5,6 @@ from datetime import datetime, timedelta from io import StringIO from typing import Any, Dict, List, Literal, Optional -from openbb_core.provider.utils.errors import EmptyDataError import requests from openbb_core.provider.abstract.fetcher import Fetcher @@ -13,6 +12,7 @@ TreasuryPricesData, TreasuryPricesQueryParams, ) +from openbb_core.provider.utils.errors import EmptyDataError from openbb_government_us.utils.helpers import get_random_agent from pandas import Index, read_csv, to_datetime from pydantic import Field From 3a9b813198cf65fcdd09d00a18ab02d7ff194011 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 20:01:54 +0000 Subject: [PATCH 117/133] simplify test --- .../extensions/tests/test_routers.py | 7 +-- .../extensions/tests/utils/router_testers.py | 63 +++---------------- 2 files changed, 11 insertions(+), 59 deletions(-) diff --git a/openbb_platform/extensions/tests/test_routers.py b/openbb_platform/extensions/tests/test_routers.py index 70e79bd33d9f..9a057194bff6 100644 --- a/openbb_platform/extensions/tests/test_routers.py +++ b/openbb_platform/extensions/tests/test_routers.py @@ -22,13 +22,10 @@ def test_router_model_functions_signature() -> None: def test_router_examples_rules() -> None: """Test if the router examples follow certain rules. - General rules: + Rules: - All endpoints should have examples. - - If any endpoint is excluded from the schema it only needs to contain a Python example. - - POST method examples should have both API and Python examples, unless they are excluded from the schema. - - API examples: - At least one example using all required parameters. + - If any endpoint is excluded from the schema it only needs a Python example. """ invalid_examples = check_router_command_examples() assert not invalid_examples, "\n".join(sorted(invalid_examples)) diff --git a/openbb_platform/extensions/tests/utils/router_testers.py b/openbb_platform/extensions/tests/utils/router_testers.py index 39b1c4170f47..918b9e7850d6 100644 --- a/openbb_platform/extensions/tests/utils/router_testers.py +++ b/openbb_platform/extensions/tests/utils/router_testers.py @@ -64,18 +64,10 @@ def check_router_model_functions_signature() -> List[str]: return missing_args + missing_return_type -def check_general_example_violations( +def check_general( keywords: Dict, examples: List, router_name: str, function: Any ) -> List[str]: - """Check for general violations in the router command examples. - - Criteria - -------- - - All endpoints should have examples. - - If any endpoint is excluded from the schema it only needs to contain a Python example. - - POST method examples should have both API and Python examples, - unless they are excluded from the schema. - """ + """Check for general violations in the router command examples.""" general_violation: List[str] = [] # Check if the endpoint has examples @@ -84,54 +76,17 @@ def check_general_example_violations( f"'{router_name}' > '{function.__name__}': missing examples" ) return general_violation - # Check if a POST method has both API and Python examples - if ( - "POST" in keywords.get("methods", "") - and keywords.get("include_in_schema", "") != "False" - ): - if "APIEx" not in examples: - general_violation.append( - f"'{router_name}' > '{function.__name__}': missing API example" - ) - if "PythonEx" not in examples: - general_violation.append( - f"'{router_name}' > '{function.__name__}': missing Python example" - ) - # Check if a POST endpoint excluded from the schema has a Python example - if ( - (keywords.get("include_in_schema", "") == "False") - and ("POST" in keywords.get("methods", "")) - and ("PythonEx" not in examples) - ): - general_violation.append( - f"'{router_name}' > '{function.__name__}': is excluded from the" - "api schema but doesn't have a Python example." - ) - if "APIEx" in examples: - general_violation.append( - f"'{router_name}' > '{function.__name__}': endpoint excluded from the" - "api schema but has an API example." - ) return general_violation -def check_api_example_violations( +def check_api( examples: str, router_name: str, model: Optional[str], function: Any ) -> List[str]: - """Check for API example violations in the router command examples. - - Criteria - -------- - - When using models, at least one example using all required standard parameters. - - It cannot use any provider specific parameters here. - - It should not specify the provider field. - """ + """Check for API examples.""" + # Check if the endpoint has at least 1 example with all required fields api_example_violation: List[str] = [] - parsed_examples = parse_example_string(examples) - - # Check model endpoint example criteria if model and "APIEx" in parsed_examples: required_fields = get_required_fields(model.strip("'")) for api_example in parsed_examples["APIEx"]: @@ -172,14 +127,14 @@ def check_router_command_examples() -> List[str]: if decorator_details["decorator"] == "router.command": keywords = decorator_details["keywords"] examples = keywords.get("examples", []) - ### General checks ### - general_violation += check_general_example_violations( + # General checks + general_violation += check_general( keywords, examples, router_name, function ) if examples: - ### API example checks ### + # API example checks model = keywords.get("model", None) - api_example_violation += check_api_example_violations( + api_example_violation += check_api( examples, router_name, model, function ) From 3130be88420bf12240f071cce8c3dd12fdfb7afe Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 20:04:14 +0000 Subject: [PATCH 118/133] rebuild --- openbb_platform/openbb/package/index.py | 1 - .../openbb/package/regulators_sec.py | 31 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index e7db0d7ff8ff..12ca514ea490 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -146,7 +146,6 @@ def constituents( Examples -------- >>> from openbb import obb - >>> obb.index.constituents(symbol='dowjones') >>> obb.index.constituents(symbol='dowjones', provider='fmp') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index 4c64ca89a515..da1772db78be 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -274,23 +274,23 @@ def schema_files( >>> from openbb import obb >>> obb.regulators.sec.schema_files() >>> # Get a list of schema files. - >>> data = obb.regulators.sec.schema_files() + >>> data = obb.regulators.sec.schema_files().results >>> data.files[0] - >>> https://xbrl.fasb.org/us-gaap/ - >>> #### The directory structure can be navigated by constructing a URL from the 'results' list. #### + >>> 'https://xbrl.fasb.org/us-gaap/' + >>> # The directory structure can be navigated by constructing a URL from the 'results' list. >>> url = data.files[0]+data.files[-1] - >>> #### The URL base will always be the 0 position in the list, feed the URL back in as a parameter. #### + >>> # The URL base will always be the 0 position in the list, feed the URL back in as a parameter. >>> obb.regulators.sec.schema_files(url=url).results.files - >>> ['https://xbrl.fasb.org/us-gaap/2024/' - >>> 'USGAAP2024FileList.xml' - >>> 'dis/' - >>> 'dqcrules/' - >>> 'ebp/' - >>> 'elts/' - >>> 'entire/' - >>> 'meta/' - >>> 'stm/' - >>> 'us-gaap-2024.zip'] + >>> ['https://xbrl.fasb.org/us-gaap/2024/' + >>> 'USGAAP2024FileList.xml' + >>> 'dis/' + >>> 'dqcrules/' + >>> 'ebp/' + >>> 'elts/' + >>> 'entire/' + >>> 'meta/' + >>> 'stm/' + >>> 'us-gaap-2024.zip'] """ # noqa: E501 return self._run( @@ -390,7 +390,7 @@ def sic_search( @validate def symbol_map( self, - query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", + query: Annotated[str, OpenBBCustomParameter(description="Search query.")], use_cache: Annotated[ Optional[bool], OpenBBCustomParameter( @@ -435,7 +435,6 @@ def symbol_map( Examples -------- >>> from openbb import obb - >>> obb.regulators.sec.symbol_map() >>> obb.regulators.sec.symbol_map(query='0000789019') """ # noqa: E501 From 68547647ebb4085f9ef475fca45db571051a4a6a Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 20:09:05 +0000 Subject: [PATCH 119/133] test doc --- openbb_platform/extensions/tests/test_routers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openbb_platform/extensions/tests/test_routers.py b/openbb_platform/extensions/tests/test_routers.py index 9a057194bff6..863979dc4ffb 100644 --- a/openbb_platform/extensions/tests/test_routers.py +++ b/openbb_platform/extensions/tests/test_routers.py @@ -25,7 +25,6 @@ def test_router_examples_rules() -> None: Rules: - All endpoints should have examples. - At least one example using all required parameters. - - If any endpoint is excluded from the schema it only needs a Python example. """ invalid_examples = check_router_command_examples() assert not invalid_examples, "\n".join(sorted(invalid_examples)) From a0a74be7b3d0350e1f5627837a481eb398712dbd Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 22:14:20 +0000 Subject: [PATCH 120/133] add provider to some ex --- .../openbb_commodity/commodity_router.py | 3 +- .../crypto/openbb_crypto/crypto_router.py | 4 +- .../openbb_crypto/price/price_router.py | 6 +- .../openbb_currency/currency_router.py | 10 +- .../futures/futures_router.py | 2 +- .../options/options_router.py | 2 +- .../economy/openbb_economy/economy_router.py | 57 ++++--- .../economy/openbb_economy/gdp/gdp_router.py | 14 +- .../openbb_equity/calendar/calendar_router.py | 28 +++- .../openbb_equity/compare/compare_router.py | 18 +- .../openbb_equity/darkpool/darkpool_router.py | 4 +- .../discovery/discovery_router.py | 42 +++-- .../equity/openbb_equity/equity_router.py | 24 ++- .../estimates/estimates_router.py | 7 +- .../fundamental/fundamental_router.py | 157 +++++++++++++----- 15 files changed, 271 insertions(+), 107 deletions(-) diff --git a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py index 4f74f3fb5495..ebf5401c28f7 100644 --- a/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py +++ b/openbb_platform/extensions/commodity/openbb_commodity/commodity_router.py @@ -19,7 +19,7 @@ @router.command( model="LbmaFixing", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "nasdaq"}), APIEx( description="Get the daily LBMA fixing prices for silver in 2023.", parameters={ @@ -28,6 +28,7 @@ "end_date": "2023-12-31", "transform": "rdiff", "collapse": "monthly", + "provider": "nasdaq", }, ), ], diff --git a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py index 145d2c4d9ec0..1f92af05c972 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/crypto_router.py @@ -21,8 +21,8 @@ @router.command( model="CryptoSearch", examples=[ - APIEx(parameters={}), - APIEx(parameters={"query": "BTCUSD"}), + APIEx(parameters={"provider": "fmp"}), + APIEx(parameters={"query": "BTCUSD", "provider": "fmp"}), ], ) async def search( diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index 27130dfbf52b..24aa03763753 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -19,12 +19,13 @@ @router.command( model="CryptoHistorical", examples=[ - APIEx(parameters={"symbol": "BTCUSD"}), + APIEx(parameters={"symbol": "BTCUSD", "provider": "fmp"}), APIEx( parameters={ "symbol": "BTCUSD", "start_date": "2024-01-01", "end_date": "2024-01-31", + "provider": "fmp", }, ), APIEx( @@ -32,16 +33,17 @@ "symbol": "BTCUSD,ETHUSD", "start_date": "2024-01-01", "end_date": "2024-01-31", + "provider": "polygon", }, ), APIEx( description="Get monthly historical prices from Yahoo Finance for Ethereum.", parameters={ "symbol": "ETH-USD", - "provider": "yfinance", "interval": "1mo", "start_date": "2024-01-01", "end_date": "2024-12-31", + "provider": "yfinance", }, ), ], diff --git a/openbb_platform/extensions/currency/openbb_currency/currency_router.py b/openbb_platform/extensions/currency/openbb_currency/currency_router.py index ae43d65b9dcc..669b463869af 100644 --- a/openbb_platform/extensions/currency/openbb_currency/currency_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/currency_router.py @@ -21,10 +21,10 @@ @router.command( model="CurrencyPairs", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "intrinio"}), APIEx( - description="Search for 'EURUSD' currency pair using 'polygon' as provider.", - parameters={"provider": "polygon", "symbol": "EURUSD"}, + description="Search for 'EURUSD' currency pair using 'intrinio' as provider.", + parameters={"provider": "intrinio", "symbol": "EURUSD"}, ), APIEx( description="Search for actively traded currency pairs on the queried date using 'polygon' as provider.", @@ -57,7 +57,7 @@ async def search( @router.command( model="CurrencyReferenceRates", - examples=[APIEx(parameters={})], + examples=[APIEx(parameters={"provider": "ecb"})], ) async def reference_rates( cc: CommandContext, @@ -81,7 +81,7 @@ async def reference_rates( @router.command( model="CurrencySnapshots", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "fmp"}), APIEx( description="Get exchange rates from USD and XAU to EUR, JPY, and GBP using 'fmp' as provider.", parameters={ diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index d5549a991db3..a551cc2f28a7 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -18,7 +18,7 @@ @router.command( model="FuturesHistorical", examples=[ - APIEx(parameters={"symbol": "ES"}), + APIEx(parameters={"symbol": "ES", "provider": "yfinance"}), APIEx( description="Enter multiple symbols.", parameters={"symbol": "ES,NQ", "provider": "yfinance"}, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index fb68ae4ab47f..153b20700b92 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -42,7 +42,7 @@ async def chains( APIEx(parameters={}), APIEx( description="Use the 'symbol' parameter to get the most recent activity for a specific symbol.", - parameters={"symbol": "TSLA"}, + parameters={"symbol": "TSLA", "provider": "intrinio"}, ), ], ) diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 88b4d8318190..137efc0724ac 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -23,7 +23,7 @@ model="EconomicCalendar", examples=[ APIEx( - parameters={}, + parameters={"provider": "fmp"}, description="By default, the calendar will be forward-looking.", ), APIEx( @@ -52,12 +52,13 @@ async def calendar( @router.command( model="ConsumerPriceIndex", examples=[ - APIEx(parameters={"country": "japan,china,turkey"}), + APIEx(parameters={"country": "japan,china,turkey", "provider": "fred"}), APIEx( description="Use the `units` parameter to define the reference period for the change in values.", parameters={ "country": "united_states,united_kingdom", "units": "growth_previous", + "provider": "fred", }, ), ], @@ -74,7 +75,7 @@ async def cpi( @router.command( model="RiskPremium", - examples=[APIEx(parameters={})], + examples=[APIEx(parameters={"provider": "fmp"})], ) async def risk_premium( cc: CommandContext, @@ -89,8 +90,8 @@ async def risk_premium( @router.command( model="BalanceOfPayments", examples=[ - APIEx(parameters={}), - APIEx(parameters={"report_type": "summary"}), + APIEx(parameters={"provider": "ecb"}), + APIEx(parameters={"report_type": "summary", "provider": "ecb"}), APIEx( description="The `country` parameter will override the `report_type`.", parameters={"country": "united_states", "provider": "ecb"}, @@ -107,7 +108,7 @@ async def balance_of_payments( return await OBBject.from_query(Query(**locals())) -@router.command(model="FredSearch", examples=[APIEx(parameters={})]) +@router.command(model="FredSearch", examples=[APIEx(parameters={"provider": "fred"})]) async def fred_search( cc: CommandContext, provider_choices: ProviderChoices, @@ -125,14 +126,14 @@ async def fred_search( @router.command( model="FredSeries", examples=[ - APIEx(parameters={"symbol": "NFCI"}), + APIEx(parameters={"symbol": "NFCI", "provider": "fred"}), APIEx( description="Multiple series can be passed in as a list.", - parameters={"symbol": "NFCI,STLFSI4"}, + parameters={"symbol": "NFCI,STLFSI4", "provider": "fred"}, ), APIEx( description="Use the `transform` parameter to transform the data as change, log, or percent change.", - parameters={"symbol": "CBBTCUSD", "transform": "pc1"}, + parameters={"symbol": "CBBTCUSD", "transform": "pc1", "provider": "fred"}, ), ], ) @@ -148,7 +149,10 @@ async def fred_series( @router.command( model="MoneyMeasures", - examples=[APIEx(parameters={}), APIEx(parameters={"adjusted": False})], + examples=[ + APIEx(parameters={"provider": "federal_reserve"}), + APIEx(parameters={"adjusted": False, "provider": "federal_reserve"}), + ], ) async def money_measures( cc: CommandContext, @@ -163,11 +167,18 @@ async def money_measures( @router.command( model="Unemployment", examples=[ - APIEx(parameters={}), - APIEx(parameters={"country": "all", "frequency": "quarterly"}), + APIEx(parameters={"provider": "oecd"}), + APIEx( + parameters={"country": "all", "frequency": "quarterly", "provider": "oecd"} + ), APIEx( description="Demographics for the statistics are selected with the `age` and `sex` parameters.", - parameters={"country": "all", "frequency": "quarterly", "age": "25-54"}, + parameters={ + "country": "all", + "frequency": "quarterly", + "age": "25-54", + "provider": "oecd", + }, ), ], ) @@ -183,7 +194,10 @@ async def unemployment( @router.command( model="CLI", - examples=[APIEx(parameters={}), APIEx(parameters={"country": "all"})], + examples=[ + APIEx(parameters={"provider": "oecd"}), + APIEx(parameters={"country": "all", "provider": "oecd"}), + ], ) async def composite_leading_indicator( cc: CommandContext, @@ -201,8 +215,10 @@ async def composite_leading_indicator( @router.command( model="STIR", examples=[ - APIEx(parameters={}), - APIEx(parameters={"country": "all", "frequency": "quarterly"}), + APIEx(parameters={"provider": "oecd"}), + APIEx( + parameters={"country": "all", "frequency": "quarterly", "provider": "oecd"} + ), ], ) async def short_term_interest_rate( @@ -224,8 +240,10 @@ async def short_term_interest_rate( @router.command( model="LTIR", examples=[ - APIEx(parameters={}), - APIEx(parameters={"country": "all", "frequency": "quarterly"}), + APIEx(parameters={"provider": "oecd"}), + APIEx( + parameters={"country": "all", "frequency": "quarterly", "provider": "oecd"} + ), ], ) async def long_term_interest_rate( @@ -251,7 +269,7 @@ async def long_term_interest_rate( model="FredRegional", examples=[ APIEx( - parameters={"symbol": "NYICLAIMS"}, + parameters={"symbol": "NYICLAIMS", "provider": "fred"}, ), APIEx( description="With a date, time series data is returned.", @@ -260,6 +278,7 @@ async def long_term_interest_rate( "start_date": "2021-01-01", "end_date": "2021-12-31", "limit": 10, + "provider": "fred", }, ), ], diff --git a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py index d9cb95a273d4..024fc8e2ff86 100644 --- a/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/gdp/gdp_router.py @@ -19,8 +19,8 @@ @router.command( model="GdpForecast", examples=[ - APIEx(parameters={}), - APIEx(parameters={"period": "annual", "type": "real"}), + APIEx(parameters={"provider": "oecd"}), + APIEx(parameters={"period": "annual", "type": "real", "provider": "oecd"}), ], ) async def forecast( @@ -35,7 +35,10 @@ async def forecast( @router.command( model="GdpNominal", - examples=[APIEx(parameters={}), APIEx(parameters={"units": "usd"})], + examples=[ + APIEx(parameters={"provider": "oecd"}), + APIEx(parameters={"units": "usd", "provider": "oecd"}), + ], ) async def nominal( cc: CommandContext, @@ -49,7 +52,10 @@ async def nominal( @router.command( model="GdpReal", - examples=[APIEx(parameters={}), APIEx(parameters={"units": "yoy"})], + examples=[ + APIEx(parameters={"provider": "oecd"}), + APIEx(parameters={"units": "yoy", "provider": "oecd"}), + ], ) async def real( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py index dac46203256c..7c9395dde3c6 100644 --- a/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/calendar/calendar_router.py @@ -19,12 +19,18 @@ @router.command( model="CalendarIpo", examples=[ - APIEx(parameters={}), - APIEx(parameters={"limit": 100}), - APIEx(description="Get all IPOs available.", parameters={}), + APIEx(parameters={"provider": "intrinio"}), + APIEx(parameters={"limit": 100, "provider": "nasdaq"}), + APIEx( + description="Get all IPOs available.", parameters={"provider": "intrinio"} + ), APIEx( description="Get IPOs for specific dates.", - parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, + parameters={ + "start_date": "2024-02-01", + "end_date": "2024-02-07", + "provider": "nasdaq", + }, ), ], ) @@ -41,12 +47,13 @@ async def ipo( @router.command( model="CalendarDividend", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "fmp"}), APIEx( description="Get dividend calendar for specific dates.", parameters={ "start_date": "2024-02-01", "end_date": "2024-02-07", + "provider": "nasdaq", }, ), ], @@ -64,12 +71,13 @@ async def dividend( @router.command( model="CalendarSplits", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "fmp"}), APIEx( description="Get stock splits calendar for specific dates.", parameters={ "start_date": "2024-02-01", "end_date": "2024-02-07", + "provider": "fmp", }, ), ], @@ -87,10 +95,14 @@ async def splits( @router.command( model="CalendarEarnings", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "fmp"}), APIEx( description="Get earnings calendar for specific dates.", - parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, + parameters={ + "start_date": "2024-02-01", + "end_date": "2024-02-07", + "provider": "fmp", + }, ), ], ) diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py index 76262f3e72d3..2f585055e3fb 100644 --- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py @@ -17,7 +17,7 @@ @router.command( model="EquityPeers", - examples=[APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def peers( cc: CommandContext, @@ -35,18 +35,26 @@ async def peers( @router.command( model="CompareGroups", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "finviz"}), APIEx( description="Group by sector and analyze valuation.", - parameters={"group": "sector", "metric": "valuation"}, + parameters={"group": "sector", "metric": "valuation", "provider": "finviz"}, ), APIEx( description="Group by industry and analyze performance.", - parameters={"group": "industry", "metric": "performance"}, + parameters={ + "group": "industry", + "metric": "performance", + "provider": "finviz", + }, ), APIEx( description="Group by country and analyze valuation.", - parameters={"group": "country", "metric": "valuation"}, + parameters={ + "group": "country", + "metric": "valuation", + "provider": "finviz", + }, ), ], ) diff --git a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py index 2a4f54478fd5..67307cbeec0e 100644 --- a/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/darkpool/darkpool_router.py @@ -19,10 +19,10 @@ @router.command( model="OTCAggregate", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "finra"}), APIEx( description="Get OTC data for a symbol", - parameters={"symbol": "AAPL"}, + parameters={"symbol": "AAPL", "provider": "finra"}, ), ], ) diff --git a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py index 9ae09e12b1c4..86ccde2857d2 100644 --- a/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/discovery/discovery_router.py @@ -17,7 +17,10 @@ @router.command( model="EquityGainers", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[ + APIEx(parameters={"provider": "yfinance"}), + APIEx(parameters={"sort": "desc", "provider": "yfinance"}), + ], ) async def gainers( cc: CommandContext, @@ -31,7 +34,10 @@ async def gainers( @router.command( model="EquityLosers", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[ + APIEx(parameters={"provider": "yfinance"}), + APIEx(parameters={"sort": "desc", "provider": "yfinance"}), + ], ) async def losers( cc: CommandContext, @@ -45,7 +51,10 @@ async def losers( @router.command( model="EquityActive", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[ + APIEx(parameters={"provider": "yfinance"}), + APIEx(parameters={"sort": "desc", "provider": "yfinance"}), + ], ) async def active( cc: CommandContext, @@ -59,7 +68,10 @@ async def active( @router.command( model="EquityUndervaluedLargeCaps", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[ + APIEx(parameters={"provider": "yfinance"}), + APIEx(parameters={"sort": "desc", "provider": "yfinance"}), + ], ) async def undervalued_large_caps( cc: CommandContext, @@ -73,7 +85,10 @@ async def undervalued_large_caps( @router.command( model="EquityUndervaluedGrowth", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[ + APIEx(parameters={"provider": "yfinance"}), + APIEx(parameters={"sort": "desc", "provider": "yfinance"}), + ], ) async def undervalued_growth( cc: CommandContext, @@ -87,7 +102,10 @@ async def undervalued_growth( @router.command( model="EquityAggressiveSmallCaps", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[ + APIEx(parameters={"provider": "yfinance"}), + APIEx(parameters={"sort": "desc", "provider": "yfinance"}), + ], ) async def aggressive_small_caps( cc: CommandContext, @@ -101,7 +119,10 @@ async def aggressive_small_caps( @router.command( model="GrowthTechEquities", - examples=[APIEx(parameters={}), APIEx(parameters={"sort": "desc"})], + examples=[ + APIEx(parameters={"provider": "yfinance"}), + APIEx(parameters={"sort": "desc", "provider": "yfinance"}), + ], ) async def growth_tech( cc: CommandContext, @@ -115,7 +136,7 @@ async def growth_tech( @router.command( model="TopRetail", - examples=[APIEx(parameters={})], + examples=[APIEx(parameters={"provider": "nasdaq"})], ) async def top_retail( cc: CommandContext, @@ -132,7 +153,7 @@ async def top_retail( @router.command( model="UpcomingReleaseDays", - examples=[APIEx(parameters={})], + examples=[APIEx(parameters={"provider": "seeking_alpha"})], ) async def upcoming_release_days( cc: CommandContext, @@ -147,13 +168,14 @@ async def upcoming_release_days( @router.command( model="DiscoveryFilings", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "fmp"}), APIEx( description="Get filings for the year 2023, limited to 100 results", parameters={ "start_date": "2023-01-01", "end_date": "2023-12-31", "limit": 100, + "provider": "fmp", }, ), ], diff --git a/openbb_platform/extensions/equity/openbb_equity/equity_router.py b/openbb_platform/extensions/equity/openbb_equity/equity_router.py index 766ee2f8a9a2..9da54b7678c8 100644 --- a/openbb_platform/extensions/equity/openbb_equity/equity_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/equity_router.py @@ -38,8 +38,15 @@ @router.command( model="EquitySearch", examples=[ - APIEx(parameters={}), - APIEx(parameters={"query": "AAPL", "is_symbol": False, "use_cache": True}), + APIEx(parameters={"provider": "intrinio"}), + APIEx( + parameters={ + "query": "AAPL", + "is_symbol": False, + "use_cache": True, + "provider": "nasdaq", + } + ), ], ) async def search( @@ -52,7 +59,9 @@ async def search( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityScreener", examples=[APIEx(parameters={})]) +@router.command( + model="EquityScreener", examples=[APIEx(parameters={"provider": "fmp"})] +) async def screener( cc: CommandContext, provider_choices: ProviderChoices, @@ -64,7 +73,10 @@ async def screener( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityInfo", examples=[APIEx(parameters={"symbol": "AAPL"})]) +@router.command( + model="EquityInfo", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], +) async def profile( cc: CommandContext, provider_choices: ProviderChoices, @@ -75,7 +87,9 @@ async def profile( return await OBBject.from_query(Query(**locals())) -@router.command(model="MarketSnapshots", examples=[APIEx(parameters={})]) +@router.command( + model="MarketSnapshots", examples=[APIEx(parameters={"provider": "fmp"})] +) async def market_snapshots( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py index 0aa16d91d5b7..07c328c334c8 100644 --- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py @@ -19,7 +19,7 @@ @router.command( model="PriceTarget", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "benzinga"}), APIEx( description="Get price targets for Microsoft using 'benzinga' as provider.", parameters={ @@ -46,7 +46,6 @@ async def price_target( @router.command( model="AnalystEstimates", examples=[ - APIEx(parameters={"symbol": "AAPL"}), APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), ], ) @@ -63,7 +62,7 @@ async def historical( @router.command( model="PriceTargetConsensus", examples=[ - APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), APIEx(parameters={"symbol": "AAPL,MSFT", "provider": "yfinance"}), ], ) @@ -80,7 +79,7 @@ async def consensus( @router.command( model="AnalystSearch", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "benzinga"}), APIEx(parameters={"firm_name": "Wedbush", "provider": "benzinga"}), ], ) diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index 265e6bad0eaf..3b205c1264c1 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -18,7 +18,7 @@ @router.command( model="EquityValuationMultiples", - examples=[APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def multiples( cc: CommandContext, @@ -33,8 +33,15 @@ async def multiples( @router.command( model="BalanceSheet", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx( + parameters={ + "symbol": "AAPL", + "period": "annual", + "limit": 5, + "provider": "intrinio", + } + ), ], ) async def balance( @@ -50,8 +57,8 @@ async def balance( @router.command( model="BalanceSheetGrowth", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "limit": 10}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx(parameters={"symbol": "AAPL", "limit": 10, "provider": "intrinio"}), ], ) async def balance_growth( @@ -67,8 +74,15 @@ async def balance_growth( @router.command( model="CashFlowStatement", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx( + parameters={ + "symbol": "AAPL", + "period": "annual", + "limit": 5, + "provider": "intrinio", + } + ), ], ) async def cash( @@ -84,7 +98,7 @@ async def cash( @router.command( model="ReportedFinancials", examples=[ - APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "provider": "intrinio"}), APIEx( description="Get AAPL balance sheet with a limit of 10 items.", parameters={ @@ -92,15 +106,24 @@ async def cash( "period": "annual", "statement_type": "balance", "limit": 10, + "provider": "intrinio", }, ), APIEx( description="Get reported income statement", - parameters={"symbol": "AAPL", "statement_type": "income"}, + parameters={ + "symbol": "AAPL", + "statement_type": "income", + "provider": "intrinio", + }, ), APIEx( description="Get reported cash flow statement", - parameters={"symbol": "AAPL", "statement_type": "cash"}, + parameters={ + "symbol": "AAPL", + "statement_type": "cash", + "provider": "intrinio", + }, ), ], ) @@ -117,8 +140,8 @@ async def reported_financials( @router.command( model="CashFlowStatementGrowth", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "limit": 10}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx(parameters={"symbol": "AAPL", "limit": 10, "provider": "intrinio"}), ], ) async def cash_growth( @@ -132,7 +155,8 @@ async def cash_growth( @router.command( - model="HistoricalDividends", examples=[APIEx(parameters={"symbol": "AAPL"})] + model="HistoricalDividends", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "intrinio"})], ) async def dividends( cc: CommandContext, @@ -144,7 +168,10 @@ async def dividends( return await OBBject.from_query(Query(**locals())) -@router.command(model="HistoricalEps", examples=[APIEx(parameters={"symbol": "AAPL"})]) +@router.command( + model="HistoricalEps", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], +) async def historical_eps( cc: CommandContext, provider_choices: ProviderChoices, @@ -156,7 +183,8 @@ async def historical_eps( @router.command( - model="HistoricalEmployees", examples=[APIEx(parameters={"symbol": "AAPL"})] + model="HistoricalEmployees", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def employee_count( cc: CommandContext, @@ -170,7 +198,7 @@ async def employee_count( @router.command( model="SearchAttributes", - examples=[APIEx(parameters={"query": "ebitda"})], + examples=[APIEx(parameters={"query": "ebitda", "provider": "intrinio"})], ) async def search_attributes( cc: CommandContext, @@ -184,7 +212,9 @@ async def search_attributes( @router.command( model="LatestAttributes", - examples=[APIEx(parameters={"symbol": "AAPL", "tag": "ceo"})], + examples=[ + APIEx(parameters={"symbol": "AAPL", "tag": "ceo", "provider": "intrinio"}) + ], ) async def latest_attributes( cc: CommandContext, @@ -198,7 +228,9 @@ async def latest_attributes( @router.command( model="HistoricalAttributes", - examples=[APIEx(parameters={"symbol": "AAPL", "tag": "ebitda"})], + examples=[ + APIEx(parameters={"symbol": "AAPL", "tag": "ebitda", "provider": "intrinio"}) + ], ) async def historical_attributes( cc: CommandContext, @@ -213,8 +245,15 @@ async def historical_attributes( @router.command( model="IncomeStatement", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 5}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx( + parameters={ + "symbol": "AAPL", + "period": "annual", + "limit": 5, + "provider": "intrinio", + } + ), ], ) async def income( @@ -230,8 +269,15 @@ async def income( @router.command( model="IncomeStatementGrowth", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "limit": 10, "period": "annual"}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx( + parameters={ + "symbol": "AAPL", + "limit": 10, + "period": "annual", + "provider": "intrinio", + } + ), ], ) async def income_growth( @@ -247,8 +293,15 @@ async def income_growth( @router.command( model="KeyMetrics", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 100}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx( + parameters={ + "symbol": "AAPL", + "period": "annual", + "limit": 100, + "provider": "intrinio", + } + ), ], ) async def metrics( @@ -261,7 +314,10 @@ async def metrics( return await OBBject.from_query(Query(**locals())) -@router.command(model="KeyExecutives", examples=[APIEx(parameters={"symbol": "AAPL"})]) +@router.command( + model="KeyExecutives", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], +) async def management( cc: CommandContext, provider_choices: ProviderChoices, @@ -273,7 +329,8 @@ async def management( @router.command( - model="ExecutiveCompensation", examples=[APIEx(parameters={"symbol": "AAPL"})] + model="ExecutiveCompensation", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def management_compensation( cc: CommandContext, @@ -293,7 +350,7 @@ async def management_compensation( since=(4, 1), expected_removal=(4, 3), ), - examples=[APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def overview( cc: CommandContext, @@ -308,8 +365,15 @@ async def overview( @router.command( model="FinancialRatios", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "period": "annual", "limit": 12}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx( + parameters={ + "symbol": "AAPL", + "period": "annual", + "limit": 12, + "provider": "intrinio", + } + ), ], ) async def ratios( @@ -325,8 +389,15 @@ async def ratios( @router.command( model="RevenueGeographic", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx( + parameters={ + "symbol": "AAPL", + "period": "annual", + "structure": "flat", + "provider": "fmp", + } + ), ], ) async def revenue_per_geography( @@ -342,8 +413,15 @@ async def revenue_per_geography( @router.command( model="RevenueBusinessLine", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "period": "annual", "structure": "flat"}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx( + parameters={ + "symbol": "AAPL", + "period": "annual", + "structure": "flat", + "provider": "fmp", + } + ), ], ) async def revenue_per_segment( @@ -358,7 +436,10 @@ async def revenue_per_segment( @router.command( model="CompanyFilings", - examples=[APIEx(parameters={}), APIEx(parameters={"limit": 100})], + examples=[ + APIEx(parameters={"provider": "fmp"}), + APIEx(parameters={"limit": 100, "provider": "intrinio"}), + ], ) async def filings( cc: CommandContext, @@ -376,7 +457,7 @@ async def filings( @router.command( - model="HistoricalSplits", examples=[APIEx(parameters={"symbol": "AAPL"})] + model="HistoricalSplits", examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})] ) async def historical_splits( cc: CommandContext, @@ -390,7 +471,7 @@ async def historical_splits( @router.command( model="EarningsCallTranscript", - examples=[APIEx(parameters={"symbol": "AAPL", "year": 2020})], + examples=[APIEx(parameters={"symbol": "AAPL", "year": 2020, "provider": "fmp"})], ) async def transcript( cc: CommandContext, @@ -405,8 +486,8 @@ async def transcript( @router.command( model="TrailingDividendYield", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "limit": 252}), + APIEx(parameters={"symbol": "AAPL", "provider": "tiingo"}), + APIEx(parameters={"symbol": "AAPL", "limit": 252, "provider": "tiingo"}), ], ) async def trailing_dividend_yield( From 5d48ee3af23862bdeac6aed424db4b699a781b89 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 22:38:54 +0000 Subject: [PATCH 121/133] ^ --- .../fundamental/fundamental_router.py | 3 +- .../ownership/ownership_router.py | 17 +- .../openbb_equity/price/price_router.py | 17 +- .../openbb_equity/shorts/shorts_router.py | 6 +- .../openbb_etf/discovery/discovery_router.py | 3 - .../extensions/etf/openbb_etf/etf_router.py | 17 +- .../corporate/corporate_router.py | 27 +- .../openbb_fixedincome/fixedincome_router.py | 5 +- .../government/government_router.py | 14 +- .../openbb_fixedincome/rate/rate_router.py | 36 +- .../spreads/spreads_router.py | 15 +- .../index/openbb_index/index_router.py | 15 +- .../openbb/assets/extension_map.json | 17 +- openbb_platform/openbb/assets/module_map.json | 93 ++- .../openbb/package/__extensions__.py | 47 ++ openbb_platform/openbb/package/crypto.py | 4 +- openbb_platform/openbb/package/currency.py | 126 ++++ .../openbb/package/derivatives_options.py | 28 +- openbb_platform/openbb/package/economy.py | 294 ++++++++- openbb_platform/openbb/package/equity.py | 120 +++- .../openbb/package/equity_calendar.py | 69 +- .../openbb/package/equity_compare.py | 127 ++++ .../openbb/package/equity_discovery.py | 183 +++++- .../openbb/package/equity_estimates.py | 46 +- .../openbb/package/equity_fundamental.py | 176 ++++-- .../openbb/package/equity_ownership.py | 26 +- .../openbb/package/equity_price.py | 255 ++++++-- .../openbb/package/equity_shorts.py | 158 +++++ openbb_platform/openbb/package/etf.py | 353 ++++++++--- .../openbb/package/fixedincome_corporate.py | 179 ++++++ .../openbb/package/fixedincome_government.py | 558 ++++++++++++++++ openbb_platform/openbb/package/index.py | 593 ++++++++++++++++-- openbb_platform/openbb/package/news.py | 49 +- openbb_platform/openbb/package/regulators.py | 10 + 34 files changed, 3271 insertions(+), 415 deletions(-) diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index 3b205c1264c1..de572174d07a 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -457,7 +457,8 @@ async def filings( @router.command( - model="HistoricalSplits", examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})] + model="HistoricalSplits", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def historical_splits( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py index 552fd3f3b95b..8095164823e0 100644 --- a/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/ownership/ownership_router.py @@ -19,8 +19,8 @@ @router.command( model="EquityOwnership", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "page": 0}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx(parameters={"symbol": "AAPL", "page": 0, "provider": "fmp"}), ], ) async def major_holders( @@ -35,7 +35,7 @@ async def major_holders( @router.command( model="InstitutionalOwnership", - examples=[APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def institutional( cc: CommandContext, @@ -50,8 +50,8 @@ async def institutional( @router.command( model="InsiderTrading", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "limit": 500}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx(parameters={"symbol": "AAPL", "limit": 500, "provider": "intrinio"}), ], ) async def insider_trading( @@ -65,7 +65,8 @@ async def insider_trading( @router.command( - model="ShareStatistics", examples=[APIEx(parameters={"symbol": "AAPL"})] + model="ShareStatistics", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def share_statistics( cc: CommandContext, @@ -80,10 +81,10 @@ async def share_statistics( @router.command( model="Form13FHR", examples=[ - APIEx(parameters={"symbol": "NVDA"}), + APIEx(parameters={"symbol": "NVDA", "provider": "sec"}), APIEx( description="Enter a date (calendar quarter ending) for a specific report.", - parameters={"symbol": "BRK-A", "date": "2016-09-30"}, + parameters={"symbol": "BRK-A", "date": "2016-09-30", "provider": "sec"}, ), PythonEx( description="Example finding Michael Burry's filings.", diff --git a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py index f2268fe92dbf..b52b0f7a730b 100644 --- a/openbb_platform/extensions/equity/openbb_equity/price/price_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/price/price_router.py @@ -16,7 +16,10 @@ # pylint: disable=unused-argument -@router.command(model="EquityQuote", examples=[APIEx(parameters={"symbol": "AAPL"})]) +@router.command( + model="EquityQuote", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], +) async def quote( cc: CommandContext, provider_choices: ProviderChoices, @@ -27,7 +30,10 @@ async def quote( return await OBBject.from_query(Query(**locals())) -@router.command(model="EquityNBBO", examples=[APIEx(parameters={"symbol": "AAPL"})]) +@router.command( + model="EquityNBBO", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "polygon"})], +) async def nbbo( cc: CommandContext, provider_choices: ProviderChoices, @@ -41,8 +47,8 @@ async def nbbo( @router.command( model="EquityHistorical", examples=[ - APIEx(parameters={"symbol": "AAPL"}), - APIEx(parameters={"symbol": "AAPL", "interval": "1d"}), + APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), + APIEx(parameters={"symbol": "AAPL", "interval": "1d", "provider": "intrinio"}), ], ) async def historical( @@ -56,7 +62,8 @@ async def historical( @router.command( - model="PricePerformance", examples=[APIEx(parameters={"symbol": "AAPL"})] + model="PricePerformance", + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "fmp"})], ) async def performance( cc: CommandContext, diff --git a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py index d917c1a8fd38..1a08323b7bd2 100644 --- a/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/shorts/shorts_router.py @@ -18,7 +18,7 @@ @router.command( model="EquityFTD", - examples=[APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "sec"})], ) async def fails_to_deliver( cc: CommandContext, @@ -32,7 +32,7 @@ async def fails_to_deliver( @router.command( model="ShortVolume", - examples=[APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "stockgrid"})], ) async def short_volume( cc: CommandContext, @@ -46,7 +46,7 @@ async def short_volume( @router.command( model="EquityShortInterest", - examples=[APIEx(parameters={"symbol": "AAPL"})], + examples=[APIEx(parameters={"symbol": "AAPL", "provider": "finra"})], ) async def short_interest( cc: CommandContext, diff --git a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py index f177f95453d1..7963e7129475 100644 --- a/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/discovery/discovery_router.py @@ -20,7 +20,6 @@ model="ETFGainers", operation_id="etf_gainers", examples=[ - APIEx(parameters={}), APIEx(description="Get the top ETF gainers.", parameters={"provider": "wsj"}), ], ) @@ -38,7 +37,6 @@ async def gainers( model="ETFLosers", operation_id="etf_losers", examples=[ - APIEx(parameters={}), APIEx(description="Get the top ETF losers.", parameters={"provider": "wsj"}), ], ) @@ -56,7 +54,6 @@ async def losers( model="ETFActive", operation_id="etf_active", examples=[ - APIEx(parameters={}), APIEx(description="Get the most active ETFs.", parameters={"provider": "wsj"}), ], ) diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index 9fa9240ea42b..0e1b2ff21923 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -22,10 +22,9 @@ @router.command( model="EtfSearch", examples=[ - APIEx(parameters={}), APIEx( description="An empty query returns the full list of ETFs from the provider.", - parameters={}, + parameters={"provider": "fmp"}, ), APIEx( description="The query will return results from text-based fields containing the term.", @@ -50,7 +49,7 @@ async def search( model="EtfHistorical", operation_id="etf_historical", examples=[ - APIEx(parameters={"symbol": "SPY"}), + APIEx(parameters={"symbol": "SPY", "provider": "fmp"}), APIEx(parameters={"symbol": "SPY", "provider": "yfinance"}), APIEx( description="This function accepts multiple tickers.", @@ -71,7 +70,7 @@ async def historical( @router.command( model="EtfInfo", examples=[ - APIEx(parameters={"symbol": "SPY"}), + APIEx(parameters={"symbol": "SPY", "provider": "fmp"}), APIEx( description="This function accepts multiple tickers.", parameters={"symbol": "SPY,IWM,QQQ,DJIA", "provider": "fmp"}, @@ -90,7 +89,7 @@ async def info( @router.command( model="EtfSectors", - examples=[APIEx(parameters={"symbol": "SPY"})], + examples=[APIEx(parameters={"symbol": "SPY", "provider": "fmp"})], ) async def sectors( cc: CommandContext, @@ -104,7 +103,7 @@ async def sectors( @router.command( model="EtfCountries", - examples=[APIEx(parameters={"symbol": "VT"})], + examples=[APIEx(parameters={"symbol": "VT", "provider": "fmp"})], ) async def countries( cc: CommandContext, @@ -119,7 +118,7 @@ async def countries( @router.command( model="PricePerformance", examples=[ - APIEx(parameters={"symbol": "QQQ"}), + APIEx(parameters={"symbol": "QQQ", "provider": "fmp"}), APIEx(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"}), ], ) @@ -136,7 +135,7 @@ async def price_performance( @router.command( model="EtfHoldings", examples=[ - APIEx(parameters={"symbol": "XLK"}), + APIEx(parameters={"symbol": "XLK", "provider": "fmp"}), APIEx( description="Including a date (FMP, SEC) will return the holdings as per NPORT-P filings.", parameters={"symbol": "XLK", "date": "2022-03-31", "provider": "fmp"}, @@ -159,7 +158,7 @@ async def holdings( @router.command( model="EtfHoldingsDate", - examples=[APIEx(parameters={"symbol": "XLK"})], + examples=[APIEx(parameters={"symbol": "XLK", "provider": "fmp"})], ) async def holdings_date( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py index 39b650da7a1e..18631946f2eb 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/corporate/corporate_router.py @@ -18,7 +18,10 @@ @router.command( model="ICEBofA", - examples=[APIEx(parameters={}), APIEx(parameters={"index_type": "yield_to_worst"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"index_type": "yield_to_worst", "provider": "fred"}), + ], ) async def ice_bofa( cc: CommandContext, @@ -39,7 +42,10 @@ async def ice_bofa( @router.command( model="MoodyCorporateBondIndex", - examples=[APIEx(parameters={}), APIEx(parameters={"index_type": "baa"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"index_type": "baa", "provider": "fred"}), + ], ) async def moody( cc: CommandContext, @@ -59,7 +65,10 @@ async def moody( @router.command( model="HighQualityMarketCorporateBond", - examples=[APIEx(parameters={}), APIEx(parameters={"yield_curve": "par"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"yield_curve": "par", "provider": "fred"}), + ], ) async def hqm( cc: CommandContext, @@ -79,7 +88,10 @@ async def hqm( @router.command( model="SpotRate", - examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "10,20,30,50"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"maturity": "10,20,30,50", "provider": "fred"}), + ], ) async def spot_rates( cc: CommandContext, @@ -99,7 +111,10 @@ async def spot_rates( @router.command( model="CommercialPaper", - examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "15d"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"maturity": "15d", "provider": "fred"}), + ], ) async def commercial_paper( cc: CommandContext, @@ -117,7 +132,7 @@ async def commercial_paper( return await OBBject.from_query(Query(**locals())) -@router.command(model="BondPrices", examples=[APIEx(parameters={})]) +@router.command(model="BondPrices", examples=[APIEx(parameters={"provider": "tmx"})]) async def bond_prices( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py index 8b34db4430b5..feac9a5898ec 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_router.py @@ -27,7 +27,10 @@ @router.command( model="SOFR", - examples=[APIEx(parameters={}), APIEx(parameters={"period": "overnight"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"period": "overnight", "provider": "fred"}), + ], ) async def sofr( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index bb8f5ea9125a..e2b4e7b1f6c9 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -33,8 +33,8 @@ async def us_yield_curve( @router.command( model="EUYieldCurve", examples=[ - APIEx(parameters={}), - APIEx(parameters={"yield_curve_type": "spot_rate"}), + APIEx(parameters={"provider": "ecb"}), + APIEx(parameters={"yield_curve_type": "spot_rate", "provider": "ecb"}), ], ) async def eu_yield_curve( @@ -68,7 +68,7 @@ async def eu_yield_curve( @router.command( model="TreasuryRates", - examples=[APIEx(parameters={}), APIEx(parameters={"provider": "federal_reserve"})], + examples=[APIEx(parameters={"provider": "fmp"})], ) async def treasury_rates( cc: CommandContext, @@ -83,12 +83,13 @@ async def treasury_rates( @router.command( model="TreasuryAuctions", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "government_us"}), APIEx( parameters={ "security_type": "Bill", "start_date": "2022-01-01", "end_date": "2023-01-01", + "provider": "government_us", } ), ], @@ -105,7 +106,10 @@ async def treasury_auctions( @router.command( model="TreasuryPrices", - examples=[APIEx(parameters={}), APIEx(parameters={"date": "2019-02-05"})], + examples=[ + APIEx(parameters={"provider": "government_us"}), + APIEx(parameters={"date": "2019-02-05", "provider": "government_us"}), + ], ) async def treasury_prices( cc: CommandContext, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py index 251169d5ebcb..709b9c279049 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/rate/rate_router.py @@ -18,7 +18,10 @@ @router.command( model="AMERIBOR", - examples=[APIEx(parameters={}), APIEx(parameters={"parameter": "30_day_ma"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"parameter": "30_day_ma", "provider": "fred"}), + ], ) async def ameribor( cc: CommandContext, @@ -38,8 +41,8 @@ async def ameribor( @router.command( model="SONIA", examples=[ - APIEx(parameters={}), - APIEx(parameters={"parameter": "total_nominal_value"}), + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"parameter": "total_nominal_value", "provider": "fred"}), ], ) async def sonia( @@ -59,7 +62,7 @@ async def sonia( @router.command( model="IORB", - examples=[APIEx(parameters={})], + examples=[APIEx(parameters={"provider": "fred"})], ) async def iorb( cc: CommandContext, @@ -79,7 +82,7 @@ async def iorb( @router.command( model="FEDFUNDS", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "fred"}), APIEx(parameters={"parameter": "daily", "provider": "fred"}), ], ) @@ -100,7 +103,10 @@ async def effr( @router.command( model="PROJECTIONS", - examples=[APIEx(parameters={}), APIEx(parameters={"long_run": True})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"long_run": True, "provider": "fred"}), + ], ) async def effr_forecast( cc: CommandContext, @@ -121,8 +127,8 @@ async def effr_forecast( @router.command( model="ESTR", examples=[ - APIEx(parameters={}), - APIEx(parameters={"parameter": "number_of_active_banks"}), + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"parameter": "number_of_active_banks", "provider": "fred"}), ], ) async def estr( @@ -144,8 +150,8 @@ async def estr( @router.command( model="EuropeanCentralBankInterestRates", examples=[ - APIEx(parameters={}), - APIEx(parameters={"interest_rate_type": "refinancing"}), + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"interest_rate_type": "refinancing", "provider": "fred"}), ], ) async def ecb( @@ -169,8 +175,14 @@ async def ecb( @router.command( model="DiscountWindowPrimaryCreditRate", examples=[ - APIEx(parameters={}), - APIEx(parameters={"start_date": "2023-02-01", "end_date": "2023-05-01"}), + APIEx(parameters={"provider": "fred"}), + APIEx( + parameters={ + "start_date": "2023-02-01", + "end_date": "2023-05-01", + "provider": "fred", + } + ), ], ) async def dpcredit( diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py index c69f9ec7ec9f..1c0ee460911f 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/spreads/spreads_router.py @@ -18,7 +18,10 @@ @router.command( model="TreasuryConstantMaturity", - examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "2y"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"maturity": "2y", "provider": "fred"}), + ], ) async def tcm( cc: CommandContext, @@ -38,7 +41,10 @@ async def tcm( @router.command( model="SelectedTreasuryConstantMaturity", - examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "10y"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"maturity": "10y", "provider": "fred"}), + ], ) async def tcm_effr( cc: CommandContext, @@ -58,7 +64,10 @@ async def tcm_effr( @router.command( model="SelectedTreasuryBill", - examples=[APIEx(parameters={}), APIEx(parameters={"maturity": "6m"})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"maturity": "6m", "provider": "fred"}), + ], ) async def treasury_effr( cc: CommandContext, diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index e075ceb00330..c4a91fb2186f 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -28,7 +28,7 @@ since=(4, 1), expected_removal=(4, 3), ), - examples=[APIEx(parameters={"symbol": "SPX"})], + examples=[APIEx(parameters={"symbol": "SPX", "provider": "fmp"})], ) async def market( cc: CommandContext, @@ -63,7 +63,7 @@ async def constituents( @router.command( model="IndexSnapshots", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "tmx"}), APIEx(parameters={"region": "us", "provider": "cboe"}), ], ) @@ -79,7 +79,10 @@ async def snapshots( @router.command( model="AvailableIndices", - examples=[APIEx(parameters={}), APIEx(parameters={"provider": "yfinance"})], + examples=[ + APIEx(parameters={"provider": "fmp"}), + APIEx(parameters={"provider": "yfinance"}), + ], ) async def available( cc: CommandContext, @@ -94,7 +97,7 @@ async def available( @router.command( model="IndexSearch", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "cboe"}), APIEx(parameters={"query": "SPX", "provider": "cboe"}), ], ) @@ -111,7 +114,7 @@ async def search( @router.command( model="SP500Multiples", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "nasdaq"}), APIEx(parameters={"series_name": "shiller_pe_year", "provider": "nasdaq"}), ], ) @@ -127,7 +130,7 @@ async def sp500_multiples( @router.command( model="IndexSectors", - examples=[APIEx(parameters={"symbol": "^TX60"})], + examples=[APIEx(parameters={"symbol": "^TX60", "provider": "tmx"})], ) async def sectors( cc: CommandContext, diff --git a/openbb_platform/openbb/assets/extension_map.json b/openbb_platform/openbb/assets/extension_map.json index 3a653d729ce2..7673bb805992 100644 --- a/openbb_platform/openbb/assets/extension_map.json +++ b/openbb_platform/openbb/assets/extension_map.json @@ -4,25 +4,40 @@ "crypto@1.1.2", "currency@1.1.2", "derivatives@1.1.2", + "econometrics@1.1.2", "economy@1.1.2", "equity@1.1.2", "etf@1.1.2", "fixedincome@1.1.2", "index@1.1.2", "news@1.1.2", - "regulators@1.1.2" + "quantitative@1.1.2", + "regulators@1.1.2", + "technical@1.1.3" ], "openbb_provider_extension": [ + "alpha_vantage@1.1.2", "benzinga@1.1.2", + "biztoc@1.1.2", + "cboe@1.1.2", + "ecb@1.1.2", "federal_reserve@1.1.2", + "finra@1.1.2", + "finviz@1.0.1", "fmp@1.1.2", "fred@1.1.2", + "government_us@1.1.2", "intrinio@1.1.2", + "nasdaq@1.1.3", "oecd@1.1.2", "polygon@1.1.2", "sec@1.1.2", + "seeking_alpha@1.1.2", + "stockgrid@1.1.2", "tiingo@1.1.2", + "tmx@1.0.0", "tradingeconomics@1.1.2", + "wsj@1.1.2", "yfinance@1.1.2" ] } \ No newline at end of file diff --git a/openbb_platform/openbb/assets/module_map.json b/openbb_platform/openbb/assets/module_map.json index 0163f3c6803c..f294ba8ff90e 100644 --- a/openbb_platform/openbb/assets/module_map.json +++ b/openbb_platform/openbb/assets/module_map.json @@ -1,5 +1,7 @@ { "__extensions__": "", + "commodity": "/commodity", + "commodity_lbma_fixing": "/commodity/lbma_fixing", "crypto": "/crypto", "crypto_price": "/crypto/price", "crypto_price_historical": "/crypto/price/historical", @@ -7,6 +9,7 @@ "currency": "/currency", "currency_price": "/currency/price", "currency_price_historical": "/currency/price/historical", + "currency_reference_rates": "/currency/reference_rates", "currency_search": "/currency/search", "currency_snapshots": "/currency/snapshots", "derivatives": "/derivatives", @@ -16,7 +19,23 @@ "derivatives_options": "/derivatives/options", "derivatives_options_chains": "/derivatives/options/chains", "derivatives_options_unusual": "/derivatives/options/unusual", + "econometrics": "/econometrics", + "econometrics_autocorrelation": "/econometrics/autocorrelation", + "econometrics_causality": "/econometrics/causality", + "econometrics_cointegration": "/econometrics/cointegration", + "econometrics_correlation_matrix": "/econometrics/correlation_matrix", + "econometrics_ols_regression": "/econometrics/ols_regression", + "econometrics_ols_regression_summary": "/econometrics/ols_regression_summary", + "econometrics_panel_between": "/econometrics/panel_between", + "econometrics_panel_first_difference": "/econometrics/panel_first_difference", + "econometrics_panel_fixed": "/econometrics/panel_fixed", + "econometrics_panel_fmac": "/econometrics/panel_fmac", + "econometrics_panel_pooled": "/econometrics/panel_pooled", + "econometrics_panel_random_effects": "/econometrics/panel_random_effects", + "econometrics_residual_autocorrelation": "/econometrics/residual_autocorrelation", + "econometrics_unit_root": "/econometrics/unit_root", "economy": "/economy", + "economy_balance_of_payments": "/economy/balance_of_payments", "economy_calendar": "/economy/calendar", "economy_composite_leading_indicator": "/economy/composite_leading_indicator", "economy_cpi": "/economy/cpi", @@ -39,7 +58,10 @@ "equity_calendar_ipo": "/equity/calendar/ipo", "equity_calendar_splits": "/equity/calendar/splits", "equity_compare": "/equity/compare", + "equity_compare_groups": "/equity/compare/groups", "equity_compare_peers": "/equity/compare/peers", + "equity_darkpool": "/equity/darkpool", + "equity_darkpool_otc": "/equity/darkpool/otc", "equity_discovery": "/equity/discovery", "equity_discovery_active": "/equity/discovery/active", "equity_discovery_aggressive_small_caps": "/equity/discovery/aggressive_small_caps", @@ -47,8 +69,10 @@ "equity_discovery_gainers": "/equity/discovery/gainers", "equity_discovery_growth_tech": "/equity/discovery/growth_tech", "equity_discovery_losers": "/equity/discovery/losers", + "equity_discovery_top_retail": "/equity/discovery/top_retail", "equity_discovery_undervalued_growth": "/equity/discovery/undervalued_growth", "equity_discovery_undervalued_large_caps": "/equity/discovery/undervalued_large_caps", + "equity_discovery_upcoming_release_days": "/equity/discovery/upcoming_release_days", "equity_estimates": "/equity/estimates", "equity_estimates_analyst_search": "/equity/estimates/analyst_search", "equity_estimates_consensus": "/equity/estimates/consensus", @@ -97,8 +121,14 @@ "equity_search": "/equity/search", "equity_shorts": "/equity/shorts", "equity_shorts_fails_to_deliver": "/equity/shorts/fails_to_deliver", + "equity_shorts_short_interest": "/equity/shorts/short_interest", + "equity_shorts_short_volume": "/equity/shorts/short_volume", "etf": "/etf", "etf_countries": "/etf/countries", + "etf_discovery": "/etf/discovery", + "etf_discovery_active": "/etf/discovery/active", + "etf_discovery_gainers": "/etf/discovery/gainers", + "etf_discovery_losers": "/etf/discovery/losers", "etf_equity_exposure": "/etf/equity_exposure", "etf_historical": "/etf/historical", "etf_holdings": "/etf/holdings", @@ -110,12 +140,16 @@ "etf_sectors": "/etf/sectors", "fixedincome": "/fixedincome", "fixedincome_corporate": "/fixedincome/corporate", + "fixedincome_corporate_bond_prices": "/fixedincome/corporate/bond_prices", "fixedincome_corporate_commercial_paper": "/fixedincome/corporate/commercial_paper", "fixedincome_corporate_hqm": "/fixedincome/corporate/hqm", "fixedincome_corporate_ice_bofa": "/fixedincome/corporate/ice_bofa", "fixedincome_corporate_moody": "/fixedincome/corporate/moody", "fixedincome_corporate_spot_rates": "/fixedincome/corporate/spot_rates", "fixedincome_government": "/fixedincome/government", + "fixedincome_government_eu_yield_curve": "/fixedincome/government/eu_yield_curve", + "fixedincome_government_treasury_auctions": "/fixedincome/government/treasury_auctions", + "fixedincome_government_treasury_prices": "/fixedincome/government/treasury_prices", "fixedincome_government_treasury_rates": "/fixedincome/government/treasury_rates", "fixedincome_government_us_yield_curve": "/fixedincome/government/us_yield_curve", "fixedincome_rate": "/fixedincome/rate", @@ -138,15 +172,72 @@ "index_market": "/index/market", "index_price": "/index/price", "index_price_historical": "/index/price/historical", + "index_search": "/index/search", + "index_sectors": "/index/sectors", + "index_snapshots": "/index/snapshots", + "index_sp500_multiples": "/index/sp500_multiples", "news": "/news", "news_company": "/news/company", "news_world": "/news/world", + "quantitative": "/quantitative", + "quantitative_capm": "/quantitative/capm", + "quantitative_normality": "/quantitative/normality", + "quantitative_performance": "/quantitative/performance", + "quantitative_performance_omega_ratio": "/quantitative/performance/omega_ratio", + "quantitative_performance_sharpe_ratio": "/quantitative/performance/sharpe_ratio", + "quantitative_performance_sortino_ratio": "/quantitative/performance/sortino_ratio", + "quantitative_rolling": "/quantitative/rolling", + "quantitative_rolling_kurtosis": "/quantitative/rolling/kurtosis", + "quantitative_rolling_mean": "/quantitative/rolling/mean", + "quantitative_rolling_quantile": "/quantitative/rolling/quantile", + "quantitative_rolling_skew": "/quantitative/rolling/skew", + "quantitative_rolling_stdev": "/quantitative/rolling/stdev", + "quantitative_rolling_variance": "/quantitative/rolling/variance", + "quantitative_stats": "/quantitative/stats", + "quantitative_stats_kurtosis": "/quantitative/stats/kurtosis", + "quantitative_stats_mean": "/quantitative/stats/mean", + "quantitative_stats_quantile": "/quantitative/stats/quantile", + "quantitative_stats_skew": "/quantitative/stats/skew", + "quantitative_stats_stdev": "/quantitative/stats/stdev", + "quantitative_stats_variance": "/quantitative/stats/variance", + "quantitative_summary": "/quantitative/summary", + "quantitative_unitroot_test": "/quantitative/unitroot_test", "regulators": "/regulators", + "regulators_cftc": "/regulators/cftc", + "regulators_cftc_cot": "/regulators/cftc/cot", + "regulators_cftc_cot_search": "/regulators/cftc/cot_search", "regulators_sec": "/regulators/sec", "regulators_sec_cik_map": "/regulators/sec/cik_map", "regulators_sec_institutions_search": "/regulators/sec/institutions_search", "regulators_sec_rss_litigation": "/regulators/sec/rss_litigation", "regulators_sec_schema_files": "/regulators/sec/schema_files", "regulators_sec_sic_search": "/regulators/sec/sic_search", - "regulators_sec_symbol_map": "/regulators/sec/symbol_map" + "regulators_sec_symbol_map": "/regulators/sec/symbol_map", + "technical": "/technical", + "technical_ad": "/technical/ad", + "technical_adosc": "/technical/adosc", + "technical_adx": "/technical/adx", + "technical_aroon": "/technical/aroon", + "technical_atr": "/technical/atr", + "technical_bbands": "/technical/bbands", + "technical_cci": "/technical/cci", + "technical_cg": "/technical/cg", + "technical_clenow": "/technical/clenow", + "technical_cones": "/technical/cones", + "technical_demark": "/technical/demark", + "technical_donchian": "/technical/donchian", + "technical_ema": "/technical/ema", + "technical_fib": "/technical/fib", + "technical_fisher": "/technical/fisher", + "technical_hma": "/technical/hma", + "technical_ichimoku": "/technical/ichimoku", + "technical_kc": "/technical/kc", + "technical_macd": "/technical/macd", + "technical_obv": "/technical/obv", + "technical_rsi": "/technical/rsi", + "technical_sma": "/technical/sma", + "technical_stoch": "/technical/stoch", + "technical_vwap": "/technical/vwap", + "technical_wma": "/technical/wma", + "technical_zlma": "/technical/zlma" } \ No newline at end of file diff --git a/openbb_platform/openbb/package/__extensions__.py b/openbb_platform/openbb/package/__extensions__.py index f33f5962eea7..da67608b82b3 100644 --- a/openbb_platform/openbb/package/__extensions__.py +++ b/openbb_platform/openbb/package/__extensions__.py @@ -8,46 +8,72 @@ class Extensions(Container): # fmt: off """ Routers: + /commodity /crypto /currency /derivatives + /econometrics /economy /equity /etf /fixedincome /index /news + /quantitative /regulators + /technical Extensions: - commodity@1.0.0 - crypto@1.1.2 - currency@1.1.2 - derivatives@1.1.2 + - econometrics@1.1.2 - economy@1.1.2 - equity@1.1.2 - etf@1.1.2 - fixedincome@1.1.2 - index@1.1.2 - news@1.1.2 + - quantitative@1.1.2 - regulators@1.1.2 + - technical@1.1.3 + - alpha_vantage@1.1.2 - benzinga@1.1.2 + - biztoc@1.1.2 + - cboe@1.1.2 + - ecb@1.1.2 - federal_reserve@1.1.2 + - finra@1.1.2 + - finviz@1.0.1 - fmp@1.1.2 - fred@1.1.2 + - government_us@1.1.2 - intrinio@1.1.2 + - nasdaq@1.1.3 - oecd@1.1.2 - polygon@1.1.2 - sec@1.1.2 + - seeking_alpha@1.1.2 + - stockgrid@1.1.2 - tiingo@1.1.2 + - tmx@1.0.0 - tradingeconomics@1.1.2 + - wsj@1.1.2 - yfinance@1.1.2 """ # fmt: on def __repr__(self) -> str: return self.__doc__ or "" + @property + def commodity(self): + # pylint: disable=import-outside-toplevel + from . import commodity + + return commodity.ROUTER_commodity(command_runner=self._command_runner) + @property def crypto(self): # pylint: disable=import-outside-toplevel @@ -69,6 +95,13 @@ def derivatives(self): return derivatives.ROUTER_derivatives(command_runner=self._command_runner) + @property + def econometrics(self): + # pylint: disable=import-outside-toplevel + from . import econometrics + + return econometrics.ROUTER_econometrics(command_runner=self._command_runner) + @property def economy(self): # pylint: disable=import-outside-toplevel @@ -111,9 +144,23 @@ def news(self): return news.ROUTER_news(command_runner=self._command_runner) + @property + def quantitative(self): + # pylint: disable=import-outside-toplevel + from . import quantitative + + return quantitative.ROUTER_quantitative(command_runner=self._command_runner) + @property def regulators(self): # pylint: disable=import-outside-toplevel from . import regulators return regulators.ROUTER_regulators(command_runner=self._command_runner) + + @property + def technical(self): + # pylint: disable=import-outside-toplevel + from . import technical + + return technical.ROUTER_technical(command_runner=self._command_runner) diff --git a/openbb_platform/openbb/package/crypto.py b/openbb_platform/openbb/package/crypto.py index 9eb7d77e6042..534570221df4 100644 --- a/openbb_platform/openbb/package/crypto.py +++ b/openbb_platform/openbb/package/crypto.py @@ -77,8 +77,8 @@ def search( Examples -------- >>> from openbb import obb - >>> obb.crypto.search() - >>> obb.crypto.search(query='BTCUSD') + >>> obb.crypto.search(provider='fmp') + >>> obb.crypto.search(query='BTCUSD', provider='fmp') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index 36e892f198d5..e6d0a841af9a 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -13,6 +13,7 @@ class ROUTER_currency(Container): """/currency /price + reference_rates search snapshots """ @@ -27,6 +28,131 @@ def price(self): return currency_price.ROUTER_currency_price(command_runner=self._command_runner) + @exception_handler + @validate + def reference_rates( + self, provider: Optional[Literal["ecb"]] = None, **kwargs + ) -> OBBject: + """Current, official, currency reference rates. + + Foreign exchange reference rates are the exchange rates set by a major financial institution or regulatory body, + serving as a benchmark for the value of currencies around the world. + These rates are used as a standard to facilitate international trade and financial transactions, + ensuring consistency and reliability in currency conversion. + They are typically updated on a daily basis and reflect the market conditions at a specific time. + Central banks and financial institutions often use these rates to guide their own exchange rates, + impacting global trade, loans, and investments. + + + Parameters + ---------- + provider : Optional[Literal['ecb']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'ecb' if there is + no default. + + Returns + ------- + OBBject + results : CurrencyReferenceRates + Serializable results. + provider : Optional[Literal['ecb']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + CurrencyReferenceRates + ---------------------- + date : date + The date of the data. + EUR : Optional[float] + Euro. + USD : Optional[float] + US Dollar. + JPY : Optional[float] + Japanese Yen. + BGN : Optional[float] + Bulgarian Lev. + CZK : Optional[float] + Czech Koruna. + DKK : Optional[float] + Danish Krone. + GBP : Optional[float] + Pound Sterling. + HUF : Optional[float] + Hungarian Forint. + PLN : Optional[float] + Polish Zloty. + RON : Optional[float] + Romanian Leu. + SEK : Optional[float] + Swedish Krona. + CHF : Optional[float] + Swiss Franc. + ISK : Optional[float] + Icelandic Krona. + NOK : Optional[float] + Norwegian Krone. + TRY : Optional[float] + Turkish Lira. + AUD : Optional[float] + Australian Dollar. + BRL : Optional[float] + Brazilian Real. + CAD : Optional[float] + Canadian Dollar. + CNY : Optional[float] + Chinese Yuan. + HKD : Optional[float] + Hong Kong Dollar. + IDR : Optional[float] + Indonesian Rupiah. + ILS : Optional[float] + Israeli Shekel. + INR : Optional[float] + Indian Rupee. + KRW : Optional[float] + South Korean Won. + MXN : Optional[float] + Mexican Peso. + MYR : Optional[float] + Malaysian Ringgit. + NZD : Optional[float] + New Zealand Dollar. + PHP : Optional[float] + Philippine Peso. + SGD : Optional[float] + Singapore Dollar. + THB : Optional[float] + Thai Baht. + ZAR : Optional[float] + South African Rand. + + Examples + -------- + >>> from openbb import obb + >>> obb.currency.reference_rates() + """ # noqa: E501 + + return self._run( + "/currency/reference_rates", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/currency/reference_rates", + ("ecb",), + ) + }, + standard_params={}, + extra_params=kwargs, + ) + ) + @exception_handler @validate def search( diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py index 6eca8895451a..3e4e6f0924dc 100644 --- a/openbb_platform/openbb/package/derivatives_options.py +++ b/openbb_platform/openbb/package/derivatives_options.py @@ -26,7 +26,7 @@ def chains( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["intrinio"]] = None, + provider: Optional[Literal["cboe", "intrinio", "tmx"]] = None, **kwargs ) -> OBBject: """Get the complete options chain for a ticker. @@ -35,19 +35,23 @@ def chains( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['intrinio']] + provider : Optional[Literal['cboe', 'intrinio', 'tmx']] 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. + use_cache : bool + When True, the company directories will be cached for24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe); + Caching is used to validate the supplied ticker symbol, or if a historical EOD chain is requested. To bypass, set to False. (provider: tmx) date : Optional[datetime.date] - The end-of-day date for options chains data. (provider: intrinio) + The end-of-day date for options chains data. (provider: intrinio); + A specific date to get data for. (provider: tmx) Returns ------- OBBject results : List[OptionsChains] Serializable results. - provider : Optional[Literal['intrinio']] + provider : Optional[Literal['cboe', 'intrinio', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -144,8 +148,20 @@ def chains( Vega of the option. rho : Optional[float] Rho of the option. + last_trade_timestamp : Optional[datetime] + Last trade timestamp of the option. (provider: cboe) + dte : Optional[int] + Days to expiration for the option. (provider: cboe, tmx) exercise_style : Optional[str] The exercise style of the option, American or European. (provider: intrinio) + transactions : Optional[int] + Number of transactions for the contract. (provider: tmx) + total_value : Optional[float] + Total value of the transactions. (provider: tmx) + settlement_price : Optional[float] + Settlement price on that date. (provider: tmx) + underlying_price : Optional[float] + Price of the underlying stock on that date. (provider: tmx) Examples -------- @@ -162,7 +178,7 @@ def chains( "provider": self._get_provider( provider, "/derivatives/options/chains", - ("intrinio",), + ("cboe", "intrinio", "tmx"), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 0d63846f35fc..d0758ae043db 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -16,6 +16,7 @@ class ROUTER_economy(Container): """/economy + balance_of_payments calendar composite_leading_indicator cpi @@ -33,6 +34,283 @@ class ROUTER_economy(Container): def __repr__(self) -> str: return self.__doc__ or "" + @exception_handler + @validate + def balance_of_payments( + self, provider: Optional[Literal["ecb"]] = None, **kwargs + ) -> OBBject: + """Balance of Payments Reports. + + Parameters + ---------- + provider : Optional[Literal['ecb']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'ecb' if there is + no default. + report_type : Literal['main', 'summary', 'services', 'investment_income', 'direct_investment', 'portfolio_investment', 'other_investment'] + The report type, the level of detail in the data. (provider: ecb) + frequency : Literal['monthly', 'quarterly'] + The frequency of the data. Monthly is valid only for ['main', 'summary']. (provider: ecb) + country : Literal['brazil', 'canada', 'china', 'eu_ex_euro_area', 'eu_institutions', 'india', 'japan', 'russia', 'switzerland', 'united_kingdom', 'united_states', 'total', None] + The country/region of the data. This parameter will override the 'report_type' parameter. (provider: ecb) + + Returns + ------- + OBBject + results : List[BalanceOfPayments] + Serializable results. + provider : Optional[Literal['ecb']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + BalanceOfPayments + ----------------- + period : Optional[date] + The date representing the beginning of the reporting period. + current_account : Optional[float] + Current Account Balance (Billions of EUR) + goods : Optional[float] + Goods Balance (Billions of EUR) + services : Optional[float] + Services Balance (Billions of EUR) + primary_income : Optional[float] + Primary Income Balance (Billions of EUR) + secondary_income : Optional[float] + Secondary Income Balance (Billions of EUR) + capital_account : Optional[float] + Capital Account Balance (Billions of EUR) + net_lending_to_rest_of_world : Optional[float] + Balance of net lending to the rest of the world (Billions of EUR) + financial_account : Optional[float] + Financial Account Balance (Billions of EUR) + direct_investment : Optional[float] + Direct Investment Balance (Billions of EUR) + portfolio_investment : Optional[float] + Portfolio Investment Balance (Billions of EUR) + financial_derivatives : Optional[float] + Financial Derivatives Balance (Billions of EUR) + other_investment : Optional[float] + Other Investment Balance (Billions of EUR) + reserve_assets : Optional[float] + Reserve Assets Balance (Billions of EUR) + errors_and_ommissions : Optional[float] + Errors and Omissions (Billions of EUR) + current_account_credit : Optional[float] + Current Account Credits (Billions of EUR) + current_account_debit : Optional[float] + Current Account Debits (Billions of EUR) + current_account_balance : Optional[float] + Current Account Balance (Billions of EUR) + goods_credit : Optional[float] + Goods Credits (Billions of EUR) + goods_debit : Optional[float] + Goods Debits (Billions of EUR) + services_credit : Optional[float] + Services Credits (Billions of EUR) + services_debit : Optional[float] + Services Debits (Billions of EUR) + primary_income_credit : Optional[float] + Primary Income Credits (Billions of EUR) + primary_income_employee_compensation_credit : Optional[float] + Primary Income Employee Compensation Credit (Billions of EUR) + primary_income_debit : Optional[float] + Primary Income Debits (Billions of EUR) + primary_income_employee_compensation_debit : Optional[float] + Primary Income Employee Compensation Debit (Billions of EUR) + secondary_income_credit : Optional[float] + Secondary Income Credits (Billions of EUR) + secondary_income_debit : Optional[float] + Secondary Income Debits (Billions of EUR) + capital_account_credit : Optional[float] + Capital Account Credits (Billions of EUR) + capital_account_debit : Optional[float] + Capital Account Debits (Billions of EUR) + services_total_credit : Optional[float] + Services Total Credit (Billions of EUR) + services_total_debit : Optional[float] + Services Total Debit (Billions of EUR) + transport_credit : Optional[float] + Transport Credit (Billions of EUR) + transport_debit : Optional[float] + Transport Debit (Billions of EUR) + travel_credit : Optional[float] + Travel Credit (Billions of EUR) + travel_debit : Optional[float] + Travel Debit (Billions of EUR) + financial_services_credit : Optional[float] + Financial Services Credit (Billions of EUR) + financial_services_debit : Optional[float] + Financial Services Debit (Billions of EUR) + communications_credit : Optional[float] + Communications Credit (Billions of EUR) + communications_debit : Optional[float] + Communications Debit (Billions of EUR) + other_business_services_credit : Optional[float] + Other Business Services Credit (Billions of EUR) + other_business_services_debit : Optional[float] + Other Business Services Debit (Billions of EUR) + other_services_credit : Optional[float] + Other Services Credit (Billions of EUR) + other_services_debit : Optional[float] + Other Services Debit (Billions of EUR) + investment_total_credit : Optional[float] + Investment Total Credit (Billions of EUR) + investment_total_debit : Optional[float] + Investment Total Debit (Billions of EUR) + equity_credit : Optional[float] + Equity Credit (Billions of EUR) + equity_reinvested_earnings_credit : Optional[float] + Equity Reinvested Earnings Credit (Billions of EUR) + equity_debit : Optional[float] + Equity Debit (Billions of EUR) + equity_reinvested_earnings_debit : Optional[float] + Equity Reinvested Earnings Debit (Billions of EUR) + debt_instruments_credit : Optional[float] + Debt Instruments Credit (Billions of EUR) + debt_instruments_debit : Optional[float] + Debt Instruments Debit (Billions of EUR) + portfolio_investment_equity_credit : Optional[float] + Portfolio Investment Equity Credit (Billions of EUR) + portfolio_investment_equity_debit : Optional[float] + Portfolio Investment Equity Debit (Billions of EUR) + portfolio_investment_debt_instruments_credit : Optional[float] + Portfolio Investment Debt Instruments Credit (Billions of EUR) + portofolio_investment_debt_instruments_debit : Optional[float] + Portfolio Investment Debt Instruments Debit (Billions of EUR) + other_investment_credit : Optional[float] + Other Investment Credit (Billions of EUR) + other_investment_debit : Optional[float] + Other Investment Debit (Billions of EUR) + reserve_assets_credit : Optional[float] + Reserve Assets Credit (Billions of EUR) + assets_total : Optional[float] + Assets Total (Billions of EUR) + assets_equity : Optional[float] + Assets Equity (Billions of EUR) + assets_debt_instruments : Optional[float] + Assets Debt Instruments (Billions of EUR) + assets_mfi : Optional[float] + Assets MFIs (Billions of EUR) + assets_non_mfi : Optional[float] + Assets Non MFIs (Billions of EUR) + assets_direct_investment_abroad : Optional[float] + Assets Direct Investment Abroad (Billions of EUR) + liabilities_total : Optional[float] + Liabilities Total (Billions of EUR) + liabilities_equity : Optional[float] + Liabilities Equity (Billions of EUR) + liabilities_debt_instruments : Optional[float] + Liabilities Debt Instruments (Billions of EUR) + liabilities_mfi : Optional[float] + Liabilities MFIs (Billions of EUR) + liabilities_non_mfi : Optional[float] + Liabilities Non MFIs (Billions of EUR) + liabilities_direct_investment_euro_area : Optional[float] + Liabilities Direct Investment in Euro Area (Billions of EUR) + assets_equity_and_fund_shares : Optional[float] + Assets Equity and Investment Fund Shares (Billions of EUR) + assets_equity_shares : Optional[float] + Assets Equity Shares (Billions of EUR) + assets_investment_fund_shares : Optional[float] + Assets Investment Fund Shares (Billions of EUR) + assets_debt_short_term : Optional[float] + Assets Debt Short Term (Billions of EUR) + assets_debt_long_term : Optional[float] + Assets Debt Long Term (Billions of EUR) + assets_resident_sector_eurosystem : Optional[float] + Assets Resident Sector Eurosystem (Billions of EUR) + assets_resident_sector_mfi_ex_eurosystem : Optional[float] + Assets Resident Sector MFIs outside Eurosystem (Billions of EUR) + assets_resident_sector_government : Optional[float] + Assets Resident Sector Government (Billions of EUR) + assets_resident_sector_other : Optional[float] + Assets Resident Sector Other (Billions of EUR) + liabilities_equity_and_fund_shares : Optional[float] + Liabilities Equity and Investment Fund Shares (Billions of EUR) + liabilities_investment_fund_shares : Optional[float] + Liabilities Investment Fund Shares (Billions of EUR) + liabilities_debt_short_term : Optional[float] + Liabilities Debt Short Term (Billions of EUR) + liabilities_debt_long_term : Optional[float] + Liabilities Debt Long Term (Billions of EUR) + liabilities_resident_sector_government : Optional[float] + Liabilities Resident Sector Government (Billions of EUR) + liabilities_resident_sector_other : Optional[float] + Liabilities Resident Sector Other (Billions of EUR) + assets_currency_and_deposits : Optional[float] + Assets Currency and Deposits (Billions of EUR) + assets_loans : Optional[float] + Assets Loans (Billions of EUR) + assets_trade_credit_and_advances : Optional[float] + Assets Trade Credits and Advances (Billions of EUR) + assets_eurosystem : Optional[float] + Assets Eurosystem (Billions of EUR) + assets_other_mfi_ex_eurosystem : Optional[float] + Assets Other MFIs outside Eurosystem (Billions of EUR) + assets_government : Optional[float] + Assets Government (Billions of EUR) + assets_other_sectors : Optional[float] + Assets Other Sectors (Billions of EUR) + liabilities_currency_and_deposits : Optional[float] + Liabilities Currency and Deposits (Billions of EUR) + liabilities_loans : Optional[float] + Liabilities Loans (Billions of EUR) + liabilities_trade_credit_and_advances : Optional[float] + Liabilities Trade Credits and Advances (Billions of EUR) + liabilities_eurosystem : Optional[float] + Liabilities Eurosystem (Billions of EUR) + liabilities_other_mfi_ex_eurosystem : Optional[float] + Liabilities Other MFIs outside Eurosystem (Billions of EUR) + liabilities_government : Optional[float] + Liabilities Government (Billions of EUR) + liabilities_other_sectors : Optional[float] + Liabilities Other Sectors (Billions of EUR) + goods_balance : Optional[float] + Goods Balance (Billions of EUR) + services_balance : Optional[float] + Services Balance (Billions of EUR) + primary_income_balance : Optional[float] + Primary Income Balance (Billions of EUR) + investment_income_balance : Optional[float] + Investment Income Balance (Billions of EUR) + investment_income_credit : Optional[float] + Investment Income Credits (Billions of EUR) + investment_income_debit : Optional[float] + Investment Income Debits (Billions of EUR) + secondary_income_balance : Optional[float] + Secondary Income Balance (Billions of EUR) + capital_account_balance : Optional[float] + Capital Account Balance (Billions of EUR) + + Examples + -------- + >>> from openbb import obb + >>> obb.economy.balance_of_payments() + >>> obb.economy.balance_of_payments(report_type='summary') + >>> # The `country` parameter will override the `report_type`. + >>> obb.economy.balance_of_payments(country='united_states', provider='ecb') + """ # noqa: E501 + + return self._run( + "/economy/balance_of_payments", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/economy/balance_of_payments", + ("ecb",), + ) + }, + standard_params={}, + extra_params=kwargs, + ) + ) + @exception_handler @validate def calendar( @@ -49,7 +327,7 @@ def calendar( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "tradingeconomics"]] = None, + provider: Optional[Literal["fmp", "nasdaq", "tradingeconomics"]] = None, **kwargs ) -> OBBject: """Get the upcoming, or historical, economic calendar of global events. @@ -60,12 +338,12 @@ def calendar( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'tradingeconomics']] + provider : Optional[Literal['fmp', 'nasdaq', 'tradingeconomics']] 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. country : Optional[str] - Country of the event. Multiple items allowed. (provider: tradingeconomics) + Country of the event Multiple items allowed. (provider: nasdaq, tradingeconomics) importance : Optional[Literal['Low', 'Medium', 'High']] Importance of the event. (provider: tradingeconomics) group : Optional[Literal['interest rate', 'inflation', 'bonds', 'consumer', 'gdp', 'government', 'housing', 'labour', 'markets', 'money', 'prices', 'trade', 'business']] @@ -76,7 +354,7 @@ def calendar( OBBject results : List[EconomicCalendar] Serializable results. - provider : Optional[Literal['fmp', 'tradingeconomics']] + provider : Optional[Literal['fmp', 'nasdaq', 'tradingeconomics']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -123,6 +401,8 @@ def calendar( Last updated timestamp. (provider: fmp) created_at : Optional[datetime] Created at timestamp. (provider: fmp) + description : Optional[str] + Event description. (provider: nasdaq) Examples -------- @@ -130,6 +410,8 @@ def calendar( >>> # By default, the calendar will be forward-looking. >>> obb.economy.calendar() >>> obb.economy.calendar(provider='fmp', start_date='2020-03-01', end_date='2020-03-31') + >>> # By default, the calendar will be forward-looking. + >>> obb.economy.calendar(provider='nasdaq') """ # noqa: E501 return self._run( @@ -139,7 +421,7 @@ def calendar( "provider": self._get_provider( provider, "/economy/calendar", - ("fmp", "tradingeconomics"), + ("fmp", "nasdaq", "tradingeconomics"), ) }, standard_params={ @@ -529,7 +811,7 @@ def fred_regional( The name of the region. (provider: fred) code : Optional[Union[int, str]] The code of the region. (provider: fred) - value : Optional[Union[float, int]] + value : Optional[Union[int, float]] The obersvation value. The units are defined in the search results by series ID. (provider: fred) series_id : Optional[str] The individual series ID for the region. (provider: fred) diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index e1a2f8db3c0a..3db5a1b1cc13 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -14,6 +14,7 @@ class ROUTER_equity(Container): """/equity /calendar /compare + /darkpool /discovery /estimates /fundamental @@ -45,6 +46,15 @@ def compare(self): return equity_compare.ROUTER_equity_compare(command_runner=self._command_runner) + @property + def darkpool(self): + # pylint: disable=import-outside-toplevel + from . import equity_darkpool + + return equity_darkpool.ROUTER_equity_darkpool( + command_runner=self._command_runner + ) + @property def discovery(self): # pylint: disable=import-outside-toplevel @@ -229,10 +239,12 @@ def profile( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp, intrinio, tmx, yfinance." ), ], - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Optional[ + Literal["finviz", "fmp", "intrinio", "tmx", "yfinance"] + ] = None, **kwargs ) -> OBBject: """Get general information about a company. This includes company name, industry, sector and price data. @@ -240,10 +252,10 @@ def profile( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance. - provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] + Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp, intrinio, tmx, yfinance. + provider : Optional[Literal['finviz', 'fmp', 'intrinio', 'tmx', 'yfinance']] 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 'finviz' if there is no default. Returns @@ -251,7 +263,7 @@ def profile( OBBject results : List[EquityInfo] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] + provider : Optional[Literal['finviz', 'fmp', 'intrinio', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -338,6 +350,33 @@ def profile( Date of the company's first stock price. last_stock_price_date : Optional[date] Date of the company's last stock price. + index : Optional[str] + Included in indices - i.e., Dow, Nasdaq, or S&P. (provider: finviz) + optionable : Optional[str] + Whether options trade against the ticker. (provider: finviz) + shortable : Optional[str] + If the asset is shortable. (provider: finviz) + shares_outstanding : Optional[Union[str, int]] + The number of shares outstanding, as an abbreviated string. (provider: finviz); + The number of listed shares outstanding. (provider: tmx); + The number of listed shares outstanding. (provider: yfinance) + shares_float : Optional[Union[str, int]] + The number of shares in the public float, as an abbreviated string. (provider: finviz); + The number of shares in the public float. (provider: yfinance) + short_interest : Optional[str] + The last reported number of shares sold short, as an abbreviated string. (provider: finviz) + institutional_ownership : Optional[float] + The institutional ownership of the stock, as a normalized percent. (provider: finviz) + market_cap : Optional[int] + The market capitalization of the stock, as an abbreviated string. (provider: finviz); + Market capitalization of the company. (provider: fmp); + The market capitalization of the asset. (provider: yfinance) + dividend_yield : Optional[float] + The dividend yield of the stock, as a normalized percent. (provider: finviz, yfinance) + earnings_date : Optional[str] + The last, or next confirmed, earnings date and announcement time, as a string. The format is Nov 02 AMC - for after market close. (provider: finviz) + beta : Optional[float] + The beta of the stock relative to the broad market. (provider: finviz, fmp, yfinance) is_etf : Optional[bool] If the symbol is an ETF. (provider: fmp) is_actively_trading : Optional[bool] @@ -350,9 +389,6 @@ def profile( Image of the company. (provider: fmp) currency : Optional[str] Currency in which the stock is traded. (provider: fmp, yfinance) - market_cap : Optional[int] - Market capitalization of the company. (provider: fmp); - The market capitalization of the asset. (provider: yfinance) last_price : Optional[float] The last traded price. (provider: fmp) year_high : Optional[float] @@ -363,26 +399,26 @@ def profile( Average daily trading volume. (provider: fmp) annualized_dividend_amount : Optional[float] The annualized dividend payment based on the most recent regular dividend payment. (provider: fmp) - beta : Optional[float] - Beta of the stock relative to the market. (provider: fmp, yfinance) id : Optional[str] Intrinio ID for the company. (provider: intrinio) thea_enabled : Optional[bool] Whether the company has been enabled for Thea. (provider: intrinio) + email : Optional[str] + The email of the company. (provider: tmx) + issue_type : Optional[str] + The issuance type of the asset. (provider: tmx, yfinance) + shares_escrow : Optional[int] + The number of shares held in escrow. (provider: tmx) + shares_total : Optional[int] + The total number of shares outstanding from all classes. (provider: tmx) + dividend_frequency : Optional[str] + The dividend frequency. (provider: tmx) exchange_timezone : Optional[str] The timezone of the exchange. (provider: yfinance) - issue_type : Optional[str] - The issuance type of the asset. (provider: yfinance) - shares_outstanding : Optional[int] - The number of listed shares outstanding. (provider: yfinance) - shares_float : Optional[int] - The number of shares in the public float. (provider: yfinance) shares_implied_outstanding : Optional[int] Implied shares outstanding of common equityassuming the conversion of all convertible subsidiary equity into common. (provider: yfinance) shares_short : Optional[int] The reported number of shares short. (provider: yfinance) - dividend_yield : Optional[float] - The dividend yield of the asset, as a normalized percent. (provider: yfinance) Examples -------- @@ -397,7 +433,7 @@ def profile( "provider": self._get_provider( provider, "/equity/profile", - ("fmp", "intrinio", "yfinance"), + ("finviz", "fmp", "intrinio", "tmx", "yfinance"), ) }, standard_params={ @@ -406,7 +442,13 @@ def profile( extra_params=kwargs, extra_info={ "symbol": { - "multiple_items_allowed": ["fmp", "intrinio", "yfinance"] + "multiple_items_allowed": [ + "finviz", + "fmp", + "intrinio", + "tmx", + "yfinance", + ] } }, ) @@ -538,7 +580,7 @@ def search( Optional[bool], OpenBBCustomParameter(description="Whether to use the cache or not."), ] = True, - provider: Optional[Literal["intrinio", "sec"]] = None, + provider: Optional[Literal["cboe", "intrinio", "nasdaq", "sec", "tmx"]] = None, **kwargs ) -> OBBject: """Search for stock symbol, CIK, LEI, or company name. @@ -551,14 +593,16 @@ def search( Whether to search by ticker symbol. use_cache : Optional[bool] Whether to use the cache or not. - provider : Optional[Literal['intrinio', 'sec']] + provider : Optional[Literal['cboe', 'intrinio', 'nasdaq', 'sec', 'tmx']] 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. active : Optional[bool] When true, return companies that are actively traded (having stock prices within the past 14 days). When false, return companies that are not actively traded or never have been traded. (provider: intrinio) limit : Optional[int] The number of data entries to return. (provider: intrinio) + is_etf : Optional[bool] + If True, returns ETFs. (provider: nasdaq) is_fund : bool Whether to direct the search to the list of mutual funds and ETFs. (provider: sec) @@ -567,7 +611,7 @@ def search( OBBject results : List[EquitySearch] Serializable results. - provider : Optional[Literal['intrinio', 'sec']] + provider : Optional[Literal['cboe', 'intrinio', 'nasdaq', 'sec', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -582,6 +626,10 @@ def search( Symbol representing the entity requested in the data. name : str Name of the company. + dpm_name : Optional[str] + Name of the primary market maker. (provider: cboe) + post_station : Optional[str] + Post and station location on the CBOE trading floor. (provider: cboe) cik : Optional[str] ; Central Index Key (provider: sec) @@ -589,6 +637,26 @@ def search( The Legal Entity Identifier (LEI) of the company. (provider: intrinio) intrinio_id : Optional[str] The Intrinio ID of the company. (provider: intrinio) + nasdaq_traded : Optional[str] + Is Nasdaq traded? (provider: nasdaq) + exchange : Optional[str] + Primary Exchange (provider: nasdaq) + market_category : Optional[str] + Market Category (provider: nasdaq) + etf : Optional[str] + Is ETF? (provider: nasdaq) + round_lot_size : Optional[float] + Round Lot Size (provider: nasdaq) + test_issue : Optional[str] + Is test Issue? (provider: nasdaq) + financial_status : Optional[str] + Financial Status (provider: nasdaq) + cqs_symbol : Optional[str] + CQS Symbol (provider: nasdaq) + nasdaq_symbol : Optional[str] + NASDAQ Symbol (provider: nasdaq) + next_shares : Optional[str] + Is NextShares? (provider: nasdaq) Examples -------- @@ -604,7 +672,7 @@ def search( "provider": self._get_provider( provider, "/equity/search", - ("intrinio", "sec"), + ("cboe", "intrinio", "nasdaq", "sec", "tmx"), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/equity_calendar.py b/openbb_platform/openbb/package/equity_calendar.py index ff1bff9237f9..6a744658d95d 100644 --- a/openbb_platform/openbb/package/equity_calendar.py +++ b/openbb_platform/openbb/package/equity_calendar.py @@ -38,7 +38,7 @@ def dividend( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["fmp", "nasdaq"]] = None, **kwargs ) -> OBBject: """Get historical and upcoming dividend payments. Includes dividend amount, ex-dividend and payment dates. @@ -49,7 +49,7 @@ def dividend( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'nasdaq']] 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. @@ -59,7 +59,7 @@ def dividend( OBBject results : List[CalendarDividend] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'nasdaq']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -88,6 +88,8 @@ def dividend( The adjusted-dividend amount. (provider: fmp) label : Optional[str] Ex-dividend date formatted for display. (provider: fmp) + annualized_amount : Optional[float] + The indicated annualized dividend amount. (provider: nasdaq) Examples -------- @@ -104,7 +106,7 @@ def dividend( "provider": self._get_provider( provider, "/equity/calendar/dividend", - ("fmp",), + ("fmp", "nasdaq"), ) }, standard_params={ @@ -131,7 +133,7 @@ def earnings( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["fmp", "nasdaq", "tmx"]] = None, **kwargs ) -> OBBject: """Get historical and upcoming company earnings releases. Includes earnings per share (EPS) and revenue data. @@ -142,7 +144,7 @@ def earnings( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'nasdaq', 'tmx']] 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. @@ -152,7 +154,7 @@ def earnings( OBBject results : List[CalendarEarnings] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'nasdaq', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -174,17 +176,30 @@ def earnings( eps_consensus : Optional[float] The analyst conesus earnings-per-share estimate. eps_actual : Optional[float] - The actual earnings per share announced. (provider: fmp) + The actual earnings per share announced. (provider: fmp, nasdaq); + The actual EPS in dollars. (provider: tmx) revenue_actual : Optional[float] The actual reported revenue. (provider: fmp) revenue_consensus : Optional[float] The revenue forecast consensus. (provider: fmp) - period_ending : Optional[date] - The fiscal period end date. (provider: fmp) + period_ending : Optional[Union[date, str]] + The fiscal period end date. (provider: fmp, nasdaq) reporting_time : Optional[str] - The reporting time - e.g. after market close. (provider: fmp) + The reporting time - e.g. after market close. (provider: fmp, nasdaq); + The time of the report - i.e., before or after market. (provider: tmx) updated_date : Optional[date] The date the data was updated last. (provider: fmp) + surprise_percent : Optional[float] + The earnings surprise as normalized percentage points. (provider: nasdaq); + The EPS surprise as a normalized percent. (provider: tmx) + num_estimates : Optional[int] + The number of analysts providing estimates for the consensus. (provider: nasdaq) + previous_report_date : Optional[date] + The previous report date for the same period last year. (provider: nasdaq) + market_cap : Optional[int] + The market cap (USD) of the reporting entity. (provider: nasdaq) + eps_surprise : Optional[float] + The EPS surprise in dollars. (provider: tmx) Examples -------- @@ -201,7 +216,7 @@ def earnings( "provider": self._get_provider( provider, "/equity/calendar/earnings", - ("fmp",), + ("fmp", "nasdaq", "tmx"), ) }, standard_params={ @@ -235,7 +250,7 @@ def ipo( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["intrinio"]] = None, + provider: Optional[Literal["intrinio", "nasdaq"]] = None, **kwargs ) -> OBBject: """Get historical and upcoming initial public offerings (IPOs). @@ -250,23 +265,26 @@ def ipo( End date of the data, in YYYY-MM-DD format. limit : Optional[int] The number of data entries to return. - provider : Optional[Literal['intrinio']] + provider : Optional[Literal['intrinio', 'nasdaq']] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'intrinio' if there is no default. - status : Optional[Literal['upcoming', 'priced', 'withdrawn']] - Status of the IPO. [upcoming, priced, or withdrawn] (provider: intrinio) + status : Optional[Union[Literal['upcoming', 'priced', 'withdrawn'], Literal['upcoming', 'priced', 'filed', 'withdrawn']]] + Status of the IPO. [upcoming, priced, or withdrawn] (provider: intrinio); + The status of the IPO. (provider: nasdaq) min_value : Optional[int] Return IPOs with an offer dollar amount greater than the given amount. (provider: intrinio) max_value : Optional[int] Return IPOs with an offer dollar amount less than the given amount. (provider: intrinio) + is_spo : bool + If True, returns data for secondary public offerings (SPOs). (provider: nasdaq) Returns ------- OBBject results : List[CalendarIpo] Serializable results. - provider : Optional[Literal['intrinio']] + provider : Optional[Literal['intrinio', 'nasdaq']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -293,7 +311,8 @@ def ipo( Typically NYSE or NASDAQ. (provider: intrinio) offer_amount : Optional[float] - The total dollar amount of shares offered in the IPO. Typically this is share price * share count (provider: intrinio) + The total dollar amount of shares offered in the IPO. Typically this is share price * share count (provider: intrinio); + The dollar value of the shares offered. (provider: nasdaq) share_price : Optional[float] The price per share at which the IPO was offered. (provider: intrinio) share_price_lowest : Optional[float] @@ -309,7 +328,7 @@ def ipo( they expect to offer the IPO (typically available for upcoming IPOs). (provider: intrinio) share_count : Optional[int] - The number of shares offered in the IPO. (provider: intrinio) + The number of shares offered in the IPO. (provider: intrinio, nasdaq) share_count_lowest : Optional[int] The expected lowest number of shares that will be offered in the IPO. Before an IPO is priced, @@ -356,6 +375,16 @@ def ipo( The company that is going public via the IPO. (provider: intrinio) security : Optional[openbb_intrinio.utils.references.IntrinioSecurity] The primary Security for the Company that is going public via the IPO (provider: intrinio) + name : Optional[str] + The name of the company. (provider: nasdaq) + expected_price_date : Optional[date] + The date the pricing is expected. (provider: nasdaq) + filed_date : Optional[date] + The date the IPO was filed. (provider: nasdaq) + withdraw_date : Optional[date] + The date the IPO was withdrawn. (provider: nasdaq) + deal_status : Optional[str] + The status of the deal. (provider: nasdaq) Examples -------- @@ -375,7 +404,7 @@ def ipo( "provider": self._get_provider( provider, "/equity/calendar/ipo", - ("intrinio",), + ("intrinio", "nasdaq"), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/equity_compare.py b/openbb_platform/openbb/package/equity_compare.py index f2a3725fbfdc..e5eb310c8a22 100644 --- a/openbb_platform/openbb/package/equity_compare.py +++ b/openbb_platform/openbb/package/equity_compare.py @@ -12,12 +12,139 @@ class ROUTER_equity_compare(Container): """/equity/compare + groups peers """ def __repr__(self) -> str: return self.__doc__ or "" + @exception_handler + @validate + def groups( + self, + group: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="The group to compare - i.e., 'sector', 'industry', 'country'. Choices vary by provider." + ), + ] = None, + metric: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="The type of metrics to compare - i.e, 'valuation', 'performance'. Choices vary by provider." + ), + ] = None, + provider: Optional[Literal["finviz"]] = None, + **kwargs + ) -> OBBject: + """Get company data grouped by sector, industry or country and display either performance or valuation metrics. + + Valuation metrics include price to earnings, price to book, price to sales ratios and price to cash flow. + Performance metrics include the stock price change for different time periods. + + Parameters + ---------- + group : Optional[str] + The group to compare - i.e., 'sector', 'industry', 'country'. Choices vary by provider. + metric : Optional[str] + The type of metrics to compare - i.e, 'valuation', 'performance'. Choices vary by provider. + provider : Optional[Literal['finviz']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'finviz' if there is + no default. + + Returns + ------- + OBBject + results : List[CompareGroups] + Serializable results. + provider : Optional[Literal['finviz']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + CompareGroups + ------------- + name : str + Name or label of the group. + stocks : Optional[int] + The number of stocks in the group. (provider: finviz) + market_cap : Optional[int] + The market cap of the group. (provider: finviz) + performance_1_d : Optional[float] + The performance in the last day, as a normalized percent. (provider: finviz) + performance_1_w : Optional[float] + The performance in the last week, as a normalized percent. (provider: finviz) + performance_1_m : Optional[float] + The performance in the last month, as a normalized percent. (provider: finviz) + performance_3_m : Optional[float] + The performance in the last quarter, as a normalized percent. (provider: finviz) + performance_6_m : Optional[float] + The performance in the last half year, as a normalized percent. (provider: finviz) + performance_1_y : Optional[float] + The performance in the last year, as a normalized percent. (provider: finviz) + performance_ytd : Optional[float] + The performance in the year to date, as a normalized percent. (provider: finviz) + dividend_yield : Optional[float] + The dividend yield of the group, as a normalized percent. (provider: finviz) + pe : Optional[float] + The P/E ratio of the group. (provider: finviz) + forward_pe : Optional[float] + The forward P/E ratio of the group. (provider: finviz) + peg : Optional[float] + The PEG ratio of the group. (provider: finviz) + eps_growth_past_5_years : Optional[float] + The EPS growth of the group for the past 5 years, as a normalized percent. (provider: finviz) + eps_growth_next_5_years : Optional[float] + The estimated EPS growth of the groupo for the next 5 years, as a normalized percent. (provider: finviz) + sales_growth_past_5_years : Optional[float] + The sales growth of the group for the past 5 years, as a normalized percent. (provider: finviz) + float_short : Optional[float] + The percent of the float shorted for the group, as a normalized value. (provider: finviz) + analyst_recommendation : Optional[float] + The analyst consensus, on a scale of 1-5 where 1 is a buy and 5 is a sell. (provider: finviz) + volume : Optional[int] + The trading volume. (provider: finviz) + volume_average : Optional[int] + The 3-month average volume of the group. (provider: finviz) + volume_relative : Optional[float] + The relative volume compared to the 3-month average volume. (provider: finviz) + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.compare.groups() + >>> # Group by sector and analyze valuation. + >>> obb.equity.compare.groups(group='sector', metric='valuation') + >>> # Group by industry and analyze performance. + >>> obb.equity.compare.groups(group='industry', metric='performance') + >>> # Group by country and analyze valuation. + >>> obb.equity.compare.groups(group='country', metric='valuation') + """ # noqa: E501 + + return self._run( + "/equity/compare/groups", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/equity/compare/groups", + ("finviz",), + ) + }, + standard_params={ + "group": group, + "metric": metric, + }, + extra_params=kwargs, + ) + ) + @exception_handler @validate def peers( diff --git a/openbb_platform/openbb/package/equity_discovery.py b/openbb_platform/openbb/package/equity_discovery.py index acb41dab1c5e..23822c0e8e0e 100644 --- a/openbb_platform/openbb/package/equity_discovery.py +++ b/openbb_platform/openbb/package/equity_discovery.py @@ -19,8 +19,10 @@ class ROUTER_equity_discovery(Container): gainers growth_tech losers + top_retail undervalued_growth undervalued_large_caps + upcoming_release_days """ def __repr__(self) -> str: @@ -31,7 +33,7 @@ def __repr__(self) -> str: def active( self, sort: Annotated[ - str, + Literal["asc", "desc"], OpenBBCustomParameter( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), @@ -43,7 +45,7 @@ def active( Parameters ---------- - sort : str + sort : Literal['asc', 'desc'] Sort order. Possible values: 'asc', 'desc'. Default: 'desc'. provider : Optional[Literal['yfinance']] The provider to use for the query, by default None. @@ -114,7 +116,7 @@ def active( def aggressive_small_caps( self, sort: Annotated[ - str, + Literal["asc", "desc"], OpenBBCustomParameter( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), @@ -126,7 +128,7 @@ def aggressive_small_caps( Parameters ---------- - sort : str + sort : Literal['asc', 'desc'] Sort order. Possible values: 'asc', 'desc'. Default: 'desc'. provider : Optional[Literal['yfinance']] The provider to use for the query, by default None. @@ -307,31 +309,33 @@ def filings( def gainers( self, sort: Annotated[ - str, + Literal["asc", "desc"], OpenBBCustomParameter( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["yfinance"]] = None, + provider: Optional[Literal["tmx", "yfinance"]] = None, **kwargs ) -> OBBject: """Get the top price gainers in the stock market. Parameters ---------- - sort : str + sort : Literal['asc', 'desc'] Sort order. Possible values: 'asc', 'desc'. Default: 'desc'. - provider : Optional[Literal['yfinance']] + provider : Optional[Literal['tmx', 'yfinance']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'yfinance' if there is + If None, the provider specified in defaults is selected or 'tmx' if there is no default. + category : Literal['dividend', 'energy', 'healthcare', 'industrials', 'price_performer', 'rising_stars', 'real_estate', 'tech', 'utilities', '52w_high', 'volume'] + The category of list to retrieve. Defaults to `price_performer`. (provider: tmx) Returns ------- OBBject results : List[EquityGainers] Serializable results. - provider : Optional[Literal['yfinance']] + provider : Optional[Literal['tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -354,6 +358,8 @@ def gainers( Percent change. volume : float The trading volume. + rank : Optional[int] + The rank of the stock in the list. (provider: tmx) market_cap : Optional[float] Market Cap. (provider: yfinance) avg_volume_3_months : Optional[float] @@ -375,7 +381,7 @@ def gainers( "provider": self._get_provider( provider, "/equity/discovery/gainers", - ("yfinance",), + ("tmx", "yfinance"), ) }, standard_params={ @@ -390,7 +396,7 @@ def gainers( def growth_tech( self, sort: Annotated[ - str, + Literal["asc", "desc"], OpenBBCustomParameter( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), @@ -402,7 +408,7 @@ def growth_tech( Parameters ---------- - sort : str + sort : Literal['asc', 'desc'] Sort order. Possible values: 'asc', 'desc'. Default: 'desc'. provider : Optional[Literal['yfinance']] The provider to use for the query, by default None. @@ -473,7 +479,7 @@ def growth_tech( def losers( self, sort: Annotated[ - str, + Literal["asc", "desc"], OpenBBCustomParameter( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), @@ -485,7 +491,7 @@ def losers( Parameters ---------- - sort : str + sort : Literal['asc', 'desc'] Sort order. Possible values: 'asc', 'desc'. Default: 'desc'. provider : Optional[Literal['yfinance']] The provider to use for the query, by default None. @@ -551,12 +557,85 @@ def losers( ) ) + @exception_handler + @validate + def top_retail( + self, + limit: Annotated[ + int, + OpenBBCustomParameter(description="The number of data entries to return."), + ] = 5, + provider: Optional[Literal["nasdaq"]] = None, + **kwargs + ) -> OBBject: + """Tracks over $30B USD/day of individual investors trades. + + It gives a daily view into retail activity and sentiment for over 9,500 US traded stocks, + ADRs, and ETPs. + + Parameters + ---------- + limit : int + The number of data entries to return. + provider : Optional[Literal['nasdaq']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'nasdaq' if there is + no default. + + Returns + ------- + OBBject + results : List[TopRetail] + Serializable results. + provider : Optional[Literal['nasdaq']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + TopRetail + --------- + date : date + The date of the data. + symbol : str + Symbol representing the entity requested in the data. + activity : float + Activity of the symbol. + sentiment : float + Sentiment of the symbol. 1 is bullish, -1 is bearish. + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.discovery.top_retail() + """ # noqa: E501 + + return self._run( + "/equity/discovery/top_retail", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/equity/discovery/top_retail", + ("nasdaq",), + ) + }, + standard_params={ + "limit": limit, + }, + extra_params=kwargs, + ) + ) + @exception_handler @validate def undervalued_growth( self, sort: Annotated[ - str, + Literal["asc", "desc"], OpenBBCustomParameter( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), @@ -568,7 +647,7 @@ def undervalued_growth( Parameters ---------- - sort : str + sort : Literal['asc', 'desc'] Sort order. Possible values: 'asc', 'desc'. Default: 'desc'. provider : Optional[Literal['yfinance']] The provider to use for the query, by default None. @@ -639,7 +718,7 @@ def undervalued_growth( def undervalued_large_caps( self, sort: Annotated[ - str, + Literal["asc", "desc"], OpenBBCustomParameter( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), @@ -651,7 +730,7 @@ def undervalued_large_caps( Parameters ---------- - sort : str + sort : Literal['asc', 'desc'] Sort order. Possible values: 'asc', 'desc'. Default: 'desc'. provider : Optional[Literal['yfinance']] The provider to use for the query, by default None. @@ -716,3 +795,69 @@ def undervalued_large_caps( extra_params=kwargs, ) ) + + @exception_handler + @validate + def upcoming_release_days( + self, provider: Optional[Literal["seeking_alpha"]] = None, **kwargs + ) -> OBBject: + """Get upcoming earnings release dates. + + Parameters + ---------- + provider : Optional[Literal['seeking_alpha']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'seeking_alpha' if there is + no default. + limit : int + The number of data entries to return.In this case, the number of lookahead days. (provider: seeking_alpha) + + Returns + ------- + OBBject + results : List[UpcomingReleaseDays] + Serializable results. + provider : Optional[Literal['seeking_alpha']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + UpcomingReleaseDays + ------------------- + symbol : str + Symbol representing the entity requested in the data. + name : str + The full name of the asset. + exchange : str + The exchange the asset is traded on. + release_time_type : str + The type of release time. + release_date : date + The date of the release. + sector_id : Optional[int] + The sector ID of the asset. (provider: seeking_alpha) + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.discovery.upcoming_release_days() + """ # noqa: E501 + + return self._run( + "/equity/discovery/upcoming_release_days", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/equity/discovery/upcoming_release_days", + ("seeking_alpha",), + ) + }, + standard_params={}, + extra_params=kwargs, + ) + ) diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py index 7ba1fbc603bc..0fa4a3fc173f 100644 --- a/openbb_platform/openbb/package/equity_estimates.py +++ b/openbb_platform/openbb/package/equity_estimates.py @@ -200,10 +200,10 @@ def consensus( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): tmx, yfinance." ), ], - provider: Optional[Literal["fmp", "yfinance"]] = None, + provider: Optional[Literal["fmp", "tmx", "yfinance"]] = None, **kwargs ) -> OBBject: """Get consensus price target and recommendation. @@ -211,8 +211,8 @@ def consensus( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): yfinance. - provider : Optional[Literal['fmp', 'yfinance']] + Symbol to get data for. Multiple items allowed for provider(s): tmx, yfinance. + provider : Optional[Literal['fmp', 'tmx', 'yfinance']] 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. @@ -222,7 +222,7 @@ def consensus( OBBject results : Union[List[PriceTargetConsensus], PriceTargetConsensus] Serializable results. - provider : Optional[Literal['fmp', 'yfinance']] + provider : Optional[Literal['fmp', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -243,6 +243,18 @@ def consensus( Consensus target of the price target consensus. target_median : Optional[float] Median target of the price target consensus. + target_upside : Optional[float] + Percent of upside, as a normalized percent. (provider: tmx) + total_analysts : Optional[int] + Total number of analyst. (provider: tmx) + buy_ratings : Optional[int] + Number of buy ratings. (provider: tmx) + sell_ratings : Optional[int] + Number of sell ratings. (provider: tmx) + hold_ratings : Optional[int] + Number of hold ratings. (provider: tmx) + consensus_action : Optional[str] + Consensus action. (provider: tmx) recommendation : Optional[str] Recommendation - buy, sell, etc. (provider: yfinance) recommendation_mean : Optional[float] @@ -268,14 +280,14 @@ def consensus( "provider": self._get_provider( provider, "/equity/estimates/consensus", - ("fmp", "yfinance"), + ("fmp", "tmx", "yfinance"), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["yfinance"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["tmx", "yfinance"]}}, ) ) @@ -406,14 +418,14 @@ def price_target( symbol: Annotated[ Union[str, None, List[Optional[str]]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): benzinga." + description="Symbol to get data for. Multiple items allowed for provider(s): benzinga, finviz." ), ] = None, limit: Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 200, - provider: Optional[Literal["benzinga", "fmp"]] = None, + provider: Optional[Literal["benzinga", "finviz", "fmp"]] = None, **kwargs ) -> OBBject: """Get analyst price targets by company. @@ -421,10 +433,10 @@ def price_target( Parameters ---------- symbol : Union[str, None, List[Optional[str]]] - Symbol to get data for. Multiple items allowed for provider(s): benzinga. + Symbol to get data for. Multiple items allowed for provider(s): benzinga, finviz. limit : int The number of data entries to return. - provider : Optional[Literal['benzinga', 'fmp']] + provider : Optional[Literal['benzinga', 'finviz', 'fmp']] 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. @@ -456,7 +468,7 @@ def price_target( OBBject results : List[PriceTarget] Serializable results. - provider : Optional[Literal['benzinga', 'fmp']] + provider : Optional[Literal['benzinga', 'finviz', 'fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -515,6 +527,10 @@ def price_target( Unique ID of this entry. (provider: benzinga) last_updated : Optional[datetime] Last updated timestamp, UTC. (provider: benzinga) + status : Optional[str] + The action taken by the firm. This could be 'Upgrade', 'Downgrade', 'Reiterated', etc. (provider: finviz) + rating_change : Optional[str] + The rating given by the analyst. This could be 'Buy', 'Sell', 'Underweight', etc. If the rating is a revision, the change is indicated by '->' (provider: finviz) news_url : Optional[str] News URL of the price target. (provider: fmp) news_title : Optional[str] @@ -539,7 +555,7 @@ def price_target( "provider": self._get_provider( provider, "/equity/estimates/price_target", - ("benzinga", "fmp"), + ("benzinga", "finviz", "fmp"), ) }, standard_params={ @@ -547,6 +563,8 @@ def price_target( "limit": limit, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["benzinga"]}}, + extra_info={ + "symbol": {"multiple_items_allowed": ["benzinga", "finviz"]} + }, ) ) diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index caea2e6c5fa8..c8b22923deb3 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -961,7 +961,10 @@ def cash_growth( def dividends( self, symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): nasdaq." + ), ], start_date: Annotated[ Union[datetime.date, None, str], @@ -975,20 +978,22 @@ def dividends( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Optional[ + Literal["fmp", "intrinio", "nasdaq", "tmx", "yfinance"] + ] = None, **kwargs ) -> OBBject: """Get historical dividend data for a given company. Parameters ---------- - symbol : str - Symbol to get data for. + symbol : Union[str, List[str]] + Symbol to get data for. Multiple items allowed for provider(s): nasdaq. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'nasdaq', 'tmx', 'yfinance']] 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. @@ -1000,7 +1005,7 @@ def dividends( OBBject results : List[HistoricalDividends] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'nasdaq', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1020,17 +1025,25 @@ def dividends( adj_dividend : Optional[float] Adjusted dividend of the historical dividends. (provider: fmp) record_date : Optional[date] - Record date of the historical dividends. (provider: fmp) + Record date of the historical dividends. (provider: fmp); + The record date of ownership for eligibility. (provider: nasdaq); + The record date of ownership for rights to the dividend. (provider: tmx) payment_date : Optional[date] - Payment date of the historical dividends. (provider: fmp) + Payment date of the historical dividends. (provider: fmp); + The payment date of the dividend. (provider: nasdaq); + The date the dividend is paid. (provider: tmx) declaration_date : Optional[date] - Declaration date of the historical dividends. (provider: fmp) + Declaration date of the historical dividends. (provider: fmp, nasdaq) factor : Optional[float] factor by which to multiply stock prices before this date, in order to calculate historically-adjusted stock prices. (provider: intrinio) currency : Optional[str] - The currency in which the dividend is paid. (provider: intrinio) + The currency in which the dividend is paid. (provider: intrinio, nasdaq, tmx) split_ratio : Optional[float] The ratio of the stock split, if a stock split occurred. (provider: intrinio) + dividend_type : Optional[str] + The type of dividend - i.e., cash, stock. (provider: nasdaq) + decalaration_date : Optional[date] + The date of the announcement. (provider: tmx) Examples -------- @@ -1045,7 +1058,7 @@ def dividends( "provider": self._get_provider( provider, "/equity/fundamental/dividends", - ("fmp", "intrinio", "yfinance"), + ("fmp", "intrinio", "nasdaq", "tmx", "yfinance"), ) }, standard_params={ @@ -1054,6 +1067,7 @@ def dividends( "end_date": end_date, }, extra_params=kwargs, + extra_info={"symbol": {"multiple_items_allowed": ["nasdaq"]}}, ) ) @@ -1153,7 +1167,7 @@ def filings( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["fmp", "intrinio", "sec"]] = None, + provider: Optional[Literal["fmp", "intrinio", "sec", "tmx"]] = None, **kwargs ) -> OBBject: """Get the URLs to SEC filings reported to EDGAR database, such as 10-K, 10-Q, 8-K, and more. SEC @@ -1171,14 +1185,16 @@ def filings( Filter by form type. Check the data provider for available types. limit : int The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio', 'sec']] + provider : Optional[Literal['fmp', 'intrinio', 'sec', 'tmx']] 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. start_date : Optional[datetime.date] - Start date of the data, in YYYY-MM-DD format. (provider: intrinio) + Start date of the data, in YYYY-MM-DD format. (provider: intrinio); + The start date to fetch. (provider: tmx) end_date : Optional[datetime.date] - End date of the data, in YYYY-MM-DD format. (provider: intrinio) + End date of the data, in YYYY-MM-DD format. (provider: intrinio); + The end date to fetch. (provider: tmx) thea_enabled : Optional[bool] Return filings that have been read by Intrinio's Thea NLP. (provider: intrinio) cik : Optional[Union[int, str]] @@ -1193,7 +1209,7 @@ def filings( OBBject results : List[CompanyFilings] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'sec']] + provider : Optional[Literal['fmp', 'intrinio', 'sec', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1251,11 +1267,14 @@ def filings( is_xbrl : Optional[Union[int, str]] Whether the filing is an XBRL filing. (provider: sec) size : Optional[Union[int, str]] - The size of the filing. (provider: sec) + The size of the filing. (provider: sec); + The file size of the PDF document. (provider: tmx) complete_submission_url : Optional[str] The URL to the complete filing submission. (provider: sec) filing_detail_url : Optional[str] The URL to the filing details. (provider: sec) + description : Optional[str] + The description of the filing. (provider: tmx) Examples -------- @@ -1271,7 +1290,7 @@ def filings( "provider": self._get_provider( provider, "/equity/fundamental/filings", - ("fmp", "intrinio", "sec"), + ("fmp", "intrinio", "sec", "tmx"), ) }, standard_params={ @@ -1419,30 +1438,35 @@ def historical_attributes( def historical_eps( self, symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") + Union[str, List[str]], + OpenBBCustomParameter( + description="Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage." + ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["alpha_vantage", "fmp"]] = None, **kwargs ) -> OBBject: """Get historical earnings per share data for a given company. Parameters ---------- - symbol : str - Symbol to get data for. - provider : Optional[Literal['fmp']] + symbol : Union[str, List[str]] + Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage. + provider : Optional[Literal['alpha_vantage', 'fmp']] 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. + period : Literal['annual', 'quarter'] + Time period of the data to return. (provider: alpha_vantage) limit : Optional[int] - The number of data entries to return. (provider: fmp) + The number of data entries to return. (provider: alpha_vantage, fmp) Returns ------- OBBject results : List[HistoricalEps] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['alpha_vantage', 'fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1463,6 +1487,12 @@ def historical_eps( Actual EPS from the earnings date. eps_estimated : Optional[float] Estimated EPS for the earnings date. + surprise : Optional[float] + Surprise in EPS (Actual - Estimated). (provider: alpha_vantage) + surprise_percent : Optional[Union[float, str]] + EPS surprise as a normalized percent. (provider: alpha_vantage) + reported_date : Optional[date] + Date of the earnings report. (provider: alpha_vantage) revenue_estimated : Optional[float] Estimated consensus revenue for the reporting period. (provider: fmp) revenue_actual : Optional[float] @@ -1487,13 +1517,14 @@ def historical_eps( "provider": self._get_provider( provider, "/equity/fundamental/historical_eps", - ("fmp",), + ("alpha_vantage", "fmp"), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, + extra_info={"symbol": {"multiple_items_allowed": ["alpha_vantage"]}}, ) ) @@ -2337,7 +2368,7 @@ def metrics( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp, yfinance." ), ], period: Annotated[ @@ -2348,7 +2379,7 @@ def metrics( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Optional[Literal["finviz", "fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: """Get fundamental metrics for a given company. @@ -2356,14 +2387,14 @@ def metrics( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fmp, yfinance. + Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp, yfinance. period : Optional[Literal['annual', 'quarter']] Time period of the data to return. limit : Optional[int] The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] + provider : Optional[Literal['finviz', 'fmp', 'intrinio', 'yfinance']] 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 'finviz' if there is no default. with_ttm : Optional[bool] Include trailing twelve months (TTM) data. (provider: fmp) @@ -2373,7 +2404,7 @@ def metrics( OBBject results : Union[List[KeyMetrics], KeyMetrics] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] + provider : Optional[Literal['finviz', 'fmp', 'intrinio', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2390,6 +2421,53 @@ def metrics( Market capitalization pe_ratio : Optional[float] Price-to-earnings ratio (P/E ratio) + foward_pe : Optional[float] + Forward price-to-earnings ratio (forward P/E) (provider: finviz) + eps : Optional[float] + Earnings per share (EPS) (provider: finviz) + price_to_sales : Optional[float] + Price-to-sales ratio (P/S) (provider: finviz) + price_to_book : Optional[float] + Price-to-book ratio (P/B) (provider: finviz, yfinance) + book_value_per_share : Optional[float] + Book value per share (Book/sh) (provider: finviz); + Book value per share (provider: fmp) + price_to_cash : Optional[float] + Price-to-cash ratio (P/C) (provider: finviz) + cash_per_share : Optional[float] + Cash per share (Cash/sh) (provider: finviz); + Cash per share (provider: fmp); + Cash per share. (provider: yfinance) + price_to_free_cash_flow : Optional[float] + Price-to-free cash flow ratio (P/FCF) (provider: finviz) + debt_to_equity : Optional[float] + Debt-to-equity ratio (Debt/Eq) (provider: finviz); + Debt-to-equity ratio (provider: fmp); + Debt-to-equity ratio. (provider: yfinance) + long_term_debt_to_equity : Optional[float] + Long-term debt-to-equity ratio (LT Debt/Eq) (provider: finviz) + quick_ratio : Optional[float] + Quick ratio (provider: finviz, yfinance) + current_ratio : Optional[float] + Current ratio (provider: finviz, fmp, yfinance) + gross_margin : Optional[float] + Gross margin, as a normalized percent. (provider: finviz, yfinance) + profit_margin : Optional[float] + Profit margin, as a normalized percent. (provider: finviz, yfinance) + operating_margin : Optional[float] + Operating margin, as a normalized percent. (provider: finviz, yfinance) + return_on_assets : Optional[float] + Return on assets (ROA), as a normalized percent. (provider: finviz, yfinance) + return_on_investment : Optional[float] + Return on investment (ROI), as a normalized percent. (provider: finviz) + return_on_equity : Optional[float] + Return on equity (ROE), as a normalized percent. (provider: finviz, yfinance) + payout_ratio : Optional[float] + Payout ratio, as a normalized percent. (provider: finviz); + Payout ratio (provider: fmp); + Payout ratio. (provider: yfinance) + dividend_yield : Optional[float] + Dividend yield, as a normalized percent. (provider: finviz, fmp, intrinio, yfinance) date : Optional[date] The date of the data. (provider: fmp) period : Optional[str] @@ -2404,10 +2482,6 @@ def metrics( Operating cash flow per share (provider: fmp) free_cash_flow_per_share : Optional[float] Free cash flow per share (provider: fmp) - cash_per_share : Optional[float] - Cash per share (provider: fmp, yfinance) - book_value_per_share : Optional[float] - Book value per share (provider: fmp) tangible_book_value_per_share : Optional[float] Tangible book value per share (provider: fmp) shareholders_equity_per_share : Optional[float] @@ -2438,22 +2512,14 @@ def metrics( Earnings yield (provider: fmp) free_cash_flow_yield : Optional[float] Free cash flow yield (provider: fmp) - debt_to_equity : Optional[float] - Debt-to-equity ratio (provider: fmp, yfinance) debt_to_assets : Optional[float] Debt-to-assets ratio (provider: fmp) net_debt_to_ebitda : Optional[float] Net debt-to-EBITDA ratio (provider: fmp) - current_ratio : Optional[float] - Current ratio (provider: fmp, yfinance) interest_coverage : Optional[float] Interest coverage (provider: fmp) income_quality : Optional[float] Income quality (provider: fmp) - dividend_yield : Optional[float] - Dividend yield, as a normalized percent. (provider: fmp, intrinio, yfinance) - payout_ratio : Optional[float] - Payout ratio (provider: fmp, yfinance) sales_general_and_administrative_to_revenue : Optional[float] Sales general and administrative expenses-to-revenue ratio (provider: fmp) research_and_development_to_revenue : Optional[float] @@ -2535,26 +2601,12 @@ def metrics( Revenue growth (Year Over Year), as a normalized percent. (provider: yfinance) enterprise_to_revenue : Optional[float] Enterprise value to revenue ratio. (provider: yfinance) - quick_ratio : Optional[float] - Quick ratio. (provider: yfinance) - gross_margin : Optional[float] - Gross margin, as a normalized percent. (provider: yfinance) - operating_margin : Optional[float] - Operating margin, as a normalized percent. (provider: yfinance) ebitda_margin : Optional[float] EBITDA margin, as a normalized percent. (provider: yfinance) - profit_margin : Optional[float] - Profit margin, as a normalized percent. (provider: yfinance) - return_on_assets : Optional[float] - Return on assets, as a normalized percent. (provider: yfinance) - return_on_equity : Optional[float] - Return on equity, as a normalized percent. (provider: yfinance) dividend_yield_5y_avg : Optional[float] 5-year average dividend yield, as a normalized percent. (provider: yfinance) book_value : Optional[float] Book value per share. (provider: yfinance) - price_to_book : Optional[float] - Price-to-book ratio. (provider: yfinance) overall_risk : Optional[float] Overall risk score. (provider: yfinance) audit_risk : Optional[float] @@ -2584,7 +2636,7 @@ def metrics( "provider": self._get_provider( provider, "/equity/fundamental/metrics", - ("fmp", "intrinio", "yfinance"), + ("finviz", "fmp", "intrinio", "yfinance"), ) }, standard_params={ @@ -2593,7 +2645,9 @@ def metrics( "limit": limit, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp", "yfinance"]}}, + extra_info={ + "symbol": {"multiple_items_allowed": ["finviz", "fmp", "yfinance"]} + }, ) ) diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index 4a9da4db311d..a4f65eb44d28 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -152,7 +152,7 @@ def insider_trading( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 500, - provider: Optional[Literal["fmp", "intrinio"]] = None, + provider: Optional[Literal["fmp", "intrinio", "tmx"]] = None, **kwargs ) -> OBBject: """Get data about trading by a company's management team and board of directors. @@ -163,7 +163,7 @@ def insider_trading( Symbol to get data for. limit : int The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio']] + provider : Optional[Literal['fmp', 'intrinio', 'tmx']] 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. @@ -177,13 +177,15 @@ def insider_trading( Type of ownership. (provider: intrinio) sort_by : Optional[Literal['filing_date', 'updated_on']] Field to sort by. (provider: intrinio) + summary : bool + Return a summary of the insider activity instead of the individuals. (provider: tmx) Returns ------- OBBject results : List[InsiderTrading] Serializable results. - provider : Optional[Literal['fmp', 'intrinio']] + provider : Optional[Literal['fmp', 'intrinio', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -236,7 +238,7 @@ def insider_trading( Expiration date of the derivative. (provider: intrinio) underlying_security_title : Optional[str] Name of the underlying non-derivative security related to this derivative transaction. (provider: intrinio) - underlying_shares : Optional[Union[float, int]] + underlying_shares : Optional[Union[int, float]] Number of underlying shares related to this derivative transaction. (provider: intrinio) nature_of_ownership : Optional[str] Nature of ownership of the insider trading. (provider: intrinio) @@ -252,6 +254,20 @@ def insider_trading( Whether the owner is having a derivative transaction. (provider: intrinio) report_line_number : Optional[int] Report line number of the insider trading. (provider: intrinio) + period : Optional[str] + The period of the activity. Bucketed by three, six, and twelve months. (provider: tmx) + acquisition_or_deposition : Optional[str] + Whether the insider bought or sold the shares. (provider: tmx) + number_of_trades : Optional[int] + The number of shares traded over the period. (provider: tmx) + trade_value : Optional[float] + The value of the shares traded by the insider. (provider: tmx) + securities_bought : Optional[int] + The total number of shares bought by all insiders over the period. (provider: tmx) + securities_sold : Optional[int] + The total number of shares sold by all insiders over the period. (provider: tmx) + net_activity : Optional[int] + The total net activity by all insiders over the period. (provider: tmx) Examples -------- @@ -267,7 +283,7 @@ def insider_trading( "provider": self._get_provider( provider, "/equity/ownership/insider_trading", - ("fmp", "intrinio"), + ("fmp", "intrinio", "tmx"), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py index ef05fd937a37..01c9cbbdd063 100644 --- a/openbb_platform/openbb/package/equity_price.py +++ b/openbb_platform/openbb/package/equity_price.py @@ -29,7 +29,7 @@ def historical( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, yfinance." ), ], interval: Annotated[ @@ -48,8 +48,18 @@ def historical( description="End date of the data, in YYYY-MM-DD format." ), ] = None, + chart: bool = False, provider: Optional[ - Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"] + Literal[ + "alpha_vantage", + "cboe", + "fmp", + "intrinio", + "polygon", + "tiingo", + "tmx", + "yfinance", + ] ] = None, **kwargs ) -> OBBject: @@ -58,17 +68,30 @@ def historical( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance. + Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, yfinance. interval : Optional[str] Time interval of the data to return. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinanc... + chart : bool + Whether to create a chart or not, by default False. + provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'pol... 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. + adjustment : Union[Literal['splits_only', 'splits_and_dividends', 'unadjusted'], Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']] + The adjustment factor to apply. 'splits_only' is not supported for intraday data. (provider: alpha_vantage); + The adjustment factor to apply. Default is splits only. (provider: polygon); + The adjustment factor to apply. Only valid for daily data. (provider: tmx); + The adjustment factor to apply. Default is splits only. (provider: yfinance) + extended_hours : Optional[bool] + Include Pre and Post market data. (provider: alpha_vantage, polygon, yfinance) + adjusted : bool + This field is deprecated (4.1.5) and will be removed in a future version. Use 'adjustment' set as 'splits_and_dividends' instead. (provider: alpha_vantage, yfinance) + use_cache : bool + When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe) start_time : Optional[datetime.time] Return intervals starting at the specified time on the `start_date` formatted as 'HH:MM:SS'. (provider: intrinio) end_time : Optional[datetime.time] @@ -77,23 +100,21 @@ def historical( Timezone of the data, in the IANA format (Continent/City). (provider: intrinio) source : Literal['realtime', 'delayed', 'nasdaq_basic'] The source of the data. (provider: intrinio) - adjustment : Union[Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']] - The adjustment factor to apply. Default is splits only. (provider: polygon, yfinance) - extended_hours : bool - Include Pre and Post market data. (provider: polygon, yfinance) sort : Literal['asc', 'desc'] Sort order of the data. This impacts the results in combination with the 'limit' parameter. The results are always returned in ascending order by date. (provider: polygon) limit : int The number of data entries to return. (provider: polygon) include_actions : bool Include dividends and stock splits in results. (provider: yfinance) + prepost : bool + This field is deprecated (4.1.5) and will be removed in a future version. Use 'extended_hours' as True instead. (provider: yfinance) Returns ------- OBBject results : List[EquityHistorical] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance']] + provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygon', 'tiingo', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -118,16 +139,31 @@ def historical( The trading volume. vwap : Optional[float] Volume Weighted Average Price over the period. - adj_close : Optional[float] - The adjusted close price. (provider: fmp, intrinio, tiingo) + adj_close : Optional[Union[Annotated[float, Gt(gt=0)], float]] + The adjusted close price. (provider: alpha_vantage, fmp, intrinio, tiingo) + dividend : Optional[Union[Annotated[float, Ge(ge=0)], float]] + Dividend amount, if a dividend was paid. (provider: alpha_vantage, intrinio, tiingo, yfinance) + split_ratio : Optional[Union[Annotated[float, Ge(ge=0)], float]] + Split coefficient, if a split occurred. (provider: alpha_vantage); + Ratio of the equity split, if a split occurred. (provider: intrinio); + Ratio of the equity split, if a split occurred. (provider: tiingo); + Ratio of the equity split, if a split occurred. (provider: yfinance) + calls_volume : Optional[int] + Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + puts_volume : Optional[int] + Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + total_options_volume : Optional[int] + Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) unadjusted_volume : Optional[float] Unadjusted volume of the symbol. (provider: fmp) change : Optional[float] Change in the price from the previous close. (provider: fmp); - Change in the price of the symbol from the previous day. (provider: intrinio) + Change in the price of the symbol from the previous day. (provider: intrinio); + Change in price. (provider: tmx) change_percent : Optional[float] Change in the price from the previous close, as a normalized percent. (provider: fmp); - Percent change in the price of the symbol from the previous day. (provider: intrinio) + Percent change in the price of the symbol from the previous day. (provider: intrinio); + Change in price, as a normalized percentage. (provider: tmx) average : Optional[float] Average trade price of an individual equity during the interval. (provider: intrinio) adj_open : Optional[float] @@ -144,18 +180,17 @@ def historical( 52 week low price for the symbol. (provider: intrinio) factor : Optional[float] factor by which to multiply equity prices before this date, in order to calculate historically-adjusted equity prices. (provider: intrinio) - split_ratio : Optional[float] - Ratio of the equity split, if a split occurred. (provider: intrinio, tiingo, yfinance) - dividend : Optional[float] - Dividend amount, if a dividend was paid. (provider: intrinio, tiingo, yfinance) close_time : Optional[datetime] The timestamp that represents the end of the interval span. (provider: intrinio) interval : Optional[str] The data time frequency. (provider: intrinio) intra_period : Optional[bool] If true, the equity price represents an unfinished period (be it day, week, quarter, month, or year), meaning that the close price is the latest price available, not the official close price for the period (provider: intrinio) - transactions : Optional[Annotated[int, Gt(gt=0)]] - Number of transactions for the symbol in the time period. (provider: polygon) + transactions : Optional[Union[Annotated[int, Gt(gt=0)], int]] + Number of transactions for the symbol in the time period. (provider: polygon); + Total number of transactions recorded. (provider: tmx) + transactions_value : Optional[float] + Nominal value of recorded transactions. (provider: tmx) Examples -------- @@ -171,7 +206,16 @@ def historical( "provider": self._get_provider( provider, "/equity/price/historical", - ("fmp", "intrinio", "polygon", "tiingo", "yfinance"), + ( + "alpha_vantage", + "cboe", + "fmp", + "intrinio", + "polygon", + "tiingo", + "tmx", + "yfinance", + ), ) }, standard_params={ @@ -181,12 +225,16 @@ def historical( "end_date": end_date, }, extra_params=kwargs, + chart=chart, extra_info={ "symbol": { "multiple_items_allowed": [ + "alpha_vantage", + "cboe", "fmp", "polygon", "tiingo", + "tmx", "yfinance", ] } @@ -331,10 +379,10 @@ def performance( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp." + description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["finviz", "fmp"]] = None, **kwargs ) -> OBBject: """Get price performance data for a given stock. This includes price changes for different time periods. @@ -342,10 +390,10 @@ def performance( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fmp. - provider : Optional[Literal['fmp']] + Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp. + provider : Optional[Literal['finviz', 'fmp']] 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 'finviz' if there is no default. Returns @@ -353,7 +401,7 @@ def performance( OBBject results : List[PricePerformance] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['finviz', 'fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -392,8 +440,22 @@ def performance( Ten-year return. max : Optional[float] Return from the beginning of the time series. + volatility_week : Optional[float] + One-week realized volatility, as a normalized percent. (provider: finviz) + volatility_month : Optional[float] + One-month realized volatility, as a normalized percent. (provider: finviz) + price : Optional[float] + Last Price. (provider: finviz) + volume : Optional[float] + Current volume. (provider: finviz) + average_volume : Optional[float] + Average daily volume. (provider: finviz) + relative_volume : Optional[float] + Relative volume as a ratio of current volume to average volume. (provider: finviz) + analyst_recommendation : Optional[float] + The analyst consensus, on a scale of 1-5 where 1 is a buy and 5 is a sell. (provider: finviz) symbol : Optional[str] - The ticker symbol. (provider: fmp) + The ticker symbol. (provider: finviz, fmp) Examples -------- @@ -408,14 +470,14 @@ def performance( "provider": self._get_provider( provider, "/equity/price/performance", - ("fmp",), + ("finviz", "fmp"), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["finviz", "fmp"]}}, ) ) @@ -426,10 +488,12 @@ def quote( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance." + description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): cboe, fmp, intrinio, tmx, yfinance." ), ], - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Optional[ + Literal["cboe", "fmp", "intrinio", "tmx", "yfinance"] + ] = None, **kwargs ) -> OBBject: """Get the latest quote for a given stock. Quote includes price, volume, and other data. @@ -437,11 +501,13 @@ def quote( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance. - provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] + Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): cboe, fmp, intrinio, tmx, yfinance. + provider : Optional[Literal['cboe', 'fmp', 'intrinio', 'tmx', 'yfinance']] 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. + use_cache : bool + When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe) source : Literal['iex', 'bats', 'bats_delayed', 'utp_delayed', 'cta_a_delayed', 'cta_b_delayed', 'intrinio_mx', 'intrinio_mx_plus', 'delayed_sip'] Source of the data. (provider: intrinio) @@ -450,7 +516,7 @@ def quote( OBBject results : List[EquityQuote] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] + provider : Optional[Literal['cboe', 'fmp', 'intrinio', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -513,9 +579,9 @@ def quote( The low price. close : Optional[float] The close price. - volume : Optional[Union[float, int]] + volume : Optional[Union[int, float]] The trading volume. - exchange_volume : Optional[Union[float, int]] + exchange_volume : Optional[Union[int, float]] Volume of shares exchanged during the trading day on the specific exchange. prev_close : Optional[float] The previous close price. @@ -527,20 +593,51 @@ def quote( The one year high (52W High). year_low : Optional[float] The one year low (52W Low). + iv30 : Optional[float] + The 30-day implied volatility of the stock. (provider: cboe) + iv30_change : Optional[float] + Change in 30-day implied volatility of the stock. (provider: cboe) + iv30_change_percent : Optional[float] + Change in 30-day implied volatility of the stock as a normalized percentage value. (provider: cboe) + iv30_annual_high : Optional[float] + The 1-year high of 30-day implied volatility. (provider: cboe) + hv30_annual_high : Optional[float] + The 1-year high of 30-day realized volatility. (provider: cboe) + iv30_annual_low : Optional[float] + The 1-year low of 30-day implied volatility. (provider: cboe) + hv30_annual_low : Optional[float] + The 1-year low of 30-dayrealized volatility. (provider: cboe) + iv60_annual_high : Optional[float] + The 1-year high of 60-day implied volatility. (provider: cboe) + hv60_annual_high : Optional[float] + The 1-year high of 60-day realized volatility. (provider: cboe) + iv60_annual_low : Optional[float] + The 1-year low of 60-day implied volatility. (provider: cboe) + hv60_annual_low : Optional[float] + The 1-year low of 60-day realized volatility. (provider: cboe) + iv90_annual_high : Optional[float] + The 1-year high of 90-day implied volatility. (provider: cboe) + hv90_annual_high : Optional[float] + The 1-year high of 90-day realized volatility. (provider: cboe) + iv90_annual_low : Optional[float] + The 1-year low of 90-day implied volatility. (provider: cboe) + hv90_annual_low : Optional[float] + The 1-year low of 90-day realized volatility. (provider: cboe) price_avg50 : Optional[float] 50 day moving average price. (provider: fmp) price_avg200 : Optional[float] 200 day moving average price. (provider: fmp) avg_volume : Optional[int] Average volume over the last 10 trading days. (provider: fmp) - market_cap : Optional[float] - Market cap of the company. (provider: fmp) + market_cap : Optional[Union[float, int]] + Market cap of the company. (provider: fmp); + Market capitalization. (provider: tmx) shares_outstanding : Optional[int] - Number of shares outstanding. (provider: fmp) - eps : Optional[float] - Earnings per share. (provider: fmp) - pe : Optional[float] - Price earnings ratio. (provider: fmp) + Number of shares outstanding. (provider: fmp, tmx) + eps : Optional[Union[float, str]] + Earnings per share. (provider: fmp, tmx) + pe : Optional[Union[float, str]] + Price earnings ratio. (provider: fmp, tmx) earnings_announcement : Optional[Union[datetime, str]] Upcoming earnings announcement date. (provider: fmp) is_darkpool : Optional[bool] @@ -551,6 +648,64 @@ def quote( Date and Time when the data was last updated. (provider: intrinio) security : Optional[openbb_intrinio.utils.references.IntrinioSecurity] Security details related to the quote. (provider: intrinio) + security_type : Optional[str] + The issuance type of the asset. (provider: tmx) + sector : Optional[str] + The sector of the asset. (provider: tmx) + industry_category : Optional[str] + The industry category of the asset. (provider: tmx) + industry_group : Optional[str] + The industry group of the asset. (provider: tmx) + vwap : Optional[float] + Volume Weighted Average Price over the period. (provider: tmx) + ma_21 : Optional[float] + Twenty-one day moving average. (provider: tmx) + ma_50 : Optional[float] + Fifty day moving average. (provider: tmx) + ma_200 : Optional[float] + Two-hundred day moving average. (provider: tmx) + volume_avg_10d : Optional[int] + Ten day average volume. (provider: tmx) + volume_avg_30d : Optional[int] + Thirty day average volume. (provider: tmx) + volume_avg_50d : Optional[int] + Fifty day average volume. (provider: tmx) + market_cap_all_classes : Optional[int] + Market capitalization of all share classes. (provider: tmx) + div_amount : Optional[float] + The most recent dividend amount. (provider: tmx) + div_currency : Optional[str] + The currency the dividend is paid in. (provider: tmx) + div_yield : Optional[float] + The dividend yield as a normalized percentage. (provider: tmx) + div_freq : Optional[str] + The frequency of dividend payments. (provider: tmx) + div_ex_date : Optional[date] + The ex-dividend date. (provider: tmx) + div_pay_date : Optional[date] + The next dividend ayment date. (provider: tmx) + div_growth_3y : Optional[Union[str, float]] + The three year dividend growth as a normalized percentage. (provider: tmx) + div_growth_5y : Optional[Union[str, float]] + The five year dividend growth as a normalized percentage. (provider: tmx) + debt_to_equity : Optional[Union[str, float]] + The debt to equity ratio. (provider: tmx) + price_to_book : Optional[Union[str, float]] + The price to book ratio. (provider: tmx) + price_to_cf : Optional[Union[str, float]] + The price to cash flow ratio. (provider: tmx) + return_on_equity : Optional[Union[str, float]] + The return on equity, as a normalized percentage. (provider: tmx) + return_on_assets : Optional[Union[str, float]] + The return on assets, as a normalized percentage. (provider: tmx) + beta : Optional[Union[str, float]] + The beta relative to the TSX Composite. (provider: tmx) + alpha : Optional[Union[str, float]] + The alpha relative to the TSX Composite. (provider: tmx) + shares_escrow : Optional[int] + The number of shares held in escrow. (provider: tmx) + shares_total : Optional[int] + The total number of shares outstanding from all classes. (provider: tmx) ma_50d : Optional[float] 50-day moving average price. (provider: yfinance) ma_200d : Optional[float] @@ -575,7 +730,7 @@ def quote( "provider": self._get_provider( provider, "/equity/price/quote", - ("fmp", "intrinio", "yfinance"), + ("cboe", "fmp", "intrinio", "tmx", "yfinance"), ) }, standard_params={ @@ -584,7 +739,13 @@ def quote( extra_params=kwargs, extra_info={ "symbol": { - "multiple_items_allowed": ["fmp", "intrinio", "yfinance"] + "multiple_items_allowed": [ + "cboe", + "fmp", + "intrinio", + "tmx", + "yfinance", + ] } }, ) diff --git a/openbb_platform/openbb/package/equity_shorts.py b/openbb_platform/openbb/package/equity_shorts.py index 23fcded89cfd..22cc66fa55d8 100644 --- a/openbb_platform/openbb/package/equity_shorts.py +++ b/openbb_platform/openbb/package/equity_shorts.py @@ -13,6 +13,8 @@ class ROUTER_equity_shorts(Container): """/equity/shorts fails_to_deliver + short_interest + short_volume """ def __repr__(self) -> str: @@ -99,3 +101,159 @@ def fails_to_deliver( extra_params=kwargs, ) ) + + @exception_handler + @validate + def short_interest( + self, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + provider: Optional[Literal["finra"]] = None, + **kwargs + ) -> OBBject: + """Get reported short volume and days to cover data. + + Parameters + ---------- + symbol : str + Symbol to get data for. + provider : Optional[Literal['finra']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'finra' if there is + no default. + + Returns + ------- + OBBject + results : List[EquityShortInterest] + Serializable results. + provider : Optional[Literal['finra']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + EquityShortInterest + ------------------- + settlement_date : date + The mid-month short interest report is based on short positions held by members on the settlement date of the 15th of each month. If the 15th falls on a weekend or another non-settlement date, the designated settlement date will be the previous business day on which transactions settled. The end-of-month short interest report is based on short positions held on the last business day of the month on which transactions settle. Once the short position reports are received, the short interest data is compiled for each equity security and provided for publication on the 7th business day after the reporting settlement date. + symbol : str + Symbol representing the entity requested in the data. + issue_name : str + Unique identifier of the issue. + market_class : str + Primary listing market. + current_short_position : float + The total number of shares in the issue that are reflected on the books and records of the reporting firms as short as defined by Rule 200 of Regulation SHO as of the current cycle’s designated settlement date. + previous_short_position : float + The total number of shares in the issue that are reflected on the books and records of the reporting firms as short as defined by Rule 200 of Regulation SHO as of the previous cycle’s designated settlement date. + avg_daily_volume : float + Total Volume or Adjusted Volume in case of splits / Total trade days between (previous settlement date + 1) to (current settlement date). The NULL values are translated as zero. + days_to_cover : float + The number of days of average share volume it would require to buy all of the shares that were sold short during the reporting cycle. Formula: Short Interest / Average Daily Share Volume, Rounded to Hundredths. 1.00 will be displayed for any values equal or less than 1 (i.e., Average Daily Share is equal to or greater than Short Interest). N/A will be displayed If the days to cover is Zero (i.e., Average Daily Share Volume is Zero). + change : float + Change in Shares Short from Previous Cycle: Difference in short interest between the current cycle and the previous cycle. + change_pct : float + Change in Shares Short from Previous Cycle as a percent. + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.shorts.short_interest(symbol='AAPL') + """ # noqa: E501 + + return self._run( + "/equity/shorts/short_interest", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/equity/shorts/short_interest", + ("finra",), + ) + }, + standard_params={ + "symbol": symbol, + }, + extra_params=kwargs, + ) + ) + + @exception_handler + @validate + def short_volume( + self, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + provider: Optional[Literal["stockgrid"]] = None, + **kwargs + ) -> OBBject: + """Get reported Fail-to-deliver (FTD) data. + + Parameters + ---------- + symbol : str + Symbol to get data for. + provider : Optional[Literal['stockgrid']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'stockgrid' if there is + no default. + + Returns + ------- + OBBject + results : List[ShortVolume] + Serializable results. + provider : Optional[Literal['stockgrid']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + ShortVolume + ----------- + date : Optional[date] + The date of the data. + market : Optional[str] + Reporting Facility ID. N=NYSE TRF, Q=NASDAQ TRF Carteret, B=NASDAQ TRY Chicago, D=FINRA ADF + short_volume : Optional[int] + Aggregate reported share volume of executed short sale and short sale exempt trades during regular trading hours + short_exempt_volume : Optional[int] + Aggregate reported share volume of executed short sale exempt trades during regular trading hours + total_volume : Optional[int] + Aggregate reported share volume of executed trades during regular trading hours + close : Optional[float] + Closing price of the stock on the date. (provider: stockgrid) + short_volume_percent : Optional[float] + Percentage of the total volume that was short volume. (provider: stockgrid) + + Examples + -------- + >>> from openbb import obb + >>> obb.equity.shorts.short_volume(symbol='AAPL') + """ # noqa: E501 + + return self._run( + "/equity/shorts/short_volume", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/equity/shorts/short_volume", + ("stockgrid",), + ) + }, + standard_params={ + "symbol": symbol, + }, + extra_params=kwargs, + ) + ) diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index 2d7c06fc322f..caefcf87d805 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -14,6 +14,7 @@ class ROUTER_etf(Container): """/etf countries + /discovery equity_exposure historical holdings @@ -35,10 +36,10 @@ def countries( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp." + description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, tmx." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["fmp", "tmx"]] = None, **kwargs ) -> OBBject: """ETF Country weighting. @@ -46,18 +47,20 @@ def countries( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp. - provider : Optional[Literal['fmp']] + Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, tmx. + provider : Optional[Literal['fmp', 'tmx']] 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. + use_cache : bool + Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfCountries] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -84,17 +87,24 @@ def countries( "provider": self._get_provider( provider, "/etf/countries", - ("fmp",), + ("fmp", "tmx"), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["fmp", "tmx"]}}, ) ) + @property + def discovery(self): + # pylint: disable=import-outside-toplevel + from . import etf_discovery + + return etf_discovery.ROUTER_etf_discovery(command_runner=self._command_runner) + @exception_handler @validate def equity_exposure( @@ -143,7 +153,7 @@ def equity_exposure( The number of shares held in the ETF. weight : Optional[float] The weight of the equity in the ETF, as a normalized percent. - market_value : Optional[Union[float, int]] + market_value : Optional[Union[int, float]] The market value of the equity position in the ETF. Examples @@ -179,7 +189,7 @@ def historical( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, yfinance." ), ], interval: Annotated[ @@ -199,7 +209,16 @@ def historical( ), ] = None, provider: Optional[ - Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"] + Literal[ + "alpha_vantage", + "cboe", + "fmp", + "intrinio", + "polygon", + "tiingo", + "tmx", + "yfinance", + ] ] = None, **kwargs ) -> OBBject: @@ -208,17 +227,28 @@ def historical( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance. + Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, yfinance. interval : Optional[str] Time interval of the data to return. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinanc... + provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'pol... 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. + adjustment : Union[Literal['splits_only', 'splits_and_dividends', 'unadjusted'], Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']] + The adjustment factor to apply. 'splits_only' is not supported for intraday data. (provider: alpha_vantage); + The adjustment factor to apply. Default is splits only. (provider: polygon); + The adjustment factor to apply. Only valid for daily data. (provider: tmx); + The adjustment factor to apply. Default is splits only. (provider: yfinance) + extended_hours : Optional[bool] + Include Pre and Post market data. (provider: alpha_vantage, polygon, yfinance) + adjusted : bool + This field is deprecated (4.1.5) and will be removed in a future version. Use 'adjustment' set as 'splits_and_dividends' instead. (provider: alpha_vantage, yfinance) + use_cache : bool + When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe) start_time : Optional[datetime.time] Return intervals starting at the specified time on the `start_date` formatted as 'HH:MM:SS'. (provider: intrinio) end_time : Optional[datetime.time] @@ -227,23 +257,21 @@ def historical( Timezone of the data, in the IANA format (Continent/City). (provider: intrinio) source : Literal['realtime', 'delayed', 'nasdaq_basic'] The source of the data. (provider: intrinio) - adjustment : Union[Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']] - The adjustment factor to apply. Default is splits only. (provider: polygon, yfinance) - extended_hours : bool - Include Pre and Post market data. (provider: polygon, yfinance) sort : Literal['asc', 'desc'] Sort order of the data. This impacts the results in combination with the 'limit' parameter. The results are always returned in ascending order by date. (provider: polygon) limit : int The number of data entries to return. (provider: polygon) include_actions : bool Include dividends and stock splits in results. (provider: yfinance) + prepost : bool + This field is deprecated (4.1.5) and will be removed in a future version. Use 'extended_hours' as True instead. (provider: yfinance) Returns ------- OBBject results : List[EtfHistorical] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance']] + provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygon', 'tiingo', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -268,16 +296,31 @@ def historical( The trading volume. vwap : Optional[float] Volume Weighted Average Price over the period. - adj_close : Optional[float] - The adjusted close price. (provider: fmp, intrinio, tiingo) + adj_close : Optional[Union[Annotated[float, Gt(gt=0)], float]] + The adjusted close price. (provider: alpha_vantage, fmp, intrinio, tiingo) + dividend : Optional[Union[Annotated[float, Ge(ge=0)], float]] + Dividend amount, if a dividend was paid. (provider: alpha_vantage, intrinio, tiingo, yfinance) + split_ratio : Optional[Union[Annotated[float, Ge(ge=0)], float]] + Split coefficient, if a split occurred. (provider: alpha_vantage); + Ratio of the equity split, if a split occurred. (provider: intrinio); + Ratio of the equity split, if a split occurred. (provider: tiingo); + Ratio of the equity split, if a split occurred. (provider: yfinance) + calls_volume : Optional[int] + Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + puts_volume : Optional[int] + Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + total_options_volume : Optional[int] + Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) unadjusted_volume : Optional[float] Unadjusted volume of the symbol. (provider: fmp) change : Optional[float] Change in the price from the previous close. (provider: fmp); - Change in the price of the symbol from the previous day. (provider: intrinio) + Change in the price of the symbol from the previous day. (provider: intrinio); + Change in price. (provider: tmx) change_percent : Optional[float] Change in the price from the previous close, as a normalized percent. (provider: fmp); - Percent change in the price of the symbol from the previous day. (provider: intrinio) + Percent change in the price of the symbol from the previous day. (provider: intrinio); + Change in price, as a normalized percentage. (provider: tmx) average : Optional[float] Average trade price of an individual equity during the interval. (provider: intrinio) adj_open : Optional[float] @@ -294,18 +337,17 @@ def historical( 52 week low price for the symbol. (provider: intrinio) factor : Optional[float] factor by which to multiply equity prices before this date, in order to calculate historically-adjusted equity prices. (provider: intrinio) - split_ratio : Optional[float] - Ratio of the equity split, if a split occurred. (provider: intrinio, tiingo, yfinance) - dividend : Optional[float] - Dividend amount, if a dividend was paid. (provider: intrinio, tiingo, yfinance) close_time : Optional[datetime] The timestamp that represents the end of the interval span. (provider: intrinio) interval : Optional[str] The data time frequency. (provider: intrinio) intra_period : Optional[bool] If true, the equity price represents an unfinished period (be it day, week, quarter, month, or year), meaning that the close price is the latest price available, not the official close price for the period (provider: intrinio) - transactions : Optional[Annotated[int, Gt(gt=0)]] - Number of transactions for the symbol in the time period. (provider: polygon) + transactions : Optional[Union[Annotated[int, Gt(gt=0)], int]] + Number of transactions for the symbol in the time period. (provider: polygon); + Total number of transactions recorded. (provider: tmx) + transactions_value : Optional[float] + Nominal value of recorded transactions. (provider: tmx) Examples -------- @@ -323,7 +365,16 @@ def historical( "provider": self._get_provider( provider, "/etf/historical", - ("fmp", "intrinio", "polygon", "tiingo", "yfinance"), + ( + "alpha_vantage", + "cboe", + "fmp", + "intrinio", + "polygon", + "tiingo", + "tmx", + "yfinance", + ), ) }, standard_params={ @@ -336,9 +387,12 @@ def historical( extra_info={ "symbol": { "multiple_items_allowed": [ + "alpha_vantage", + "cboe", "fmp", "polygon", "tiingo", + "tmx", "yfinance", ] } @@ -353,7 +407,7 @@ def holdings( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") ], - provider: Optional[Literal["fmp", "sec"]] = None, + provider: Optional[Literal["fmp", "sec", "tmx"]] = None, **kwargs ) -> OBBject: """Get the holdings for an individual ETF. @@ -362,7 +416,7 @@ def holdings( ---------- symbol : str Symbol to get data for. (ETF) - provider : Optional[Literal['fmp', 'sec']] + provider : Optional[Literal['fmp', 'sec', 'tmx']] 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. @@ -372,14 +426,15 @@ def holdings( cik : Optional[str] The CIK of the filing entity. Overrides symbol. (provider: fmp) use_cache : bool - Whether or not to use cache for the request. (provider: sec) + Whether or not to use cache for the request. (provider: sec); + Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfHoldings] Serializable results. - provider : Optional[Literal['fmp', 'sec']] + provider : Optional[Literal['fmp', 'sec', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -409,12 +464,13 @@ def holdings( The type of units. (provider: fmp); The units of the holding. (provider: sec) currency : Optional[str] - The currency of the holding. (provider: fmp, sec) + The currency of the holding. (provider: fmp, sec, tmx) value : Optional[float] The value of the holding, in dollars. (provider: fmp, sec) weight : Optional[float] The weight of the holding, as a normalized percent. (provider: fmp); - The weight of the holding in ETF in %. (provider: sec) + The weight of the holding in ETF in %. (provider: sec); + The weight of the asset in the portfolio, as a normalized percentage. (provider: tmx) payoff_profile : Optional[str] The payoff profile of the holding. (provider: fmp, sec) asset_category : Optional[str] @@ -422,7 +478,7 @@ def holdings( issuer_category : Optional[str] The issuer category of the holding. (provider: fmp, sec) country : Optional[str] - The country of the holding. (provider: fmp, sec) + The country of the holding. (provider: fmp, sec, tmx) is_restricted : Optional[str] Whether the holding is restricted. (provider: fmp, sec) fair_value_level : Optional[int] @@ -551,6 +607,20 @@ def holdings( The currency of the derivative's notional amount. (provider: sec) unrealized_gain : Optional[float] The unrealized gain or loss on the derivative. (provider: sec) + shares : Optional[Union[int, str]] + The value of the assets under management. (provider: tmx) + market_value : Optional[Union[str, float]] + The market value of the holding. (provider: tmx) + share_percentage : Optional[float] + The share percentage of the holding, as a normalized percentage. (provider: tmx) + share_change : Optional[Union[str, float]] + The change in shares of the holding. (provider: tmx) + exchange : Optional[str] + The exchange code of the holding. (provider: tmx) + type_id : Optional[str] + The holding type ID of the asset. (provider: tmx) + fund_id : Optional[str] + The fund ID of the asset. (provider: tmx) Examples -------- @@ -569,7 +639,7 @@ def holdings( "provider": self._get_provider( provider, "/etf/holdings", - ("fmp", "sec"), + ("fmp", "sec", "tmx"), ) }, standard_params={ @@ -651,7 +721,7 @@ def holdings_performance( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp." + description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp." ), ], provider: Optional[Literal["fmp"]] = None, @@ -662,7 +732,7 @@ def holdings_performance( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fmp. + Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp. provider : Optional[Literal['fmp']] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is @@ -735,7 +805,7 @@ def holdings_performance( "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["finviz", "fmp"]}}, ) ) @@ -746,10 +816,10 @@ def info( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance." + description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, tmx, yfinance." ), ], - provider: Optional[Literal["fmp", "yfinance"]] = None, + provider: Optional[Literal["fmp", "tmx", "yfinance"]] = None, **kwargs ) -> OBBject: """ETF Information Overview. @@ -757,18 +827,20 @@ def info( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance. - provider : Optional[Literal['fmp', 'yfinance']] + Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, tmx, yfinance. + provider : Optional[Literal['fmp', 'tmx', 'yfinance']] 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. + use_cache : bool + Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfInfo] Serializable results. - provider : Optional[Literal['fmp', 'yfinance']] + provider : Optional[Literal['fmp', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -788,7 +860,8 @@ def info( inception_date : Optional[str] Inception date of the ETF. issuer : Optional[str] - Company of the ETF. (provider: fmp) + Company of the ETF. (provider: fmp); + The issuer of the ETF. (provider: tmx) cusip : Optional[str] CUSIP of the ETF. (provider: fmp) isin : Optional[str] @@ -798,7 +871,8 @@ def info( asset_class : Optional[str] Asset class of the ETF. (provider: fmp) aum : Optional[float] - Assets under management. (provider: fmp) + Assets under management. (provider: fmp); + The AUM of the ETF. (provider: tmx) nav : Optional[float] Net asset value of the ETF. (provider: fmp) nav_currency : Optional[str] @@ -807,10 +881,57 @@ def info( The expense ratio, as a normalized percent. (provider: fmp) holdings_count : Optional[int] Number of holdings. (provider: fmp) - avg_volume : Optional[float] - Average daily trading volume. (provider: fmp) + avg_volume : Optional[Union[float, int]] + Average daily trading volume. (provider: fmp); + The average daily volume of the ETF. (provider: tmx) website : Optional[str] - Website of the issuer. (provider: fmp) + Website of the issuer. (provider: fmp); + The website of the ETF. (provider: tmx) + investment_style : Optional[str] + The investment style of the ETF. (provider: tmx) + esg : Optional[bool] + Whether the ETF qualifies as an ESG fund. (provider: tmx) + currency : Optional[str] + The currency of the ETF. (provider: tmx); + The currency in which the fund is listed. (provider: yfinance) + unit_price : Optional[float] + The unit price of the ETF. (provider: tmx) + close : Optional[float] + The closing price of the ETF. (provider: tmx) + prev_close : Optional[float] + The previous closing price of the ETF. (provider: tmx, yfinance) + return_1m : Optional[float] + The one-month return of the ETF, as a normalized percent (provider: tmx) + return_3m : Optional[float] + The three-month return of the ETF, as a normalized percent. (provider: tmx) + return_6m : Optional[float] + The six-month return of the ETF, as a normalized percent. (provider: tmx) + return_ytd : Optional[float] + The year-to-date return of the ETF, as a normalized percent. (provider: tmx, yfinance) + return_1y : Optional[float] + The one-year return of the ETF, as a normalized percent. (provider: tmx) + return_3y : Optional[float] + The three-year return of the ETF, as a normalized percent. (provider: tmx) + return_5y : Optional[float] + The five-year return of the ETF, as a normalized percent. (provider: tmx) + return_10y : Optional[float] + The ten-year return of the ETF, as a normalized percent. (provider: tmx) + return_from_inception : Optional[float] + The return from inception of the ETF, as a normalized percent. (provider: tmx) + avg_volume_30d : Optional[int] + The 30-day average volume of the ETF. (provider: tmx) + pe_ratio : Optional[float] + The price-to-earnings ratio of the ETF. (provider: tmx) + pb_ratio : Optional[float] + The price-to-book ratio of the ETF. (provider: tmx) + management_fee : Optional[float] + The management fee of the ETF, as a normalized percent. (provider: tmx) + mer : Optional[float] + The management expense ratio of the ETF, as a normalized percent. (provider: tmx) + distribution_yield : Optional[float] + The distribution yield of the ETF, as a normalized percent. (provider: tmx) + dividend_frequency : Optional[str] + The dividend payment frequency of the ETF. (provider: tmx) fund_type : Optional[str] The legal type of fund. (provider: yfinance) fund_family : Optional[str] @@ -821,8 +942,6 @@ def info( The exchange the fund is listed on. (provider: yfinance) exchange_timezone : Optional[str] The timezone of the exchange. (provider: yfinance) - currency : Optional[str] - The currency in which the fund is listed. (provider: yfinance) nav_price : Optional[float] The net asset value per unit of the fund. (provider: yfinance) total_assets : Optional[int] @@ -843,8 +962,6 @@ def info( 50-day moving average price. (provider: yfinance) ma_200d : Optional[float] 200-day moving average price. (provider: yfinance) - return_ytd : Optional[float] - The year-to-date return of the fund, as a normalized percent. (provider: yfinance) return_3y_avg : Optional[float] The three year average return of the fund, as a normalized percent. (provider: yfinance) return_5y_avg : Optional[float] @@ -871,8 +988,6 @@ def info( The lowest price of the most recent trading session. (provider: yfinance) volume : Optional[int] The trading volume of the most recent trading session. (provider: yfinance) - prev_close : Optional[float] - The previous closing price. (provider: yfinance) Examples -------- @@ -889,14 +1004,16 @@ def info( "provider": self._get_provider( provider, "/etf/info", - ("fmp", "yfinance"), + ("fmp", "tmx", "yfinance"), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp", "yfinance"]}}, + extra_info={ + "symbol": {"multiple_items_allowed": ["fmp", "tmx", "yfinance"]} + }, ) ) @@ -907,10 +1024,10 @@ def price_performance( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): fmp." + description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["finviz", "fmp"]] = None, **kwargs ) -> OBBject: """Price performance as a return, over different periods. This is a proxy for `equity.price.performance`. @@ -918,10 +1035,10 @@ def price_performance( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): fmp. - provider : Optional[Literal['fmp']] + Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp. + provider : Optional[Literal['finviz', 'fmp']] 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 'finviz' if there is no default. Returns @@ -929,7 +1046,7 @@ def price_performance( OBBject results : List[PricePerformance] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['finviz', 'fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -968,8 +1085,22 @@ def price_performance( Ten-year return. max : Optional[float] Return from the beginning of the time series. + volatility_week : Optional[float] + One-week realized volatility, as a normalized percent. (provider: finviz) + volatility_month : Optional[float] + One-month realized volatility, as a normalized percent. (provider: finviz) + price : Optional[float] + Last Price. (provider: finviz) + volume : Optional[float] + Current volume. (provider: finviz) + average_volume : Optional[float] + Average daily volume. (provider: finviz) + relative_volume : Optional[float] + Relative volume as a ratio of current volume to average volume. (provider: finviz) + analyst_recommendation : Optional[float] + The analyst consensus, on a scale of 1-5 where 1 is a buy and 5 is a sell. (provider: finviz) symbol : Optional[str] - The ticker symbol. (provider: fmp) + The ticker symbol. (provider: finviz, fmp) Examples -------- @@ -985,14 +1116,14 @@ def price_performance( "provider": self._get_provider( provider, "/etf/price_performance", - ("fmp",), + ("finviz", "fmp"), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["finviz", "fmp"]}}, ) ) @@ -1003,7 +1134,7 @@ def search( query: Annotated[ Optional[str], OpenBBCustomParameter(description="Search query.") ] = "", - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["fmp", "tmx"]] = None, **kwargs ) -> OBBject: """Search for ETFs. @@ -1015,7 +1146,7 @@ def search( ---------- query : Optional[str] Search query. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'tmx']] 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. @@ -1023,13 +1154,19 @@ def search( The exchange code the ETF trades on. (provider: fmp) is_active : Optional[Literal[True, False]] Whether the ETF is actively trading. (provider: fmp) + div_freq : Optional[Literal['monthly', 'annually', 'quarterly']] + The dividend payment frequency. (provider: tmx) + sort_by : Optional[Literal['nav', 'return_1m', 'return_3m', 'return_6m', 'return_1y', 'return_3y', 'return_ytd', 'beta_1y', 'volume_avg_daily', 'management_fee', 'distribution_yield', 'pb_ratio', 'pe_ratio']] + The column to sort by. (provider: tmx) + use_cache : bool + Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfSearch] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1066,6 +1203,70 @@ def search( The country the ETF is registered in. (provider: fmp) actively_trading : Optional[Literal[True, False]] Whether the ETF is actively trading. (provider: fmp) + short_name : Optional[str] + The short name of the ETF. (provider: tmx) + inception_date : Optional[str] + The inception date of the ETF. (provider: tmx) + issuer : Optional[str] + The issuer of the ETF. (provider: tmx) + investment_style : Optional[str] + The investment style of the ETF. (provider: tmx) + esg : Optional[bool] + Whether the ETF qualifies as an ESG fund. (provider: tmx) + currency : Optional[str] + The currency of the ETF. (provider: tmx) + unit_price : Optional[float] + The unit price of the ETF. (provider: tmx) + close : Optional[float] + The closing price of the ETF. (provider: tmx) + prev_close : Optional[float] + The previous closing price of the ETF. (provider: tmx) + return_1m : Optional[float] + The one-month return of the ETF, as a normalized percent. (provider: tmx) + return_3m : Optional[float] + The three-month return of the ETF, as a normalized percent. (provider: tmx) + return_6m : Optional[float] + The six-month return of the ETF, as a normalized percent. (provider: tmx) + return_ytd : Optional[float] + The year-to-date return of the ETF, as a normalized percent. (provider: tmx) + return_1y : Optional[float] + The one-year return of the ETF, as a normalized percent. (provider: tmx) + beta_1y : Optional[float] + The one-year beta of the ETF, as a normalized percent. (provider: tmx) + return_3y : Optional[float] + The three-year return of the ETF, as a normalized percent. (provider: tmx) + beta_3y : Optional[float] + The three-year beta of the ETF, as a normalized percent. (provider: tmx) + return_5y : Optional[float] + The five-year return of the ETF, as a normalized percent. (provider: tmx) + beta_5y : Optional[float] + The five-year beta of the ETF, as a normalized percent. (provider: tmx) + return_10y : Optional[float] + The ten-year return of the ETF, as a normalized percent. (provider: tmx) + beta_10y : Optional[float] + The ten-year beta of the ETF. (provider: tmx) + beta_15y : Optional[float] + The fifteen-year beta of the ETF. (provider: tmx) + return_from_inception : Optional[float] + The return from inception of the ETF, as a normalized percent. (provider: tmx) + avg_volume : Optional[int] + The average daily volume of the ETF. (provider: tmx) + avg_volume_30d : Optional[int] + The 30-day average volume of the ETF. (provider: tmx) + aum : Optional[float] + The AUM of the ETF. (provider: tmx) + pe_ratio : Optional[float] + The price-to-earnings ratio of the ETF. (provider: tmx) + pb_ratio : Optional[float] + The price-to-book ratio of the ETF. (provider: tmx) + management_fee : Optional[float] + The management fee of the ETF, as a normalized percent. (provider: tmx) + mer : Optional[float] + The management expense ratio of the ETF, as a normalized percent. (provider: tmx) + distribution_yield : Optional[float] + The distribution yield of the ETF, as a normalized percent. (provider: tmx) + dividend_frequency : Optional[str] + The dividend payment frequency of the ETF. (provider: tmx) Examples -------- @@ -1084,7 +1285,7 @@ def search( "provider": self._get_provider( provider, "/etf/search", - ("fmp",), + ("fmp", "tmx"), ) }, standard_params={ @@ -1101,7 +1302,7 @@ def sectors( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") ], - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["fmp", "tmx"]] = None, **kwargs ) -> OBBject: """ETF Sector weighting. @@ -1110,17 +1311,19 @@ def sectors( ---------- symbol : str Symbol to get data for. (ETF) - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'tmx']] 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. + use_cache : bool + Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfSectors] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['fmp', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1149,7 +1352,7 @@ def sectors( "provider": self._get_provider( provider, "/etf/sectors", - ("fmp",), + ("fmp", "tmx"), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index fbddb3d5a637..98ec05abef46 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -16,6 +16,7 @@ class ROUTER_fixedincome_corporate(Container): """/fixedincome/corporate + bond_prices commercial_paper hqm ice_bofa @@ -26,6 +27,184 @@ class ROUTER_fixedincome_corporate(Container): def __repr__(self) -> str: return self.__doc__ or "" + @exception_handler + @validate + def bond_prices( + self, + country: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="The country to get data. Matches partial name." + ), + ] = None, + issuer_name: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="Name of the issuer. Returns partial matches and is case insensitive." + ), + ] = None, + isin: Annotated[ + Union[List, str, None], + OpenBBCustomParameter( + description="International Securities Identification Number(s) of the bond(s)." + ), + ] = None, + lei: Annotated[ + Optional[str], + OpenBBCustomParameter( + description="Legal Entity Identifier of the issuing entity." + ), + ] = None, + currency: Annotated[ + Union[List, str, None], + OpenBBCustomParameter( + description="Currency of the bond. Formatted as the 3-letter ISO 4217 code (e.g. GBP, EUR, USD)." + ), + ] = None, + coupon_min: Annotated[ + Optional[float], + OpenBBCustomParameter(description="Minimum coupon rate of the bond."), + ] = None, + coupon_max: Annotated[ + Optional[float], + OpenBBCustomParameter(description="Maximum coupon rate of the bond."), + ] = None, + issued_amount_min: Annotated[ + Optional[int], + OpenBBCustomParameter(description="Minimum issued amount of the bond."), + ] = None, + issued_amount_max: Annotated[ + Optional[str], + OpenBBCustomParameter(description="Maximum issued amount of the bond."), + ] = None, + maturity_date_min: Annotated[ + Optional[datetime.date], + OpenBBCustomParameter(description="Minimum maturity date of the bond."), + ] = None, + maturity_date_max: Annotated[ + Optional[datetime.date], + OpenBBCustomParameter(description="Maximum maturity date of the bond."), + ] = None, + provider: Optional[Literal["tmx"]] = None, + **kwargs + ) -> OBBject: + """Corporate Bond Prices. + + Parameters + ---------- + country : Optional[str] + The country to get data. Matches partial name. + issuer_name : Optional[str] + Name of the issuer. Returns partial matches and is case insensitive. + isin : Union[List, str, None] + International Securities Identification Number(s) of the bond(s). + lei : Optional[str] + Legal Entity Identifier of the issuing entity. + currency : Union[List, str, None] + Currency of the bond. Formatted as the 3-letter ISO 4217 code (e.g. GBP, EUR, USD). + coupon_min : Optional[float] + Minimum coupon rate of the bond. + coupon_max : Optional[float] + Maximum coupon rate of the bond. + issued_amount_min : Optional[int] + Minimum issued amount of the bond. + issued_amount_max : Optional[str] + Maximum issued amount of the bond. + maturity_date_min : Optional[datetime.date] + Minimum maturity date of the bond. + maturity_date_max : Optional[datetime.date] + Maximum maturity date of the bond. + provider : Optional[Literal['tmx']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'tmx' if there is + no default. + issue_date_min : Optional[datetime.date] + Filter by the minimum original issue date. (provider: tmx) + issue_date_max : Optional[datetime.date] + Filter by the maximum original issue date. (provider: tmx) + last_traded_min : Optional[datetime.date] + Filter by the minimum last trade date. (provider: tmx) + use_cache : bool + All bond data is sourced from a single JSON file that is updated daily. The file is cached for one day to eliminate downloading more than once. Caching will significantly speed up subsequent queries. To bypass, set to False. (provider: tmx) + + Returns + ------- + OBBject + results : List[BondPrices] + Serializable results. + provider : Optional[Literal['tmx']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + BondPrices + ---------- + isin : Optional[str] + International Securities Identification Number of the bond. + lei : Optional[str] + Legal Entity Identifier of the issuing entity. + figi : Optional[str] + FIGI of the bond. + cusip : Optional[str] + CUSIP of the bond. + coupon_rate : Optional[float] + Coupon rate of the bond. + ytm : Optional[float] + Yield to maturity (YTM) is the rate of return anticipated on a bond if it is held until the maturity date. It takes into account the current market price, par value, coupon rate and time to maturity. It is assumed that all coupons are reinvested at the same rate. Values are returned as a normalized percent. (provider: tmx) + price : Optional[float] + The last price for the bond. (provider: tmx) + highest_price : Optional[float] + The highest price for the bond on the last traded date. (provider: tmx) + lowest_price : Optional[float] + The lowest price for the bond on the last traded date. (provider: tmx) + total_trades : Optional[int] + Total number of trades on the last traded date. (provider: tmx) + last_traded_date : Optional[date] + Last traded date of the bond. (provider: tmx) + maturity_date : Optional[date] + Maturity date of the bond. (provider: tmx) + issue_date : Optional[date] + Issue date of the bond. This is the date when the bond first accrues interest. (provider: tmx) + issuer_name : Optional[str] + Name of the issuing entity. (provider: tmx) + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.corporate.bond_prices() + """ # noqa: E501 + + return self._run( + "/fixedincome/corporate/bond_prices", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/fixedincome/corporate/bond_prices", + ("tmx",), + ) + }, + standard_params={ + "country": country, + "issuer_name": issuer_name, + "isin": isin, + "lei": lei, + "currency": currency, + "coupon_min": coupon_min, + "coupon_max": coupon_max, + "issued_amount_min": issued_amount_min, + "issued_amount_max": issued_amount_max, + "maturity_date_min": maturity_date_min, + "maturity_date_max": maturity_date_max, + }, + extra_params=kwargs, + ) + ) + @exception_handler @validate def commercial_paper( diff --git a/openbb_platform/openbb/package/fixedincome_government.py b/openbb_platform/openbb/package/fixedincome_government.py index d9031659b6d8..5d24593e1523 100644 --- a/openbb_platform/openbb/package/fixedincome_government.py +++ b/openbb_platform/openbb/package/fixedincome_government.py @@ -13,6 +13,9 @@ class ROUTER_fixedincome_government(Container): """/fixedincome/government + eu_yield_curve + treasury_auctions + treasury_prices treasury_rates us_yield_curve """ @@ -20,6 +23,561 @@ class ROUTER_fixedincome_government(Container): def __repr__(self) -> str: return self.__doc__ or "" + @exception_handler + @validate + def eu_yield_curve( + self, + date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter(description="A specific date to get data for."), + ] = None, + provider: Optional[Literal["ecb"]] = None, + **kwargs + ) -> OBBject: + """Euro Area Yield Curve. + + Gets euro area yield curve data from ECB. + + The graphic depiction of the relationship between the yield on bonds of the same credit quality but different + maturities is known as the yield curve. In the past, most market participants have constructed yield curves from + the observations of prices and yields in the Treasury market. Two reasons account for this tendency. First, + Treasury securities are viewed as free of default risk, and differences in creditworthiness do not affect yield + estimates. Second, as the most active bond market, the Treasury market offers the fewest problems of illiquidity + or infrequent trading. The key function of the Treasury yield curve is to serve as a benchmark for pricing bonds + and setting yields in other sectors of the debt market. + + It is clear that the market’s expectations of future rate changes are one important determinant of the + yield-curve shape. For example, a steeply upward-sloping curve may indicate market expectations of near-term Fed + tightening or of rising inflation. However, it may be too restrictive to assume that the yield differences across + bonds with different maturities only reflect the market’s rate expectations. The well-known pure expectations + hypothesis has such an extreme implication. The pure expectations hypothesis asserts that all government bonds + have the same near-term expected return (as the nominally riskless short-term bond) because the return-seeking + activity of risk-neutral traders removes all expected return differentials across bonds. + + + Parameters + ---------- + date : Union[datetime.date, None, str] + A specific date to get data for. + provider : Optional[Literal['ecb']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'ecb' if there is + no default. + rating : Literal['aaa', 'all_ratings'] + The rating type, either 'aaa' or 'all_ratings'. (provider: ecb) + yield_curve_type : Literal['spot_rate', 'instantaneous_forward', 'par_yield'] + The yield curve type. (provider: ecb) + + Returns + ------- + OBBject + results : List[EUYieldCurve] + Serializable results. + provider : Optional[Literal['ecb']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + EUYieldCurve + ------------ + maturity : Optional[float] + Maturity, in years. + rate : Optional[float] + Yield curve rate, as a normalized percent. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.government.eu_yield_curve() + >>> obb.fixedincome.government.eu_yield_curve(yield_curve_type='spot_rate') + """ # noqa: E501 + + return self._run( + "/fixedincome/government/eu_yield_curve", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/fixedincome/government/eu_yield_curve", + ("ecb",), + ) + }, + standard_params={ + "date": date, + }, + extra_params=kwargs, + ) + ) + + @exception_handler + @validate + def treasury_auctions( + self, + security_type: Annotated[ + Literal["Bill", "Note", "Bond", "CMB", "TIPS", "FRN", None], + OpenBBCustomParameter( + description="Used to only return securities of a particular type." + ), + ] = None, + cusip: Annotated[ + Optional[str], + OpenBBCustomParameter(description="Filter securities by CUSIP."), + ] = None, + page_size: Annotated[ + Optional[int], + OpenBBCustomParameter( + description="Maximum number of results to return; you must also include pagenum when using pagesize." + ), + ] = None, + page_num: Annotated[ + Optional[int], + OpenBBCustomParameter( + description="The first page number to display results for; used in combination with page size." + ), + ] = None, + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format. The default is 90 days ago." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="End date of the data, in YYYY-MM-DD format. The default is today." + ), + ] = None, + provider: Optional[Literal["government_us"]] = None, + **kwargs + ) -> OBBject: + """Government Treasury Auctions. + + Parameters + ---------- + security_type : Literal['Bill', 'Note', 'Bond', 'CMB', 'TIPS', 'FRN', None] + Used to only return securities of a particular type. + cusip : Optional[str] + Filter securities by CUSIP. + page_size : Optional[int] + Maximum number of results to return; you must also include pagenum when using pagesize. + page_num : Optional[int] + The first page number to display results for; used in combination with page size. + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. The default is 90 days ago. + end_date : Union[datetime.date, None, str] + End date of the data, in YYYY-MM-DD format. The default is today. + provider : Optional[Literal['government_us']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'government_us' if there is + no default. + + Returns + ------- + OBBject + results : List[TreasuryAuctions] + Serializable results. + provider : Optional[Literal['government_us']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + TreasuryAuctions + ---------------- + cusip : str + CUSIP of the Security. + issue_date : date + The issue date of the security. + security_type : Literal['Bill', 'Note', 'Bond', 'CMB', 'TIPS', 'FRN'] + The type of security. + security_term : str + The term of the security. + maturity_date : date + The maturity date of the security. + interest_rate : Optional[float] + The interest rate of the security. + cpi_on_issue_date : Optional[float] + Reference CPI rate on the issue date of the security. + cpi_on_dated_date : Optional[float] + Reference CPI rate on the dated date of the security. + announcement_date : Optional[date] + The announcement date of the security. + auction_date : Optional[date] + The auction date of the security. + auction_date_year : Optional[int] + The auction date year of the security. + dated_date : Optional[date] + The dated date of the security. + first_payment_date : Optional[date] + The first payment date of the security. + accrued_interest_per_100 : Optional[float] + Accrued interest per $100. + accrued_interest_per_1000 : Optional[float] + Accrued interest per $1000. + adjusted_accrued_interest_per_100 : Optional[float] + Adjusted accrued interest per $100. + adjusted_accrued_interest_per_1000 : Optional[float] + Adjusted accrued interest per $1000. + adjusted_price : Optional[float] + Adjusted price. + allocation_percentage : Optional[float] + Allocation percentage, as normalized percentage points. + allocation_percentage_decimals : Optional[float] + The number of decimals in the Allocation percentage. + announced_cusip : Optional[str] + The announced CUSIP of the security. + auction_format : Optional[str] + The auction format of the security. + avg_median_discount_rate : Optional[float] + The average median discount rate of the security. + avg_median_investment_rate : Optional[float] + The average median investment rate of the security. + avg_median_price : Optional[float] + The average median price paid for the security. + avg_median_discount_margin : Optional[float] + The average median discount margin of the security. + avg_median_yield : Optional[float] + The average median yield of the security. + back_dated : Optional[Literal['Yes', 'No']] + Whether the security is back dated. + back_dated_date : Optional[date] + The back dated date of the security. + bid_to_cover_ratio : Optional[float] + The bid to cover ratio of the security. + call_date : Optional[date] + The call date of the security. + callable : Optional[Literal['Yes', 'No']] + Whether the security is callable. + called_date : Optional[date] + The called date of the security. + cash_management_bill : Optional[Literal['Yes', 'No']] + Whether the security is a cash management bill. + closing_time_competitive : Optional[str] + The closing time for competitive bids on the security. + closing_time_non_competitive : Optional[str] + The closing time for non-competitive bids on the security. + competitive_accepted : Optional[int] + The accepted value for competitive bids on the security. + competitive_accepted_decimals : Optional[int] + The number of decimals in the Competitive Accepted. + competitive_tendered : Optional[int] + The tendered value for competitive bids on the security. + competitive_tenders_accepted : Optional[Literal['Yes', 'No']] + Whether competitive tenders are accepted on the security. + corp_us_cusip : Optional[str] + The CUSIP of the security. + cpi_base_reference_period : Optional[str] + The CPI base reference period of the security. + currently_outstanding : Optional[int] + The currently outstanding value on the security. + direct_bidder_accepted : Optional[int] + The accepted value from direct bidders on the security. + direct_bidder_tendered : Optional[int] + The tendered value from direct bidders on the security. + est_amount_of_publicly_held_maturing_security : Optional[int] + The estimated amount of publicly held maturing securities on the security. + fima_included : Optional[Literal['Yes', 'No']] + Whether the security is included in the FIMA (Foreign and International Money Authorities). + fima_non_competitive_accepted : Optional[int] + The non-competitive accepted value on the security from FIMAs. + fima_non_competitive_tendered : Optional[int] + The non-competitive tendered value on the security from FIMAs. + first_interest_period : Optional[str] + The first interest period of the security. + first_interest_payment_date : Optional[date] + The first interest payment date of the security. + floating_rate : Optional[Literal['Yes', 'No']] + Whether the security is a floating rate. + frn_index_determination_date : Optional[date] + The FRN index determination date of the security. + frn_index_determination_rate : Optional[float] + The FRN index determination rate of the security. + high_discount_rate : Optional[float] + The high discount rate of the security. + high_investment_rate : Optional[float] + The high investment rate of the security. + high_price : Optional[float] + The high price of the security at auction. + high_discount_margin : Optional[float] + The high discount margin of the security. + high_yield : Optional[float] + The high yield of the security at auction. + index_ratio_on_issue_date : Optional[float] + The index ratio on the issue date of the security. + indirect_bidder_accepted : Optional[int] + The accepted value from indirect bidders on the security. + indirect_bidder_tendered : Optional[int] + The tendered value from indirect bidders on the security. + interest_payment_frequency : Optional[str] + The interest payment frequency of the security. + low_discount_rate : Optional[float] + The low discount rate of the security. + low_investment_rate : Optional[float] + The low investment rate of the security. + low_price : Optional[float] + The low price of the security at auction. + low_discount_margin : Optional[float] + The low discount margin of the security. + low_yield : Optional[float] + The low yield of the security at auction. + maturing_date : Optional[date] + The maturing date of the security. + max_competitive_award : Optional[int] + The maximum competitive award at auction. + max_non_competitive_award : Optional[int] + The maximum non-competitive award at auction. + max_single_bid : Optional[int] + The maximum single bid at auction. + min_bid_amount : Optional[int] + The minimum bid amount at auction. + min_strip_amount : Optional[int] + The minimum strip amount at auction. + min_to_issue : Optional[int] + The minimum to issue at auction. + multiples_to_bid : Optional[int] + The multiples to bid at auction. + multiples_to_issue : Optional[int] + The multiples to issue at auction. + nlp_exclusion_amount : Optional[int] + The NLP exclusion amount at auction. + nlp_reporting_threshold : Optional[int] + The NLP reporting threshold at auction. + non_competitive_accepted : Optional[int] + The accepted value from non-competitive bidders on the security. + non_competitive_tenders_accepted : Optional[Literal['Yes', 'No']] + Whether or not the auction accepted non-competitive tenders. + offering_amount : Optional[int] + The offering amount at auction. + original_cusip : Optional[str] + The original CUSIP of the security. + original_dated_date : Optional[date] + The original dated date of the security. + original_issue_date : Optional[date] + The original issue date of the security. + original_security_term : Optional[str] + The original term of the security. + pdf_announcement : Optional[str] + The PDF filename for the announcement of the security. + pdf_competitive_results : Optional[str] + The PDF filename for the competitive results of the security. + pdf_non_competitive_results : Optional[str] + The PDF filename for the non-competitive results of the security. + pdf_special_announcement : Optional[str] + The PDF filename for the special announcements. + price_per_100 : Optional[float] + The price per 100 of the security. + primary_dealer_accepted : Optional[int] + The primary dealer accepted value on the security. + primary_dealer_tendered : Optional[int] + The primary dealer tendered value on the security. + reopening : Optional[Literal['Yes', 'No']] + Whether or not the auction was reopened. + security_term_day_month : Optional[str] + The security term in days or months. + security_term_week_year : Optional[str] + The security term in weeks or years. + series : Optional[str] + The series name of the security. + soma_accepted : Optional[int] + The SOMA accepted value on the security. + soma_holdings : Optional[int] + The SOMA holdings on the security. + soma_included : Optional[Literal['Yes', 'No']] + Whether or not the SOMA (System Open Market Account) was included on the security. + soma_tendered : Optional[int] + The SOMA tendered value on the security. + spread : Optional[float] + The spread on the security. + standard_payment_per_1000 : Optional[float] + The standard payment per 1000 of the security. + strippable : Optional[Literal['Yes', 'No']] + Whether or not the security is strippable. + term : Optional[str] + The term of the security. + tiin_conversion_factor_per_1000 : Optional[float] + The TIIN conversion factor per 1000 of the security. + tips : Optional[Literal['Yes', 'No']] + Whether or not the security is TIPS. + total_accepted : Optional[int] + The total accepted value at auction. + total_tendered : Optional[int] + The total tendered value at auction. + treasury_retail_accepted : Optional[int] + The accepted value on the security from retail. + treasury_retail_tenders_accepted : Optional[Literal['Yes', 'No']] + Whether or not the tender offers from retail are accepted + type : Optional[str] + The type of issuance. This might be different than the security type. + unadjusted_accrued_interest_per_1000 : Optional[float] + The unadjusted accrued interest per 1000 of the security. + unadjusted_price : Optional[float] + The unadjusted price of the security. + updated_timestamp : Optional[datetime] + The updated timestamp of the security. + xml_announcement : Optional[str] + The XML filename for the announcement of the security. + xml_competitive_results : Optional[str] + The XML filename for the competitive results of the security. + xml_special_announcement : Optional[str] + The XML filename for special announcements. + tint_cusip1 : Optional[str] + Tint CUSIP 1. + tint_cusip2 : Optional[str] + Tint CUSIP 2. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.government.treasury_auctions() + >>> obb.fixedincome.government.treasury_auctions(security_type='Bill', start_date='2022-01-01', end_date='2023-01-01') + """ # noqa: E501 + + return self._run( + "/fixedincome/government/treasury_auctions", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/fixedincome/government/treasury_auctions", + ("government_us",), + ) + }, + standard_params={ + "security_type": security_type, + "cusip": cusip, + "page_size": page_size, + "page_num": page_num, + "start_date": start_date, + "end_date": end_date, + }, + extra_params=kwargs, + ) + ) + + @exception_handler + @validate + def treasury_prices( + self, + date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="A specific date to get data for. No date will return the current posted data." + ), + ] = None, + provider: Optional[Literal["government_us", "tmx"]] = None, + **kwargs + ) -> OBBject: + """Government Treasury Prices by date. + + Parameters + ---------- + date : Union[datetime.date, None, str] + A specific date to get data for. No date will return the current posted data. + provider : Optional[Literal['government_us', 'tmx']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'government_us' if there is + no default. + cusip : Optional[str] + Filter by CUSIP. (provider: government_us) + security_type : Literal[None, 'bill', 'note', 'bond', 'tips', 'frn'] + Filter by security type. (provider: government_us) + govt_type : Literal['federal', 'provincial', 'municipal'] + The level of government issuer. (provider: tmx) + issue_date_min : Optional[datetime.date] + Filter by the minimum original issue date. (provider: tmx) + issue_date_max : Optional[datetime.date] + Filter by the maximum original issue date. (provider: tmx) + last_traded_min : Optional[datetime.date] + Filter by the minimum last trade date. (provider: tmx) + maturity_date_min : Optional[datetime.date] + Filter by the minimum maturity date. (provider: tmx) + maturity_date_max : Optional[datetime.date] + Filter by the maximum maturity date. (provider: tmx) + use_cache : bool + All bond data is sourced from a single JSON file that is updated daily. The file is cached for one day to eliminate downloading more than once. Caching will significantly speed up subsequent queries. To bypass, set to False. (provider: tmx) + + Returns + ------- + OBBject + results : List[TreasuryPrices] + Serializable results. + provider : Optional[Literal['government_us', 'tmx']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + TreasuryPrices + -------------- + issuer_name : Optional[str] + Name of the issuing entity. + cusip : Optional[str] + CUSIP of the security. + isin : Optional[str] + ISIN of the security. + security_type : Optional[str] + The type of Treasury security - i.e., Bill, Note, Bond, TIPS, FRN. + issue_date : Optional[date] + The original issue date of the security. + maturity_date : Optional[date] + The maturity date of the security. + call_date : Optional[date] + The call date of the security. + bid : Optional[float] + The bid price of the security. + offer : Optional[float] + The offer price of the security. + eod_price : Optional[float] + The end-of-day price of the security. + last_traded_date : Optional[date] + The last trade date of the security. + total_trades : Optional[int] + Total number of trades on the last traded date. + last_price : Optional[float] + The last price of the security. + highest_price : Optional[float] + The highest price for the bond on the last traded date. + lowest_price : Optional[float] + The lowest price for the bond on the last traded date. + rate : Optional[float] + The annualized interest rate or coupon of the security. + ytm : Optional[float] + Yield to maturity (YTM) is the rate of return anticipated on a bond if it is held until the maturity date. It takes into account the current market price, par value, coupon rate and time to maturity. It is assumed that all coupons are reinvested at the same rate. + + Examples + -------- + >>> from openbb import obb + >>> obb.fixedincome.government.treasury_prices() + >>> obb.fixedincome.government.treasury_prices(date='2019-02-05') + """ # noqa: E501 + + return self._run( + "/fixedincome/government/treasury_prices", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/fixedincome/government/treasury_prices", + ("government_us", "tmx"), + ) + }, + standard_params={ + "date": date, + }, + extra_params=kwargs, + ) + ) + @exception_handler @validate def treasury_rates( diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index 4b691f9e3216..fd36c153e37e 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -19,6 +19,10 @@ class ROUTER_index(Container): constituents market /price + search + sectors + snapshots + sp500_multiples """ def __repr__(self) -> str: @@ -27,23 +31,28 @@ def __repr__(self) -> str: @exception_handler @validate def available( - self, provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs + self, + provider: Optional[Literal["cboe", "fmp", "tmx", "yfinance"]] = None, + **kwargs ) -> OBBject: """All indices available from a given provider. Parameters ---------- - provider : Optional[Literal['fmp', 'yfinance']] + provider : Optional[Literal['cboe', 'fmp', 'tmx', 'yfinance']] 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. + use_cache : bool + When True, the Cboe Index directory will be cached for 24 hours. Set as False to bypass. (provider: cboe); + Whether to use a cached request. Index data is from a single JSON file, updated each day after close. It is cached for one day. To bypass, set to False. (provider: tmx) Returns ------- OBBject results : List[AvailableIndices] Serializable results. - provider : Optional[Literal['fmp', 'yfinance']] + provider : Optional[Literal['cboe', 'fmp', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -58,14 +67,30 @@ def available( Name of the index. currency : Optional[str] Currency the index is traded in. + symbol : Optional[str] + Symbol for the index. (provider: cboe, tmx, yfinance) + description : Optional[str] + Description for the index. Valid only for US indices. (provider: cboe) + data_delay : Optional[int] + Data delay for the index. Valid only for US indices. (provider: cboe) + open_time : Optional[datetime.time] + Opening time for the index. Valid only for US indices. (provider: cboe) + close_time : Optional[datetime.time] + Closing time for the index. Valid only for US indices. (provider: cboe) + time_zone : Optional[str] + Time zone for the index. Valid only for US indices. (provider: cboe) + tick_days : Optional[str] + The trading days for the index. Valid only for US indices. (provider: cboe) + tick_frequency : Optional[str] + The frequency of the index ticks. Valid only for US indices. (provider: cboe) + tick_period : Optional[str] + The period of the index ticks. Valid only for US indices. (provider: cboe) stock_exchange : Optional[str] Stock exchange where the index is listed. (provider: fmp) exchange_short_name : Optional[str] Short name of the stock exchange where the index is listed. (provider: fmp) code : Optional[str] ID code for keying the index in the OpenBB Terminal. (provider: yfinance) - symbol : Optional[str] - Symbol for the index. (provider: yfinance) Examples -------- @@ -81,7 +106,7 @@ def available( "provider": self._get_provider( provider, "/index/available", - ("fmp", "yfinance"), + ("cboe", "fmp", "tmx", "yfinance"), ) }, standard_params={}, @@ -96,7 +121,7 @@ def constituents( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Optional[Literal["cboe", "fmp", "tmx"]] = None, **kwargs ) -> OBBject: """Index Constituents. @@ -105,17 +130,19 @@ def constituents( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['cboe', 'fmp', 'tmx']] 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. + use_cache : bool + Whether to use a cached request. Index data is from a single JSON file, updated each day after close. It is cached for one day. To bypass, set to False. (provider: tmx) Returns ------- OBBject results : List[IndexConstituents] Serializable results. - provider : Optional[Literal['fmp']] + provider : Optional[Literal['cboe', 'fmp', 'tmx']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -130,6 +157,32 @@ def constituents( Symbol representing the entity requested in the data. name : Optional[str] Name of the constituent company in the index. + security_type : Optional[str] + The type of security represented. (provider: cboe) + last_price : Optional[float] + Last price for the symbol. (provider: cboe) + open : Optional[float] + The open price. (provider: cboe) + high : Optional[float] + The high price. (provider: cboe) + low : Optional[float] + The low price. (provider: cboe) + close : Optional[float] + The close price. (provider: cboe) + volume : Optional[int] + The trading volume. (provider: cboe) + prev_close : Optional[float] + The previous close price. (provider: cboe) + change : Optional[float] + Change in price. (provider: cboe) + change_percent : Optional[float] + Change in price as a normalized percentage. (provider: cboe) + tick : Optional[str] + Whether the last sale was an up or down tick. (provider: cboe) + last_trade_time : Optional[datetime] + Last trade timestamp for the symbol. (provider: cboe) + asset_type : Optional[str] + Type of asset. (provider: cboe) sector : Optional[str] Sector the constituent company in the index belongs to. (provider: fmp) sub_sector : Optional[str] @@ -142,11 +195,15 @@ def constituents( Central Index Key (CIK) for the requested entity. (provider: fmp) founded : Optional[Union[str, date]] Founding year of the constituent company in the index. (provider: fmp) + market_value : Optional[float] + The quoted market value of the asset. (provider: tmx) Examples -------- >>> from openbb import obb >>> obb.index.constituents(symbol='dowjones', provider='fmp') + >>> # Providers other than FMP will use the ticker symbol. + >>> obb.index.constituents(symbol='BEP50P', provider='cboe') """ # noqa: E501 return self._run( @@ -156,7 +213,7 @@ def constituents( "provider": self._get_provider( provider, "/index/constituents", - ("fmp",), + ("cboe", "fmp", "tmx"), ) }, standard_params={ @@ -177,7 +234,7 @@ def market( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): cboe, fmp, intrinio, polygon, yfinance." ), ], start_date: Annotated[ @@ -192,7 +249,13 @@ def market( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + interval: Annotated[ + Optional[str], + OpenBBCustomParameter(description="Time interval of the data to return."), + ] = "1d", + provider: Optional[ + Literal["cboe", "fmp", "intrinio", "polygon", "yfinance"] + ] = None, **kwargs ) -> OBBject: """Historical Market Indices. @@ -200,48 +263,30 @@ def market( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): yfinance. + Symbol to get data for. Multiple items allowed for provider(s): cboe, fmp, intrinio, polygon, yfinance. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] + interval : Optional[str] + Time interval of the data to return. + provider : Optional[Literal['cboe', 'fmp', 'intrinio', 'polygon', 'yfinance'... 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. - timeseries : Optional[Annotated[int, Ge(ge=0)]] - Number of days to look back. (provider: fmp) - interval : Optional[Union[Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1W', '1M', '1Q']]] - Data granularity. (provider: fmp, yfinance) - sort : Literal['asc', 'desc'] - Sort the data in ascending or descending order. (provider: fmp); - Sort order. (provider: intrinio); - Sort order of the data. (provider: polygon) - tag : Optional[str] - Index tag. (provider: intrinio) - type : Optional[str] - Index type. (provider: intrinio) - limit : int + use_cache : bool + When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe) + limit : Optional[int] The number of data entries to return. (provider: intrinio, polygon) - timespan : Literal['minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'] - Timespan of the data. (provider: polygon) - adjusted : bool - Whether the data is adjusted. (provider: polygon) - multiplier : int - Multiplier of the timespan. (provider: polygon) - period : Optional[Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max']] - Time 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) + sort : Literal['asc', 'desc'] + Sort order of the data. This impacts the results in combination with the 'limit' parameter. The results are always returned in ascending order by date. (provider: polygon) Returns ------- OBBject results : List[MarketIndices] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] + provider : Optional[Literal['cboe', 'fmp', 'intrinio', 'polygon', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -252,7 +297,7 @@ def market( MarketIndices ------------- - date : datetime + date : Union[date, datetime] The date of the data. open : Optional[Annotated[float, Strict(strict=True)]] The open price. @@ -264,18 +309,18 @@ def market( The close price. volume : Optional[int] The trading volume. - adj_close : Optional[float] - The adjusted close price. (provider: fmp) - unadjusted_volume : Optional[float] - Unadjusted volume of the symbol. (provider: fmp) + calls_volume : Optional[float] + Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + puts_volume : Optional[float] + Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + total_options_volume : Optional[float] + Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + vwap : Optional[float] + Volume Weighted Average Price over the period. (provider: fmp) change : Optional[float] - Change in the price of the symbol from the previous day. (provider: fmp) + Change in the price from the previous close. (provider: fmp) change_percent : Optional[float] - Change % in the price of the symbol. (provider: fmp) - label : Optional[str] - Human readable format of the date. (provider: fmp) - change_over_time : Optional[float] - Change % in the price of the symbol over a period of time. (provider: fmp) + Change in the price from the previous close, as a normalized percent. (provider: fmp) transactions : Optional[Annotated[int, Gt(gt=0)]] Number of transactions for the symbol in the time period. (provider: polygon) @@ -299,16 +344,27 @@ def market( "provider": self._get_provider( provider, "/index/market", - ("fmp", "intrinio", "polygon", "yfinance"), + ("cboe", "fmp", "intrinio", "polygon", "yfinance"), ) }, standard_params={ "symbol": symbol, "start_date": start_date, "end_date": end_date, + "interval": interval, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["yfinance"]}}, + extra_info={ + "symbol": { + "multiple_items_allowed": [ + "cboe", + "fmp", + "intrinio", + "polygon", + "yfinance", + ] + } + }, ) ) @@ -318,3 +374,428 @@ def price(self): from . import index_price return index_price.ROUTER_index_price(command_runner=self._command_runner) + + @exception_handler + @validate + def search( + self, + query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", + is_symbol: Annotated[ + bool, + OpenBBCustomParameter(description="Whether to search by ticker symbol."), + ] = False, + provider: Optional[Literal["cboe"]] = None, + **kwargs + ) -> OBBject: + """Filters indices for rows containing the query. + + Parameters + ---------- + query : str + Search query. + is_symbol : bool + Whether to search by ticker symbol. + provider : Optional[Literal['cboe']] + 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. + use_cache : bool + When True, the Cboe Index directory will be cached for 24 hours. Set as False to bypass. (provider: cboe) + + Returns + ------- + OBBject + results : List[IndexSearch] + Serializable results. + provider : Optional[Literal['cboe']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + IndexSearch + ----------- + symbol : str + Symbol representing the entity requested in the data. + name : str + Name of the index. + description : Optional[str] + Description for the index. (provider: cboe) + data_delay : Optional[int] + Data delay for the index. Valid only for US indices. (provider: cboe) + currency : Optional[str] + Currency for the index. (provider: cboe) + time_zone : Optional[str] + Time zone for the index. Valid only for US indices. (provider: cboe) + open_time : Optional[datetime.time] + Opening time for the index. Valid only for US indices. (provider: cboe) + close_time : Optional[datetime.time] + Closing time for the index. Valid only for US indices. (provider: cboe) + tick_days : Optional[str] + The trading days for the index. Valid only for US indices. (provider: cboe) + tick_frequency : Optional[str] + Tick frequency for the index. Valid only for US indices. (provider: cboe) + tick_period : Optional[str] + Tick period for the index. Valid only for US indices. (provider: cboe) + + Examples + -------- + >>> from openbb import obb + >>> obb.index.search() + >>> obb.index.search(query='SPX', provider='cboe') + """ # noqa: E501 + + return self._run( + "/index/search", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/index/search", + ("cboe",), + ) + }, + standard_params={ + "query": query, + "is_symbol": is_symbol, + }, + extra_params=kwargs, + ) + ) + + @exception_handler + @validate + def sectors( + self, + symbol: Annotated[ + str, OpenBBCustomParameter(description="Symbol to get data for.") + ], + provider: Optional[Literal["tmx"]] = None, + **kwargs + ) -> OBBject: + """Index Sectors. Sector weighting of an index. + + Parameters + ---------- + symbol : str + Symbol to get data for. + provider : Optional[Literal['tmx']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'tmx' if there is + no default. + use_cache : bool + Whether to use a cached request. All Index data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 1 day. (provider: tmx) + + Returns + ------- + OBBject + results : List[IndexSectors] + Serializable results. + provider : Optional[Literal['tmx']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + IndexSectors + ------------ + sector : str + The sector name. + weight : float + The weight of the sector in the index. + + Examples + -------- + >>> from openbb import obb + >>> obb.index.sectors(symbol='^TX60') + """ # noqa: E501 + + return self._run( + "/index/sectors", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/index/sectors", + ("tmx",), + ) + }, + standard_params={ + "symbol": symbol, + }, + extra_params=kwargs, + ) + ) + + @exception_handler + @validate + def snapshots( + self, + region: Annotated[ + str, + OpenBBCustomParameter( + description="The region of focus for the data - i.e., us, eu." + ), + ] = "us", + provider: Optional[Literal["cboe", "tmx"]] = None, + **kwargs + ) -> OBBject: + """Index Snapshots. Current levels for all indices from a provider, grouped by `region`. + + Parameters + ---------- + region : str + The region of focus for the data - i.e., us, eu. + provider : Optional[Literal['cboe', 'tmx']] + 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. + use_cache : bool + Whether to use a cached request. Index data is from a single JSON file, updated each day after close. It is cached for one day. To bypass, set to False. (provider: tmx) + + Returns + ------- + OBBject + results : List[IndexSnapshots] + Serializable results. + provider : Optional[Literal['cboe', 'tmx']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + IndexSnapshots + -------------- + symbol : str + Symbol representing the entity requested in the data. + name : Optional[str] + Name of the index. + currency : Optional[str] + Currency of the index. + price : Optional[float] + Current price of the index. + open : Optional[float] + The open price. + high : Optional[float] + The high price. + low : Optional[float] + The low price. + close : Optional[float] + The close price. + volume : Optional[int] + The trading volume. + prev_close : Optional[float] + The previous close price. + change : Optional[float] + Change in value of the index. + change_percent : Optional[float] + Change, in normalized percentage points, of the index. + bid : Optional[float] + Current bid price. (provider: cboe) + ask : Optional[float] + Current ask price. (provider: cboe) + last_trade_time : Optional[datetime] + Last trade timestamp for the symbol. (provider: cboe) + status : Optional[str] + Status of the market, open or closed. (provider: cboe) + year_high : Optional[float] + The 52-week high of the index. (provider: tmx) + year_low : Optional[float] + The 52-week low of the index. (provider: tmx) + return_mtd : Optional[float] + The month-to-date return of the index, as a normalized percent. (provider: tmx) + return_qtd : Optional[float] + The quarter-to-date return of the index, as a normalized percent. (provider: tmx) + return_ytd : Optional[float] + The year-to-date return of the index, as a normalized percent. (provider: tmx) + total_market_value : Optional[float] + The total quoted market value of the index. (provider: tmx) + number_of_constituents : Optional[int] + The number of constituents in the index. (provider: tmx) + constituent_average_market_value : Optional[float] + The average quoted market value of the index constituents. (provider: tmx) + constituent_median_market_value : Optional[float] + The median quoted market value of the index constituents. (provider: tmx) + constituent_top10_market_value : Optional[float] + The sum of the top 10 quoted market values of the index constituents. (provider: tmx) + constituent_largest_market_value : Optional[float] + The largest quoted market value of the index constituents. (provider: tmx) + constituent_largest_weight : Optional[float] + The largest weight of the index constituents, as a normalized percent. (provider: tmx) + constituent_smallest_market_value : Optional[float] + The smallest quoted market value of the index constituents. (provider: tmx) + constituent_smallest_weight : Optional[float] + The smallest weight of the index constituents, as a normalized percent. (provider: tmx) + + Examples + -------- + >>> from openbb import obb + >>> obb.index.snapshots() + >>> obb.index.snapshots(region='us', provider='cboe') + """ # noqa: E501 + + return self._run( + "/index/snapshots", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/index/snapshots", + ("cboe", "tmx"), + ) + }, + standard_params={ + "region": region, + }, + extra_params=kwargs, + ) + ) + + @exception_handler + @validate + def sp500_multiples( + self, + series_name: Annotated[ + Literal[ + "shiller_pe_month", + "shiller_pe_year", + "pe_year", + "pe_month", + "dividend_year", + "dividend_month", + "dividend_growth_quarter", + "dividend_growth_year", + "dividend_yield_year", + "dividend_yield_month", + "earnings_year", + "earnings_month", + "earnings_growth_year", + "earnings_growth_quarter", + "real_earnings_growth_year", + "real_earnings_growth_quarter", + "earnings_yield_year", + "earnings_yield_month", + "real_price_year", + "real_price_month", + "inflation_adjusted_price_year", + "inflation_adjusted_price_month", + "sales_year", + "sales_quarter", + "sales_growth_year", + "sales_growth_quarter", + "real_sales_year", + "real_sales_quarter", + "real_sales_growth_year", + "real_sales_growth_quarter", + "price_to_sales_year", + "price_to_sales_quarter", + "price_to_book_value_year", + "price_to_book_value_quarter", + "book_value_year", + "book_value_quarter", + ], + OpenBBCustomParameter( + description="The name of the series. Defaults to 'pe_month'." + ), + ] = "pe_month", + start_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + end_date: Annotated[ + Union[datetime.date, None, str], + OpenBBCustomParameter( + description="Start date of the data, in YYYY-MM-DD format." + ), + ] = None, + transform: Annotated[ + Literal["diff", "rdiff", "cumul", "normalize", None], + OpenBBCustomParameter( + description="Transform the data as difference, percent change, cumulative, or normalize." + ), + ] = None, + collapse: Annotated[ + Literal["daily", "weekly", "monthly", "quarterly", "annual", None], + OpenBBCustomParameter( + description="Collapse the frequency of the time series." + ), + ] = None, + provider: Optional[Literal["nasdaq"]] = None, + **kwargs + ) -> OBBject: + """Historical S&P 500 multiples and Shiller PE ratios. + + Parameters + ---------- + series_name : Literal['shiller_pe_month', 'shiller_pe_year', 'pe_year', 'pe_month', 'd... + The name of the series. Defaults to 'pe_month'. + start_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + end_date : Union[datetime.date, None, str] + Start date of the data, in YYYY-MM-DD format. + transform : Literal['diff', 'rdiff', 'cumul', 'normalize', None] + Transform the data as difference, percent change, cumulative, or normalize. + collapse : Literal['daily', 'weekly', 'monthly', 'quarterly', 'annual', None] + Collapse the frequency of the time series. + provider : Optional[Literal['nasdaq']] + The provider to use for the query, by default None. + If None, the provider specified in defaults is selected or 'nasdaq' if there is + no default. + + Returns + ------- + OBBject + results : List[SP500Multiples] + Serializable results. + provider : Optional[Literal['nasdaq']] + Provider name. + warnings : Optional[List[Warning_]] + List of warnings. + chart : Optional[Chart] + Chart object. + extra : Dict[str, Any] + Extra info. + + SP500Multiples + -------------- + date : date + The date of the data. + + Examples + -------- + >>> from openbb import obb + >>> obb.index.sp500_multiples() + >>> obb.index.sp500_multiples(series_name='shiller_pe_year', provider='nasdaq') + """ # noqa: E501 + + return self._run( + "/index/sp500_multiples", + **filter_inputs( + provider_choices={ + "provider": self._get_provider( + provider, + "/index/sp500_multiples", + ("nasdaq",), + ) + }, + standard_params={ + "series_name": series_name, + "start_date": start_date, + "end_date": end_date, + "transform": transform, + "collapse": collapse, + }, + extra_params=kwargs, + ) + ) diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index a2b3df302a7b..ab15654adf9a 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -28,7 +28,7 @@ def company( symbol: Annotated[ Union[str, None, List[Optional[str]]], OpenBBCustomParameter( - description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, yfinance." + description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, tmx, yfinance." ), ] = None, start_date: Annotated[ @@ -48,7 +48,9 @@ def company( OpenBBCustomParameter(description="The number of data entries to return."), ] = 2500, provider: Optional[ - Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"] + Literal[ + "benzinga", "fmp", "intrinio", "polygon", "tiingo", "tmx", "yfinance" + ] ] = None, **kwargs ) -> OBBject: @@ -57,7 +59,7 @@ def company( Parameters ---------- symbol : Union[str, None, List[Optional[str]]] - Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, yfinance. + Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, tmx, yfinance. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] @@ -94,7 +96,8 @@ def company( content_types : Optional[str] Content types of the news to retrieve. (provider: benzinga) page : Optional[int] - Page number of the results. Use in combination with limit. (provider: fmp) + Page number of the results. Use in combination with limit. (provider: fmp); + The page number to start from. Use with limit. (provider: tmx) offset : Optional[int] Page offset, used in conjunction with limit. (provider: tiingo) source : Optional[str] @@ -105,7 +108,7 @@ def company( OBBject results : List[CompanyNews] Serializable results. - provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance']] + provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'polygon', 'tiingo', 'tmx', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -146,6 +149,7 @@ def company( Name of the news source. (provider: fmp); Source of the article. (provider: polygon); News source. (provider: tiingo); + Source of the news. (provider: tmx); Source of the news article (provider: yfinance) amp_url : Optional[str] AMP URL. (provider: polygon) @@ -184,6 +188,7 @@ def company( "intrinio", "polygon", "tiingo", + "tmx", "yfinance", ), ) @@ -203,6 +208,7 @@ def company( "intrinio", "polygon", "tiingo", + "tmx", "yfinance", ] } @@ -232,7 +238,9 @@ def world( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["benzinga", "fmp", "intrinio", "tiingo"]] = None, + provider: Optional[ + Literal["benzinga", "biztoc", "fmp", "intrinio", "tiingo"] + ] = None, **kwargs ) -> OBBject: """World News. Global news data. @@ -245,7 +253,7 @@ def world( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'tiingo']] + provider : Optional[Literal['benzinga', 'biztoc', 'fmp', 'intrinio', 'tiingo... 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. @@ -273,17 +281,24 @@ def world( Authors of the news to retrieve. (provider: benzinga) content_types : Optional[str] Content types of the news to retrieve. (provider: benzinga) - offset : Optional[int] - Page offset, used in conjunction with limit. (provider: tiingo) + filter : Literal['crypto', 'hot', 'latest', 'main', 'media', 'source', 'tag'] + Filter by type of news. (provider: biztoc) source : Optional[str] + Filter by a specific publisher. Only valid when filter is set to source. (provider: biztoc); A comma-separated list of the domains requested. (provider: tiingo) + tag : Optional[str] + Tag, topic, to filter articles by. Only valid when filter is set to tag. (provider: biztoc) + term : Optional[str] + Search term to filter articles by. This overrides all other filters. (provider: biztoc) + offset : Optional[int] + Page offset, used in conjunction with limit. (provider: tiingo) Returns ------- OBBject results : List[WorldNews] Serializable results. - provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'tiingo']] + provider : Optional[Literal['benzinga', 'biztoc', 'fmp', 'intrinio', 'tiingo']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -305,7 +320,7 @@ def world( url : Optional[str] URL to the article. id : Optional[str] - Article ID. (provider: benzinga, intrinio) + Article ID. (provider: benzinga, biztoc, intrinio) author : Optional[str] Author of the news. (provider: benzinga) teaser : Optional[str] @@ -314,10 +329,14 @@ def world( Channels associated with the news. (provider: benzinga) stocks : Optional[str] Stocks associated with the news. (provider: benzinga) - tags : Optional[str] - Tags associated with the news. (provider: benzinga, tiingo) + tags : Optional[Union[str, List[str]]] + Tags associated with the news. (provider: benzinga, biztoc, tiingo) updated : Optional[datetime] Updated date of the news. (provider: benzinga) + favicon : Optional[str] + Icon image for the source of the article. (provider: biztoc) + score : Optional[float] + Search relevance score for the article. (provider: biztoc) site : Optional[str] News source. (provider: fmp, tiingo) company : Optional[Dict[str, Any]] @@ -342,6 +361,8 @@ def world( >>> obb.news.world(topics='finance', provider='benzinga') >>> # Get news by source using 'tingo' as provider. >>> obb.news.world(provider='tiingo', source='bloomberg') + >>> # Filter aticles by term using 'biztoc' as provider. + >>> obb.news.world(provider='biztoc', term='apple') """ # noqa: E501 return self._run( @@ -351,7 +372,7 @@ def world( "provider": self._get_provider( provider, "/news/world", - ("benzinga", "fmp", "intrinio", "tiingo"), + ("benzinga", "biztoc", "fmp", "intrinio", "tiingo"), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/regulators.py b/openbb_platform/openbb/package/regulators.py index 753e0bfc69aa..f309425d2784 100644 --- a/openbb_platform/openbb/package/regulators.py +++ b/openbb_platform/openbb/package/regulators.py @@ -6,12 +6,22 @@ class ROUTER_regulators(Container): """/regulators + /cftc /sec """ def __repr__(self) -> str: return self.__doc__ or "" + @property + def cftc(self): + # pylint: disable=import-outside-toplevel + from . import regulators_cftc + + return regulators_cftc.ROUTER_regulators_cftc( + command_runner=self._command_runner + ) + @property def sec(self): # pylint: disable=import-outside-toplevel From a9ec896d8fa3206545d927ae256adcd3d6361947 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 22:47:13 +0000 Subject: [PATCH 122/133] last --- .../index/openbb_index/price/price_router.py | 1 - .../news/openbb_news/news_router.py | 21 +++++++++++++------ .../openbb_regulators/cftc/cftc_router.py | 13 +++++++----- .../openbb_regulators/sec/sec_router.py | 16 +++++++------- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/openbb_platform/extensions/index/openbb_index/price/price_router.py b/openbb_platform/extensions/index/openbb_index/price/price_router.py index 6d16f353e134..883427d5f4cc 100644 --- a/openbb_platform/extensions/index/openbb_index/price/price_router.py +++ b/openbb_platform/extensions/index/openbb_index/price/price_router.py @@ -19,7 +19,6 @@ @router.command( model="IndexHistorical", examples=[ - APIEx(parameters={"symbol": "SPX"}), APIEx(parameters={"symbol": "^GSPC", "provider": "fmp"}), APIEx( description="Not all providers have the same symbols.", diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index 9aaf6274e69a..9e01e8fd6f9a 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -18,11 +18,15 @@ @router.command( model="WorldNews", examples=[ - APIEx(parameters={}), - APIEx(parameters={"limit": 100}), + APIEx(parameters={"provider": "fmp"}), + APIEx(parameters={"limit": 100, "provider": "intrinio"}), APIEx( description="Get news on the specified dates.", - parameters={"start_date": "2024-02-01", "end_date": "2024-02-07"}, + parameters={ + "start_date": "2024-02-01", + "end_date": "2024-02-07", + "provider": "intrinio", + }, ), APIEx( description="Display the headlines of the news.", @@ -55,7 +59,7 @@ async def world( @router.command( model="CompanyNews", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "fmp"}), APIEx(parameters={"limit": 100}), APIEx( description="Get news on the specified dates.", @@ -63,6 +67,7 @@ async def world( "symbol": "AAPL", "start_date": "2024-02-01", "end_date": "2024-02-07", + "provider": "intrinio", }, ), APIEx( @@ -75,11 +80,15 @@ async def world( ), APIEx( description="Get news for multiple symbols.", - parameters={"symbol": "aapl,tsla"}, + parameters={"symbol": "aapl,tsla", "provider": "fmp"}, ), APIEx( description="Get news company's ISIN.", - parameters={"symbol": "NVDA", "isin": "US0378331005"}, + parameters={ + "symbol": "NVDA", + "isin": "US0378331005", + "provider": "benzinga", + }, ), ], ) diff --git a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py index 9867df0f92ae..eb5e1e642aae 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/cftc/cftc_router.py @@ -17,7 +17,10 @@ @router.command( model="COTSearch", - examples=[APIEx(parameters={}), APIEx(parameters={"query": "gold"})], + examples=[ + APIEx(parameters={"provider": "nasdaq"}), + APIEx(parameters={"query": "gold", "provider": "nasdaq"}), + ], ) async def cot_search( cc: CommandContext, @@ -35,18 +38,18 @@ async def cot_search( @router.command( model="COT", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "nasdaq"}), APIEx( description="Get the Commitment of Traders Report for Gold.", - parameters={"id": "GC=F"}, + parameters={"id": "GC=F", "provider": "nasdaq"}, ), APIEx( description="Enter the report ID by the Nasdaq Data Link Code.", - parameters={"id": "088691"}, + parameters={"id": "088691", "provider": "nasdaq"}, ), APIEx( description="Get the report for futures only.", - parameters={"id": "088691", "data_type": "F"}, + parameters={"id": "088691", "data_type": "F", "provider": "nasdaq"}, ), ], ) diff --git a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py index db85d8041e30..df212ad35c72 100644 --- a/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py +++ b/openbb_platform/extensions/regulators/openbb_regulators/sec/sec_router.py @@ -17,7 +17,7 @@ @router.command( model="CikMap", - examples=[APIEx(parameters={"symbol": "MSFT"})], + examples=[APIEx(parameters={"symbol": "MSFT", "provider": "sec"})], ) async def cik_map( cc: CommandContext, @@ -32,8 +32,8 @@ async def cik_map( @router.command( model="InstitutionsSearch", examples=[ - APIEx(parameters={}), - APIEx(parameters={"query": "blackstone real estate"}), + APIEx(parameters={"provider": "sec"}), + APIEx(parameters={"query": "blackstone real estate", "provider": "sec"}), ], ) async def institutions_search( @@ -49,7 +49,7 @@ async def institutions_search( @router.command( model="SchemaFiles", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "sec"}), PythonEx( description="Get a list of schema files.", code=[ @@ -86,7 +86,7 @@ async def schema_files( @router.command( model="SymbolMap", - examples=[APIEx(parameters={"query": "0000789019"})], + examples=[APIEx(parameters={"query": "0000789019", "provider": "sec"})], ) async def symbol_map( cc: CommandContext, @@ -100,7 +100,7 @@ async def symbol_map( @router.command( model="RssLitigation", - examples=[APIEx(parameters={})], + examples=[APIEx(parameters={"provider": "sec"})], ) async def rss_litigation( cc: CommandContext, @@ -115,8 +115,8 @@ async def rss_litigation( @router.command( model="SicSearch", examples=[ - APIEx(parameters={}), - APIEx(parameters={"query": "real estate investment trusts"}), + APIEx(parameters={"provider": "sec"}), + APIEx(parameters={"query": "real estate investment trusts", "provider": "sec"}), ], ) async def sic_search( From c73b40324ceb192c3e982e31d2997860c352c02e Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 23:05:14 +0000 Subject: [PATCH 123/133] add provider --- .../core/openbb_core/app/model/example.py | 30 +++++++++---------- .../openbb_currency/price/price_router.py | 3 +- .../futures/futures_router.py | 2 +- .../options/options_router.py | 4 +-- .../extensions/etf/openbb_etf/etf_router.py | 4 +-- .../government/government_router.py | 5 +++- .../news/openbb_news/news_router.py | 2 +- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index 4d09d8c63f5c..e2d105f0db88 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -34,28 +34,26 @@ class APIEx(Example): description: Optional[str] = Field( default=None, description="Optional description unless more than 3 parameters" ) - parameters: Dict[ - str, Union[str, int, float, bool, List[str], List[Dict[str, Any]], None] - ] + parameters: Dict[str, Union[str, int, float, bool, List[str], List[Dict[str, Any]]]] @computed_field # type: ignore[misc] @property def provider(self) -> Optional[str]: """Return the provider from the parameters.""" - if provider := self.parameters.get("provider"): - if isinstance(provider, str): - return provider - raise ValueError(f"Provider must be a string, not {type(provider)}") - return None + return self.parameters.get("provider") # type: ignore @model_validator(mode="before") @classmethod - def check_model(cls, values: dict) -> dict: - """Check if there are more than 3 parameters and a description is not added.""" - if len(values.get("parameters", {})) > 3 and not values.get("description"): - raise ValueError( - "API example with more than 3 parameters must have a description." - ) + def validate_model(cls, values: dict) -> dict: + """Validate model.""" + parameters = values.get("parameters", {}) + if "provider" not in parameters and "data" not in parameters: + raise ValueError("API example must specify a provider.") + + if provider := parameters.get("provider"): + if not isinstance(provider, str): + raise ValueError("Provider must be a string.") + return values @staticmethod @@ -63,8 +61,8 @@ def _unpack_type(type_: type) -> set: """Unpack types from types, example Union[List[str], int] -> {str, int}.""" if ( hasattr(type_, "__args__") - and type(type_) - is not _GenericAlias # pylint: disable=unidiomatic-typecheck + and type(type_) # pylint: disable=unidiomatic-typecheck + is not _GenericAlias ): return set().union(*map(APIEx._unpack_type, type_.__args__)) return {type_} if isinstance(type_, type) else {type(type_)} diff --git a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py index 037ce2323daa..fe84f8c7d8c6 100644 --- a/openbb_platform/extensions/currency/openbb_currency/price/price_router.py +++ b/openbb_platform/extensions/currency/openbb_currency/price/price_router.py @@ -19,13 +19,14 @@ @router.command( model="CurrencyHistorical", examples=[ - APIEx(parameters={"symbol": "EURUSD"}), + APIEx(parameters={"symbol": "EURUSD", "provider": "fmp"}), APIEx( description="Filter historical data with specific start and end date.", parameters={ "symbol": "EURUSD", "start_date": "2023-01-01", "end_date": "2023-12-31", + "provider": "fmp", }, ), APIEx( diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py index a551cc2f28a7..bc47e4531a94 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/futures/futures_router.py @@ -46,7 +46,7 @@ async def historical( @router.command( model="FuturesCurve", examples=[ - APIEx(parameters={"symbol": "VX"}), + APIEx(parameters={"symbol": "VX", "provider": "cboe"}), APIEx( description="Enter a date to get the term structure from a historical date.", parameters={"symbol": "NG", "provider": "yfinance", "date": "2023-01-01"}, diff --git a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py index 153b20700b92..ec6ecf29186c 100644 --- a/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py +++ b/openbb_platform/extensions/derivatives/openbb_derivatives/options/options_router.py @@ -19,7 +19,7 @@ @router.command( model="OptionsChains", examples=[ - APIEx(parameters={"symbol": "AAPL"}), + APIEx(parameters={"symbol": "AAPL", "provider": "intrinio"}), APIEx( description='Use the "date" parameter to get the end-of-day-data for a specific date, where supported.', parameters={"symbol": "AAPL", "date": "2023-01-25", "provider": "intrinio"}, @@ -39,7 +39,7 @@ async def chains( @router.command( model="OptionsUnusual", examples=[ - APIEx(parameters={}), + APIEx(parameters={"provider": "intrinio"}), APIEx( description="Use the 'symbol' parameter to get the most recent activity for a specific symbol.", parameters={"symbol": "TSLA", "provider": "intrinio"}, diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py index 0e1b2ff21923..caa8c90938b5 100644 --- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py +++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py @@ -172,7 +172,7 @@ async def holdings_date( @router.command( model="EtfHoldingsPerformance", - examples=[APIEx(parameters={"symbol": "XLK"})], + examples=[APIEx(parameters={"symbol": "XLK", "provider": "fmp"})], ) async def holdings_performance( cc: CommandContext, @@ -187,7 +187,7 @@ async def holdings_performance( @router.command( model="EtfEquityExposure", examples=[ - APIEx(parameters={"symbol": "MSFT"}), + APIEx(parameters={"symbol": "MSFT", "provider": "fmp"}), APIEx( description="This function accepts multiple tickers.", parameters={"symbol": "MSFT,AAPL", "provider": "fmp"}, diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index e2b4e7b1f6c9..7d7a325eb7ad 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -18,7 +18,10 @@ @router.command( model="USYieldCurve", - examples=[APIEx(parameters={}), APIEx(parameters={"inflation_adjusted": True})], + examples=[ + APIEx(parameters={"provider": "fred"}), + APIEx(parameters={"inflation_adjusted": True, "provider": "fred"}), + ], ) async def us_yield_curve( cc: CommandContext, diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index 9e01e8fd6f9a..4f9a29a296ec 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -60,7 +60,7 @@ async def world( model="CompanyNews", examples=[ APIEx(parameters={"provider": "fmp"}), - APIEx(parameters={"limit": 100}), + APIEx(parameters={"limit": 100, "provider": "fmp"}), APIEx( description="Get news on the specified dates.", parameters={ From d5aa76f71a674eb39a1a4b46c5749e4eb2241be2 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 23:08:01 +0000 Subject: [PATCH 124/133] rebuild --- .../openbb/assets/extension_map.json | 17 +- openbb_platform/openbb/assets/module_map.json | 93 +-- .../openbb/package/__extensions__.py | 47 -- .../openbb/package/crypto_price.py | 8 +- openbb_platform/openbb/package/currency.py | 134 +---- .../openbb/package/currency_price.py | 4 +- .../openbb/package/derivatives_options.py | 34 +- openbb_platform/openbb/package/economy.py | 336 +---------- openbb_platform/openbb/package/economy_gdp.py | 12 +- openbb_platform/openbb/package/equity.py | 129 +--- .../openbb/package/equity_calendar.py | 88 +-- .../openbb/package/equity_compare.py | 129 +--- .../openbb/package/equity_discovery.py | 187 +----- .../openbb/package/equity_estimates.py | 53 +- .../openbb/package/equity_fundamental.py | 256 ++++---- .../openbb/package/equity_ownership.py | 42 +- .../openbb/package/equity_price.py | 265 ++------ .../openbb/package/equity_shorts.py | 160 +---- openbb_platform/openbb/package/etf.py | 374 +++--------- openbb_platform/openbb/package/fixedincome.py | 4 +- .../openbb/package/fixedincome_corporate.py | 199 +----- .../openbb/package/fixedincome_government.py | 565 +----------------- .../openbb/package/fixedincome_rate.py | 28 +- .../openbb/package/fixedincome_spreads.py | 12 +- openbb_platform/openbb/package/index.py | 535 +---------------- openbb_platform/openbb/package/news.py | 65 +- openbb_platform/openbb/package/regulators.py | 10 - .../openbb/package/regulators_sec.py | 16 +- 28 files changed, 492 insertions(+), 3310 deletions(-) diff --git a/openbb_platform/openbb/assets/extension_map.json b/openbb_platform/openbb/assets/extension_map.json index 7673bb805992..3a653d729ce2 100644 --- a/openbb_platform/openbb/assets/extension_map.json +++ b/openbb_platform/openbb/assets/extension_map.json @@ -4,40 +4,25 @@ "crypto@1.1.2", "currency@1.1.2", "derivatives@1.1.2", - "econometrics@1.1.2", "economy@1.1.2", "equity@1.1.2", "etf@1.1.2", "fixedincome@1.1.2", "index@1.1.2", "news@1.1.2", - "quantitative@1.1.2", - "regulators@1.1.2", - "technical@1.1.3" + "regulators@1.1.2" ], "openbb_provider_extension": [ - "alpha_vantage@1.1.2", "benzinga@1.1.2", - "biztoc@1.1.2", - "cboe@1.1.2", - "ecb@1.1.2", "federal_reserve@1.1.2", - "finra@1.1.2", - "finviz@1.0.1", "fmp@1.1.2", "fred@1.1.2", - "government_us@1.1.2", "intrinio@1.1.2", - "nasdaq@1.1.3", "oecd@1.1.2", "polygon@1.1.2", "sec@1.1.2", - "seeking_alpha@1.1.2", - "stockgrid@1.1.2", "tiingo@1.1.2", - "tmx@1.0.0", "tradingeconomics@1.1.2", - "wsj@1.1.2", "yfinance@1.1.2" ] } \ No newline at end of file diff --git a/openbb_platform/openbb/assets/module_map.json b/openbb_platform/openbb/assets/module_map.json index f294ba8ff90e..0163f3c6803c 100644 --- a/openbb_platform/openbb/assets/module_map.json +++ b/openbb_platform/openbb/assets/module_map.json @@ -1,7 +1,5 @@ { "__extensions__": "", - "commodity": "/commodity", - "commodity_lbma_fixing": "/commodity/lbma_fixing", "crypto": "/crypto", "crypto_price": "/crypto/price", "crypto_price_historical": "/crypto/price/historical", @@ -9,7 +7,6 @@ "currency": "/currency", "currency_price": "/currency/price", "currency_price_historical": "/currency/price/historical", - "currency_reference_rates": "/currency/reference_rates", "currency_search": "/currency/search", "currency_snapshots": "/currency/snapshots", "derivatives": "/derivatives", @@ -19,23 +16,7 @@ "derivatives_options": "/derivatives/options", "derivatives_options_chains": "/derivatives/options/chains", "derivatives_options_unusual": "/derivatives/options/unusual", - "econometrics": "/econometrics", - "econometrics_autocorrelation": "/econometrics/autocorrelation", - "econometrics_causality": "/econometrics/causality", - "econometrics_cointegration": "/econometrics/cointegration", - "econometrics_correlation_matrix": "/econometrics/correlation_matrix", - "econometrics_ols_regression": "/econometrics/ols_regression", - "econometrics_ols_regression_summary": "/econometrics/ols_regression_summary", - "econometrics_panel_between": "/econometrics/panel_between", - "econometrics_panel_first_difference": "/econometrics/panel_first_difference", - "econometrics_panel_fixed": "/econometrics/panel_fixed", - "econometrics_panel_fmac": "/econometrics/panel_fmac", - "econometrics_panel_pooled": "/econometrics/panel_pooled", - "econometrics_panel_random_effects": "/econometrics/panel_random_effects", - "econometrics_residual_autocorrelation": "/econometrics/residual_autocorrelation", - "econometrics_unit_root": "/econometrics/unit_root", "economy": "/economy", - "economy_balance_of_payments": "/economy/balance_of_payments", "economy_calendar": "/economy/calendar", "economy_composite_leading_indicator": "/economy/composite_leading_indicator", "economy_cpi": "/economy/cpi", @@ -58,10 +39,7 @@ "equity_calendar_ipo": "/equity/calendar/ipo", "equity_calendar_splits": "/equity/calendar/splits", "equity_compare": "/equity/compare", - "equity_compare_groups": "/equity/compare/groups", "equity_compare_peers": "/equity/compare/peers", - "equity_darkpool": "/equity/darkpool", - "equity_darkpool_otc": "/equity/darkpool/otc", "equity_discovery": "/equity/discovery", "equity_discovery_active": "/equity/discovery/active", "equity_discovery_aggressive_small_caps": "/equity/discovery/aggressive_small_caps", @@ -69,10 +47,8 @@ "equity_discovery_gainers": "/equity/discovery/gainers", "equity_discovery_growth_tech": "/equity/discovery/growth_tech", "equity_discovery_losers": "/equity/discovery/losers", - "equity_discovery_top_retail": "/equity/discovery/top_retail", "equity_discovery_undervalued_growth": "/equity/discovery/undervalued_growth", "equity_discovery_undervalued_large_caps": "/equity/discovery/undervalued_large_caps", - "equity_discovery_upcoming_release_days": "/equity/discovery/upcoming_release_days", "equity_estimates": "/equity/estimates", "equity_estimates_analyst_search": "/equity/estimates/analyst_search", "equity_estimates_consensus": "/equity/estimates/consensus", @@ -121,14 +97,8 @@ "equity_search": "/equity/search", "equity_shorts": "/equity/shorts", "equity_shorts_fails_to_deliver": "/equity/shorts/fails_to_deliver", - "equity_shorts_short_interest": "/equity/shorts/short_interest", - "equity_shorts_short_volume": "/equity/shorts/short_volume", "etf": "/etf", "etf_countries": "/etf/countries", - "etf_discovery": "/etf/discovery", - "etf_discovery_active": "/etf/discovery/active", - "etf_discovery_gainers": "/etf/discovery/gainers", - "etf_discovery_losers": "/etf/discovery/losers", "etf_equity_exposure": "/etf/equity_exposure", "etf_historical": "/etf/historical", "etf_holdings": "/etf/holdings", @@ -140,16 +110,12 @@ "etf_sectors": "/etf/sectors", "fixedincome": "/fixedincome", "fixedincome_corporate": "/fixedincome/corporate", - "fixedincome_corporate_bond_prices": "/fixedincome/corporate/bond_prices", "fixedincome_corporate_commercial_paper": "/fixedincome/corporate/commercial_paper", "fixedincome_corporate_hqm": "/fixedincome/corporate/hqm", "fixedincome_corporate_ice_bofa": "/fixedincome/corporate/ice_bofa", "fixedincome_corporate_moody": "/fixedincome/corporate/moody", "fixedincome_corporate_spot_rates": "/fixedincome/corporate/spot_rates", "fixedincome_government": "/fixedincome/government", - "fixedincome_government_eu_yield_curve": "/fixedincome/government/eu_yield_curve", - "fixedincome_government_treasury_auctions": "/fixedincome/government/treasury_auctions", - "fixedincome_government_treasury_prices": "/fixedincome/government/treasury_prices", "fixedincome_government_treasury_rates": "/fixedincome/government/treasury_rates", "fixedincome_government_us_yield_curve": "/fixedincome/government/us_yield_curve", "fixedincome_rate": "/fixedincome/rate", @@ -172,72 +138,15 @@ "index_market": "/index/market", "index_price": "/index/price", "index_price_historical": "/index/price/historical", - "index_search": "/index/search", - "index_sectors": "/index/sectors", - "index_snapshots": "/index/snapshots", - "index_sp500_multiples": "/index/sp500_multiples", "news": "/news", "news_company": "/news/company", "news_world": "/news/world", - "quantitative": "/quantitative", - "quantitative_capm": "/quantitative/capm", - "quantitative_normality": "/quantitative/normality", - "quantitative_performance": "/quantitative/performance", - "quantitative_performance_omega_ratio": "/quantitative/performance/omega_ratio", - "quantitative_performance_sharpe_ratio": "/quantitative/performance/sharpe_ratio", - "quantitative_performance_sortino_ratio": "/quantitative/performance/sortino_ratio", - "quantitative_rolling": "/quantitative/rolling", - "quantitative_rolling_kurtosis": "/quantitative/rolling/kurtosis", - "quantitative_rolling_mean": "/quantitative/rolling/mean", - "quantitative_rolling_quantile": "/quantitative/rolling/quantile", - "quantitative_rolling_skew": "/quantitative/rolling/skew", - "quantitative_rolling_stdev": "/quantitative/rolling/stdev", - "quantitative_rolling_variance": "/quantitative/rolling/variance", - "quantitative_stats": "/quantitative/stats", - "quantitative_stats_kurtosis": "/quantitative/stats/kurtosis", - "quantitative_stats_mean": "/quantitative/stats/mean", - "quantitative_stats_quantile": "/quantitative/stats/quantile", - "quantitative_stats_skew": "/quantitative/stats/skew", - "quantitative_stats_stdev": "/quantitative/stats/stdev", - "quantitative_stats_variance": "/quantitative/stats/variance", - "quantitative_summary": "/quantitative/summary", - "quantitative_unitroot_test": "/quantitative/unitroot_test", "regulators": "/regulators", - "regulators_cftc": "/regulators/cftc", - "regulators_cftc_cot": "/regulators/cftc/cot", - "regulators_cftc_cot_search": "/regulators/cftc/cot_search", "regulators_sec": "/regulators/sec", "regulators_sec_cik_map": "/regulators/sec/cik_map", "regulators_sec_institutions_search": "/regulators/sec/institutions_search", "regulators_sec_rss_litigation": "/regulators/sec/rss_litigation", "regulators_sec_schema_files": "/regulators/sec/schema_files", "regulators_sec_sic_search": "/regulators/sec/sic_search", - "regulators_sec_symbol_map": "/regulators/sec/symbol_map", - "technical": "/technical", - "technical_ad": "/technical/ad", - "technical_adosc": "/technical/adosc", - "technical_adx": "/technical/adx", - "technical_aroon": "/technical/aroon", - "technical_atr": "/technical/atr", - "technical_bbands": "/technical/bbands", - "technical_cci": "/technical/cci", - "technical_cg": "/technical/cg", - "technical_clenow": "/technical/clenow", - "technical_cones": "/technical/cones", - "technical_demark": "/technical/demark", - "technical_donchian": "/technical/donchian", - "technical_ema": "/technical/ema", - "technical_fib": "/technical/fib", - "technical_fisher": "/technical/fisher", - "technical_hma": "/technical/hma", - "technical_ichimoku": "/technical/ichimoku", - "technical_kc": "/technical/kc", - "technical_macd": "/technical/macd", - "technical_obv": "/technical/obv", - "technical_rsi": "/technical/rsi", - "technical_sma": "/technical/sma", - "technical_stoch": "/technical/stoch", - "technical_vwap": "/technical/vwap", - "technical_wma": "/technical/wma", - "technical_zlma": "/technical/zlma" + "regulators_sec_symbol_map": "/regulators/sec/symbol_map" } \ No newline at end of file diff --git a/openbb_platform/openbb/package/__extensions__.py b/openbb_platform/openbb/package/__extensions__.py index da67608b82b3..f33f5962eea7 100644 --- a/openbb_platform/openbb/package/__extensions__.py +++ b/openbb_platform/openbb/package/__extensions__.py @@ -8,72 +8,46 @@ class Extensions(Container): # fmt: off """ Routers: - /commodity /crypto /currency /derivatives - /econometrics /economy /equity /etf /fixedincome /index /news - /quantitative /regulators - /technical Extensions: - commodity@1.0.0 - crypto@1.1.2 - currency@1.1.2 - derivatives@1.1.2 - - econometrics@1.1.2 - economy@1.1.2 - equity@1.1.2 - etf@1.1.2 - fixedincome@1.1.2 - index@1.1.2 - news@1.1.2 - - quantitative@1.1.2 - regulators@1.1.2 - - technical@1.1.3 - - alpha_vantage@1.1.2 - benzinga@1.1.2 - - biztoc@1.1.2 - - cboe@1.1.2 - - ecb@1.1.2 - federal_reserve@1.1.2 - - finra@1.1.2 - - finviz@1.0.1 - fmp@1.1.2 - fred@1.1.2 - - government_us@1.1.2 - intrinio@1.1.2 - - nasdaq@1.1.3 - oecd@1.1.2 - polygon@1.1.2 - sec@1.1.2 - - seeking_alpha@1.1.2 - - stockgrid@1.1.2 - tiingo@1.1.2 - - tmx@1.0.0 - tradingeconomics@1.1.2 - - wsj@1.1.2 - yfinance@1.1.2 """ # fmt: on def __repr__(self) -> str: return self.__doc__ or "" - @property - def commodity(self): - # pylint: disable=import-outside-toplevel - from . import commodity - - return commodity.ROUTER_commodity(command_runner=self._command_runner) - @property def crypto(self): # pylint: disable=import-outside-toplevel @@ -95,13 +69,6 @@ def derivatives(self): return derivatives.ROUTER_derivatives(command_runner=self._command_runner) - @property - def econometrics(self): - # pylint: disable=import-outside-toplevel - from . import econometrics - - return econometrics.ROUTER_econometrics(command_runner=self._command_runner) - @property def economy(self): # pylint: disable=import-outside-toplevel @@ -144,23 +111,9 @@ def news(self): return news.ROUTER_news(command_runner=self._command_runner) - @property - def quantitative(self): - # pylint: disable=import-outside-toplevel - from . import quantitative - - return quantitative.ROUTER_quantitative(command_runner=self._command_runner) - @property def regulators(self): # pylint: disable=import-outside-toplevel from . import regulators return regulators.ROUTER_regulators(command_runner=self._command_runner) - - @property - def technical(self): - # pylint: disable=import-outside-toplevel - from . import technical - - return technical.ROUTER_technical(command_runner=self._command_runner) diff --git a/openbb_platform/openbb/package/crypto_price.py b/openbb_platform/openbb/package/crypto_price.py index 6bd64c12798d..3b1dcf0e47a7 100644 --- a/openbb_platform/openbb/package/crypto_price.py +++ b/openbb_platform/openbb/package/crypto_price.py @@ -111,11 +111,11 @@ def historical( Examples -------- >>> from openbb import obb - >>> obb.crypto.price.historical(symbol='BTCUSD') - >>> obb.crypto.price.historical(symbol='BTCUSD', start_date='2024-01-01', end_date='2024-01-31') - >>> obb.crypto.price.historical(symbol='BTCUSD,ETHUSD', start_date='2024-01-01', end_date='2024-01-31') + >>> obb.crypto.price.historical(symbol='BTCUSD', provider='fmp') + >>> obb.crypto.price.historical(symbol='BTCUSD', start_date='2024-01-01', end_date='2024-01-31', provider='fmp') + >>> obb.crypto.price.historical(symbol='BTCUSD,ETHUSD', start_date='2024-01-01', end_date='2024-01-31', provider='polygon') >>> # Get monthly historical prices from Yahoo Finance for Ethereum. - >>> obb.crypto.price.historical(symbol='ETH-USD', provider='yfinance', interval='1mo', start_date='2024-01-01', end_date='2024-12-31') + >>> obb.crypto.price.historical(symbol='ETH-USD', interval='1mo', start_date='2024-01-01', end_date='2024-12-31', provider='yfinance') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index e6d0a841af9a..69b830d74959 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -13,7 +13,6 @@ class ROUTER_currency(Container): """/currency /price - reference_rates search snapshots """ @@ -28,131 +27,6 @@ def price(self): return currency_price.ROUTER_currency_price(command_runner=self._command_runner) - @exception_handler - @validate - def reference_rates( - self, provider: Optional[Literal["ecb"]] = None, **kwargs - ) -> OBBject: - """Current, official, currency reference rates. - - Foreign exchange reference rates are the exchange rates set by a major financial institution or regulatory body, - serving as a benchmark for the value of currencies around the world. - These rates are used as a standard to facilitate international trade and financial transactions, - ensuring consistency and reliability in currency conversion. - They are typically updated on a daily basis and reflect the market conditions at a specific time. - Central banks and financial institutions often use these rates to guide their own exchange rates, - impacting global trade, loans, and investments. - - - Parameters - ---------- - provider : Optional[Literal['ecb']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'ecb' if there is - no default. - - Returns - ------- - OBBject - results : CurrencyReferenceRates - Serializable results. - provider : Optional[Literal['ecb']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - CurrencyReferenceRates - ---------------------- - date : date - The date of the data. - EUR : Optional[float] - Euro. - USD : Optional[float] - US Dollar. - JPY : Optional[float] - Japanese Yen. - BGN : Optional[float] - Bulgarian Lev. - CZK : Optional[float] - Czech Koruna. - DKK : Optional[float] - Danish Krone. - GBP : Optional[float] - Pound Sterling. - HUF : Optional[float] - Hungarian Forint. - PLN : Optional[float] - Polish Zloty. - RON : Optional[float] - Romanian Leu. - SEK : Optional[float] - Swedish Krona. - CHF : Optional[float] - Swiss Franc. - ISK : Optional[float] - Icelandic Krona. - NOK : Optional[float] - Norwegian Krone. - TRY : Optional[float] - Turkish Lira. - AUD : Optional[float] - Australian Dollar. - BRL : Optional[float] - Brazilian Real. - CAD : Optional[float] - Canadian Dollar. - CNY : Optional[float] - Chinese Yuan. - HKD : Optional[float] - Hong Kong Dollar. - IDR : Optional[float] - Indonesian Rupiah. - ILS : Optional[float] - Israeli Shekel. - INR : Optional[float] - Indian Rupee. - KRW : Optional[float] - South Korean Won. - MXN : Optional[float] - Mexican Peso. - MYR : Optional[float] - Malaysian Ringgit. - NZD : Optional[float] - New Zealand Dollar. - PHP : Optional[float] - Philippine Peso. - SGD : Optional[float] - Singapore Dollar. - THB : Optional[float] - Thai Baht. - ZAR : Optional[float] - South African Rand. - - Examples - -------- - >>> from openbb import obb - >>> obb.currency.reference_rates() - """ # noqa: E501 - - return self._run( - "/currency/reference_rates", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/currency/reference_rates", - ("ecb",), - ) - }, - standard_params={}, - extra_params=kwargs, - ) - ) - @exception_handler @validate def search( @@ -242,9 +116,9 @@ def search( Examples -------- >>> from openbb import obb - >>> obb.currency.search() - >>> # Search for 'EURUSD' currency pair using 'polygon' as provider. - >>> obb.currency.search(provider='polygon', symbol='EURUSD') + >>> obb.currency.search(provider='intrinio') + >>> # Search for 'EURUSD' currency pair using 'intrinio' as provider. + >>> obb.currency.search(provider='intrinio', symbol='EURUSD') >>> # Search for actively traded currency pairs on the queried date using 'polygon' as provider. >>> obb.currency.search(provider='polygon', date='2024-01-02', active=True) >>> # Search for terms using 'polygon' as provider. @@ -358,7 +232,7 @@ def snapshots( Examples -------- >>> from openbb import obb - >>> obb.currency.snapshots() + >>> obb.currency.snapshots(provider='fmp') >>> # Get exchange rates from USD and XAU to EUR, JPY, and GBP using 'fmp' as provider. >>> obb.currency.snapshots(provider='fmp', base='USD,XAU', counter_currencies='EUR,JPY,GBP', quote_type='indirect') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/currency_price.py b/openbb_platform/openbb/package/currency_price.py index a2a19f91ded3..9613b8fd973b 100644 --- a/openbb_platform/openbb/package/currency_price.py +++ b/openbb_platform/openbb/package/currency_price.py @@ -114,9 +114,9 @@ def historical( Examples -------- >>> from openbb import obb - >>> obb.currency.price.historical(symbol='EURUSD') + >>> obb.currency.price.historical(symbol='EURUSD', provider='fmp') >>> # Filter historical data with specific start and end date. - >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='2023-12-31') + >>> obb.currency.price.historical(symbol='EURUSD', start_date='2023-01-01', end_date='2023-12-31', provider='fmp') >>> # Get data with different granularity. >>> obb.currency.price.historical(symbol='EURUSD', provider='polygon', interval='15m') """ # noqa: E501 diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py index 3e4e6f0924dc..79d144242a52 100644 --- a/openbb_platform/openbb/package/derivatives_options.py +++ b/openbb_platform/openbb/package/derivatives_options.py @@ -26,7 +26,7 @@ def chains( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["cboe", "intrinio", "tmx"]] = None, + provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: """Get the complete options chain for a ticker. @@ -35,23 +35,19 @@ def chains( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['cboe', 'intrinio', 'tmx']] + provider : Optional[Literal['intrinio']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'cboe' if there is + If None, the provider specified in defaults is selected or 'intrinio' if there is no default. - use_cache : bool - When True, the company directories will be cached for24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe); - Caching is used to validate the supplied ticker symbol, or if a historical EOD chain is requested. To bypass, set to False. (provider: tmx) date : Optional[datetime.date] - The end-of-day date for options chains data. (provider: intrinio); - A specific date to get data for. (provider: tmx) + The end-of-day date for options chains data. (provider: intrinio) Returns ------- OBBject results : List[OptionsChains] Serializable results. - provider : Optional[Literal['cboe', 'intrinio', 'tmx']] + provider : Optional[Literal['intrinio']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -148,25 +144,13 @@ def chains( Vega of the option. rho : Optional[float] Rho of the option. - last_trade_timestamp : Optional[datetime] - Last trade timestamp of the option. (provider: cboe) - dte : Optional[int] - Days to expiration for the option. (provider: cboe, tmx) exercise_style : Optional[str] The exercise style of the option, American or European. (provider: intrinio) - transactions : Optional[int] - Number of transactions for the contract. (provider: tmx) - total_value : Optional[float] - Total value of the transactions. (provider: tmx) - settlement_price : Optional[float] - Settlement price on that date. (provider: tmx) - underlying_price : Optional[float] - Price of the underlying stock on that date. (provider: tmx) Examples -------- >>> from openbb import obb - >>> obb.derivatives.options.chains(symbol='AAPL') + >>> obb.derivatives.options.chains(symbol='AAPL', provider='intrinio') >>> # Use the "date" parameter to get the end-of-day-data for a specific date, where supported. >>> obb.derivatives.options.chains(symbol='AAPL', date='2023-01-25', provider='intrinio') """ # noqa: E501 @@ -178,7 +162,7 @@ def chains( "provider": self._get_provider( provider, "/derivatives/options/chains", - ("cboe", "intrinio", "tmx"), + ("intrinio",), ) }, standard_params={ @@ -256,9 +240,9 @@ def unusual( Examples -------- >>> from openbb import obb - >>> obb.derivatives.options.unusual() + >>> obb.derivatives.options.unusual(provider='intrinio') >>> # Use the 'symbol' parameter to get the most recent activity for a specific symbol. - >>> obb.derivatives.options.unusual(symbol='TSLA') + >>> obb.derivatives.options.unusual(symbol='TSLA', provider='intrinio') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index d0758ae043db..afb7cf629396 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -16,7 +16,6 @@ class ROUTER_economy(Container): """/economy - balance_of_payments calendar composite_leading_indicator cpi @@ -34,283 +33,6 @@ class ROUTER_economy(Container): def __repr__(self) -> str: return self.__doc__ or "" - @exception_handler - @validate - def balance_of_payments( - self, provider: Optional[Literal["ecb"]] = None, **kwargs - ) -> OBBject: - """Balance of Payments Reports. - - Parameters - ---------- - provider : Optional[Literal['ecb']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'ecb' if there is - no default. - report_type : Literal['main', 'summary', 'services', 'investment_income', 'direct_investment', 'portfolio_investment', 'other_investment'] - The report type, the level of detail in the data. (provider: ecb) - frequency : Literal['monthly', 'quarterly'] - The frequency of the data. Monthly is valid only for ['main', 'summary']. (provider: ecb) - country : Literal['brazil', 'canada', 'china', 'eu_ex_euro_area', 'eu_institutions', 'india', 'japan', 'russia', 'switzerland', 'united_kingdom', 'united_states', 'total', None] - The country/region of the data. This parameter will override the 'report_type' parameter. (provider: ecb) - - Returns - ------- - OBBject - results : List[BalanceOfPayments] - Serializable results. - provider : Optional[Literal['ecb']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - BalanceOfPayments - ----------------- - period : Optional[date] - The date representing the beginning of the reporting period. - current_account : Optional[float] - Current Account Balance (Billions of EUR) - goods : Optional[float] - Goods Balance (Billions of EUR) - services : Optional[float] - Services Balance (Billions of EUR) - primary_income : Optional[float] - Primary Income Balance (Billions of EUR) - secondary_income : Optional[float] - Secondary Income Balance (Billions of EUR) - capital_account : Optional[float] - Capital Account Balance (Billions of EUR) - net_lending_to_rest_of_world : Optional[float] - Balance of net lending to the rest of the world (Billions of EUR) - financial_account : Optional[float] - Financial Account Balance (Billions of EUR) - direct_investment : Optional[float] - Direct Investment Balance (Billions of EUR) - portfolio_investment : Optional[float] - Portfolio Investment Balance (Billions of EUR) - financial_derivatives : Optional[float] - Financial Derivatives Balance (Billions of EUR) - other_investment : Optional[float] - Other Investment Balance (Billions of EUR) - reserve_assets : Optional[float] - Reserve Assets Balance (Billions of EUR) - errors_and_ommissions : Optional[float] - Errors and Omissions (Billions of EUR) - current_account_credit : Optional[float] - Current Account Credits (Billions of EUR) - current_account_debit : Optional[float] - Current Account Debits (Billions of EUR) - current_account_balance : Optional[float] - Current Account Balance (Billions of EUR) - goods_credit : Optional[float] - Goods Credits (Billions of EUR) - goods_debit : Optional[float] - Goods Debits (Billions of EUR) - services_credit : Optional[float] - Services Credits (Billions of EUR) - services_debit : Optional[float] - Services Debits (Billions of EUR) - primary_income_credit : Optional[float] - Primary Income Credits (Billions of EUR) - primary_income_employee_compensation_credit : Optional[float] - Primary Income Employee Compensation Credit (Billions of EUR) - primary_income_debit : Optional[float] - Primary Income Debits (Billions of EUR) - primary_income_employee_compensation_debit : Optional[float] - Primary Income Employee Compensation Debit (Billions of EUR) - secondary_income_credit : Optional[float] - Secondary Income Credits (Billions of EUR) - secondary_income_debit : Optional[float] - Secondary Income Debits (Billions of EUR) - capital_account_credit : Optional[float] - Capital Account Credits (Billions of EUR) - capital_account_debit : Optional[float] - Capital Account Debits (Billions of EUR) - services_total_credit : Optional[float] - Services Total Credit (Billions of EUR) - services_total_debit : Optional[float] - Services Total Debit (Billions of EUR) - transport_credit : Optional[float] - Transport Credit (Billions of EUR) - transport_debit : Optional[float] - Transport Debit (Billions of EUR) - travel_credit : Optional[float] - Travel Credit (Billions of EUR) - travel_debit : Optional[float] - Travel Debit (Billions of EUR) - financial_services_credit : Optional[float] - Financial Services Credit (Billions of EUR) - financial_services_debit : Optional[float] - Financial Services Debit (Billions of EUR) - communications_credit : Optional[float] - Communications Credit (Billions of EUR) - communications_debit : Optional[float] - Communications Debit (Billions of EUR) - other_business_services_credit : Optional[float] - Other Business Services Credit (Billions of EUR) - other_business_services_debit : Optional[float] - Other Business Services Debit (Billions of EUR) - other_services_credit : Optional[float] - Other Services Credit (Billions of EUR) - other_services_debit : Optional[float] - Other Services Debit (Billions of EUR) - investment_total_credit : Optional[float] - Investment Total Credit (Billions of EUR) - investment_total_debit : Optional[float] - Investment Total Debit (Billions of EUR) - equity_credit : Optional[float] - Equity Credit (Billions of EUR) - equity_reinvested_earnings_credit : Optional[float] - Equity Reinvested Earnings Credit (Billions of EUR) - equity_debit : Optional[float] - Equity Debit (Billions of EUR) - equity_reinvested_earnings_debit : Optional[float] - Equity Reinvested Earnings Debit (Billions of EUR) - debt_instruments_credit : Optional[float] - Debt Instruments Credit (Billions of EUR) - debt_instruments_debit : Optional[float] - Debt Instruments Debit (Billions of EUR) - portfolio_investment_equity_credit : Optional[float] - Portfolio Investment Equity Credit (Billions of EUR) - portfolio_investment_equity_debit : Optional[float] - Portfolio Investment Equity Debit (Billions of EUR) - portfolio_investment_debt_instruments_credit : Optional[float] - Portfolio Investment Debt Instruments Credit (Billions of EUR) - portofolio_investment_debt_instruments_debit : Optional[float] - Portfolio Investment Debt Instruments Debit (Billions of EUR) - other_investment_credit : Optional[float] - Other Investment Credit (Billions of EUR) - other_investment_debit : Optional[float] - Other Investment Debit (Billions of EUR) - reserve_assets_credit : Optional[float] - Reserve Assets Credit (Billions of EUR) - assets_total : Optional[float] - Assets Total (Billions of EUR) - assets_equity : Optional[float] - Assets Equity (Billions of EUR) - assets_debt_instruments : Optional[float] - Assets Debt Instruments (Billions of EUR) - assets_mfi : Optional[float] - Assets MFIs (Billions of EUR) - assets_non_mfi : Optional[float] - Assets Non MFIs (Billions of EUR) - assets_direct_investment_abroad : Optional[float] - Assets Direct Investment Abroad (Billions of EUR) - liabilities_total : Optional[float] - Liabilities Total (Billions of EUR) - liabilities_equity : Optional[float] - Liabilities Equity (Billions of EUR) - liabilities_debt_instruments : Optional[float] - Liabilities Debt Instruments (Billions of EUR) - liabilities_mfi : Optional[float] - Liabilities MFIs (Billions of EUR) - liabilities_non_mfi : Optional[float] - Liabilities Non MFIs (Billions of EUR) - liabilities_direct_investment_euro_area : Optional[float] - Liabilities Direct Investment in Euro Area (Billions of EUR) - assets_equity_and_fund_shares : Optional[float] - Assets Equity and Investment Fund Shares (Billions of EUR) - assets_equity_shares : Optional[float] - Assets Equity Shares (Billions of EUR) - assets_investment_fund_shares : Optional[float] - Assets Investment Fund Shares (Billions of EUR) - assets_debt_short_term : Optional[float] - Assets Debt Short Term (Billions of EUR) - assets_debt_long_term : Optional[float] - Assets Debt Long Term (Billions of EUR) - assets_resident_sector_eurosystem : Optional[float] - Assets Resident Sector Eurosystem (Billions of EUR) - assets_resident_sector_mfi_ex_eurosystem : Optional[float] - Assets Resident Sector MFIs outside Eurosystem (Billions of EUR) - assets_resident_sector_government : Optional[float] - Assets Resident Sector Government (Billions of EUR) - assets_resident_sector_other : Optional[float] - Assets Resident Sector Other (Billions of EUR) - liabilities_equity_and_fund_shares : Optional[float] - Liabilities Equity and Investment Fund Shares (Billions of EUR) - liabilities_investment_fund_shares : Optional[float] - Liabilities Investment Fund Shares (Billions of EUR) - liabilities_debt_short_term : Optional[float] - Liabilities Debt Short Term (Billions of EUR) - liabilities_debt_long_term : Optional[float] - Liabilities Debt Long Term (Billions of EUR) - liabilities_resident_sector_government : Optional[float] - Liabilities Resident Sector Government (Billions of EUR) - liabilities_resident_sector_other : Optional[float] - Liabilities Resident Sector Other (Billions of EUR) - assets_currency_and_deposits : Optional[float] - Assets Currency and Deposits (Billions of EUR) - assets_loans : Optional[float] - Assets Loans (Billions of EUR) - assets_trade_credit_and_advances : Optional[float] - Assets Trade Credits and Advances (Billions of EUR) - assets_eurosystem : Optional[float] - Assets Eurosystem (Billions of EUR) - assets_other_mfi_ex_eurosystem : Optional[float] - Assets Other MFIs outside Eurosystem (Billions of EUR) - assets_government : Optional[float] - Assets Government (Billions of EUR) - assets_other_sectors : Optional[float] - Assets Other Sectors (Billions of EUR) - liabilities_currency_and_deposits : Optional[float] - Liabilities Currency and Deposits (Billions of EUR) - liabilities_loans : Optional[float] - Liabilities Loans (Billions of EUR) - liabilities_trade_credit_and_advances : Optional[float] - Liabilities Trade Credits and Advances (Billions of EUR) - liabilities_eurosystem : Optional[float] - Liabilities Eurosystem (Billions of EUR) - liabilities_other_mfi_ex_eurosystem : Optional[float] - Liabilities Other MFIs outside Eurosystem (Billions of EUR) - liabilities_government : Optional[float] - Liabilities Government (Billions of EUR) - liabilities_other_sectors : Optional[float] - Liabilities Other Sectors (Billions of EUR) - goods_balance : Optional[float] - Goods Balance (Billions of EUR) - services_balance : Optional[float] - Services Balance (Billions of EUR) - primary_income_balance : Optional[float] - Primary Income Balance (Billions of EUR) - investment_income_balance : Optional[float] - Investment Income Balance (Billions of EUR) - investment_income_credit : Optional[float] - Investment Income Credits (Billions of EUR) - investment_income_debit : Optional[float] - Investment Income Debits (Billions of EUR) - secondary_income_balance : Optional[float] - Secondary Income Balance (Billions of EUR) - capital_account_balance : Optional[float] - Capital Account Balance (Billions of EUR) - - Examples - -------- - >>> from openbb import obb - >>> obb.economy.balance_of_payments() - >>> obb.economy.balance_of_payments(report_type='summary') - >>> # The `country` parameter will override the `report_type`. - >>> obb.economy.balance_of_payments(country='united_states', provider='ecb') - """ # noqa: E501 - - return self._run( - "/economy/balance_of_payments", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/economy/balance_of_payments", - ("ecb",), - ) - }, - standard_params={}, - extra_params=kwargs, - ) - ) - @exception_handler @validate def calendar( @@ -327,7 +49,7 @@ def calendar( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "nasdaq", "tradingeconomics"]] = None, + provider: Optional[Literal["fmp", "tradingeconomics"]] = None, **kwargs ) -> OBBject: """Get the upcoming, or historical, economic calendar of global events. @@ -338,12 +60,12 @@ def calendar( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'nasdaq', 'tradingeconomics']] + provider : Optional[Literal['fmp', 'tradingeconomics']] 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. country : Optional[str] - Country of the event Multiple items allowed. (provider: nasdaq, tradingeconomics) + Country of the event. Multiple items allowed. (provider: tradingeconomics) importance : Optional[Literal['Low', 'Medium', 'High']] Importance of the event. (provider: tradingeconomics) group : Optional[Literal['interest rate', 'inflation', 'bonds', 'consumer', 'gdp', 'government', 'housing', 'labour', 'markets', 'money', 'prices', 'trade', 'business']] @@ -354,7 +76,7 @@ def calendar( OBBject results : List[EconomicCalendar] Serializable results. - provider : Optional[Literal['fmp', 'nasdaq', 'tradingeconomics']] + provider : Optional[Literal['fmp', 'tradingeconomics']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -401,17 +123,13 @@ def calendar( Last updated timestamp. (provider: fmp) created_at : Optional[datetime] Created at timestamp. (provider: fmp) - description : Optional[str] - Event description. (provider: nasdaq) Examples -------- >>> from openbb import obb >>> # By default, the calendar will be forward-looking. - >>> obb.economy.calendar() + >>> obb.economy.calendar(provider='fmp') >>> obb.economy.calendar(provider='fmp', start_date='2020-03-01', end_date='2020-03-31') - >>> # By default, the calendar will be forward-looking. - >>> obb.economy.calendar(provider='nasdaq') """ # noqa: E501 return self._run( @@ -421,7 +139,7 @@ def calendar( "provider": self._get_provider( provider, "/economy/calendar", - ("fmp", "nasdaq", "tradingeconomics"), + ("fmp", "tradingeconomics"), ) }, standard_params={ @@ -495,8 +213,8 @@ def composite_leading_indicator( Examples -------- >>> from openbb import obb - >>> obb.economy.composite_leading_indicator() - >>> obb.economy.composite_leading_indicator(country='all') + >>> obb.economy.composite_leading_indicator(provider='oecd') + >>> obb.economy.composite_leading_indicator(country='all', provider='oecd') """ # noqa: E501 return self._run( @@ -663,9 +381,9 @@ def cpi( Examples -------- >>> from openbb import obb - >>> obb.economy.cpi(country='japan,china,turkey') + >>> obb.economy.cpi(country='japan,china,turkey', provider='fred') >>> # Use the `units` parameter to define the reference period for the change in values. - >>> obb.economy.cpi(country='united_states,united_kingdom', units='growth_previous') + >>> obb.economy.cpi(country='united_states,united_kingdom', units='growth_previous', provider='fred') """ # noqa: E501 return self._run( @@ -811,7 +529,7 @@ def fred_regional( The name of the region. (provider: fred) code : Optional[Union[int, str]] The code of the region. (provider: fred) - value : Optional[Union[int, float]] + value : Optional[Union[float, int]] The obersvation value. The units are defined in the search results by series ID. (provider: fred) series_id : Optional[str] The individual series ID for the region. (provider: fred) @@ -819,9 +537,9 @@ def fred_regional( Examples -------- >>> from openbb import obb - >>> obb.economy.fred_regional(symbol='NYICLAIMS') + >>> obb.economy.fred_regional(symbol='NYICLAIMS', provider='fred') >>> # With a date, time series data is returned. - >>> obb.economy.fred_regional(symbol='NYICLAIMS', start_date='2021-01-01', end_date='2021-12-31', limit=10) + >>> obb.economy.fred_regional(symbol='NYICLAIMS', start_date='2021-01-01', end_date='2021-12-31', limit=10, provider='fred') """ # noqa: E501 return self._run( @@ -947,7 +665,7 @@ def fred_search( Examples -------- >>> from openbb import obb - >>> obb.economy.fred_search() + >>> obb.economy.fred_search(provider='fred') """ # noqa: E501 return self._run( @@ -1081,11 +799,11 @@ def fred_series( Examples -------- >>> from openbb import obb - >>> obb.economy.fred_series(symbol='NFCI') + >>> obb.economy.fred_series(symbol='NFCI', provider='fred') >>> # Multiple series can be passed in as a list. - >>> obb.economy.fred_series(symbol='NFCI,STLFSI4') + >>> obb.economy.fred_series(symbol='NFCI,STLFSI4', provider='fred') >>> # Use the `transform` parameter to transform the data as change, log, or percent change. - >>> obb.economy.fred_series(symbol='CBBTCUSD', transform='pc1') + >>> obb.economy.fred_series(symbol='CBBTCUSD', transform='pc1', provider='fred') """ # noqa: E501 return self._run( @@ -1186,8 +904,8 @@ def long_term_interest_rate( Examples -------- >>> from openbb import obb - >>> obb.economy.long_term_interest_rate() - >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly') + >>> obb.economy.long_term_interest_rate(provider='oecd') + >>> obb.economy.long_term_interest_rate(country='all', frequency='quarterly', provider='oecd') """ # noqa: E501 return self._run( @@ -1284,8 +1002,8 @@ def money_measures( Examples -------- >>> from openbb import obb - >>> obb.economy.money_measures() - >>> obb.economy.money_measures(adjusted=False) + >>> obb.economy.money_measures(provider='federal_reserve') + >>> obb.economy.money_measures(adjusted=False, provider='federal_reserve') """ # noqa: E501 return self._run( @@ -1349,7 +1067,7 @@ def risk_premium( Examples -------- >>> from openbb import obb - >>> obb.economy.risk_premium() + >>> obb.economy.risk_premium(provider='fmp') """ # noqa: E501 return self._run( @@ -1434,8 +1152,8 @@ def short_term_interest_rate( Examples -------- >>> from openbb import obb - >>> obb.economy.short_term_interest_rate() - >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly') + >>> obb.economy.short_term_interest_rate(provider='oecd') + >>> obb.economy.short_term_interest_rate(country='all', frequency='quarterly', provider='oecd') """ # noqa: E501 return self._run( @@ -1524,10 +1242,10 @@ def unemployment( Examples -------- >>> from openbb import obb - >>> obb.economy.unemployment() - >>> obb.economy.unemployment(country='all', frequency='quarterly') + >>> obb.economy.unemployment(provider='oecd') + >>> obb.economy.unemployment(country='all', frequency='quarterly', provider='oecd') >>> # Demographics for the statistics are selected with the `age` and `sex` parameters. - >>> obb.economy.unemployment(country='all', frequency='quarterly', age='25-54') + >>> obb.economy.unemployment(country='all', frequency='quarterly', age='25-54', provider='oecd') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/economy_gdp.py b/openbb_platform/openbb/package/economy_gdp.py index 9e1d7ca27a50..004a859f48c7 100644 --- a/openbb_platform/openbb/package/economy_gdp.py +++ b/openbb_platform/openbb/package/economy_gdp.py @@ -95,8 +95,8 @@ def forecast( Examples -------- >>> from openbb import obb - >>> obb.economy.gdp.forecast() - >>> obb.economy.gdp.forecast(period='annual', type='real') + >>> obb.economy.gdp.forecast(provider='oecd') + >>> obb.economy.gdp.forecast(period='annual', type='real', provider='oecd') """ # noqa: E501 return self._run( @@ -185,8 +185,8 @@ def nominal( Examples -------- >>> from openbb import obb - >>> obb.economy.gdp.nominal() - >>> obb.economy.gdp.nominal(units='usd') + >>> obb.economy.gdp.nominal(provider='oecd') + >>> obb.economy.gdp.nominal(units='usd', provider='oecd') """ # noqa: E501 return self._run( @@ -274,8 +274,8 @@ def real( Examples -------- >>> from openbb import obb - >>> obb.economy.gdp.real() - >>> obb.economy.gdp.real(units='yoy') + >>> obb.economy.gdp.real(provider='oecd') + >>> obb.economy.gdp.real(units='yoy', provider='oecd') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index 3db5a1b1cc13..fb01d3b6831d 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -14,7 +14,6 @@ class ROUTER_equity(Container): """/equity /calendar /compare - /darkpool /discovery /estimates /fundamental @@ -46,15 +45,6 @@ def compare(self): return equity_compare.ROUTER_equity_compare(command_runner=self._command_runner) - @property - def darkpool(self): - # pylint: disable=import-outside-toplevel - from . import equity_darkpool - - return equity_darkpool.ROUTER_equity_darkpool( - command_runner=self._command_runner - ) - @property def discovery(self): # pylint: disable=import-outside-toplevel @@ -198,7 +188,7 @@ def market_snapshots( Examples -------- >>> from openbb import obb - >>> obb.equity.market_snapshots() + >>> obb.equity.market_snapshots(provider='fmp') """ # noqa: E501 return self._run( @@ -239,12 +229,10 @@ def profile( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp, intrinio, tmx, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance." ), ], - provider: Optional[ - Literal["finviz", "fmp", "intrinio", "tmx", "yfinance"] - ] = None, + provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: """Get general information about a company. This includes company name, industry, sector and price data. @@ -252,10 +240,10 @@ def profile( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp, intrinio, tmx, yfinance. - provider : Optional[Literal['finviz', 'fmp', 'intrinio', 'tmx', 'yfinance']] + Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance. + provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'finviz' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. Returns @@ -263,7 +251,7 @@ def profile( OBBject results : List[EquityInfo] Serializable results. - provider : Optional[Literal['finviz', 'fmp', 'intrinio', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -350,33 +338,6 @@ def profile( Date of the company's first stock price. last_stock_price_date : Optional[date] Date of the company's last stock price. - index : Optional[str] - Included in indices - i.e., Dow, Nasdaq, or S&P. (provider: finviz) - optionable : Optional[str] - Whether options trade against the ticker. (provider: finviz) - shortable : Optional[str] - If the asset is shortable. (provider: finviz) - shares_outstanding : Optional[Union[str, int]] - The number of shares outstanding, as an abbreviated string. (provider: finviz); - The number of listed shares outstanding. (provider: tmx); - The number of listed shares outstanding. (provider: yfinance) - shares_float : Optional[Union[str, int]] - The number of shares in the public float, as an abbreviated string. (provider: finviz); - The number of shares in the public float. (provider: yfinance) - short_interest : Optional[str] - The last reported number of shares sold short, as an abbreviated string. (provider: finviz) - institutional_ownership : Optional[float] - The institutional ownership of the stock, as a normalized percent. (provider: finviz) - market_cap : Optional[int] - The market capitalization of the stock, as an abbreviated string. (provider: finviz); - Market capitalization of the company. (provider: fmp); - The market capitalization of the asset. (provider: yfinance) - dividend_yield : Optional[float] - The dividend yield of the stock, as a normalized percent. (provider: finviz, yfinance) - earnings_date : Optional[str] - The last, or next confirmed, earnings date and announcement time, as a string. The format is Nov 02 AMC - for after market close. (provider: finviz) - beta : Optional[float] - The beta of the stock relative to the broad market. (provider: finviz, fmp, yfinance) is_etf : Optional[bool] If the symbol is an ETF. (provider: fmp) is_actively_trading : Optional[bool] @@ -389,6 +350,9 @@ def profile( Image of the company. (provider: fmp) currency : Optional[str] Currency in which the stock is traded. (provider: fmp, yfinance) + market_cap : Optional[int] + Market capitalization of the company. (provider: fmp); + The market capitalization of the asset. (provider: yfinance) last_price : Optional[float] The last traded price. (provider: fmp) year_high : Optional[float] @@ -399,31 +363,31 @@ def profile( Average daily trading volume. (provider: fmp) annualized_dividend_amount : Optional[float] The annualized dividend payment based on the most recent regular dividend payment. (provider: fmp) + beta : Optional[float] + Beta of the stock relative to the market. (provider: fmp, yfinance) id : Optional[str] Intrinio ID for the company. (provider: intrinio) thea_enabled : Optional[bool] Whether the company has been enabled for Thea. (provider: intrinio) - email : Optional[str] - The email of the company. (provider: tmx) - issue_type : Optional[str] - The issuance type of the asset. (provider: tmx, yfinance) - shares_escrow : Optional[int] - The number of shares held in escrow. (provider: tmx) - shares_total : Optional[int] - The total number of shares outstanding from all classes. (provider: tmx) - dividend_frequency : Optional[str] - The dividend frequency. (provider: tmx) exchange_timezone : Optional[str] The timezone of the exchange. (provider: yfinance) + issue_type : Optional[str] + The issuance type of the asset. (provider: yfinance) + shares_outstanding : Optional[int] + The number of listed shares outstanding. (provider: yfinance) + shares_float : Optional[int] + The number of shares in the public float. (provider: yfinance) shares_implied_outstanding : Optional[int] Implied shares outstanding of common equityassuming the conversion of all convertible subsidiary equity into common. (provider: yfinance) shares_short : Optional[int] The reported number of shares short. (provider: yfinance) + dividend_yield : Optional[float] + The dividend yield of the asset, as a normalized percent. (provider: yfinance) Examples -------- >>> from openbb import obb - >>> obb.equity.profile(symbol='AAPL') + >>> obb.equity.profile(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -433,7 +397,7 @@ def profile( "provider": self._get_provider( provider, "/equity/profile", - ("finviz", "fmp", "intrinio", "tmx", "yfinance"), + ("fmp", "intrinio", "yfinance"), ) }, standard_params={ @@ -442,13 +406,7 @@ def profile( extra_params=kwargs, extra_info={ "symbol": { - "multiple_items_allowed": [ - "finviz", - "fmp", - "intrinio", - "tmx", - "yfinance", - ] + "multiple_items_allowed": ["fmp", "intrinio", "yfinance"] } }, ) @@ -549,7 +507,7 @@ def screener(self, provider: Optional[Literal["fmp"]] = None, **kwargs) -> OBBje Examples -------- >>> from openbb import obb - >>> obb.equity.screener() + >>> obb.equity.screener(provider='fmp') """ # noqa: E501 return self._run( @@ -580,7 +538,7 @@ def search( Optional[bool], OpenBBCustomParameter(description="Whether to use the cache or not."), ] = True, - provider: Optional[Literal["cboe", "intrinio", "nasdaq", "sec", "tmx"]] = None, + provider: Optional[Literal["intrinio", "sec"]] = None, **kwargs ) -> OBBject: """Search for stock symbol, CIK, LEI, or company name. @@ -593,16 +551,14 @@ def search( Whether to search by ticker symbol. use_cache : Optional[bool] Whether to use the cache or not. - provider : Optional[Literal['cboe', 'intrinio', 'nasdaq', 'sec', 'tmx']] + provider : Optional[Literal['intrinio', 'sec']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'cboe' if there is + If None, the provider specified in defaults is selected or 'intrinio' if there is no default. active : Optional[bool] When true, return companies that are actively traded (having stock prices within the past 14 days). When false, return companies that are not actively traded or never have been traded. (provider: intrinio) limit : Optional[int] The number of data entries to return. (provider: intrinio) - is_etf : Optional[bool] - If True, returns ETFs. (provider: nasdaq) is_fund : bool Whether to direct the search to the list of mutual funds and ETFs. (provider: sec) @@ -611,7 +567,7 @@ def search( OBBject results : List[EquitySearch] Serializable results. - provider : Optional[Literal['cboe', 'intrinio', 'nasdaq', 'sec', 'tmx']] + provider : Optional[Literal['intrinio', 'sec']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -626,10 +582,6 @@ def search( Symbol representing the entity requested in the data. name : str Name of the company. - dpm_name : Optional[str] - Name of the primary market maker. (provider: cboe) - post_station : Optional[str] - Post and station location on the CBOE trading floor. (provider: cboe) cik : Optional[str] ; Central Index Key (provider: sec) @@ -637,32 +589,11 @@ def search( The Legal Entity Identifier (LEI) of the company. (provider: intrinio) intrinio_id : Optional[str] The Intrinio ID of the company. (provider: intrinio) - nasdaq_traded : Optional[str] - Is Nasdaq traded? (provider: nasdaq) - exchange : Optional[str] - Primary Exchange (provider: nasdaq) - market_category : Optional[str] - Market Category (provider: nasdaq) - etf : Optional[str] - Is ETF? (provider: nasdaq) - round_lot_size : Optional[float] - Round Lot Size (provider: nasdaq) - test_issue : Optional[str] - Is test Issue? (provider: nasdaq) - financial_status : Optional[str] - Financial Status (provider: nasdaq) - cqs_symbol : Optional[str] - CQS Symbol (provider: nasdaq) - nasdaq_symbol : Optional[str] - NASDAQ Symbol (provider: nasdaq) - next_shares : Optional[str] - Is NextShares? (provider: nasdaq) Examples -------- >>> from openbb import obb - >>> obb.equity.search() - >>> obb.equity.search(query='AAPL', is_symbol=False, use_cache=True) + >>> obb.equity.search(provider='intrinio') """ # noqa: E501 return self._run( @@ -672,7 +603,7 @@ def search( "provider": self._get_provider( provider, "/equity/search", - ("cboe", "intrinio", "nasdaq", "sec", "tmx"), + ("intrinio", "sec"), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/equity_calendar.py b/openbb_platform/openbb/package/equity_calendar.py index 6a744658d95d..0b7a6e222fed 100644 --- a/openbb_platform/openbb/package/equity_calendar.py +++ b/openbb_platform/openbb/package/equity_calendar.py @@ -38,7 +38,7 @@ def dividend( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "nasdaq"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Get historical and upcoming dividend payments. Includes dividend amount, ex-dividend and payment dates. @@ -49,7 +49,7 @@ def dividend( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'nasdaq']] + provider : Optional[Literal['fmp']] 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. @@ -59,7 +59,7 @@ def dividend( OBBject results : List[CalendarDividend] Serializable results. - provider : Optional[Literal['fmp', 'nasdaq']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -88,15 +88,11 @@ def dividend( The adjusted-dividend amount. (provider: fmp) label : Optional[str] Ex-dividend date formatted for display. (provider: fmp) - annualized_amount : Optional[float] - The indicated annualized dividend amount. (provider: nasdaq) Examples -------- >>> from openbb import obb - >>> obb.equity.calendar.dividend() - >>> # Get dividend calendar for specific dates. - >>> obb.equity.calendar.dividend(start_date='2024-02-01', end_date='2024-02-07') + >>> obb.equity.calendar.dividend(provider='fmp') """ # noqa: E501 return self._run( @@ -106,7 +102,7 @@ def dividend( "provider": self._get_provider( provider, "/equity/calendar/dividend", - ("fmp", "nasdaq"), + ("fmp",), ) }, standard_params={ @@ -133,7 +129,7 @@ def earnings( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "nasdaq", "tmx"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Get historical and upcoming company earnings releases. Includes earnings per share (EPS) and revenue data. @@ -144,7 +140,7 @@ def earnings( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'nasdaq', 'tmx']] + provider : Optional[Literal['fmp']] 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. @@ -154,7 +150,7 @@ def earnings( OBBject results : List[CalendarEarnings] Serializable results. - provider : Optional[Literal['fmp', 'nasdaq', 'tmx']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -176,37 +172,24 @@ def earnings( eps_consensus : Optional[float] The analyst conesus earnings-per-share estimate. eps_actual : Optional[float] - The actual earnings per share announced. (provider: fmp, nasdaq); - The actual EPS in dollars. (provider: tmx) + The actual earnings per share announced. (provider: fmp) revenue_actual : Optional[float] The actual reported revenue. (provider: fmp) revenue_consensus : Optional[float] The revenue forecast consensus. (provider: fmp) - period_ending : Optional[Union[date, str]] - The fiscal period end date. (provider: fmp, nasdaq) + period_ending : Optional[date] + The fiscal period end date. (provider: fmp) reporting_time : Optional[str] - The reporting time - e.g. after market close. (provider: fmp, nasdaq); - The time of the report - i.e., before or after market. (provider: tmx) + The reporting time - e.g. after market close. (provider: fmp) updated_date : Optional[date] The date the data was updated last. (provider: fmp) - surprise_percent : Optional[float] - The earnings surprise as normalized percentage points. (provider: nasdaq); - The EPS surprise as a normalized percent. (provider: tmx) - num_estimates : Optional[int] - The number of analysts providing estimates for the consensus. (provider: nasdaq) - previous_report_date : Optional[date] - The previous report date for the same period last year. (provider: nasdaq) - market_cap : Optional[int] - The market cap (USD) of the reporting entity. (provider: nasdaq) - eps_surprise : Optional[float] - The EPS surprise in dollars. (provider: tmx) Examples -------- >>> from openbb import obb - >>> obb.equity.calendar.earnings() + >>> obb.equity.calendar.earnings(provider='fmp') >>> # Get earnings calendar for specific dates. - >>> obb.equity.calendar.earnings(start_date='2024-02-01', end_date='2024-02-07') + >>> obb.equity.calendar.earnings(start_date='2024-02-01', end_date='2024-02-07', provider='fmp') """ # noqa: E501 return self._run( @@ -216,7 +199,7 @@ def earnings( "provider": self._get_provider( provider, "/equity/calendar/earnings", - ("fmp", "nasdaq", "tmx"), + ("fmp",), ) }, standard_params={ @@ -250,7 +233,7 @@ def ipo( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["intrinio", "nasdaq"]] = None, + provider: Optional[Literal["intrinio"]] = None, **kwargs ) -> OBBject: """Get historical and upcoming initial public offerings (IPOs). @@ -265,26 +248,23 @@ def ipo( End date of the data, in YYYY-MM-DD format. limit : Optional[int] The number of data entries to return. - provider : Optional[Literal['intrinio', 'nasdaq']] + provider : Optional[Literal['intrinio']] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'intrinio' if there is no default. - status : Optional[Union[Literal['upcoming', 'priced', 'withdrawn'], Literal['upcoming', 'priced', 'filed', 'withdrawn']]] - Status of the IPO. [upcoming, priced, or withdrawn] (provider: intrinio); - The status of the IPO. (provider: nasdaq) + status : Optional[Literal['upcoming', 'priced', 'withdrawn']] + Status of the IPO. [upcoming, priced, or withdrawn] (provider: intrinio) min_value : Optional[int] Return IPOs with an offer dollar amount greater than the given amount. (provider: intrinio) max_value : Optional[int] Return IPOs with an offer dollar amount less than the given amount. (provider: intrinio) - is_spo : bool - If True, returns data for secondary public offerings (SPOs). (provider: nasdaq) Returns ------- OBBject results : List[CalendarIpo] Serializable results. - provider : Optional[Literal['intrinio', 'nasdaq']] + provider : Optional[Literal['intrinio']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -311,8 +291,7 @@ def ipo( Typically NYSE or NASDAQ. (provider: intrinio) offer_amount : Optional[float] - The total dollar amount of shares offered in the IPO. Typically this is share price * share count (provider: intrinio); - The dollar value of the shares offered. (provider: nasdaq) + The total dollar amount of shares offered in the IPO. Typically this is share price * share count (provider: intrinio) share_price : Optional[float] The price per share at which the IPO was offered. (provider: intrinio) share_price_lowest : Optional[float] @@ -328,7 +307,7 @@ def ipo( they expect to offer the IPO (typically available for upcoming IPOs). (provider: intrinio) share_count : Optional[int] - The number of shares offered in the IPO. (provider: intrinio, nasdaq) + The number of shares offered in the IPO. (provider: intrinio) share_count_lowest : Optional[int] The expected lowest number of shares that will be offered in the IPO. Before an IPO is priced, @@ -375,26 +354,13 @@ def ipo( The company that is going public via the IPO. (provider: intrinio) security : Optional[openbb_intrinio.utils.references.IntrinioSecurity] The primary Security for the Company that is going public via the IPO (provider: intrinio) - name : Optional[str] - The name of the company. (provider: nasdaq) - expected_price_date : Optional[date] - The date the pricing is expected. (provider: nasdaq) - filed_date : Optional[date] - The date the IPO was filed. (provider: nasdaq) - withdraw_date : Optional[date] - The date the IPO was withdrawn. (provider: nasdaq) - deal_status : Optional[str] - The status of the deal. (provider: nasdaq) Examples -------- >>> from openbb import obb - >>> obb.equity.calendar.ipo() - >>> obb.equity.calendar.ipo(limit=100) + >>> obb.equity.calendar.ipo(provider='intrinio') >>> # Get all IPOs available. - >>> obb.equity.calendar.ipo() - >>> # Get IPOs for specific dates. - >>> obb.equity.calendar.ipo(start_date='2024-02-01', end_date='2024-02-07') + >>> obb.equity.calendar.ipo(provider='intrinio') """ # noqa: E501 return self._run( @@ -404,7 +370,7 @@ def ipo( "provider": self._get_provider( provider, "/equity/calendar/ipo", - ("intrinio", "nasdaq"), + ("intrinio",), ) }, standard_params={ @@ -479,9 +445,9 @@ def splits( Examples -------- >>> from openbb import obb - >>> obb.equity.calendar.splits() + >>> obb.equity.calendar.splits(provider='fmp') >>> # Get stock splits calendar for specific dates. - >>> obb.equity.calendar.splits(start_date='2024-02-01', end_date='2024-02-07') + >>> obb.equity.calendar.splits(start_date='2024-02-01', end_date='2024-02-07', provider='fmp') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_compare.py b/openbb_platform/openbb/package/equity_compare.py index e5eb310c8a22..857e3762c98f 100644 --- a/openbb_platform/openbb/package/equity_compare.py +++ b/openbb_platform/openbb/package/equity_compare.py @@ -12,139 +12,12 @@ class ROUTER_equity_compare(Container): """/equity/compare - groups peers """ def __repr__(self) -> str: return self.__doc__ or "" - @exception_handler - @validate - def groups( - self, - group: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="The group to compare - i.e., 'sector', 'industry', 'country'. Choices vary by provider." - ), - ] = None, - metric: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="The type of metrics to compare - i.e, 'valuation', 'performance'. Choices vary by provider." - ), - ] = None, - provider: Optional[Literal["finviz"]] = None, - **kwargs - ) -> OBBject: - """Get company data grouped by sector, industry or country and display either performance or valuation metrics. - - Valuation metrics include price to earnings, price to book, price to sales ratios and price to cash flow. - Performance metrics include the stock price change for different time periods. - - Parameters - ---------- - group : Optional[str] - The group to compare - i.e., 'sector', 'industry', 'country'. Choices vary by provider. - metric : Optional[str] - The type of metrics to compare - i.e, 'valuation', 'performance'. Choices vary by provider. - provider : Optional[Literal['finviz']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'finviz' if there is - no default. - - Returns - ------- - OBBject - results : List[CompareGroups] - Serializable results. - provider : Optional[Literal['finviz']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - CompareGroups - ------------- - name : str - Name or label of the group. - stocks : Optional[int] - The number of stocks in the group. (provider: finviz) - market_cap : Optional[int] - The market cap of the group. (provider: finviz) - performance_1_d : Optional[float] - The performance in the last day, as a normalized percent. (provider: finviz) - performance_1_w : Optional[float] - The performance in the last week, as a normalized percent. (provider: finviz) - performance_1_m : Optional[float] - The performance in the last month, as a normalized percent. (provider: finviz) - performance_3_m : Optional[float] - The performance in the last quarter, as a normalized percent. (provider: finviz) - performance_6_m : Optional[float] - The performance in the last half year, as a normalized percent. (provider: finviz) - performance_1_y : Optional[float] - The performance in the last year, as a normalized percent. (provider: finviz) - performance_ytd : Optional[float] - The performance in the year to date, as a normalized percent. (provider: finviz) - dividend_yield : Optional[float] - The dividend yield of the group, as a normalized percent. (provider: finviz) - pe : Optional[float] - The P/E ratio of the group. (provider: finviz) - forward_pe : Optional[float] - The forward P/E ratio of the group. (provider: finviz) - peg : Optional[float] - The PEG ratio of the group. (provider: finviz) - eps_growth_past_5_years : Optional[float] - The EPS growth of the group for the past 5 years, as a normalized percent. (provider: finviz) - eps_growth_next_5_years : Optional[float] - The estimated EPS growth of the groupo for the next 5 years, as a normalized percent. (provider: finviz) - sales_growth_past_5_years : Optional[float] - The sales growth of the group for the past 5 years, as a normalized percent. (provider: finviz) - float_short : Optional[float] - The percent of the float shorted for the group, as a normalized value. (provider: finviz) - analyst_recommendation : Optional[float] - The analyst consensus, on a scale of 1-5 where 1 is a buy and 5 is a sell. (provider: finviz) - volume : Optional[int] - The trading volume. (provider: finviz) - volume_average : Optional[int] - The 3-month average volume of the group. (provider: finviz) - volume_relative : Optional[float] - The relative volume compared to the 3-month average volume. (provider: finviz) - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.compare.groups() - >>> # Group by sector and analyze valuation. - >>> obb.equity.compare.groups(group='sector', metric='valuation') - >>> # Group by industry and analyze performance. - >>> obb.equity.compare.groups(group='industry', metric='performance') - >>> # Group by country and analyze valuation. - >>> obb.equity.compare.groups(group='country', metric='valuation') - """ # noqa: E501 - - return self._run( - "/equity/compare/groups", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/equity/compare/groups", - ("finviz",), - ) - }, - standard_params={ - "group": group, - "metric": metric, - }, - extra_params=kwargs, - ) - ) - @exception_handler @validate def peers( @@ -191,7 +64,7 @@ def peers( Examples -------- >>> from openbb import obb - >>> obb.equity.compare.peers(symbol='AAPL') + >>> obb.equity.compare.peers(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_discovery.py b/openbb_platform/openbb/package/equity_discovery.py index 23822c0e8e0e..b3429c2d6f92 100644 --- a/openbb_platform/openbb/package/equity_discovery.py +++ b/openbb_platform/openbb/package/equity_discovery.py @@ -19,10 +19,8 @@ class ROUTER_equity_discovery(Container): gainers growth_tech losers - top_retail undervalued_growth undervalued_large_caps - upcoming_release_days """ def __repr__(self) -> str: @@ -90,8 +88,8 @@ def active( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.active() - >>> obb.equity.discovery.active(sort='desc') + >>> obb.equity.discovery.active(provider='yfinance') + >>> obb.equity.discovery.active(sort='desc', provider='yfinance') """ # noqa: E501 return self._run( @@ -173,8 +171,8 @@ def aggressive_small_caps( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.aggressive_small_caps() - >>> obb.equity.discovery.aggressive_small_caps(sort='desc') + >>> obb.equity.discovery.aggressive_small_caps(provider='yfinance') + >>> obb.equity.discovery.aggressive_small_caps(sort='desc', provider='yfinance') """ # noqa: E501 return self._run( @@ -279,9 +277,9 @@ def filings( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.filings() + >>> obb.equity.discovery.filings(provider='fmp') >>> # Get filings for the year 2023, limited to 100 results - >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31', limit=100) + >>> obb.equity.discovery.filings(start_date='2023-01-01', end_date='2023-12-31', limit=100, provider='fmp') """ # noqa: E501 return self._run( @@ -314,7 +312,7 @@ def gainers( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["tmx", "yfinance"]] = None, + provider: Optional[Literal["yfinance"]] = None, **kwargs ) -> OBBject: """Get the top price gainers in the stock market. @@ -323,19 +321,17 @@ def gainers( ---------- sort : Literal['asc', 'desc'] Sort order. Possible values: 'asc', 'desc'. Default: 'desc'. - provider : Optional[Literal['tmx', 'yfinance']] + provider : Optional[Literal['yfinance']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'tmx' if there is + If None, the provider specified in defaults is selected or 'yfinance' if there is no default. - category : Literal['dividend', 'energy', 'healthcare', 'industrials', 'price_performer', 'rising_stars', 'real_estate', 'tech', 'utilities', '52w_high', 'volume'] - The category of list to retrieve. Defaults to `price_performer`. (provider: tmx) Returns ------- OBBject results : List[EquityGainers] Serializable results. - provider : Optional[Literal['tmx', 'yfinance']] + provider : Optional[Literal['yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -358,8 +354,6 @@ def gainers( Percent change. volume : float The trading volume. - rank : Optional[int] - The rank of the stock in the list. (provider: tmx) market_cap : Optional[float] Market Cap. (provider: yfinance) avg_volume_3_months : Optional[float] @@ -370,8 +364,8 @@ def gainers( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.gainers() - >>> obb.equity.discovery.gainers(sort='desc') + >>> obb.equity.discovery.gainers(provider='yfinance') + >>> obb.equity.discovery.gainers(sort='desc', provider='yfinance') """ # noqa: E501 return self._run( @@ -381,7 +375,7 @@ def gainers( "provider": self._get_provider( provider, "/equity/discovery/gainers", - ("tmx", "yfinance"), + ("yfinance",), ) }, standard_params={ @@ -453,8 +447,8 @@ def growth_tech( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.growth_tech() - >>> obb.equity.discovery.growth_tech(sort='desc') + >>> obb.equity.discovery.growth_tech(provider='yfinance') + >>> obb.equity.discovery.growth_tech(sort='desc', provider='yfinance') """ # noqa: E501 return self._run( @@ -536,8 +530,8 @@ def losers( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.losers() - >>> obb.equity.discovery.losers(sort='desc') + >>> obb.equity.discovery.losers(provider='yfinance') + >>> obb.equity.discovery.losers(sort='desc', provider='yfinance') """ # noqa: E501 return self._run( @@ -557,79 +551,6 @@ def losers( ) ) - @exception_handler - @validate - def top_retail( - self, - limit: Annotated[ - int, - OpenBBCustomParameter(description="The number of data entries to return."), - ] = 5, - provider: Optional[Literal["nasdaq"]] = None, - **kwargs - ) -> OBBject: - """Tracks over $30B USD/day of individual investors trades. - - It gives a daily view into retail activity and sentiment for over 9,500 US traded stocks, - ADRs, and ETPs. - - Parameters - ---------- - limit : int - The number of data entries to return. - provider : Optional[Literal['nasdaq']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'nasdaq' if there is - no default. - - Returns - ------- - OBBject - results : List[TopRetail] - Serializable results. - provider : Optional[Literal['nasdaq']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - TopRetail - --------- - date : date - The date of the data. - symbol : str - Symbol representing the entity requested in the data. - activity : float - Activity of the symbol. - sentiment : float - Sentiment of the symbol. 1 is bullish, -1 is bearish. - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.discovery.top_retail() - """ # noqa: E501 - - return self._run( - "/equity/discovery/top_retail", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/equity/discovery/top_retail", - ("nasdaq",), - ) - }, - standard_params={ - "limit": limit, - }, - extra_params=kwargs, - ) - ) - @exception_handler @validate def undervalued_growth( @@ -692,8 +613,8 @@ def undervalued_growth( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.undervalued_growth() - >>> obb.equity.discovery.undervalued_growth(sort='desc') + >>> obb.equity.discovery.undervalued_growth(provider='yfinance') + >>> obb.equity.discovery.undervalued_growth(sort='desc', provider='yfinance') """ # noqa: E501 return self._run( @@ -775,8 +696,8 @@ def undervalued_large_caps( Examples -------- >>> from openbb import obb - >>> obb.equity.discovery.undervalued_large_caps() - >>> obb.equity.discovery.undervalued_large_caps(sort='desc') + >>> obb.equity.discovery.undervalued_large_caps(provider='yfinance') + >>> obb.equity.discovery.undervalued_large_caps(sort='desc', provider='yfinance') """ # noqa: E501 return self._run( @@ -795,69 +716,3 @@ def undervalued_large_caps( extra_params=kwargs, ) ) - - @exception_handler - @validate - def upcoming_release_days( - self, provider: Optional[Literal["seeking_alpha"]] = None, **kwargs - ) -> OBBject: - """Get upcoming earnings release dates. - - Parameters - ---------- - provider : Optional[Literal['seeking_alpha']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'seeking_alpha' if there is - no default. - limit : int - The number of data entries to return.In this case, the number of lookahead days. (provider: seeking_alpha) - - Returns - ------- - OBBject - results : List[UpcomingReleaseDays] - Serializable results. - provider : Optional[Literal['seeking_alpha']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - UpcomingReleaseDays - ------------------- - symbol : str - Symbol representing the entity requested in the data. - name : str - The full name of the asset. - exchange : str - The exchange the asset is traded on. - release_time_type : str - The type of release time. - release_date : date - The date of the release. - sector_id : Optional[int] - The sector ID of the asset. (provider: seeking_alpha) - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.discovery.upcoming_release_days() - """ # noqa: E501 - - return self._run( - "/equity/discovery/upcoming_release_days", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/equity/discovery/upcoming_release_days", - ("seeking_alpha",), - ) - }, - standard_params={}, - extra_params=kwargs, - ) - ) diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py index 0fa4a3fc173f..62eeb6e7b4da 100644 --- a/openbb_platform/openbb/package/equity_estimates.py +++ b/openbb_platform/openbb/package/equity_estimates.py @@ -171,7 +171,7 @@ def analyst_search( Examples -------- >>> from openbb import obb - >>> obb.equity.estimates.analyst_search() + >>> obb.equity.estimates.analyst_search(provider='benzinga') >>> obb.equity.estimates.analyst_search(firm_name='Wedbush', provider='benzinga') """ # noqa: E501 @@ -200,10 +200,10 @@ def consensus( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): tmx, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." ), ], - provider: Optional[Literal["fmp", "tmx", "yfinance"]] = None, + provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: """Get consensus price target and recommendation. @@ -211,8 +211,8 @@ def consensus( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): tmx, yfinance. - provider : Optional[Literal['fmp', 'tmx', 'yfinance']] + Symbol to get data for. Multiple items allowed for provider(s): yfinance. + provider : Optional[Literal['fmp', 'yfinance']] 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. @@ -222,7 +222,7 @@ def consensus( OBBject results : Union[List[PriceTargetConsensus], PriceTargetConsensus] Serializable results. - provider : Optional[Literal['fmp', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -243,18 +243,6 @@ def consensus( Consensus target of the price target consensus. target_median : Optional[float] Median target of the price target consensus. - target_upside : Optional[float] - Percent of upside, as a normalized percent. (provider: tmx) - total_analysts : Optional[int] - Total number of analyst. (provider: tmx) - buy_ratings : Optional[int] - Number of buy ratings. (provider: tmx) - sell_ratings : Optional[int] - Number of sell ratings. (provider: tmx) - hold_ratings : Optional[int] - Number of hold ratings. (provider: tmx) - consensus_action : Optional[str] - Consensus action. (provider: tmx) recommendation : Optional[str] Recommendation - buy, sell, etc. (provider: yfinance) recommendation_mean : Optional[float] @@ -269,7 +257,7 @@ def consensus( Examples -------- >>> from openbb import obb - >>> obb.equity.estimates.consensus(symbol='AAPL') + >>> obb.equity.estimates.consensus(symbol='AAPL', provider='fmp') >>> obb.equity.estimates.consensus(symbol='AAPL,MSFT', provider='yfinance') """ # noqa: E501 @@ -280,14 +268,14 @@ def consensus( "provider": self._get_provider( provider, "/equity/estimates/consensus", - ("fmp", "tmx", "yfinance"), + ("fmp", "yfinance"), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["tmx", "yfinance"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["yfinance"]}}, ) ) @@ -388,7 +376,6 @@ def historical( Examples -------- >>> from openbb import obb - >>> obb.equity.estimates.historical(symbol='AAPL') >>> obb.equity.estimates.historical(symbol='AAPL', provider='fmp') """ # noqa: E501 @@ -418,14 +405,14 @@ def price_target( symbol: Annotated[ Union[str, None, List[Optional[str]]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): benzinga, finviz." + description="Symbol to get data for. Multiple items allowed for provider(s): benzinga." ), ] = None, limit: Annotated[ int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 200, - provider: Optional[Literal["benzinga", "finviz", "fmp"]] = None, + provider: Optional[Literal["benzinga", "fmp"]] = None, **kwargs ) -> OBBject: """Get analyst price targets by company. @@ -433,10 +420,10 @@ def price_target( Parameters ---------- symbol : Union[str, None, List[Optional[str]]] - Symbol to get data for. Multiple items allowed for provider(s): benzinga, finviz. + Symbol to get data for. Multiple items allowed for provider(s): benzinga. limit : int The number of data entries to return. - provider : Optional[Literal['benzinga', 'finviz', 'fmp']] + provider : Optional[Literal['benzinga', 'fmp']] 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. @@ -468,7 +455,7 @@ def price_target( OBBject results : List[PriceTarget] Serializable results. - provider : Optional[Literal['benzinga', 'finviz', 'fmp']] + provider : Optional[Literal['benzinga', 'fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -527,10 +514,6 @@ def price_target( Unique ID of this entry. (provider: benzinga) last_updated : Optional[datetime] Last updated timestamp, UTC. (provider: benzinga) - status : Optional[str] - The action taken by the firm. This could be 'Upgrade', 'Downgrade', 'Reiterated', etc. (provider: finviz) - rating_change : Optional[str] - The rating given by the analyst. This could be 'Buy', 'Sell', 'Underweight', etc. If the rating is a revision, the change is indicated by '->' (provider: finviz) news_url : Optional[str] News URL of the price target. (provider: fmp) news_title : Optional[str] @@ -543,7 +526,7 @@ def price_target( Examples -------- >>> from openbb import obb - >>> obb.equity.estimates.price_target() + >>> obb.equity.estimates.price_target(provider='benzinga') >>> # Get price targets for Microsoft using 'benzinga' as provider. >>> obb.equity.estimates.price_target(start_date='2020-01-01', end_date='2024-02-16', limit=10, symbol='msft', provider='benzinga', action='downgrades') """ # noqa: E501 @@ -555,7 +538,7 @@ def price_target( "provider": self._get_provider( provider, "/equity/estimates/price_target", - ("benzinga", "finviz", "fmp"), + ("benzinga", "fmp"), ) }, standard_params={ @@ -563,8 +546,6 @@ def price_target( "limit": limit, }, extra_params=kwargs, - extra_info={ - "symbol": {"multiple_items_allowed": ["benzinga", "finviz"]} - }, + extra_info={"symbol": {"multiple_items_allowed": ["benzinga"]}}, ) ) diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index c8b22923deb3..cfaccbb402e7 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -380,8 +380,8 @@ def balance( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.balance(symbol='AAPL') - >>> obb.equity.fundamental.balance(symbol='AAPL', period='annual', limit=5) + >>> obb.equity.fundamental.balance(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.balance(symbol='AAPL', period='annual', limit=5, provider='intrinio') """ # noqa: E501 return self._run( @@ -534,8 +534,8 @@ def balance_growth( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.balance_growth(symbol='AAPL') - >>> obb.equity.fundamental.balance_growth(symbol='AAPL', limit=10) + >>> obb.equity.fundamental.balance_growth(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.balance_growth(symbol='AAPL', limit=10, provider='intrinio') """ # noqa: E501 return self._run( @@ -798,8 +798,8 @@ def cash( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.cash(symbol='AAPL') - >>> obb.equity.fundamental.cash(symbol='AAPL', period='annual', limit=5) + >>> obb.equity.fundamental.cash(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.cash(symbol='AAPL', period='annual', limit=5, provider='intrinio') """ # noqa: E501 return self._run( @@ -934,8 +934,8 @@ def cash_growth( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.cash_growth(symbol='AAPL') - >>> obb.equity.fundamental.cash_growth(symbol='AAPL', limit=10) + >>> obb.equity.fundamental.cash_growth(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.cash_growth(symbol='AAPL', limit=10, provider='intrinio') """ # noqa: E501 return self._run( @@ -961,10 +961,7 @@ def cash_growth( def dividends( self, symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): nasdaq." - ), + str, OpenBBCustomParameter(description="Symbol to get data for.") ], start_date: Annotated[ Union[datetime.date, None, str], @@ -978,22 +975,20 @@ def dividends( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[ - Literal["fmp", "intrinio", "nasdaq", "tmx", "yfinance"] - ] = None, + provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: """Get historical dividend data for a given company. Parameters ---------- - symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): nasdaq. + symbol : str + Symbol to get data for. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fmp', 'intrinio', 'nasdaq', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] 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. @@ -1005,7 +1000,7 @@ def dividends( OBBject results : List[HistoricalDividends] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'nasdaq', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1025,30 +1020,22 @@ def dividends( adj_dividend : Optional[float] Adjusted dividend of the historical dividends. (provider: fmp) record_date : Optional[date] - Record date of the historical dividends. (provider: fmp); - The record date of ownership for eligibility. (provider: nasdaq); - The record date of ownership for rights to the dividend. (provider: tmx) + Record date of the historical dividends. (provider: fmp) payment_date : Optional[date] - Payment date of the historical dividends. (provider: fmp); - The payment date of the dividend. (provider: nasdaq); - The date the dividend is paid. (provider: tmx) + Payment date of the historical dividends. (provider: fmp) declaration_date : Optional[date] - Declaration date of the historical dividends. (provider: fmp, nasdaq) + Declaration date of the historical dividends. (provider: fmp) factor : Optional[float] factor by which to multiply stock prices before this date, in order to calculate historically-adjusted stock prices. (provider: intrinio) currency : Optional[str] - The currency in which the dividend is paid. (provider: intrinio, nasdaq, tmx) + The currency in which the dividend is paid. (provider: intrinio) split_ratio : Optional[float] The ratio of the stock split, if a stock split occurred. (provider: intrinio) - dividend_type : Optional[str] - The type of dividend - i.e., cash, stock. (provider: nasdaq) - decalaration_date : Optional[date] - The date of the announcement. (provider: tmx) Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.dividends(symbol='AAPL') + >>> obb.equity.fundamental.dividends(symbol='AAPL', provider='intrinio') """ # noqa: E501 return self._run( @@ -1058,7 +1045,7 @@ def dividends( "provider": self._get_provider( provider, "/equity/fundamental/dividends", - ("fmp", "intrinio", "nasdaq", "tmx", "yfinance"), + ("fmp", "intrinio", "yfinance"), ) }, standard_params={ @@ -1067,7 +1054,6 @@ def dividends( "end_date": end_date, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["nasdaq"]}}, ) ) @@ -1130,7 +1116,7 @@ def employee_count( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.employee_count(symbol='AAPL') + >>> obb.equity.fundamental.employee_count(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -1167,7 +1153,7 @@ def filings( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["fmp", "intrinio", "sec", "tmx"]] = None, + provider: Optional[Literal["fmp", "intrinio", "sec"]] = None, **kwargs ) -> OBBject: """Get the URLs to SEC filings reported to EDGAR database, such as 10-K, 10-Q, 8-K, and more. SEC @@ -1185,16 +1171,14 @@ def filings( Filter by form type. Check the data provider for available types. limit : int The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio', 'sec', 'tmx']] + provider : Optional[Literal['fmp', 'intrinio', 'sec']] 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. start_date : Optional[datetime.date] - Start date of the data, in YYYY-MM-DD format. (provider: intrinio); - The start date to fetch. (provider: tmx) + Start date of the data, in YYYY-MM-DD format. (provider: intrinio) end_date : Optional[datetime.date] - End date of the data, in YYYY-MM-DD format. (provider: intrinio); - The end date to fetch. (provider: tmx) + End date of the data, in YYYY-MM-DD format. (provider: intrinio) thea_enabled : Optional[bool] Return filings that have been read by Intrinio's Thea NLP. (provider: intrinio) cik : Optional[Union[int, str]] @@ -1209,7 +1193,7 @@ def filings( OBBject results : List[CompanyFilings] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'sec', 'tmx']] + provider : Optional[Literal['fmp', 'intrinio', 'sec']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1267,20 +1251,17 @@ def filings( is_xbrl : Optional[Union[int, str]] Whether the filing is an XBRL filing. (provider: sec) size : Optional[Union[int, str]] - The size of the filing. (provider: sec); - The file size of the PDF document. (provider: tmx) + The size of the filing. (provider: sec) complete_submission_url : Optional[str] The URL to the complete filing submission. (provider: sec) filing_detail_url : Optional[str] The URL to the filing details. (provider: sec) - description : Optional[str] - The description of the filing. (provider: tmx) Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.filings() - >>> obb.equity.fundamental.filings(limit=100) + >>> obb.equity.fundamental.filings(provider='fmp') + >>> obb.equity.fundamental.filings(limit=100, provider='intrinio') """ # noqa: E501 return self._run( @@ -1290,7 +1271,7 @@ def filings( "provider": self._get_provider( provider, "/equity/fundamental/filings", - ("fmp", "intrinio", "sec", "tmx"), + ("fmp", "intrinio", "sec"), ) }, standard_params={ @@ -1402,7 +1383,7 @@ def historical_attributes( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.historical_attributes(symbol='AAPL', tag='ebitda') + >>> obb.equity.fundamental.historical_attributes(symbol='AAPL', tag='ebitda', provider='intrinio') """ # noqa: E501 return self._run( @@ -1438,35 +1419,30 @@ def historical_attributes( def historical_eps( self, symbol: Annotated[ - Union[str, List[str]], - OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage." - ), + str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["alpha_vantage", "fmp"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Get historical earnings per share data for a given company. Parameters ---------- - symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage. - provider : Optional[Literal['alpha_vantage', 'fmp']] + symbol : str + Symbol to get data for. + provider : Optional[Literal['fmp']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'alpha_vantage' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. - period : Literal['annual', 'quarter'] - Time period of the data to return. (provider: alpha_vantage) limit : Optional[int] - The number of data entries to return. (provider: alpha_vantage, fmp) + The number of data entries to return. (provider: fmp) Returns ------- OBBject results : List[HistoricalEps] Serializable results. - provider : Optional[Literal['alpha_vantage', 'fmp']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1487,12 +1463,6 @@ def historical_eps( Actual EPS from the earnings date. eps_estimated : Optional[float] Estimated EPS for the earnings date. - surprise : Optional[float] - Surprise in EPS (Actual - Estimated). (provider: alpha_vantage) - surprise_percent : Optional[Union[float, str]] - EPS surprise as a normalized percent. (provider: alpha_vantage) - reported_date : Optional[date] - Date of the earnings report. (provider: alpha_vantage) revenue_estimated : Optional[float] Estimated consensus revenue for the reporting period. (provider: fmp) revenue_actual : Optional[float] @@ -1507,7 +1477,7 @@ def historical_eps( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.historical_eps(symbol='AAPL') + >>> obb.equity.fundamental.historical_eps(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -1517,14 +1487,13 @@ def historical_eps( "provider": self._get_provider( provider, "/equity/fundamental/historical_eps", - ("alpha_vantage", "fmp"), + ("fmp",), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["alpha_vantage"]}}, ) ) @@ -1577,7 +1546,7 @@ def historical_splits( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.historical_splits(symbol='AAPL') + >>> obb.equity.fundamental.historical_splits(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -1933,8 +1902,8 @@ def income( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.income(symbol='AAPL') - >>> obb.equity.fundamental.income(symbol='AAPL', period='annual', limit=5) + >>> obb.equity.fundamental.income(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.income(symbol='AAPL', period='annual', limit=5, provider='intrinio') """ # noqa: E501 return self._run( @@ -2067,8 +2036,8 @@ def income_growth( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.income_growth(symbol='AAPL') - >>> obb.equity.fundamental.income_growth(symbol='AAPL', limit=10, period='annual') + >>> obb.equity.fundamental.income_growth(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.income_growth(symbol='AAPL', limit=10, period='annual', provider='intrinio') """ # noqa: E501 return self._run( @@ -2148,7 +2117,7 @@ def latest_attributes( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.latest_attributes(symbol='AAPL', tag='ceo') + >>> obb.equity.fundamental.latest_attributes(symbol='AAPL', tag='ceo', provider='intrinio') """ # noqa: E501 return self._run( @@ -2232,7 +2201,7 @@ def management( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.management(symbol='AAPL') + >>> obb.equity.fundamental.management(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -2338,7 +2307,7 @@ def management_compensation( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.management_compensation(symbol='AAPL') + >>> obb.equity.fundamental.management_compensation(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -2368,7 +2337,7 @@ def metrics( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, yfinance." ), ], period: Annotated[ @@ -2379,7 +2348,7 @@ def metrics( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["finviz", "fmp", "intrinio", "yfinance"]] = None, + provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: """Get fundamental metrics for a given company. @@ -2387,14 +2356,14 @@ def metrics( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp, yfinance. + Symbol to get data for. Multiple items allowed for provider(s): fmp, yfinance. period : Optional[Literal['annual', 'quarter']] Time period of the data to return. limit : Optional[int] The number of data entries to return. - provider : Optional[Literal['finviz', 'fmp', 'intrinio', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'finviz' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. with_ttm : Optional[bool] Include trailing twelve months (TTM) data. (provider: fmp) @@ -2404,7 +2373,7 @@ def metrics( OBBject results : Union[List[KeyMetrics], KeyMetrics] Serializable results. - provider : Optional[Literal['finviz', 'fmp', 'intrinio', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -2421,53 +2390,6 @@ def metrics( Market capitalization pe_ratio : Optional[float] Price-to-earnings ratio (P/E ratio) - foward_pe : Optional[float] - Forward price-to-earnings ratio (forward P/E) (provider: finviz) - eps : Optional[float] - Earnings per share (EPS) (provider: finviz) - price_to_sales : Optional[float] - Price-to-sales ratio (P/S) (provider: finviz) - price_to_book : Optional[float] - Price-to-book ratio (P/B) (provider: finviz, yfinance) - book_value_per_share : Optional[float] - Book value per share (Book/sh) (provider: finviz); - Book value per share (provider: fmp) - price_to_cash : Optional[float] - Price-to-cash ratio (P/C) (provider: finviz) - cash_per_share : Optional[float] - Cash per share (Cash/sh) (provider: finviz); - Cash per share (provider: fmp); - Cash per share. (provider: yfinance) - price_to_free_cash_flow : Optional[float] - Price-to-free cash flow ratio (P/FCF) (provider: finviz) - debt_to_equity : Optional[float] - Debt-to-equity ratio (Debt/Eq) (provider: finviz); - Debt-to-equity ratio (provider: fmp); - Debt-to-equity ratio. (provider: yfinance) - long_term_debt_to_equity : Optional[float] - Long-term debt-to-equity ratio (LT Debt/Eq) (provider: finviz) - quick_ratio : Optional[float] - Quick ratio (provider: finviz, yfinance) - current_ratio : Optional[float] - Current ratio (provider: finviz, fmp, yfinance) - gross_margin : Optional[float] - Gross margin, as a normalized percent. (provider: finviz, yfinance) - profit_margin : Optional[float] - Profit margin, as a normalized percent. (provider: finviz, yfinance) - operating_margin : Optional[float] - Operating margin, as a normalized percent. (provider: finviz, yfinance) - return_on_assets : Optional[float] - Return on assets (ROA), as a normalized percent. (provider: finviz, yfinance) - return_on_investment : Optional[float] - Return on investment (ROI), as a normalized percent. (provider: finviz) - return_on_equity : Optional[float] - Return on equity (ROE), as a normalized percent. (provider: finviz, yfinance) - payout_ratio : Optional[float] - Payout ratio, as a normalized percent. (provider: finviz); - Payout ratio (provider: fmp); - Payout ratio. (provider: yfinance) - dividend_yield : Optional[float] - Dividend yield, as a normalized percent. (provider: finviz, fmp, intrinio, yfinance) date : Optional[date] The date of the data. (provider: fmp) period : Optional[str] @@ -2482,6 +2404,10 @@ def metrics( Operating cash flow per share (provider: fmp) free_cash_flow_per_share : Optional[float] Free cash flow per share (provider: fmp) + cash_per_share : Optional[float] + Cash per share (provider: fmp, yfinance) + book_value_per_share : Optional[float] + Book value per share (provider: fmp) tangible_book_value_per_share : Optional[float] Tangible book value per share (provider: fmp) shareholders_equity_per_share : Optional[float] @@ -2512,14 +2438,22 @@ def metrics( Earnings yield (provider: fmp) free_cash_flow_yield : Optional[float] Free cash flow yield (provider: fmp) + debt_to_equity : Optional[float] + Debt-to-equity ratio (provider: fmp, yfinance) debt_to_assets : Optional[float] Debt-to-assets ratio (provider: fmp) net_debt_to_ebitda : Optional[float] Net debt-to-EBITDA ratio (provider: fmp) + current_ratio : Optional[float] + Current ratio (provider: fmp, yfinance) interest_coverage : Optional[float] Interest coverage (provider: fmp) income_quality : Optional[float] Income quality (provider: fmp) + dividend_yield : Optional[float] + Dividend yield, as a normalized percent. (provider: fmp, intrinio, yfinance) + payout_ratio : Optional[float] + Payout ratio (provider: fmp, yfinance) sales_general_and_administrative_to_revenue : Optional[float] Sales general and administrative expenses-to-revenue ratio (provider: fmp) research_and_development_to_revenue : Optional[float] @@ -2601,12 +2535,26 @@ def metrics( Revenue growth (Year Over Year), as a normalized percent. (provider: yfinance) enterprise_to_revenue : Optional[float] Enterprise value to revenue ratio. (provider: yfinance) + quick_ratio : Optional[float] + Quick ratio. (provider: yfinance) + gross_margin : Optional[float] + Gross margin, as a normalized percent. (provider: yfinance) + operating_margin : Optional[float] + Operating margin, as a normalized percent. (provider: yfinance) ebitda_margin : Optional[float] EBITDA margin, as a normalized percent. (provider: yfinance) + profit_margin : Optional[float] + Profit margin, as a normalized percent. (provider: yfinance) + return_on_assets : Optional[float] + Return on assets, as a normalized percent. (provider: yfinance) + return_on_equity : Optional[float] + Return on equity, as a normalized percent. (provider: yfinance) dividend_yield_5y_avg : Optional[float] 5-year average dividend yield, as a normalized percent. (provider: yfinance) book_value : Optional[float] Book value per share. (provider: yfinance) + price_to_book : Optional[float] + Price-to-book ratio. (provider: yfinance) overall_risk : Optional[float] Overall risk score. (provider: yfinance) audit_risk : Optional[float] @@ -2625,8 +2573,8 @@ def metrics( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.metrics(symbol='AAPL') - >>> obb.equity.fundamental.metrics(symbol='AAPL', period='annual', limit=100) + >>> obb.equity.fundamental.metrics(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.metrics(symbol='AAPL', period='annual', limit=100, provider='intrinio') """ # noqa: E501 return self._run( @@ -2636,7 +2584,7 @@ def metrics( "provider": self._get_provider( provider, "/equity/fundamental/metrics", - ("finviz", "fmp", "intrinio", "yfinance"), + ("fmp", "intrinio", "yfinance"), ) }, standard_params={ @@ -2645,9 +2593,7 @@ def metrics( "limit": limit, }, extra_params=kwargs, - extra_info={ - "symbol": {"multiple_items_allowed": ["finviz", "fmp", "yfinance"]} - }, + extra_info={"symbol": {"multiple_items_allowed": ["fmp", "yfinance"]}}, ) ) @@ -2817,7 +2763,7 @@ def multiples( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.multiples(symbol='AAPL') + >>> obb.equity.fundamental.multiples(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -2955,7 +2901,7 @@ def overview( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.overview(symbol='AAPL') + >>> obb.equity.fundamental.overview(symbol='AAPL', provider='fmp') """ # noqa: E501 simplefilter("always", DeprecationWarning) @@ -3154,8 +3100,8 @@ def ratios( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.ratios(symbol='AAPL') - >>> obb.equity.fundamental.ratios(symbol='AAPL', period='annual', limit=12) + >>> obb.equity.fundamental.ratios(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.ratios(symbol='AAPL', period='annual', limit=12, provider='intrinio') """ # noqa: E501 return self._run( @@ -3247,13 +3193,13 @@ def reported_financials( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.reported_financials(symbol='AAPL') + >>> obb.equity.fundamental.reported_financials(symbol='AAPL', provider='intrinio') >>> # Get AAPL balance sheet with a limit of 10 items. - >>> obb.equity.fundamental.reported_financials(symbol='AAPL', period='annual', statement_type='balance', limit=10) + >>> obb.equity.fundamental.reported_financials(symbol='AAPL', period='annual', statement_type='balance', limit=10, provider='intrinio') >>> # Get reported income statement - >>> obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='income') + >>> obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='income', provider='intrinio') >>> # Get reported cash flow statement - >>> obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='cash') + >>> obb.equity.fundamental.reported_financials(symbol='AAPL', statement_type='cash', provider='intrinio') """ # noqa: E501 return self._run( @@ -3339,8 +3285,8 @@ def revenue_per_geography( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.revenue_per_geography(symbol='AAPL') - >>> obb.equity.fundamental.revenue_per_geography(symbol='AAPL', period='annual', structure='flat') + >>> obb.equity.fundamental.revenue_per_geography(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.revenue_per_geography(symbol='AAPL', period='annual', structure='flat', provider='fmp') """ # noqa: E501 return self._run( @@ -3425,8 +3371,8 @@ def revenue_per_segment( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.revenue_per_segment(symbol='AAPL') - >>> obb.equity.fundamental.revenue_per_segment(symbol='AAPL', period='annual', structure='flat') + >>> obb.equity.fundamental.revenue_per_segment(symbol='AAPL', provider='fmp') + >>> obb.equity.fundamental.revenue_per_segment(symbol='AAPL', period='annual', structure='flat', provider='fmp') """ # noqa: E501 return self._run( @@ -3517,7 +3463,7 @@ def search_attributes( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.search_attributes(query='ebitda') + >>> obb.equity.fundamental.search_attributes(query='ebitda', provider='intrinio') """ # noqa: E501 return self._run( @@ -3591,8 +3537,8 @@ def trailing_dividend_yield( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.trailing_dividend_yield(symbol='AAPL') - >>> obb.equity.fundamental.trailing_dividend_yield(symbol='AAPL', limit=252) + >>> obb.equity.fundamental.trailing_dividend_yield(symbol='AAPL', provider='tiingo') + >>> obb.equity.fundamental.trailing_dividend_yield(symbol='AAPL', limit=252, provider='tiingo') """ # noqa: E501 return self._run( @@ -3670,7 +3616,7 @@ def transcript( Examples -------- >>> from openbb import obb - >>> obb.equity.fundamental.transcript(symbol='AAPL', year=2020) + >>> obb.equity.fundamental.transcript(symbol='AAPL', year=2020, provider='fmp') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index a4f65eb44d28..a851bac29047 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -113,9 +113,9 @@ def form_13f( Examples -------- >>> from openbb import obb - >>> obb.equity.ownership.form_13f(symbol='NVDA') + >>> obb.equity.ownership.form_13f(symbol='NVDA', provider='sec') >>> # Enter a date (calendar quarter ending) for a specific report. - >>> obb.equity.ownership.form_13f(symbol='BRK-A', date='2016-09-30') + >>> obb.equity.ownership.form_13f(symbol='BRK-A', date='2016-09-30', provider='sec') >>> # Example finding Michael Burry's filings. >>> cik = obb.regulators.sec.institutions_search("Scion Asset Management").results[0].cik >>> # Use the `limit` parameter to return N number of reports from the most recent. @@ -152,7 +152,7 @@ def insider_trading( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 500, - provider: Optional[Literal["fmp", "intrinio", "tmx"]] = None, + provider: Optional[Literal["fmp", "intrinio"]] = None, **kwargs ) -> OBBject: """Get data about trading by a company's management team and board of directors. @@ -163,7 +163,7 @@ def insider_trading( Symbol to get data for. limit : int The number of data entries to return. - provider : Optional[Literal['fmp', 'intrinio', 'tmx']] + provider : Optional[Literal['fmp', 'intrinio']] 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. @@ -177,15 +177,13 @@ def insider_trading( Type of ownership. (provider: intrinio) sort_by : Optional[Literal['filing_date', 'updated_on']] Field to sort by. (provider: intrinio) - summary : bool - Return a summary of the insider activity instead of the individuals. (provider: tmx) Returns ------- OBBject results : List[InsiderTrading] Serializable results. - provider : Optional[Literal['fmp', 'intrinio', 'tmx']] + provider : Optional[Literal['fmp', 'intrinio']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -238,7 +236,7 @@ def insider_trading( Expiration date of the derivative. (provider: intrinio) underlying_security_title : Optional[str] Name of the underlying non-derivative security related to this derivative transaction. (provider: intrinio) - underlying_shares : Optional[Union[int, float]] + underlying_shares : Optional[Union[float, int]] Number of underlying shares related to this derivative transaction. (provider: intrinio) nature_of_ownership : Optional[str] Nature of ownership of the insider trading. (provider: intrinio) @@ -254,26 +252,12 @@ def insider_trading( Whether the owner is having a derivative transaction. (provider: intrinio) report_line_number : Optional[int] Report line number of the insider trading. (provider: intrinio) - period : Optional[str] - The period of the activity. Bucketed by three, six, and twelve months. (provider: tmx) - acquisition_or_deposition : Optional[str] - Whether the insider bought or sold the shares. (provider: tmx) - number_of_trades : Optional[int] - The number of shares traded over the period. (provider: tmx) - trade_value : Optional[float] - The value of the shares traded by the insider. (provider: tmx) - securities_bought : Optional[int] - The total number of shares bought by all insiders over the period. (provider: tmx) - securities_sold : Optional[int] - The total number of shares sold by all insiders over the period. (provider: tmx) - net_activity : Optional[int] - The total net activity by all insiders over the period. (provider: tmx) Examples -------- >>> from openbb import obb - >>> obb.equity.ownership.insider_trading(symbol='AAPL') - >>> obb.equity.ownership.insider_trading(symbol='AAPL', limit=500) + >>> obb.equity.ownership.insider_trading(symbol='AAPL', provider='fmp') + >>> obb.equity.ownership.insider_trading(symbol='AAPL', limit=500, provider='intrinio') """ # noqa: E501 return self._run( @@ -283,7 +267,7 @@ def insider_trading( "provider": self._get_provider( provider, "/equity/ownership/insider_trading", - ("fmp", "intrinio", "tmx"), + ("fmp", "intrinio"), ) }, standard_params={ @@ -411,7 +395,7 @@ def institutional( Examples -------- >>> from openbb import obb - >>> obb.equity.ownership.institutional(symbol='AAPL') + >>> obb.equity.ownership.institutional(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -562,8 +546,8 @@ def major_holders( Examples -------- >>> from openbb import obb - >>> obb.equity.ownership.major_holders(symbol='AAPL') - >>> obb.equity.ownership.major_holders(symbol='AAPL', page=0) + >>> obb.equity.ownership.major_holders(symbol='AAPL', provider='fmp') + >>> obb.equity.ownership.major_holders(symbol='AAPL', page=0, provider='fmp') """ # noqa: E501 return self._run( @@ -665,7 +649,7 @@ def share_statistics( Examples -------- >>> from openbb import obb - >>> obb.equity.ownership.share_statistics(symbol='AAPL') + >>> obb.equity.ownership.share_statistics(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py index 01c9cbbdd063..3937fce75bf2 100644 --- a/openbb_platform/openbb/package/equity_price.py +++ b/openbb_platform/openbb/package/equity_price.py @@ -29,7 +29,7 @@ def historical( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance." ), ], interval: Annotated[ @@ -48,18 +48,8 @@ def historical( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - chart: bool = False, provider: Optional[ - Literal[ - "alpha_vantage", - "cboe", - "fmp", - "intrinio", - "polygon", - "tiingo", - "tmx", - "yfinance", - ] + Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"] ] = None, **kwargs ) -> OBBject: @@ -68,30 +58,17 @@ def historical( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, yfinance. + Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance. interval : Optional[str] Time interval of the data to return. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - chart : bool - Whether to create a chart or not, by default False. - provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'pol... + provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinanc... The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'alpha_vantage' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. - adjustment : Union[Literal['splits_only', 'splits_and_dividends', 'unadjusted'], Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']] - The adjustment factor to apply. 'splits_only' is not supported for intraday data. (provider: alpha_vantage); - The adjustment factor to apply. Default is splits only. (provider: polygon); - The adjustment factor to apply. Only valid for daily data. (provider: tmx); - The adjustment factor to apply. Default is splits only. (provider: yfinance) - extended_hours : Optional[bool] - Include Pre and Post market data. (provider: alpha_vantage, polygon, yfinance) - adjusted : bool - This field is deprecated (4.1.5) and will be removed in a future version. Use 'adjustment' set as 'splits_and_dividends' instead. (provider: alpha_vantage, yfinance) - use_cache : bool - When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe) start_time : Optional[datetime.time] Return intervals starting at the specified time on the `start_date` formatted as 'HH:MM:SS'. (provider: intrinio) end_time : Optional[datetime.time] @@ -100,12 +77,18 @@ def historical( Timezone of the data, in the IANA format (Continent/City). (provider: intrinio) source : Literal['realtime', 'delayed', 'nasdaq_basic'] The source of the data. (provider: intrinio) + adjustment : Union[Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']] + The adjustment factor to apply. Default is splits only. (provider: polygon, yfinance) + extended_hours : bool + Include Pre and Post market data. (provider: polygon, yfinance) sort : Literal['asc', 'desc'] Sort order of the data. This impacts the results in combination with the 'limit' parameter. The results are always returned in ascending order by date. (provider: polygon) limit : int The number of data entries to return. (provider: polygon) include_actions : bool Include dividends and stock splits in results. (provider: yfinance) + adjusted : bool + This field is deprecated (4.1.5) and will be removed in a future version. Use 'adjustment' set as 'splits_and_dividends' instead. (provider: yfinance) prepost : bool This field is deprecated (4.1.5) and will be removed in a future version. Use 'extended_hours' as True instead. (provider: yfinance) @@ -114,7 +97,7 @@ def historical( OBBject results : List[EquityHistorical] Serializable results. - provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygon', 'tiingo', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -139,31 +122,16 @@ def historical( The trading volume. vwap : Optional[float] Volume Weighted Average Price over the period. - adj_close : Optional[Union[Annotated[float, Gt(gt=0)], float]] - The adjusted close price. (provider: alpha_vantage, fmp, intrinio, tiingo) - dividend : Optional[Union[Annotated[float, Ge(ge=0)], float]] - Dividend amount, if a dividend was paid. (provider: alpha_vantage, intrinio, tiingo, yfinance) - split_ratio : Optional[Union[Annotated[float, Ge(ge=0)], float]] - Split coefficient, if a split occurred. (provider: alpha_vantage); - Ratio of the equity split, if a split occurred. (provider: intrinio); - Ratio of the equity split, if a split occurred. (provider: tiingo); - Ratio of the equity split, if a split occurred. (provider: yfinance) - calls_volume : Optional[int] - Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) - puts_volume : Optional[int] - Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) - total_options_volume : Optional[int] - Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + adj_close : Optional[float] + The adjusted close price. (provider: fmp, intrinio, tiingo) unadjusted_volume : Optional[float] Unadjusted volume of the symbol. (provider: fmp) change : Optional[float] Change in the price from the previous close. (provider: fmp); - Change in the price of the symbol from the previous day. (provider: intrinio); - Change in price. (provider: tmx) + Change in the price of the symbol from the previous day. (provider: intrinio) change_percent : Optional[float] Change in the price from the previous close, as a normalized percent. (provider: fmp); - Percent change in the price of the symbol from the previous day. (provider: intrinio); - Change in price, as a normalized percentage. (provider: tmx) + Percent change in the price of the symbol from the previous day. (provider: intrinio) average : Optional[float] Average trade price of an individual equity during the interval. (provider: intrinio) adj_open : Optional[float] @@ -180,23 +148,24 @@ def historical( 52 week low price for the symbol. (provider: intrinio) factor : Optional[float] factor by which to multiply equity prices before this date, in order to calculate historically-adjusted equity prices. (provider: intrinio) + split_ratio : Optional[float] + Ratio of the equity split, if a split occurred. (provider: intrinio, tiingo, yfinance) + dividend : Optional[float] + Dividend amount, if a dividend was paid. (provider: intrinio, tiingo, yfinance) close_time : Optional[datetime] The timestamp that represents the end of the interval span. (provider: intrinio) interval : Optional[str] The data time frequency. (provider: intrinio) intra_period : Optional[bool] If true, the equity price represents an unfinished period (be it day, week, quarter, month, or year), meaning that the close price is the latest price available, not the official close price for the period (provider: intrinio) - transactions : Optional[Union[Annotated[int, Gt(gt=0)], int]] - Number of transactions for the symbol in the time period. (provider: polygon); - Total number of transactions recorded. (provider: tmx) - transactions_value : Optional[float] - Nominal value of recorded transactions. (provider: tmx) + transactions : Optional[Annotated[int, Gt(gt=0)]] + Number of transactions for the symbol in the time period. (provider: polygon) Examples -------- >>> from openbb import obb - >>> obb.equity.price.historical(symbol='AAPL') - >>> obb.equity.price.historical(symbol='AAPL', interval='1d') + >>> obb.equity.price.historical(symbol='AAPL', provider='fmp') + >>> obb.equity.price.historical(symbol='AAPL', interval='1d', provider='intrinio') """ # noqa: E501 return self._run( @@ -206,16 +175,7 @@ def historical( "provider": self._get_provider( provider, "/equity/price/historical", - ( - "alpha_vantage", - "cboe", - "fmp", - "intrinio", - "polygon", - "tiingo", - "tmx", - "yfinance", - ), + ("fmp", "intrinio", "polygon", "tiingo", "yfinance"), ) }, standard_params={ @@ -225,16 +185,12 @@ def historical( "end_date": end_date, }, extra_params=kwargs, - chart=chart, extra_info={ "symbol": { "multiple_items_allowed": [ - "alpha_vantage", - "cboe", "fmp", "polygon", "tiingo", - "tmx", "yfinance", ] } @@ -352,7 +308,7 @@ def nbbo( Examples -------- >>> from openbb import obb - >>> obb.equity.price.nbbo(symbol='AAPL') + >>> obb.equity.price.nbbo(symbol='AAPL', provider='polygon') """ # noqa: E501 return self._run( @@ -379,10 +335,10 @@ def performance( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["finviz", "fmp"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Get price performance data for a given stock. This includes price changes for different time periods. @@ -390,10 +346,10 @@ def performance( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp. - provider : Optional[Literal['finviz', 'fmp']] + Symbol to get data for. Multiple items allowed for provider(s): fmp. + provider : Optional[Literal['fmp']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'finviz' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. Returns @@ -401,7 +357,7 @@ def performance( OBBject results : List[PricePerformance] Serializable results. - provider : Optional[Literal['finviz', 'fmp']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -440,27 +396,13 @@ def performance( Ten-year return. max : Optional[float] Return from the beginning of the time series. - volatility_week : Optional[float] - One-week realized volatility, as a normalized percent. (provider: finviz) - volatility_month : Optional[float] - One-month realized volatility, as a normalized percent. (provider: finviz) - price : Optional[float] - Last Price. (provider: finviz) - volume : Optional[float] - Current volume. (provider: finviz) - average_volume : Optional[float] - Average daily volume. (provider: finviz) - relative_volume : Optional[float] - Relative volume as a ratio of current volume to average volume. (provider: finviz) - analyst_recommendation : Optional[float] - The analyst consensus, on a scale of 1-5 where 1 is a buy and 5 is a sell. (provider: finviz) symbol : Optional[str] - The ticker symbol. (provider: finviz, fmp) + The ticker symbol. (provider: fmp) Examples -------- >>> from openbb import obb - >>> obb.equity.price.performance(symbol='AAPL') + >>> obb.equity.price.performance(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -470,14 +412,14 @@ def performance( "provider": self._get_provider( provider, "/equity/price/performance", - ("finviz", "fmp"), + ("fmp",), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["finviz", "fmp"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}}, ) ) @@ -488,12 +430,10 @@ def quote( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): cboe, fmp, intrinio, tmx, yfinance." + description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance." ), ], - provider: Optional[ - Literal["cboe", "fmp", "intrinio", "tmx", "yfinance"] - ] = None, + provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, **kwargs ) -> OBBject: """Get the latest quote for a given stock. Quote includes price, volume, and other data. @@ -501,13 +441,11 @@ def quote( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): cboe, fmp, intrinio, tmx, yfinance. - provider : Optional[Literal['cboe', 'fmp', 'intrinio', 'tmx', 'yfinance']] + Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance. + provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'cboe' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. - use_cache : bool - When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe) source : Literal['iex', 'bats', 'bats_delayed', 'utp_delayed', 'cta_a_delayed', 'cta_b_delayed', 'intrinio_mx', 'intrinio_mx_plus', 'delayed_sip'] Source of the data. (provider: intrinio) @@ -516,7 +454,7 @@ def quote( OBBject results : List[EquityQuote] Serializable results. - provider : Optional[Literal['cboe', 'fmp', 'intrinio', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -579,9 +517,9 @@ def quote( The low price. close : Optional[float] The close price. - volume : Optional[Union[int, float]] + volume : Optional[Union[float, int]] The trading volume. - exchange_volume : Optional[Union[int, float]] + exchange_volume : Optional[Union[float, int]] Volume of shares exchanged during the trading day on the specific exchange. prev_close : Optional[float] The previous close price. @@ -593,51 +531,20 @@ def quote( The one year high (52W High). year_low : Optional[float] The one year low (52W Low). - iv30 : Optional[float] - The 30-day implied volatility of the stock. (provider: cboe) - iv30_change : Optional[float] - Change in 30-day implied volatility of the stock. (provider: cboe) - iv30_change_percent : Optional[float] - Change in 30-day implied volatility of the stock as a normalized percentage value. (provider: cboe) - iv30_annual_high : Optional[float] - The 1-year high of 30-day implied volatility. (provider: cboe) - hv30_annual_high : Optional[float] - The 1-year high of 30-day realized volatility. (provider: cboe) - iv30_annual_low : Optional[float] - The 1-year low of 30-day implied volatility. (provider: cboe) - hv30_annual_low : Optional[float] - The 1-year low of 30-dayrealized volatility. (provider: cboe) - iv60_annual_high : Optional[float] - The 1-year high of 60-day implied volatility. (provider: cboe) - hv60_annual_high : Optional[float] - The 1-year high of 60-day realized volatility. (provider: cboe) - iv60_annual_low : Optional[float] - The 1-year low of 60-day implied volatility. (provider: cboe) - hv60_annual_low : Optional[float] - The 1-year low of 60-day realized volatility. (provider: cboe) - iv90_annual_high : Optional[float] - The 1-year high of 90-day implied volatility. (provider: cboe) - hv90_annual_high : Optional[float] - The 1-year high of 90-day realized volatility. (provider: cboe) - iv90_annual_low : Optional[float] - The 1-year low of 90-day implied volatility. (provider: cboe) - hv90_annual_low : Optional[float] - The 1-year low of 90-day realized volatility. (provider: cboe) price_avg50 : Optional[float] 50 day moving average price. (provider: fmp) price_avg200 : Optional[float] 200 day moving average price. (provider: fmp) avg_volume : Optional[int] Average volume over the last 10 trading days. (provider: fmp) - market_cap : Optional[Union[float, int]] - Market cap of the company. (provider: fmp); - Market capitalization. (provider: tmx) + market_cap : Optional[float] + Market cap of the company. (provider: fmp) shares_outstanding : Optional[int] - Number of shares outstanding. (provider: fmp, tmx) - eps : Optional[Union[float, str]] - Earnings per share. (provider: fmp, tmx) - pe : Optional[Union[float, str]] - Price earnings ratio. (provider: fmp, tmx) + Number of shares outstanding. (provider: fmp) + eps : Optional[float] + Earnings per share. (provider: fmp) + pe : Optional[float] + Price earnings ratio. (provider: fmp) earnings_announcement : Optional[Union[datetime, str]] Upcoming earnings announcement date. (provider: fmp) is_darkpool : Optional[bool] @@ -648,64 +555,6 @@ def quote( Date and Time when the data was last updated. (provider: intrinio) security : Optional[openbb_intrinio.utils.references.IntrinioSecurity] Security details related to the quote. (provider: intrinio) - security_type : Optional[str] - The issuance type of the asset. (provider: tmx) - sector : Optional[str] - The sector of the asset. (provider: tmx) - industry_category : Optional[str] - The industry category of the asset. (provider: tmx) - industry_group : Optional[str] - The industry group of the asset. (provider: tmx) - vwap : Optional[float] - Volume Weighted Average Price over the period. (provider: tmx) - ma_21 : Optional[float] - Twenty-one day moving average. (provider: tmx) - ma_50 : Optional[float] - Fifty day moving average. (provider: tmx) - ma_200 : Optional[float] - Two-hundred day moving average. (provider: tmx) - volume_avg_10d : Optional[int] - Ten day average volume. (provider: tmx) - volume_avg_30d : Optional[int] - Thirty day average volume. (provider: tmx) - volume_avg_50d : Optional[int] - Fifty day average volume. (provider: tmx) - market_cap_all_classes : Optional[int] - Market capitalization of all share classes. (provider: tmx) - div_amount : Optional[float] - The most recent dividend amount. (provider: tmx) - div_currency : Optional[str] - The currency the dividend is paid in. (provider: tmx) - div_yield : Optional[float] - The dividend yield as a normalized percentage. (provider: tmx) - div_freq : Optional[str] - The frequency of dividend payments. (provider: tmx) - div_ex_date : Optional[date] - The ex-dividend date. (provider: tmx) - div_pay_date : Optional[date] - The next dividend ayment date. (provider: tmx) - div_growth_3y : Optional[Union[str, float]] - The three year dividend growth as a normalized percentage. (provider: tmx) - div_growth_5y : Optional[Union[str, float]] - The five year dividend growth as a normalized percentage. (provider: tmx) - debt_to_equity : Optional[Union[str, float]] - The debt to equity ratio. (provider: tmx) - price_to_book : Optional[Union[str, float]] - The price to book ratio. (provider: tmx) - price_to_cf : Optional[Union[str, float]] - The price to cash flow ratio. (provider: tmx) - return_on_equity : Optional[Union[str, float]] - The return on equity, as a normalized percentage. (provider: tmx) - return_on_assets : Optional[Union[str, float]] - The return on assets, as a normalized percentage. (provider: tmx) - beta : Optional[Union[str, float]] - The beta relative to the TSX Composite. (provider: tmx) - alpha : Optional[Union[str, float]] - The alpha relative to the TSX Composite. (provider: tmx) - shares_escrow : Optional[int] - The number of shares held in escrow. (provider: tmx) - shares_total : Optional[int] - The total number of shares outstanding from all classes. (provider: tmx) ma_50d : Optional[float] 50-day moving average price. (provider: yfinance) ma_200d : Optional[float] @@ -720,7 +569,7 @@ def quote( Examples -------- >>> from openbb import obb - >>> obb.equity.price.quote(symbol='AAPL') + >>> obb.equity.price.quote(symbol='AAPL', provider='fmp') """ # noqa: E501 return self._run( @@ -730,7 +579,7 @@ def quote( "provider": self._get_provider( provider, "/equity/price/quote", - ("cboe", "fmp", "intrinio", "tmx", "yfinance"), + ("fmp", "intrinio", "yfinance"), ) }, standard_params={ @@ -739,13 +588,7 @@ def quote( extra_params=kwargs, extra_info={ "symbol": { - "multiple_items_allowed": [ - "cboe", - "fmp", - "intrinio", - "tmx", - "yfinance", - ] + "multiple_items_allowed": ["fmp", "intrinio", "yfinance"] } }, ) diff --git a/openbb_platform/openbb/package/equity_shorts.py b/openbb_platform/openbb/package/equity_shorts.py index 22cc66fa55d8..f30b6752d058 100644 --- a/openbb_platform/openbb/package/equity_shorts.py +++ b/openbb_platform/openbb/package/equity_shorts.py @@ -13,8 +13,6 @@ class ROUTER_equity_shorts(Container): """/equity/shorts fails_to_deliver - short_interest - short_volume """ def __repr__(self) -> str: @@ -82,7 +80,7 @@ def fails_to_deliver( Examples -------- >>> from openbb import obb - >>> obb.equity.shorts.fails_to_deliver(symbol='AAPL') + >>> obb.equity.shorts.fails_to_deliver(symbol='AAPL', provider='sec') """ # noqa: E501 return self._run( @@ -101,159 +99,3 @@ def fails_to_deliver( extra_params=kwargs, ) ) - - @exception_handler - @validate - def short_interest( - self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - provider: Optional[Literal["finra"]] = None, - **kwargs - ) -> OBBject: - """Get reported short volume and days to cover data. - - Parameters - ---------- - symbol : str - Symbol to get data for. - provider : Optional[Literal['finra']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'finra' if there is - no default. - - Returns - ------- - OBBject - results : List[EquityShortInterest] - Serializable results. - provider : Optional[Literal['finra']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - EquityShortInterest - ------------------- - settlement_date : date - The mid-month short interest report is based on short positions held by members on the settlement date of the 15th of each month. If the 15th falls on a weekend or another non-settlement date, the designated settlement date will be the previous business day on which transactions settled. The end-of-month short interest report is based on short positions held on the last business day of the month on which transactions settle. Once the short position reports are received, the short interest data is compiled for each equity security and provided for publication on the 7th business day after the reporting settlement date. - symbol : str - Symbol representing the entity requested in the data. - issue_name : str - Unique identifier of the issue. - market_class : str - Primary listing market. - current_short_position : float - The total number of shares in the issue that are reflected on the books and records of the reporting firms as short as defined by Rule 200 of Regulation SHO as of the current cycle’s designated settlement date. - previous_short_position : float - The total number of shares in the issue that are reflected on the books and records of the reporting firms as short as defined by Rule 200 of Regulation SHO as of the previous cycle’s designated settlement date. - avg_daily_volume : float - Total Volume or Adjusted Volume in case of splits / Total trade days between (previous settlement date + 1) to (current settlement date). The NULL values are translated as zero. - days_to_cover : float - The number of days of average share volume it would require to buy all of the shares that were sold short during the reporting cycle. Formula: Short Interest / Average Daily Share Volume, Rounded to Hundredths. 1.00 will be displayed for any values equal or less than 1 (i.e., Average Daily Share is equal to or greater than Short Interest). N/A will be displayed If the days to cover is Zero (i.e., Average Daily Share Volume is Zero). - change : float - Change in Shares Short from Previous Cycle: Difference in short interest between the current cycle and the previous cycle. - change_pct : float - Change in Shares Short from Previous Cycle as a percent. - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.shorts.short_interest(symbol='AAPL') - """ # noqa: E501 - - return self._run( - "/equity/shorts/short_interest", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/equity/shorts/short_interest", - ("finra",), - ) - }, - standard_params={ - "symbol": symbol, - }, - extra_params=kwargs, - ) - ) - - @exception_handler - @validate - def short_volume( - self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - provider: Optional[Literal["stockgrid"]] = None, - **kwargs - ) -> OBBject: - """Get reported Fail-to-deliver (FTD) data. - - Parameters - ---------- - symbol : str - Symbol to get data for. - provider : Optional[Literal['stockgrid']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'stockgrid' if there is - no default. - - Returns - ------- - OBBject - results : List[ShortVolume] - Serializable results. - provider : Optional[Literal['stockgrid']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - ShortVolume - ----------- - date : Optional[date] - The date of the data. - market : Optional[str] - Reporting Facility ID. N=NYSE TRF, Q=NASDAQ TRF Carteret, B=NASDAQ TRY Chicago, D=FINRA ADF - short_volume : Optional[int] - Aggregate reported share volume of executed short sale and short sale exempt trades during regular trading hours - short_exempt_volume : Optional[int] - Aggregate reported share volume of executed short sale exempt trades during regular trading hours - total_volume : Optional[int] - Aggregate reported share volume of executed trades during regular trading hours - close : Optional[float] - Closing price of the stock on the date. (provider: stockgrid) - short_volume_percent : Optional[float] - Percentage of the total volume that was short volume. (provider: stockgrid) - - Examples - -------- - >>> from openbb import obb - >>> obb.equity.shorts.short_volume(symbol='AAPL') - """ # noqa: E501 - - return self._run( - "/equity/shorts/short_volume", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/equity/shorts/short_volume", - ("stockgrid",), - ) - }, - standard_params={ - "symbol": symbol, - }, - extra_params=kwargs, - ) - ) diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index caefcf87d805..786a145a1d4a 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -14,7 +14,6 @@ class ROUTER_etf(Container): """/etf countries - /discovery equity_exposure historical holdings @@ -36,10 +35,10 @@ def countries( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, tmx." + description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["fmp", "tmx"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """ETF Country weighting. @@ -47,20 +46,18 @@ def countries( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, tmx. - provider : Optional[Literal['fmp', 'tmx']] + Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp. + provider : Optional[Literal['fmp']] 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. - use_cache : bool - Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfCountries] Serializable results. - provider : Optional[Literal['fmp', 'tmx']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -77,7 +74,7 @@ def countries( Examples -------- >>> from openbb import obb - >>> obb.etf.countries(symbol='VT') + >>> obb.etf.countries(symbol='VT', provider='fmp') """ # noqa: E501 return self._run( @@ -87,24 +84,17 @@ def countries( "provider": self._get_provider( provider, "/etf/countries", - ("fmp", "tmx"), + ("fmp",), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["fmp", "tmx"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}}, ) ) - @property - def discovery(self): - # pylint: disable=import-outside-toplevel - from . import etf_discovery - - return etf_discovery.ROUTER_etf_discovery(command_runner=self._command_runner) - @exception_handler @validate def equity_exposure( @@ -153,13 +143,13 @@ def equity_exposure( The number of shares held in the ETF. weight : Optional[float] The weight of the equity in the ETF, as a normalized percent. - market_value : Optional[Union[int, float]] + market_value : Optional[Union[float, int]] The market value of the equity position in the ETF. Examples -------- >>> from openbb import obb - >>> obb.etf.equity_exposure(symbol='MSFT') + >>> obb.etf.equity_exposure(symbol='MSFT', provider='fmp') >>> # This function accepts multiple tickers. >>> obb.etf.equity_exposure(symbol='MSFT,AAPL', provider='fmp') """ # noqa: E501 @@ -189,7 +179,7 @@ def historical( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance." ), ], interval: Annotated[ @@ -209,16 +199,7 @@ def historical( ), ] = None, provider: Optional[ - Literal[ - "alpha_vantage", - "cboe", - "fmp", - "intrinio", - "polygon", - "tiingo", - "tmx", - "yfinance", - ] + Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"] ] = None, **kwargs ) -> OBBject: @@ -227,28 +208,17 @@ def historical( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, yfinance. + Symbol to get data for. Multiple items allowed for provider(s): fmp, polygon, tiingo, yfinance. interval : Optional[str] Time interval of the data to return. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'pol... + provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinanc... The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'alpha_vantage' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. - adjustment : Union[Literal['splits_only', 'splits_and_dividends', 'unadjusted'], Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']] - The adjustment factor to apply. 'splits_only' is not supported for intraday data. (provider: alpha_vantage); - The adjustment factor to apply. Default is splits only. (provider: polygon); - The adjustment factor to apply. Only valid for daily data. (provider: tmx); - The adjustment factor to apply. Default is splits only. (provider: yfinance) - extended_hours : Optional[bool] - Include Pre and Post market data. (provider: alpha_vantage, polygon, yfinance) - adjusted : bool - This field is deprecated (4.1.5) and will be removed in a future version. Use 'adjustment' set as 'splits_and_dividends' instead. (provider: alpha_vantage, yfinance) - use_cache : bool - When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe) start_time : Optional[datetime.time] Return intervals starting at the specified time on the `start_date` formatted as 'HH:MM:SS'. (provider: intrinio) end_time : Optional[datetime.time] @@ -257,12 +227,18 @@ def historical( Timezone of the data, in the IANA format (Continent/City). (provider: intrinio) source : Literal['realtime', 'delayed', 'nasdaq_basic'] The source of the data. (provider: intrinio) + adjustment : Union[Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']] + The adjustment factor to apply. Default is splits only. (provider: polygon, yfinance) + extended_hours : bool + Include Pre and Post market data. (provider: polygon, yfinance) sort : Literal['asc', 'desc'] Sort order of the data. This impacts the results in combination with the 'limit' parameter. The results are always returned in ascending order by date. (provider: polygon) limit : int The number of data entries to return. (provider: polygon) include_actions : bool Include dividends and stock splits in results. (provider: yfinance) + adjusted : bool + This field is deprecated (4.1.5) and will be removed in a future version. Use 'adjustment' set as 'splits_and_dividends' instead. (provider: yfinance) prepost : bool This field is deprecated (4.1.5) and will be removed in a future version. Use 'extended_hours' as True instead. (provider: yfinance) @@ -271,7 +247,7 @@ def historical( OBBject results : List[EtfHistorical] Serializable results. - provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygon', 'tiingo', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -296,31 +272,16 @@ def historical( The trading volume. vwap : Optional[float] Volume Weighted Average Price over the period. - adj_close : Optional[Union[Annotated[float, Gt(gt=0)], float]] - The adjusted close price. (provider: alpha_vantage, fmp, intrinio, tiingo) - dividend : Optional[Union[Annotated[float, Ge(ge=0)], float]] - Dividend amount, if a dividend was paid. (provider: alpha_vantage, intrinio, tiingo, yfinance) - split_ratio : Optional[Union[Annotated[float, Ge(ge=0)], float]] - Split coefficient, if a split occurred. (provider: alpha_vantage); - Ratio of the equity split, if a split occurred. (provider: intrinio); - Ratio of the equity split, if a split occurred. (provider: tiingo); - Ratio of the equity split, if a split occurred. (provider: yfinance) - calls_volume : Optional[int] - Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) - puts_volume : Optional[int] - Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) - total_options_volume : Optional[int] - Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) + adj_close : Optional[float] + The adjusted close price. (provider: fmp, intrinio, tiingo) unadjusted_volume : Optional[float] Unadjusted volume of the symbol. (provider: fmp) change : Optional[float] Change in the price from the previous close. (provider: fmp); - Change in the price of the symbol from the previous day. (provider: intrinio); - Change in price. (provider: tmx) + Change in the price of the symbol from the previous day. (provider: intrinio) change_percent : Optional[float] Change in the price from the previous close, as a normalized percent. (provider: fmp); - Percent change in the price of the symbol from the previous day. (provider: intrinio); - Change in price, as a normalized percentage. (provider: tmx) + Percent change in the price of the symbol from the previous day. (provider: intrinio) average : Optional[float] Average trade price of an individual equity during the interval. (provider: intrinio) adj_open : Optional[float] @@ -337,22 +298,23 @@ def historical( 52 week low price for the symbol. (provider: intrinio) factor : Optional[float] factor by which to multiply equity prices before this date, in order to calculate historically-adjusted equity prices. (provider: intrinio) + split_ratio : Optional[float] + Ratio of the equity split, if a split occurred. (provider: intrinio, tiingo, yfinance) + dividend : Optional[float] + Dividend amount, if a dividend was paid. (provider: intrinio, tiingo, yfinance) close_time : Optional[datetime] The timestamp that represents the end of the interval span. (provider: intrinio) interval : Optional[str] The data time frequency. (provider: intrinio) intra_period : Optional[bool] If true, the equity price represents an unfinished period (be it day, week, quarter, month, or year), meaning that the close price is the latest price available, not the official close price for the period (provider: intrinio) - transactions : Optional[Union[Annotated[int, Gt(gt=0)], int]] - Number of transactions for the symbol in the time period. (provider: polygon); - Total number of transactions recorded. (provider: tmx) - transactions_value : Optional[float] - Nominal value of recorded transactions. (provider: tmx) + transactions : Optional[Annotated[int, Gt(gt=0)]] + Number of transactions for the symbol in the time period. (provider: polygon) Examples -------- >>> from openbb import obb - >>> obb.etf.historical(symbol='SPY') + >>> obb.etf.historical(symbol='SPY', provider='fmp') >>> obb.etf.historical(symbol='SPY', provider='yfinance') >>> # This function accepts multiple tickers. >>> obb.etf.historical(symbol='SPY,IWM,QQQ,DJIA', provider='yfinance') @@ -365,16 +327,7 @@ def historical( "provider": self._get_provider( provider, "/etf/historical", - ( - "alpha_vantage", - "cboe", - "fmp", - "intrinio", - "polygon", - "tiingo", - "tmx", - "yfinance", - ), + ("fmp", "intrinio", "polygon", "tiingo", "yfinance"), ) }, standard_params={ @@ -387,12 +340,9 @@ def historical( extra_info={ "symbol": { "multiple_items_allowed": [ - "alpha_vantage", - "cboe", "fmp", "polygon", "tiingo", - "tmx", "yfinance", ] } @@ -407,7 +357,7 @@ def holdings( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") ], - provider: Optional[Literal["fmp", "sec", "tmx"]] = None, + provider: Optional[Literal["fmp", "sec"]] = None, **kwargs ) -> OBBject: """Get the holdings for an individual ETF. @@ -416,7 +366,7 @@ def holdings( ---------- symbol : str Symbol to get data for. (ETF) - provider : Optional[Literal['fmp', 'sec', 'tmx']] + provider : Optional[Literal['fmp', 'sec']] 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. @@ -426,15 +376,14 @@ def holdings( cik : Optional[str] The CIK of the filing entity. Overrides symbol. (provider: fmp) use_cache : bool - Whether or not to use cache for the request. (provider: sec); - Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) + Whether or not to use cache for the request. (provider: sec) Returns ------- OBBject results : List[EtfHoldings] Serializable results. - provider : Optional[Literal['fmp', 'sec', 'tmx']] + provider : Optional[Literal['fmp', 'sec']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -464,13 +413,12 @@ def holdings( The type of units. (provider: fmp); The units of the holding. (provider: sec) currency : Optional[str] - The currency of the holding. (provider: fmp, sec, tmx) + The currency of the holding. (provider: fmp, sec) value : Optional[float] The value of the holding, in dollars. (provider: fmp, sec) weight : Optional[float] The weight of the holding, as a normalized percent. (provider: fmp); - The weight of the holding in ETF in %. (provider: sec); - The weight of the asset in the portfolio, as a normalized percentage. (provider: tmx) + The weight of the holding in ETF in %. (provider: sec) payoff_profile : Optional[str] The payoff profile of the holding. (provider: fmp, sec) asset_category : Optional[str] @@ -478,7 +426,7 @@ def holdings( issuer_category : Optional[str] The issuer category of the holding. (provider: fmp, sec) country : Optional[str] - The country of the holding. (provider: fmp, sec, tmx) + The country of the holding. (provider: fmp, sec) is_restricted : Optional[str] Whether the holding is restricted. (provider: fmp, sec) fair_value_level : Optional[int] @@ -607,25 +555,11 @@ def holdings( The currency of the derivative's notional amount. (provider: sec) unrealized_gain : Optional[float] The unrealized gain or loss on the derivative. (provider: sec) - shares : Optional[Union[int, str]] - The value of the assets under management. (provider: tmx) - market_value : Optional[Union[str, float]] - The market value of the holding. (provider: tmx) - share_percentage : Optional[float] - The share percentage of the holding, as a normalized percentage. (provider: tmx) - share_change : Optional[Union[str, float]] - The change in shares of the holding. (provider: tmx) - exchange : Optional[str] - The exchange code of the holding. (provider: tmx) - type_id : Optional[str] - The holding type ID of the asset. (provider: tmx) - fund_id : Optional[str] - The fund ID of the asset. (provider: tmx) Examples -------- >>> from openbb import obb - >>> obb.etf.holdings(symbol='XLK') + >>> obb.etf.holdings(symbol='XLK', provider='fmp') >>> # Including a date (FMP, SEC) will return the holdings as per NPORT-P filings. >>> obb.etf.holdings(symbol='XLK', date='2022-03-31', provider='fmp') >>> # The same data can be returned from the SEC directly. @@ -639,7 +573,7 @@ def holdings( "provider": self._get_provider( provider, "/etf/holdings", - ("fmp", "sec", "tmx"), + ("fmp", "sec"), ) }, standard_params={ @@ -694,7 +628,7 @@ def holdings_date( Examples -------- >>> from openbb import obb - >>> obb.etf.holdings_date(symbol='XLK') + >>> obb.etf.holdings_date(symbol='XLK', provider='fmp') """ # noqa: E501 return self._run( @@ -721,7 +655,7 @@ def holdings_performance( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp." ), ], provider: Optional[Literal["fmp"]] = None, @@ -732,7 +666,7 @@ def holdings_performance( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp. + Symbol to get data for. Multiple items allowed for provider(s): fmp. provider : Optional[Literal['fmp']] The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is @@ -788,7 +722,7 @@ def holdings_performance( Examples -------- >>> from openbb import obb - >>> obb.etf.holdings_performance(symbol='XLK') + >>> obb.etf.holdings_performance(symbol='XLK', provider='fmp') """ # noqa: E501 return self._run( @@ -805,7 +739,7 @@ def holdings_performance( "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["finviz", "fmp"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}}, ) ) @@ -816,10 +750,10 @@ def info( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, tmx, yfinance." + description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance." ), ], - provider: Optional[Literal["fmp", "tmx", "yfinance"]] = None, + provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: """ETF Information Overview. @@ -827,20 +761,18 @@ def info( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, tmx, yfinance. - provider : Optional[Literal['fmp', 'tmx', 'yfinance']] + Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance. + provider : Optional[Literal['fmp', 'yfinance']] 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. - use_cache : bool - Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfInfo] Serializable results. - provider : Optional[Literal['fmp', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -860,8 +792,7 @@ def info( inception_date : Optional[str] Inception date of the ETF. issuer : Optional[str] - Company of the ETF. (provider: fmp); - The issuer of the ETF. (provider: tmx) + Company of the ETF. (provider: fmp) cusip : Optional[str] CUSIP of the ETF. (provider: fmp) isin : Optional[str] @@ -871,8 +802,7 @@ def info( asset_class : Optional[str] Asset class of the ETF. (provider: fmp) aum : Optional[float] - Assets under management. (provider: fmp); - The AUM of the ETF. (provider: tmx) + Assets under management. (provider: fmp) nav : Optional[float] Net asset value of the ETF. (provider: fmp) nav_currency : Optional[str] @@ -881,57 +811,10 @@ def info( The expense ratio, as a normalized percent. (provider: fmp) holdings_count : Optional[int] Number of holdings. (provider: fmp) - avg_volume : Optional[Union[float, int]] - Average daily trading volume. (provider: fmp); - The average daily volume of the ETF. (provider: tmx) + avg_volume : Optional[float] + Average daily trading volume. (provider: fmp) website : Optional[str] - Website of the issuer. (provider: fmp); - The website of the ETF. (provider: tmx) - investment_style : Optional[str] - The investment style of the ETF. (provider: tmx) - esg : Optional[bool] - Whether the ETF qualifies as an ESG fund. (provider: tmx) - currency : Optional[str] - The currency of the ETF. (provider: tmx); - The currency in which the fund is listed. (provider: yfinance) - unit_price : Optional[float] - The unit price of the ETF. (provider: tmx) - close : Optional[float] - The closing price of the ETF. (provider: tmx) - prev_close : Optional[float] - The previous closing price of the ETF. (provider: tmx, yfinance) - return_1m : Optional[float] - The one-month return of the ETF, as a normalized percent (provider: tmx) - return_3m : Optional[float] - The three-month return of the ETF, as a normalized percent. (provider: tmx) - return_6m : Optional[float] - The six-month return of the ETF, as a normalized percent. (provider: tmx) - return_ytd : Optional[float] - The year-to-date return of the ETF, as a normalized percent. (provider: tmx, yfinance) - return_1y : Optional[float] - The one-year return of the ETF, as a normalized percent. (provider: tmx) - return_3y : Optional[float] - The three-year return of the ETF, as a normalized percent. (provider: tmx) - return_5y : Optional[float] - The five-year return of the ETF, as a normalized percent. (provider: tmx) - return_10y : Optional[float] - The ten-year return of the ETF, as a normalized percent. (provider: tmx) - return_from_inception : Optional[float] - The return from inception of the ETF, as a normalized percent. (provider: tmx) - avg_volume_30d : Optional[int] - The 30-day average volume of the ETF. (provider: tmx) - pe_ratio : Optional[float] - The price-to-earnings ratio of the ETF. (provider: tmx) - pb_ratio : Optional[float] - The price-to-book ratio of the ETF. (provider: tmx) - management_fee : Optional[float] - The management fee of the ETF, as a normalized percent. (provider: tmx) - mer : Optional[float] - The management expense ratio of the ETF, as a normalized percent. (provider: tmx) - distribution_yield : Optional[float] - The distribution yield of the ETF, as a normalized percent. (provider: tmx) - dividend_frequency : Optional[str] - The dividend payment frequency of the ETF. (provider: tmx) + Website of the issuer. (provider: fmp) fund_type : Optional[str] The legal type of fund. (provider: yfinance) fund_family : Optional[str] @@ -942,6 +825,8 @@ def info( The exchange the fund is listed on. (provider: yfinance) exchange_timezone : Optional[str] The timezone of the exchange. (provider: yfinance) + currency : Optional[str] + The currency in which the fund is listed. (provider: yfinance) nav_price : Optional[float] The net asset value per unit of the fund. (provider: yfinance) total_assets : Optional[int] @@ -962,6 +847,8 @@ def info( 50-day moving average price. (provider: yfinance) ma_200d : Optional[float] 200-day moving average price. (provider: yfinance) + return_ytd : Optional[float] + The year-to-date return of the fund, as a normalized percent. (provider: yfinance) return_3y_avg : Optional[float] The three year average return of the fund, as a normalized percent. (provider: yfinance) return_5y_avg : Optional[float] @@ -988,11 +875,13 @@ def info( The lowest price of the most recent trading session. (provider: yfinance) volume : Optional[int] The trading volume of the most recent trading session. (provider: yfinance) + prev_close : Optional[float] + The previous closing price. (provider: yfinance) Examples -------- >>> from openbb import obb - >>> obb.etf.info(symbol='SPY') + >>> obb.etf.info(symbol='SPY', provider='fmp') >>> # This function accepts multiple tickers. >>> obb.etf.info(symbol='SPY,IWM,QQQ,DJIA', provider='fmp') """ # noqa: E501 @@ -1004,16 +893,14 @@ def info( "provider": self._get_provider( provider, "/etf/info", - ("fmp", "tmx", "yfinance"), + ("fmp", "yfinance"), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={ - "symbol": {"multiple_items_allowed": ["fmp", "tmx", "yfinance"]} - }, + extra_info={"symbol": {"multiple_items_allowed": ["fmp", "yfinance"]}}, ) ) @@ -1024,10 +911,10 @@ def price_performance( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["finviz", "fmp"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Price performance as a return, over different periods. This is a proxy for `equity.price.performance`. @@ -1035,10 +922,10 @@ def price_performance( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): finviz, fmp. - provider : Optional[Literal['finviz', 'fmp']] + Symbol to get data for. Multiple items allowed for provider(s): fmp. + provider : Optional[Literal['fmp']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'finviz' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. Returns @@ -1046,7 +933,7 @@ def price_performance( OBBject results : List[PricePerformance] Serializable results. - provider : Optional[Literal['finviz', 'fmp']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1085,27 +972,13 @@ def price_performance( Ten-year return. max : Optional[float] Return from the beginning of the time series. - volatility_week : Optional[float] - One-week realized volatility, as a normalized percent. (provider: finviz) - volatility_month : Optional[float] - One-month realized volatility, as a normalized percent. (provider: finviz) - price : Optional[float] - Last Price. (provider: finviz) - volume : Optional[float] - Current volume. (provider: finviz) - average_volume : Optional[float] - Average daily volume. (provider: finviz) - relative_volume : Optional[float] - Relative volume as a ratio of current volume to average volume. (provider: finviz) - analyst_recommendation : Optional[float] - The analyst consensus, on a scale of 1-5 where 1 is a buy and 5 is a sell. (provider: finviz) symbol : Optional[str] - The ticker symbol. (provider: finviz, fmp) + The ticker symbol. (provider: fmp) Examples -------- >>> from openbb import obb - >>> obb.etf.price_performance(symbol='QQQ') + >>> obb.etf.price_performance(symbol='QQQ', provider='fmp') >>> obb.etf.price_performance(symbol='SPY,QQQ,IWM,DJIA', provider='fmp') """ # noqa: E501 @@ -1116,14 +989,14 @@ def price_performance( "provider": self._get_provider( provider, "/etf/price_performance", - ("finviz", "fmp"), + ("fmp",), ) }, standard_params={ "symbol": symbol, }, extra_params=kwargs, - extra_info={"symbol": {"multiple_items_allowed": ["finviz", "fmp"]}}, + extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}}, ) ) @@ -1134,7 +1007,7 @@ def search( query: Annotated[ Optional[str], OpenBBCustomParameter(description="Search query.") ] = "", - provider: Optional[Literal["fmp", "tmx"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Search for ETFs. @@ -1146,7 +1019,7 @@ def search( ---------- query : Optional[str] Search query. - provider : Optional[Literal['fmp', 'tmx']] + provider : Optional[Literal['fmp']] 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. @@ -1154,19 +1027,13 @@ def search( The exchange code the ETF trades on. (provider: fmp) is_active : Optional[Literal[True, False]] Whether the ETF is actively trading. (provider: fmp) - div_freq : Optional[Literal['monthly', 'annually', 'quarterly']] - The dividend payment frequency. (provider: tmx) - sort_by : Optional[Literal['nav', 'return_1m', 'return_3m', 'return_6m', 'return_1y', 'return_3y', 'return_ytd', 'beta_1y', 'volume_avg_daily', 'management_fee', 'distribution_yield', 'pb_ratio', 'pe_ratio']] - The column to sort by. (provider: tmx) - use_cache : bool - Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfSearch] Serializable results. - provider : Optional[Literal['fmp', 'tmx']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1203,77 +1070,12 @@ def search( The country the ETF is registered in. (provider: fmp) actively_trading : Optional[Literal[True, False]] Whether the ETF is actively trading. (provider: fmp) - short_name : Optional[str] - The short name of the ETF. (provider: tmx) - inception_date : Optional[str] - The inception date of the ETF. (provider: tmx) - issuer : Optional[str] - The issuer of the ETF. (provider: tmx) - investment_style : Optional[str] - The investment style of the ETF. (provider: tmx) - esg : Optional[bool] - Whether the ETF qualifies as an ESG fund. (provider: tmx) - currency : Optional[str] - The currency of the ETF. (provider: tmx) - unit_price : Optional[float] - The unit price of the ETF. (provider: tmx) - close : Optional[float] - The closing price of the ETF. (provider: tmx) - prev_close : Optional[float] - The previous closing price of the ETF. (provider: tmx) - return_1m : Optional[float] - The one-month return of the ETF, as a normalized percent. (provider: tmx) - return_3m : Optional[float] - The three-month return of the ETF, as a normalized percent. (provider: tmx) - return_6m : Optional[float] - The six-month return of the ETF, as a normalized percent. (provider: tmx) - return_ytd : Optional[float] - The year-to-date return of the ETF, as a normalized percent. (provider: tmx) - return_1y : Optional[float] - The one-year return of the ETF, as a normalized percent. (provider: tmx) - beta_1y : Optional[float] - The one-year beta of the ETF, as a normalized percent. (provider: tmx) - return_3y : Optional[float] - The three-year return of the ETF, as a normalized percent. (provider: tmx) - beta_3y : Optional[float] - The three-year beta of the ETF, as a normalized percent. (provider: tmx) - return_5y : Optional[float] - The five-year return of the ETF, as a normalized percent. (provider: tmx) - beta_5y : Optional[float] - The five-year beta of the ETF, as a normalized percent. (provider: tmx) - return_10y : Optional[float] - The ten-year return of the ETF, as a normalized percent. (provider: tmx) - beta_10y : Optional[float] - The ten-year beta of the ETF. (provider: tmx) - beta_15y : Optional[float] - The fifteen-year beta of the ETF. (provider: tmx) - return_from_inception : Optional[float] - The return from inception of the ETF, as a normalized percent. (provider: tmx) - avg_volume : Optional[int] - The average daily volume of the ETF. (provider: tmx) - avg_volume_30d : Optional[int] - The 30-day average volume of the ETF. (provider: tmx) - aum : Optional[float] - The AUM of the ETF. (provider: tmx) - pe_ratio : Optional[float] - The price-to-earnings ratio of the ETF. (provider: tmx) - pb_ratio : Optional[float] - The price-to-book ratio of the ETF. (provider: tmx) - management_fee : Optional[float] - The management fee of the ETF, as a normalized percent. (provider: tmx) - mer : Optional[float] - The management expense ratio of the ETF, as a normalized percent. (provider: tmx) - distribution_yield : Optional[float] - The distribution yield of the ETF, as a normalized percent. (provider: tmx) - dividend_frequency : Optional[str] - The dividend payment frequency of the ETF. (provider: tmx) Examples -------- >>> from openbb import obb - >>> obb.etf.search() >>> # An empty query returns the full list of ETFs from the provider. - >>> obb.etf.search() + >>> obb.etf.search(provider='fmp') >>> # The query will return results from text-based fields containing the term. >>> obb.etf.search(query='commercial real estate', provider='fmp') """ # noqa: E501 @@ -1285,7 +1087,7 @@ def search( "provider": self._get_provider( provider, "/etf/search", - ("fmp", "tmx"), + ("fmp",), ) }, standard_params={ @@ -1302,7 +1104,7 @@ def sectors( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") ], - provider: Optional[Literal["fmp", "tmx"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """ETF Sector weighting. @@ -1311,19 +1113,17 @@ def sectors( ---------- symbol : str Symbol to get data for. (ETF) - provider : Optional[Literal['fmp', 'tmx']] + provider : Optional[Literal['fmp']] 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. - use_cache : bool - Whether to use a cached request. All ETF data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 4 hours. (provider: tmx) Returns ------- OBBject results : List[EtfSectors] Serializable results. - provider : Optional[Literal['fmp', 'tmx']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -1342,7 +1142,7 @@ def sectors( Examples -------- >>> from openbb import obb - >>> obb.etf.sectors(symbol='SPY') + >>> obb.etf.sectors(symbol='SPY', provider='fmp') """ # noqa: E501 return self._run( @@ -1352,7 +1152,7 @@ def sectors( "provider": self._get_provider( provider, "/etf/sectors", - ("fmp", "tmx"), + ("fmp",), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index 2c4923c45f5e..ec2db50e14cb 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -112,8 +112,8 @@ def sofr( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.sofr() - >>> obb.fixedincome.sofr(period='overnight') + >>> obb.fixedincome.sofr(provider='fred') + >>> obb.fixedincome.sofr(period='overnight', provider='fred') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index 98ec05abef46..14c7693df1fb 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -16,7 +16,6 @@ class ROUTER_fixedincome_corporate(Container): """/fixedincome/corporate - bond_prices commercial_paper hqm ice_bofa @@ -27,184 +26,6 @@ class ROUTER_fixedincome_corporate(Container): def __repr__(self) -> str: return self.__doc__ or "" - @exception_handler - @validate - def bond_prices( - self, - country: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="The country to get data. Matches partial name." - ), - ] = None, - issuer_name: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="Name of the issuer. Returns partial matches and is case insensitive." - ), - ] = None, - isin: Annotated[ - Union[List, str, None], - OpenBBCustomParameter( - description="International Securities Identification Number(s) of the bond(s)." - ), - ] = None, - lei: Annotated[ - Optional[str], - OpenBBCustomParameter( - description="Legal Entity Identifier of the issuing entity." - ), - ] = None, - currency: Annotated[ - Union[List, str, None], - OpenBBCustomParameter( - description="Currency of the bond. Formatted as the 3-letter ISO 4217 code (e.g. GBP, EUR, USD)." - ), - ] = None, - coupon_min: Annotated[ - Optional[float], - OpenBBCustomParameter(description="Minimum coupon rate of the bond."), - ] = None, - coupon_max: Annotated[ - Optional[float], - OpenBBCustomParameter(description="Maximum coupon rate of the bond."), - ] = None, - issued_amount_min: Annotated[ - Optional[int], - OpenBBCustomParameter(description="Minimum issued amount of the bond."), - ] = None, - issued_amount_max: Annotated[ - Optional[str], - OpenBBCustomParameter(description="Maximum issued amount of the bond."), - ] = None, - maturity_date_min: Annotated[ - Optional[datetime.date], - OpenBBCustomParameter(description="Minimum maturity date of the bond."), - ] = None, - maturity_date_max: Annotated[ - Optional[datetime.date], - OpenBBCustomParameter(description="Maximum maturity date of the bond."), - ] = None, - provider: Optional[Literal["tmx"]] = None, - **kwargs - ) -> OBBject: - """Corporate Bond Prices. - - Parameters - ---------- - country : Optional[str] - The country to get data. Matches partial name. - issuer_name : Optional[str] - Name of the issuer. Returns partial matches and is case insensitive. - isin : Union[List, str, None] - International Securities Identification Number(s) of the bond(s). - lei : Optional[str] - Legal Entity Identifier of the issuing entity. - currency : Union[List, str, None] - Currency of the bond. Formatted as the 3-letter ISO 4217 code (e.g. GBP, EUR, USD). - coupon_min : Optional[float] - Minimum coupon rate of the bond. - coupon_max : Optional[float] - Maximum coupon rate of the bond. - issued_amount_min : Optional[int] - Minimum issued amount of the bond. - issued_amount_max : Optional[str] - Maximum issued amount of the bond. - maturity_date_min : Optional[datetime.date] - Minimum maturity date of the bond. - maturity_date_max : Optional[datetime.date] - Maximum maturity date of the bond. - provider : Optional[Literal['tmx']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'tmx' if there is - no default. - issue_date_min : Optional[datetime.date] - Filter by the minimum original issue date. (provider: tmx) - issue_date_max : Optional[datetime.date] - Filter by the maximum original issue date. (provider: tmx) - last_traded_min : Optional[datetime.date] - Filter by the minimum last trade date. (provider: tmx) - use_cache : bool - All bond data is sourced from a single JSON file that is updated daily. The file is cached for one day to eliminate downloading more than once. Caching will significantly speed up subsequent queries. To bypass, set to False. (provider: tmx) - - Returns - ------- - OBBject - results : List[BondPrices] - Serializable results. - provider : Optional[Literal['tmx']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - BondPrices - ---------- - isin : Optional[str] - International Securities Identification Number of the bond. - lei : Optional[str] - Legal Entity Identifier of the issuing entity. - figi : Optional[str] - FIGI of the bond. - cusip : Optional[str] - CUSIP of the bond. - coupon_rate : Optional[float] - Coupon rate of the bond. - ytm : Optional[float] - Yield to maturity (YTM) is the rate of return anticipated on a bond if it is held until the maturity date. It takes into account the current market price, par value, coupon rate and time to maturity. It is assumed that all coupons are reinvested at the same rate. Values are returned as a normalized percent. (provider: tmx) - price : Optional[float] - The last price for the bond. (provider: tmx) - highest_price : Optional[float] - The highest price for the bond on the last traded date. (provider: tmx) - lowest_price : Optional[float] - The lowest price for the bond on the last traded date. (provider: tmx) - total_trades : Optional[int] - Total number of trades on the last traded date. (provider: tmx) - last_traded_date : Optional[date] - Last traded date of the bond. (provider: tmx) - maturity_date : Optional[date] - Maturity date of the bond. (provider: tmx) - issue_date : Optional[date] - Issue date of the bond. This is the date when the bond first accrues interest. (provider: tmx) - issuer_name : Optional[str] - Name of the issuing entity. (provider: tmx) - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.corporate.bond_prices() - """ # noqa: E501 - - return self._run( - "/fixedincome/corporate/bond_prices", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/fixedincome/corporate/bond_prices", - ("tmx",), - ) - }, - standard_params={ - "country": country, - "issuer_name": issuer_name, - "isin": isin, - "lei": lei, - "currency": currency, - "coupon_min": coupon_min, - "coupon_max": coupon_max, - "issued_amount_min": issued_amount_min, - "issued_amount_max": issued_amount_max, - "maturity_date_min": maturity_date_min, - "maturity_date_max": maturity_date_max, - }, - extra_params=kwargs, - ) - ) - @exception_handler @validate def commercial_paper( @@ -284,8 +105,8 @@ def commercial_paper( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.corporate.commercial_paper() - >>> obb.fixedincome.corporate.commercial_paper(maturity='15d') + >>> obb.fixedincome.corporate.commercial_paper(provider='fred') + >>> obb.fixedincome.corporate.commercial_paper(maturity='15d', provider='fred') """ # noqa: E501 return self._run( @@ -373,8 +194,8 @@ def hqm( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.corporate.hqm() - >>> obb.fixedincome.corporate.hqm(yield_curve='par') + >>> obb.fixedincome.corporate.hqm(provider='fred') + >>> obb.fixedincome.corporate.hqm(yield_curve='par', provider='fred') """ # noqa: E501 return self._run( @@ -472,8 +293,8 @@ def ice_bofa( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.corporate.ice_bofa() - >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst') + >>> obb.fixedincome.corporate.ice_bofa(provider='fred') + >>> obb.fixedincome.corporate.ice_bofa(index_type='yield_to_worst', provider='fred') """ # noqa: E501 return self._run( @@ -565,8 +386,8 @@ def moody( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.corporate.moody() - >>> obb.fixedincome.corporate.moody(index_type='baa') + >>> obb.fixedincome.corporate.moody(provider='fred') + >>> obb.fixedincome.corporate.moody(index_type='baa', provider='fred') """ # noqa: E501 return self._run( @@ -667,8 +488,8 @@ def spot_rates( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.corporate.spot_rates() - >>> obb.fixedincome.corporate.spot_rates(maturity='10,20,30,50') + >>> obb.fixedincome.corporate.spot_rates(provider='fred') + >>> obb.fixedincome.corporate.spot_rates(maturity='10,20,30,50', provider='fred') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_government.py b/openbb_platform/openbb/package/fixedincome_government.py index 5d24593e1523..be57bc8aa9f4 100644 --- a/openbb_platform/openbb/package/fixedincome_government.py +++ b/openbb_platform/openbb/package/fixedincome_government.py @@ -13,9 +13,6 @@ class ROUTER_fixedincome_government(Container): """/fixedincome/government - eu_yield_curve - treasury_auctions - treasury_prices treasury_rates us_yield_curve """ @@ -23,561 +20,6 @@ class ROUTER_fixedincome_government(Container): def __repr__(self) -> str: return self.__doc__ or "" - @exception_handler - @validate - def eu_yield_curve( - self, - date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter(description="A specific date to get data for."), - ] = None, - provider: Optional[Literal["ecb"]] = None, - **kwargs - ) -> OBBject: - """Euro Area Yield Curve. - - Gets euro area yield curve data from ECB. - - The graphic depiction of the relationship between the yield on bonds of the same credit quality but different - maturities is known as the yield curve. In the past, most market participants have constructed yield curves from - the observations of prices and yields in the Treasury market. Two reasons account for this tendency. First, - Treasury securities are viewed as free of default risk, and differences in creditworthiness do not affect yield - estimates. Second, as the most active bond market, the Treasury market offers the fewest problems of illiquidity - or infrequent trading. The key function of the Treasury yield curve is to serve as a benchmark for pricing bonds - and setting yields in other sectors of the debt market. - - It is clear that the market’s expectations of future rate changes are one important determinant of the - yield-curve shape. For example, a steeply upward-sloping curve may indicate market expectations of near-term Fed - tightening or of rising inflation. However, it may be too restrictive to assume that the yield differences across - bonds with different maturities only reflect the market’s rate expectations. The well-known pure expectations - hypothesis has such an extreme implication. The pure expectations hypothesis asserts that all government bonds - have the same near-term expected return (as the nominally riskless short-term bond) because the return-seeking - activity of risk-neutral traders removes all expected return differentials across bonds. - - - Parameters - ---------- - date : Union[datetime.date, None, str] - A specific date to get data for. - provider : Optional[Literal['ecb']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'ecb' if there is - no default. - rating : Literal['aaa', 'all_ratings'] - The rating type, either 'aaa' or 'all_ratings'. (provider: ecb) - yield_curve_type : Literal['spot_rate', 'instantaneous_forward', 'par_yield'] - The yield curve type. (provider: ecb) - - Returns - ------- - OBBject - results : List[EUYieldCurve] - Serializable results. - provider : Optional[Literal['ecb']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - EUYieldCurve - ------------ - maturity : Optional[float] - Maturity, in years. - rate : Optional[float] - Yield curve rate, as a normalized percent. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.government.eu_yield_curve() - >>> obb.fixedincome.government.eu_yield_curve(yield_curve_type='spot_rate') - """ # noqa: E501 - - return self._run( - "/fixedincome/government/eu_yield_curve", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/fixedincome/government/eu_yield_curve", - ("ecb",), - ) - }, - standard_params={ - "date": date, - }, - extra_params=kwargs, - ) - ) - - @exception_handler - @validate - def treasury_auctions( - self, - security_type: Annotated[ - Literal["Bill", "Note", "Bond", "CMB", "TIPS", "FRN", None], - OpenBBCustomParameter( - description="Used to only return securities of a particular type." - ), - ] = None, - cusip: Annotated[ - Optional[str], - OpenBBCustomParameter(description="Filter securities by CUSIP."), - ] = None, - page_size: Annotated[ - Optional[int], - OpenBBCustomParameter( - description="Maximum number of results to return; you must also include pagenum when using pagesize." - ), - ] = None, - page_num: Annotated[ - Optional[int], - OpenBBCustomParameter( - description="The first page number to display results for; used in combination with page size." - ), - ] = None, - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format. The default is 90 days ago." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="End date of the data, in YYYY-MM-DD format. The default is today." - ), - ] = None, - provider: Optional[Literal["government_us"]] = None, - **kwargs - ) -> OBBject: - """Government Treasury Auctions. - - Parameters - ---------- - security_type : Literal['Bill', 'Note', 'Bond', 'CMB', 'TIPS', 'FRN', None] - Used to only return securities of a particular type. - cusip : Optional[str] - Filter securities by CUSIP. - page_size : Optional[int] - Maximum number of results to return; you must also include pagenum when using pagesize. - page_num : Optional[int] - The first page number to display results for; used in combination with page size. - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. The default is 90 days ago. - end_date : Union[datetime.date, None, str] - End date of the data, in YYYY-MM-DD format. The default is today. - provider : Optional[Literal['government_us']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'government_us' if there is - no default. - - Returns - ------- - OBBject - results : List[TreasuryAuctions] - Serializable results. - provider : Optional[Literal['government_us']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - TreasuryAuctions - ---------------- - cusip : str - CUSIP of the Security. - issue_date : date - The issue date of the security. - security_type : Literal['Bill', 'Note', 'Bond', 'CMB', 'TIPS', 'FRN'] - The type of security. - security_term : str - The term of the security. - maturity_date : date - The maturity date of the security. - interest_rate : Optional[float] - The interest rate of the security. - cpi_on_issue_date : Optional[float] - Reference CPI rate on the issue date of the security. - cpi_on_dated_date : Optional[float] - Reference CPI rate on the dated date of the security. - announcement_date : Optional[date] - The announcement date of the security. - auction_date : Optional[date] - The auction date of the security. - auction_date_year : Optional[int] - The auction date year of the security. - dated_date : Optional[date] - The dated date of the security. - first_payment_date : Optional[date] - The first payment date of the security. - accrued_interest_per_100 : Optional[float] - Accrued interest per $100. - accrued_interest_per_1000 : Optional[float] - Accrued interest per $1000. - adjusted_accrued_interest_per_100 : Optional[float] - Adjusted accrued interest per $100. - adjusted_accrued_interest_per_1000 : Optional[float] - Adjusted accrued interest per $1000. - adjusted_price : Optional[float] - Adjusted price. - allocation_percentage : Optional[float] - Allocation percentage, as normalized percentage points. - allocation_percentage_decimals : Optional[float] - The number of decimals in the Allocation percentage. - announced_cusip : Optional[str] - The announced CUSIP of the security. - auction_format : Optional[str] - The auction format of the security. - avg_median_discount_rate : Optional[float] - The average median discount rate of the security. - avg_median_investment_rate : Optional[float] - The average median investment rate of the security. - avg_median_price : Optional[float] - The average median price paid for the security. - avg_median_discount_margin : Optional[float] - The average median discount margin of the security. - avg_median_yield : Optional[float] - The average median yield of the security. - back_dated : Optional[Literal['Yes', 'No']] - Whether the security is back dated. - back_dated_date : Optional[date] - The back dated date of the security. - bid_to_cover_ratio : Optional[float] - The bid to cover ratio of the security. - call_date : Optional[date] - The call date of the security. - callable : Optional[Literal['Yes', 'No']] - Whether the security is callable. - called_date : Optional[date] - The called date of the security. - cash_management_bill : Optional[Literal['Yes', 'No']] - Whether the security is a cash management bill. - closing_time_competitive : Optional[str] - The closing time for competitive bids on the security. - closing_time_non_competitive : Optional[str] - The closing time for non-competitive bids on the security. - competitive_accepted : Optional[int] - The accepted value for competitive bids on the security. - competitive_accepted_decimals : Optional[int] - The number of decimals in the Competitive Accepted. - competitive_tendered : Optional[int] - The tendered value for competitive bids on the security. - competitive_tenders_accepted : Optional[Literal['Yes', 'No']] - Whether competitive tenders are accepted on the security. - corp_us_cusip : Optional[str] - The CUSIP of the security. - cpi_base_reference_period : Optional[str] - The CPI base reference period of the security. - currently_outstanding : Optional[int] - The currently outstanding value on the security. - direct_bidder_accepted : Optional[int] - The accepted value from direct bidders on the security. - direct_bidder_tendered : Optional[int] - The tendered value from direct bidders on the security. - est_amount_of_publicly_held_maturing_security : Optional[int] - The estimated amount of publicly held maturing securities on the security. - fima_included : Optional[Literal['Yes', 'No']] - Whether the security is included in the FIMA (Foreign and International Money Authorities). - fima_non_competitive_accepted : Optional[int] - The non-competitive accepted value on the security from FIMAs. - fima_non_competitive_tendered : Optional[int] - The non-competitive tendered value on the security from FIMAs. - first_interest_period : Optional[str] - The first interest period of the security. - first_interest_payment_date : Optional[date] - The first interest payment date of the security. - floating_rate : Optional[Literal['Yes', 'No']] - Whether the security is a floating rate. - frn_index_determination_date : Optional[date] - The FRN index determination date of the security. - frn_index_determination_rate : Optional[float] - The FRN index determination rate of the security. - high_discount_rate : Optional[float] - The high discount rate of the security. - high_investment_rate : Optional[float] - The high investment rate of the security. - high_price : Optional[float] - The high price of the security at auction. - high_discount_margin : Optional[float] - The high discount margin of the security. - high_yield : Optional[float] - The high yield of the security at auction. - index_ratio_on_issue_date : Optional[float] - The index ratio on the issue date of the security. - indirect_bidder_accepted : Optional[int] - The accepted value from indirect bidders on the security. - indirect_bidder_tendered : Optional[int] - The tendered value from indirect bidders on the security. - interest_payment_frequency : Optional[str] - The interest payment frequency of the security. - low_discount_rate : Optional[float] - The low discount rate of the security. - low_investment_rate : Optional[float] - The low investment rate of the security. - low_price : Optional[float] - The low price of the security at auction. - low_discount_margin : Optional[float] - The low discount margin of the security. - low_yield : Optional[float] - The low yield of the security at auction. - maturing_date : Optional[date] - The maturing date of the security. - max_competitive_award : Optional[int] - The maximum competitive award at auction. - max_non_competitive_award : Optional[int] - The maximum non-competitive award at auction. - max_single_bid : Optional[int] - The maximum single bid at auction. - min_bid_amount : Optional[int] - The minimum bid amount at auction. - min_strip_amount : Optional[int] - The minimum strip amount at auction. - min_to_issue : Optional[int] - The minimum to issue at auction. - multiples_to_bid : Optional[int] - The multiples to bid at auction. - multiples_to_issue : Optional[int] - The multiples to issue at auction. - nlp_exclusion_amount : Optional[int] - The NLP exclusion amount at auction. - nlp_reporting_threshold : Optional[int] - The NLP reporting threshold at auction. - non_competitive_accepted : Optional[int] - The accepted value from non-competitive bidders on the security. - non_competitive_tenders_accepted : Optional[Literal['Yes', 'No']] - Whether or not the auction accepted non-competitive tenders. - offering_amount : Optional[int] - The offering amount at auction. - original_cusip : Optional[str] - The original CUSIP of the security. - original_dated_date : Optional[date] - The original dated date of the security. - original_issue_date : Optional[date] - The original issue date of the security. - original_security_term : Optional[str] - The original term of the security. - pdf_announcement : Optional[str] - The PDF filename for the announcement of the security. - pdf_competitive_results : Optional[str] - The PDF filename for the competitive results of the security. - pdf_non_competitive_results : Optional[str] - The PDF filename for the non-competitive results of the security. - pdf_special_announcement : Optional[str] - The PDF filename for the special announcements. - price_per_100 : Optional[float] - The price per 100 of the security. - primary_dealer_accepted : Optional[int] - The primary dealer accepted value on the security. - primary_dealer_tendered : Optional[int] - The primary dealer tendered value on the security. - reopening : Optional[Literal['Yes', 'No']] - Whether or not the auction was reopened. - security_term_day_month : Optional[str] - The security term in days or months. - security_term_week_year : Optional[str] - The security term in weeks or years. - series : Optional[str] - The series name of the security. - soma_accepted : Optional[int] - The SOMA accepted value on the security. - soma_holdings : Optional[int] - The SOMA holdings on the security. - soma_included : Optional[Literal['Yes', 'No']] - Whether or not the SOMA (System Open Market Account) was included on the security. - soma_tendered : Optional[int] - The SOMA tendered value on the security. - spread : Optional[float] - The spread on the security. - standard_payment_per_1000 : Optional[float] - The standard payment per 1000 of the security. - strippable : Optional[Literal['Yes', 'No']] - Whether or not the security is strippable. - term : Optional[str] - The term of the security. - tiin_conversion_factor_per_1000 : Optional[float] - The TIIN conversion factor per 1000 of the security. - tips : Optional[Literal['Yes', 'No']] - Whether or not the security is TIPS. - total_accepted : Optional[int] - The total accepted value at auction. - total_tendered : Optional[int] - The total tendered value at auction. - treasury_retail_accepted : Optional[int] - The accepted value on the security from retail. - treasury_retail_tenders_accepted : Optional[Literal['Yes', 'No']] - Whether or not the tender offers from retail are accepted - type : Optional[str] - The type of issuance. This might be different than the security type. - unadjusted_accrued_interest_per_1000 : Optional[float] - The unadjusted accrued interest per 1000 of the security. - unadjusted_price : Optional[float] - The unadjusted price of the security. - updated_timestamp : Optional[datetime] - The updated timestamp of the security. - xml_announcement : Optional[str] - The XML filename for the announcement of the security. - xml_competitive_results : Optional[str] - The XML filename for the competitive results of the security. - xml_special_announcement : Optional[str] - The XML filename for special announcements. - tint_cusip1 : Optional[str] - Tint CUSIP 1. - tint_cusip2 : Optional[str] - Tint CUSIP 2. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.government.treasury_auctions() - >>> obb.fixedincome.government.treasury_auctions(security_type='Bill', start_date='2022-01-01', end_date='2023-01-01') - """ # noqa: E501 - - return self._run( - "/fixedincome/government/treasury_auctions", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/fixedincome/government/treasury_auctions", - ("government_us",), - ) - }, - standard_params={ - "security_type": security_type, - "cusip": cusip, - "page_size": page_size, - "page_num": page_num, - "start_date": start_date, - "end_date": end_date, - }, - extra_params=kwargs, - ) - ) - - @exception_handler - @validate - def treasury_prices( - self, - date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="A specific date to get data for. No date will return the current posted data." - ), - ] = None, - provider: Optional[Literal["government_us", "tmx"]] = None, - **kwargs - ) -> OBBject: - """Government Treasury Prices by date. - - Parameters - ---------- - date : Union[datetime.date, None, str] - A specific date to get data for. No date will return the current posted data. - provider : Optional[Literal['government_us', 'tmx']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'government_us' if there is - no default. - cusip : Optional[str] - Filter by CUSIP. (provider: government_us) - security_type : Literal[None, 'bill', 'note', 'bond', 'tips', 'frn'] - Filter by security type. (provider: government_us) - govt_type : Literal['federal', 'provincial', 'municipal'] - The level of government issuer. (provider: tmx) - issue_date_min : Optional[datetime.date] - Filter by the minimum original issue date. (provider: tmx) - issue_date_max : Optional[datetime.date] - Filter by the maximum original issue date. (provider: tmx) - last_traded_min : Optional[datetime.date] - Filter by the minimum last trade date. (provider: tmx) - maturity_date_min : Optional[datetime.date] - Filter by the minimum maturity date. (provider: tmx) - maturity_date_max : Optional[datetime.date] - Filter by the maximum maturity date. (provider: tmx) - use_cache : bool - All bond data is sourced from a single JSON file that is updated daily. The file is cached for one day to eliminate downloading more than once. Caching will significantly speed up subsequent queries. To bypass, set to False. (provider: tmx) - - Returns - ------- - OBBject - results : List[TreasuryPrices] - Serializable results. - provider : Optional[Literal['government_us', 'tmx']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - TreasuryPrices - -------------- - issuer_name : Optional[str] - Name of the issuing entity. - cusip : Optional[str] - CUSIP of the security. - isin : Optional[str] - ISIN of the security. - security_type : Optional[str] - The type of Treasury security - i.e., Bill, Note, Bond, TIPS, FRN. - issue_date : Optional[date] - The original issue date of the security. - maturity_date : Optional[date] - The maturity date of the security. - call_date : Optional[date] - The call date of the security. - bid : Optional[float] - The bid price of the security. - offer : Optional[float] - The offer price of the security. - eod_price : Optional[float] - The end-of-day price of the security. - last_traded_date : Optional[date] - The last trade date of the security. - total_trades : Optional[int] - Total number of trades on the last traded date. - last_price : Optional[float] - The last price of the security. - highest_price : Optional[float] - The highest price for the bond on the last traded date. - lowest_price : Optional[float] - The lowest price for the bond on the last traded date. - rate : Optional[float] - The annualized interest rate or coupon of the security. - ytm : Optional[float] - Yield to maturity (YTM) is the rate of return anticipated on a bond if it is held until the maturity date. It takes into account the current market price, par value, coupon rate and time to maturity. It is assumed that all coupons are reinvested at the same rate. - - Examples - -------- - >>> from openbb import obb - >>> obb.fixedincome.government.treasury_prices() - >>> obb.fixedincome.government.treasury_prices(date='2019-02-05') - """ # noqa: E501 - - return self._run( - "/fixedincome/government/treasury_prices", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/fixedincome/government/treasury_prices", - ("government_us", "tmx"), - ) - }, - standard_params={ - "date": date, - }, - extra_params=kwargs, - ) - ) - @exception_handler @validate def treasury_rates( @@ -658,8 +100,7 @@ def treasury_rates( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.government.treasury_rates() - >>> obb.fixedincome.government.treasury_rates(provider='federal_reserve') + >>> obb.fixedincome.government.treasury_rates(provider='fmp') """ # noqa: E501 return self._run( @@ -734,8 +175,8 @@ def us_yield_curve( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.government.us_yield_curve() - >>> obb.fixedincome.government.us_yield_curve(inflation_adjusted=True) + >>> obb.fixedincome.government.us_yield_curve(provider='fred') + >>> obb.fixedincome.government.us_yield_curve(inflation_adjusted=True, provider='fred') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_rate.py b/openbb_platform/openbb/package/fixedincome_rate.py index b6f17f9f5a4f..8ae6d60b7699 100644 --- a/openbb_platform/openbb/package/fixedincome_rate.py +++ b/openbb_platform/openbb/package/fixedincome_rate.py @@ -89,8 +89,8 @@ def ameribor( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.rate.ameribor() - >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma') + >>> obb.fixedincome.rate.ameribor(provider='fred') + >>> obb.fixedincome.rate.ameribor(parameter='30_day_ma', provider='fred') """ # noqa: E501 return self._run( @@ -175,8 +175,8 @@ def dpcredit( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.rate.dpcredit() - >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01') + >>> obb.fixedincome.rate.dpcredit(provider='fred') + >>> obb.fixedincome.rate.dpcredit(start_date='2023-02-01', end_date='2023-05-01', provider='fred') """ # noqa: E501 return self._run( @@ -267,8 +267,8 @@ def ecb( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.rate.ecb() - >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing') + >>> obb.fixedincome.rate.ecb(provider='fred') + >>> obb.fixedincome.rate.ecb(interest_rate_type='refinancing', provider='fred') """ # noqa: E501 return self._run( @@ -353,7 +353,7 @@ def effr( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.rate.effr() + >>> obb.fixedincome.rate.effr(provider='fred') >>> obb.fixedincome.rate.effr(parameter='daily', provider='fred') """ # noqa: E501 @@ -433,8 +433,8 @@ def effr_forecast( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.rate.effr_forecast() - >>> obb.fixedincome.rate.effr_forecast(long_run=True) + >>> obb.fixedincome.rate.effr_forecast(provider='fred') + >>> obb.fixedincome.rate.effr_forecast(long_run=True, provider='fred') """ # noqa: E501 return self._run( @@ -516,8 +516,8 @@ def estr( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.rate.estr() - >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks') + >>> obb.fixedincome.rate.estr(provider='fred') + >>> obb.fixedincome.rate.estr(parameter='number_of_active_banks', provider='fred') """ # noqa: E501 return self._run( @@ -599,7 +599,7 @@ def iorb( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.rate.iorb() + >>> obb.fixedincome.rate.iorb(provider='fred') """ # noqa: E501 return self._run( @@ -683,8 +683,8 @@ def sonia( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.rate.sonia() - >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value') + >>> obb.fixedincome.rate.sonia(provider='fred') + >>> obb.fixedincome.rate.sonia(parameter='total_nominal_value', provider='fred') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/fixedincome_spreads.py b/openbb_platform/openbb/package/fixedincome_spreads.py index 3195690a3a9d..5555fb8acf54 100644 --- a/openbb_platform/openbb/package/fixedincome_spreads.py +++ b/openbb_platform/openbb/package/fixedincome_spreads.py @@ -89,8 +89,8 @@ def tcm( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.spreads.tcm() - >>> obb.fixedincome.spreads.tcm(maturity='2y') + >>> obb.fixedincome.spreads.tcm(provider='fred') + >>> obb.fixedincome.spreads.tcm(maturity='2y', provider='fred') """ # noqa: E501 return self._run( @@ -180,8 +180,8 @@ def tcm_effr( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.spreads.tcm_effr() - >>> obb.fixedincome.spreads.tcm_effr(maturity='10y') + >>> obb.fixedincome.spreads.tcm_effr(provider='fred') + >>> obb.fixedincome.spreads.tcm_effr(maturity='10y', provider='fred') """ # noqa: E501 return self._run( @@ -272,8 +272,8 @@ def treasury_effr( Examples -------- >>> from openbb import obb - >>> obb.fixedincome.spreads.treasury_effr() - >>> obb.fixedincome.spreads.treasury_effr(maturity='6m') + >>> obb.fixedincome.spreads.treasury_effr(provider='fred') + >>> obb.fixedincome.spreads.treasury_effr(maturity='6m', provider='fred') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index fd36c153e37e..6553ca5ef71f 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -19,10 +19,6 @@ class ROUTER_index(Container): constituents market /price - search - sectors - snapshots - sp500_multiples """ def __repr__(self) -> str: @@ -31,28 +27,23 @@ def __repr__(self) -> str: @exception_handler @validate def available( - self, - provider: Optional[Literal["cboe", "fmp", "tmx", "yfinance"]] = None, - **kwargs + self, provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs ) -> OBBject: """All indices available from a given provider. Parameters ---------- - provider : Optional[Literal['cboe', 'fmp', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'yfinance']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'cboe' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. - use_cache : bool - When True, the Cboe Index directory will be cached for 24 hours. Set as False to bypass. (provider: cboe); - Whether to use a cached request. Index data is from a single JSON file, updated each day after close. It is cached for one day. To bypass, set to False. (provider: tmx) Returns ------- OBBject results : List[AvailableIndices] Serializable results. - provider : Optional[Literal['cboe', 'fmp', 'tmx', 'yfinance']] + provider : Optional[Literal['fmp', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -67,35 +58,19 @@ def available( Name of the index. currency : Optional[str] Currency the index is traded in. - symbol : Optional[str] - Symbol for the index. (provider: cboe, tmx, yfinance) - description : Optional[str] - Description for the index. Valid only for US indices. (provider: cboe) - data_delay : Optional[int] - Data delay for the index. Valid only for US indices. (provider: cboe) - open_time : Optional[datetime.time] - Opening time for the index. Valid only for US indices. (provider: cboe) - close_time : Optional[datetime.time] - Closing time for the index. Valid only for US indices. (provider: cboe) - time_zone : Optional[str] - Time zone for the index. Valid only for US indices. (provider: cboe) - tick_days : Optional[str] - The trading days for the index. Valid only for US indices. (provider: cboe) - tick_frequency : Optional[str] - The frequency of the index ticks. Valid only for US indices. (provider: cboe) - tick_period : Optional[str] - The period of the index ticks. Valid only for US indices. (provider: cboe) stock_exchange : Optional[str] Stock exchange where the index is listed. (provider: fmp) exchange_short_name : Optional[str] Short name of the stock exchange where the index is listed. (provider: fmp) code : Optional[str] ID code for keying the index in the OpenBB Terminal. (provider: yfinance) + symbol : Optional[str] + Symbol for the index. (provider: yfinance) Examples -------- >>> from openbb import obb - >>> obb.index.available() + >>> obb.index.available(provider='fmp') >>> obb.index.available(provider='yfinance') """ # noqa: E501 @@ -106,7 +81,7 @@ def available( "provider": self._get_provider( provider, "/index/available", - ("cboe", "fmp", "tmx", "yfinance"), + ("fmp", "yfinance"), ) }, standard_params={}, @@ -121,7 +96,7 @@ def constituents( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["cboe", "fmp", "tmx"]] = None, + provider: Optional[Literal["fmp"]] = None, **kwargs ) -> OBBject: """Index Constituents. @@ -130,19 +105,17 @@ def constituents( ---------- symbol : str Symbol to get data for. - provider : Optional[Literal['cboe', 'fmp', 'tmx']] + provider : Optional[Literal['fmp']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'cboe' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. - use_cache : bool - Whether to use a cached request. Index data is from a single JSON file, updated each day after close. It is cached for one day. To bypass, set to False. (provider: tmx) Returns ------- OBBject results : List[IndexConstituents] Serializable results. - provider : Optional[Literal['cboe', 'fmp', 'tmx']] + provider : Optional[Literal['fmp']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -157,32 +130,6 @@ def constituents( Symbol representing the entity requested in the data. name : Optional[str] Name of the constituent company in the index. - security_type : Optional[str] - The type of security represented. (provider: cboe) - last_price : Optional[float] - Last price for the symbol. (provider: cboe) - open : Optional[float] - The open price. (provider: cboe) - high : Optional[float] - The high price. (provider: cboe) - low : Optional[float] - The low price. (provider: cboe) - close : Optional[float] - The close price. (provider: cboe) - volume : Optional[int] - The trading volume. (provider: cboe) - prev_close : Optional[float] - The previous close price. (provider: cboe) - change : Optional[float] - Change in price. (provider: cboe) - change_percent : Optional[float] - Change in price as a normalized percentage. (provider: cboe) - tick : Optional[str] - Whether the last sale was an up or down tick. (provider: cboe) - last_trade_time : Optional[datetime] - Last trade timestamp for the symbol. (provider: cboe) - asset_type : Optional[str] - Type of asset. (provider: cboe) sector : Optional[str] Sector the constituent company in the index belongs to. (provider: fmp) sub_sector : Optional[str] @@ -195,15 +142,11 @@ def constituents( Central Index Key (CIK) for the requested entity. (provider: fmp) founded : Optional[Union[str, date]] Founding year of the constituent company in the index. (provider: fmp) - market_value : Optional[float] - The quoted market value of the asset. (provider: tmx) Examples -------- >>> from openbb import obb >>> obb.index.constituents(symbol='dowjones', provider='fmp') - >>> # Providers other than FMP will use the ticker symbol. - >>> obb.index.constituents(symbol='BEP50P', provider='cboe') """ # noqa: E501 return self._run( @@ -213,7 +156,7 @@ def constituents( "provider": self._get_provider( provider, "/index/constituents", - ("cboe", "fmp", "tmx"), + ("fmp",), ) }, standard_params={ @@ -234,7 +177,7 @@ def market( symbol: Annotated[ Union[str, List[str]], OpenBBCustomParameter( - description="Symbol to get data for. Multiple items allowed for provider(s): cboe, fmp, intrinio, polygon, yfinance." + description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, polygon, yfinance." ), ], start_date: Annotated[ @@ -253,9 +196,7 @@ def market( Optional[str], OpenBBCustomParameter(description="Time interval of the data to return."), ] = "1d", - provider: Optional[ - Literal["cboe", "fmp", "intrinio", "polygon", "yfinance"] - ] = None, + provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, **kwargs ) -> OBBject: """Historical Market Indices. @@ -263,19 +204,17 @@ def market( Parameters ---------- symbol : Union[str, List[str]] - Symbol to get data for. Multiple items allowed for provider(s): cboe, fmp, intrinio, polygon, yfinance. + Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, polygon, yfinance. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. interval : Optional[str] Time interval of the data to return. - provider : Optional[Literal['cboe', 'fmp', 'intrinio', 'polygon', 'yfinance'... + provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'cboe' if there is + If None, the provider specified in defaults is selected or 'fmp' if there is no default. - use_cache : bool - When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe) limit : Optional[int] The number of data entries to return. (provider: intrinio, polygon) sort : Literal['asc', 'desc'] @@ -286,7 +225,7 @@ def market( OBBject results : List[MarketIndices] Serializable results. - provider : Optional[Literal['cboe', 'fmp', 'intrinio', 'polygon', 'yfinance']] + provider : Optional[Literal['fmp', 'intrinio', 'polygon', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -309,12 +248,6 @@ def market( The close price. volume : Optional[int] The trading volume. - calls_volume : Optional[float] - Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) - puts_volume : Optional[float] - Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) - total_options_volume : Optional[float] - Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe) vwap : Optional[float] Volume Weighted Average Price over the period. (provider: fmp) change : Optional[float] @@ -327,7 +260,7 @@ def market( Examples -------- >>> from openbb import obb - >>> obb.index.market(symbol='SPX') + >>> obb.index.market(symbol='SPX', provider='fmp') """ # noqa: E501 simplefilter("always", DeprecationWarning) @@ -344,7 +277,7 @@ def market( "provider": self._get_provider( provider, "/index/market", - ("cboe", "fmp", "intrinio", "polygon", "yfinance"), + ("fmp", "intrinio", "polygon", "yfinance"), ) }, standard_params={ @@ -357,7 +290,6 @@ def market( extra_info={ "symbol": { "multiple_items_allowed": [ - "cboe", "fmp", "intrinio", "polygon", @@ -374,428 +306,3 @@ def price(self): from . import index_price return index_price.ROUTER_index_price(command_runner=self._command_runner) - - @exception_handler - @validate - def search( - self, - query: Annotated[str, OpenBBCustomParameter(description="Search query.")] = "", - is_symbol: Annotated[ - bool, - OpenBBCustomParameter(description="Whether to search by ticker symbol."), - ] = False, - provider: Optional[Literal["cboe"]] = None, - **kwargs - ) -> OBBject: - """Filters indices for rows containing the query. - - Parameters - ---------- - query : str - Search query. - is_symbol : bool - Whether to search by ticker symbol. - provider : Optional[Literal['cboe']] - 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. - use_cache : bool - When True, the Cboe Index directory will be cached for 24 hours. Set as False to bypass. (provider: cboe) - - Returns - ------- - OBBject - results : List[IndexSearch] - Serializable results. - provider : Optional[Literal['cboe']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - IndexSearch - ----------- - symbol : str - Symbol representing the entity requested in the data. - name : str - Name of the index. - description : Optional[str] - Description for the index. (provider: cboe) - data_delay : Optional[int] - Data delay for the index. Valid only for US indices. (provider: cboe) - currency : Optional[str] - Currency for the index. (provider: cboe) - time_zone : Optional[str] - Time zone for the index. Valid only for US indices. (provider: cboe) - open_time : Optional[datetime.time] - Opening time for the index. Valid only for US indices. (provider: cboe) - close_time : Optional[datetime.time] - Closing time for the index. Valid only for US indices. (provider: cboe) - tick_days : Optional[str] - The trading days for the index. Valid only for US indices. (provider: cboe) - tick_frequency : Optional[str] - Tick frequency for the index. Valid only for US indices. (provider: cboe) - tick_period : Optional[str] - Tick period for the index. Valid only for US indices. (provider: cboe) - - Examples - -------- - >>> from openbb import obb - >>> obb.index.search() - >>> obb.index.search(query='SPX', provider='cboe') - """ # noqa: E501 - - return self._run( - "/index/search", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/index/search", - ("cboe",), - ) - }, - standard_params={ - "query": query, - "is_symbol": is_symbol, - }, - extra_params=kwargs, - ) - ) - - @exception_handler - @validate - def sectors( - self, - symbol: Annotated[ - str, OpenBBCustomParameter(description="Symbol to get data for.") - ], - provider: Optional[Literal["tmx"]] = None, - **kwargs - ) -> OBBject: - """Index Sectors. Sector weighting of an index. - - Parameters - ---------- - symbol : str - Symbol to get data for. - provider : Optional[Literal['tmx']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'tmx' if there is - no default. - use_cache : bool - Whether to use a cached request. All Index data comes from a single JSON file that is updated daily. To bypass, set to False. If True, the data will be cached for 1 day. (provider: tmx) - - Returns - ------- - OBBject - results : List[IndexSectors] - Serializable results. - provider : Optional[Literal['tmx']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - IndexSectors - ------------ - sector : str - The sector name. - weight : float - The weight of the sector in the index. - - Examples - -------- - >>> from openbb import obb - >>> obb.index.sectors(symbol='^TX60') - """ # noqa: E501 - - return self._run( - "/index/sectors", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/index/sectors", - ("tmx",), - ) - }, - standard_params={ - "symbol": symbol, - }, - extra_params=kwargs, - ) - ) - - @exception_handler - @validate - def snapshots( - self, - region: Annotated[ - str, - OpenBBCustomParameter( - description="The region of focus for the data - i.e., us, eu." - ), - ] = "us", - provider: Optional[Literal["cboe", "tmx"]] = None, - **kwargs - ) -> OBBject: - """Index Snapshots. Current levels for all indices from a provider, grouped by `region`. - - Parameters - ---------- - region : str - The region of focus for the data - i.e., us, eu. - provider : Optional[Literal['cboe', 'tmx']] - 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. - use_cache : bool - Whether to use a cached request. Index data is from a single JSON file, updated each day after close. It is cached for one day. To bypass, set to False. (provider: tmx) - - Returns - ------- - OBBject - results : List[IndexSnapshots] - Serializable results. - provider : Optional[Literal['cboe', 'tmx']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - IndexSnapshots - -------------- - symbol : str - Symbol representing the entity requested in the data. - name : Optional[str] - Name of the index. - currency : Optional[str] - Currency of the index. - price : Optional[float] - Current price of the index. - open : Optional[float] - The open price. - high : Optional[float] - The high price. - low : Optional[float] - The low price. - close : Optional[float] - The close price. - volume : Optional[int] - The trading volume. - prev_close : Optional[float] - The previous close price. - change : Optional[float] - Change in value of the index. - change_percent : Optional[float] - Change, in normalized percentage points, of the index. - bid : Optional[float] - Current bid price. (provider: cboe) - ask : Optional[float] - Current ask price. (provider: cboe) - last_trade_time : Optional[datetime] - Last trade timestamp for the symbol. (provider: cboe) - status : Optional[str] - Status of the market, open or closed. (provider: cboe) - year_high : Optional[float] - The 52-week high of the index. (provider: tmx) - year_low : Optional[float] - The 52-week low of the index. (provider: tmx) - return_mtd : Optional[float] - The month-to-date return of the index, as a normalized percent. (provider: tmx) - return_qtd : Optional[float] - The quarter-to-date return of the index, as a normalized percent. (provider: tmx) - return_ytd : Optional[float] - The year-to-date return of the index, as a normalized percent. (provider: tmx) - total_market_value : Optional[float] - The total quoted market value of the index. (provider: tmx) - number_of_constituents : Optional[int] - The number of constituents in the index. (provider: tmx) - constituent_average_market_value : Optional[float] - The average quoted market value of the index constituents. (provider: tmx) - constituent_median_market_value : Optional[float] - The median quoted market value of the index constituents. (provider: tmx) - constituent_top10_market_value : Optional[float] - The sum of the top 10 quoted market values of the index constituents. (provider: tmx) - constituent_largest_market_value : Optional[float] - The largest quoted market value of the index constituents. (provider: tmx) - constituent_largest_weight : Optional[float] - The largest weight of the index constituents, as a normalized percent. (provider: tmx) - constituent_smallest_market_value : Optional[float] - The smallest quoted market value of the index constituents. (provider: tmx) - constituent_smallest_weight : Optional[float] - The smallest weight of the index constituents, as a normalized percent. (provider: tmx) - - Examples - -------- - >>> from openbb import obb - >>> obb.index.snapshots() - >>> obb.index.snapshots(region='us', provider='cboe') - """ # noqa: E501 - - return self._run( - "/index/snapshots", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/index/snapshots", - ("cboe", "tmx"), - ) - }, - standard_params={ - "region": region, - }, - extra_params=kwargs, - ) - ) - - @exception_handler - @validate - def sp500_multiples( - self, - series_name: Annotated[ - Literal[ - "shiller_pe_month", - "shiller_pe_year", - "pe_year", - "pe_month", - "dividend_year", - "dividend_month", - "dividend_growth_quarter", - "dividend_growth_year", - "dividend_yield_year", - "dividend_yield_month", - "earnings_year", - "earnings_month", - "earnings_growth_year", - "earnings_growth_quarter", - "real_earnings_growth_year", - "real_earnings_growth_quarter", - "earnings_yield_year", - "earnings_yield_month", - "real_price_year", - "real_price_month", - "inflation_adjusted_price_year", - "inflation_adjusted_price_month", - "sales_year", - "sales_quarter", - "sales_growth_year", - "sales_growth_quarter", - "real_sales_year", - "real_sales_quarter", - "real_sales_growth_year", - "real_sales_growth_quarter", - "price_to_sales_year", - "price_to_sales_quarter", - "price_to_book_value_year", - "price_to_book_value_quarter", - "book_value_year", - "book_value_quarter", - ], - OpenBBCustomParameter( - description="The name of the series. Defaults to 'pe_month'." - ), - ] = "pe_month", - start_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - end_date: Annotated[ - Union[datetime.date, None, str], - OpenBBCustomParameter( - description="Start date of the data, in YYYY-MM-DD format." - ), - ] = None, - transform: Annotated[ - Literal["diff", "rdiff", "cumul", "normalize", None], - OpenBBCustomParameter( - description="Transform the data as difference, percent change, cumulative, or normalize." - ), - ] = None, - collapse: Annotated[ - Literal["daily", "weekly", "monthly", "quarterly", "annual", None], - OpenBBCustomParameter( - description="Collapse the frequency of the time series." - ), - ] = None, - provider: Optional[Literal["nasdaq"]] = None, - **kwargs - ) -> OBBject: - """Historical S&P 500 multiples and Shiller PE ratios. - - Parameters - ---------- - series_name : Literal['shiller_pe_month', 'shiller_pe_year', 'pe_year', 'pe_month', 'd... - The name of the series. Defaults to 'pe_month'. - start_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - end_date : Union[datetime.date, None, str] - Start date of the data, in YYYY-MM-DD format. - transform : Literal['diff', 'rdiff', 'cumul', 'normalize', None] - Transform the data as difference, percent change, cumulative, or normalize. - collapse : Literal['daily', 'weekly', 'monthly', 'quarterly', 'annual', None] - Collapse the frequency of the time series. - provider : Optional[Literal['nasdaq']] - The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or 'nasdaq' if there is - no default. - - Returns - ------- - OBBject - results : List[SP500Multiples] - Serializable results. - provider : Optional[Literal['nasdaq']] - Provider name. - warnings : Optional[List[Warning_]] - List of warnings. - chart : Optional[Chart] - Chart object. - extra : Dict[str, Any] - Extra info. - - SP500Multiples - -------------- - date : date - The date of the data. - - Examples - -------- - >>> from openbb import obb - >>> obb.index.sp500_multiples() - >>> obb.index.sp500_multiples(series_name='shiller_pe_year', provider='nasdaq') - """ # noqa: E501 - - return self._run( - "/index/sp500_multiples", - **filter_inputs( - provider_choices={ - "provider": self._get_provider( - provider, - "/index/sp500_multiples", - ("nasdaq",), - ) - }, - standard_params={ - "series_name": series_name, - "start_date": start_date, - "end_date": end_date, - "transform": transform, - "collapse": collapse, - }, - extra_params=kwargs, - ) - ) diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index ab15654adf9a..3af85fbe9f79 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -28,7 +28,7 @@ def company( symbol: Annotated[ Union[str, None, List[Optional[str]]], OpenBBCustomParameter( - description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, tmx, yfinance." + description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, yfinance." ), ] = None, start_date: Annotated[ @@ -48,9 +48,7 @@ def company( OpenBBCustomParameter(description="The number of data entries to return."), ] = 2500, provider: Optional[ - Literal[ - "benzinga", "fmp", "intrinio", "polygon", "tiingo", "tmx", "yfinance" - ] + Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"] ] = None, **kwargs ) -> OBBject: @@ -59,7 +57,7 @@ def company( Parameters ---------- symbol : Union[str, None, List[Optional[str]]] - Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, tmx, yfinance. + Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): benzinga, fmp, intrinio, polygon, tiingo, yfinance. start_date : Union[datetime.date, None, str] Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] @@ -96,8 +94,7 @@ def company( content_types : Optional[str] Content types of the news to retrieve. (provider: benzinga) page : Optional[int] - Page number of the results. Use in combination with limit. (provider: fmp); - The page number to start from. Use with limit. (provider: tmx) + Page number of the results. Use in combination with limit. (provider: fmp) offset : Optional[int] Page offset, used in conjunction with limit. (provider: tiingo) source : Optional[str] @@ -108,7 +105,7 @@ def company( OBBject results : List[CompanyNews] Serializable results. - provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'polygon', 'tiingo', 'tmx', 'yfinance']] + provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -149,7 +146,6 @@ def company( Name of the news source. (provider: fmp); Source of the article. (provider: polygon); News source. (provider: tiingo); - Source of the news. (provider: tmx); Source of the news article (provider: yfinance) amp_url : Optional[str] AMP URL. (provider: polygon) @@ -163,16 +159,16 @@ def company( Examples -------- >>> from openbb import obb - >>> obb.news.company() - >>> obb.news.company(limit=100) + >>> obb.news.company(provider='fmp') + >>> obb.news.company(limit=100, provider='fmp') >>> # Get news on the specified dates. - >>> obb.news.company(symbol='AAPL', start_date='2024-02-01', end_date='2024-02-07') + >>> obb.news.company(symbol='AAPL', start_date='2024-02-01', end_date='2024-02-07', provider='intrinio') >>> # Display the headlines of the news. >>> obb.news.company(symbol='AAPL', display='headline', provider='benzinga') >>> # Get news for multiple symbols. - >>> obb.news.company(symbol='aapl,tsla') + >>> obb.news.company(symbol='aapl,tsla', provider='fmp') >>> # Get news company's ISIN. - >>> obb.news.company(symbol='NVDA', isin='US0378331005') + >>> obb.news.company(symbol='NVDA', isin='US0378331005', provider='benzinga') """ # noqa: E501 return self._run( @@ -188,7 +184,6 @@ def company( "intrinio", "polygon", "tiingo", - "tmx", "yfinance", ), ) @@ -208,7 +203,6 @@ def company( "intrinio", "polygon", "tiingo", - "tmx", "yfinance", ] } @@ -238,9 +232,7 @@ def world( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[ - Literal["benzinga", "biztoc", "fmp", "intrinio", "tiingo"] - ] = None, + provider: Optional[Literal["benzinga", "fmp", "intrinio", "tiingo"]] = None, **kwargs ) -> OBBject: """World News. Global news data. @@ -253,7 +245,7 @@ def world( Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['benzinga', 'biztoc', 'fmp', 'intrinio', 'tiingo... + provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'tiingo']] 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. @@ -281,24 +273,17 @@ def world( Authors of the news to retrieve. (provider: benzinga) content_types : Optional[str] Content types of the news to retrieve. (provider: benzinga) - filter : Literal['crypto', 'hot', 'latest', 'main', 'media', 'source', 'tag'] - Filter by type of news. (provider: biztoc) - source : Optional[str] - Filter by a specific publisher. Only valid when filter is set to source. (provider: biztoc); - A comma-separated list of the domains requested. (provider: tiingo) - tag : Optional[str] - Tag, topic, to filter articles by. Only valid when filter is set to tag. (provider: biztoc) - term : Optional[str] - Search term to filter articles by. This overrides all other filters. (provider: biztoc) offset : Optional[int] Page offset, used in conjunction with limit. (provider: tiingo) + source : Optional[str] + A comma-separated list of the domains requested. (provider: tiingo) Returns ------- OBBject results : List[WorldNews] Serializable results. - provider : Optional[Literal['benzinga', 'biztoc', 'fmp', 'intrinio', 'tiingo']] + provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'tiingo']] Provider name. warnings : Optional[List[Warning_]] List of warnings. @@ -320,7 +305,7 @@ def world( url : Optional[str] URL to the article. id : Optional[str] - Article ID. (provider: benzinga, biztoc, intrinio) + Article ID. (provider: benzinga, intrinio) author : Optional[str] Author of the news. (provider: benzinga) teaser : Optional[str] @@ -329,14 +314,10 @@ def world( Channels associated with the news. (provider: benzinga) stocks : Optional[str] Stocks associated with the news. (provider: benzinga) - tags : Optional[Union[str, List[str]]] - Tags associated with the news. (provider: benzinga, biztoc, tiingo) + tags : Optional[str] + Tags associated with the news. (provider: benzinga, tiingo) updated : Optional[datetime] Updated date of the news. (provider: benzinga) - favicon : Optional[str] - Icon image for the source of the article. (provider: biztoc) - score : Optional[float] - Search relevance score for the article. (provider: biztoc) site : Optional[str] News source. (provider: fmp, tiingo) company : Optional[Dict[str, Any]] @@ -351,18 +332,16 @@ def world( Examples -------- >>> from openbb import obb - >>> obb.news.world() - >>> obb.news.world(limit=100) + >>> obb.news.world(provider='fmp') + >>> obb.news.world(limit=100, provider='intrinio') >>> # Get news on the specified dates. - >>> obb.news.world(start_date='2024-02-01', end_date='2024-02-07') + >>> obb.news.world(start_date='2024-02-01', end_date='2024-02-07', provider='intrinio') >>> # Display the headlines of the news. >>> obb.news.world(display='headline', provider='benzinga') >>> # Get news by topics. >>> obb.news.world(topics='finance', provider='benzinga') >>> # Get news by source using 'tingo' as provider. >>> obb.news.world(provider='tiingo', source='bloomberg') - >>> # Filter aticles by term using 'biztoc' as provider. - >>> obb.news.world(provider='biztoc', term='apple') """ # noqa: E501 return self._run( @@ -372,7 +351,7 @@ def world( "provider": self._get_provider( provider, "/news/world", - ("benzinga", "biztoc", "fmp", "intrinio", "tiingo"), + ("benzinga", "fmp", "intrinio", "tiingo"), ) }, standard_params={ diff --git a/openbb_platform/openbb/package/regulators.py b/openbb_platform/openbb/package/regulators.py index f309425d2784..753e0bfc69aa 100644 --- a/openbb_platform/openbb/package/regulators.py +++ b/openbb_platform/openbb/package/regulators.py @@ -6,22 +6,12 @@ class ROUTER_regulators(Container): """/regulators - /cftc /sec """ def __repr__(self) -> str: return self.__doc__ or "" - @property - def cftc(self): - # pylint: disable=import-outside-toplevel - from . import regulators_cftc - - return regulators_cftc.ROUTER_regulators_cftc( - command_runner=self._command_runner - ) - @property def sec(self): # pylint: disable=import-outside-toplevel diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index da1772db78be..c64d5a62af68 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -66,7 +66,7 @@ def cik_map( Examples -------- >>> from openbb import obb - >>> obb.regulators.sec.cik_map(symbol='MSFT') + >>> obb.regulators.sec.cik_map(symbol='MSFT', provider='sec') """ # noqa: E501 return self._run( @@ -137,8 +137,8 @@ def institutions_search( Examples -------- >>> from openbb import obb - >>> obb.regulators.sec.institutions_search() - >>> obb.regulators.sec.institutions_search(query='blackstone real estate') + >>> obb.regulators.sec.institutions_search(provider='sec') + >>> obb.regulators.sec.institutions_search(query='blackstone real estate', provider='sec') """ # noqa: E501 return self._run( @@ -203,7 +203,7 @@ def rss_litigation( Examples -------- >>> from openbb import obb - >>> obb.regulators.sec.rss_litigation() + >>> obb.regulators.sec.rss_litigation(provider='sec') """ # noqa: E501 return self._run( @@ -272,7 +272,7 @@ def schema_files( Examples -------- >>> from openbb import obb - >>> obb.regulators.sec.schema_files() + >>> obb.regulators.sec.schema_files(provider='sec') >>> # Get a list of schema files. >>> data = obb.regulators.sec.schema_files().results >>> data.files[0] @@ -364,8 +364,8 @@ def sic_search( Examples -------- >>> from openbb import obb - >>> obb.regulators.sec.sic_search() - >>> obb.regulators.sec.sic_search(query='real estate investment trusts') + >>> obb.regulators.sec.sic_search(provider='sec') + >>> obb.regulators.sec.sic_search(query='real estate investment trusts', provider='sec') """ # noqa: E501 return self._run( @@ -435,7 +435,7 @@ def symbol_map( Examples -------- >>> from openbb import obb - >>> obb.regulators.sec.symbol_map(query='0000789019') + >>> obb.regulators.sec.symbol_map(query='0000789019', provider='sec') """ # noqa: E501 return self._run( From b5f63bf3979f7c93aa47cf67b84d579b61a6ae28 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Fri, 8 Mar 2024 23:47:06 +0000 Subject: [PATCH 125/133] working examples --- .../extensions/crypto/openbb_crypto/price/price_router.py | 2 +- .../openbb_equity/fundamental/fundamental_router.py | 8 ++++---- .../extensions/index/openbb_index/index_router.py | 2 +- .../extensions/news/openbb_news/news_router.py | 4 ++-- openbb_platform/openbb/package/crypto_price.py | 2 +- openbb_platform/openbb/package/equity_fundamental.py | 8 ++++---- openbb_platform/openbb/package/index.py | 2 +- openbb_platform/openbb/package/news.py | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py index 24aa03763753..efce03361499 100644 --- a/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py +++ b/openbb_platform/extensions/crypto/openbb_crypto/price/price_router.py @@ -40,7 +40,7 @@ description="Get monthly historical prices from Yahoo Finance for Ethereum.", parameters={ "symbol": "ETH-USD", - "interval": "1mo", + "interval": "1m", "start_date": "2024-01-01", "end_date": "2024-12-31", "provider": "yfinance", diff --git a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py index de572174d07a..e2cf2b7f97ad 100644 --- a/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py +++ b/openbb_platform/extensions/equity/openbb_equity/fundamental/fundamental_router.py @@ -58,7 +58,7 @@ async def balance( model="BalanceSheetGrowth", examples=[ APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), - APIEx(parameters={"symbol": "AAPL", "limit": 10, "provider": "intrinio"}), + APIEx(parameters={"symbol": "AAPL", "limit": 10, "provider": "fmp"}), ], ) async def balance_growth( @@ -141,7 +141,7 @@ async def reported_financials( model="CashFlowStatementGrowth", examples=[ APIEx(parameters={"symbol": "AAPL", "provider": "fmp"}), - APIEx(parameters={"symbol": "AAPL", "limit": 10, "provider": "intrinio"}), + APIEx(parameters={"symbol": "AAPL", "limit": 10, "provider": "fmp"}), ], ) async def cash_growth( @@ -275,7 +275,7 @@ async def income( "symbol": "AAPL", "limit": 10, "period": "annual", - "provider": "intrinio", + "provider": "fmp", } ), ], @@ -438,7 +438,7 @@ async def revenue_per_segment( model="CompanyFilings", examples=[ APIEx(parameters={"provider": "fmp"}), - APIEx(parameters={"limit": 100, "provider": "intrinio"}), + APIEx(parameters={"limit": 100, "provider": "fmp"}), ], ) async def filings( diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index c4a91fb2186f..80c4b7bae5e6 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -28,7 +28,7 @@ since=(4, 1), expected_removal=(4, 3), ), - examples=[APIEx(parameters={"symbol": "SPX", "provider": "fmp"})], + examples=[APIEx(parameters={"symbol": "^IBEX", "provider": "fmp"})], ) async def market( cc: CommandContext, diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py index 4f9a29a296ec..1a964f363b9b 100644 --- a/openbb_platform/extensions/news/openbb_news/news_router.py +++ b/openbb_platform/extensions/news/openbb_news/news_router.py @@ -59,8 +59,8 @@ async def world( @router.command( model="CompanyNews", examples=[ - APIEx(parameters={"provider": "fmp"}), - APIEx(parameters={"limit": 100, "provider": "fmp"}), + APIEx(parameters={"provider": "benzinga"}), + APIEx(parameters={"limit": 100, "provider": "benzinga"}), APIEx( description="Get news on the specified dates.", parameters={ diff --git a/openbb_platform/openbb/package/crypto_price.py b/openbb_platform/openbb/package/crypto_price.py index 3b1dcf0e47a7..41e77e7608de 100644 --- a/openbb_platform/openbb/package/crypto_price.py +++ b/openbb_platform/openbb/package/crypto_price.py @@ -115,7 +115,7 @@ def historical( >>> obb.crypto.price.historical(symbol='BTCUSD', start_date='2024-01-01', end_date='2024-01-31', provider='fmp') >>> obb.crypto.price.historical(symbol='BTCUSD,ETHUSD', start_date='2024-01-01', end_date='2024-01-31', provider='polygon') >>> # Get monthly historical prices from Yahoo Finance for Ethereum. - >>> obb.crypto.price.historical(symbol='ETH-USD', interval='1mo', start_date='2024-01-01', end_date='2024-12-31', provider='yfinance') + >>> obb.crypto.price.historical(symbol='ETH-USD', interval='1m', start_date='2024-01-01', end_date='2024-12-31', provider='yfinance') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index cfaccbb402e7..2cae31d2e103 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -535,7 +535,7 @@ def balance_growth( -------- >>> from openbb import obb >>> obb.equity.fundamental.balance_growth(symbol='AAPL', provider='fmp') - >>> obb.equity.fundamental.balance_growth(symbol='AAPL', limit=10, provider='intrinio') + >>> obb.equity.fundamental.balance_growth(symbol='AAPL', limit=10, provider='fmp') """ # noqa: E501 return self._run( @@ -935,7 +935,7 @@ def cash_growth( -------- >>> from openbb import obb >>> obb.equity.fundamental.cash_growth(symbol='AAPL', provider='fmp') - >>> obb.equity.fundamental.cash_growth(symbol='AAPL', limit=10, provider='intrinio') + >>> obb.equity.fundamental.cash_growth(symbol='AAPL', limit=10, provider='fmp') """ # noqa: E501 return self._run( @@ -1261,7 +1261,7 @@ def filings( -------- >>> from openbb import obb >>> obb.equity.fundamental.filings(provider='fmp') - >>> obb.equity.fundamental.filings(limit=100, provider='intrinio') + >>> obb.equity.fundamental.filings(limit=100, provider='fmp') """ # noqa: E501 return self._run( @@ -2037,7 +2037,7 @@ def income_growth( -------- >>> from openbb import obb >>> obb.equity.fundamental.income_growth(symbol='AAPL', provider='fmp') - >>> obb.equity.fundamental.income_growth(symbol='AAPL', limit=10, period='annual', provider='intrinio') + >>> obb.equity.fundamental.income_growth(symbol='AAPL', limit=10, period='annual', provider='fmp') """ # noqa: E501 return self._run( diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index 6553ca5ef71f..c7ad79e09025 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -260,7 +260,7 @@ def market( Examples -------- >>> from openbb import obb - >>> obb.index.market(symbol='SPX', provider='fmp') + >>> obb.index.market(symbol='^IBEX', provider='fmp') """ # noqa: E501 simplefilter("always", DeprecationWarning) diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index 3af85fbe9f79..89df963cf2c6 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -159,8 +159,8 @@ def company( Examples -------- >>> from openbb import obb - >>> obb.news.company(provider='fmp') - >>> obb.news.company(limit=100, provider='fmp') + >>> obb.news.company(provider='benzinga') + >>> obb.news.company(limit=100, provider='benzinga') >>> # Get news on the specified dates. >>> obb.news.company(symbol='AAPL', start_date='2024-02-01', end_date='2024-02-07', provider='intrinio') >>> # Display the headlines of the news. From 6b55c7f935645bd576094758f59911df12dabeb3 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sat, 9 Mar 2024 00:02:07 +0000 Subject: [PATCH 126/133] noqa --- .../core/openbb_core/app/model/example.py | 7 +++---- .../econometrics_router.py | 20 +++++++++---------- .../performance/performance_router.py | 8 ++++---- .../quantitative_router.py | 8 ++++---- .../rolling/rolling_router.py | 12 +++++------ .../openbb_quantitative/stats/stats_router.py | 12 +++++------ .../technical/openbb_technical/helpers.py | 4 ++-- .../openbb_technical/technical_router.py | 6 +++--- .../extensions/tests/utils/helpers.py | 2 +- 9 files changed, 39 insertions(+), 40 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index e2d105f0db88..b6b72d35a39f 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -50,9 +50,9 @@ def validate_model(cls, values: dict) -> dict: if "provider" not in parameters and "data" not in parameters: raise ValueError("API example must specify a provider.") - if provider := parameters.get("provider"): - if not isinstance(provider, str): - raise ValueError("Provider must be a string.") + provider = parameters.get("provider") + if provider and not isinstance(provider, str): + raise ValueError("Provider must be a string.") return values @@ -132,7 +132,6 @@ def mock_data( obs = {} for k, v in sample.items(): if k == "date": - assert isinstance(v, str) obs[k] = ( datetime.strptime(v, "%Y-%m-%d") + timedelta(days=i) ).strftime("%Y-%m-%d") diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 47cbf7fa6495..48dbbe169eb2 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -36,7 +36,7 @@ PythonEx( description="Get the correlation matrix of a dataset.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 "obb.econometrics.correlation_matrix(data=stock_data)", ], ), @@ -84,7 +84,7 @@ def correlation_matrix(data: List[Data]) -> OBBject[List[Data]]: PythonEx( description="Perform Ordinary Least Squares (OLS) regression.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 'obb.econometrics.ols_regression(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], ), @@ -136,8 +136,8 @@ def ols_regression( PythonEx( description="Perform Ordinary Least Squares (OLS) regression and return the summary.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 + 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', # noqa: E501 ], ), APIEx( @@ -221,7 +221,7 @@ def ols_regression_summary( PythonEx( description="Perform Durbin-Watson test for autocorrelation.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 'obb.econometrics.autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', ], ), @@ -275,8 +275,8 @@ def autocorrelation( PythonEx( description="Perform Breusch-Godfrey Lagrange Multiplier tests for residual autocorrelation.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", - 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 + 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', # noqa: E501 ], ), APIEx( @@ -342,7 +342,7 @@ def residual_autocorrelation( PythonEx( description="Perform co-integration test between two timeseries.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 'obb.econometrics.cointegration(data=stock_data, columns=["open", "close"])', ], ), @@ -412,7 +412,7 @@ def cointegration( PythonEx( description="Perform Granger causality test to determine if X 'causes' y.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 'obb.econometrics.causality(data=stock_data, y_column="close", x_column="open")', ], ), @@ -483,7 +483,7 @@ def causality( PythonEx( description="Perform Augmented Dickey-Fuller (ADF) unit root test.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 'obb.econometrics.unit_root(data=stock_data, column="close")', 'obb.econometrics.unit_root(data=stock_data, column="close", regression="ct")', ], diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 46951a5e3393..2632cdfb1572 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -26,7 +26,7 @@ PythonEx( description="Get Omega Ratio.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.performance.omega_ratio(data=returns, target="close")', ], @@ -99,7 +99,7 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: PythonEx( description="Get Rolling Sharpe Ratio.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.performance.sharpe_ratio(data=returns, target="close")', ], @@ -168,10 +168,10 @@ def sharpe_ratio( PythonEx( description="Get Rolling Sortino Ratio.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.performance.sortino_ratio(data=stock_data, target="close")', - 'obb.quantitative.performance.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', + 'obb.quantitative.performance.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', # noqa: E501 ], ), APIEx( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py index 7963b39b66b8..0065ec62011b 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/quantitative_router.py @@ -42,7 +42,7 @@ PythonEx( description="Get Normality Statistics.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 "obb.quantitative.normality(data=stock_data, target='close')", ], ), @@ -98,7 +98,7 @@ def normality(data: List[Data], target: str) -> OBBject[NormalityModel]: PythonEx( description="Get Capital Asset Pricing Model (CAPM).", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 "obb.quantitative.capm(data=stock_data, target='close')", ], ), @@ -163,7 +163,7 @@ def capm(data: List[Data], target: str) -> OBBject[CAPMModel]: PythonEx( description="Get Unit Root Test.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 "obb.quantitative.unitroot_test(data=stock_data, target='close')", ], ), @@ -234,7 +234,7 @@ def unitroot_test( PythonEx( description="Get Summary Statistics.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 "obb.quantitative.summary(data=stock_data, target='close')", ], ), diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py index c5c7824ebbb0..fb02b5f051a7 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/rolling/rolling_router.py @@ -31,7 +31,7 @@ PythonEx( description="Get Rolling Mean.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.skew(data=returns, target="close")', ], @@ -95,7 +95,7 @@ def skew( PythonEx( description="Get Rolling Variance.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.variance(data=returns, target="close", window=252)', ], @@ -153,7 +153,7 @@ def variance( PythonEx( description="Get Rolling Standard Deviation.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.stdev(data=returns, target="close", window=252)', ], @@ -215,7 +215,7 @@ def stdev( PythonEx( description="Get Rolling Kurtosis.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.kurtosis(data=returns, target="close", window=252)', ], @@ -279,7 +279,7 @@ def kurtosis( PythonEx( description="Get Rolling Quantile.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.25)', 'obb.quantitative.rolling.quantile(data=returns, target="close", window=252, quantile_pct=0.75)', @@ -360,7 +360,7 @@ def quantile( PythonEx( description="Get Rolling Mean.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.rolling.mean(data=returns, target="close", window=252)', ], diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py index 4a59e544ff87..41e93a160208 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/stats/stats_router.py @@ -30,7 +30,7 @@ PythonEx( description="Get Skewness.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.skew(data=returns, target="close")', ], @@ -85,7 +85,7 @@ def skew( PythonEx( description="Get Variance.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.variance(data=returns, target="close")', ], @@ -134,7 +134,7 @@ def variance(data: List[Data], target: str) -> OBBject[List[Data]]: PythonEx( description="Get Standard Deviation.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.stdev(data=returns, target="close")', ], @@ -185,7 +185,7 @@ def stdev(data: List[Data], target: str) -> OBBject[List[Data]]: PythonEx( description="Get Kurtosis.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.kurtosis(data=returns, target="close")', ], @@ -237,7 +237,7 @@ def kurtosis(data: List[Data], target: str) -> OBBject[List[Data]]: PythonEx( description="Get Quantile.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.quantile(data=returns, target="close", quantile_pct=0.75)', ], @@ -296,7 +296,7 @@ def quantile( PythonEx( description="Get Mean.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.stats.mean(data=returns, target="close")', ], diff --git a/openbb_platform/extensions/technical/openbb_technical/helpers.py b/openbb_platform/extensions/technical/openbb_technical/helpers.py index ae1ad19ea6f4..c6a22f3fd170 100644 --- a/openbb_platform/extensions/technical/openbb_technical/helpers.py +++ b/openbb_platform/extensions/technical/openbb_technical/helpers.py @@ -13,8 +13,8 @@ def validate_data(data: list, length: Union[int, List[int]]) -> None: """Validate data.""" if isinstance(length, int): length = [length] - for l in length: - if l > len(data): + for item in length: + if item > len(data): raise ValueError( f"Data length is less than required by parameters: {max(length)}" ) diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index 4863d006429b..bc7677bd10b6 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -334,7 +334,7 @@ def adosc( description="Get the Chande Momentum Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", + "bbands_data = obb.technical.bbands(data=stock_data.results, target='close', length=50, std=2, mamode='sma')", # noqa: E501 ], ), APIEx(parameters={"length": 2, "data": APIEx.mock_data("timeseries")}), @@ -860,7 +860,7 @@ def hma( description="Get the Donchian Channels.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", + "donchian_data = obb.technical.donchian(data=stock_data.results, lower_length=20, upper_length=20, offset=0)", # noqa: E501 ], ), APIEx( @@ -1353,7 +1353,7 @@ def rsi( description="Get the Stochastic Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", + "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", # noqa: E501 ], ), ], diff --git a/openbb_platform/extensions/tests/utils/helpers.py b/openbb_platform/extensions/tests/utils/helpers.py index 65baa2a17b36..dc4b37b9d44f 100644 --- a/openbb_platform/extensions/tests/utils/helpers.py +++ b/openbb_platform/extensions/tests/utils/helpers.py @@ -42,7 +42,7 @@ def execute_docstring_examples(module_name: str, path: str) -> List[str]: for dt in doc_tests: code = "".join([ex.source for ex in dt.examples]) try: - exec(code) # pylint: disable=exec-used + exec(code) # pylint: disable=exec-used # noqa: S102 except Exception as e: errors.append( f"\n\n{'_'*136}\nPath: {path}\nCode:\n{code}\nError: {str(e)}" From f9cba1290420aba1e78b476a7da724fd34d04d40 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sat, 9 Mar 2024 00:12:57 +0000 Subject: [PATCH 127/133] pylint --- openbb_platform/core/openbb_core/app/model/example.py | 2 +- .../core/openbb_core/app/static/package_builder.py | 8 ++++++-- .../openbb_econometrics/econometrics_router.py | 4 ++-- .../openbb_quantitative/performance/performance_router.py | 2 +- .../technical/openbb_technical/technical_router.py | 2 +- .../finra/openbb_finra/models/equity_short_interest.py | 7 +++---- .../providers/sec/openbb_sec/models/symbol_map.py | 2 ++ 7 files changed, 16 insertions(+), 11 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/model/example.py b/openbb_platform/core/openbb_core/app/model/example.py index b6b72d35a39f..27f0e77084ac 100644 --- a/openbb_platform/core/openbb_core/app/model/example.py +++ b/openbb_platform/core/openbb_core/app/model/example.py @@ -139,7 +139,7 @@ def mock_data( obs[k] = round(v * s, 2) result.append(obs) return result - elif dataset == "panel": + if dataset == "panel": sample = sample or { "portfolio_value": 100000.0, "risk_free_rate": 0.02, diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 5f1135a27df3..d3b7ce10cc5b 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -1014,10 +1014,14 @@ def format_description(description: str) -> str: description = "Whether to create a chart or not, by default False." else: # pylint: disable=W0212 - p_type = param._annotation.__args__[0] + p_type = param._annotation.__args__[ + 0 + ] # pylint: disable=protected-access type_ = p_type.__name__ if inspect.isclass(p_type) else p_type description = getattr( - param._annotation.__metadata__[0], "description", "" + param._annotation.__metadata__[0], + "description", + "", # pylint: disable=protected-access ) type_str = format_type(type_, char_limit=79) # type: ignore diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 48dbbe169eb2..142d3cabf520 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -136,8 +136,8 @@ def ols_regression( PythonEx( description="Perform Ordinary Least Squares (OLS) regression and return the summary.", code=[ - "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 - 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', # noqa: E501 + "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 pylint: disable=line-too-long + 'obb.econometrics.ols_regression_summary(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', # noqa: E501 pylint: disable=line-too-long ], ), APIEx( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 2632cdfb1572..9313130bebd1 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -99,7 +99,7 @@ def get_omega_ratio(df_target: pd.Series, threshold: float) -> float: PythonEx( description="Get Rolling Sharpe Ratio.", code=[ - 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 + 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 # pylint: disable=line-too-long 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.performance.sharpe_ratio(data=returns, target="close")', ], diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py index bc7677bd10b6..53cd2a2e91e0 100644 --- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py +++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py @@ -1353,7 +1353,7 @@ def rsi( description="Get the Stochastic Oscillator.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')", - "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", # noqa: E501 + "stoch_data = obb.technical.stoch(data=stock_data.results, fast_k_period=14, slow_d_period=3, slow_k_period=3)", # noqa: E501 # pylint: disable=line-too-long ], ), ], diff --git a/openbb_platform/providers/finra/openbb_finra/models/equity_short_interest.py b/openbb_platform/providers/finra/openbb_finra/models/equity_short_interest.py index dc9507a3768e..f55dc4210ebc 100644 --- a/openbb_platform/providers/finra/openbb_finra/models/equity_short_interest.py +++ b/openbb_platform/providers/finra/openbb_finra/models/equity_short_interest.py @@ -10,6 +10,8 @@ ) from openbb_finra.utils.data_storage import DB_PATH, prepare_data +# pylint: disable=unused-argument + class FinraShortInterestQueryParams(ShortInterestQueryParams): """FINRA Equity Short Interest Query.""" @@ -73,10 +75,7 @@ def extract_data( "changePreviousNumber", "settlementDate", ] - return [ - {title: value for title, value in zip(titles, list(row)[1:])} - for row in result - ] + return [dict(zip(titles, list(row)[1:])) for row in result] @staticmethod def transform_data( diff --git a/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py b/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py index 2ba2e2858661..449d4202ee69 100644 --- a/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py +++ b/openbb_platform/providers/sec/openbb_sec/models/symbol_map.py @@ -9,6 +9,8 @@ from openbb_sec.utils.helpers import cik_map from pydantic import Field +# pylint: disable=unused-argument + class SecSymbolMapQueryParams(SymbolMapQueryParams): """SEC Symbol Mapping Query. From 7aaeaad3a385c5df5079b4daeef28be214d337c5 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sat, 9 Mar 2024 00:20:37 +0000 Subject: [PATCH 128/133] pylint --- .../core/openbb_core/app/static/package_builder.py | 8 +++----- .../openbb_econometrics/econometrics_router.py | 2 +- .../openbb_quantitative/performance/performance_router.py | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index d3b7ce10cc5b..a83c0b93ae7a 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -1013,15 +1013,13 @@ def format_description(description: str) -> str: type_ = "bool" description = "Whether to create a chart or not, by default False." else: - # pylint: disable=W0212 - p_type = param._annotation.__args__[ - 0 - ] # pylint: disable=protected-access + p_type = param._annotation.__args__[0] # pylint: disable=W0212 type_ = p_type.__name__ if inspect.isclass(p_type) else p_type description = getattr( + # pylint: disable=protected-access param._annotation.__metadata__[0], "description", - "", # pylint: disable=protected-access + "", ) type_str = format_type(type_, char_limit=79) # type: ignore diff --git a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py index 142d3cabf520..21e44275d870 100644 --- a/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py +++ b/openbb_platform/extensions/econometrics/openbb_econometrics/econometrics_router.py @@ -276,7 +276,7 @@ def autocorrelation( description="Perform Breusch-Godfrey Lagrange Multiplier tests for residual autocorrelation.", code=[ "stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp').to_df()", # noqa: E501 - 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', # noqa: E501 + 'obb.econometrics.residual_autocorrelation(data=stock_data, y_column="close", x_columns=["open", "high", "low"])', # noqa: E501 pylint: disable=line-too-long ], ), APIEx( diff --git a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py index 9313130bebd1..025df52bb20a 100644 --- a/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py +++ b/openbb_platform/extensions/quantitative/openbb_quantitative/performance/performance_router.py @@ -171,7 +171,7 @@ def sharpe_ratio( 'stock_data = obb.equity.price.historical(symbol="TSLA", start_date="2023-01-01", provider="fmp").to_df()', # noqa: E501 'returns = stock_data["close"].pct_change().dropna()', 'obb.quantitative.performance.sortino_ratio(data=stock_data, target="close")', - 'obb.quantitative.performance.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', # noqa: E501 + 'obb.quantitative.performance.sortino_ratio(data=stock_data, target="close", target_return=0.01, window=126, adjusted=True)', # noqa: E501 pylint: disable=line-too-long ], ), APIEx( From 5c71de34ca3abb9e1375dc79661ab643eea4ea7f Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sat, 9 Mar 2024 19:35:38 +0000 Subject: [PATCH 129/133] clean --- .../openbb_core/app/static/package_builder.py | 90 +++++---- .../tests/app/static/test_package_builder.py | 11 +- openbb_platform/openbb/package/crypto.py | 7 +- .../openbb/package/crypto_price.py | 7 +- openbb_platform/openbb/package/currency.py | 16 +- .../openbb/package/currency_price.py | 7 +- .../openbb/package/derivatives_options.py | 14 +- openbb_platform/openbb/package/economy.py | 79 ++++++-- openbb_platform/openbb/package/economy_gdp.py | 21 ++- openbb_platform/openbb/package/equity.py | 34 +++- .../openbb/package/equity_calendar.py | 28 ++- .../openbb/package/equity_compare.py | 7 +- .../openbb/package/equity_discovery.py | 56 +++++- .../openbb/package/equity_estimates.py | 28 ++- .../openbb/package/equity_fundamental.py | 175 +++++++++++++++--- .../openbb/package/equity_ownership.py | 35 +++- .../openbb/package/equity_price.py | 28 ++- .../openbb/package/equity_shorts.py | 7 +- openbb_platform/openbb/package/etf.py | 70 +++++-- openbb_platform/openbb/package/fixedincome.py | 7 +- .../openbb/package/fixedincome_corporate.py | 35 +++- .../openbb/package/fixedincome_government.py | 14 +- .../openbb/package/fixedincome_rate.py | 58 +++++- .../openbb/package/fixedincome_spreads.py | 21 ++- openbb_platform/openbb/package/index.py | 23 ++- openbb_platform/openbb/package/news.py | 16 +- .../openbb/package/regulators_sec.py | 44 ++++- 27 files changed, 779 insertions(+), 159 deletions(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index a83c0b93ae7a..b6e08c836969 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -556,9 +556,6 @@ def format_params( path: str, parameter_map: Dict[str, Parameter] ) -> OrderedDict[str, Parameter]: """Format the params.""" - DEFAULT_REPLACEMENT = { - "provider": None, - } parameter_map.pop("cc", None) # we need to add the chart parameter here bc of the docstring generation @@ -566,7 +563,12 @@ def format_params( parameter_map["chart"] = Parameter( name="chart", kind=Parameter.POSITIONAL_OR_KEYWORD, - annotation=bool, + annotation=Annotated[ + bool, + OpenBBCustomParameter( + description="Whether to create a chart or not, by default False." + ), + ], default=False, ) @@ -575,6 +577,28 @@ def format_params( for name, param in parameter_map.items(): if name == "extra_params": formatted[name] = Parameter(name="kwargs", kind=Parameter.VAR_KEYWORD) + elif name == "provider_choices": + fields = param.annotation.__args__[0].__dataclass_fields__ + field = fields["provider"] + type_ = getattr(field, "type") + args = getattr(type_, "__args__") + first = args[0] if args else None + formatted["provider"] = Parameter( + name="provider", + kind=Parameter.POSITIONAL_OR_KEYWORD, + annotation=Annotated[ + Union[MethodDefinition.get_type(field), None], + OpenBBCustomParameter( + description=( + "The provider to use for the query, by default None.\n" + f" If None, the provider specified in defaults is selected or '{first}' if there is\n" + " no default." + "" + ) + ), + ], + default=None, + ) elif MethodDefinition.is_annotated_dc(param.annotation): fields = param.annotation.__args__[0].__dataclass_fields__ for field_name, field in fields.items(): @@ -590,7 +614,7 @@ def format_params( name=field_name, kind=Parameter.POSITIONAL_OR_KEYWORD, annotation=updated_type, - default=DEFAULT_REPLACEMENT.get(field_name, default), + default=default, ) else: new_type = MethodDefinition.get_expanded_type(name) @@ -608,7 +632,7 @@ def format_params( name=name, kind=Parameter.POSITIONAL_OR_KEYWORD, annotation=updated_type, - default=DEFAULT_REPLACEMENT.get(name, param.default), + default=param.default, ) return MethodDefinition.reorder_params(params=formatted) @@ -995,6 +1019,21 @@ def format_description(description: str) -> str: description = description.replace("\n", f"\n{create_indent(2)}") return description + def get_param_info(parameter: Parameter) -> Tuple[str, str]: + """Get the parameter info.""" + annotation = getattr(parameter, "_annotation", None) + if isinstance(annotation, _AnnotatedAlias): + args = getattr(annotation, "__args__", []) if annotation else [] + p_type = args[0] if args else None + else: + p_type = annotation + type_ = ( + getattr(p_type, "__name__", "") if inspect.isclass(p_type) else p_type + ) + metadata = getattr(annotation, "__metadata__", []) + description = getattr(metadata[0], "description", "") if metadata else "" + return type_, description + docstring = summary.strip("\n").replace("\n ", f"\n{create_indent(2)}") docstring += "\n\n" docstring += f"{create_indent(2)}Parameters\n" @@ -1002,40 +1041,23 @@ def format_description(description: str) -> str: # Explicit parameters for param_name, param in explicit_params.items(): - if param_name == "provider": - # pylint: disable=W0212 - type_ = param._annotation - default = param._annotation.__args__[0].__args__[0] - description = f"""The provider to use for the query, by default None. - If None, the provider specified in defaults is selected or '{default}' if there is - no default.""" - elif param_name == "chart": - type_ = "bool" - description = "Whether to create a chart or not, by default False." - else: - p_type = param._annotation.__args__[0] # pylint: disable=W0212 - type_ = p_type.__name__ if inspect.isclass(p_type) else p_type - description = getattr( - # pylint: disable=protected-access - param._annotation.__metadata__[0], - "description", - "", - ) - - type_str = format_type(type_, char_limit=79) # type: ignore + type_, description = get_param_info(param) + type_str = format_type(str(type_), char_limit=79) docstring += f"{create_indent(2)}{param_name} : {type_str}\n" docstring += f"{create_indent(3)}{format_description(description)}\n" # Kwargs for param_name, param in kwarg_params.items(): - p_type = param.type - type_ = p_type.__name__ if inspect.isclass(p_type) else p_type + p_type = getattr(param, "type", "") + type_ = ( + getattr(p_type, "__name__", "") if inspect.isclass(p_type) else p_type + ) if "NoneType" in str(type_): type_ = f"Optional[{type_}]".replace(", NoneType", "") - description = getattr(param.default, "description", "") - + default = getattr(param, "default", "") + description = getattr(default, "description", "") docstring += f"{create_indent(2)}{param_name} : {type_}\n" docstring += f"{create_indent(3)}{format_description(description)}\n" @@ -1043,10 +1065,8 @@ def format_description(description: str) -> str: docstring += "\n" docstring += f"{create_indent(2)}Returns\n" docstring += f"{create_indent(2)}-------\n" - provider_param = explicit_params.get("provider", None) - available_providers = getattr(provider_param, "_annotation", None) - - docstring += cls.get_OBBject_description(results_type, available_providers) + providers, _ = get_param_info(explicit_params.get("provider", None)) + docstring += cls.get_OBBject_description(results_type, providers) # Schema underline = "-" * len(model_name) diff --git a/openbb_platform/core/tests/app/static/test_package_builder.py b/openbb_platform/core/tests/app/static/test_package_builder.py index 9057c932bcc8..eb1fe3a1d2e2 100644 --- a/openbb_platform/core/tests/app/static/test_package_builder.py +++ b/openbb_platform/core/tests/app/static/test_package_builder.py @@ -311,7 +311,7 @@ def some_func(): } output = method_definition.build_command_method_doc( - func=some_func, formatted_params=formatted_params + path="/menu/submenu/command", func=some_func, formatted_params=formatted_params ) assert output assert isinstance(output, str) @@ -499,7 +499,7 @@ def test_generate_model_docstring(docstring_generator): summary = "This is a summary." pi = docstring_generator.provider_interface - params = pi.params[model_name] + kwarg_params = pi.params[model_name]["extra"].__dataclass_fields__ return_schema = pi.return_schema[model_name] returns = return_schema.model_fields @@ -513,7 +513,7 @@ def test_generate_model_docstring(docstring_generator): model_name=model_name, summary=summary, explicit_params=explicit_dict, - params=params, + kwarg_params=kwarg_params, returns=returns, results_type="List[WorldNews]", ) @@ -537,7 +537,10 @@ def some_func(): } doc = docstring_generator.generate( - func=some_func, formatted_params=formatted_params, model_name="WorldNews" + path="/menu/submenu/command", + func=some_func, + formatted_params=formatted_params, + model_name="WorldNews", ) assert doc assert "Parameters" in doc diff --git a/openbb_platform/openbb/package/crypto.py b/openbb_platform/openbb/package/crypto.py index 534570221df4..7fe45375b17e 100644 --- a/openbb_platform/openbb/package/crypto.py +++ b/openbb_platform/openbb/package/crypto.py @@ -33,7 +33,12 @@ def search( query: Annotated[ Optional[str], OpenBBCustomParameter(description="Search query.") ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Search available cryptocurrency pairs within a provider. diff --git a/openbb_platform/openbb/package/crypto_price.py b/openbb_platform/openbb/package/crypto_price.py index 41e77e7608de..5d7e02ef8ef9 100644 --- a/openbb_platform/openbb/package/crypto_price.py +++ b/openbb_platform/openbb/package/crypto_price.py @@ -41,7 +41,12 @@ def historical( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "polygon", "tiingo", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "polygon", "tiingo", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical price data for cryptocurrency pair(s) within a provider. diff --git a/openbb_platform/openbb/package/currency.py b/openbb_platform/openbb/package/currency.py index 69b830d74959..aae2308b9a29 100644 --- a/openbb_platform/openbb/package/currency.py +++ b/openbb_platform/openbb/package/currency.py @@ -30,7 +30,14 @@ def price(self): @exception_handler @validate def search( - self, provider: Optional[Literal["fmp", "intrinio", "polygon"]] = None, **kwargs + self, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "polygon"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, + **kwargs ) -> OBBject: """Currency Search. @@ -162,7 +169,12 @@ def snapshots( description="An optional list of counter currency symbols to filter for. None returns all." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Snapshots of currency exchange rates from an indirect or direct perspective of a base currency. diff --git a/openbb_platform/openbb/package/currency_price.py b/openbb_platform/openbb/package/currency_price.py index 9613b8fd973b..aa39e03e0911 100644 --- a/openbb_platform/openbb/package/currency_price.py +++ b/openbb_platform/openbb/package/currency_price.py @@ -41,7 +41,12 @@ def historical( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "polygon", "tiingo", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "polygon", "tiingo", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Currency Historical Price. Currency historical data. diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py index 79d144242a52..c1e156d9a3de 100644 --- a/openbb_platform/openbb/package/derivatives_options.py +++ b/openbb_platform/openbb/package/derivatives_options.py @@ -26,7 +26,12 @@ def chains( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["intrinio"]] = None, + provider: Annotated[ + Optional[Literal["intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'intrinio' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the complete options chain for a ticker. @@ -182,7 +187,12 @@ def unusual( description="Symbol to get data for. (the underlying symbol)" ), ] = None, - provider: Optional[Literal["intrinio"]] = None, + provider: Annotated[ + Optional[Literal["intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'intrinio' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the complete options chain for a ticker. diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index afb7cf629396..3aa90603745e 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -49,7 +49,12 @@ def calendar( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "tradingeconomics"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "tradingeconomics"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the upcoming, or historical, economic calendar of global events. @@ -166,7 +171,12 @@ def composite_leading_indicator( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["oecd"]] = None, + provider: Annotated[ + Optional[Literal["oecd"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'oecd' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """The composite leading indicator (CLI) is designed to provide early signals of turning points @@ -328,7 +338,12 @@ def cpi( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Consumer Price Index (CPI). Returns either the rescaled index value, or a rate of change (inflation). @@ -435,7 +450,12 @@ def fred_regional( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100000, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Query the Geo Fred API for regional economic data by series group. @@ -570,7 +590,12 @@ def fred_search( query: Annotated[ Optional[str], OpenBBCustomParameter(description="The search word(s).") ] = None, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Search for FRED series or economic releases by ID or string. @@ -711,7 +736,12 @@ def fred_series( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100000, - provider: Optional[Literal["fred", "intrinio"]] = None, + provider: Annotated[ + Optional[Literal["fred", "intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get data by series ID from FRED. @@ -850,7 +880,12 @@ def long_term_interest_rate( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["oecd"]] = None, + provider: Annotated[ + Optional[Literal["oecd"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'oecd' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Long-term interest rates refer to government bonds maturing in ten years. @@ -948,7 +983,12 @@ def money_measures( description="Whether to return seasonally adjusted data." ), ] = True, - provider: Optional[Literal["federal_reserve"]] = None, + provider: Annotated[ + Optional[Literal["federal_reserve"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'federal_reserve' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Money Measures (M1/M2 and components). The Federal Reserve publishes as part of the H.6 Release. @@ -1028,7 +1068,14 @@ def money_measures( @exception_handler @validate def risk_premium( - self, provider: Optional[Literal["fmp"]] = None, **kwargs + self, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, + **kwargs ) -> OBBject: """Market Risk Premium by country. @@ -1101,7 +1148,12 @@ def short_term_interest_rate( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["oecd"]] = None, + provider: Annotated[ + Optional[Literal["oecd"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'oecd' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Short-term interest rates are the rates at which short-term borrowings are effected between @@ -1190,7 +1242,12 @@ def unemployment( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["oecd"]] = None, + provider: Annotated[ + Optional[Literal["oecd"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'oecd' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Global unemployment data. diff --git a/openbb_platform/openbb/package/economy_gdp.py b/openbb_platform/openbb/package/economy_gdp.py index 004a859f48c7..d4a4bb05a85f 100644 --- a/openbb_platform/openbb/package/economy_gdp.py +++ b/openbb_platform/openbb/package/economy_gdp.py @@ -49,7 +49,12 @@ def forecast( description="Type of GDP to get forecast of. Either nominal or real." ), ] = "real", - provider: Optional[Literal["oecd"]] = None, + provider: Annotated[ + Optional[Literal["oecd"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'oecd' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Forecasted GDP Data. @@ -141,7 +146,12 @@ def nominal( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["oecd"]] = None, + provider: Annotated[ + Optional[Literal["oecd"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'oecd' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Nominal GDP Data. @@ -230,7 +240,12 @@ def real( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["oecd"]] = None, + provider: Annotated[ + Optional[Literal["oecd"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'oecd' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Real GDP Data. diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py index fb01d3b6831d..f36be502f66c 100644 --- a/openbb_platform/openbb/package/equity.py +++ b/openbb_platform/openbb/package/equity.py @@ -75,7 +75,14 @@ def fundamental(self): @exception_handler @validate def market_snapshots( - self, provider: Optional[Literal["fmp", "polygon"]] = None, **kwargs + self, + provider: Annotated[ + Optional[Literal["fmp", "polygon"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, + **kwargs ) -> OBBject: """Get an updated equity market snapshot. This includes price data for thousands of stocks. @@ -232,7 +239,12 @@ def profile( description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio, yfinance." ), ], - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get general information about a company. This includes company name, industry, sector and price data. @@ -414,7 +426,16 @@ def profile( @exception_handler @validate - def screener(self, provider: Optional[Literal["fmp"]] = None, **kwargs) -> OBBject: + def screener( + self, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, + **kwargs + ) -> OBBject: """Screen for companies meeting various criteria. These criteria include market cap, price, beta, volume, and dividend yield. @@ -538,7 +559,12 @@ def search( Optional[bool], OpenBBCustomParameter(description="Whether to use the cache or not."), ] = True, - provider: Optional[Literal["intrinio", "sec"]] = None, + provider: Annotated[ + Optional[Literal["intrinio", "sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'intrinio' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Search for stock symbol, CIK, LEI, or company name. diff --git a/openbb_platform/openbb/package/equity_calendar.py b/openbb_platform/openbb/package/equity_calendar.py index 0b7a6e222fed..ccd675cb892a 100644 --- a/openbb_platform/openbb/package/equity_calendar.py +++ b/openbb_platform/openbb/package/equity_calendar.py @@ -38,7 +38,12 @@ def dividend( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical and upcoming dividend payments. Includes dividend amount, ex-dividend and payment dates. @@ -129,7 +134,12 @@ def earnings( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical and upcoming company earnings releases. Includes earnings per share (EPS) and revenue data. @@ -233,7 +243,12 @@ def ipo( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["intrinio"]] = None, + provider: Annotated[ + Optional[Literal["intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'intrinio' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical and upcoming initial public offerings (IPOs). @@ -399,7 +414,12 @@ def splits( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical and upcoming stock split operations. diff --git a/openbb_platform/openbb/package/equity_compare.py b/openbb_platform/openbb/package/equity_compare.py index 857e3762c98f..704c2328a1e8 100644 --- a/openbb_platform/openbb/package/equity_compare.py +++ b/openbb_platform/openbb/package/equity_compare.py @@ -25,7 +25,12 @@ def peers( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the closest peers for a given company. diff --git a/openbb_platform/openbb/package/equity_discovery.py b/openbb_platform/openbb/package/equity_discovery.py index b3429c2d6f92..12df47ef9034 100644 --- a/openbb_platform/openbb/package/equity_discovery.py +++ b/openbb_platform/openbb/package/equity_discovery.py @@ -36,7 +36,12 @@ def active( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["yfinance"]] = None, + provider: Annotated[ + Optional[Literal["yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'yfinance' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the most actively traded stocks based on volume. @@ -119,7 +124,12 @@ def aggressive_small_caps( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["yfinance"]] = None, + provider: Annotated[ + Optional[Literal["yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'yfinance' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get top small cap stocks based on earnings growth. @@ -218,7 +228,12 @@ def filings( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the URLs to SEC filings reported to EDGAR database, such as 10-K, 10-Q, 8-K, and more. SEC @@ -312,7 +327,12 @@ def gainers( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["yfinance"]] = None, + provider: Annotated[ + Optional[Literal["yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'yfinance' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the top price gainers in the stock market. @@ -395,7 +415,12 @@ def growth_tech( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["yfinance"]] = None, + provider: Annotated[ + Optional[Literal["yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'yfinance' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get top tech stocks based on revenue and earnings growth. @@ -478,7 +503,12 @@ def losers( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["yfinance"]] = None, + provider: Annotated[ + Optional[Literal["yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'yfinance' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the top price losers in the stock market. @@ -561,7 +591,12 @@ def undervalued_growth( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["yfinance"]] = None, + provider: Annotated[ + Optional[Literal["yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'yfinance' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get potentially undervalued growth stocks. @@ -644,7 +679,12 @@ def undervalued_large_caps( description="Sort order. Possible values: 'asc', 'desc'. Default: 'desc'." ), ] = "desc", - provider: Optional[Literal["yfinance"]] = None, + provider: Annotated[ + Optional[Literal["yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'yfinance' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get potentially undervalued large cap stocks. diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py index 62eeb6e7b4da..4016105cc9d6 100644 --- a/openbb_platform/openbb/package/equity_estimates.py +++ b/openbb_platform/openbb/package/equity_estimates.py @@ -37,7 +37,12 @@ def analyst_search( description="A comma separated list of firm names to bring back. Omitting will bring back all available firms." ), ] = None, - provider: Optional[Literal["benzinga"]] = None, + provider: Annotated[ + Optional[Literal["benzinga"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'benzinga' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Search for specific analysts and get their forecast track record. @@ -203,7 +208,12 @@ def consensus( description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." ), ], - provider: Optional[Literal["fmp", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get consensus price target and recommendation. @@ -294,7 +304,12 @@ def historical( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 30, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical analyst estimates for earnings and revenue. @@ -412,7 +427,12 @@ def price_target( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 200, - provider: Optional[Literal["benzinga", "fmp"]] = None, + provider: Annotated[ + Optional[Literal["benzinga", "fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'benzinga' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get analyst price targets by company. diff --git a/openbb_platform/openbb/package/equity_fundamental.py b/openbb_platform/openbb/package/equity_fundamental.py index 2cae31d2e103..c0c6f810ecb5 100644 --- a/openbb_platform/openbb/package/equity_fundamental.py +++ b/openbb_platform/openbb/package/equity_fundamental.py @@ -60,7 +60,12 @@ def balance( Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return."), ] = 5, - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the balance sheet for a given company. @@ -414,7 +419,12 @@ def balance_growth( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 10, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the growth of a company's balance sheet items over time. @@ -570,7 +580,12 @@ def cash( Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return."), ] = 5, - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the cash flow statement for a given company. @@ -832,7 +847,12 @@ def cash_growth( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 10, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the growth of a company's cash flow statement items over time. @@ -975,7 +995,12 @@ def dividends( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical dividend data for a given company. @@ -1064,7 +1089,12 @@ def employee_count( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical employee count data for a given company. @@ -1153,7 +1183,12 @@ def filings( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["fmp", "intrinio", "sec"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the URLs to SEC filings reported to EDGAR database, such as 10-K, 10-Q, 8-K, and more. SEC @@ -1327,7 +1362,12 @@ def historical_attributes( Optional[Literal["asc", "desc"]], OpenBBCustomParameter(description="Sort order."), ] = "desc", - provider: Optional[Literal["intrinio"]] = None, + provider: Annotated[ + Optional[Literal["intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'intrinio' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the historical values of a data tag from Intrinio. @@ -1421,7 +1461,12 @@ def historical_eps( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical earnings per share data for a given company. @@ -1504,7 +1549,12 @@ def historical_splits( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get historical stock splits for a given company. @@ -1580,7 +1630,12 @@ def income( Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return."), ] = 5, - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the income statement for a given company. @@ -1940,7 +1995,12 @@ def income_growth( Literal["quarter", "annual"], OpenBBCustomParameter(description="Time period of the data to return."), ] = "annual", - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the growth of a company's income statement items over time. @@ -2075,7 +2135,12 @@ def latest_attributes( description="Intrinio data tag ID or code. Multiple items allowed for provider(s): intrinio." ), ], - provider: Optional[Literal["intrinio"]] = None, + provider: Annotated[ + Optional[Literal["intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'intrinio' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the latest value of a data tag from Intrinio. @@ -2149,7 +2214,12 @@ def management( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get executive management team data for a given company. @@ -2243,7 +2313,12 @@ def management_compensation( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get executive management team compensation for a given company over time. @@ -2348,7 +2423,12 @@ def metrics( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 100, - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get fundamental metrics for a given company. @@ -2607,7 +2687,12 @@ def multiples( description="Symbol to get data for. Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get equity valuation multiples for a given company. @@ -2795,7 +2880,12 @@ def overview( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get company general business and stock data for a given company. @@ -2942,7 +3032,12 @@ def ratios( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 12, - provider: Optional[Literal["fmp", "intrinio"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get an extensive set of financial and accounting ratios for a given company over time. @@ -3145,7 +3240,12 @@ def reported_financials( description="The number of data entries to return. Although the response object contains multiple results, because of the variance in the fields, year-to-year and quarter-to-quarter, it is recommended to view results in small chunks." ), ] = 100, - provider: Optional[Literal["intrinio"]] = None, + provider: Annotated[ + Optional[Literal["intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'intrinio' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get financial statements as reported by the company. @@ -3237,7 +3337,12 @@ def revenue_per_geography( Literal["hierarchical", "flat"], OpenBBCustomParameter(description="Structure of the returned data."), ] = "flat", - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the revenue geographic breakdown for a given company over time. @@ -3323,7 +3428,12 @@ def revenue_per_segment( Literal["hierarchical", "flat"], OpenBBCustomParameter(description="Structure of the returned data."), ] = "flat", - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the revenue breakdown by business segment for a given company over time. @@ -3405,7 +3515,12 @@ def search_attributes( Optional[int], OpenBBCustomParameter(description="The number of data entries to return."), ] = 1000, - provider: Optional[Literal["intrinio"]] = None, + provider: Annotated[ + Optional[Literal["intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'intrinio' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Search Intrinio data tags to search in latest or historical attributes. @@ -3497,7 +3612,12 @@ def trailing_dividend_yield( description="The number of data entries to return. Default is 252, the number of trading days in a year." ), ] = 252, - provider: Optional[Literal["tiingo"]] = None, + provider: Annotated[ + Optional[Literal["tiingo"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'tiingo' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the 1 year trailing dividend yield for a given company over time. @@ -3570,7 +3690,12 @@ def transcript( int, OpenBBCustomParameter(description="Year of the earnings call transcript."), ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get earnings call transcripts for a given company. diff --git a/openbb_platform/openbb/package/equity_ownership.py b/openbb_platform/openbb/package/equity_ownership.py index a851bac29047..7942b4a1db99 100644 --- a/openbb_platform/openbb/package/equity_ownership.py +++ b/openbb_platform/openbb/package/equity_ownership.py @@ -45,7 +45,12 @@ def form_13f( description="The number of data entries to return. The number of previous filings to return. The date parameter takes priority over this parameter." ), ] = 1, - provider: Optional[Literal["sec"]] = None, + provider: Annotated[ + Optional[Literal["sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'sec' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """The Securities and Exchange Commission's (SEC) Form 13F is a quarterly report @@ -152,7 +157,12 @@ def insider_trading( int, OpenBBCustomParameter(description="The number of data entries to return."), ] = 500, - provider: Optional[Literal["fmp", "intrinio"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get data about trading by a company's management team and board of directors. @@ -285,7 +295,12 @@ def institutional( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get data about institutional ownership for a given company over time. @@ -430,7 +445,12 @@ def major_holders( Optional[int], OpenBBCustomParameter(description="Page number of the data to fetch."), ] = 0, - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get data about major holders for a given company over time. @@ -579,7 +599,12 @@ def share_statistics( description="Symbol to get data for. Multiple items allowed for provider(s): yfinance." ), ], - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get data about share float for a given company. diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py index 3937fce75bf2..5e83ca0c9cdf 100644 --- a/openbb_platform/openbb/package/equity_price.py +++ b/openbb_platform/openbb/package/equity_price.py @@ -48,8 +48,11 @@ def historical( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[ - Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"] + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), ] = None, **kwargs ) -> OBBject: @@ -205,7 +208,12 @@ def nbbo( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["polygon"]] = None, + provider: Annotated[ + Optional[Literal["polygon"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'polygon' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the National Best Bid and Offer for a given stock. @@ -338,7 +346,12 @@ def performance( description="Symbol to get data for. Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get price performance data for a given stock. This includes price changes for different time periods. @@ -433,7 +446,12 @@ def quote( description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed for provider(s): fmp, intrinio, yfinance." ), ], - provider: Optional[Literal["fmp", "intrinio", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the latest quote for a given stock. Quote includes price, volume, and other data. diff --git a/openbb_platform/openbb/package/equity_shorts.py b/openbb_platform/openbb/package/equity_shorts.py index f30b6752d058..115690a4fab0 100644 --- a/openbb_platform/openbb/package/equity_shorts.py +++ b/openbb_platform/openbb/package/equity_shorts.py @@ -25,7 +25,12 @@ def fails_to_deliver( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["sec"]] = None, + provider: Annotated[ + Optional[Literal["sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'sec' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get reported Fail-to-deliver (FTD) data. diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py index 786a145a1d4a..b34a947e0922 100644 --- a/openbb_platform/openbb/package/etf.py +++ b/openbb_platform/openbb/package/etf.py @@ -38,7 +38,12 @@ def countries( description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """ETF Country weighting. @@ -105,7 +110,12 @@ def equity_exposure( description="Symbol to get data for. (Stock) Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the exposure to ETFs for a specific stock. @@ -198,8 +208,11 @@ def historical( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[ - Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"] + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "polygon", "tiingo", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), ] = None, **kwargs ) -> OBBject: @@ -357,7 +370,12 @@ def holdings( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") ], - provider: Optional[Literal["fmp", "sec"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the holdings for an individual ETF. @@ -590,7 +608,12 @@ def holdings_date( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Use this function to get the holdings dates, if available. @@ -658,7 +681,12 @@ def holdings_performance( description="Symbol to get data for. Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Get the recent price performance of each ticker held in the ETF. @@ -753,7 +781,12 @@ def info( description="Symbol to get data for. (ETF) Multiple items allowed for provider(s): fmp, yfinance." ), ], - provider: Optional[Literal["fmp", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """ETF Information Overview. @@ -914,7 +947,12 @@ def price_performance( description="Symbol to get data for. Multiple items allowed for provider(s): fmp." ), ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Price performance as a return, over different periods. This is a proxy for `equity.price.performance`. @@ -1007,7 +1045,12 @@ def search( query: Annotated[ Optional[str], OpenBBCustomParameter(description="Search query.") ] = "", - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Search for ETFs. @@ -1104,7 +1147,12 @@ def sectors( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for. (ETF)") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """ETF Sector weighting. diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index ec2db50e14cb..30bfb1f52c83 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -66,7 +66,12 @@ def sofr( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Secured Overnight Financing Rate. diff --git a/openbb_platform/openbb/package/fixedincome_corporate.py b/openbb_platform/openbb/package/fixedincome_corporate.py index 14c7693df1fb..bd6d09f57271 100644 --- a/openbb_platform/openbb/package/fixedincome_corporate.py +++ b/openbb_platform/openbb/package/fixedincome_corporate.py @@ -53,7 +53,12 @@ def commercial_paper( grade: Annotated[ Literal["aa", "a2_p2"], OpenBBCustomParameter(description="The grade.") ] = "aa", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Commercial Paper. @@ -142,7 +147,12 @@ def hqm( Literal["spot", "par"], OpenBBCustomParameter(description="The yield curve type."), ] = "spot", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """High Quality Market Corporate Bond. @@ -236,7 +246,12 @@ def ice_bofa( Literal["yield", "yield_to_worst", "total_return", "spread"], OpenBBCustomParameter(description="The type of series."), ] = "yield", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """ICE BofA US Corporate Bond Indices. @@ -336,7 +351,12 @@ def moody( Literal["aaa", "baa"], OpenBBCustomParameter(description="The type of series."), ] = "aaa", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Moody Corporate Bond Index. @@ -438,7 +458,12 @@ def spot_rates( ), OpenBBCustomChoices(choices=["par_yield", "spot_rate"]), ] = "spot_rate", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Spot Rates. diff --git a/openbb_platform/openbb/package/fixedincome_government.py b/openbb_platform/openbb/package/fixedincome_government.py index be57bc8aa9f4..5b0f6169e6cf 100644 --- a/openbb_platform/openbb/package/fixedincome_government.py +++ b/openbb_platform/openbb/package/fixedincome_government.py @@ -36,7 +36,12 @@ def treasury_rates( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["federal_reserve", "fmp"]] = None, + provider: Annotated[ + Optional[Literal["federal_reserve", "fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'federal_reserve' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Government Treasury Rates. @@ -135,7 +140,12 @@ def us_yield_curve( Optional[bool], OpenBBCustomParameter(description="Get inflation adjusted rates."), ] = False, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """US Yield Curve. Get United States yield curve. diff --git a/openbb_platform/openbb/package/fixedincome_rate.py b/openbb_platform/openbb/package/fixedincome_rate.py index 8ae6d60b7699..17cb78b99e6e 100644 --- a/openbb_platform/openbb/package/fixedincome_rate.py +++ b/openbb_platform/openbb/package/fixedincome_rate.py @@ -42,7 +42,12 @@ def ameribor( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Ameribor. @@ -127,7 +132,12 @@ def dpcredit( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Discount Window Primary Credit Rate. @@ -217,7 +227,12 @@ def ecb( Literal["deposit", "lending", "refinancing"], OpenBBCustomParameter(description="The type of interest rate."), ] = "lending", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """European Central Bank Interest Rates. @@ -306,7 +321,12 @@ def effr( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["federal_reserve", "fred"]] = None, + provider: Annotated[ + Optional[Literal["federal_reserve", "fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'federal_reserve' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Fed Funds Rate. @@ -378,7 +398,14 @@ def effr( @exception_handler @validate def effr_forecast( - self, provider: Optional[Literal["fred"]] = None, **kwargs + self, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, + **kwargs ) -> OBBject: """Fed Funds Rate Projections. @@ -468,7 +495,12 @@ def estr( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Euro Short-Term Rate. @@ -554,7 +586,12 @@ def iorb( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Interest on Reserve Balances. @@ -636,7 +673,12 @@ def sonia( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Sterling Overnight Index Average. diff --git a/openbb_platform/openbb/package/fixedincome_spreads.py b/openbb_platform/openbb/package/fixedincome_spreads.py index 5555fb8acf54..b70c58e9676f 100644 --- a/openbb_platform/openbb/package/fixedincome_spreads.py +++ b/openbb_platform/openbb/package/fixedincome_spreads.py @@ -41,7 +41,12 @@ def tcm( Optional[Literal["3m", "2y"]], OpenBBCustomParameter(description="The maturity"), ] = "3m", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Treasury Constant Maturity. @@ -132,7 +137,12 @@ def tcm_effr( Optional[Literal["10y", "5y", "1y", "6m", "3m"]], OpenBBCustomParameter(description="The maturity"), ] = "10y", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Select Treasury Constant Maturity. @@ -223,7 +233,12 @@ def treasury_effr( Optional[Literal["3m", "6m"]], OpenBBCustomParameter(description="The maturity"), ] = "3m", - provider: Optional[Literal["fred"]] = None, + provider: Annotated[ + Optional[Literal["fred"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fred' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Select Treasury Bill. diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py index c7ad79e09025..0d945611d798 100644 --- a/openbb_platform/openbb/package/index.py +++ b/openbb_platform/openbb/package/index.py @@ -27,7 +27,14 @@ def __repr__(self) -> str: @exception_handler @validate def available( - self, provider: Optional[Literal["fmp", "yfinance"]] = None, **kwargs + self, + provider: Annotated[ + Optional[Literal["fmp", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, + **kwargs ) -> OBBject: """All indices available from a given provider. @@ -96,7 +103,12 @@ def constituents( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["fmp"]] = None, + provider: Annotated[ + Optional[Literal["fmp"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Index Constituents. @@ -196,7 +208,12 @@ def market( Optional[str], OpenBBCustomParameter(description="Time interval of the data to return."), ] = "1d", - provider: Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]] = None, + provider: Annotated[ + Optional[Literal["fmp", "intrinio", "polygon", "yfinance"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Historical Market Indices. diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py index 89df963cf2c6..52601f5905fd 100644 --- a/openbb_platform/openbb/package/news.py +++ b/openbb_platform/openbb/package/news.py @@ -47,8 +47,13 @@ def company( Optional[Annotated[int, Ge(ge=0)]], OpenBBCustomParameter(description="The number of data entries to return."), ] = 2500, - provider: Optional[ - Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"] + provider: Annotated[ + Optional[ + Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"] + ], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'benzinga' if there is\n no default." + ), ] = None, **kwargs ) -> OBBject: @@ -232,7 +237,12 @@ def world( description="End date of the data, in YYYY-MM-DD format." ), ] = None, - provider: Optional[Literal["benzinga", "fmp", "intrinio", "tiingo"]] = None, + provider: Annotated[ + Optional[Literal["benzinga", "fmp", "intrinio", "tiingo"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'benzinga' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """World News. Global news data. diff --git a/openbb_platform/openbb/package/regulators_sec.py b/openbb_platform/openbb/package/regulators_sec.py index c64d5a62af68..4b0ebcf377c1 100644 --- a/openbb_platform/openbb/package/regulators_sec.py +++ b/openbb_platform/openbb/package/regulators_sec.py @@ -30,7 +30,12 @@ def cik_map( symbol: Annotated[ str, OpenBBCustomParameter(description="Symbol to get data for.") ], - provider: Optional[Literal["sec"]] = None, + provider: Annotated[ + Optional[Literal["sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'sec' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Map a ticker symbol to a CIK number. @@ -97,7 +102,12 @@ def institutions_search( description="Whether or not to use cache. If True, cache will store for seven days." ), ] = True, - provider: Optional[Literal["sec"]] = None, + provider: Annotated[ + Optional[Literal["sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'sec' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Search SEC-regulated institutions by name and return a list of results with CIK numbers. @@ -162,7 +172,14 @@ def institutions_search( @exception_handler @validate def rss_litigation( - self, provider: Optional[Literal["sec"]] = None, **kwargs + self, + provider: Annotated[ + Optional[Literal["sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'sec' if there is\n no default." + ), + ] = None, + **kwargs ) -> OBBject: """The RSS feed provides links to litigation releases concerning civil lawsuits brought by the Commission in federal court. @@ -232,7 +249,12 @@ def schema_files( description="Whether or not to use cache. If True, cache will store for seven days." ), ] = True, - provider: Optional[Literal["sec"]] = None, + provider: Annotated[ + Optional[Literal["sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'sec' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """A tool for navigating the directory of SEC XML schema files by year. @@ -322,7 +344,12 @@ def sic_search( description="Whether or not to use cache. If True, cache will store for seven days." ), ] = True, - provider: Optional[Literal["sec"]] = None, + provider: Annotated[ + Optional[Literal["sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'sec' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Search for Industry Titles, Reporting Office, and SIC Codes. An empty query string returns all results. @@ -397,7 +424,12 @@ def symbol_map( description="Whether or not to use cache. If True, cache will store for seven days." ), ] = True, - provider: Optional[Literal["sec"]] = None, + provider: Annotated[ + Optional[Literal["sec"]], + OpenBBCustomParameter( + description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'sec' if there is\n no default." + ), + ] = None, **kwargs ) -> OBBject: """Map a CIK number to a ticker symbol, leading 0s can be omitted or included. From 9504ed7fb6bc306c2f22adc5f9fa3143efea17a7 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sat, 9 Mar 2024 19:42:35 +0000 Subject: [PATCH 130/133] minor fix --- .../extensions/economy/openbb_economy/economy_router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 137efc0724ac..9cf8fdfcfd8d 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -172,7 +172,7 @@ async def money_measures( parameters={"country": "all", "frequency": "quarterly", "provider": "oecd"} ), APIEx( - description="Demographics for the statistics are selected with the `age` and `sex` parameters.", + description="Demographics for the statistics are selected with the `age` parameter.", parameters={ "country": "all", "frequency": "quarterly", From 94e64543588d5557324ce45c1e39c1091c7c0850 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sat, 9 Mar 2024 22:46:31 +0000 Subject: [PATCH 131/133] fix test --- .../extensions/tests/utils/helpers.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/openbb_platform/extensions/tests/utils/helpers.py b/openbb_platform/extensions/tests/utils/helpers.py index dc4b37b9d44f..1f0531ea133e 100644 --- a/openbb_platform/extensions/tests/utils/helpers.py +++ b/openbb_platform/extensions/tests/utils/helpers.py @@ -243,25 +243,18 @@ def parse_example_string(example_string: str) -> Dict[str, Any]: # Initialize the result dictionary result = {} - # Regular expression patterns to find PythonEx and APIEx examples, including optional descriptions - pythonex_pattern = r"PythonEx\(code=\[(.*?)\](?:, description=['\"](.*?)['\"])?\)" - apiex_pattern = r"APIEx\(parameters=(\{.*?\})(?:, description=['\"](.*?)['\"])?\)" + # Regular expression patterns to find PythonEx and APIEx examples + pythonex_pattern = r"PythonEx\(.*?code=(\[.*?\]).*?\)" + apiex_pattern = r"APIEx\(.*?parameters=(\{.*?\}).*?\)" # Function to parse individual examples def parse_examples(matches, example_type): examples = [] for match in matches: if example_type == "PythonEx": - code, description = match - # Treat code as a raw string without evaluating it - example = {"code": [code]} + example = {"code": [match]} else: # APIEx - parameters, description = match - # Directly use parameters without evaluating - example = {"params": parameters} - - if description: - example["description"] = description + example = {"params": match} examples.append(example) return examples @@ -275,7 +268,6 @@ def parse_examples(matches, example_type): return result - def get_required_fields(model: str) -> List[str]: """Get the required fields of a model.""" fields = pi.map[model]["openbb"]["QueryParams"]["fields"] From 840d3fad68a665a254a8b94701a7016bee59cf39 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sat, 9 Mar 2024 22:47:02 +0000 Subject: [PATCH 132/133] lint --- openbb_platform/extensions/tests/utils/helpers.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openbb_platform/extensions/tests/utils/helpers.py b/openbb_platform/extensions/tests/utils/helpers.py index 1f0531ea133e..50e9b72796de 100644 --- a/openbb_platform/extensions/tests/utils/helpers.py +++ b/openbb_platform/extensions/tests/utils/helpers.py @@ -268,6 +268,7 @@ def parse_examples(matches, example_type): return result + def get_required_fields(model: str) -> List[str]: """Get the required fields of a model.""" fields = pi.map[model]["openbb"]["QueryParams"]["fields"] From 0667e41f79b76ac050e70fa628ffe130339f72ae Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Sat, 9 Mar 2024 23:03:50 +0000 Subject: [PATCH 133/133] ruff --- openbb_platform/extensions/tests/utils/helpers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/openbb_platform/extensions/tests/utils/helpers.py b/openbb_platform/extensions/tests/utils/helpers.py index 50e9b72796de..14ee9126f789 100644 --- a/openbb_platform/extensions/tests/utils/helpers.py +++ b/openbb_platform/extensions/tests/utils/helpers.py @@ -251,11 +251,9 @@ def parse_example_string(example_string: str) -> Dict[str, Any]: def parse_examples(matches, example_type): examples = [] for match in matches: - if example_type == "PythonEx": - example = {"code": [match]} - else: # APIEx - example = {"params": match} - examples.append(example) + examples.append( + {"code": [match]} if example_type == "PythonEx" else {"params": match} + ) return examples # Find and parse all PythonEx examples