private VolatilitySurface(ITimeMeasure time, MoneynessProvider moneyness,
                           VarianceInterpoler varianceInterpoler, LocalVariance localVariance)
 {
     Time = time;
     VarianceInterpoler = varianceInterpoler;
     Moneyness          = moneyness;
     LocalVariance      = localVariance;
 }
        public static VolatilitySurface BuildInterpol(VolatilityMatrix volMatrix, MoneynessProvider moneyness)
        {
            double[] timePillars = volMatrix.Time[volMatrix.Pillars];

            var varianceSlices = EnumerableUtils.For(0, timePillars.Length, i =>
            {
                double t = timePillars[i];
                double[] moneynessPillars = volMatrix.Strikes.Map(k => moneyness.Moneyness(t, k));
                var varianceSlice         = volMatrix.Vols.Row(i).Map(v => t * v * v);
                return((RrFunction)SplineInterpoler.BuildCubicSpline(moneynessPillars, varianceSlice));
            });

            var varianceInterpol = new VarianceInterpoler(timePillars, varianceSlices);

            return(new VolatilitySurface(volMatrix.Time, moneyness, varianceInterpol, varianceInterpol.BuildLocalVariance()));
        }
        public double Variance(double maturity, double strike)
        {
            var m = Moneyness.Moneyness(maturity, strike);

            return(VarianceInterpoler.Eval(maturity, m));
        }