From 0d1c2bd6dcaaccaaf9c860340da29da15e14b8a3 Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Wed, 11 Oct 2023 16:56:07 +0200 Subject: [PATCH 1/6] Skip all tests when doing cspell in pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a40496dd2b2..739b57228d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: [ "--ignore-words-list=VAI,MIS,shs,gard,te,commun,parana,ro,zar,vie,hel,jewl,zlot,ba,buil,coo,ether,hist,hsi,mape,navagation,operatio,pres,ser,yeld,shold,ist,varian,datas,ake,creat,statics,ket,toke,certi,buidl,ot", "--quiet-level=2", - "--skip=./tests,.git,*.css,*.csv,*.html,*.ini,*.ipynb,*.js,*.json,*.lock,*.scss,*.txt,*.yaml,build/pyinstaller/*,./website/config.toml", + "--skip=./**/tests/**,./**/test_*.py,.git,*.css,*.csv,*.html,*.ini,*.ipynb,*.js,*.json,*.lock,*.scss,*.txt,*.yaml,build/pyinstaller/*,./website/config.toml", "-x=openbb_terminal/economy/fedreserve_model.py", "-x=.github/workflows/linting.yml" ] From bd590c58d767fd4ee1588269c87aee6fa363f9aa Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Wed, 11 Oct 2023 16:56:37 +0200 Subject: [PATCH 2/6] Resolve linter errors --- .../economy/integration/test_economy_api.py | 61 ++++++++++++++++--- .../integration/test_economy_python.py | 54 ++++++++++++---- 2 files changed, 94 insertions(+), 21 deletions(-) diff --git a/openbb_platform/extensions/economy/integration/test_economy_api.py b/openbb_platform/extensions/economy/integration/test_economy_api.py index f7218bb5f9e..63708779f10 100644 --- a/openbb_platform/extensions/economy/integration/test_economy_api.py +++ b/openbb_platform/extensions/economy/integration/test_economy_api.py @@ -15,6 +15,9 @@ def headers(): return {"Authorization": f"Basic {base64_bytes.decode('ascii')}"} +# pylint: disable=redefined-outer-name + + @pytest.mark.parametrize( "params", [({"index": "dowjones"})], @@ -308,7 +311,7 @@ def test_economy_cot_search(params, headers): ( { "code": "13874P", - "data_type": "FO", + "data_type": "FO", # cspell: disable-line "legacy_format": True, "report_type": "ALL", "measure": "CR", @@ -379,15 +382,25 @@ def test_economy_fred_index(params, headers): assert isinstance(result, requests.Response) assert result.status_code == 200 + @pytest.mark.parametrize( "params", - [({'units': 'usd', 'start_date': '2023-01-01', 'end_date': '2023-06-06'}), -({'country': 'united_states', 'provider': 'oecd', 'units': 'usd', 'start_date': '2023-01-01', 'end_date': '2023-06-06'})], + [ + ({"units": "usd", "start_date": "2023-01-01", "end_date": "2023-06-06"}), + ( + { + "country": "united_states", + "provider": "oecd", + "units": "usd", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + } + ), + ], ) @pytest.mark.integration def test_economy_gdpnom(params, headers): params = {p: v for p, v in params.items() if v} - query_str = get_querystring(params, []) url = f"http://0.0.0.0:8000/api/v1/economy/gdpnom?{query_str}" @@ -395,15 +408,25 @@ def test_economy_gdpnom(params, headers): assert isinstance(result, requests.Response) assert result.status_code == 200 + @pytest.mark.parametrize( "params", - [({'units': 'yoy', 'start_date': '2023-01-01', 'end_date': '2023-06-06'}), -({'country': 'united_states', 'provider': 'oecd', 'units': 'yoy', 'start_date': '2023-01-01', 'end_date': '2023-06-06'})], + [ + ({"units": "yoy", "start_date": "2023-01-01", "end_date": "2023-06-06"}), + ( + { + "country": "united_states", + "provider": "oecd", + "units": "yoy", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + } + ), + ], ) @pytest.mark.integration def test_economy_gdpreal(params, headers): params = {p: v for p, v in params.items() if v} - query_str = get_querystring(params, []) url = f"http://0.0.0.0:8000/api/v1/economy/gdpreal?{query_str}" @@ -411,15 +434,33 @@ def test_economy_gdpreal(params, headers): assert isinstance(result, requests.Response) assert result.status_code == 200 + @pytest.mark.parametrize( "params", - [({'period': 'annual', 'start_date': '2023-01-01', 'end_date': '2023-06-06', 'type': 'real'}), -({'country': 'united_states', 'provider': 'oecd', 'period': 'annual', 'start_date': '2023-01-01', 'end_date': '2023-06-06', 'type': 'real'})], + [ + ( + { + "period": "annual", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + "type": "real", + } + ), + ( + { + "country": "united_states", + "provider": "oecd", + "period": "annual", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + "type": "real", + } + ), + ], ) @pytest.mark.integration def test_economy_gdpforecast(params, headers): params = {p: v for p, v in params.items() if v} - query_str = get_querystring(params, []) url = f"http://0.0.0.0:8000/api/v1/economy/gdpforecast?{query_str}" diff --git a/openbb_platform/extensions/economy/integration/test_economy_python.py b/openbb_platform/extensions/economy/integration/test_economy_python.py index 4c117bb5617..c217a28595d 100644 --- a/openbb_platform/extensions/economy/integration/test_economy_python.py +++ b/openbb_platform/extensions/economy/integration/test_economy_python.py @@ -5,15 +5,18 @@ from openbb_core.app.model.obbject import OBBject @pytest.fixture(scope="session") -def obb(pytestconfig): +def obb(pytestconfig): # pylint: disable=inconsistent-return-statements """Fixture to setup obb.""" if pytestconfig.getoption("markexpr") != "not integration": - import openbb + import openbb # pylint: disable=import-outside-toplevel return openbb.obb +# pylint: disable=redefined-outer-name + + @pytest.mark.parametrize( "params", [ @@ -366,9 +369,16 @@ def test_economy_fred_index(params): @pytest.mark.parametrize( "params", [ - ({'units': 'usd', 'start_date': '2023-01-01', 'end_date': '2023-06-06'}), -({'country': 'united_states', 'provider': 'oecd', 'units': 'usd', 'start_date': '2023-01-01', 'end_date': '2023-06-06'}), - + ({"units": "usd", "start_date": "2023-01-01", "end_date": "2023-06-06"}), + ( + { + "country": "united_states", + "provider": "oecd", + "units": "usd", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + } + ), ], ) @pytest.mark.integration @@ -384,9 +394,16 @@ def test_economy_gdpnom(params, obb): @pytest.mark.parametrize( "params", [ - ({'units': 'yoy', 'start_date': '2023-01-01', 'end_date': '2023-06-06'}), -({'country': 'united_states', 'provider': 'oecd', 'units': 'yoy', 'start_date': '2023-01-01', 'end_date': '2023-06-06'}), - + ({"units": "yoy", "start_date": "2023-01-01", "end_date": "2023-06-06"}), + ( + { + "country": "united_states", + "provider": "oecd", + "units": "yoy", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + } + ), ], ) @pytest.mark.integration @@ -402,9 +419,24 @@ def test_economy_gdpreal(params, obb): @pytest.mark.parametrize( "params", [ - ({'period': 'annual', 'start_date': '2023-01-01', 'end_date': '2023-06-06', 'type': 'real'}), -({'country': 'united_states', 'provider': 'oecd', 'period': 'annual', 'start_date': '2023-01-01', 'end_date': '2023-06-06', 'type': 'real'}), - + ( + { + "period": "annual", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + "type": "real", + } + ), + ( + { + "country": "united_states", + "provider": "oecd", + "period": "annual", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + "type": "real", + } + ), ], ) @pytest.mark.integration From bfa57dde041ebc895249f50f0115932126861873 Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Wed, 11 Oct 2023 18:53:15 +0200 Subject: [PATCH 3/6] Resolve more linter errors --- .../openbb_provider/standard_models/gdpreal.py | 5 ++++- .../oecd/openbb_oecd/models/gdpforecast.py | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/openbb_platform/platform/provider/openbb_provider/standard_models/gdpreal.py b/openbb_platform/platform/provider/openbb_provider/standard_models/gdpreal.py index 6bfdbb37798..e8ad24efe25 100644 --- a/openbb_platform/platform/provider/openbb_provider/standard_models/gdpreal.py +++ b/openbb_platform/platform/provider/openbb_provider/standard_models/gdpreal.py @@ -14,7 +14,10 @@ class GDPRealQueryParams(QueryParams): units: Literal["idx", "qoq", "yoy"] = Field( default="yoy", - description="Units to get real GDP in. Either idx (indicating 2015=100), qoq (previous period) or yoy (same period, previous year).)", + description="Units to get real GDP in. " + + "Either idx (indicating 2015=100), " + + "qoq (previous period) " + + "or yoy (same period, previous year).)", ) start_date: Optional[dateType] = Field( default=None, description=QUERY_DESCRIPTIONS.get("start_date") diff --git a/openbb_platform/providers/oecd/openbb_oecd/models/gdpforecast.py b/openbb_platform/providers/oecd/openbb_oecd/models/gdpforecast.py index 4224f36f6a4..ad124365233 100644 --- a/openbb_platform/providers/oecd/openbb_oecd/models/gdpforecast.py +++ b/openbb_platform/providers/oecd/openbb_oecd/models/gdpforecast.py @@ -67,9 +67,23 @@ class OECDGDPForecastFetcher( ) -> dict: units = query.period[0].upper() if query.type == "real": - url = f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.REALGDPFORECAST.TOT.AGRWTH.{units}/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en&startPeriod={query.start_date}&endPeriod={query.end_date}" + url = ( + "https://stats.oecd.org/sdmx-json/data/DP_LIVE/.REALGDPFORECAST.TOT.AGRWTH." + + units + + "/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en&startPeriod=" + + query.start_date + + "&endPeriod=" + + query.end_date + ) elif query.type == "nominal": - url = f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.NOMGDPFORECAST.TOT.AGRWTH.{units}/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en&startPeriod={query.start_date}&endPeriod={query.end_date}" + url = ( + "https://stats.oecd.org/sdmx-json/data/DP_LIVE/.NOMGDPFORECAST.TOT.AGRWTH." + + units + + "/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en&startPeriod=" + + query.start_date + + "&endPeriod=" + + query.end_date + ) data_df = helpers.fetch_data(url, csv_kwargs={"encoding": "utf-8"}, **kwargs) # Sometimes there is weird unicode characters in the column names, so we need to rename them. From 623ea5a78ef208d71e672b0ec5e8a354e0e47033 Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Wed, 11 Oct 2023 18:59:33 +0200 Subject: [PATCH 4/6] Exclude static files of v4 python from ruff --- pyproject.toml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index df3b0c7fe5d..05f39612a34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,13 +115,13 @@ posthog = "^3.0.1" reportlab = "<4" #Pinning due to build error on MacOs arch = "^5.5.0" llama-index = "^0.8.8" -langchain = "0.0.266" # Pinned for llama index +langchain = "0.0.266" # Pinned for llama index ffn = "0.3.6" jupyter-client = "7.4.1" jupyter-server = "1.23.6" python-jose = "^3.3.0" -nixtlats = "^0.1.11" # Pinning for stability -nltk = "^3.8.1" # Is a dependence for llama index +nixtlats = "^0.1.11" # Pinning for stability +nltk = "^3.8.1" # Is a dependence for llama index [tool.poetry.extras] forecast = [ @@ -204,10 +204,27 @@ target-version = "py38" # This is an introductory addition of ruff. We should look to adding: # D: pydocstyle, PD: pandas-vet # All options here: https://github.com/charliermarsh/ruff#supported-rules -select = ["E", "W", "F", "Q", "S", "UP", "I", "PLC", "PLE", "PLR", "PLW", "SIM", "T20"] +select = [ + "E", + "W", + "F", + "Q", + "S", + "UP", + "I", + "PLC", + "PLE", + "PLR", + "PLW", + "SIM", + "T20", +] # These ignores should be seen as temporary solutions to problems that will NEED fixed ignore = ["PLR2004", "PLR0913", "PLR0915"] -exclude = ["^openbb_platform/platform/core/openbb_core/app/static/package/.*"] +exclude = [ + "^openbb_platform/platform/core/openbb_core/app/static/package/.*", + "^openbb_platform/openbb/package/.*", +] [tool.ruff.per-file-ignores] "**/tests/*" = ["S101"] From 68dc4a3fa02c0110f0a731db983bbae7f3f64380 Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Wed, 11 Oct 2023 19:08:02 +0200 Subject: [PATCH 5/6] More linting --- openbb_platform/providers/oecd/openbb_oecd/models/gdpnom.py | 6 +++++- .../providers/oecd/openbb_oecd/models/gdpreal.py | 6 +++++- openbb_platform/providers/oecd/tests/test_oecd_fetchers.py | 3 ++- openbb_terminal/economy/oecd_model.py | 5 ----- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/openbb_platform/providers/oecd/openbb_oecd/models/gdpnom.py b/openbb_platform/providers/oecd/openbb_oecd/models/gdpnom.py index bbe5e2ce26c..18ff68cb8b6 100644 --- a/openbb_platform/providers/oecd/openbb_oecd/models/gdpnom.py +++ b/openbb_platform/providers/oecd/openbb_oecd/models/gdpnom.py @@ -52,7 +52,11 @@ class OECDGDPNomFetcher(Fetcher[OECDGDPNomQueryParams, List[OECDGDPNomData]]): **kwargs: Any, ) -> dict: unit = "MLN_USD" if query.units == "usd" else "USD_CAP" - url = f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.GDP.TOT.{unit}.A/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en&startPeriod={query.start_date}&endPeriod={query.end_date}" + url = ( + f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.GDP.TOT.{unit}.A/OECD" + "?contentType=csv&detail=code&separator=comma&csv-lang=en" + f"&startPeriod={query.start_date}&endPeriod={query.end_date}" + ) data_df = helpers.fetch_data(url, csv_kwargs={"encoding": "utf-8"}, **kwargs) # Sometimes there is weird unicode characters in the column names, so we need to rename them. # Even changing the encoding on the fetch doesn't seem to help. diff --git a/openbb_platform/providers/oecd/openbb_oecd/models/gdpreal.py b/openbb_platform/providers/oecd/openbb_oecd/models/gdpreal.py index 26dc99596bd..b61cd709a46 100644 --- a/openbb_platform/providers/oecd/openbb_oecd/models/gdpreal.py +++ b/openbb_platform/providers/oecd/openbb_oecd/models/gdpreal.py @@ -61,7 +61,11 @@ class OECDGDPRealFetcher(Fetcher[OECDGDPRealQueryParams, List[OECDGDPRealData]]) **kwargs: Any, ) -> dict: units = {"qoq": "PC_CHGPP", "yoy": "PC_CHGPY", "idx": "IDX"}[query.units] - url = f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.QGDP.{'VOLIDX' if units == 'IDX' else 'TOT'}.{units}.Q/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en&startPeriod={query.start_date}&endPeriod={query.end_date}" + url = ( + f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.QGDP.{'VOLIDX' if units == 'IDX' else 'TOT'}" + f".{units}.Q/OECD?contentType=csv&detail=code&separator=comma&csv-lang=en" + f"&startPeriod={query.start_date}&endPeriod={query.end_date}" + ) data_df = helpers.fetch_data(url, csv_kwargs={"encoding": "utf-8"}, **kwargs) # Sometimes there is weird unicode characters in the column names, so we need to rename them. # Even changing the encoding on the fetch doesn't seem to help. diff --git a/openbb_platform/providers/oecd/tests/test_oecd_fetchers.py b/openbb_platform/providers/oecd/tests/test_oecd_fetchers.py index b1bfed598d1..08ba368ff99 100644 --- a/openbb_platform/providers/oecd/tests/test_oecd_fetchers.py +++ b/openbb_platform/providers/oecd/tests/test_oecd_fetchers.py @@ -1,9 +1,10 @@ import datetime + import pytest from openbb_core.app.service.user_service import UserService +from openbb_oecd.models.gdpforecast import OECDGDPForecastFetcher from openbb_oecd.models.gdpnom import OECDGDPNomFetcher from openbb_oecd.models.gdpreal import OECDGDPRealFetcher -from openbb_oecd.models.gdpforecast import OECDGDPForecastFetcher test_credentials = UserService().default_user_settings.credentials.dict() diff --git a/openbb_terminal/economy/oecd_model.py b/openbb_terminal/economy/oecd_model.py index f757ff6d880..bc8d7ad4739 100644 --- a/openbb_terminal/economy/oecd_model.py +++ b/openbb_terminal/economy/oecd_model.py @@ -540,11 +540,6 @@ def get_gdp( no_data_message(error=str(e)) return df - print( - f"https://stats.oecd.org/sdmx-json/data/DP_LIVE/.GDP.TOT.{units_dict[units]}.A/OECD?contentType=csv&detail=code" - f"&separator=comma&csv-lang=en&startPeriod={start_date}&endPeriod={end_date}" - ) - df = df.iloc[:, [0, 5]] result = pd.DataFrame() From 58717ece01c5acd679a640ebd213f1454a2a1cde Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Wed, 11 Oct 2023 19:18:41 +0200 Subject: [PATCH 6/6] Another attempt to resolve even more linting errors --- .../openbb/package/__extensions__.py | 1 - .../openbb/package/econometrics.py | 18 +- openbb_platform/openbb/package/economy.py | 249 ------------------ .../openbb/package/extension_map.json | 1 - .../openbb/package/module_map.json | 3 - openbb_platform/openbb/package/qa.py | 38 ++- openbb_platform/openbb/package/ta.py | 6 +- .../tests/api/test_auth/test_user_auth.py | 1 - 8 files changed, 41 insertions(+), 276 deletions(-) diff --git a/openbb_platform/openbb/package/__extensions__.py b/openbb_platform/openbb/package/__extensions__.py index 5d2ebc153d5..198cf925498 100644 --- a/openbb_platform/openbb/package/__extensions__.py +++ b/openbb_platform/openbb/package/__extensions__.py @@ -38,7 +38,6 @@ Extensions: - fmp@0.1.0a2 - fred@0.1.0a2 - intrinio@0.1.0a2 - - oecd@0.1.0a2 - polygon@0.1.0a2 - quandl@0.1.0a2 - yfinance@0.1.0a2 """ diff --git a/openbb_platform/openbb/package/econometrics.py b/openbb_platform/openbb/package/econometrics.py index ea0c1f3846c..c7bfcd960ba 100644 --- a/openbb_platform/openbb/package/econometrics.py +++ b/openbb_platform/openbb/package/econometrics.py @@ -53,6 +53,7 @@ class ROUTER_econometrics(Container): List of columns to use as exogenous variables. lags: PositiveInt Number of lags to use in the test. + Returns ------- OBBject[Data] @@ -85,6 +86,7 @@ class ROUTER_econometrics(Container): Data columns to check cointegration maxlag: PositiveInt Number of lags to use in the test. + Returns ------- OBBject[Data] @@ -132,7 +134,7 @@ class ROUTER_econometrics(Container): y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform Durbin-Watson test for autocorrelation + """Perform Durbin-Watson test for autocorrelation. Parameters ---------- @@ -180,6 +182,7 @@ class ROUTER_econometrics(Container): Columns to use as exogenous variables. lag: PositiveInt Number of lags to use in the test. + Returns ------- OBBject[Data] @@ -275,7 +278,7 @@ class ROUTER_econometrics(Container): y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform a Between estimator regression on panel data + """Perform a Between estimator regression on panel data. Parameters ---------- @@ -310,7 +313,7 @@ class ROUTER_econometrics(Container): y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform a first-difference estimate for panel data + """Perform a first-difference estimate for panel data. Parameters ---------- @@ -345,7 +348,7 @@ class ROUTER_econometrics(Container): y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Fama-MacBeth estimator for panel data + """Fama-MacBeth estimator for panel data. Parameters ---------- @@ -380,7 +383,7 @@ class ROUTER_econometrics(Container): y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """One- and two-way fixed effects estimator for panel data + """One- and two-way fixed effects estimator for panel data. Parameters ---------- @@ -415,7 +418,7 @@ class ROUTER_econometrics(Container): y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform a Pooled coefficvient estimator regression on panel data + """Perform a Pooled coefficvient estimator regression on panel data. Parameters ---------- @@ -450,7 +453,7 @@ class ROUTER_econometrics(Container): y_column: str, x_columns: List[str], ) -> OBBject[Dict]: - """Perform One-way Random Effects model for panel data + """Perform One-way Random Effects model for panel data. Parameters ---------- @@ -496,6 +499,7 @@ class ROUTER_econometrics(Container): regression: str Regression type to use in the test. Either "c" for constant only, "ct" for constant and trend, or "ctt" for constant, trend, and trend-squared. + Returns ------- OBBject[Data] diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 84a1da9669d..abacfd43e51 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -22,9 +22,6 @@ class ROUTER_economy(Container): european_index european_index_constituents fred_index - gdpforecast - gdpnom - gdpreal index index_search index_snapshots @@ -741,252 +738,6 @@ class ROUTER_economy(Container): **inputs, ) - @validate_call - def gdpforecast( - self, - period: Annotated[ - Literal["quarter", "annual"], - OpenBBCustomParameter( - description="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[List[Data]]: - """GDP Data. - - Parameters - ---------- - period : Literal['quarter', 'annual'] - Units for nominal GDP period. Either quarter or annual. - start_date : Optional[datetime.date] - Start date of the data, in YYYY-MM-DD format. - end_date : Optional[datetime.date] - End date of the data, in YYYY-MM-DD format. - type : Literal['nominal', 'real'] - Type of GDP to get forecast of. Either nominal or real. - 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['argentina', 'asia', 'australia', 'austria', 'belgium', 'brazil', 'bulgaria', 'canada', 'chile', 'china', 'colombia', 'costa_rica', 'croatia', 'czech_republic', 'denmark', 'estonia', 'euro_area_17', 'finland', 'france', 'germany', 'greece', 'hungary', 'iceland', 'india', 'indonesia', 'ireland', 'israel', 'italy', 'japan', 'korea', 'latvia', 'lithuania', 'luxembourg', 'mexico', 'netherlands', 'new_zealand', 'non-oecd', 'norway', 'oecd_total', 'peru', 'poland', 'portugal', 'romania', 'russia', 'slovak_republic', 'slovenia', 'south_africa', 'spain', 'sweden', 'switzerland', 'turkey', 'united_kingdom', 'united_states', 'world'] - Country to get GDP for. (provider: oecd) - - Returns - ------- - OBBject - results : List[GDPForecast] - 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. - - GDPForecast - ----------- - date : Optional[date] - The date of the data. - value : Optional[float] - Nominal GDP value on the date.""" # noqa: E501 - - inputs = filter_inputs( - provider_choices={ - "provider": provider, - }, - standard_params={ - "period": period, - "start_date": start_date, - "end_date": end_date, - "type": type, - }, - extra_params=kwargs, - ) - - return self._run( - "/economy/gdpforecast", - **inputs, - ) - - @validate_call - def gdpnom( - self, - units: Annotated[ - Literal["usd", "usd_cap"], - OpenBBCustomParameter( - description="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[List[Data]]: - """GDP Data. - - Parameters - ---------- - units : Literal['usd', 'usd_cap'] - Units to get nominal GDP in. Either usd or usd_cap indicating per capita. - start_date : Optional[datetime.date] - Start date of the data, in YYYY-MM-DD format. - end_date : Optional[datetime.date] - 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['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 to get GDP for. (provider: oecd) - - Returns - ------- - OBBject - results : List[GDPNom] - 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. - - GDPNom - ------ - date : Optional[date] - The date of the data. - value : Optional[float] - Nominal GDP value on the date.""" # noqa: E501 - - inputs = filter_inputs( - provider_choices={ - "provider": provider, - }, - standard_params={ - "units": units, - "start_date": start_date, - "end_date": end_date, - }, - extra_params=kwargs, - ) - - return self._run( - "/economy/gdpnom", - **inputs, - ) - - @validate_call - def gdpreal( - self, - units: Annotated[ - Literal["idx", "qoq", "yoy"], - OpenBBCustomParameter( - description="Units to get real GDP in. 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[List[Data]]: - """GDP Data. - - Parameters - ---------- - units : Literal['idx', 'qoq', 'yoy'] - Units to get real GDP in. Either idx (indicating 2015=100), qoq (previous period) or yoy (same period, previous year).) - start_date : Optional[datetime.date] - Start date of the data, in YYYY-MM-DD format. - end_date : Optional[datetime.date] - 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['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 to get GDP for. (provider: oecd) - - Returns - ------- - OBBject - results : List[GDPReal] - 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. - - GDPReal - ------- - date : Optional[date] - The date of the data. - value : Optional[float] - Nominal GDP value on the date.""" # noqa: E501 - - inputs = filter_inputs( - provider_choices={ - "provider": provider, - }, - standard_params={ - "units": units, - "start_date": start_date, - "end_date": end_date, - }, - extra_params=kwargs, - ) - - return self._run( - "/economy/gdpreal", - **inputs, - ) - @validate_call def index( self, diff --git a/openbb_platform/openbb/package/extension_map.json b/openbb_platform/openbb/package/extension_map.json index 23a5db8b678..fd19f57c957 100644 --- a/openbb_platform/openbb/package/extension_map.json +++ b/openbb_platform/openbb/package/extension_map.json @@ -19,7 +19,6 @@ "fmp@0.1.0a2", "fred@0.1.0a2", "intrinio@0.1.0a2", - "oecd@0.1.0a2", "polygon@0.1.0a2", "quandl@0.1.0a2", "yfinance@0.1.0a2" diff --git a/openbb_platform/openbb/package/module_map.json b/openbb_platform/openbb/package/module_map.json index e9fe2e1a4aa..0cea5192336 100644 --- a/openbb_platform/openbb/package/module_map.json +++ b/openbb_platform/openbb/package/module_map.json @@ -26,9 +26,6 @@ "economy_european_index": "/economy/european_index", "economy_european_index_constituents": "/economy/european_index_constituents", "economy_fred_index": "/economy/fred_index", - "economy_gdpforecast": "/economy/gdpforecast", - "economy_gdpnom": "/economy/gdpnom", - "economy_gdpreal": "/economy/gdpreal", "economy_index": "/economy/index", "economy_index_search": "/economy/index_search", "economy_index_snapshots": "/economy/index_snapshots", diff --git a/openbb_platform/openbb/package/qa.py b/openbb_platform/openbb/package/qa.py index d582ebd779b..d3401a9fcc3 100644 --- a/openbb_platform/openbb/package/qa.py +++ b/openbb_platform/openbb/package/qa.py @@ -40,7 +40,7 @@ class ROUTER_qa(Container): def capm( self, data: Union[List[Data], pandas.DataFrame], target: str ) -> OBBject[CAPMModel]: - """Capital Asset Pricing Model.""" # noqa: E501 + """Get Capital Asset Pricing Model.""" # noqa: E501 inputs = filter_inputs( data=data, @@ -59,7 +59,7 @@ class ROUTER_qa(Container): target: str, window: Annotated[int, Gt(gt=0)], ) -> OBBject[List[Data]]: - """Kurtosis. + """Get the Kurtosis. Parameters ---------- @@ -91,8 +91,7 @@ class ROUTER_qa(Container): def normality( self, data: Union[List[Data], pandas.DataFrame], target: str ) -> OBBject[NormalityModel]: - """ - Normality Statistics. + """Get Normality Statistics. - **Kurtosis**: whether the kurtosis of a sample differs from the normal distribution. - **Skewness**: whether the skewness of a sample differs from the normal distribution. @@ -131,7 +130,7 @@ class ROUTER_qa(Container): threshold_start: float = 0.0, threshold_end: float = 1.5, ) -> OBBject[List[OmegaModel]]: - """Omega Ratio. + """Calculate the Omega Ratio. Parameters ---------- @@ -170,7 +169,24 @@ class ROUTER_qa(Container): window: Annotated[int, Gt(gt=0)], quantile_pct: Annotated[float, Ge(ge=0)] = 0.5, ) -> OBBject[List[Data]]: - """Quantile.""" # noqa: E501 + """Get Quantile. + + Parameters + ---------- + data : List[Data] + Time series data. + target : str + Target column name. + window : PositiveInt + Window size. + quantile_pct : NonNegativeFloat, optional + Quantile percentage, by default 0.5 + + Returns + ------- + OBBject[List[Data]] + Quantile. + """ # noqa: E501 inputs = filter_inputs( data=data, @@ -192,7 +208,7 @@ class ROUTER_qa(Container): rfr: float = 0.0, window: Annotated[int, Gt(gt=0)] = 252, ) -> OBBject[List[Data]]: - """Sharpe Ratio. + """Get Sharpe Ratio. Parameters ---------- @@ -230,7 +246,7 @@ class ROUTER_qa(Container): target: str, window: Annotated[int, Gt(gt=0)], ) -> OBBject[List[Data]]: - """Skewness. + """Get Skewness. Parameters ---------- @@ -267,7 +283,7 @@ class ROUTER_qa(Container): window: Annotated[int, Gt(gt=0)] = 252, adjusted: bool = False, ) -> OBBject[List[Data]]: - """Sortino Ratio. + """Get Sortino Ratio. For method & terminology see: http://www.redrockcapital.com/Sortino__A__Sharper__Ratio_Red_Rock_Capital.pdf @@ -307,7 +323,7 @@ class ROUTER_qa(Container): def summary( self, data: Union[List[Data], pandas.DataFrame], target: str ) -> OBBject[SummaryModel]: - """Summary. + """Get Summary Statistics. Parameters ---------- @@ -340,7 +356,7 @@ class ROUTER_qa(Container): fuller_reg: Literal["c", "ct", "ctt", "nc"] = "c", kpss_reg: Literal["c", "ct"] = "c", ) -> OBBject[UnitRootModel]: - """Unit Root Test. + """Get Unit Root Test. Augmented Dickey-Fuller test for unit root. Kwiatkowski-Phillips-Schmidt-Shin test for unit root. diff --git a/openbb_platform/openbb/package/ta.py b/openbb_platform/openbb/package/ta.py index 152284e210f..f008dd1626b 100644 --- a/openbb_platform/openbb/package/ta.py +++ b/openbb_platform/openbb/package/ta.py @@ -612,8 +612,8 @@ class ROUTER_ta(Container): data: Union[List[Data], pandas.DataFrame], index: str = "date", target: str = "close", - show_all: bool = False, - asint: bool = False, + show_all: bool = True, + asint: bool = True, offset: int = 0, ) -> OBBject[List[Data]]: """ @@ -630,7 +630,7 @@ class ROUTER_ta(Container): show_all : bool, optional Show 1 - 13. If set to False, show 6 - 9 asint : bool, optional - If True, fill NAs with 0 and change type to int, by default False + If True, fill NAs with 0 and change type to int, by default True. offset : int, optional How many periods to offset the result diff --git a/openbb_platform/platform/core/tests/api/test_auth/test_user_auth.py b/openbb_platform/platform/core/tests/api/test_auth/test_user_auth.py index 3c99e64cefb..820c151f9be 100644 --- a/openbb_platform/platform/core/tests/api/test_auth/test_user_auth.py +++ b/openbb_platform/platform/core/tests/api/test_auth/test_user_auth.py @@ -11,7 +11,6 @@ from openbb_core.api.auth.user import ( get_user_settings, ) - # ruff: noqa: S105 S106