Наследование: SwaptionVolatilityDiscrete
Пример #1
0
        public void testSwaptionVolMatrixCoherence()
        {
            //"Testing swaption volatility matrix...");

            CommonVars vars = new CommonVars();

            SwaptionVolatilityMatrix vol;
            string description;

            //floating reference date, floating market data
            description = "floating reference date, floating market data";
            vol = new SwaptionVolatilityMatrix(vars.conventions.calendar,
                                                vars.conventions.optionBdc,
                                                vars.atm.tenors.options,
                                                vars.atm.tenors.swaps,
                                                vars.atm.volsHandle,
                                                vars.conventions.dayCounter);

            vars.makeCoherenceTest(description, vol);

            //fixed reference date, floating market data
            description = "fixed reference date, floating market data";
            vol = new SwaptionVolatilityMatrix(Settings.evaluationDate(),
                                                vars.conventions.calendar,
                                                vars.conventions.optionBdc,
                                                vars.atm.tenors.options,
                                                vars.atm.tenors.swaps,
                                                vars.atm.volsHandle,
                                                vars.conventions.dayCounter);

            vars.makeCoherenceTest(description, vol);

            // floating reference date, fixed market data
            description = "floating reference date, fixed market data";
            vol = new SwaptionVolatilityMatrix(vars.conventions.calendar,
                                                vars.conventions.optionBdc,
                                                vars.atm.tenors.options,
                                                vars.atm.tenors.swaps,
                                                vars.atm.volsHandle,
                                                vars.conventions.dayCounter);

            vars.makeCoherenceTest(description, vol);

            // fixed reference date, fixed market data
            description = "fixed reference date, fixed market data";
            vol = new SwaptionVolatilityMatrix(Settings.evaluationDate(),
                                                vars.conventions.calendar,
                                                vars.conventions.optionBdc,
                                                vars.atm.tenors.options,
                                                vars.atm.tenors.swaps,
                                                vars.atm.volsHandle,
                                                vars.conventions.dayCounter);

            vars.makeCoherenceTest(description, vol);
        }
Пример #2
0
        public override void setParams( Vector parameters)
        {
            base.setParams(parameters);

            int k=covarProxy_.volatilityModel().parameters().Count;

            covarProxy_.volatilityModel().setParams(new List<Parameter>(arguments_.GetRange(0, k)));
            covarProxy_.correlationModel().setParams(new List<Parameter>(arguments_.GetRange(k, arguments_.Count-k)));

            swaptionVola = null;
        }
Пример #3
0
        // calculating swaption volatility matrix using
        // Rebonatos approx. formula. Be aware that this
        // matrix is valid only for regular fixings and
        // assumes that the fix and floating leg have the
        // same frequency
        public SwaptionVolatilityMatrix getSwaptionVolatilityMatrix()
        {
            if (swaptionVola!=null) {
                return swaptionVola;
            }

            IborIndex index = process_.index();
            Date today = process_.fixingDates()[0];

            int size=process_.size()/2;
            Matrix volatilities=new Matrix(size, size);

            List<Date> exercises = new InitializedList<Date>(size);
            for (int i = 0; i < size; ++i){
                exercises[i]=process_.fixingDates()[i+1];
            }

            List<Period> lengths = new InitializedList<Period>(size);
            for (int i=0; i < size; ++i) {
                lengths[i] = (i+1)*index.tenor();
            }

            Vector f = process_.initialValues();
            for (int k=0; k < size; ++k) {
                int alpha  =k;
                double t_alpha=process_.fixingTimes()[alpha+1];

                Matrix var=new Matrix(size, size);
                for (int i=alpha+1; i <= k+size; ++i) {
                    for (int j=i; j <= k+size; ++j) {
                        var[i-alpha-1,j-alpha-1] = var[j-alpha-1,i-alpha-1] =
                            covarProxy_.integratedCovariance(i, j, t_alpha,null);
                    }
                }

                for (int l=1; l <= size; ++l) {
                    int beta =l + k;
                    Vector w = w_0(alpha, beta);

                    double sum=0.0;
                    for (int i=alpha+1; i <= beta; ++i) {
                        for (int j=alpha+1; j <= beta; ++j) {
                            sum+=w[i]*w[j]*f[i]*f[j]*var[i-alpha-1,j-alpha-1];
                        }
                    }
                    volatilities[k,l-1] =
                        Math.Sqrt(sum/t_alpha)/S_0(alpha, beta);
                }
            }

            return swaptionVola = new SwaptionVolatilityMatrix( today, exercises, lengths,
                                                                volatilities,index.dayCounter());
        }
Пример #4
0
        public void testSwaptionVolMatrixObservability()
        {
            //"Testing swaption volatility matrix observability...");

            CommonVars vars=new CommonVars();

            SwaptionVolatilityMatrix vol;
            string description;

            //floating reference date, floating market data
            description = "floating reference date, floating market data";
            vol = new SwaptionVolatilityMatrix( vars.conventions.calendar,
                                                vars.conventions.optionBdc,
                                                vars.atm.tenors.options,
                                                vars.atm.tenors.swaps,
                                                vars.atm.volsHandle,
                                                vars.conventions.dayCounter);

            vars.makeObservabilityTest(description, vol, true, true);

            //fixed reference date, floating market data
            description = "fixed reference date, floating market data";
            vol = new SwaptionVolatilityMatrix( Settings.evaluationDate(),
                                                vars.conventions.calendar,
                                                vars.conventions.optionBdc,
                                                vars.atm.tenors.options,
                                                vars.atm.tenors.swaps,
                                                vars.atm.volsHandle,
                                                vars.conventions.dayCounter);
            vars.makeObservabilityTest(description, vol, true, false);

            // floating reference date, fixed market data
            description = "floating reference date, fixed market data";
            vol = new SwaptionVolatilityMatrix( vars.conventions.calendar,
                                                vars.conventions.optionBdc,
                                                vars.atm.tenors.options,
                                                vars.atm.tenors.swaps,
                                                vars.atm.volsHandle,
                                                vars.conventions.dayCounter);
            vars.makeObservabilityTest(description, vol, false, true);

            // fixed reference date, fixed market data
            description = "fixed reference date, fixed market data";
            vol = new SwaptionVolatilityMatrix( Settings.evaluationDate(),
                                                vars.conventions.calendar,
                                                vars.conventions.optionBdc,
                                                vars.atm.tenors.options,
                                                vars.atm.tenors.swaps,
                                                vars.atm.volsHandle,
                                                vars.conventions.dayCounter);
            vars.makeObservabilityTest(description, vol, false, false);

               // fixed reference date and fixed market data, option dates
                //SwaptionVolatilityMatrix(const Date& referenceDate,
                //                         const std::vector<Date>& exerciseDates,
                //                         const std::vector<Period>& swapTenors,
                //                         const Matrix& volatilities,
                //                         const DayCounter& dayCounter);
        }