mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-26 11:12:50 +00:00
feat: balancesheet
This commit is contained in:
@@ -30,12 +30,7 @@ class BalanceSheetQueryParams(QueryParams):
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def upper_symbol(cls, v: str):
|
||||
"""Convert symbol to uppercase."""
|
||||
if "," in v:
|
||||
_warn(
|
||||
f"{QUERY_DESCRIPTIONS.get('symbol_list_warning', '')} {v.split(',')[0].upper()}"
|
||||
)
|
||||
return v.split(",")[0].upper() if "," in v else v.upper()
|
||||
return v
|
||||
|
||||
|
||||
class BalanceSheetData(Data):
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
"""Field validators"""
|
||||
|
||||
|
||||
def check_single(v: str) -> str:
|
||||
"""Check that string is not comma-separated string"""
|
||||
if "," in v:
|
||||
raise ValueError("multiple values are not allowed")
|
||||
return v
|
||||
@@ -12,8 +12,9 @@ from openbb_core.provider.standard_models.balance_sheet import (
|
||||
BalanceSheetData,
|
||||
BalanceSheetQueryParams,
|
||||
)
|
||||
from openbb_core.provider.utils.validators import check_single
|
||||
from openbb_fmp.utils.helpers import create_url, get_data_many
|
||||
from pydantic import Field, model_validator
|
||||
from pydantic import Field, field_validator, model_validator
|
||||
|
||||
|
||||
class FMPBalanceSheetQueryParams(BalanceSheetQueryParams):
|
||||
@@ -24,6 +25,11 @@ class FMPBalanceSheetQueryParams(BalanceSheetQueryParams):
|
||||
|
||||
period: Optional[Literal["annual", "quarter"]] = Field(default="annual")
|
||||
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def validate_symbol(cls, v: str) -> str:
|
||||
return check_single(v)
|
||||
|
||||
|
||||
class FMPBalanceSheetData(BalanceSheetData):
|
||||
"""FMP Balance Sheet Data."""
|
||||
|
||||
@@ -10,6 +10,7 @@ from openbb_core.provider.standard_models.balance_sheet import (
|
||||
BalanceSheetQueryParams,
|
||||
)
|
||||
from openbb_core.provider.utils.helpers import ClientResponse, amake_requests
|
||||
from openbb_core.provider.utils.validators import check_single
|
||||
from openbb_intrinio.utils.helpers import get_data_one
|
||||
from pydantic import Field, field_validator, model_validator
|
||||
|
||||
@@ -36,6 +37,11 @@ class IntrinioBalanceSheetQueryParams(BalanceSheetQueryParams):
|
||||
v = "FY" if v == "annual" else "QTR"
|
||||
return v
|
||||
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def validate_symbol(cls, v: str) -> str:
|
||||
return check_single(v)
|
||||
|
||||
@field_validator("symbol", mode="after", check_fields=False)
|
||||
@classmethod
|
||||
def handle_symbol(cls, v) -> str:
|
||||
|
||||
@@ -9,8 +9,9 @@ from openbb_core.provider.standard_models.balance_sheet import (
|
||||
BalanceSheetQueryParams,
|
||||
)
|
||||
from openbb_core.provider.utils.helpers import get_querystring
|
||||
from openbb_core.provider.utils.validators import check_single
|
||||
from openbb_polygon.utils.helpers import get_data_many
|
||||
from pydantic import Field
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
|
||||
class PolygonBalanceSheetQueryParams(BalanceSheetQueryParams):
|
||||
@@ -70,6 +71,11 @@ class PolygonBalanceSheetQueryParams(BalanceSheetQueryParams):
|
||||
default=None, description="Sort of the financial statement."
|
||||
)
|
||||
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def validate_symbol(cls, v: str) -> str:
|
||||
return check_single(v)
|
||||
|
||||
|
||||
class PolygonBalanceSheetData(BalanceSheetData):
|
||||
"""Polygon Balance Sheet Statement Data."""
|
||||
|
||||
@@ -11,6 +11,7 @@ from openbb_core.provider.standard_models.balance_sheet import (
|
||||
)
|
||||
from openbb_core.provider.utils.errors import EmptyDataError
|
||||
from openbb_core.provider.utils.helpers import to_snake_case
|
||||
from openbb_core.provider.utils.validators import check_single
|
||||
from pydantic import Field, field_validator
|
||||
from yfinance import Ticker
|
||||
|
||||
@@ -38,6 +39,11 @@ class YFinanceBalanceSheetData(BalanceSheetData):
|
||||
"total_equity_non_controlling_interests": "total_equity_gross_minority_interest",
|
||||
}
|
||||
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def validate_symbol(cls, v: str) -> str:
|
||||
return check_single(v)
|
||||
|
||||
@field_validator("period_ending", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def date_validate(cls, v): # pylint: disable=E0213
|
||||
|
||||
Reference in New Issue
Block a user