3

I posted this on Wilmott too, wasn't sure which would get more of a response.

I'm relatively new to the world of Quantlib (and C++ . . .), so perhaps this is quite obvious. I'm trying to figure out if Quantlib can price forward premium vanilla swaptions (OIS discounting, 3mL curve for estimation). All I can see in Quantlib in the Swaption files are inputs for one term structure for discounting. Does it use this also for estimation? Or is there a way to override it, such that I can enter two curves.

Any help, examples etc would be much appreciated (and would save me a lot of time staring at the same files hoping something jumps out at me...)!

Thanks a lot

keynesiancross
  • 3,441
  • 15
  • 47
  • 87

1 Answers1

8

It depends. If you want to price Bermudan swaptions, you're out of luck; QuantLib can only price them on a tree and there's no way to use the two curves.

If you want to price European swaptions, you can use the two curves in the Black formula, although I agree that it's not obvious to find that out by looking at the code. As you've probably seen already, you'll have to instantiate both an instrument (the Swaption class) and a corresponding engine (the BlackSwaptionEngine class). The constructor of the BlackSwaptionEngine takes a discount curve besides the other args, so you'll pass the OIS curve here. The constructor of the Swaption, on the other hand, takes the swap underlying the option as a VanillaSwap instance. In turn, the VanillaSwap constructor takes an IborIndex instance representing the floating-rate index to be paid; and finally, the IborIndex constructor takes the curve to be used to forecast its fixings, so that's the place where you can pass the 3mL curve. To summarize:

shared_ptr<IborIndex> libor(new GBPLibor(3*Months, forecastCurve));
shared_ptr<VanillaSwap> swap(new VanillaSwap(..., libor, ...));
shared_ptr<Instrument> swaption(new Swaption(swap, ...));
shared_ptr<PricingEngine> engine(new BlackSwaptionEngine(discountCurve, ...));
swaption->setPricingEngine(engine);
double price = swaption->NPV();

Also, note that the current released version (QuantLib 1.1) has a bug that makes it use the wrong curve at some point during the calculations. You'll want to use version 1.2, which is not yet released but can be checked out from the Subversion repository at https://quantlib.svn.sourceforge.net/svnroot/quantlib/branches/R01020x-branch/QuantLib.

Luigi Ballabio
  • 4,128
  • 21
  • 29
  • Awesome - thanks for your response Luigi, very helpful. You're QL book is also coming in very handy. – keynesiancross Jan 17 '12 at 13:01
  • Hi Luigi - quick question for a beginner. Where in that link about is the 1.2 version? And would I download it and build it like 1.1? (For some context, took me 4 hrs to figure out I had to build 1.1 before I could use it haha). Thanks again – keynesiancross Jan 17 '12 at 16:01
  • 1
    That link _is_ the 1.2 version. If you have Subversion installed, you can check it out from that address. If you don't know what I'm talking about, go to http://quantlib.svn.sourceforge.net/viewvc/quantlib/branches/R01020x-branch/QuantLib instead and click "Download GNU tarball" near the bottom of the page. If you're on Windows, you'll build it like 1.1; if you're on Linux or Mac OS instead, you'll have to run the autogen.sh script first (some details on this and on Subversion are at http://quantlib.org/svn.shtml) – Luigi Ballabio Jan 17 '12 at 19:44