Skip to content

Commit

Permalink
[Enhancement] Fixed Income Enhancements (#6490)
Browse files Browse the repository at this point in the history
* improve effr and move sofr to fixedincome.rate

* federal_reserve default start date

* fred cassette

* commercial paper

* cp series map

* update sofr and add federal_reserve to endpoint

* examples

* update ameribor

* maturity_dict

* add overnight bank funding rate

* add federal reserve to obfr

* pop footnoteId

* central bank holdings descriptions

* move moody's bond indices to the bond_indices endpoint

* add it to the INDEX_CHOICES

* improve hqm

* handle none

* add treasury minus fed funds to yield curve

* static assets

* estr

* description

* missed file in commit

* second return statement
  • Loading branch information
deeleeramone authored Jun 18, 2024
1 parent d465f22 commit 1a990ba
Show file tree
Hide file tree
Showing 62 changed files with 7,604 additions and 3,527 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)


class AMERIBORQueryParams(QueryParams):
class AmeriborQueryParams(QueryParams):
"""AMERIBOR Query."""

start_date: Optional[dateType] = Field(
Expand All @@ -26,8 +26,19 @@ class AMERIBORQueryParams(QueryParams):
)


class AMERIBORData(Data):
class AmeriborData(Data):
"""AMERIBOR Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
rate: Optional[float] = Field(description="AMERIBOR rate.")
symbol: Optional[str] = Field(
default=None, description=DATA_DESCRIPTIONS.get("symbol", "")
)
maturity: str = Field(description="Maturity length of the item.")
rate: float = Field(
description="Interest rate.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
title: Optional[str] = Field(
default=None,
description="Title of the series.",
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from datetime import (
date as dateType,
)
from typing import Literal, Optional
from typing import Optional

from pydantic import Field, field_validator
from pydantic import Field

from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
Expand All @@ -26,28 +26,21 @@ class CommercialPaperParams(QueryParams):
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)
maturity: Literal["overnight", "7d", "15d", "30d", "60d", "90d"] = Field(
default="30d",
description="The maturity.",
)
category: Literal["asset_backed", "financial", "nonfinancial"] = Field(
default="financial",
description="The category.",
)
grade: Literal["aa", "a2_p2"] = Field(
default="aa",
description="The grade.",
)

@field_validator("maturity", "category", "grade", 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 CommercialPaperData(Data):
"""Commercial Paper Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
rate: Optional[float] = Field(description="Commercial Paper Rate.")
symbol: Optional[str] = Field(
default=None, description=DATA_DESCRIPTIONS.get("symbol", "")
)
maturity: str = Field(description="Maturity length of the item.")
rate: float = Field(
description="Interest rate.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
title: Optional[str] = Field(
default=None,
description="Title of the series.",
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""Euro Short Term Rate 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 EuroShortTermRateQueryParams(QueryParams):
"""Euro Short Term Rate Query."""

start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)


class EuroShortTermRateData(Data):
"""Euro Short Term Rate Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
rate: float = Field(
description="Volume-weighted trimmed mean rate.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
percentile_25: Optional[float] = Field(
default=None,
description="Rate at 25th percentile of volume.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
percentile_75: Optional[float] = Field(
default=None,
description="Rate at 75th percentile of volume.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
volume: Optional[float] = Field(
default=None,
description=DATA_DESCRIPTIONS.get("volume", "")+ " (Millions of €EUR).",
json_schema_extra={
"x-unit_measurement": "currency",
"x-frontend_multiply": 1e6,
},
)
transactions: Optional[int] = Field(
default=None,
description="Number of transactions.",
)
number_of_banks: Optional[int] = Field(
default=None,
description="Number of active banks.",
)
large_bank_share_of_volume: Optional[float] = Field(
default=None,
description="The percent of volume attributable to the 5 largest active banks.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Federal Funds Rate 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 FederalFundsRateQueryParams(QueryParams):
"""Federal Funds Rate Query."""

start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)


class FederalFundsRateData(Data):
"""Federal Funds Rate Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
rate: float = Field(
description="Effective federal funds rate.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
target_range_upper: Optional[float] = Field(
default=None,
description="Upper bound of the target range.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
target_range_lower: Optional[float] = Field(
default=None,
description="Lower bound of the target range.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
percentile_1: Optional[float] = Field(
default=None,
description="1st percentile of the distribution.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
percentile_25: Optional[float] = Field(
default=None,
description="25th percentile of the distribution.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
percentile_75: Optional[float] = Field(
default=None,
description="75th percentile of the distribution.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
percentile_99: Optional[float] = Field(
default=None,
description="99th percentile of the distribution.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
volume: Optional[float] = Field(
default=None,
description=DATA_DESCRIPTIONS.get("volume", "")
+ "The notional volume of transactions (Billions of $).",
json_schema_extra={
"x-unit_measurement": "currency",
"x-frontend_multiply": 1e9,
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from datetime import (
date as dateType,
)
from typing import Literal, Optional
from typing import Optional, Union

from pydantic import Field, field_validator
from pydantic import Field

from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
Expand All @@ -18,26 +18,18 @@
class HighQualityMarketCorporateBondQueryParams(QueryParams):
"""High Quality Market Corporate Bond Query."""

date: Optional[dateType] = Field(
date: Optional[Union[dateType, str]] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("date", ""),
)
yield_curve: Literal["spot", "par"] = Field(
default="spot",
description="The yield curve type.",
)

@field_validator("yield_curve", 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 HighQualityMarketCorporateBondData(Data):
"""High Quality Market Corporate Bond Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
rate: Optional[float] = Field(description="HighQualityMarketCorporateBond Rate.")
rate: float = Field(
description="Interest rate.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
maturity: str = Field(description="Maturity.")
yield_curve: Literal["spot", "par"] = Field(description="The yield curve type.")
Loading

0 comments on commit 1a990ba

Please sign in to comment.