Skip to content

Commit

Permalink
[BugFix] Add json_schema_extra With Choices To Provider 'period' Fi…
Browse files Browse the repository at this point in the history
…eld (#6451)

* add json_schema_extra choices to provider 'period' field

* black

* unused imports

* mypy

* pytest

---------

Co-authored-by: Igor Radovanovic <[email protected]>
  • Loading branch information
deeleeramone and IgorWounds authored May 26, 2024
1 parent 5ff4d89 commit 5fecd9d
Show file tree
Hide file tree
Showing 25 changed files with 1,499 additions and 1,018 deletions.
Original file line number Diff line number Diff line change
@@ -1,137 +1,47 @@
"""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
def to_upper(cls, v: str):
"""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
Original file line number Diff line number Diff line change
@@ -1,124 +1,47 @@
"""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
def to_upper(cls, v: str) -> str:
"""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
Loading

0 comments on commit 5fecd9d

Please sign in to comment.