fift_analytics.zero_coupon#

GILTS Zero Coupon Bonds#

Zero Coupon Bond functionalities for bond price modelling.

fift_analytics.zero_coupon.get_zero_coupon_gilt_price(face_value: float, annual_yield: float, maturity_date: str, settlement_date: str | None = None) float#

Calculate the theoretical price of a zero-coupon gilt using continuous compounding.

Parameters:
  • face_value (float) -- The face value (maturity value) of the bond.

  • annual_yield (float) -- The annual yield to maturity as a decimal (e.g., 0.04 for 4% or -0.01 for -1%).

  • maturity_date (str) -- The maturity date of the bond in 'YYYY-MM-DD' format.

  • settlement_date (Optional[str]) -- The settlement date in 'YYYY-MM-DD' format. Defaults to today if not provided.

Raises:

ValueError -- If inputs are invalid (e.g., negative face value or invalid dates).

Returns:

The theoretical price of the zero-coupon gilt rounded to 2 decimal places.

Return type:

float

Example:
>>> face_value = 1000  # £1,000 face value
>>> annual_yield = -0.01  # -1% annual yield
>>> maturity_date = "2025-02-19"  # Maturity date: February 17, 2035
>>> settlement_date = "2025-02-16"  # Settlement date: February 17, 2025
>>> price = get_zero_coupon_gilt_price(face_value, annual_yield, maturity_date, settlement_date)
>>> print(f"The theoretical price of the zero-coupon gilt is: £{price:.2f}")
fift_analytics.zero_coupon.calculate_zero_coupon_bond_convexity(time_to_maturity: float, annual_yield: float, compounding_frequency: int = 2) float#

Calculate the convexity of a zero-coupon bond using DMO-aligned methodology.

Parameters:
  • time_to_maturity (float) -- Time to maturity in years.

  • annual_yield (float) -- Yield-to-maturity as a decimal (e.g., 0.05 for 5%, -0.01 for -1%).

  • compounding_frequency (int) -- Number of compounding periods per year (default is 2 for semi-annual).

Returns:

Convexity of the zero-coupon bond.

Return type:

float

Example::
>>> calculate_zero_coupon_bond_convexity(5, 0.05)
26.455026455026455
fift_analytics.zero_coupon.calculate_zero_coupon_bond_duration(time_to_maturity: float, ytm: float, duration_type: Literal['Macaulay', 'Modified'], compounding_frequency: Annotated[int | None, Gt(gt=0)] = None) dict#

Calculate the Macaulay or Modified durations of a zero-coupon bond, allowing for negative yields.

Parameters:
  • time_to_maturity (float) -- Time to maturity in years.

  • ytm (float) -- Yield-to-maturity as a decimal (e.g., 0.05 for 5%, -0.01 for -1%).

  • duration_type (str) -- type of duration calculated: can be only "Macaulay", "Modified".

  • compounding_frequency (Optional[int]) -- Number of compounding periods per year (e.g., 1 for annual, 2 for semi-annual). If None, assumes continuous compounding.

Returns:

The calculated duration

Return type:

float

Example::
>>> calculate_zero_coupon_bond_duration(5, -0.01, "Modified", 2)
5.025125628140703
fift_analytics.zero_coupon.calculate_zero_coupon_bond_dv01(face_value: float, yield_to_maturity: float, maturity_date: str, settlement_date: str | None = None, maturity_threshold: float = 0.019178082191780823, n_decimals: int | None = None) float#

Calculate the DV01 of a zero-coupon bond using the get_zero_coupon_gilt_price function.

Parameters:
  • face_value -- Face value of the bond.

  • yield_to_maturity -- Annual yield to maturity as a decimal (e.g., 0.05 for 5%).

  • maturity_date -- The maturity date of the bond in 'YYYY-MM-DD' format.

  • settlement_date -- The settlement date in 'YYYY-MM-DD' format. Defaults to today if not provided.

  • maturity_threshold -- Threshold (in years) below which DV01 is considered zero (default is 7 days).

  • n_decimals -- Decimal precision of the returned dv01.

Returns:

DV01 of the zero-coupon bond.