Exemple #1
0
        public void testTermVolatilityStripping2()
        {
            // Testing forward/forward vol stripping from non-flat term vol "
            // surface using OptionletStripper2 class...");

            CommonVars vars = new CommonVars();

            Settings.setEvaluationDate(Date.Today);

            vars.setCapFloorTermVolCurve();
            vars.setCapFloorTermVolSurface();

            IborIndex iborIndex = new Euribor6M(vars.yieldTermStructure);

            // optionletstripper1
            OptionletStripper1       optionletStripper1        = new OptionletStripper1(vars.capFloorVolSurface, iborIndex, null, vars.accuracy);
            StrippedOptionletAdapter strippedOptionletAdapter1 = new StrippedOptionletAdapter(optionletStripper1);
            Handle <OptionletVolatilityStructure> vol1         = new Handle <OptionletVolatilityStructure>(strippedOptionletAdapter1);

            vol1.link.enableExtrapolation();

            // optionletstripper2
            OptionletStripper        optionletStripper2        = new OptionletStripper2(optionletStripper1, vars.capFloorVolCurve);
            StrippedOptionletAdapter strippedOptionletAdapter2 = new StrippedOptionletAdapter(optionletStripper2);
            Handle <OptionletVolatilityStructure> vol2         = new Handle <OptionletVolatilityStructure>(strippedOptionletAdapter2);

            vol2.link.enableExtrapolation();

            // consistency check: diff(stripped vol1-stripped vol2)
            for (int strikeIndex = 0; strikeIndex < vars.strikes.Count; ++strikeIndex)
            {
                for (int tenorIndex = 0; tenorIndex < vars.optionTenors.Count; ++tenorIndex)
                {
                    double strippedVol1 = vol1.link.volatility(vars.optionTenors[tenorIndex], vars.strikes[strikeIndex], true);
                    double strippedVol2 = vol2.link.volatility(vars.optionTenors[tenorIndex], vars.strikes[strikeIndex], true);

                    // vol from flat vol surface (for comparison only)
                    double flatVol = vars.capFloorVolSurface.volatility(vars.optionTenors[tenorIndex], vars.strikes[strikeIndex], true);

                    double error = Math.Abs(strippedVol1 - strippedVol2);
                    if (error > vars.tolerance)
                    {
                        QAssert.Fail("\noption tenor:  " + vars.optionTenors[tenorIndex] +
                                     "\nstrike:        " + (vars.strikes[strikeIndex]) +
                                     "\nstripped vol1: " + (strippedVol1) +
                                     "\nstripped vol2: " + (strippedVol2) +
                                     "\nflat vol:      " + (flatVol) +
                                     "\nerror:         " + (error) +
                                     "\ntolerance:     " + (vars.tolerance));
                    }
                }
            }
        }