简体   繁体   English

QuantLib中的交换定价

[英]Swaption pricing in QuantLib

I posted this on Wilmott too, wasn't sure which would get more of a response. 我也把这个发布在Wilmott上,不知道哪个会得到更多回复。

I'm relatively new to the world of Quantlib (and C++ . . .), so perhaps this is quite obvious. 我对Quantlib(和C ++ ......)的世界相对较新,所以也许这很明显。 I'm trying to figure out if Quantlib can price forward premium vanilla swaptions (OIS discounting, 3mL curve for estimation). 我想弄清楚Quantlib是否可以定价优质香草互换价格(OIS折扣,估算3mL曲线)。 All I can see in Quantlib in the Swaption files are inputs for one term structure for discounting. 我在Swaption文件中看到的所有Quantlib都是用于折扣的一个期限结构的输入。 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 非常感谢

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. QuantLib只能在树上定价,而且无法使用这两条曲线。

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). 正如您可能已经看到的那样,您必须实例化一个工具(Swaption类)和相应的引擎(BlackSwaptionEngine类)。 The constructor of the BlackSwaptionEngine takes a discount curve besides the other args, so you'll pass the OIS curve here. 除了其他参数之外,BlackSwaptionEngine的构造函数采用折扣曲线,因此您将在此处传递OIS曲线。 The constructor of the Swaption, on the other hand, takes the swap underlying the option as a VanillaSwap instance. 另一方面,Swaption的构造函数将选项的交换作为VanillaSwap实例。 In turn, the VanillaSwap constructor takes an IborIndex instance representing the floating-rate index to be paid; 反过来,VanillaSwap构造函数采用IborIndex实例来表示要支付的浮动利率指数; 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. 最后,IborIndex构造函数将曲线用于预测其固定,因此这是您可以传递3mL曲线的位置。 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. 另请注意,当前发布的版本(QuantLib 1.1)有一个错误,使得它在计算过程中的某个时刻使用了错误的曲线。 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 . 您将需要使用版本1.2,该版本尚未发布,但可以从Subversion存储库中检出, 网址https://quantlib.svn.sourceforge.net/svnroot/quantlib/branches/R01020x-branch/QuantLib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM