@Test public void relativeProfitIsCalculatedCorrectlyWhenTradeWasOpened() { assertThat(new BasicCompletedTrade(BUY, LIMIT, asList(SOME_PENDING_ORDER_OPENED, SOME_ORDER_CLOSED)) .getRelativeProfit().get()).isEqualTo(new Price(5)); assertThat(new BasicCompletedTrade(BUY, LIMIT, asList(SOME_PENDING_ORDER_OPENED, OTHER_ORDER_CLOSED)) .getRelativeProfit().get()).isEqualTo(new Price(-5)); assertThat(new BasicCompletedTrade(SELL, LIMIT, asList(SOME_PENDING_ORDER_OPENED, SOME_ORDER_CLOSED)) .getRelativeProfit().get()).isEqualTo(new Price(-5)); assertThat(new BasicCompletedTrade(SELL, LIMIT, asList(SOME_PENDING_ORDER_OPENED, OTHER_ORDER_CLOSED)) .getRelativeProfit().get()).isEqualTo(new Price(5)); }
public Optional<Price> getRelativeProfit() { return getExitPrice().flatMap(exit -> getEntryPrice().map(entry -> exit.minus(entry))) .map(diff -> type == BUY ? diff : diff.inverse()); }
BasicCompletedTrade { public Optional<Price> getRelativeProfit() { return getExitPrice().flatMap(exit -> getEntryPrice().map(entry -> exit.minus(entry))) .map(diff -> type == BUY ? diff : diff.inverse()); } }
BasicCompletedTrade { public Optional<Price> getRelativeProfit() { return getExitPrice().flatMap(exit -> getEntryPrice().map(entry -> exit.minus(entry))) .map(diff -> type == BUY ? diff : diff.inverse()); } BasicCompletedTrade(final OrderType type, final ExecutionCondition executionCondition,
            final List<TradeEvent> events); }
BasicCompletedTrade { public Optional<Price> getRelativeProfit() { return getExitPrice().flatMap(exit -> getEntryPrice().map(entry -> exit.minus(entry))) .map(diff -> type == BUY ? diff : diff.inverse()); } BasicCompletedTrade(final OrderType type, final ExecutionCondition executionCondition,
            final List<TradeEvent> events); OrderType getType(); ExecutionCondition getExecutionCondition(); List<TradeEvent> getEvents(); Optional<Price> getRelativeProfit(); Optional<Ratio> getRateOfReturn(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); }
BasicCompletedTrade { public Optional<Price> getRelativeProfit() { return getExitPrice().flatMap(exit -> getEntryPrice().map(entry -> exit.minus(entry))) .map(diff -> type == BUY ? diff : diff.inverse()); } BasicCompletedTrade(final OrderType type, final ExecutionCondition executionCondition,
            final List<TradeEvent> events); OrderType getType(); ExecutionCondition getExecutionCondition(); List<TradeEvent> getEvents(); Optional<Price> getRelativeProfit(); Optional<Ratio> getRateOfReturn(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }