Skip to content

Commit

Permalink
function cleanup (#6584)
Browse files Browse the repository at this point in the history
Co-authored-by: Igor Radovanovic <[email protected]>
  • Loading branch information
deeleeramone and IgorWounds authored Jul 13, 2024
1 parent 0ed04fa commit 9be525d
Show file tree
Hide file tree
Showing 13 changed files with 385 additions and 2,304 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)


class CLIQueryParams(QueryParams):
class CompositeLeadingIndicatorQueryParams(QueryParams):
"""Composite Leading Indicator Query."""

start_date: Optional[dateType] = Field(
Expand All @@ -24,14 +24,13 @@ class CLIQueryParams(QueryParams):
)


class CLIData(Data):
class CompositeLeadingIndicatorData(Data):
"""Composite Leading Indicator Data."""

date: Optional[dateType] = Field(
default=None, description=DATA_DESCRIPTIONS.get("date")
)
value: Optional[float] = Field(default=None, description="CLI value")
country: Optional[str] = Field(
date: dateType = Field(description=DATA_DESCRIPTIONS.get("date"))
value: float = Field(
default=None,
description="Country for which CLI is given",
description="CLI value",
json_schema_extra={"x-unit_measurement": "index"},
)
country: str = Field(description="Country for the CLI value.")
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,11 @@ def test_economy_unemployment(params, headers):
@parametrize(
"params",
[
({"start_date": "2023-01-01", "end_date": "2023-06-06", "provider": "oecd"}),
(
{
"country": "united_states",
"adjustment": "amplitude",
"growth_rate": False,
"provider": "oecd",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,11 @@ def test_economy_unemployment(params, obb):
@parametrize(
"params",
[
({"start_date": "2023-01-01", "end_date": "2023-06-06"}),
(
{
"country": "united_states",
"adjustment": "amplitude",
"growth_rate": False,
"provider": "oecd",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ async def unemployment(


@router.command(
model="CLI",
model="CompositeLeadingIndicator",
examples=[
APIEx(parameters={"provider": "oecd"}),
APIEx(parameters={"country": "all", "provider": "oecd"}),
APIEx(parameters={"country": "all", "provider": "oecd", "growth_rate": True}),
],
)
async def composite_leading_indicator(
Expand All @@ -216,7 +216,7 @@ async def composite_leading_indicator(
standard_params: StandardParams,
extra_params: ExtraParams,
) -> OBBject:
"""Use the composite leading indicator (CLI).
"""Get the composite leading indicator (CLI).
It is designed to provide early signals of turning points
in business cycles showing fluctuation of the economic activity around its long term potential level.
Expand Down
64 changes: 52 additions & 12 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -5846,8 +5846,8 @@
"flag": null,
"message": null
},
"description": "Use the composite leading indicator (CLI).\n\nIt is designed to provide early signals of turning points\nin business cycles showing fluctuation of the economic activity around its long term potential level.\n\nCLIs show short-term economic movements in qualitative rather than quantitative terms.",
"examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.economy.composite_leading_indicator(provider='oecd')\nobb.economy.composite_leading_indicator(country=all, provider='oecd')\n```\n\n",
"description": "Get the composite leading indicator (CLI).\n\nIt is designed to provide early signals of turning points\nin business cycles showing fluctuation of the economic activity around its long term potential level.\n\nCLIs show short-term economic movements in qualitative rather than quantitative terms.",
"examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.economy.composite_leading_indicator(provider='oecd')\nobb.economy.composite_leading_indicator(country=all, provider='oecd', growth_rate=True)\n```\n\n",
"parameters": {
"standard": [
{
Expand Down Expand Up @@ -5877,9 +5877,49 @@
"oecd": [
{
"name": "country",
"type": "Literal['united_states', 'united_kingdom', 'japan', 'mexico', 'indonesia', 'australia', 'brazil', 'canada', 'italy', 'germany', 'turkey', 'france', 'south_africa', 'south_korea', 'spain', 'india', 'china', 'g7', 'g20', 'all']",
"description": "Country to get GDP for.",
"default": "united_states",
"type": "Union[Union[Literal['g20', 'g7', 'asia5', 'north_america', 'europe4', 'australia', 'brazil', 'canada', 'china', 'france', 'germany', 'india', 'indonesia', 'italy', 'japan', 'mexico', 'south_africa', 'south_korea', 'spain', 'turkey', 'united_kingdom', 'united_states', 'all'], str], List[Union[Literal['g20', 'g7', 'asia5', 'north_america', 'europe4', 'australia', 'brazil', 'canada', 'china', 'france', 'germany', 'india', 'indonesia', 'italy', 'japan', 'mexico', 'south_africa', 'south_korea', 'spain', 'turkey', 'united_kingdom', 'united_states', 'all'], str]]]",
"description": "Country to get the CLI for, default is G20. Multiple items allowed for provider(s): oecd.",
"default": "g20",
"optional": true,
"choices": [
"g20",
"g7",
"asia5",
"north_america",
"europe4",
"australia",
"brazil",
"canada",
"china",
"france",
"germany",
"india",
"indonesia",
"italy",
"japan",
"mexico",
"spain",
"south_africa",
"south_korea",
"turkey",
"united_states",
"united_kingdom",
"all"
]
},
{
"name": "adjustment",
"type": "Literal['amplitude', 'normalized']",
"description": "Adjustment of the data, either 'amplitude' or 'normalized'. Default is amplitude.",
"default": "amplitude",
"optional": true,
"choices": null
},
{
"name": "growth_rate",
"type": "bool",
"description": "Return the 1-year growth rate (%) of the CLI, default is False.",
"default": false,
"optional": true,
"choices": null
}
Expand All @@ -5889,7 +5929,7 @@
"OBBject": [
{
"name": "results",
"type": "List[CLI]",
"type": "List[CompositeLeadingIndicator]",
"description": "Serializable results."
},
{
Expand Down Expand Up @@ -5920,8 +5960,8 @@
"name": "date",
"type": "date",
"description": "The date of the data.",
"default": null,
"optional": true,
"default": "",
"optional": false,
"choices": null
},
{
Expand All @@ -5935,15 +5975,15 @@
{
"name": "country",
"type": "str",
"description": "Country for which CLI is given",
"default": null,
"optional": true,
"description": "Country for the CLI value.",
"default": "",
"optional": false,
"choices": null
}
],
"oecd": []
},
"model": "CLI"
"model": "CompositeLeadingIndicator"
},
"/economy/short_term_interest_rate": {
"deprecated": {
Expand Down
25 changes: 15 additions & 10 deletions openbb_platform/openbb/package/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def composite_leading_indicator(
] = None,
**kwargs
) -> OBBject:
"""Use the composite leading indicator (CLI).
"""Get the composite leading indicator (CLI).
It is designed to provide early signals of turning points
in business cycles showing fluctuation of the economic activity around its long term potential level.
Expand All @@ -541,13 +541,17 @@ def composite_leading_indicator(
End date of the data, in YYYY-MM-DD format.
provider : Optional[Literal['oecd']]
The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: oecd.
country : Literal['united_states', 'united_kingdom', 'japan', 'mexico', 'indonesia', 'australia', 'brazil', 'canada', 'italy', 'germany', 'turkey', 'france', 'south_africa', 'south_korea', 'spain', 'india', 'china', 'g7', 'g20', 'all']
Country to get GDP for. (provider: oecd)
country : Union[Literal['g20', 'g7', 'asia5', 'north_america', 'europe4', 'australia', 'brazil', 'canada', 'china', 'france', 'germany', 'india', 'indonesia', 'italy', 'japan', 'mexico', 'south_africa', 'south_korea', 'spain', 'turkey', 'united_kingdom', 'united_states', 'all'], str]
Country to get the CLI for, default is G20. Multiple comma separated items allowed. (provider: oecd)
adjustment : Literal['amplitude', 'normalized']
Adjustment of the data, either 'amplitude' or 'normalized'. Default is amplitude. (provider: oecd)
growth_rate : bool
Return the 1-year growth rate (%) of the CLI, default is False. (provider: oecd)
Returns
-------
OBBject
results : List[CLI]
results : List[CompositeLeadingIndicator]
Serializable results.
provider : Optional[Literal['oecd']]
Provider name.
Expand All @@ -558,20 +562,20 @@ def composite_leading_indicator(
extra : Dict[str, Any]
Extra info.
CLI
---
date : Optional[date]
CompositeLeadingIndicator
-------------------------
date : date
The date of the data.
value : Optional[float]
CLI value
country : Optional[str]
Country for which CLI is given
country : str
Country for the CLI value.
Examples
--------
>>> from openbb import obb
>>> obb.economy.composite_leading_indicator(provider='oecd')
>>> obb.economy.composite_leading_indicator(country='all', provider='oecd')
>>> obb.economy.composite_leading_indicator(country='all', provider='oecd', growth_rate=True)
""" # noqa: E501

return self._run(
Expand All @@ -589,6 +593,7 @@ def composite_leading_indicator(
"end_date": end_date,
},
extra_params=kwargs,
info={"country": {"oecd": {"multiple_items_allowed": True}}},
)
)

Expand Down
6 changes: 4 additions & 2 deletions openbb_platform/providers/oecd/openbb_oecd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""OECD provider module."""

from openbb_core.provider.abstract.provider import Provider
from openbb_oecd.models.composite_leading_indicator import OECDCLIFetcher
from openbb_oecd.models.composite_leading_indicator import (
OECDCompositeLeadingIndicatorFetcher,
)
from openbb_oecd.models.consumer_price_index import OECDCPIFetcher
from openbb_oecd.models.gdp_forecast import OECDGdpForecastFetcher
from openbb_oecd.models.gdp_nominal import OECDGdpNominalFetcher
Expand All @@ -25,7 +27,7 @@
"HousePriceIndex": OECDHousePriceIndexFetcher,
"ImmediateInterestRate": OECDImmediateInterestRateFetcher,
"Unemployment": OECDUnemploymentFetcher,
"CLI": OECDCLIFetcher,
"CompositeLeadingIndicator": OECDCompositeLeadingIndicatorFetcher,
"SharePriceIndex": OECDSharePriceIndexFetcher,
"STIR": OECDSTIRFetcher,
"LTIR": OECDLTIRFetcher,
Expand Down
Loading

0 comments on commit 9be525d

Please sign in to comment.