From 2d078f07400fa3fb264170a92cfbbed5a268a843 Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Tue, 14 May 2024 23:50:22 -0700 Subject: [PATCH] black --- .../provider/standard_models/yield_curve.py | 40 +++++++++++++++++++ .../government/government_router.py | 16 +++++++- 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 openbb_platform/core/openbb_core/provider/standard_models/yield_curve.py diff --git a/openbb_platform/core/openbb_core/provider/standard_models/yield_curve.py b/openbb_platform/core/openbb_core/provider/standard_models/yield_curve.py new file mode 100644 index 000000000000..6621b68bc6e3 --- /dev/null +++ b/openbb_platform/core/openbb_core/provider/standard_models/yield_curve.py @@ -0,0 +1,40 @@ +"""Yield Curve Standard Model.""" + +from datetime import date as dateType +from typing import Optional + +from pydantic import Field + +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, +) + + +class YieldCurveQueryParams(QueryParams): + """Yield Curve Query.""" + + country: Optional[str] = Field( + default=None, description=QUERY_DESCRIPTIONS.get("country", "") + ) + date: Optional[str] = Field( + default=None, + description=QUERY_DESCRIPTIONS.get("date", "") + + " By default is the current data.", + ) + + +class YieldCurveData(Data): + """Yield Curve Data.""" + + date: Optional[dateType] = Field( + default=None, + description=DATA_DESCRIPTIONS.get("date", ""), + ) + maturity: str = Field(description="Maturity length of the security.") + rate: float = Field( + description="The yield as a normalized percent (0.05 is 5%)", + json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100}, + ) diff --git a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py index eb97388ad9c3..d65fd411e46d 100644 --- a/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py +++ b/openbb_platform/extensions/fixedincome/openbb_fixedincome/government/government_router.py @@ -22,9 +22,21 @@ examples=[ APIEx(parameters={"provider": "federal_reserve"}), APIEx(parameters={"date": "2023-05-01,2024-05-01", "provider": "fmp"}), - APIEx(parameters={"date": "2023-05-01", "country": "united_kingdom", "provider": "econdb"}), + APIEx( + parameters={ + "date": "2023-05-01", + "country": "united_kingdom", + "provider": "econdb", + } + ), APIEx(parameters={"provider": "ecb", "yield_curve_type": "par_yield"}), - APIEx(parameters={"provider": "fred", "yield_curve_type": "real", "date": "2023-05-01,2024-05-01"}) + APIEx( + parameters={ + "provider": "fred", + "yield_curve_type": "real", + "date": "2023-05-01,2024-05-01", + } + ), ], ) async def yield_curve(