TotalRiskAlphaCalculator { public double evaluate(final DoubleTimeSeries<?> assetReturnTS, final DoubleTimeSeries<?> riskFreeReturnTS, final DoubleTimeSeries<?> marketReturnTS) { Validate.notNull(assetReturnTS, "asset returns"); Validate.notNull(riskFreeReturnTS, "risk-free returns"); Validate.notNull(marketReturnTS, "market returns"); final double assetReturn = _expectedAssetReturnCalculator.evaluate(assetReturnTS); final double marketReturn = _expectedMarketReturnCalculator.evaluate(marketReturnTS); final double riskFreeReturn = _expectedRiskFreeReturnCalculator.evaluate(riskFreeReturnTS); final double assetStandardDeviation = _assetStandardDeviationCalculator.evaluate(assetReturnTS); final double marketStandardDeviation = _marketStandardDeviationCalculator.evaluate(marketReturnTS); return assetReturn - (riskFreeReturn + (marketReturn - riskFreeReturn) * assetStandardDeviation / marketStandardDeviation); } TotalRiskAlphaCalculator(final DoubleTimeSeriesStatisticsCalculator expectedAssetReturnCalculator,
      final DoubleTimeSeriesStatisticsCalculator expectedRiskFreeReturnCalculator, final DoubleTimeSeriesStatisticsCalculator expectedMarketReturnCalculator,
      final DoubleTimeSeriesStatisticsCalculator assetStandardDeviationCalculator, final DoubleTimeSeriesStatisticsCalculator marketStandardDeviationCalculator); double evaluate(final DoubleTimeSeries<?> assetReturnTS, final DoubleTimeSeries<?> riskFreeReturnTS, final DoubleTimeSeries<?> marketReturnTS);  }
@Test public void test() { assertEquals(CALCULATOR.evaluate(ASSET_RETURN, RISK_FREE, MARKET_RETURN), 0.0194, 1e-4); }