diff options
19 files changed, 1548 insertions, 422 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/house_price_index.py b/openbb_platform/core/openbb_core/provider/standard_models/house_price_index.py new file mode 100644 index 00000000000..7e92b210b80 --- /dev/null +++ b/openbb_platform/core/openbb_core/provider/standard_models/house_price_index.py @@ -0,0 +1,55 @@ +"""House Price Index Standard Model.""" + +from datetime import date as dateType +from typing import Literal, Optional + +from pydantic import Field + +from openbb_core.provider.abstract.data import Data +from openbb_core.provider.abstract.query_params import QueryParams +from openbb_core.provider.utils.descriptions import ( + DATA_DESCRIPTIONS, + QUERY_DESCRIPTIONS, +) + + +class HousePriceIndexQueryParams(QueryParams): + """House Price Index Query.""" + + country: str = Field( + description=QUERY_DESCRIPTIONS.get("country", ""), + default="united_states", + ) + frequency: Literal["monthly", "quarter", "annual"] = Field( + description=QUERY_DESCRIPTIONS.get("frequency", ""), + default="quarter", + json_schema_extra={"choices": ["monthly", "quarter", "annual"]}, + ) + transform: Literal["index", "yoy", "period"] = Field( + description="Transformation of the CPI data. Period represents the change since previous." + + " Defaults to change from one year ago (yoy).", + default="index", + json_schema_extra={"choices": ["index", "yoy", "period"]}, + ) + start_date: Optional[dateType] = Field( + default=None, description=QUERY_DESCRIPTIONS.get("start_date") + ) + end_date: Optional[dateType] = Field( + default=None, description=QUERY_DESCRIPTIONS.get("end_date") + ) + + +class HousePriceIndexData(Data): + """House Price Index Data.""" + + date: Optional[dateType] = Field( + default=None, description=DATA_DESCRIPTIONS.get("date") + ) + country: Optional[str] = Field( + default=None, + description=DATA_DESCRIPTIONS.get("country", ""), + ) + value: Optional[float] = Field( + default=None, + description="Share price index value.", + ) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/immediate_interest_rate.py b/openbb_platform/core/openbb_core/provider/standard_models/immediate_interest_rate.py new file mode 100644 index 00000000000..2143fc519bc --- /dev/null +++ b/openbb_platform/core/openbb_core/provider/standard_models/immediate_interest_rate.py @@ -0,0 +1,45 @@ +"""Immediate Interest Rates Standard Model.""" + +from datetime import date as dateType +from typing import Optional + +from pydantic import Field + +from openbb_core.provider.abstract.data import Data +from openbb_core.provider.abstract.query_params import QueryParams +from openbb_core.provider.utils.descriptions import ( + DATA_DESCRIPTIONS, + QUERY_DESCRIPTIONS, +) + + +class ImmediateInterestRateQueryParams(QueryParams): + """Immediate (Call money, interbank rate) Rate Query.""" + + country: str = Field( + description=QUERY_DESCRIPTIONS.get("country", ""), + default="united_states", + ) + start_date: Optional[dateType] = Field( + default=None, description=QUERY_DESCRIPTIONS.get("start_date") + ) + end_date: Optional[dateType] = Field( + default=None, description=QUERY_DESCRIPTIONS.get("end_date") + ) + + +class ImmediateInterestRateData(Data): + """Immediate Interest Rates Data.""" + + date: Optional[dateType] = Field( + default=None, description=DATA_DESCRIPTIONS.get("date") + ) + country: Optional[str] = Field( + default=None, + description="Country for which interest rate is given", + ) + value: Optional[float] = Field( + default=None, + description="Immediate interest rates, call money, interbank rate.", + json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100}, + ) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/unemployment.py b/openbb_platform/core/openbb_core/provider/standard_models/unemployment.py index 2091aff51c4..4380719fd77 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/unemployment.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/unemployment.py @@ -1,7 +1,7 @@ """Unemployment Standard Model.""" from datetime import date as dateType -from typing import Optional +from typing import Literal, Optional from pydantic import Field @@ -16,6 +16,15 @@ from openbb_core.provider.utils.descriptions import ( class UnemploymentQueryParams(QueryParams): """Unemployment Query.""" + country: str = Field( + description=QUERY_DESCRIPTIONS.get("country", ""), + default="united_states", + ) + frequency: Literal["monthly", "quarter", "annual"] = Field( + description=QUERY_DESCRIPTIONS.get("frequency", ""), + default="monthly", + json_schema_extra={"choices": ["monthly", "quarter", "annual"]}, + ) start_date: Optional[dateType] = Field( default=None, description=QUERY_DESCRIPTIONS.get("start_date") ) @@ -30,11 +39,12 @@ class UnemploymentData(Data): date: Optional[dateType] = Field( default=None, description=DATA_DESCRIPTIONS.get("date") ) - value: Optional[float] = Field( - default=None, - description="Unemployment rate (given as a whole number, i.e 10=10%)", - ) country: Optional[str] = Field( default=None, description="Country for which unemployment rate is given", ) + value: Optional[float] = Field( + default=None, + description="Unemployment rate, as a normalized percent.", + json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100}, + ) diff --git a/openbb_platform/extensions/economy/integration/test_economy_api.py b/openbb_platform/extensions/economy/integration/test_economy_api.py index 556094a492b..db2ada070bb 100644 --- a/openbb_platform/extensions/economy/integration/test_economy_api.py +++ b/openbb_platform/extensions/economy/integration/test_economy_api.py @@ -431,7 +431,6 @@ def test_economy_money_measures(params, headers): @parametrize( "params", [ - ({"start_date": "2023-01-01", "end_date": "2023-06-06", "provider": "oecd"}), ( { "country": "united_states", @@ -734,3 +733,56 @@ def test_economy_share_price_index(params, headers): result = requests.get(url, headers=headers, timeout=10) assert isinstance(result, requests.Response) assert result.status_code == 200 + + +@parametrize( + "params", + [ + ( + { + "country": "united_states,united_kingdom", + "frequency": "quarter", + "provider": "oecd", + "start_date": "2022-01-01", + "end_date": "2024-04-01", + "transform": "index", + } + ), + ], +) +@pytest.mark.integration +def test_economy_house_price_index(params, headers): + """Test the economy house price index.""" + 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/house_price_index?{query_str}" + result = requests.get(url, headers=headers, timeout=10) + assert isinstance(result, requests.Response) + assert result.status_code == 200 + + +@parametrize( + "params", + [ + ( + { + "country": "united_states,united_kingdom", + "frequency": "monthly", + "provider": "oecd", + "start_date": "2022-01-01", + "end_date": "2024-04-01", + } + ), + ], +) +@pytest.mark.integration +def test_economy_immediate_interest_rate(params, headers): + """Test the economy immediate_interest_rate.""" + 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/immediate_interest_rate?{query_str}" + result = requests.get(url, headers=headers, timeout=10) + assert isinstance(result, requests.Response) + assert result.status_code == 200 diff --git a/openbb_platform/extensions/economy/integration/test_economy_python.py b/openbb_platform/extensions/economy/integration/test_economy_python.py index 9899b9b34c2..f31297561c3 100644 --- a/openbb_platform/extensions/economy/integration/test_economy_python.py +++ b/openbb_platform/extensions/economy/integration/test_economy_python.py @@ -400,7 +400,6 @@ def test_economy_money_measures(params, obb): @parametrize( "params", [ - ({"start_date": "2023-01-01", "end_date": "2023-06-06"}), ( { "country": "united_states", @@ -693,3 +692,54 @@ def test_economy_share_price_index(params, obb): assert result assert isinstance(result, OBBject) assert len(result.results) > 0 + + +@parametrize( + "params", + [ + ( + { + "country": "united_states,united_kingdom", + "frequency": "quarter", + "provider": "oecd", + "start_date": "2022-01-01", + "end_date": "2024-04-01", + "transform": "index", + } + ), + ], +) +@pytest.mark.integration +def test_economy_house_price_index(params, obb): + """Test economy house price index.""" + params = {p: v for p, v in params.items() if v} + + result = obb.economy.house_price_index(**params) + assert result + assert isinstance(result, OBBject) + assert len(result.results) > 0 + + +@parametrize( + "params", + [ + ( + { + "country": "united_states,united_kingdom", + "frequency": "monthly", + "provider": "oecd", + "start_date": "2022-01-01", + "end_date": "2024-04-01", + } + ), + ], +) +@pytest.mark.integration +def test_economy_immediate_interest_rate(params, obb): + """Test economy immediate interest rate.""" + params = {p: v for p, v in params.items() if v} + + result = obb.economy.immediate_interest_rate(**params) + assert result + assert isinstance(result, OBBject) + assert len(result.results) > 0 diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index ade0833bd01..43f86910491 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -421,7 +421,7 @@ async def central_bank_holdings( description="Multiple countries can be passed in as a list.", parameters={ "country": "united_kingdom,germany", - "frequency": "quarterly", + "frequency": "quarter", "provider": "oecd", }, ), @@ -435,3 +435,51 @@ async def share_price_index( ) -> OBBject: """Get the Share Price Index by country from the OECD Short-Term Economics Statistics.""" return await OBBject.from_query(Query(**locals())) + + +@router.command( + model="HousePriceIndex", + examples=[ + APIEx(parameters={"provider": "oecd"}), + APIEx( + description="Multiple countries can be passed in as a list.", + parameters={ + "country": "united_kingdom,germany", + "frequency": "quarter", + "provider": "oecd", + }, + ), + ], +) +async def house_price_index( + cc: CommandContext, + provider_choices: ProviderChoices, + standard_params: StandardParams, + extra_params: ExtraParams, +) -> OBBject: + """Get the House Price Index by country from the OECD Short-Term Economics Statistics.""" + return await OBBject.from_query(Query(**locals())) + + +@router.command( + model="ImmediateInterestRate", + examples=[ + APIEx(parameters={"provider": "oecd"}), + APIEx( + description="Multiple countries can be passed in as a list.", + parameters={ + "country": "united_kingdom,germany", + "frequency": "monthly", + "provider": "oecd", + }, + ), + ], +) +async def immediate_interest_rate( + cc: CommandContext, + provider_choices: ProviderChoices, + standard_params: StandardParams, + extra_params: ExtraParams, +) -> OBBject: + """Get immediate interest rates by country.""" + return await OBBject.from_query(Query(**locals())) diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index 664b855d393..5f7900d0901 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -2340,7 +2340,7 @@ "oecd": [ { "name": "country", - "type": "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']", + "type": "Literal['G20', 'G7', 'argentina', 'australia', 'austria', 'belgium', 'brazil', 'bulgaria', 'canada', 'chile', 'china', 'colombia', 'costa_rica', 'croatia', 'czech_republic', 'denmark', 'estonia', 'euro_area_20', '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']", "description": "Country to get GDP for.", "default": "united_states", "optional": true, @@ -4176,10 +4176,30 @@ "message": null }, "description": "Get global unemployment data.", - "examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.economy.unemployment(provider='oecd')\nobb.economy.unemployment(country=all, frequency=quarterly, provider='oecd')\n# Demographics for the statistics are selected with the `age` parameter.\nobb.economy.unemployment(country=all, frequency=quarterly, age=25-54, provider='oecd')\n```\n\n", + "examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.economy.unemployment(provider='oecd')\nobb.economy.unemployment(country='all', frequency='quarterly', provider='oecd')\n# Demographics for the statistics are selected with the `age` parameter.\nobb.economy.unemployment(country='all', frequency='quarterly', age=25-54, provider='oecd')\n```\n\n", "parameters": { "standard": [ { + "name": "country", + "type": "Union[str, List[str]]", + "description": "The country to get data. Multiple items allowed for provider(s): oecd.", + "default": "united_states", + "optional": true, + "choices": null + }, + { + "name": "frequency", + "type": "Literal['monthly', 'quarter', 'annual']", + "description": "The frequency of the data.", + "default": "monthly", + "optional": true, + "choices": [ + "monthly", + "quarter", + "annual" + ] + }, + { "name": "start_date", "type": "Union[date, str]", "description": "Start date of the data, in YYYY-MM-DD format.", @@ -4206,11 +4226,57 @@ "oecd": [ { "name": "country", - "type": "Literal['colombia', 'new_zealand', 'united_kingdom', 'italy', 'luxembourg', 'euro_area19', 'sweden', 'oecd', 'south_africa', 'denmark', 'canada', 'switzerland', 'slovakia', 'hungary', 'portugal', 'spain', 'france', 'czech_republic', 'costa_rica', 'japan', 'slovenia', 'russia', 'austria', 'latvia', 'netherlands', 'israel', 'iceland', 'united_states', 'ireland', 'mexico', 'germany', 'greece', 'turkey', 'australia', 'poland', 'south_korea', 'chile', 'finland', 'european_union27_2020', 'norway', 'lithuania', 'euro_area20', 'estonia', 'belgium', 'brazil', 'indonesia', 'all']", - "description": "Country to get GDP for.", + "type": "str", + "description": "The country to get data.", "default": "united_states", "optional": true, - "choices": null + "choices": [ + "all", + "australia", + "austria", + "belgium", + "canada", + "chile", + "colombia", + "costa_rica", + "czech_republic", + "denmark", + "estonia", + "euro_area20", + "european_union27_2020", + "finland", + "france", + "g7", + "germany", + "greece", + "hungary", + "iceland", + "ireland", + "israel", + "italy", + "japan", + "korea", + "latvia", + "lithuania", + "luxembourg", + "mexico", + "netherlands", + "new_zealand", + "norway", + "oecd", + "poland", + "portugal", + "russia", + "slovakia", + "slovenia", + "south_africa", + "spain", + "sweden", + "switzerland", + "turkey", + "united_kingdom", + "united_states" + ] }, { "name": "sex", @@ -4218,23 +4284,26 @@ "description": "Sex to get unemployment for.", "default": "total", "optional": true, - "choices": null - }, - { - "name": "frequency", - "type": "Literal['monthly', 'quarterly', 'annual']", - "description": "Frequency to get unemployment for.", - "default": "monthly", - "optional": true, - "choices": null + "choices": [ + "total", + "male", + "female" + ] }, { "name": "age", - "type": "Literal['total', '15-24', '15-64', '25-54', '55-64']", + "type": "Literal['total', '15-24', '25-54', '55-64', '15-64', '15-74']", "description": "Age group to get unemployment for. Total indicates 15 years or over", "default": "total", "optional": true, - "choices": null + "choices": [ + "total", + "15-24", + "25-54", + "55-64", + "15-64", + "15-74" + ] }, { "name": "seasonal_adjustment", @@ -4286,17 +4355,17 @@ "choices": null }, { - "name": "value", - "type": "float", - "description": "Unemployment rate (given as a whole number, i.e 10=10%)", + "name": "country", + "type": "str", + "description": "Country for which unemployment rate is given", "default": null, "optional": true, "choices": null }, { - "name": "country", - "type": "str", - "description": "Country for which unemployment rate is given", + "name": "value", + "type": "float", + "description": "Unemployment rate, as a normalized percent.", "default": null, "optional": true, "choices": null @@ -4446,7 +4515,7 @@ "oecd": [ { "name": "country", - "type": "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']", + "type": "Literal['belgium', 'bulgaria', 'brazil', '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', 'romania', 'russia', 'euro_area19', 'colombia', 'italy', 'india', 'china', 'croatia', 'all']", "description": "Country to get interest rate for.", "default": "united_states", "optional": true, @@ -4558,7 +4627,7 @@ "oecd": [ { "name": "country", - "type": "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']", + "type": "Literal['belgium', 'bulgaria', 'brazil', 'ireland', 'mexico', 'indonesia', 'new_zealand', 'japan', 'united_kingdom', 'france', 'chil |