Hi! I have a similar question to that of Daniel. I first tested the code on some zero-coupon bonds (actually some bond strips, but that doesn't matter), and indeed it worked great.
But what I really wanted to do, is to fit the Vasicek model on a set of coupon-bearing bonds, resulting in a spot rate structure.
So what I did was I altered the code calculating the prices so that it would calculate the prices of my coupon bonds, and I used that measure directly for fitting, so using price errors instead of yield errors.
My results however aren't that good. So again in short: the only thing that actually changed is that I now use prices (for coupon-bearing bonds) directly. My inputs are time-to-maturity and market prices (and coupon rates of course). I didn't for example make any changes in the optimization options. Any suggestions to make a better fit? Thanks.
But what I really wanted to do, is to fit the Vasicek model on a set of coupon-bearing bonds, resulting in a spot rate structure.
So what I did was I altered the code calculating the prices so that it would calculate the prices of my coupon bonds, and I used that measure directly for fitting, so using price errors instead of yield errors.
My results however aren't that good. So again in short: the only thing that actually changed is that I now use prices (for coupon-bearing bonds) directly. My inputs are time-to-maturity and market prices (and coupon rates of course). I didn't for example make any changes in the optimization options. Any suggestions to make a better fit? Thanks.