I appreciate that Quantlib Schedule class can take a date vector as constructor. I have successfully built a schedule via this way. However, when I pass this schedule to vanillaswap constructor, the code starts to generate error on function bool Schedule::isRegular(Size i) const
in schedule.cpp. Here is part of my code related to this error:
vector<Date> fixedDates;
vector<Date> floatDates;
fixedDates.push_back(Date(15, April, 2016));
fixedDates.push_back(Date(18, April, 2017));
floatDates.push_back(Date(15, April, 2016));
floatDates.push_back(Date(15, July, 2016));
floatDates.push_back(Date(17, October, 2016));
floatDates.push_back(Date(17, January, 2017));
floatDates.push_back(Date(18, April, 2017));
Schedule fixedSchedule(fixedDates);
Schedule floatSchedule(floatDates);
VanillaSwap::Type swapType = VanillaSwap::Payer;
VanillaSwap swap(swapType, nominal, fixedSchedule, fixedRate, Actual365Fixed(), floatSchedule, libor, spread, Actual365Fixed());
When I run my code, it fails due to this isRegular_.size()
return 0.
I found this link is useful: http://www.implementingquantlib.com/2014/11/odds-and-ends-date-calculations.html
However, I am not sure if I am complete understand the last paragraph about how to fix this problem. Is there anyone can give me an example here?
Many thanks
Since a few releases, the constructor that takes a vector of dates has been expanded (as suggested in the link you quoted) to take additional parameters. It is now declared as:
so you can pass any missing information that the schedule is not able to figure out from the dates; for example, you can pass
isRegular
asvector<bool>(n, true)
wheren
is the number of dates in the schedule (assuming the periods are regular, of course; in case you have a short or long coupon, you should put afalse
in the vector at the corresponding position).