FixedLeg duration of vanilla swap
Posted by suhasg on Jun 02, 2011; 6:10pm
URL: http://quantlib.414.s1.nabble.com/FixedLeg-duration-of-vanilla-swap-tp934.html
How does one go about calculating the modified duration of the fixed leg? Following the swapvaluation.cpp example, I can calculate the NPV by
NPV = spot5YearSwap.NPV();
I guess at this point I could get hold of the fixed leg as bunch of cashflows.
const std::vector<boost::shared_ptr<QuantLib::CashFlow> >& leg = spot5YearSwap.fixedLeg();
Now I am stumped, after looking at bind examples, I know I nned to use CashFlows::Duration here but I can not figure out how to "convert" my fixedleg to a fixedratebond, or what to pass for the yield parameter to duration.
It would have been nice if the fixedLeg contained methods to output analytics as well.
Thanks for your help.