HistoricalVolatilityCloseCalculator extends HistoricalVolatilityCalculator { @Override public Double evaluate(final LocalDateDoubleTimeSeries... x) { testTimeSeries(x, 2); if (x.length > 1) { s_logger.info("Time series array contained more than one series; only using the first one"); } testTimeSeries(x, 2); final DoubleTimeSeries<?> returnTS = _returnCalculator.evaluate(x); final Iterator<Double> iter = returnTS.valuesIterator(); Double value; double sum = 0; double sumSq = 0; final int n = returnTS.size() - 1; while (iter.hasNext()) { value = iter.next(); sum += value; sumSq += value * value; } return Math.sqrt((sumSq - sum * sum / (n + 1)) / n); } HistoricalVolatilityCloseCalculator(final TimeSeriesReturnCalculator returnCalculator);  HistoricalVolatilityCloseCalculator(final TimeSeriesReturnCalculator returnCalculator, final CalculationMode mode);  HistoricalVolatilityCloseCalculator(final TimeSeriesReturnCalculator returnCalculator, final CalculationMode mode, final double percentBadDataPoints); @Override Double evaluate(final LocalDateDoubleTimeSeries... x); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void test() { assertEquals(CALCULATOR.evaluate(new LocalDateDoubleTimeSeries[] {CLOSE_TS}), 0.0173, EPS); }