diff --git a/openbb_platform/extensions/economy/integration/test_economy_api.py b/openbb_platform/extensions/economy/integration/test_economy_api.py index c4bf967dc803..fe7c3ffc9278 100644 --- a/openbb_platform/extensions/economy/integration/test_economy_api.py +++ b/openbb_platform/extensions/economy/integration/test_economy_api.py @@ -281,7 +281,7 @@ def test_economy_index_search(params, headers): @pytest.mark.parametrize( "params", - [({"region": "US"})], + [({"provider": "cboe", "region": "US"})], ) @pytest.mark.integration def test_economy_index_snapshots(params, headers): @@ -480,11 +480,12 @@ def test_economy_gdpforecast(params, headers): [ ( { + "provider": "tradingeconomics", "start_date": "2023-01-01", "end_date": "2023-06-06", - "country": "Portugal", + "country": "portugal", "group": "gdp", - "importance": 3, + "importance": "Low", } ) ], diff --git a/openbb_platform/extensions/economy/integration/test_economy_python.py b/openbb_platform/extensions/economy/integration/test_economy_python.py index 615eeec9a2fc..87db8fc3b7d2 100644 --- a/openbb_platform/extensions/economy/integration/test_economy_python.py +++ b/openbb_platform/extensions/economy/integration/test_economy_python.py @@ -444,9 +444,9 @@ def test_economy_gdpforecast(params, obb): { "start_date": "2023-01-01", "end_date": "2023-06-06", - "country": "Portugal", - "importance": 1, - "group": "money", + "country": "portugal", + "importance": "Low", + "group": "gdp", } ), ], diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 446b5d1d279a..03bdb97c3b69 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -197,7 +197,7 @@ def gdpforecast( return OBBject(results=Query(**locals()).execute()) -@router.command(model="EconCal") +@router.command(model="EconomicCalendar") def econcal( cc: CommandContext, provider_choices: ProviderChoices, diff --git a/openbb_platform/platform/core/openbb_core/api/router/commands.py b/openbb_platform/platform/core/openbb_core/api/router/commands.py index d2e291762e14..0f90733d5d77 100644 --- a/openbb_platform/platform/core/openbb_core/api/router/commands.py +++ b/openbb_platform/platform/core/openbb_core/api/router/commands.py @@ -161,7 +161,8 @@ def wrapper(*args: Tuple[Any], **kwargs: Dict[str, Any]): execute = partial(command_runner.run, path, user_settings) output: OBBject = execute(*args, **kwargs) - return validate_output(output) + output = validate_output(output) + return output return wrapper diff --git a/openbb_platform/platform/provider/openbb_provider/standard_models/economic_calendar.py b/openbb_platform/platform/provider/openbb_provider/standard_models/economic_calendar.py index 821919f3d808..1b06bf5530db 100644 --- a/openbb_platform/platform/provider/openbb_provider/standard_models/economic_calendar.py +++ b/openbb_platform/platform/provider/openbb_provider/standard_models/economic_calendar.py @@ -7,7 +7,7 @@ ) from typing import List, Literal, Optional, Union -from pydantic import Field +from pydantic import Field, field_validator from openbb_provider.abstract.data import Data from openbb_provider.abstract.query_params import QueryParams @@ -25,26 +25,24 @@ class EconomicCalendarQueryParams(QueryParams): default=None, description=QUERY_DESCRIPTIONS.get("end_date", ""), ) - importance: Optional[Literal[1, 2, 3]] = Field( + importance: Literal["Low", "Medium", "High"] = Field( default=None, - description="Importance of the event. 1-Low, 2-Medium, 3-High", + description="Importance of the event.", ) - group: Optional[ - Literal[ - "interest rate", - "inflation", - "bonds", - "consumer", - "gdp", - "government", - "housing", - "labour", - "markets", - "money", - "prices", - "trade", - "business", - ] + group: Literal[ + "interest rate", + "inflation", + "bonds", + "consumer", + "gdp", + "government", + "housing", + "labour", + "markets", + "money", + "prices", + "trade", + "business", ] = Field(default=None, description="Grouping of events") # TODO: Probably want to figure out the list we can use. country: Optional[Union[str, List[str]]] = Field( @@ -52,6 +50,12 @@ class EconomicCalendarQueryParams(QueryParams): description="Country of the event", ) + @field_validator("importance") + @classmethod + def importance_to_number(cls, v): + string_to_value = {"Low": 1, "Medium": 2, "High": 3} + return string_to_value[v] + class EconomicCalendarData(Data): """Economic calendar Data.""" diff --git a/openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py b/openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py index 647e1351d133..66313c069566 100644 --- a/openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py +++ b/openbb_platform/providers/cboe/openbb_cboe/models/index_snapshots.py @@ -128,9 +128,14 @@ def extract_data( data = data[list(EUR_INDEX_COLUMNS.keys())] data.columns = list(EUR_INDEX_COLUMNS.values()) + data["change_percent"] = data["change_percent"].fillna(0.0) + return data.reset_index().to_dict("records") @staticmethod def transform_data(data: dict) -> List[CboeIndexSnapshotsData]: """Transform the data to the standard format""" + for item in data: + item["name"] = item["name"].replace("/", "-") + return [CboeIndexSnapshotsData.model_validate(d) for d in data] diff --git a/openbb_platform/providers/tradingeconomics/openbb_tradingeconomics/__init__.py b/openbb_platform/providers/tradingeconomics/openbb_tradingeconomics/__init__.py index 769f4be0aa14..4406a0992eef 100644 --- a/openbb_platform/providers/tradingeconomics/openbb_tradingeconomics/__init__.py +++ b/openbb_platform/providers/tradingeconomics/openbb_tradingeconomics/__init__.py @@ -7,5 +7,5 @@ website="https://tradingeconomics.com/", description="""Trading Economics""", required_credentials=["api_key"], - fetcher_dict={"EconCal": TEEarningsCalendarFetcher}, + fetcher_dict={"EconomicCalendar": TEEarningsCalendarFetcher}, ) diff --git a/openbb_platform/providers/tradingeconomics/openbb_tradingeconomics/utils/url_generator.py b/openbb_platform/providers/tradingeconomics/openbb_tradingeconomics/utils/url_generator.py index 73a5610510cd..ea198305106a 100644 --- a/openbb_platform/providers/tradingeconomics/openbb_tradingeconomics/utils/url_generator.py +++ b/openbb_platform/providers/tradingeconomics/openbb_tradingeconomics/utils/url_generator.py @@ -74,5 +74,12 @@ def generate_url(in_query): # Group + Date elif check_args(query, ["group", "start_date", "end_date"]): url = f'{base_url}/group/{query["group"]}/{query["start_date"]}/{query["end_date"]}?c=' + # All fields + elif check_args( + query, ["country", "group", "importance", "start_date", "end_date"] + ): + start_date = query["start_date"] + end_date = query["end_date"] + url = f"{base_url}/country/{country}/group/{group}/{start_date}/{end_date}?{urlencode(query)}&c=" return url if url else ""