diff --git a/openbb_platform/platform/provider/openbb_provider/standard_models/bond_prices.py b/openbb_platform/platform/provider/openbb_provider/standard_models/bond_prices.py new file mode 100644 index 000000000000..bb65dd9978b3 --- /dev/null +++ b/openbb_platform/platform/provider/openbb_provider/standard_models/bond_prices.py @@ -0,0 +1,127 @@ +"""Bond Prices data model.""" + +from datetime import ( + date as dateType, +) +from typing import List, Optional, Union + +from pydantic import Field, field_validator + +from openbb_provider.abstract.data import Data +from openbb_provider.abstract.query_params import QueryParams + + +class BondPricesQueryParams(QueryParams): + """Bond Prices Query Params.""" + + country: Optional[str] = Field( + default=None, + description="Country of the bond issuer. Matches partial name.", + ) + issuer_name: Optional[str] = Field( + default=None, + description="Name of the issuer. Returns partial matches and is case insensitive.", + ) + isin: Optional[Union[List, str]] = Field( + default=None, + description="International Securities Identification Number(s) of the bond(s).", + ) + lei: Optional[str] = Field( + default=None, + description="Legal Entity Identifier of the issuing entity.", + ) + currency: Optional[Union[List, str]] = Field( + default=None, + description="Currency of the bond. Formatted as the 3-letter ISO 4217 code (e.g. GBP, EUR, USD).", + ) + coupon_min: Optional[float] = Field( + default=None, + description="Minimum coupon rate of the bond.", + ) + coupon_max: Optional[float] = Field( + default=None, + description="Maximum coupon rate of the bond.", + ) + issued_amount_min: Optional[int] = Field( + default=None, + description="Minimum issued amount of the bond.", + ) + issued_amount_max: Optional[str] = Field( + default=None, + description="Maximum issued amount of the bond.", + ) + maturity_date_min: Optional[dateType] = Field( + default=None, + description="Minimum maturity date of the bond.", + ) + maturity_date_max: Optional[dateType] = Field( + default=None, + description="Maximum maturity date of the bond.", + ) + ytm_max: Optional[float] = Field( + default=None, + description="Maximum yield to maturity of the bond.", + ) + ytm_min: Optional[float] = Field( + default=None, + description="Minimum yield to maturity of the bond.", + ) + + @field_validator("isin", "currency", "lei", mode="before", check_fields=False) + @classmethod + def validate_upper_case(cls, v): + """Convert the field to uppercase and convert a list to a query string.""" + if isinstance(v, str): + return v.upper() + v = ",".join([symbol.upper() for symbol in list(v)]) + return v if v else None + + +class BondPricesData(Data): + """Bond Prices Data.""" + + isin: Optional[str] = Field( + default=None, + description="International Securities Identification Number of the bond.", + ) + lei: Optional[str] = Field( + default=None, + description="Legal Entity Identifier of the issuing entity.", + ) + figi: Optional[str] = Field(default=None, description="FIGI of the bond.") + cusip: Optional[str] = Field( + default=None, + description="CUSIP of the bond.", + ) + coupon_rate: Optional[float] = Field( + default=None, + description="Coupon rate of the bond.", + ) + price: Optional[float] = Field( + default=None, + description="Price of the bond.", + ) + current_yield: Optional[float] = Field( + default=None, + description="Current yield of the bond.", + ) + ytm: Optional[float] = Field( + default=None, + description="Yield to maturity of the bond.", + ) + ytw: Optional[float] = Field( + default=None, + description="Yield to worst of the bond.", + ) + duration: Optional[float] = Field( + default=None, + description="Duration of the bond.", + ) + maturity_date: Optional[dateType] = Field( + default=None, + description="Maturity date of the bond.", + ) + call_date: Optional[dateType] = Field( + default=None, + description="The nearest call date of the bond.", + ) diff --git a/openbb_platform/platform/provider/openbb_provider/standard_models/bond_reference.py b/openbb_platform/platform/provider/openbb_provider/standard_models/bond_reference.py new file mode 100644 index 000000000000..180e36efb4a4 --- /dev/null +++ b/openbb_platform/platform/provider/openbb_provider/standard_models/bond_reference.py @@ -0,0 +1,91 @@ +"""Bond Reference data model.""" + +from datetime import ( + date as dateType, +) +from typing import List, Optional, Union + +from pydantic import Field, field_validator + +from openbb_provider.abstract.data import Data +from openbb_provider.abstract.query_params import QueryParams + + +class BondReferenceQueryParams(QueryParams): + """Bond Reference Query Params.""" + + country: Optional[str] = Field( + default=None, + description="Country of the bond issuer. Matches partial name.", + ) + issuer_name: Optional[str] = Field( + default=None, + description="Name of the issuer. Returns partial matches and is case insensitive.", + ) + isin: Optional[Union[List, str]] = Field( + default=None, + description="International Securities Identification Number(s) of the bond(s).", + ) + lei: Optional[str] = Field( + default=None, + description="Legal Entity Identifier of the issuing entity.", + ) + currency: Optional[Union[List, str]] = Field( + default=None, + description="Currency of the bond. Formatted as the 3-letter ISO 4217 code (e.g. GBP, EUR, USD).", + ) + coupon_min: Optional[float] = Field( + default=None, + description="Minimum coupon rate of the bond.", + ) + coupon_max: Optional[float] = Field( + default=None, + description="Maximum coupon rate of the bond.", + ) + issued_amount_min: Optional[int] = Field( + default=None, + description="Minimum issued amount of the bond.", + ) + issued_amount_max: Optional[str] = Field( + default=None, + description="Maximum issued amount of the bond.", + ) + maturity_date_min: Optional[dateType] = Field( + default=None, + description="Minimum maturity date of the bond.", + ) + maturity_date_max: Optional[dateType] = Field( + default=None, + description="Maximum maturity date of the bond.", + ) + + @field_validator("isin", "currency", "lei", mode="before", check_fields=False) + @classmethod + def validate_upper_case(cls, v): + """Convert the field to uppercase and convert a list to a query string.""" + if isinstance(v, str): + return v.upper() + v = ",".join([symbol.upper() for symbol in list(v)]) + return v if v else None + + +class BondReferenceData(Data): + """Bond Reference Search Data.""" + + isin: Optional[str] = Field( + default=None, + description="International Securities Identification Number of the bond.", + ) + lei: Optional[str] = Field( + default=None, + description="Legal Entity Identifier of the issuing entity.", + ) + figi: Optional[str] = Field(default=None, description="FIGI of the bond.") + cusip: Optional[str] = Field( + default=None, + description="CUSIP of the bond.", + ) + coupon_rate: Optional[float] = Field( + default=None, + description="Coupon rate of the bond.", + ) diff --git a/openbb_platform/platform/provider/openbb_provider/standard_models/bond_trades.py b/openbb_platform/platform/provider/openbb_provider/standard_models/bond_trades.py new file mode 100644 index 000000000000..143c11f32835 --- /dev/null +++ b/openbb_platform/platform/provider/openbb_provider/standard_models/bond_trades.py @@ -0,0 +1,91 @@ +"""Bond Trades data model.""" + +from datetime import ( + date as dateType, + datetime, +) +from typing import Literal, Optional, Union + +from pydantic import Field, field_validator + +from openbb_provider.abstract.data import Data +from openbb_provider.abstract.query_params import QueryParams +from openbb_provider.utils.descriptions import DATA_DESCRIPTIONS, QUERY_DESCRIPTIONS + + +class BondTradesQueryParams(QueryParams): + """Bond Trades Query Params.""" + + country: Optional[str] = Field( + default=None, + description="Country of the bond issuer. Matches partial name.", + ) + isin: Optional[str] = Field( + default=None, + description="ISIN of the bond.", + ) + issuer_type: Optional[Literal["government", "corporate", "municipal"]] = Field( + default=None, + description="Type of bond issuer.", + ) + notional_currency: Optional[str] = Field( + default=None, + description=""" + Currency of the bond, which might differ from the currency of the trade. + Formatted as the 3-letter ISO 4217 code (e.g. GBP, EUR, USD). + """, + ) + start_date: Optional[Union[dateType, str]] = Field( + default=None, + description=( + QUERY_DESCRIPTIONS.get("start_date", "") + + " YYYY-MM-DD or ISO-8601 format. E.g. 2023-01-14T10:55:00Z" + ), + ) + end_date: Optional[Union[dateType, str]] = Field( + default=None, + description=( + QUERY_DESCRIPTIONS.get("end_date", "") + + " YYYY-MM-DD or ISO-8601 format. E.g. 2023-01-14T10:55:00Z" + ), + ) + + @field_validator("isin", "notional_currency", mode="before", check_fields=False) + @classmethod + def validate_upper_case(cls, v): + """Enforce upper case for fields.""" + return v.upper() if v else None + + +class BondTradesData(Data): + """Bond Trades Data.""" + + trade_date: Optional[Union[dateType, datetime]] = Field( + default=None, + description="Date of the transaction.", + ) + isin: Optional[str] = Field( + default=None, + description="ISIN of the bond.", + ) + figi: Optional[str] = Field(default=None, description="FIGI of the bond.") + cusip: Optional[str] = Field( + default=None, + description="CUSIP of the bond.", + ) + price: Optional[float] = Field( + default=None, + description="Price of the bond.", + ) + current_yield: Optional[float] = Field( + default=None, + description="Current yield of the bond.", + ) + coupon_rate: Optional[float] = Field( + default=None, + description="Coupon rate of the bond.", + ) + volume: Optional[int] = Field( + default=None, + description=DATA_DESCRIPTIONS.get("volume", ""), + ) diff --git a/openbb_platform/platform/provider/openbb_provider/utils/descriptions.py b/openbb_platform/platform/provider/openbb_provider/utils/descriptions.py index 9a400b94a9b2..4681cf91a02f 100644 --- a/openbb_platform/platform/provider/openbb_provider/utils/descriptions.py +++ b/openbb_platform/platform/provider/openbb_provider/utils/descriptions.py @@ -18,11 +18,11 @@ DATA_DESCRIPTIONS = { "symbol": "Symbol representing the entity requested in the data.", "date": "The date of the data.", - "open": "The open price of the symbol.", - "high": "The high price of the symbol.", - "low": "The low price of the symbol.", - "close": "The close price of the symbol.", - "volume": "The volume of the symbol.", - "adj_close": "The adjusted close price of the symbol.", - "vwap": "Volume Weighted Average Price of the symbol.", + "open": "The open price.", + "high": "The high price.", + "low": "The low price.", + "close": "The close price.", + "volume": "The trading volume.", + "adj_close": "The adjusted close price.", + "vwap": "Volume Weighted Average Price over the period.", }