Beispiel #1
0
        public virtual IVolSurface BumpMaturityStrikePoint(int indexMaturity, int indexStrike, double volChange)
        {
            var newMatrix = ValueOnGrids.Clone() as double[, ];

            //newMatrix[indexStrike, indexMaturity] += volChange; // note axis1 and 2 are corresponding to matrix dimension 2 and 1 respectively.
            newMatrix[indexMaturity, indexStrike] += volChange;

            return(new ImpliedVolSurface(_valuationDate, RowGrid, ColGrid, newMatrix, _interp, dcConvention: _dcConvention, volSurfaceType: _surfType));
        }
Beispiel #2
0
        public virtual IVolSurface BumpMaturitySlice(int index, double volChange)
        {
            var newMatrix = ValueOnGrids.Clone() as double[, ];

            for (var i = 0; i < ColGrid.Length; i++)
            {
                //newMatrix[i, index] += volChange;		// note axis1 and 2 are corresponding to matrix dimension 2 and 1 respectively.
                newMatrix[index, i] += volChange;
            }
            return(new ImpliedVolSurface(_valuationDate, RowGrid, ColGrid, newMatrix, _interp, dcConvention: _dcConvention, volSurfaceType: _surfType));
        }
Beispiel #3
0
        public virtual IVolSurface BumpVolSurf(double volChange)
        {
            var newMatrix = ValueOnGrids.Clone() as double[, ];

            for (var i = 0; i < RowGrid.Length; ++i)
            {
                for (var j = 0; j < ColGrid.Length; ++j)
                {
                    newMatrix[i, j] += volChange;
                }
            }
            return(new ImpliedVolSurface(_valuationDate, RowGrid, ColGrid, newMatrix, _interp, dcConvention: _dcConvention, volSurfaceType: _surfType));
        }
Beispiel #4
0
        private void Calibrate(double spotPrice, IYieldCurve yieldCurve, bool estimateAlpha, bool useFineTune,
                               double initAlpha, double initBeta, double initNu, double initRho)
        {
            // set ATM vols
            var tempCurve2D = new Curve2D <Date, double>(RowGrid, ColGrid, ValueOnGrids, x => x.ToOADate(), x => x,
                                                         Interpolation2D.BiLinear);
            var atmVols = RowGrid.Select(d => tempCurve2D.GetValue(d, spotPrice)).ToList();

            _spotPrice     = spotPrice;
            _yieldCurve    = yieldCurve;
            _useFineTune   = useFineTune;
            _estimateAlpha = estimateAlpha;

            OptimizerResults = Enumerable.Range(0, RowGrid.Count())
                               .Select(i =>
            {
                var t           = _dayCount.CalcDayCountFraction(ValuationDate, RowGrid[i]);
                var fowardPrice = _spotPrice / _yieldCurve.GetDf(ValuationDate, RowGrid[i]);
                //var optimizer = new SABRCoeffOptimizer(t, fowardPrice, atmVols[i], AxisX2, Matrix.GetColumn(i), estimateAlpha, useFineTune, initAlpha, initBeta, initNu, initRho);
                var optimizer = new SabrCoeffOptimizer(t, fowardPrice, atmVols[i], ColGrid, ValueOnGrids.GetRow(i), estimateAlpha, useFineTune, initAlpha, initBeta, initNu, initRho);
                return(optimizer.Result);
            })
                               .ToList();
        }