Exemple #1
0
        //-------------------------------------------------------------------------
        private double[] weights(double forward, double strike, double[] strikes, double timeToExpiry, double atmVol)
        {
//JAVA TO C# CONVERTER NOTE: The following call to the 'RectangularArrays' helper class reproduces the rectangular array initialization that is automatic in Java:
//ORIGINAL LINE: double[][] mat = new double[3][3];
            double[][] mat = RectangularArrays.ReturnRectangularDoubleArray(3, 3);
            double[]   vec = new double[3];
            for (int i = 0; i < 3; ++i)
            {
                mat[0][i] = BlackFormulaRepository.vega(forward, strikes[i], timeToExpiry, atmVol);
                mat[1][i] = BlackFormulaRepository.vanna(forward, strikes[i], timeToExpiry, atmVol);
                mat[2][i] = BlackFormulaRepository.volga(forward, strikes[i], timeToExpiry, atmVol);
            }
            vec[0] = BlackFormulaRepository.vega(forward, strike, timeToExpiry, atmVol);
            vec[1] = BlackFormulaRepository.vanna(forward, strike, timeToExpiry, atmVol);
            vec[2] = BlackFormulaRepository.volga(forward, strike, timeToExpiry, atmVol);
            DecompositionResult res = SVD.apply(DoubleMatrix.ofUnsafe(mat));

            return(res.solve(vec));
        }