DigitalOptionFunction { public static double driftlessTheta(final double forward, final double strike, final double timeToExpiry, final double lognormalVol, final boolean isCall) { ArgumentChecker.isTrue(forward > 0.0, "negative/NaN forward; have {}", forward); ArgumentChecker.isTrue(strike > 0.0, "negative/NaN strike; have {}", strike); ArgumentChecker.isTrue(timeToExpiry > 0.0, "negative/NaN timeToExpiry; have {}", timeToExpiry); ArgumentChecker.isTrue(lognormalVol > 0.0, "negative/NaN lognormalVol; have {}", lognormalVol); final double sigmaRootT = lognormalVol * Math.sqrt(timeToExpiry); final double d = Math.log(forward / strike) / sigmaRootT - 0.5 * sigmaRootT; final double sign = isCall ? 1. : -1.; final double div = 0.5 * (-Math.log(forward / strike) / Math.pow(timeToExpiry, 1.5) / lognormalVol - 0.5 * lognormalVol / Math.pow(timeToExpiry, 0.5)); return -sign * NORMAL.getPDF(d) * div; }  static double price(final double spot, final double strike, final double timeToExpiry, final double lognormalVol, final double interestRate, final double costOfCarry, final boolean isCall); static double delta(final double spot, final double strike, final double timeToExpiry, final double lognormalVol, final double interestRate,
      final double costOfCarry, final boolean isCall); static double gamma(final double spot, final double strike, final double timeToExpiry, final double lognormalVol, final double interestRate,
      final double costOfCarry, final boolean isCall); static double theta(final double spot, final double strike, final double timeToExpiry, final double lognormalVol, final double interestRate,
      final double costOfCarry, final boolean isCall); static double driftlessTheta(final double forward, final double strike, final double timeToExpiry, final double lognormalVol, final boolean isCall); static double vega(final double spot, final double strike, final double timeToExpiry, final double lognormalVol, final double interestRate,
      final double costOfCarry, final boolean isCall);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void negativeSpotdriftlessThetaTest() { DigitalOptionFunction.driftlessTheta(-SPOT, STRIKES[0], TIME, VOLS[1], true); }
@Test(expectedExceptions = IllegalArgumentException.class) public void negativeStrikedriftlessThetaTest() { DigitalOptionFunction.driftlessTheta(SPOT, -STRIKES[0], TIME, VOLS[1], true); }
@Test(expectedExceptions = IllegalArgumentException.class) public void negativeTimedriftlessThetaTest() { DigitalOptionFunction.driftlessTheta(SPOT, STRIKES[0], -TIME, VOLS[1], true); }
@Test(expectedExceptions = IllegalArgumentException.class) public void negativeVoldriftlessThetaTest() { DigitalOptionFunction.driftlessTheta(SPOT, STRIKES[0], TIME, -VOLS[1], true); }