mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-26 11:12:50 +00:00
feat: financial ratios
This commit is contained in:
@@ -30,11 +30,7 @@ class FinancialRatiosQueryParams(QueryParams):
|
||||
@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.upper()
|
||||
|
||||
|
||||
class FinancialRatiosData(Data):
|
||||
|
||||
@@ -13,7 +13,8 @@ from openbb_core.provider.utils.helpers import (
|
||||
amake_requests,
|
||||
to_snake_case,
|
||||
)
|
||||
from pydantic import Field, model_validator
|
||||
from openbb_core.provider.utils.validators import check_single
|
||||
from pydantic import Field, field_validator, model_validator
|
||||
|
||||
|
||||
class FMPFinancialRatiosQueryParams(FinancialRatiosQueryParams):
|
||||
@@ -26,6 +27,11 @@ class FMPFinancialRatiosQueryParams(FinancialRatiosQueryParams):
|
||||
default="annual", description=QUERY_DESCRIPTIONS.get("period", "")
|
||||
)
|
||||
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def validate_symbol(cls, v: str) -> str:
|
||||
return check_single(v)
|
||||
|
||||
|
||||
class FMPFinancialRatiosData(FinancialRatiosData):
|
||||
"""FMP Financial Ratios Data."""
|
||||
|
||||
@@ -10,6 +10,7 @@ from openbb_core.provider.standard_models.financial_ratios import (
|
||||
)
|
||||
from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS
|
||||
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
|
||||
|
||||
@@ -32,6 +33,11 @@ class IntrinioFinancialRatiosQueryParams(FinancialRatiosQueryParams):
|
||||
description="The specific fiscal year. Reports do not go beyond 2008.",
|
||||
)
|
||||
|
||||
@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:
|
||||
|
||||
Reference in New Issue
Block a user