示例#1
0
            public ObjectiveFunction(OptionletStripper1 optionletStripper1, CapFloor cap, double targetValue)
            {
                cap_         = cap;
                targetValue_ = targetValue;

                OptionletVolatilityStructure adapter = new StrippedOptionletAdapter(optionletStripper1);

                // set an implausible value, so that calculation is forced
                // at first operator()(Volatility x) call
                spreadQuote_ = new SimpleQuote(-1.0);

                OptionletVolatilityStructure spreadedAdapter = new SpreadedOptionletVolatility(
                    new Handle <OptionletVolatilityStructure>(adapter), new Handle <Quote>(spreadQuote_));

                BlackCapFloorEngine engine = new BlackCapFloorEngine(optionletStripper1.iborIndex().forwardingTermStructure(),
                                                                     new Handle <OptionletVolatilityStructure>(spreadedAdapter));

                cap_.setPricingEngine(engine);
            }
示例#2
0
        public OptionletStripper2(OptionletStripper1 optionletStripper1, Handle <CapFloorTermVolCurve> atmCapFloorTermVolCurve)
            : base(optionletStripper1.termVolSurface(),
                   optionletStripper1.iborIndex(),
                   new Handle <YieldTermStructure>(),
                   optionletStripper1.volatilityType(),
                   optionletStripper1.displacement())
        {
            stripper1_ = optionletStripper1;
            atmCapFloorTermVolCurve_ = atmCapFloorTermVolCurve;
            dc_ = stripper1_.termVolSurface().dayCounter();
            nOptionExpiries_    = atmCapFloorTermVolCurve.link.optionTenors().Count;
            atmCapFloorStrikes_ = new InitializedList <double>(nOptionExpiries_, 0.0);
            atmCapFloorPrices_  = new InitializedList <double>(nOptionExpiries_, 0.0);
            spreadsVolImplied_  = new InitializedList <double>(nOptionExpiries_, 0.0);
            caps_           = new List <CapFloor>();
            maxEvaluations_ = 10000;
            accuracy_       = 1E-6;

            stripper1_.registerWith(update);
            atmCapFloorTermVolCurve_.registerWith(update);

            Utils.QL_REQUIRE(dc_ == atmCapFloorTermVolCurve.link.dayCounter(), () => "different day counters provided");
        }