@Test public void dividesDirectionalMovementThrougTrueRange() { when(dm.indicate(SOME_MARKET_PRICE)).thenReturn(optPrice(10)).thenReturn(optPrice(900)); when(trueRange.indicate(SOME_MARKET_PRICE)).thenReturn(optPrice(20)).thenReturn(optPrice(30)); assertThat(cut.indicate(SOME_MARKET_PRICE)).contains(new Ratio(0.5)); assertThat(cut.indicate(SOME_MARKET_PRICE)).contains(new Ratio(30)); }
@Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Price> optDm = directionalMovement.indicate(marketPrice); final Optional<Price> optTr = trueRange.indicate(marketPrice); return optDm.flatMap(dm -> optTr.map(tr -> tr.asPipette() == 0 ? ZERO : new Ratio(dm.divide(tr).asBasic()))); }
DirectionalIndex implements Indicator<Ratio, C> { @Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Price> optDm = directionalMovement.indicate(marketPrice); final Optional<Price> optTr = trueRange.indicate(marketPrice); return optDm.flatMap(dm -> optTr.map(tr -> tr.asPipette() == 0 ? ZERO : new Ratio(dm.divide(tr).asBasic()))); } }
DirectionalIndex implements Indicator<Ratio, C> { @Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Price> optDm = directionalMovement.indicate(marketPrice); final Optional<Price> optTr = trueRange.indicate(marketPrice); return optDm.flatMap(dm -> optTr.map(tr -> tr.asPipette() == 0 ? ZERO : new Ratio(dm.divide(tr).asBasic()))); } DirectionalIndex(final Indicator<Price, C> directionalMovement, final Indicator<Price, C> trueRange); }
DirectionalIndex implements Indicator<Ratio, C> { @Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Price> optDm = directionalMovement.indicate(marketPrice); final Optional<Price> optTr = trueRange.indicate(marketPrice); return optDm.flatMap(dm -> optTr.map(tr -> tr.asPipette() == 0 ? ZERO : new Ratio(dm.divide(tr).asBasic()))); } DirectionalIndex(final Indicator<Price, C> directionalMovement, final Indicator<Price, C> trueRange); @Override Optional<Ratio> indicate(final C marketPrice); }
DirectionalIndex implements Indicator<Ratio, C> { @Override public Optional<Ratio> indicate(final C marketPrice) { final Optional<Price> optDm = directionalMovement.indicate(marketPrice); final Optional<Price> optTr = trueRange.indicate(marketPrice); return optDm.flatMap(dm -> optTr.map(tr -> tr.asPipette() == 0 ? ZERO : new Ratio(dm.divide(tr).asBasic()))); } DirectionalIndex(final Indicator<Price, C> directionalMovement, final Indicator<Price, C> trueRange); @Override Optional<Ratio> indicate(final C marketPrice);  }