Domanda

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top