feat: financial ratios

This commit is contained in:
Diogo Sousa
2024-02-09 15:38:28 +00:00
parent 0b507e3a53
commit 283c9a8808
3 changed files with 14 additions and 6 deletions

View File

@@ -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):

View File

@@ -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."""

View File

@@ -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: