diff options
author | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-03-21 02:26:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-21 09:26:19 +0000 |
commit | 78695fa6de3ee46182f5531f620d6607fd0cc1d9 (patch) | |
tree | ad50950e53602ca86958e74deeb64d6c13994213 | |
parent | bb6efdffdc39f97f4c7c6c3a6f4bbd13432e329a (diff) |
[BugFix] Return FMP Error Messages (#6237)
* response callback and equity quote
* merge branch develop
* fix some more
* static files
* test param
* executive comp
* some more fetchers
* test cassette
* black
* another one
* some more
* etf equity exposure
* price_performance
* black
* ruff
* test params
* more test params
---------
Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
28 files changed, 1094 insertions, 882 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/analyst_estimates.py b/openbb_platform/core/openbb_core/provider/standard_models/analyst_estimates.py index 4a4e76c796d..4e49cdbf98d 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/analyst_estimates.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/analyst_estimates.py @@ -1,7 +1,7 @@ """Analyst Estimates Standard Model.""" from datetime import date as dateType -from typing import List, Literal, Optional, Set, Union +from typing import Optional from pydantic import Field, field_validator @@ -17,10 +17,6 @@ class AnalystEstimatesQueryParams(QueryParams): """Analyst Estimates Query.""" symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) - period: Literal["quarter", "annual"] = Field( - default="annual", description=QUERY_DESCRIPTIONS.get("period", "") - ) - limit: int = Field(default=30, description=QUERY_DESCRIPTIONS.get("limit", "")) @field_validator("symbol", mode="before", check_fields=False) @classmethod @@ -28,57 +24,69 @@ class AnalystEstimatesQueryParams(QueryParams): """Convert field to uppercase.""" return v.upper() - @field_validator("period", mode="before", check_fields=False) - @classmethod - def to_lower(cls, v: Optional[str]) -> Optional[str]: - """Convert field to lowercase.""" - return v.lower() if v else v - class AnalystEstimatesData(Data): """Analyst Estimates data.""" symbol: str = Field(description=DATA_DESCRIPTIONS.get("symbol", "")) date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", "")) - estimated_revenue_low: ForceInt = Field(description="Estimated revenue low.") - estimated_revenue_high: ForceInt = Field(description="Estimated revenue high.") - estimated_revenue_avg: ForceInt = Field(description="Estimated revenue average.") - estimated_ebitda_low: ForceInt = Field(description="Estimated EBITDA low.") - estimated_ebitda_high: ForceInt = Field(description="Estimated EBITDA high.") - estimated_ebitda_avg: ForceInt = Field(description="Estimated EBITDA average.") - estimated_ebit_low: ForceInt = Field(description="Estimated EBIT low.") - estimated_ebit_high: ForceInt = Field(description="Estimated EBIT high.") - estimated_ebit_avg: ForceInt = Field(description="Estimated EBIT average.") - estimated_net_income_low: ForceInt = Field(description="Estimated net income low.") - estimated_net_income_high: ForceInt = Field( - description="Estimated net income high." - ) - estimated_net_income_avg: ForceInt = Field( - description="Estimated net income average." - ) - estimated_sga_expense_low: ForceInt = Field( - description="Estimated SGA expense low." - ) - estimated_sga_expense_high: ForceInt = Field( - description="Estimated SGA expense high." - ) - estimated_sga_expense_avg: ForceInt = Field( - description="Estimated SGA expense average." - ) - estimated_eps_avg: float = Field(description="Estimated EPS average.") - estimated_eps_high: float = Field(description="Estimated EPS high.") - estimated_eps_low: float = Field(description="Estimated EPS low.") - number_analyst_estimated_revenue: ForceInt = Field( - description="Number of analysts who estimated revenue." - ) - number_analysts_estimated_eps: ForceInt = Field( - description="Number of analysts who estimated EPS." + estimated_revenue_low: Optional[ForceInt] = Field( + default=None, description="Estimated revenue low." + ) + estimated_revenue_high: Optional[ForceInt] = Field( + default=None, description="Estimated revenue high." + ) + estimated_revenue_avg: Optional[ForceInt] = Field( + default=None, description="Estimated revenue average." + ) + estimated_sga_expense_low: Optional[ForceInt] = Field( + default=None, description="Estimated SGA expense low." + ) + estimated_sga_expense_high: Optional[ForceInt] = Field( + default=None, description="Estimated SGA expense high." + ) + estimated_sga_expense_avg: Optional[ForceInt] = Field( + default=None, description="Estimated SGA expense average." + ) + estimated_ebitda_low: Optional[ForceInt] = Field( + default=None, description="Estimated EBITDA low." + ) + estimated_ebitda_high: Optional[ForceInt] = Field( + default=None, description="Estimated EBITDA high." + ) + estimated_ebitda_avg: Optional[ForceInt] = Field( + default=None, description="Estimated EBITDA average." + ) + estimated_ebit_low: Optional[ForceInt] = Field( + default=None, description="Estimated EBIT low." + ) + estimated_ebit_high: Optional[ForceInt] = Field( + default=None, description="Estimated EBIT high." + ) + estimated_ebit_avg: Optional[ForceInt] = Field( + default=None, description="Estimated EBIT average." + ) + estimated_net_income_low: Optional[ForceInt] = Field( + default=None, description="Estimated net income low." + ) + estimated_net_income_high: Optional[ForceInt] = Field( + default=None, description="Estimated net income high." + ) + estimated_net_income_avg: Optional[ForceInt] = Field( + default=None, description="Estimated net income average." + ) + estimated_eps_avg: Optional[float] = Field( + default=None, description="Estimated EPS average." + ) + estimated_eps_high: Optional[float] = Field( + default=None, description="Estimated EPS high." + ) + estimated_eps_low: Optional[float] = Field( + default=None, description="Estimated EPS low." + ) + number_analyst_estimated_revenue: Optional[ForceInt] = Field( + default=None, description="Number of analysts who estimated revenue." + ) + number_analysts_estimated_eps: Optional[ForceInt] = Field( + default=None, description="Number of analysts who estimated EPS." ) - - @field_validator("symbol", mode="before", check_fields=False) - @classmethod - def to_upper(cls, v: Union[str, List[str], Set[str]]): - """Convert field to uppercase.""" - if isinstance(v, str): - return v.upper() - return ",".join([symbol.upper() for symbol in list(v)]) if v else None diff --git a/openbb_platform/core/openbb_core/provider/standard_models/executive_compensation.py b/openbb_platform/core/openbb_core/provider/standard_models/executive_compensation.py index 7cf723f74ba..e2dea12ed25 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/executive_compensation.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/executive_compensation.py @@ -1,10 +1,6 @@ """Executive Compensation Standard Model.""" -from datetime import ( - date as dateType, - datetime, -) -from typing import List, Optional, Set, Union +from typing import Optional from pydantic import Field, NonNegativeFloat, field_validator @@ -20,14 +16,6 @@ class ExecutiveCompensationQueryParams(QueryParams): """Executive Compensation Query.""" symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) - start_date: Optional[dateType] = Field( - default=None, - description=QUERY_DESCRIPTIONS.get("start_date", ""), - ) - end_date: Optional[dateType] = Field( - default=None, - description=QUERY_DESCRIPTIONS.get("end_date", ""), - ) @field_validator("symbol", mode="before", check_fields=False) @classmethod @@ -41,29 +29,31 @@ class ExecutiveCompensationData(Data): symbol: str = Field(description=DATA_DESCRIPTIONS.get("symbol", "")) cik: Optional[str] = Field( - default=None, - description=DATA_DESCRIPTIONS.get("cik", ""), + default=None, description=DATA_DESCRIPTIONS.get("cik", "") ) - filing_date: dateType = Field(description="Date of the filing.") - accepted_date: datetime = Field(description="Date the filing was accepted.") - name_and_position: str = Field(description="Name and position of the executive.") - year: int = Field(description="Year of the compensation.") - salary: NonNegativeFloat = Field(description="Salary of the executive.") - bonus: NonNegativeFloat = Field(description="Bonus of the executive.") - stock_award: NonNegativeFloat = Field(description="Stock award of the executive.") - incentive_plan_compensation: NonNegativeFloat = Field( - description="Incentive plan compensation of the executive." + company_name: Optional[str] = Field( + default=None, description="The name of the company." ) - all_other_compensation: NonNegativeFloat = Field( - description="All other compensation of the executive." + industry: Optional[str] = Field( + default=None, description="The industry of the company." + ) + year: Optional[int] = Field(default=None, description="Year of the compensation.") + name_and_position: Optional[str] = Field( + default=None, description="Name and position." + ) + salary: Optional[NonNegativeFloat] = Field(default=None, description="Salary.") + bonus: Optional[NonNegativeFloat] = Field( + default=None, description="Bonus payments." + ) + stock_award: Optional[NonNegativeFloat] = Field( + default=None, description="Stock awards." + ) + incentive_plan_compensation: Optional[NonNegativeFloat] = Field( + default=None, description="Incentive plan compensation." + ) + all_other_compensation: Optional[NonNegativeFloat] = Field( + default=None, description="All other compensation." + ) + total: Optional[NonNegativeFloat] = Field( + default=None, description="Total compensation." ) - total: NonNegativeFloat = Field(description="Total compensation of the executive.") - url: str = Field(description="URL of the filing data.") - - @field_validator("symbol", mode="before", check_fields=False) - @classmethod - def to_upper(cls, v: Union[str, List[str], Set[str]]): - """Convert field to uppercase.""" - if isinstance(v, str): - return v.upper() - return ",".join([symbol.upper() for symbol in list(v)]) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/historical_splits.py b/openbb_platform/core/openbb_core/provider/standard_models/historical_splits.py index 504e3a92d53..d088c65a1ee 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/historical_splits.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/historical_splits.py @@ -1,6 +1,7 @@ """Historical Splits Standard Model.""" from datetime import date as dateType +from typing import Optional from pydantic import Field, field_validator @@ -28,8 +29,15 @@ class HistoricalSplitsData(Data): """Historical Splits Data.""" date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", "")) - label: str = Field(description="Label of the historical stock splits.") - numerator: float = Field(description="Numerator of the historical stock splits.") - denominator: float = Field( - description="Denominator of the historical stock splits." + numerator: Optional[float] = Field( + default=None, + description="Numerator of the split.", + ) + denominator: Optional[float] = Field( + default=None, + description="Denominator of the split.", + ) + split_ratio: Optional[str] = Field( + default=None, + description="Split ratio.", ) diff --git a/openbb_platform/extensions/equity/integration/test_equity_api.py b/openbb_platform/extensions/equity/integration/test_equity_api.py index 97b56b20045..f30e471e073 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_api.py +++ b/openbb_platform/extensions/equity/integration/test_equity_api.py @@ -235,8 +235,7 @@ def test_equity_fundamental_cash_growth(params, headers): ( { "symbol": "AAPL", - "start_date": "2020-01-01", - "end_date": "2021-01-01", + "year": 2022, "provider": "fmp", } ), @@ -244,12 +243,14 @@ def test_equity_fundamental_cash_growth(params, headers): { "symbol": "AAPL", "provider": "fmp", + "year": None, } ), ( { "symbol": "AAPL,MSFT", "provider": "fmp", + "year": None, } ), ], diff --git a/openbb_platform/extensions/equity/integration/test_equity_python.py b/openbb_platform/extensions/equity/integration/test_equity_python.py index 8b802da8dcf..671df076840 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_python.py +++ b/openbb_platform/extensions/equity/integration/test_equity_python.py @@ -217,8 +217,7 @@ def test_equity_fundamental_cash_growth(params, obb): ( { "symbol": "AAPL", - "start_date": "2020-01-01", - "end_date": "2021-01-01", + "year": 2022, "provider": "fmp", } ), @@ -226,12 +225,14 @@ def test_equity_fundamental_cash_growth(params, obb): { "symbol": "AAPL", "provider": "fmp", + "year": None, } ), ( { "symbol": "AAPL,MSFT", "provider": "fmp", + "year": None, } ), ], diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index 96162f453bf..13c7fda420d 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -4310,7 +4310,7 @@ { "name": "symbol", "type": "Union[str, List[str]]", - "description": "Symbol to get data for. Multiple items allowed for provider(s): benzinga.", + "description": "Symbol to get data for. Multiple items allowed for provider(s): benzinga, fmp.", "default": null, "optional": true }, @@ -4657,12 +4657,21 @@ "standard": [ { "name": "symbol", - "type": "str", - "description": "Symbol to get data for.", + "type": "Union[str, List[str]]", + "description": "Symbol to get data for. Multiple items allowed for provider(s): fmp.", "default": "", "optional": false }, { + "name": "provider", + "type": "Literal['fmp']", + "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": "period", "type": "Literal['quarter', 'annual']", "description": "Time period of the data to return.", @@ -4673,18 +4682,10 @@ "name": "limit", "type": "int", "description": "The number of data entries to return.", - "default": 30, - "optional": true - }, - { - "name": "provider", - "type": "Literal['fmp']", - "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", + "default": null, "optional": true } - ], - "fmp": [] + ] }, "returns": { "OBBject": [ @@ -4735,141 +4736,141 @@ "name": "estimated_revenue_low", "type": "int", "description": "Estimated revenue low.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_revenue_high", "type": "int", "description": "Estimated revenue high.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_revenue_avg", "type": "int", "description": "Estimated revenue average.", - "default": "", - "optional": false + "default": null, + "optional": true + }, + { + "name": "estimated_sga_expense_low", + "type": "int", + "description": "Estimated SGA expense low.", + "default": null, + "optional": true + }, + { + "name": "estimated_sga_expense_high", + "type": "int", + "description": "Estimated SGA expense high.", + "default": null, + "optional": true + }, + { + "name": "estimated_sga_expense_avg", + "type": "int", + "description": "Estimated SGA expense average.", + "default": null, + "optional": true }, { "name": "estimated_ebitda_low", "type": "int", "description": "Estimated EBITDA low.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_ebitda_high", "type": "int", "description": "Estimated EBITDA high.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_ebitda_avg", "type": "int", "description": "Estimated EBITDA average.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_ebit_low", "type": "int", "description": "Estimated EBIT low.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_ebit_high", "type": "int", "description": "Estimated EBIT high.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_ebit_avg", "type": "int", "description": "Estimated EBIT average.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_net_income_low", "type": "int", "description": "Estimated net income low.", - "default": "", - "optional": false + "default": null, + "optional": true }, { "name": "estimated_net_income_high", "type": "int", |