@Test public void absoluteProfitIsCalculatedCorrectly() { final CompletedTrade win = new CompletedTrade(BUY, LIMIT, EURUSD, new Volume(10, LOT), new Price(10), asList(SOME_PENDING_ORDER_OPENED, SOME_ORDER_CLOSED)); assertThat(win.getAbsoluteProfit().get()).isEqualTo(new Money(50, 00, "USD")); final CompletedTrade win2 = new CompletedTrade(BUY, LIMIT, EURUSD, new Volume(3, MINI_LOT), new Price(10), asList(SOME_PENDING_ORDER_OPENED, OTHER_ORDER_CLOSED)); assertThat(win2.getAbsoluteProfit().get()).isEqualTo(new Money(2883, 30, "USD")); final CompletedTrade loose = new CompletedTrade(SELL, LIMIT, USDJPY, new Volume(6, MICRO_LOT), new Price(10), asList(SOME_PENDING_ORDER_OPENED, SOME_ORDER_CLOSED)); assertThat(loose.getAbsoluteProfit().get()).isEqualTo(new Money(-30, "JPY")); final CompletedTrade notClosed = new CompletedTrade(BUY, LIMIT, EURUSD, new Volume(10, LOT), new Price(10), asList(SOME_PENDING_ORDER_PLACED, SOME_PENDING_ORDER_OPENED)); assertThat(notClosed.getAbsoluteProfit()).isEmpty(); }
public Optional<Money> getAbsoluteProfit() { return getRelativeProfit().map(profit -> profit.multiply(volume, symbol.getQuoteCurrency())); }
CompletedTrade extends BasicCompletedTrade { public Optional<Money> getAbsoluteProfit() { return getRelativeProfit().map(profit -> profit.multiply(volume, symbol.getQuoteCurrency())); } }
CompletedTrade extends BasicCompletedTrade { public Optional<Money> getAbsoluteProfit() { return getRelativeProfit().map(profit -> profit.multiply(volume, symbol.getQuoteCurrency())); } CompletedTrade(final OrderType type, final ExecutionCondition executionCondition, final ForexSymbol symbol,
            final Volume volume, final Price spread, final List<TradeEvent> events); }
CompletedTrade extends BasicCompletedTrade { public Optional<Money> getAbsoluteProfit() { return getRelativeProfit().map(profit -> profit.multiply(volume, symbol.getQuoteCurrency())); } CompletedTrade(final OrderType type, final ExecutionCondition executionCondition, final ForexSymbol symbol,
            final Volume volume, final Price spread, final List<TradeEvent> events); ForexSymbol getSymbol(); Volume getVolume(); Price getSpread(); Optional<Money> getAbsoluteProfit(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); }
CompletedTrade extends BasicCompletedTrade { public Optional<Money> getAbsoluteProfit() { return getRelativeProfit().map(profit -> profit.multiply(volume, symbol.getQuoteCurrency())); } CompletedTrade(final OrderType type, final ExecutionCondition executionCondition, final ForexSymbol symbol,
            final Volume volume, final Price spread, final List<TradeEvent> events); ForexSymbol getSymbol(); Volume getVolume(); Price getSpread(); Optional<Money> getAbsoluteProfit(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }