@Test public void candlesArePassedThroughToTheIndicators() { when(averagePlusDi.indicate(any())).thenReturn(empty()); when(averageMinusDi.indicate(any())).thenReturn(empty()); cut.indicate(SOME_CANDLE); verify(averagePlusDi).indicate(SOME_CANDLE); verify(averageMinusDi).indicate(SOME_CANDLE); }
@Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Ratio> optPlusDi = averagePlusDi.indicate(marketPrice); final Optional<Ratio> optMinusDi = averageMinusDi.indicate(marketPrice); return optPlusDi.flatMap(plusDi -> optMinusDi.map(minusDi -> new Ratio( abs((plusDi.asBasic() - minusDi.asBasic()) / (plusDi.asBasic() + minusDi.asBasic()))))); }
DirectionalMovementIndex implements Indicator<Ratio, C> { @Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Ratio> optPlusDi = averagePlusDi.indicate(marketPrice); final Optional<Ratio> optMinusDi = averageMinusDi.indicate(marketPrice); return optPlusDi.flatMap(plusDi -> optMinusDi.map(minusDi -> new Ratio( abs((plusDi.asBasic() - minusDi.asBasic()) / (plusDi.asBasic() + minusDi.asBasic()))))); } }
DirectionalMovementIndex implements Indicator<Ratio, C> { @Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Ratio> optPlusDi = averagePlusDi.indicate(marketPrice); final Optional<Ratio> optMinusDi = averageMinusDi.indicate(marketPrice); return optPlusDi.flatMap(plusDi -> optMinusDi.map(minusDi -> new Ratio( abs((plusDi.asBasic() - minusDi.asBasic()) / (plusDi.asBasic() + minusDi.asBasic()))))); } DirectionalMovementIndex(final Indicator<Ratio, C> averagePlusDi, final Indicator<Ratio, C> averageMinusDi); }
DirectionalMovementIndex implements Indicator<Ratio, C> { @Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Ratio> optPlusDi = averagePlusDi.indicate(marketPrice); final Optional<Ratio> optMinusDi = averageMinusDi.indicate(marketPrice); return optPlusDi.flatMap(plusDi -> optMinusDi.map(minusDi -> new Ratio( abs((plusDi.asBasic() - minusDi.asBasic()) / (plusDi.asBasic() + minusDi.asBasic()))))); } DirectionalMovementIndex(final Indicator<Ratio, C> averagePlusDi, final Indicator<Ratio, C> averageMinusDi); @Override Optional<Ratio> indicate(final C marketPrice); }
DirectionalMovementIndex implements Indicator<Ratio, C> { @Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Ratio> optPlusDi = averagePlusDi.indicate(marketPrice); final Optional<Ratio> optMinusDi = averageMinusDi.indicate(marketPrice); return optPlusDi.flatMap(plusDi -> optMinusDi.map(minusDi -> new Ratio( abs((plusDi.asBasic() - minusDi.asBasic()) / (plusDi.asBasic() + minusDi.asBasic()))))); } DirectionalMovementIndex(final Indicator<Ratio, C> averagePlusDi, final Indicator<Ratio, C> averageMinusDi); @Override Optional<Ratio> indicate(final C marketPrice);  }