summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanglewood <85772166+deeleeramone@users.noreply.github.com>2024-05-20 12:03:54 -0700
committerGitHub <noreply@github.com>2024-05-20 19:03:54 +0000
commitbffd88f96c5c986e973c93f0201eb69af42bf3e4 (patch)
treea392ab5b99af89e69b270fe3b137f34b076ff89c
parente29223737497e8b9d48c1b71a2fe7998b12ef1c0 (diff)
[Feature] Forward EBITDA (#6433)
* forward ebitda * codespell * sort intrinio output * get * list instead of dict --------- Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
-rw-r--r--openbb_platform/core/openbb_core/provider/standard_models/forward_ebitda_estimates.py75
-rw-r--r--openbb_platform/extensions/equity/integration/test_equity_api.py33
-rw-r--r--openbb_platform/extensions/equity/integration/test_equity_python.py30
-rw-r--r--openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py30
-rw-r--r--openbb_platform/openbb/assets/reference.json230
-rw-r--r--openbb_platform/openbb/package/equity_estimates.py119
-rw-r--r--openbb_platform/providers/fmp/openbb_fmp/__init__.py2
-rw-r--r--openbb_platform/providers/fmp/openbb_fmp/models/forward_ebitda_estimates.py150
-rw-r--r--openbb_platform/providers/fmp/tests/record/http/test_fmp_fetchers/test_fmp_equity_forward_ebitda_fetcher.yaml269
-rw-r--r--openbb_platform/providers/fmp/tests/test_fmp_fetchers.py16
-rw-r--r--openbb_platform/providers/intrinio/openbb_intrinio/__init__.py4
-rw-r--r--openbb_platform/providers/intrinio/openbb_intrinio/models/forward_ebitda_estimates.py194
-rw-r--r--openbb_platform/providers/intrinio/openbb_intrinio/models/forward_pe_estimates.py4
-rw-r--r--openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_forward_ebitda_fetcher.yaml109
-rw-r--r--openbb_platform/providers/intrinio/tests/test_intrinio_fetchers.py13
15 files changed, 1274 insertions, 4 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/forward_ebitda_estimates.py b/openbb_platform/core/openbb_core/provider/standard_models/forward_ebitda_estimates.py
new file mode 100644
index 00000000000..1fb19e8468b
--- /dev/null
+++ b/openbb_platform/core/openbb_core/provider/standard_models/forward_ebitda_estimates.py
@@ -0,0 +1,75 @@
+"""Forward EBITDA Estimates Standard Model."""
+
+from datetime import date as dateType
+from typing import Optional, Union
+
+from pydantic import Field, field_validator
+
+from openbb_core.provider.abstract.data import Data, ForceInt
+from openbb_core.provider.abstract.query_params import QueryParams
+from openbb_core.provider.utils.descriptions import (
+ DATA_DESCRIPTIONS,
+ QUERY_DESCRIPTIONS,
+)
+
+
+class ForwardEbitdaEstimatesQueryParams(QueryParams):
+ """Forward EBITDA Estimates Query Parameters."""
+
+ symbol: Optional[str] = Field(
+ default=None,
+ description=QUERY_DESCRIPTIONS["symbol"],
+ )
+
+ @field_validator("symbol", mode="before", check_fields=False)
+ @classmethod
+ def to_upper(cls, v):
+ """Convert field to uppercase."""
+ return v.upper() if v else None
+
+
+class ForwardEbitdaEstimatesData(Data):
+ """Forward EBITDA Estimates Data."""
+
+ symbol: str = Field(description=DATA_DESCRIPTIONS.get("symbol", ""))
+ name: Optional[str] = Field(default=None, description="Name of the entity.")
+ last_updated: Optional[dateType] = Field(
+ default=None,
+ description="The date of the last update.",
+ )
+ period_ending: Optional[dateType] = Field(
+ default=None,
+ description="The end date of the reporting period.",
+ )
+ fiscal_year: Optional[int] = Field(
+ default=None, description="Fiscal year for the estimate."
+ )
+ fiscal_period: Optional[str] = Field(
+ default=None, description="Fiscal quarter for the estimate."
+ )
+ calendar_year: Optional[int] = Field(
+ default=None, description="Calendar year for the estimate."
+ )
+ calendar_period: Optional[Union[int, str]] = Field(
+ default=None, description="Calendar quarter for the estimate."
+ )
+ low_estimate: Optional[ForceInt] = Field(
+ default=None, description="The EBITDA estimate low for the period."
+ )
+ high_estimate: Optional[ForceInt] = Field(
+ default=None, description="The EBITDA estimate high for the period."
+ )
+ mean: Optional[ForceInt] = Field(
+ default=None, description="The EBITDA estimate mean for the period."
+ )
+ median: Optional[ForceInt] = Field(
+ default=None, description="The EBITDA estimate median for the period."
+ )
+ standard_deviation: Optional[ForceInt] = Field(
+ default=None,
+ description="The EBITDA estimate standard deviation for the period.",
+ )
+ number_of_analysts: Optional[int] = Field(
+ default=None,
+ description="Number of analysts providing estimates for the period.",
+ )
diff --git a/openbb_platform/extensions/equity/integration/test_equity_api.py b/openbb_platform/extensions/equity/integration/test_equity_api.py
index 7ab3bb95c40..b559acfff9b 100644
--- a/openbb_platform/extensions/equity/integration/test_equity_api.py
+++ b/openbb_platform/extensions/equity/integration/test_equity_api.py
@@ -1982,3 +1982,36 @@ def test_equity_estimates_forward_pe(params, headers):
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
+
+
+@parametrize(
+ "params",
+ [
+ (
+ {
+ "symbol": "AAPL,MSFT",
+ "fiscal_period": "quarter",
+ "provider": "intrinio",
+ }
+ ),
+ (
+ {
+ "symbol": "AAPL,MSFT",
+ "fiscal_period": "annual",
+ "limit": None,
+ "include_historical": False,
+ "provider": "fmp",
+ }
+ ),
+ ],
+)
+@pytest.mark.integration
+def test_equity_estimates_forward_ebitda(params, headers):
+ """Test the equity estimates forward_ebitda endpoint."""
+ 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/equity/estimates/forward_ebitda?{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/equity/integration/test_equity_python.py b/openbb_platform/extensions/equity/integration/test_equity_python.py
index 344ea98e5d8..e3da7aa2f39 100644
--- a/openbb_platform/extensions/equity/integration/test_equity_python.py
+++ b/openbb_platform/extensions/equity/integration/test_equity_python.py
@@ -753,6 +753,36 @@ def test_equity_estimates_forward_eps(params, obb):
@parametrize(
"params",
[
+ (
+ {
+ "symbol": "AAPL,MSFT",
+ "fiscal_period": "quarter",
+ "provider": "intrinio",
+ }
+ ),
+ (
+ {
+ "symbol": "AAPL,MSFT",
+ "fiscal_period": "annual",
+ "limit": None,
+ "include_historical": False,
+ "provider": "fmp",
+ }
+ ),
+ ],
+)
+@pytest.mark.integration
+def test_equity_estimates_forward_ebitda(params, obb):
+ """Test the equity estimates forward EBITDA endpoint."""
+ result = obb.equity.estimates.forward_ebitda(**params)
+ assert result
+ assert isinstance(result, OBBject)
+ assert len(result.results) > 0
+
+
+@parametrize(
+ "params",
+ [
({"symbol": "AAPL", "period": "annual", "limit": 12, "provider": "fmp"}),
(
{
diff --git a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py
index 36aae0761b8..c779c2d8dc5 100644
--- a/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py
+++ b/openbb_platform/extensions/equity/openbb_equity/estimates/estimates_router.py
@@ -117,6 +117,36 @@ async def forward_sales(
@router.command(
+ model="ForwardEbitdaEstimates",
+ examples=[
+ APIEx(parameters={"provider": "intrinio"}),
+ APIEx(
+ parameters={
+ "symbol": "AAPL",
+ "fiscal_period": "annual",
+ "provider": "intrinio",
+ }
+ ),
+ APIEx(
+ parameters={
+ "symbol": "AAPL,MSFT",
+ "fiscal_period": "quarter",
+ "provider": "fmp",
+ }
+ ),
+ ],
+)
+async def forward_ebitda(
+ cc: CommandContext,
+ provider_choices: ProviderChoices,
+ standard_params: StandardParams,
+ extra_params: ExtraParams,
+) -> OBBject:
+ """Get forward EBITDA estimates."""
+ return await OBBject.from_query(Query(**locals()))
+
+
+@router.command(
model="ForwardEpsEstimates",
examples=[
APIEx(parameters={"symbol": "AAPL", "provider": "intrinio"}),
diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json
index ff6e4f6f446..adf31f04d3b 100644
--- a/openbb_platform/openbb/assets/reference.json
+++ b/openbb_platform/openbb/assets/reference.json
@@ -7651,6 +7651,234 @@
},
"model": "ForwardSalesEstimates"
},
+ "/equity/estimates/forward_ebitda": {
+ "deprecated": {
+ "flag": null,
+ "message": null
+ },
+ "description": "Get forward EBITDA estimates.",
+ "examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.equity.estimates.forward_ebitda(provider='intrinio')\nobb.equity.estimates.forward_ebitda(symbol='AAPL', fiscal_period=annual, provider='intrinio')\nobb.equity.estimates.forward_ebitda(symbol='AAPL,MSFT', fiscal_period=quarter, provider='fmp')\n```\n\n",
+ "parameters": {
+ "standard": [
+ {
+ "name": "symbol",
+ "type": "Union[str, List[str]]",
+ "description": "Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "provider",
+ "type": "Literal['fmp', 'intrinio']",
+ "description": "The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default.",
+ "default": "fmp",
+ "optional": true
+ }
+ ],
+ "fmp": [
+ {
+ "name": "fiscal_period",
+ "type": "Literal['annual', 'quarter']",
+ "description": "The future fiscal period to retrieve estimates for.",
+ "default": "annual",
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "limit",
+ "type": "int",
+ "description": "The number of data entries to return.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "include_historical",
+ "type": "bool",
+ "description": "If True, the data will include all past data and the limit will be ignored.",
+ "default": false,
+ "optional": true,
+ "choices": null
+ }
+ ],
+ "intrinio": [
+ {
+ "name": "fiscal_period",
+ "type": "Literal['annual', 'quarter']",
+ "description": "Filter for only full-year or quarterly estimates.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "estimate_type",
+ "type": "Literal['ebitda', 'ebit', 'enterprise_value', 'cash_flow_per_share', 'pretax_income']",
+ "description": "Limit the EBITDA estimates to this type.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ }
+ ]
+ },
+ "returns": {
+ "OBBject": [
+ {
+ "name": "results",
+ "type": "List[ForwardEbitdaEstimates]",
+ "description": "Serializable results."
+ },
+ {
+ "name": "provider",
+ "type": "Optional[Literal['fmp', 'intrinio']]",
+ "description": "Provider name."
+ },
+ {
+ "name": "warnings",
+ "type": "Optional[List[Warning_]]",
+ "description": "List of warnings."
+ },
+ {
+ "name": "chart",
+ "type": "Optional[Chart]",
+ "description": "Chart object."
+ },
+ {
+ "name": "extra",
+ "type": "Dict[str, Any]",
+ "description": "Extra info."
+ }
+ ]
+ },
+ "data": {
+ "standard": [
+ {
+ "name": "symbol",
+ "type": "str",
+ "description": "Symbol representing the entity requested in the data.",
+ "default": "",
+ "optional": false,
+ "choices": null
+ },
+ {
+ "name": "name",
+ "type": "str",
+ "description": "Name of the entity.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "last_updated",
+ "type": "date",
+ "description": "The date of the last update.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "period_ending",
+ "type": "date",
+ "description": "The end date of the reporting period.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "fiscal_year",
+ "type": "int",
+ "description": "Fiscal year for the estimate.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "fiscal_period",
+ "type": "str",
+ "description": "Fiscal quarter for the estimate.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "calendar_year",
+ "type": "int",
+ "description": "Calendar year for the estimate.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "calendar_period",
+ "type": "Union[int, str]",
+ "description": "Calendar quarter for the estimate.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "low_estimate",
+ "type": "int",
+ "description": "The EBITDA estimate low for the period.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "high_estimate",
+ "type": "int",
+ "description": "The EBITDA estimate high for the period.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "mean",
+ "type": "int",
+ "description": "The EBITDA estimate mean for the period.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "median",
+ "type": "int",
+ "description": "The EBITDA estimate median for the period.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "standard_deviation",
+ "type": "int",
+ "description": "The EBITDA estimate standard deviation for the period.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ },
+ {
+ "name": "number_of_analysts",
+ "type": "int",
+ "description": "Number of analysts providing estimates for the period.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ }
+ ],
+ "fmp": [],
+ "intrinio": [
+ {
+ "name": "conensus_type",
+ "type": "Literal['ebitda', 'ebit', 'enterprise_value', 'cash_flow_per_share', 'pretax_income']",
+ "description": "The type of estimate.",
+ "default": null,
+ "optional": true,
+ "choices": null
+ }
+ ]
+ },
+ "model": "ForwardEbitdaEstimates"
+ },
"/equity/estimates/forward_eps": {
"deprecated": {
"flag": null,
@@ -8052,7 +8280,7 @@
"choices": null
},
{
- "name": "last_udpated",
+ "name": "last_updated",
"type": "date",
"description": "The date the data was last updated.",
"default": null,
diff --git a/openbb_platform/openbb/package/equity_estimates.py b/openbb_platform/openbb/package/equity_estimates.py
index b93d171b6a1..f802e51594b 100644
--- a/openbb_platform/openbb/package/equity_estimates.py
+++ b/openbb_platform/openbb/package/equity_estimates.py
@@ -14,6 +14,7 @@ class ROUTER_equity_estimates(Container):
"""/equity/estimates
analyst_search
consensus
+ forward_ebitda
forward_eps
forward_pe
forward_sales
@@ -347,6 +348,122 @@ class ROUTER_equity_estimates(Container):
@exception_handler
@validate
+ def forward_ebitda(
+ self,
+ symbol: Annotated[
+ Union[str, None, List[Optional[str]]],
+ OpenBBField(
+ description="Symbol to get data for. Multiple comma separated items allowed for provider(s): fmp, intrinio."
+ ),
+ ] = None,
+ provider: Annotated[
+ Optional[Literal["fmp", "intrinio"]],
+ OpenBBField(
+ description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default."
+ ),
+ ] = None,
+ **kwargs
+ ) -> OBBject:
+ """Get forward EBITDA estimates.
+
+ Parameters
+ ----------
+ symbol : Union[str, None, List[Optional[str]]]
+ Symbol to get data for. Multiple comma separated items allowed for provider(s): fmp, intrinio.
+ provider : Optional[Literal['fmp', 'intrinio']]
+ The provider to use for the query, by default None.
+ If None, the provider specified in defaults is selected or 'fmp' if there is
+ no default.
+ fiscal_period : Optional[Literal['annual', 'quarter']]
+ The future fiscal period to retrieve estimates for. (provider: fmp);
+ Filter for only full-year or quarterly estimates. (provider: intrinio)
+ limit : Optional[int]
+ The number of data entries to return. (provider: fmp)
+ include_historical : bool
+ If True, the data will include all past data and the limit will be ignored. (provider: fmp)
+ estimate_type : Optional[Literal['ebitda', 'ebit', 'enterprise_value', 'cash_flow_per_share', 'pretax_income']]
+ Limit the EBITDA estimates to this type. (provider: intrinio)
+
+ Returns
+ -------
+ OBBject
+ results : List[ForwardEbitdaEstimates]
+ Serializable results.
+ provider : Optional[Literal['fmp', 'intrinio']]
+ Provider name.
+ warnings : Optional[List[Warning_]]
+ List of warnings.
+ chart : Optional[Chart]
+ Chart object.
+ extra : Dict[str, Any]
+ Extra info.
+
+ ForwardEbitdaEstimates
+ ----------------------
+ symbol : str
+ Symbol representing the entity requested in the data.
+ name : Optional[str]
+ Name of the entity.
+ last_updated : Optional[date]
+ The date of the last update.
+ period_ending : Optional[date]
+ The end date of the reporting period.
+ fiscal_year : Optional[int]
+ Fiscal year for the estimate.
+ fiscal_period : Optional[str]
+ Fiscal quarter for the estimate.
+ calendar_year : Optional[int]
+ Calendar year for the estimate.
+ calendar_period : Optional[Union[int, str]]
+ Calendar quarter for the estimate.
+ low_estimate : Optional[int]
+ The EBITDA estimate low for the period.
+ high_estimate : Optional[int]
+ The EBITDA estimate high for the period.
+ mean : Optional[int]
+ The EBITDA estimate mean for the period.
+ median : Optional[int]
+ The EBITDA estimate median for the period.
+ standard_deviation : Optional[int]
+ The EBITDA estimate standard deviation for the period.
+ number_of_analysts : Optional[int]
+ Number of analysts providing estimates for the period.
+ conensus_type : Optional[Literal['ebitda', 'ebit', 'enterprise_value', 'cash_flow_per_share', 'pretax_income']]
+ The type of estimate. (provider: intrinio)
+
+ Examples
+ --------
+ >>> from openbb import obb
+ >>> obb.equity.estimates.forward_ebitda(provider='intrinio')
+ >>> obb.equity.estimates.forward_ebitda(symbol='AAPL', fiscal_period='annual', provider='intrinio')
+ >>> obb.equity.estimates.forward_ebitda(symbol='AAPL,MSFT', fiscal_period='quarter', provider='fmp')
+ """ # noqa: E501
+
+ return self._run(
+ "/equity/estimates/forward_ebitda",
+ **filter_inputs(
+ provider_choices={
+ "provider": self._get_provider(
+ provider,
+ "/equity/estimates/forward_ebitda",
+ ("fmp", "intrinio"),
+ )
+ },
+ standard_params={
+ "symbol": symbol,
+ },
+ extra_params=kwargs,
+ info={
+ "symbol": {
+ "fmp": {"multiple_items_allowed": True},
+ "intrinio": {"multiple_items_allowed": True},
+ }
+ },
+ )
+ )
+
+ @exception_handler
+ @validate
def forward_eps(
self,
symbol: Annotated[
@@ -532,7 +649,7 @@ class ROUTER_equity_estimates(Container):
Estimated Forward PEG ratio for the next fiscal year. (provider: intrinio)
eps_ttm : Optional[float]
The latest trailing twelve months earnings per share. (provider: intrinio)
- last_udpated : Optional[date]
+ last_updated : Optional[date]
The date the data was last updated. (provider: intrinio)
Examples
diff --git a/openbb_platform/providers/fmp/openbb_fmp/__init__.py b/openbb_platform/providers/fmp/openbb_fmp/__init__.py
index cb98280528a..035339d4933 100644
--- a/openbb_platform/providers/fmp/openbb_fmp/__init__.py
+++ b/openbb_platform/providers/fmp/openbb_fmp/__init__.py
@@ -39,6 +39,7 @@ from openbb_fmp.models.etf_search import FMPEtfSearchFetcher
from openbb_fmp.models.etf_sectors import FMPEtfSectorsFetcher
from openbb_fmp.models.executive_compensation import FMPExecutiveCompensationFetcher
from openbb_fmp.models.financial_ratios import FMPFinancialRatiosFetcher
+from openbb_fmp.models.forward_ebitda_estimates import FMPForwardEbitdaEstimatesFetcher
from openbb_fmp.models.forward_eps_estimates import FMPForwardEpsEstimatesFetcher
from openbb_fmp.models.historical_dividends import FMPHistoricalDividendsFetcher
from openbb_fmp.models.historical_employees import FMPHistoricalEmployeesFetcher
@@ -107,6 +108,7 @@ stock market information (news, currencies, and stock prices).""",
"EtfSectors": FMPEtfSectorsFetcher,
"ExecutiveCompensation": FMPExecutiveCompensationFetcher,
"FinancialRatios": FMPFinan