Calculating Zero-Coupon Bond Yield with Rateslib and Face Value
Summary
The document describes an attempt to calculate the effective annual yield to maturity of a zero-coupon bond using rateslib. It provides a settlement date, a 30/360 day-count convention, and a bond setup with annual frequency, zero coupon, and a specified notional. The reported yield from the library call is negative, while the author expects a positive result based on a spreadsheet calculation, prompting a question about face value and the calculation inputs.
This is a practical fixed-income troubleshooting example, but it contains no answer or confirmed diagnosis. It does not explain how the quoted price is scaled against notional, whether the price is clean or dirty, or how the library interprets the bond's dates and day-count convention. The disagreement therefore cannot be resolved from the prompt alone. Matching a yield calculation requires checking the price units, settlement and maturity schedule, convention settings, and the precise yield definition used by each tool.
Key ideas
- The document presents a rateslib setup for valuing a zero-coupon bond and calculating yield to maturity.
- It reports a negative library result despite a positive yield expected from a spreadsheet calculation.
- The question focuses on how face value or notional may affect the calculation.
- The prompt does not provide a diagnosis or establish which price and yield conventions should be used.
Tags
Full text
# How do i change face value of a Zero Coupon Bond in Python rateslib?
# How do i change face value of a Zero Coupon Bond in Python rateslib?
I'm currently trying to calculate the effective annual YTM of a Zero Coupon Bond with the following data:
- Settlement date (also date of valuation): 2024/07/11
- day count basis: 30/360
With the following code:
```
from rateslib import FixedRateBond
import datetime as dt
bond = FixedRateBond(
effective=dt.datetime(2024, 7, 1),
termination=dt.datetime(2024, 9, 30),
frequency="A",
convention="30360",
fixed_rate=0,
notional=113.1425
)
bond.ytm(price=102.010, settlement=dt.datetime(2024,7,11), dirty=True)
```
I get a result of -8.646625824122834, which it should be 60.32 when doing the calculation in Excel. What am i doing wrong here?
Thanks in advance!Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.