On Jun 2, 2011, at 8:10 PM, Pointman wrote:
>
> 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.
I think you can use CashFlows::yield to obtain a yield given the NPV
you found. Once you have that, you can call CashFlows::duration.
Luigi
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users