code: public final double getValueAtRisk(final Number confidenceLevel, final Number timePeriod) {
  
          final double aReturn = this.getMeanReturn();
          final double aStdDev = this.getVolatility();
  
          final double tmpConfidenceScale = SQRT_TWO * RandomUtils.erfi(ONE - (TWO * (ONE - confidenceLevel.doubleValue())));
          final double tmpTimePeriod = timePeriod.doubleValue();
  
          return PrimitiveMath.MAX.invoke((PrimitiveMath.SQRT.invoke(tmpTimePeriod) * aStdDev * tmpConfidenceScale) - (tmpTimePeriod * aReturn), ZERO);
      }
docs: Value at Risk (VaR) is the maximum loss not exceeded with a given probability defined as the confidence
  level, over a given period of time.