mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-31 22:41:19 +00:00
Merge branch 'feature/add-v4-standard-models' of https://github.com/OpenBB-finance/OpenBBTerminal into feature/add-v4-standard-models
This commit is contained in:
2
.pre-commit-config.yaml
vendored
2
.pre-commit-config.yaml
vendored
@@ -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"
|
||||
]
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
[
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -11,7 +11,6 @@ from openbb_core.api.auth.user import (
|
||||
get_user_settings,
|
||||
)
|
||||
|
||||
|
||||
# ruff: noqa: S105 S106
|
||||
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -68,9 +68,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.
|
||||
|
||||
@@ -53,7 +53,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.
|
||||
|
||||
@@ -62,7 +62,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.
|
||||
|
||||
@@ -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()
|
||||
|
||||
27
pyproject.toml
vendored
27
pyproject.toml
vendored
@@ -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"]
|
||||
|
||||
Reference in New Issue
Block a user