pazzo83 / QuantLib.jl

Quantlib implementation in pure Julia
Other
137 stars 42 forks source link

Build Yield Term Structure Fitting Methods with ZeroCouponBonds #10

Closed GustavoGran closed 4 years ago

GustavoGran commented 4 years ago

Hi, @pazzo83!

I've been trying to fit a Yield Term Structure using BondHelpers in the last couple of days.

As I went into the documentation I noticed that FittedBondCurve type recieves an Vector{BondHelper} argument and BondHelper type receives a FixedRateBond type and a Quote::Float64.

Everything went fine as I Fitted a Yts using maturity dates and Pair Yield Bonds (With regular coupon payment). I started to struggle when I tryied to use a Bullet Bond to fit the YTS.

If the Bullet Maturity is higher than 1 month, I can easily describe it as as FixedRateBond with a TenorPeriod(1 month,QuantLib.Time.Once()) and the program still works.

On the other hand, if the Bullet Maturity Date is lower than 1 month, I cannot set a TenorPeriod in days. I actually tryied to do that, but it seems that on schedule.jl the function get_size doesn't have an implementation like get_size(p::Dates.Day, ed::Date, td::Date) and results in an error.

Is there any workaround to deal with Bullets with maturity lower than 1 month? I tryied an alternative solution using ZeroCouponBond(), but it seems that BondHelpers() do not accept them.

ERROR: MethodError: Cannot convert an object of type ZeroCouponBond{QuantLib.Time.USGovernmentBondCalendar,DiscountingBondEngine{NullYieldTermStructure}} to an object of type BondHelper

GustavoGran commented 4 years ago

Solved.

I had been using the boolean variable "End of Month" from Schedule incorrectly.

Set it to false and everything worked.