Hello all,
I'm very new to Quantlib so apologies if this question has been answered before (although I did search the docs and mailing list unsuccesfully).
I'm trying to create an Excel function to price swaps and wanted to know how to
a) setup a cashflow schedule for an amortising swap. From what I can gather the Cashflow object passed to the swap is a single flow, not a vector
(Schedule fixedSchedule(calendar, settlementDate, maturity,fixedLegFrequency, fixedLegConvention);)
How do I pass a vector of Date=>Amount.
b) Can I price swaps where the interest reset is in arrears?
c) Also, what will be the best way to implement a cross currency swap?
thanks in advance
cheers
Sid
Yahoo! India Matrimony: Find your life partner online. |
On 04/24/05 15:29:01, Siddharth Sharma wrote:
> > I'm trying to create an Excel function to price swaps and wanted to know > how to > a) setup a cashflow schedule for an amortising swap. From what I can > gather the Cashflow object passed to the swap is a single flow, not a > vector > (Schedule fixedSchedule(calendar, settlementDate, > maturity,fixedLegFrequency, fixedLegConvention);) > How do I pass a vector of Date=>Amount. You can use the generic Swap constructor (ql/Instruments/swap.hpp) which takes two vectors of cash flows. You can build the two legs with the functions provided in ql/CashFlows/cashflowvectors.hpp and ql/CashFlows/indexedcashflowvectors.hpp, which also take a vector of amounts; pass the sequence of remaining principals (100, 96, 93, 91...) to set up an amortizing swap leg. > b) Can I price swaps where the interest reset is in arrears? Yes---use IndexedCouponVector<InArrearIndexedCoupon> to build the corresponding leg. (See ql/CashFlows/indexedcashflowvectors.hpp and ql/CashFlows/inarrearindexedcoupon.hpp) > c) Also, what will be the best way to implement a cross currency swap? This is a tougher one. At this time, Swap takes just one term structure for discounting, so it might not be possible. Suggestions and patches are welcome. Later, Luigi ---------------------------------------- Cogito ergo I'm right and you're wrong. -- Blair Houghton |
In reply to this post by Siddharth Sharma-3
Hi Luigi,
thanks for the reply. I'll try and write a CC Swap once I get my head around all this code :-) I have another question though, based on your swap example swapvaluation.cpp
I added a par rate calculation after the creation of the depoSwapTermStructure: i.e.
--------------------------------------------------------------
boost::shared_ptr<YieldTermStructure> depoSwapTermStructure(new
PiecewiseFlatForward(settlementDate, depoSwapInstruments, termStructureDayCounter, tolerance)); double tr = depoSwapTermStructure->parRate(10, settlementDate, Annual, 0); ----------------------------------------------------------------
the 10 year swap rate is 5.165% ( Rate s10yQuote=0.05165;) but the value returned by parRate is 5.16517962147765% The difference is too small to be explained by a daycount convention or fixingDays offset, but it exists nonetheless and i can't seem to figure out why.
Anyone have any ideas?
thanks and regards
Sid
Yahoo! India Matrimony: Find your life partner online. |
Free forum by Nabble | Edit this page |