|
From: Amir L. <ami...@gm...> - 2024-01-29 22:16:39
|
Hi Quantlib Users, I am having some difficulties in reconciling the yield to maturity calculation for a stream of cashflows. I have attached the jupyter notebook with my code. In the code, I take vectors of dates and amounts to create a BondLeg, to which I assign a dirty_value. I use ql.Cashflows.yieldRate to calculate an Annually Compounding and Continuous Compounding Yield to Maturity. I generate the yearFraction for the dates using the same daycount basis used to calculate the yields. I then use a PYOMO Non Linear Optimization Solver (ipopt) to solve for the yield to maturities using the yearfractions, cashflow amounts and dirty_value. The PYOMO annually compounding yield is within 1bp of the QuantLib yield. However, the QuantLib continuously compounding yield is 13bp higher than the PYOMO yield. Any help in figuring out what I am doing wrong would be much appreciated. PS, Excel using Goal Seek gives me the same answers as PYOMO as one would expect. Many thanks in advance, Best, |