@SuppressWarnings("synthetic-access")
    @Override
    public Double visitDelta(final BlackVolatilitySurfaceDelta surface, final DoublesPair data) {

      Validate.isTrue(data.first < data.second, "lower limit not less that upper");
      Validate.isTrue(data.first >= 0.0, "lower limit < 0.0");
      Validate.isTrue(data.second <= 1.0, "upper limit > 1.0");

      if (_t < 1e-4) {
        final double dnsVol = surface.getVolatilityForDelta(_t, 0.5);
        return dnsVol * dnsVol; // this will be identical to atm-vol for t-> 0
      }

      final Function1D<Double, Double> integrand = getDeltaIntegrand(surface);
      // find the delta corresponding to the at-the-money-forward (NOTE this is not the DNS of delta
      // = 0.5)
      final double atmfVol = surface.getVolatility(_t, _f);
      final double atmfDelta = BlackFormulaRepository.delta(_f, _f, _t, atmfVol, true);

      final double lowerLimit = data.first;
      final double upperLimit = data.second;

      // Do the call/k^2 integral - split up into the the put integral and the call integral because
      // the function is not smooth at strike = forward
      double res = _integrator.integrate(integrand, lowerLimit, atmfDelta); // Call part

      if (_addResidual) {
        // The lower strike cutoff is expressed as a absolute strike (i.e. k << f), while the
        // upperLimit is a call delta (values close to one = small absolute strikes),
        // so we must covert the lower strike cutoff to a upper delta cutoff
        final double limitVol = surface.getVolatility(_t, _lowStrikeCutoff);
        final double limitDelta =
            BlackFormulaRepository.delta(_f, _lowStrikeCutoff, _t, limitVol, true);
        final double u = Math.min(upperLimit, limitDelta);
        res += _integrator.integrate(integrand, atmfDelta, u); // put part
        res += _residual;
      } else {
        res += _integrator.integrate(integrand, atmfDelta, upperLimit); // put part
      }
      return 2 * res / _t;
    }
 private double presentValueDeltaStandard(
     final double forward,
     final double strike,
     final double expiry,
     final boolean isCall,
     final double df,
     final double notional,
     final double yearFraction) {
   double volatility = _smileFunction.getVolatility(strike);
   double price =
       BlackFormulaRepository.delta(forward, strike, expiry, volatility, isCall)
           * df
           * notional
           * yearFraction;
   return price;
 }
    @SuppressWarnings("synthetic-access")
    @Override
    public Double visitDelta(final BlackVolatilitySurfaceDelta surface) {

      if (_t < 1e-4) {
        final double atmVol = surface.getVolatility(_t, _f);
        return atmVol * atmVol;
      }

      final double lowerLimit = _tol;
      double upperLimit;
      if (_addResidual) {
        final double limitVol = surface.getVolatility(_t, _lowStrikeCutoff);
        upperLimit = BlackFormulaRepository.delta(_f, _lowStrikeCutoff, _t, limitVol, true);
      } else {
        upperLimit = 1 - _tol;
      }

      final DoublesPair limits = new DoublesPair(lowerLimit, upperLimit);
      return visitDelta(surface, limits);
    }