Posted by
Luigi Ballabio on
Dec 01, 2009; 3:58pm
URL: http://quantlib.414.s1.nabble.com/Floating-rate-bond-How-to-find-fixing-tp8387p8388.html
Peter,
as for the approach, I'll let the real quants answer :)
Regarding the code:
On Tue, 2009-11-24 at 21:09 +0100, Peter Toke Heden Ahlgren wrote:
> Second, I get with the present code an error saying: What() is:Missing
> Euribor1Y Actual/360 fixing for October 16th, 2009. I guess some how
> this is related to the present coupon, but being a bond newbie I am
> not sure. Now, should I expect this error and how do I come around. I
> have found the ->addFixing, but how can I know what date QL will be
> missing? And what rate should I use? The 1 Year Euro Swap Zero Coup at
> that date?
Yes, that's the fixing of last coupon. As you figured out, you'll have
to use the addFixing method. The date you'll have to pass is the one in
the error message (October 16th, 2009.) The index is the 1-year
Euribor, and the value is its fixing at that date. You can do this
manually after you see the error, or you can do this beforehand by
writing something like the following (uncommented for lack of time, post
back to the list if you can't figure out something):
const Leg& l = floatingRateBond.cashflows();
Leg::const_iterator i = CashFlows::nextCashFlow(l);
if (i != l.end()) {
boost::shared_ptr<FloatingRateCoupon> coupon =
boost::dynamic_pointer_cast<FloatingRateCoupon>(*i);
Date fixingDate = coupon->fixingDate();
Rate r = ... (you'll have to retrieve the rate for fixingDate
someway)
coupon->index()->addFixing(fixingDate, r);
}
Luigi
P.S. I haven't looked hard at your code, so I won't comment on it now.
The one thing that jumped at me was the switch on freq. You can replace
the whole thing with:
Frequency freq = Frequency((int) mxGetScalar(prhs[4]));
Period iPer = Period(freq);
Period iPerLibor = iPer;
--
Do the right thing. It will gratify some people and astonish the rest.
-- Mark Twain
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users