Exemplo n.º 1
0
        public SwaptionVolCube1x(Handle <SwaptionVolatilityStructure> atmVolStructure,
                                 List <Period> optionTenors,
                                 List <Period> swapTenors,
                                 List <double> strikeSpreads,
                                 List <List <Handle <Quote> > > volSpreads,
                                 SwapIndex swapIndexBase,
                                 SwapIndex shortSwapIndexBase,
                                 bool vegaWeightedSmileFit,
                                 List <List <Handle <Quote> > > parametersGuess,
                                 List <bool> isParameterFixed,
                                 bool isAtmCalibrated,
                                 EndCriteria endCriteria      = null,
                                 double?maxErrorTolerance     = null,
                                 OptimizationMethod optMethod = null,
                                 double?errorAccept           = null,
                                 bool useMaxError             = false,
                                 int maxGuesses      = 50,
                                 bool backwardFlat   = false,
                                 double cutoffStrike = 0.0001)
            : base(atmVolStructure, optionTenors, swapTenors, strikeSpreads, volSpreads, swapIndexBase,
                   shortSwapIndexBase, vegaWeightedSmileFit)
        {
            parametersGuessQuotes_ = parametersGuess;
            isParameterFixed_      = isParameterFixed;
            isAtmCalibrated_       = isAtmCalibrated;
            endCriteria_           = endCriteria;
            optMethod_             = optMethod;
            useMaxError_           = useMaxError;
            maxGuesses_            = maxGuesses;
            backwardFlat_          = backwardFlat;
            cutoffStrike_          = cutoffStrike;

            if (maxErrorTolerance != null)
            {
                maxErrorTolerance_ = maxErrorTolerance.Value;
            }
            else
            {
                maxErrorTolerance_ = SWAPTIONVOLCUBE_TOL;
                if (vegaWeightedSmileFit_)
                {
                    maxErrorTolerance_ = SWAPTIONVOLCUBE_VEGAWEIGHTED_TOL;
                }
            }
            if (errorAccept != null)
            {
                errorAccept_ = errorAccept.Value;
            }
            else
            {
                errorAccept_ = maxErrorTolerance_ / 5.0;
            }

            privateObserver_ = new PrivateObserver(this);
            registerWithParametersGuess();
            setParameterGuess();
        }
Exemplo n.º 2
0
        public SwaptionVolCube1x(Handle <SwaptionVolatilityStructure> atmVolStructure,
                                 List <Period> optionTenors,
                                 List <Period> swapTenors,
                                 List <double> strikeSpreads,
                                 List <List <Handle <Quote> > > volSpreads,
                                 SwapIndex swapIndexBase,
                                 SwapIndex shortSwapIndexBase,
                                 bool vegaWeightedSmileFit,
                                 List <List <Handle <Quote> > > parametersGuess,
                                 List <bool> isParameterFixed,
                                 bool isAtmCalibrated,
                                 EndCriteria endCriteria      = null,
                                 double?maxErrorTolerance     = null,
                                 OptimizationMethod optMethod = null,
                                 double?errorAccept           = null,
                                 bool useMaxError             = false,
                                 int maxGuesses      = 50,
                                 bool backwardFlat   = false,
                                 double cutoffStrike = 0.0001)
            : base(atmVolStructure, optionTenors, swapTenors, strikeSpreads, volSpreads, swapIndexBase,
                   shortSwapIndexBase, vegaWeightedSmileFit)
        {
            parametersGuessQuotes_ = parametersGuess;
            isParameterFixed_      = isParameterFixed;
            isAtmCalibrated_       = isAtmCalibrated;
            endCriteria_           = endCriteria;
            optMethod_             = optMethod;
            useMaxError_           = useMaxError;
            maxGuesses_            = maxGuesses;
            backwardFlat_          = backwardFlat;
            cutoffStrike_          = cutoffStrike;

            // the current implementations are all lognormal, if we have
            // a normal one, we can move this check to the implementing classes
            Utils.QL_REQUIRE(atmVolStructure.link.volatilityType() == VolatilityType.ShiftedLognormal, () =>
                             "vol cubes of type 1 require a lognormal atm surface");

            if (maxErrorTolerance != null)
            {
                maxErrorTolerance_ = maxErrorTolerance.Value;
            }
            else
            {
                maxErrorTolerance_ = SWAPTIONVOLCUBE_TOL;
                if (vegaWeightedSmileFit_)
                {
                    maxErrorTolerance_ = SWAPTIONVOLCUBE_VEGAWEIGHTED_TOL;
                }
            }
            if (errorAccept != null)
            {
                errorAccept_ = errorAccept.Value;
            }
            else
            {
                errorAccept_ = maxErrorTolerance_ / 5.0;
            }

            privateObserver_ = new PrivateObserver(this);
            registerWithParametersGuess();
            setParameterGuess();
        }