本文整理汇总了C++中CommonVars::setRealCapFloorTermVolSurface方法的典型用法代码示例。如果您正苦于以下问题:C++ CommonVars::setRealCapFloorTermVolSurface方法的具体用法?C++ CommonVars::setRealCapFloorTermVolSurface怎么用?C++ CommonVars::setRealCapFloorTermVolSurface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonVars
的用法示例。
在下文中一共展示了CommonVars::setRealCapFloorTermVolSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testTermVolatilityStrippingShiftedLogNormalVol
void OptionletStripperTest::testTermVolatilityStrippingShiftedLogNormalVol() {
BOOST_TEST_MESSAGE(
"Testing forward/forward vol stripping from non-flat normal vol term "
"vol surface for normal vol setup using OptionletStripper1 class...");
CommonVars vars;
Real shift = 0.03;
Settings::instance().evaluationDate() = Date(30, April, 2015);
vars.setRealCapFloorTermVolSurface();
shared_ptr< IborIndex > iborIndex(new Euribor6M(vars.forwardingYTS));
boost::shared_ptr< OptionletStripper > optionletStripper1(
new OptionletStripper1(vars.capFloorVolRealSurface, iborIndex,
Null< Rate >(), vars.accuracy, 100,
vars.discountingYTS, ShiftedLognormal, shift,
true));
boost::shared_ptr< StrippedOptionletAdapter > strippedOptionletAdapter =
boost::shared_ptr< StrippedOptionletAdapter >(
new StrippedOptionletAdapter(optionletStripper1));
Handle< OptionletVolatilityStructure > vol(strippedOptionletAdapter);
vol->enableExtrapolation();
boost::shared_ptr< BlackCapFloorEngine > strippedVolEngine(
new BlackCapFloorEngine(vars.discountingYTS, vol));
boost::shared_ptr< CapFloor > cap;
for (Size strikeIndex = 0; strikeIndex < vars.strikes.size();
++strikeIndex) {
for (Size tenorIndex = 0; tenorIndex < vars.optionTenors.size();
++tenorIndex) {
cap = MakeCapFloor(CapFloor::Cap, vars.optionTenors[tenorIndex],
iborIndex, vars.strikes[strikeIndex],
0 * Days).withPricingEngine(strippedVolEngine);
Real priceFromStrippedVolatility = cap->NPV();
boost::shared_ptr< PricingEngine >
blackCapFloorEngineConstantVolatility(new BlackCapFloorEngine(
vars.discountingYTS, vars.termV[tenorIndex][strikeIndex],
vars.capFloorVolRealSurface->dayCounter(), shift));
cap->setPricingEngine(blackCapFloorEngineConstantVolatility);
Real priceFromConstantVolatility = cap->NPV();
Real error = std::fabs(priceFromStrippedVolatility -
priceFromConstantVolatility);
if (error > vars.tolerance)
BOOST_FAIL(
"\noption tenor: "
<< vars.optionTenors[tenorIndex] << "\nstrike: "
<< io::rate(vars.strikes[strikeIndex])
<< "\nstripped vol price: "
<< io::rate(priceFromStrippedVolatility)
<< "\nconstant vol price: "
<< io::rate(priceFromConstantVolatility)
<< "\nerror: " << io::rate(error)
<< "\ntolerance: " << io::rate(vars.tolerance));
}
}
}