Skip to content

Commit

Permalink
[BugFix] Econ Calendar (#6392)
Browse files Browse the repository at this point in the history
* fix econ calendar

* black

* more black

* pylint

* add 1 to n_urls

* set default dates in transform query

* missing decorator

* add None to literal

* literals

---------

Co-authored-by: Henrique Joaquim <[email protected]>
Co-authored-by: Igor Radovanovic <[email protected]>
  • Loading branch information
3 people authored May 14, 2024
1 parent 2ac1af3 commit 17a7e7d
Show file tree
Hide file tree
Showing 10 changed files with 2,971 additions and 337 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
date as dateType,
datetime,
)
from typing import Literal, Optional, Union
from typing import Optional, Union

from pydantic import Field

Expand Down Expand Up @@ -36,30 +36,26 @@ class EconomicCalendarData(Data):
default=None, description=DATA_DESCRIPTIONS.get("date", "")
)
country: Optional[str] = Field(default=None, description="Country of event.")
category: Optional[str] = Field(default=None, description="Category of event.")
event: Optional[str] = Field(default=None, description="Event name.")
reference: Optional[str] = Field(
default=None,
description="Abbreviated period for which released data refers to.",
importance: Optional[str] = Field(
default=None, description="The importance level for the event."
)
source: Optional[str] = Field(default=None, description="Source of the data.")
sourceurl: Optional[str] = Field(default=None, description="Source URL.")
actual: Optional[Union[str, float]] = Field(
default=None, description="Latest released value."
currency: Optional[str] = Field(default=None, description="Currency of the data.")
unit: Optional[str] = Field(default=None, description="Unit of the data.")
consensus: Optional[Union[str, float]] = Field(
default=None,
description="Average forecast among a representative group of economists.",
)
previous: Optional[Union[str, float]] = Field(
default=None,
description="Value for the previous period after the revision (if revision is applicable).",
)
consensus: Optional[Union[str, float]] = Field(
revised: Optional[Union[str, float]] = Field(
default=None,
description="Average forecast among a representative group of economists.",
description="Revised previous value, if applicable.",
)
forecast: Optional[Union[str, float]] = Field(
default=None, description="Trading Economics projections"
)
url: Optional[str] = Field(default=None, description="Trading Economics URL")
importance: Optional[Union[Literal[0, 1, 2, 3], str]] = Field(
default=None, description="Importance of the event. 1-Low, 2-Medium, 3-High"
actual: Optional[Union[str, float]] = Field(
default=None, description="Latest released value."
)
currency: Optional[str] = Field(default=None, description="Currency of the data.")
unit: Optional[str] = Field(default=None, description="Unit of the data.")
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ def headers():
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"country": "mexico,sweden",
"importance": "Low",
"importance": "low",
"group": "gdp",
"calendar_id": None,
}
),
(
{
"provider": "fmp",
"start_date": "2023-10-24",
"end_date": "2023-11-03",
}
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def obb(pytestconfig): # pylint: disable=inconsistent-return-statements
@parametrize(
"params",
[
({"start_date": "2023-01-01", "end_date": "2023-06-06", "provider": "fmp"}),
(
{
"provider": "nasdaq",
Expand All @@ -36,8 +35,16 @@ def obb(pytestconfig): # pylint: disable=inconsistent-return-statements
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"country": "mexico,sweden",
"importance": "Medium",
"importance": "low",
"group": "gdp",
"calendar_id": None,
}
),
(
{
"provider": "fmp",
"start_date": "2023-10-24",
"end_date": "2023-11-03",
}
),
],
Expand Down
140 changes: 102 additions & 38 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -2211,15 +2211,22 @@
},
{
"name": "importance",
"type": "Literal['Low', 'Medium', 'High']",
"type": "Literal['low', 'medium', 'high']",
"description": "Importance of the event.",
"default": null,
"optional": true
},
{
"name": "group",
"type": "Literal['interest rate', 'inflation', 'bonds', 'consumer', 'gdp', 'government', 'housing', 'labour', 'markets', 'money', 'prices', 'trade', 'business']",
"description": "Grouping of events",
"type": "Literal['interest_rate', 'inflation', 'bonds', 'consumer', 'gdp', 'government', 'housing', 'labour', 'markets', 'money', 'prices', 'trade', 'business']",
"description": "Grouping of events.",
"default": null,
"optional": true
},
{
"name": "calendar_id",
"type": "Union[Union[int, str], List[Union[int, str]]]",
"description": "Get events by TradingEconomics Calendar ID. Multiple items allowed for provider(s): tradingeconomics.",
"default": null,
"optional": true
}
Expand Down Expand Up @@ -2270,6 +2277,13 @@
"default": null,
"optional": true
},
{
"name": "category",
"type": "str",
"description": "Category of event.",
"default": null,
"optional": true
},
{
"name": "event",
"type": "str",
Expand All @@ -2278,9 +2292,9 @@
"optional": true
},
{
"name": "reference",
"name": "importance",
"type": "str",
"description": "Abbreviated period for which released data refers to.",
"description": "The importance level for the event.",
"default": null,
"optional": true
},
Expand All @@ -2292,16 +2306,23 @@
"optional": true
},
{
"name": "sourceurl",
"name": "currency",
"type": "str",
"description": "Source URL.",
"description": "Currency of the data.",
"default": null,
"optional": true
},
{
"name": "actual",
"name": "unit",
"type": "str",
"description": "Unit of the data.",
"default": null,
"optional": true
},
{
"name": "consensus",
"type": "Union[str, float]",
"description": "Latest released value.",
"description": "Average forecast among a representative group of economists.",
"default": null,
"optional": true
},
Expand All @@ -2313,79 +2334,122 @@
"optional": true
},
{
"name": "consensus",
"name": "revised",
"type": "Union[str, float]",
"description": "Average forecast among a representative group of economists.",
"description": "Revised previous value, if applicable.",
"default": null,
"optional": true
},
{
"name": "actual",
"type": "Union[str, float]",
"description": "Latest released value.",
"default": null,
"optional": true
}
],
"fmp": [
{
"name": "change",
"type": "float",
"description": "Value change since previous.",
"default": null,
"optional": true
},
{
"name": "change_percent",
"type": "float",
"description": "Percentage change since previous.",
"default": null,
"optional": true
},
{
"name": "last_updated",
"type": "datetime",
"description": "Last updated timestamp.",
"default": null,
"optional": true
},
{
"name": "created_at",
"type": "datetime",
"description": "Created at timestamp.",
"default": null,
"optional": true
}
],
"tradingeconomics": [
{
"name": "forecast",
"type": "Union[str, float]",
"description": "Trading Economics projections",
"description": "TradingEconomics projections.",
"default": null,
"optional": true
},
{
"name": "url",
"name": "reference",
"type": "str",
"description": "Trading Economics URL",
"description": "Abbreviated period for which released data refers to.",
"default": null,
"optional": true
},
{
"name": "importance",
"type": "Union[Literal[0, 1, 2, 3], str]",
"description": "Importance of the event. 1-Low, 2-Medium, 3-High",
"name": "reference_date",
"type": "date",
"description": "Date for the reference period.",
"default": null,
"optional": true
},
{
"name": "currency",
"type": "str",
"description": "Currency of the data.",
"name": "calendar_id",
"type": "int",
"description": "TradingEconomics Calendar ID.",
"default": null,
"optional": true
},
{
"name": "unit",
"name": "date_span",
"type": "int",
"description": "Date span of the event.",
"default": null,
"optional": true
},
{
"name": "symbol",
"type": "str",
"description": "Unit of the data.",
"description": "TradingEconomics Symbol.",
"default": null,
"optional": true
}
],
"fmp": [
},
{
"name": "change",
"type": "float",
"description": "Value change since previous.",
"name": "ticker",
"type": "str",
"description": "TradingEconomics Ticker symbol.",
"default": null,
"optional": true
},
{
"name": "change_percent",
"type": "float",
"description": "Percentage change since previous.",
"name": "te_url",
"type": "str",
"description": "TradingEconomics URL path.",
"default": null,
"optional": true
},
{
"name": "updated_at",
"type": "datetime",
"description": "Last updated timestamp.",
"name": "source_url",
"type": "str",
"description": "Source URL.",
"default": null,
"optional": true
},
{
"name": "created_at",
"name": "last_updated",
"type": "datetime",
"description": "Created at timestamp.",
"description": "Last update of the data.",
"default": null,
"optional": true
}
],
"tradingeconomics": []
]
},
"model": "EconomicCalendar"
},
Expand Down
Loading

0 comments on commit 17a7e7d

Please sign in to comment.