Zero Coupon Gilts Pricers#
Zero Coupon Bond Pricers#
This section describes both public and private API for fift_analytics zero coupon bond pricers.
All methods and functions described within this section are used to re-evaluate zero coupon bond prices.
- fift_analytics.gilts.zero_coupon.zc_pricers.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.gilts.zero_coupon.zc_pricers.validate_inputs(face_value: float, maturity_date: str, settlement_date: str | None) None#
Validate input parameters for correctness.
- Parameters:
face_value -- Face value of the bond.
maturity_date -- Maturity date in 'YYYY-MM-DD' format.
settlement_date -- Settlement date in 'YYYY-MM-DD' format or None.
- Raises:
ValueError -- If any input is invalid (e.g., negative face value or invalid dates).
- fift_analytics.gilts.zero_coupon.zc_pricers.parse_settlement_date(settlement_date: str | None) datetime#
Parse and return the settlement date. Defaults to today if not provided.
- Parameters:
settlement_date -- Settlement date in 'YYYY-MM-DD' format or None.
- Returns:
Settlement date as a datetime object.
- fift_analytics.gilts.zero_coupon.zc_pricers.parse_maturity_date(maturity_date: str) datetime#
Parse and return the maturity date.
- Parameters:
maturity_date -- Maturity date in 'YYYY-MM-DD' format.
- Returns:
Maturity date as a datetime object.
- fift_analytics.gilts.zero_coupon.zc_pricers.calculate_time_to_maturity(settlement_date: datetime, maturity_date: datetime) float#
Calculate time to maturity in years using Actual/Actual (ISMA) day count convention.
- Parameters:
settlement_date -- Settlement date as a datetime object.
maturity_date -- Maturity date as a datetime object.
- Returns:
Time to maturity in years.
- Raises:
ValueError -- If the maturity date is earlier than or equal to the settlement date.
- fift_analytics.gilts.zero_coupon.zc_pricers.is_leap_year(year: int) bool#
Check if a given year is a leap year.
- Parameters:
year -- Year to check.
- Returns:
True if leap year, False otherwise.
- fift_analytics.gilts.zero_coupon.zc_pricers.compute_continuous_price(face_value: float, annual_yield: float, time_to_maturity: float) float#
Compute the price of a zero-coupon gilt using continuous compounding.
- Parameters:
face_value (float) -- Face value of the bond.
annual_yield (float) -- Annual yield to maturity as a decimal (e.g., 0.04 for 4% or -0.01 for -1%).
time_to_maturity (float) -- Time to maturity in years.
- Returns:
The price of the zero-coupon gilt rounded to 2 decimal places.
- Return type:
float
- Calculation Steps:
If time_to_maturity is very small (approaching zero), return face value directly.
Compute intermediate result using the continuous compounding formula: P = F * exp(-r * t)
Round intermediate result to six decimal places for precision.
Round final result to two decimal places for financial reporting standards.
- Example:
>>> compute_continuous_price(1000, -0.01, 10) 1051.27