QLNet.SwaptionVolatilityDiscrete.swapTenors C# (CSharp) Метод

swapTenors() публичный Метод

public swapTenors ( ) : List
Результат List
        public List<Period> swapTenors()
        {
            return swapTenors_;
        }

Usage Example

Пример #1
0
        protected void fillVolatilityCube()
        {
            SwaptionVolatilityDiscrete atmVolStructure = atmVol_.currentLink() as SwaptionVolatilityDiscrete;

            List <double> atmOptionTimes = new List <double>(atmVolStructure.optionTimes());
            List <double> optionTimes    = new List <double>(volCubeAtmCalibrated_.optionTimes());

            atmOptionTimes.InsertRange(atmOptionTimes.Count, optionTimes);
            atmOptionTimes.Sort();
            atmOptionTimes = atmOptionTimes.Distinct().ToList <double>();


            List <double> atmSwapLengths = new List <double>(atmVolStructure.swapLengths());
            List <double> swapLengths    = new List <double>(volCubeAtmCalibrated_.swapLengths());

            atmSwapLengths.InsertRange(atmSwapLengths.Count, swapLengths);
            atmSwapLengths.Sort();
            atmSwapLengths = atmSwapLengths.Distinct().ToList <double>();

            List <Date> atmOptionDates = new List <Date>(atmVolStructure.optionDates());
            List <Date> optionDates    = new List <Date>(volCubeAtmCalibrated_.optionDates());

            atmOptionDates.InsertRange(atmOptionDates.Count, optionDates);
            atmOptionDates.Sort();
            atmOptionDates = atmOptionDates.Distinct().ToList <Date>();

            List <Period> atmSwapTenors = new List <Period>(atmVolStructure.swapTenors());
            List <Period> swapTenors    = new List <Period>(volCubeAtmCalibrated_.swapTenors());

            atmSwapTenors.InsertRange(atmSwapTenors.Count, swapTenors);
            atmSwapTenors.Sort();
            atmSwapTenors = atmSwapTenors.Distinct().ToList <Period>();

            createSparseSmiles();

            for (int j = 0; j < atmOptionTimes.Count; j++)
            {
                for (int k = 0; k < atmSwapLengths.Count; k++)
                {
                    bool expandOptionTimes = !optionTimes.Exists(x => x.IsEqual(atmOptionTimes[j]));
                    bool expandSwapLengths = !swapLengths.Exists(x => x.IsEqual(atmSwapLengths[k]));
                    if (expandOptionTimes || expandSwapLengths)
                    {
                        double        atmForward       = atmStrike(atmOptionDates[j], atmSwapTenors[k]);
                        double        atmVol           = atmVol_.link.volatility(atmOptionDates[j], atmSwapTenors[k], atmForward);
                        List <double> spreadVols       = spreadVolInterpolation(atmOptionDates[j], atmSwapTenors[k]);
                        List <double> volAtmCalibrated = new List <double>(nStrikes_);
                        for (int i = 0; i < nStrikes_; i++)
                        {
                            volAtmCalibrated.Add(atmVol + spreadVols[i]);
                        }
                        volCubeAtmCalibrated_.setPoint(atmOptionDates[j], atmSwapTenors[k],
                                                       atmOptionTimes[j], atmSwapLengths[k],
                                                       volAtmCalibrated);
                    }
                }
            }
            volCubeAtmCalibrated_.updateInterpolators();
        }