Exemple #1
0
        public void testFlatTermVolatilityStripping1()
        {
            // Testing forward/forward vol stripping from flat term vol
            // surface using OptionletStripper1 class...

            CommonVars vars = new CommonVars();

            Settings.setEvaluationDate(new Date(28, Month.October, 2013));

            vars.setFlatTermVolSurface();

            IborIndex iborIndex = new Euribor6M(vars.yieldTermStructure);

            OptionletStripper optionletStripper1 = new OptionletStripper1(vars.flatTermVolSurface,
                                                                          iborIndex, null, vars.accuracy);

            StrippedOptionletAdapter strippedOptionletAdapter = new StrippedOptionletAdapter(optionletStripper1);

            Handle <OptionletVolatilityStructure> vol = new Handle <OptionletVolatilityStructure>(strippedOptionletAdapter);

            vol.link.enableExtrapolation();

            BlackCapFloorEngine strippedVolEngine = new BlackCapFloorEngine(vars.yieldTermStructure, vol);

            CapFloor cap;

            for (int tenorIndex = 0; tenorIndex < vars.optionTenors.Count; ++tenorIndex)
            {
                for (int strikeIndex = 0; strikeIndex < vars.strikes.Count; ++strikeIndex)
                {
                    cap = new MakeCapFloor(CapFloorType.Cap, vars.optionTenors[tenorIndex], iborIndex,
                                           vars.strikes[strikeIndex], new Period(0, TimeUnit.Days))
                          .withPricingEngine(strippedVolEngine);

                    double priceFromStrippedVolatility = cap.NPV();

                    IPricingEngine blackCapFloorEngineConstantVolatility = new BlackCapFloorEngine(vars.yieldTermStructure,
                                                                                                   vars.termV[tenorIndex, strikeIndex]);

                    cap.setPricingEngine(blackCapFloorEngineConstantVolatility);
                    double priceFromConstantVolatility = cap.NPV();

                    double error = Math.Abs(priceFromStrippedVolatility - priceFromConstantVolatility);
                    if (error > vars.tolerance)
                    {
                        QAssert.Fail("\noption tenor:       " + vars.optionTenors[tenorIndex] +
                                     "\nstrike:             " + vars.strikes[strikeIndex] +
                                     "\nstripped vol price: " + priceFromStrippedVolatility +
                                     "\nconstant vol price: " + priceFromConstantVolatility +
                                     "\nerror:              " + error +
                                     "\ntolerance:          " + vars.tolerance);
                    }
                }
            }
        }
Exemple #2
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BlackCapFloorEngine obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Exemple #3
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BlackCapFloorEngine obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }