diff options
author | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-05-26 07:07:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-26 14:07:51 +0000 |
commit | 5fecd9de96b5c5434a199c2fdf2c9d888b32040f (patch) | |
tree | 4879630670da8a716fcc990c10a125183143031f | |
parent | 5ff4d8907ce2fd0c2bd59fd1c6a0daae4656c43b (diff) |
[BugFix] Add `json_schema_extra` With Choices To Provider 'period' Field (#6451)
* add json_schema_extra choices to provider 'period' field
* black
* unused imports
* mypy
* pytest
---------
Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
25 files changed, 1499 insertions, 1018 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/balance_sheet_growth.py b/openbb_platform/core/openbb_core/provider/standard_models/balance_sheet_growth.py index e2aff45cb5d..429a623407c 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/balance_sheet_growth.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/balance_sheet_growth.py @@ -1,23 +1,26 @@ """Balance Sheet Statement Growth Standard Model.""" from datetime import date as dateType -from typing import List, Optional, Set, Union +from typing import Optional from pydantic import Field, field_validator from openbb_core.provider.abstract.data import Data from openbb_core.provider.abstract.query_params import QueryParams -from openbb_core.provider.utils.descriptions import ( - DATA_DESCRIPTIONS, - QUERY_DESCRIPTIONS, -) +from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS class BalanceSheetGrowthQueryParams(QueryParams): """Balance Sheet Statement Growth Query.""" symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) - limit: int = Field(default=10, description=QUERY_DESCRIPTIONS.get("limit", "")) + period: str = Field( + default="annual", + description=QUERY_DESCRIPTIONS.get("period", ""), + ) + limit: Optional[int] = Field( + default=10, description=QUERY_DESCRIPTIONS.get("limit", "") + ) @field_validator("symbol", mode="before", check_fields=False) @classmethod @@ -25,113 +28,20 @@ class BalanceSheetGrowthQueryParams(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 BalanceSheetGrowthData(Data): """Balance Sheet Statement Growth Data.""" - symbol: Optional[str] = Field( - default=None, description=DATA_DESCRIPTIONS.get("symbol", "") - ) - date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", "")) - period: str = Field(description="Reporting period.") - growth_cash_and_cash_equivalents: float = Field( - description="Growth rate of cash and cash equivalents." - ) - growth_short_term_investments: float = Field( - description="Growth rate of short-term investments." - ) - growth_cash_and_short_term_investments: float = Field( - description="Growth rate of cash and short-term investments." - ) - growth_net_receivables: float = Field(description="Growth rate of net receivables.") - growth_inventory: float = Field(description="Growth rate of inventory.") - growth_other_current_assets: float = Field( - description="Growth rate of other current assets." - ) - growth_total_current_assets: float = Field( - description="Growth rate of total current assets." - ) - growth_property_plant_equipment_net: float = Field( - description="Growth rate of net property, plant, and equipment." - ) - growth_goodwill: float = Field(description="Growth rate of goodwill.") - growth_intangible_assets: float = Field( - description="Growth rate of intangible assets." - ) - growth_goodwill_and_intangible_assets: float = Field( - description="Growth rate of goodwill and intangible assets." - ) - growth_long_term_investments: float = Field( - description="Growth rate of long-term investments." - ) - growth_tax_assets: float = Field(description="Growth rate of tax assets.") - growth_other_non_current_assets: float = Field( - description="Growth rate of other non-current assets." - ) - growth_total_non_current_assets: float = Field( - description="Growth rate of total non-current assets." - ) - growth_other_assets: float = Field(description="Growth rate of other assets.") - growth_total_assets: float = Field(description="Growth rate of total assets.") - growth_account_payables: float = Field( - description="Growth rate of accounts payable." - ) - growth_short_term_debt: float = Field(description="Growth rate of short-term debt.") - growth_tax_payables: float = Field(description="Growth rate of tax payables.") - growth_deferred_revenue: float = Field( - description="Growth rate of deferred revenue." + period_ending: dateType = Field(description="The end date of the reporting period.") + fiscal_period: Optional[str] = Field( + description="The fiscal period of the report.", default=None ) - growth_other_current_liabilities: float = Field( - description="Growth rate of other current liabilities." + fiscal_year: Optional[int] = Field( + description="The fiscal year of the fiscal period.", default=None ) - growth_total_current_liabilities: float = Field( - description="Growth rate of total current liabilities." - ) - growth_long_term_debt: float = Field(description="Growth rate of long-term debt.") - growth_deferred_revenue_non_current: float = Field( - description="Growth rate of non-current deferred revenue." - ) - growth_deferrred_tax_liabilities_non_current: float = Field( - description="Growth rate of non-current deferred tax liabilities." - ) - growth_other_non_current_liabilities: float = Field( - description="Growth rate of other non-current liabilities." - ) - growth_total_non_current_liabilities: float = Field( - description="Growth rate of total non-current liabilities." - ) - growth_other_liabilities: float = Field( - description="Growth rate of other liabilities." - ) - growth_total_liabilities: float = Field( - description="Growth rate of total liabilities." - ) - growth_common_stock: float = Field(description="Growth rate of common stock.") - growth_retained_earnings: float = Field( - description="Growth rate of retained earnings." - ) - growth_accumulated_other_comprehensive_income_loss: float = Field( - description="Growth rate of accumulated other comprehensive income/loss." - ) - growth_othertotal_stockholders_equity: float = Field( - description="Growth rate of other total stockholders' equity." - ) - growth_total_stockholders_equity: float = Field( - description="Growth rate of total stockholders' equity." - ) - growth_total_liabilities_and_stockholders_equity: float = Field( - description="Growth rate of total liabilities and stockholders' equity." - ) - growth_total_investments: float = Field( - description="Growth rate of total investments." - ) - growth_total_debt: float = Field(description="Growth rate of total debt.") - growth_net_debt: float = Field(description="Growth rate of net debt.") - - @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/cash_flow_growth.py b/openbb_platform/core/openbb_core/provider/standard_models/cash_flow_growth.py index 77dd5d5ef86..43d52fd3fbb 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/cash_flow_growth.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/cash_flow_growth.py @@ -1,23 +1,26 @@ """Cash Flow Statement Growth Standard Model.""" from datetime import date as dateType -from typing import List, Optional, Set, Union +from typing import Optional from pydantic import Field, field_validator from openbb_core.provider.abstract.data import Data from openbb_core.provider.abstract.query_params import QueryParams -from openbb_core.provider.utils.descriptions import ( - DATA_DESCRIPTIONS, - QUERY_DESCRIPTIONS, -) +from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS class CashFlowStatementGrowthQueryParams(QueryParams): """Cash Flow Statement Growth Query.""" symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) - limit: int = Field(default=10, description=QUERY_DESCRIPTIONS.get("limit", "")) + period: str = Field( + default="annual", + description=QUERY_DESCRIPTIONS.get("period", ""), + ) + limit: Optional[int] = Field( + default=10, description=QUERY_DESCRIPTIONS.get("limit", "") + ) @field_validator("symbol", mode="before", check_fields=False) @classmethod @@ -25,100 +28,20 @@ class CashFlowStatementGrowthQueryParams(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 CashFlowStatementGrowthData(Data): """Cash Flow Statement Growth Data.""" - symbol: Optional[str] = Field( - default=None, description=DATA_DESCRIPTIONS.get("symbol", "") - ) - date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", "")) - period: str = Field(description="Period the statement is returned for.") - growth_net_income: float = Field(description="Growth rate of net income.") - growth_depreciation_and_amortization: float = Field( - description="Growth rate of depreciation and amortization." - ) - growth_deferred_income_tax: float = Field( - description="Growth rate of deferred income tax." - ) - growth_stock_based_compensation: float = Field( - description="Growth rate of stock-based compensation." - ) - growth_change_in_working_capital: float = Field( - description="Growth rate of change in working capital." - ) - growth_accounts_receivables: float = Field( - description="Growth rate of accounts receivables." - ) - growth_inventory: float = Field(description="Growth rate of inventory.") - growth_accounts_payables: float = Field( - description="Growth rate of accounts payables." - ) - growth_other_working_capital: float = Field( - description="Growth rate of other working capital." - ) - growth_other_non_cash_items: float = Field( - description="Growth rate of other non-cash items." - ) - growth_net_cash_provided_by_operating_activities: float = Field( - description="Growth rate of net cash provided by operating activities." - ) - growth_investments_in_property_plant_and_equipment: float = Field( - description="Growth rate of investments in property, plant, and equipment." - ) - growth_acquisitions_net: float = Field( - description="Growth rate of net acquisitions." - ) - growth_purchases_of_investments: float = Field( - description="Growth rate of purchases of investments." + period_ending: dateType = Field(description="The end date of the reporting period.") + fiscal_period: Optional[str] = Field( + description="The fiscal period of the report.", default=None ) - growth_sales_maturities_of_investments: float = Field( - description="Growth rate of sales maturities of investments." + fiscal_year: Optional[int] = Field( + description="The fiscal year of the fiscal period.", default=None ) - growth_other_investing_activities: float = Field( - description="Growth rate of other investing activities." - ) - growth_net_cash_used_for_investing_activities: float = Field( - description="Growth rate of net cash used for investing activities." - ) - growth_debt_repayment: float = Field(description="Growth rate of debt repayment.") - growth_common_stock_issued: float = Field( - description="Growth rate of common stock issued." - ) - growth_common_stock_repurchased: float = Field( - description="Growth rate of common stock repurchased." - ) - growth_dividends_paid: float = Field(description="Growth rate of dividends paid.") - growth_other_financing_activities: float = Field( - description="Growth rate of other financing activities." - ) - growth_net_cash_used_provided_by_financing_activities: float = Field( - description="Growth rate of net cash used/provided by financing activities." - ) - growth_effect_of_forex_changes_on_cash: float = Field( - description="Growth rate of the effect of foreign exchange changes on cash." - ) - growth_net_change_in_cash: float = Field( - description="Growth rate of net change in cash." - ) - growth_cash_at_end_of_period: float = Field( - description="Growth rate of cash at the end of the period." - ) - growth_cash_at_beginning_of_period: float = Field( - description="Growth rate of cash at the beginning of the period." - ) - growth_operating_cash_flow: float = Field( - description="Growth rate of operating cash flow." - ) - growth_capital_expenditure: float = Field( - description="Growth rate of capital expenditure." - ) - growth_free_cash_flow: float = Field(description="Growth rate of free cash flow.") - - @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/income_statement_growth.py b/openbb_platform/core/openbb_core/provider/standard_models/income_statement_growth.py index 31fa068f7bc..6bb031db0a9 100644 --- a/openbb_platform/core/openbb_core/provider/standard_models/income_statement_growth.py +++ b/openbb_platform/core/openbb_core/provider/standard_models/income_statement_growth.py @@ -1,25 +1,25 @@ """Income Statement Growth 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 from openbb_core.provider.abstract.data import Data from openbb_core.provider.abstract.query_params import QueryParams -from openbb_core.provider.utils.descriptions import ( - DATA_DESCRIPTIONS, - QUERY_DESCRIPTIONS, -) +from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS class IncomeStatementGrowthQueryParams(QueryParams): """Income Statement Growth Query.""" symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", "")) - limit: int = Field(default=10, description=QUERY_DESCRIPTIONS.get("limit", "")) - period: Literal["annual", "quarter"] = Field( - default="annual", description=QUERY_DESCRIPTIONS.get("period", "") + period: str = Field( + default="annual", + description=QUERY_DESCRIPTIONS.get("period", ""), + ) + limit: Optional[int] = Field( + default=10, description=QUERY_DESCRIPTIONS.get("limit", "") ) @field_validator("symbol", mode="before", check_fields=False) @@ -38,86 +38,10 @@ class IncomeStatementGrowthQueryParams(QueryParams): class IncomeStatementGrowthData(Data): """Income Statement Growth Data.""" - symbol: Optional[str] = Field( - default=None, description=DATA_DESCRIPTIONS.get("symbol", "") - ) - date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", "")) - period: str = Field(description="Period the statement is returned for.") - growth_revenue: float = Field(description="Growth rate of total revenue.") - growth_cost_of_revenue: float = Field( - description="Growth rate of cost of goods sold." - ) - growth_gross_profit: float = Field(description="Growth rate of gross profit.") - growth_gross_profit_ratio: float = Field( - description="Growth rate of gross profit as a percentage of revenue." - ) - growth_research_and_development_expenses: float = Field( - description="Growth rate of expenses on research and development." - ) - growth_general_and_administrative_expenses: float = Field( - description="Growth rate of general and administrative expenses." - ) - growth_selling_and_marketing_expenses: float = Field( - description="Growth rate of expenses on selling and marketing activities." - ) - growth_other_expenses: float = Field( - description="Growth rate of other operating expenses." - ) - growth_operating_expenses: float = Field( - description="Growth rate of total operating expenses." - ) - growth_cost_and_expenses: float = Field( - description="Growth rate of total costs and expenses." - ) - growth_interest_expense: float = Field( - description="Growth rate of interest expenses." - ) - growth_depreciation_and_amortization: float = Field( - description="Growth rate of depreciation and amortization expenses." - ) - growth_ebitda: float = Field( - description="Growth rate of Earnings Before Interest, Taxes, Depreciation, and Amortization." - ) - growth_ebitda_ratio: float = Field( - description="Growth rate of EBITDA as a percentage of revenue." + period_ending: dateType = Field(description="The end date of the reporting period.") + fiscal_period: Optional[str] = Field( + description="The fiscal period of the report.", default=None ) - growth_operating_income: float = Field( - description="Growth rate of operating income." + fiscal_year: Optional[int] = Field( + description="The fiscal year of the fiscal period.", default=None ) - growth_operating_income_ratio: float = Field( - description="Growth rate of operating income as a percentage of revenue." - ) - growth_total_other_income_expenses_net: float = Field( - description="Growth rate of net total other income and expenses." - ) - growth_income_before_tax: float = Field( - description="Growth rate of income before taxes." - ) - growth_income_before_tax_ratio: float = Field( - description="Growth rate of income before taxes as a percentage of revenue." - ) - growth_income_tax_expense: float = Field( - description="Growth rate of income tax expenses." - ) - growth_net_income: float = Field(description="Growth rate of net income.") - growth_net_income_ratio: float = Field( - description="Growth rate of net income as a percentage of revenue." - ) - growth_eps: float = Field(description="Growth rate of Earnings Per Share (EPS).") - growth_eps_diluted: float = Field( - description="Growth rate of diluted Earnings Per Share (EPS)." - ) - growth_weighted_average_shs_out: float = Field( - description="Growth rate of weighted average shares outstanding." - ) - growth_weighted_average_shs_out_dil: float = Field( - description="Growth rate of diluted weighted average shares outstanding." - ) - - @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/extensions/equity/integration/test_equity_api.py b/openbb_platform/extensions/equity/integration/test_equity_api.py index ffe57cda534..544bb8052b1 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_api.py +++ b/openbb_platform/extensions/equity/integration/test_equity_api.py @@ -87,7 +87,7 @@ def test_equity_fundamental_balance(params, headers): @parametrize( "params", - [({"symbol": "AAPL", "limit": 10, "provider": "fmp"})], + [({"symbol": "AAPL", "limit": 10, "provider": "fmp", "period": "annual"})], ) @pytest.mark.integration def test_equity_fundamental_balance_growth(params, headers): @@ -231,7 +231,7 @@ def test_equity_fundamental_cash(params, headers): @parametrize( "params", - [({"symbol": "AAPL", "limit": 10, "provider": "fmp"})], + [({"symbol": "AAPL", "limit": 10, "provider": "fmp", "period": "annual"})], ) @pytest.mark.integration def test_equity_fundamental_cash_growth(params, headers): diff --git a/openbb_platform/extensions/equity/integration/test_equity_python.py b/openbb_platform/extensions/equity/integration/test_equity_python.py index 0e167cae8df..cb836f59019 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_python.py +++ b/openbb_platform/extensions/equity/integration/test_equity_python.py @@ -83,7 +83,7 @@ def test_equity_fundamental_balance(params, obb): @parametrize( "params", [ - ({"symbol": "AAPL", "limit": 10, "provider": "fmp"}), + ({"symbol": "AAPL", "limit": 10, "provider": "fmp", "period": "annual"}), ], ) @pytest.mark.integration @@ -214,7 +214,7 @@ def test_equity_fundamental_cash(params, obb): @parametrize( "params", [ - ({"symbol": "AAPL", "limit": 10, "provider": "fmp"}), + ({"symbol": "AAPL", "limit": 10, "provider": "fmp", "period": "annual"}), ], ) @pytest.mark.integration diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index 61835911e88..0c01282e9c1 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -10500,7 +10500,10 @@ "description": "None", |