Monday, December 19, 2016

Setting up Schedule for an amortizing floater in QuantLib



I am unsure as to the exact arguments required for the Schedule function for an amortizing floater - my code is listed below. Specifically, my question pertains to whether the schedule should always start from the issue date of the bond or should it start from the settlement date if the bond is seasoned. I seem to have seen usage both ways in some of the examples on the web so I am a bit confused.


I would expect that the NPV functions index into the right cashflow based on the settlement date provided but just checking.


Also, if anyone has a working example of an AmortizingFloatingRateBond which calculates the DM given a price (or vice versa) using a notional schedule,that'd be much appreciated.


Code Snippet:


QuantLib::JointCalendar calendar = QuantLib::JointCalendar(QuantLib::UnitedStates(),QuantLib::UnitedKingdom(),
JoinBusinessDays);
QuantLib::DayCounter dayCounter = QuantLib::Actual360();

QuantLib::Integer fixingDays = 1;
QuantLib::Natural settlementDays = 3;


QuantLib::Date tradeDate(20, QuantLib::September, 2013);
QuantLib::Date settlementDate = calendar.advance(tradeDate, settlementDays, QuantLib::Days);
settlementDate = calendar.adjust(settlementDate);
QuantLib::Settings::instance().evaluationDate() = tradeDate;

QuantLib::Date issueDate(25,QuantLib::July,2013);

QuantLib::Period p1m = QuantLib::Period(1,QuantLib::Months);


// Number of payments
int num_cashflows = 120;
QuantLib::Date maturityDate = issueDate + num_cashflows * p1m;

QuantLib::Schedule mySchedule(issueDate,
maturityDate,
QuantLib::Period(QuantLib::Monthly),
calendar,
QuantLib::BusinessDayConvention::Unadjusted,
QuantLib::BusinessDayConvention::ModifiedFollowing,

QuantLib::DateGeneration::Forward,
false);

QuantLib::AmortizingFloatingRateBond MyFloater(settlementDays,
Notional,
mySchedule,
libor,
QuantLib::Actual360(),
QuantLib::BusinessDayConvention::ModifiedFollowing,
fixingDays,

std::vector(1,1.0),
std::vector(1,Spread),
std::vector(),
std::vector(),
true,
issueDate);

MyFloater.setPricingEngine(bondEngine);

std::vector paySchedule = mySchedule.dates();

std::vector::iterator pIter;
QuantLib::Date priorDate;

for (pIter = paySchedule.begin(); pIter != paySchedule.end() && *pIter < settlementDate; ++pIter){
priorDate = *pIter;
libor->addFixing(calendar.advance(priorDate, QuantLib::Period(-fixingDays,QuantLib::Days)), 0.1805/100);
}


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...