summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormontezdesousa <79287829+montezdesousa@users.noreply.github.com>2024-02-02 10:34:26 +0000
committerGitHub <noreply@github.com>2024-02-02 10:34:26 +0000
commit5f8fca5a4a8896a87d5e7f5244627a21f53e3df9 (patch)
tree57329e25b8592dd70a2bc6c7a1d0153d0af8eeb5
parentd4baba0284f80307b68206861a4b229a1908e79a (diff)
[BugFix] Fix package builder (#6022)
* fix: remove specific imports * adjustments for correct deprecation * static assets --------- Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
-rw-r--r--openbb_platform/core/openbb_core/app/deprecation.py8
-rw-r--r--openbb_platform/core/openbb_core/app/static/package_builder.py10
-rw-r--r--openbb_platform/core/openbb_core/app/version.py6
-rw-r--r--openbb_platform/core/tests/app/test_deprecation.py7
-rw-r--r--openbb_platform/openbb/package/economy.py255
-rw-r--r--openbb_platform/openbb/package/index.py8
-rw-r--r--openbb_platform/openbb/package/module_map.json4
7 files changed, 275 insertions, 23 deletions
diff --git a/openbb_platform/core/openbb_core/app/deprecation.py b/openbb_platform/core/openbb_core/app/deprecation.py
index f4e03c87687..482338bf32d 100644
--- a/openbb_platform/core/openbb_core/app/deprecation.py
+++ b/openbb_platform/core/openbb_core/app/deprecation.py
@@ -6,6 +6,8 @@ This implementation was inspired from Pydantic's specific warnings and modified
from typing import Optional, Tuple
+from openbb_core.app.version import VERSION, get_major_minor
+
class DeprecationSummary(str):
"""A string subclass that can be used to store deprecation metadata."""
@@ -45,13 +47,13 @@ class OpenBBDeprecationWarning(DeprecationWarning):
self,
message: str,
*args: object,
- since: Tuple[int, int],
+ since: Optional[Tuple[int, int]] = None,
expected_removal: Optional[Tuple[int, int]] = None,
) -> None:
super().__init__(message, *args)
self.message = message.rstrip(".")
- self.since = since
- self.expected_removal = expected_removal or (since[0] + 1, 0)
+ self.since = since or get_major_minor(VERSION)
+ self.expected_removal = expected_removal or (self.since[0] + 1, 0)
self.long_message = (
f"{self.message}. Deprecated in OpenBB Platform V{self.since[0]}.{self.since[1]}"
f" to be removed in V{self.expected_removal[0]}.{self.expected_removal[1]}."
diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py
index d9c6911c374..cd94b48fec8 100644
--- a/openbb_platform/core/openbb_core/app/static/package_builder.py
+++ b/openbb_platform/core/openbb_core/app/static/package_builder.py
@@ -345,6 +345,7 @@ class ImportDefinition:
code += "\nfrom openbb_core.app.static.utils.decorators import validate\n"
code += "\nfrom openbb_core.app.static.utils.filters import filter_inputs\n"
code += "\nfrom openbb_core.provider.abstract.data import Data"
+ code += "\nfrom openbb_core.app.deprecation import OpenBBDeprecationWarning\n"
if path.startswith("/quantitative"):
code += "\nfrom openbb_quantitative.models import "
code += "(CAPMModel,NormalityModel,OmegaModel,SummaryModel,UnitRootModel)"
@@ -353,15 +354,6 @@ class ImportDefinition:
module_list = list(set(module_list))
module_list.sort()
- specific_imports = {
- hint_type.__module__: hint_type.__name__
- for hint_type in hint_type_list
- if getattr(hint_type, "__name__", None) is not None
- }
- code += "\n"
- for module, name in specific_imports.items():
- code += f"from {module} import {name}\n"
-
code += "\n"
for module in module_list:
code += f"import {module}\n"
diff --git a/openbb_platform/core/openbb_core/app/version.py b/openbb_platform/core/openbb_core/app/version.py
index 3405a2f1569..a022eb1c790 100644
--- a/openbb_platform/core/openbb_core/app/version.py
+++ b/openbb_platform/core/openbb_core/app/version.py
@@ -48,6 +48,12 @@ def is_git_repo(path: Path):
return False
+def get_major_minor(version: str) -> tuple[int, int]:
+ """Retrieve the major and minor version from a version string."""
+ parts = version.split(".")
+ return (int(parts[0]), int(parts[1]))
+
+
try:
VERSION = get_package_version(PACKAGE)
except pkg_resources.DistributionNotFound:
diff --git a/openbb_platform/core/tests/app/test_deprecation.py b/openbb_platform/core/tests/app/test_deprecation.py
index 3abec9e272d..c30df03f697 100644
--- a/openbb_platform/core/tests/app/test_deprecation.py
+++ b/openbb_platform/core/tests/app/test_deprecation.py
@@ -1,12 +1,7 @@
import unittest
from openbb_core.app.static.package_builder import PathHandler
-from openbb_core.app.version import VERSION
-
-
-def get_major_minor(version):
- parts = version.split(".")
- return (int(parts[0]), int(parts[1]))
+from openbb_core.app.version import VERSION, get_major_minor
class DeprecatedCommandsTest(unittest.TestCase):
diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py
index 2317d0ab163..95cb79a8422 100644
--- a/openbb_platform/openbb/package/economy.py
+++ b/openbb_platform/openbb/package/economy.py
@@ -14,12 +14,15 @@ from typing_extensions import Annotated
class ROUTER_economy(Container):
"""/economy
calendar
+ composite_leading_indicator
cpi
fred_search
fred_series
/gdp
+ long_term_interest_rate
money_measures
risk_premium
+ short_term_interest_rate
unemployment
"""
@@ -137,6 +140,85 @@ class ROUTER_economy(Container):
)
@validate
+ def composite_leading_indicator(
+ self,
+ 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:
+ """The composite leading indicator (CLI) is designed to provide early signals of turning points
+ in business cycles showing fluctuation of the economic activity around its long term potential level.
+ CLIs show short-term economic movements in qualitative rather than quantitative terms.
+
+
+ Parameters
+ ----------
+ 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['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)
+
+ Returns
+ -------
+ OBBject
+ results : List[CLI]
+ 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.
+
+ CLI
+ ---
+ date : Optional[date]
+ The date of the data.
+ value : Optional[float]
+ CLI value
+ country : Optional[str]
+ Country for which CLI is given
+
+ Example
+ -------
+ >>> from openbb import obb
+ >>> obb.economy.composite_leading_indicator()
+ """ # noqa: E501
+
+ return self._run(
+ "/economy/composite_leading_indicator",
+ **filter_inputs(
+ provider_choices={
+ "provider": provider,
+ },
+ standard_params={
+ "start_date": start_date,
+ "end_date": end_date,
+ },
+ extra_params=kwargs,
+ )
+ )
+
+ @validate
def cpi(
self,
countries: Annotated[
@@ -549,6 +631,93 @@ class ROUTER_economy(Container):
return economy_gdp.ROUTER_economy_gdp(command_runner=self._command_runner)
@validate
+ def long_term_interest_rate(
+ self,
+ 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:
+ """
+ Long-term interest rates refer to government bonds maturing in ten years.
+ Rates are mainly determined by the price charged by the lender, the risk from the borrower and the
+ fall in the capital value. Long-term interest rates are generally averages of daily rates,
+ measured as a percentage. These interest rates are implied by the prices at which the government bonds are
+ traded on financial markets, not the interest rates at which the loans were issued.
+ In all cases, they refer to bonds whose capital repayment is guaranteed by governments.
+ Long-term interest rates are one of the determinants of business investment.
+ Low long-term interest rates encourage investment in new equipment and high interest rates discourage it.
+ Investment is, in turn, a major source of economic growth.
+
+ Parameters
+ ----------
+ 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['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']
+ Country to get GDP for. (provider: oecd)
+ frequency : Literal['monthly', 'quarterly', 'annual']
+ Frequency to get interest rate for for. (provider: oecd)
+
+ Returns
+ -------
+ OBBject
+ results : List[STIR]
+ 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.
+
+ STIR
+ ----
+ date : Optional[date]
+ The date of the data.
+ value : Optional[float]
+ Interest rate (given as a whole number, i.e 10=10%)
+ country : Optional[str]
+ Country for which interest rate is given
+
+ Example
+ -------
+ >>> from openbb import obb
+ >>> obb.economy.long_term_interest_rate()
+ """ # noqa: E501
+
+ return self._run(
+ "/economy/long_term_interest_rate",
+ **filter_inputs(
+ provider_choices={
+ "provider": provider,
+ },
+ standard_params={
+ "start_date": start_date,
+ "end_date": end_date,
+ },
+ extra_params=kwargs,
+ )
+ )
+
+ @validate
def money_measures(
self,
start_date: Annotated[
@@ -572,7 +741,7 @@ class ROUTER_economy(Container):
provider: Optional[Literal["federal_reserve"]] = None,
**kwargs
) -> OBBject:
- """Money Measures (M1/M2 and components.
+ """Money Measures (M1/M2 and components).
Parameters
----------
@@ -697,6 +866,90 @@ class ROUTER_economy(Container):
)
@validate
+ def short_term_interest_rate(
+ self,
+ 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:
+ """
+ Short-term interest rates are the rates at which short-term borrowings are effected between
+ financial institutions or the rate at which short-term government paper is issued or traded in the market.
+ Short-term interest rates are generally averages of daily rates, measured as a percentage.
+ Short-term interest rates are based on three-month money market rates where available.
+ Typical standardised names are "money market rate" and "treasury bill rate".
+
+
+ Parameters
+ ----------
+ 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['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']
+ Country to get GDP for. (provider: oecd)
+ frequency : Literal['monthly', 'quarterly', 'annual']
+ Frequency to get interest rate for for. (provider: oecd)
+
+ Returns
+ -------
+ OBBject
+ results : List[STIR]
+ 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.
+
+ STIR
+ ----
+ date : Optional[date]
+ The date of the data.
+ value : Optional[float]
+ Interest rate (given as a whole number, i.e 10=10%)
+ country : Optional[str]
+ Country for which interest rate is given
+
+ Example
+ -------
+ >>> from openbb import obb
+ >>> obb.economy.short_term_interest_rate()
+ """ # noqa: E501
+
+ return self._run(
+ "/economy/short_term_interest_rate",
+ **filter_inputs(
+ provider_choices={
+ "provider": provider,
+ },
+ standard_params={
+ "start_date": start_date,
+ "end_date": end_date,
+ },
+ extra_params=kwargs,
+ )
+ )
+
+ @validate
def unemployment(
self,
start_date: Annotated[
diff --git a/openbb_platform/openbb/package/index.py b/openbb_platform/openbb/package/index.py
index 1caae2443c9..1982a7bfb2d 100644
--- a/openbb_platform/openbb/package/index.py
+++ b/openbb_platform/openbb/package/index.py
@@ -4,7 +4,7 @@ import datetime
from typing import List, Literal, Optional, Union
from warnings import simplefilter, warn
-from openbb_core.app.deprecation import OpenBBDeprecatedSince41
+from openbb_core.app.deprecation import OpenBBDeprecationWarning
from openbb_core.app.model.custom_parameter import OpenBBCustomParameter
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
@@ -158,8 +158,8 @@ class ROUTER_index(Container):
@validate
@deprecated(
- "This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.5.",
- category=OpenBBDeprecatedSince41,
+ "This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.",
+ category=OpenBBDeprecationWarning,
)
def market(
self,
@@ -274,7 +274,7 @@ class ROUTER_index(Container):
simplefilter("always", DeprecationWarning)
warn(
- "This endpoint is deprecated since v4.1 and will be removed in v4.3; Use `/index/price/historical` instead.",
+ "This endpoint is deprecated; use `/index/price/historical` instead. Deprecated in OpenBB Platform V4.1 to be removed in V4.3.",
category=DeprecationWarning,
stacklevel=2,
)
diff --git a/openbb_platform/openbb/package/module_map.json b/openbb_platform/openbb/package/module_map.json
index a14f4bc4032..37ed693004c 100644
--- a/openbb_platform/openbb/package/module_map.json
+++ b/openbb_platform/openbb/package/module_map.json
@@ -17,6 +17,7 @@
"derivatives_options_unusual": "/derivatives/options/unusual",
"economy": "/economy",
"economy_calendar": "/economy/calendar",
+ "economy_composite_leading_indicator": "/economy/composite_leading_indicator",
"economy_cpi": "/economy/cpi",
"economy_fred_search": "/economy/fred_search",
"economy_fred_series": "/economy/fred_series",
@@ -24,8 +25,11 @@
"economy_gdp_forecast": "/economy/gdp/forecast",
"economy_gdp_nominal": "/economy/gdp/nominal",
"economy_gdp_real": "/economy/gdp/real",
+ "economy_long_term_interest_rate": "/economy/long_term_interest_rate",
"economy_money_measures": "/economy/money_measures",
"economy_risk_premium": "/economy/risk_premium",
+ "economy_short_term_interest_rate": "/economy/short_term_interest_rate",
+ "economy_unemployment": "/economy/unemployment",
"equity": "/equity",
"equity_calendar": "/equity/calendar",
"equity_calendar_dividend": "/equity/calendar/dividend",