예제 #1
0
        public OptionletStripper1(CapFloorTermVolSurface termVolSurface, IborIndex index,
                                  double?switchStrike = null,
                                  double accuracy     = 1.0e-6,
                                  int maxIter         = 100,
                                  Handle <YieldTermStructure> discount = null,
                                  VolatilityType type = VolatilityType.ShiftedLognormal,
                                  double displacement = 0.0,
                                  bool dontThrow      = false)
            : base(termVolSurface, index, discount, type, displacement)
        {
            volQuotes_ = new InitializedList <List <SimpleQuote> >(nOptionletTenors_,
                                                                   new InitializedList <SimpleQuote>(nStrikes_, new SimpleQuote()));
            floatingSwitchStrike_        = switchStrike == null;
            capFlooMatrixNotInitialized_ = true;
            switchStrike_ = switchStrike;
            accuracy_     = accuracy;
            maxIter_      = maxIter;
            dontThrow_    = dontThrow;

            capFloorPrices_  = new Matrix(nOptionletTenors_, nStrikes_);
            optionletPrices_ = new Matrix(nOptionletTenors_, nStrikes_);
            capFloorVols_    = new Matrix(nOptionletTenors_, nStrikes_);
            double firstGuess = 0.14; // guess is only used for shifted lognormal vols

            optionletStDevs_ = new Matrix(nOptionletTenors_, nStrikes_, firstGuess);

            capFloors_ = new InitializedList <List <CapFloor> >(nOptionletTenors_);
        }
예제 #2
0
        protected OptionletStripper(CapFloorTermVolSurface termVolSurface, IborIndex iborIndex,
                                    Handle <YieldTermStructure> discount = null,
                                    VolatilityType type = VolatilityType.ShiftedLognormal,
                                    double displacement = 0.0)
        {
            termVolSurface_ = termVolSurface;
            iborIndex_      = iborIndex;
            discount_       = discount ?? new Handle <YieldTermStructure>();
            nStrikes_       = termVolSurface.strikes().Count;
            volatilityType_ = type;
            displacement_   = displacement;


            if (volatilityType_ == VolatilityType.Normal)
            {
                Utils.QL_REQUIRE(displacement_.IsEqual(0.0), () =>
                                 "non-null displacement is not allowed with Normal model");
            }

            termVolSurface.registerWith(update);
            iborIndex_.registerWith(update);
            discount_.registerWith(update);
            Settings.registerWith(update);

            Period indexTenor       = iborIndex_.tenor();
            Period maxCapFloorTenor = termVolSurface.optionTenors().Last();

            // optionlet tenors and capFloor lengths
            optionletTenors_.Add(indexTenor);
            capFloorLengths_.Add(optionletTenors_.Last() + indexTenor);
            Utils.QL_REQUIRE(maxCapFloorTenor >= capFloorLengths_.Last(), () =>
                             "too short (" + maxCapFloorTenor + ") capfloor term vol termVolSurface");
            Period nextCapFloorLength = capFloorLengths_.Last() + indexTenor;

            while (nextCapFloorLength <= maxCapFloorTenor)
            {
                optionletTenors_.Add(capFloorLengths_.Last());
                capFloorLengths_.Add(nextCapFloorLength);
                nextCapFloorLength += indexTenor;
            }
            nOptionletTenors_ = optionletTenors_.Count;

            optionletVolatilities_ = new InitializedList <List <double> >(nOptionletTenors_);
            for (int x = 0; x < nOptionletTenors_; x++)
            {
                optionletVolatilities_[x] = new InitializedList <double>(nStrikes_);
            }
            optionletStrikes_ = new InitializedList <List <double> >(nOptionletTenors_);
            for (int x = 0; x < nOptionletTenors_; x++)
            {
                optionletStrikes_[x] = new List <double>(termVolSurface.strikes());
            }

            optionletDates_          = new InitializedList <Date>(nOptionletTenors_);
            optionletTimes_          = new InitializedList <double>(nOptionletTenors_);
            atmOptionletRate_        = new InitializedList <double>(nOptionletTenors_);
            optionletPaymentDates_   = new InitializedList <Date>(nOptionletTenors_);
            optionletAccrualPeriods_ = new InitializedList <double>(nOptionletTenors_);
        }