示例#1
0
        public void testSabrVols()
        {
            // Testing swaption volatility cube (sabr interpolation)
            CommonVars vars = new CommonVars();

            List <List <Handle <Quote> > > parametersGuess = new InitializedList <List <Handle <Quote> > >(
                vars.cube.tenors.options.Count * vars.cube.tenors.swaps.Count);

            for (int i = 0; i < vars.cube.tenors.options.Count * vars.cube.tenors.swaps.Count; i++)
            {
                parametersGuess[i]    = new InitializedList <Handle <Quote> >(4);
                parametersGuess[i][0] = new Handle <Quote>(new SimpleQuote(0.2));
                parametersGuess[i][1] = new Handle <Quote>(new SimpleQuote(0.5));
                parametersGuess[i][2] = new Handle <Quote>(new SimpleQuote(0.4));
                parametersGuess[i][3] = new Handle <Quote>(new SimpleQuote(0.0));
            }
            List <bool> isParameterFixed = new InitializedList <bool>(4, false);

            SwaptionVolCube1x volCube = new SwaptionVolCube1x
                                            (vars.atmVolMatrix, vars.cube.tenors.options, vars.cube.tenors.swaps, vars.cube.strikeSpreads,
                                            vars.cube.volSpreadsHandle, vars.swapIndexBase, vars.shortSwapIndexBase, vars.vegaWeighedSmileFit,
                                            parametersGuess, isParameterFixed, true);
            double tolerance = 3.0e-4;

            vars.makeAtmVolTest(volCube, tolerance);

            tolerance = 12.0e-4;
            vars.makeVolSpreadsTest(volCube, tolerance);
        }
示例#2
0
        public void testSmile()
        {
            // Testing swaption volatility cube (smile)
            CommonVars vars = new CommonVars();

            SwaptionVolCube2 volCube = new SwaptionVolCube2(vars.atmVolMatrix,
                                                            vars.cube.tenors.options,
                                                            vars.cube.tenors.swaps,
                                                            vars.cube.strikeSpreads,
                                                            vars.cube.volSpreadsHandle,
                                                            vars.swapIndexBase,
                                                            vars.shortSwapIndexBase,
                                                            vars.vegaWeighedSmileFit);

            double tolerance = 1.0e-16;

            vars.makeVolSpreadsTest(volCube, tolerance);
        }