RoundTrip implements IRoundTrip { @Override public String getResults() { StringBuilder sb = new StringBuilder(); sb.append(longEntry.getOrderFilledTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)).append(",") .append("Long,") .append(longEntry.getTicker().getSymbol()).append(",") .append(longEntry.getSize()).append(",") .append(longEntry.getFilledPrice()).append(",") .append(0).append(",") .append(longExit.getOrderFilledTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)).append(",") .append(longExit.getFilledPrice()).append(",") .append(0).append(",") .append("Short,") .append(shortEntry.getTicker().getSymbol()).append(",") .append(shortEntry.getSize()).append(",") .append(shortEntry.getFilledPrice()).append(",") .append(0).append(",") .append(shortExit.getFilledPrice()).append(",") .append(0); return sb.toString(); }  @Override void addTradeReference( TradeOrder order, TradeReferenceLine tradeReference ); @Override String getResults(); @Override boolean isComplete(); @Override String getCorrelationId(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final long serialVersionUID; }
@Test public void testGetResults() { StockTicker shortTicker = new StockTicker("SPY"); String expected = "2016-03-03T05:30:45,Long,QQQ,100,50.43,0,2016-03-04T12:45:00,51.46,0,Short,SPY,50,1.23,0,2.34,0"; ZonedDateTime entryDate = ZonedDateTime.of(2016, 3, 3, 5, 30, 45, 0, ZoneId.systemDefault()); ZonedDateTime exitDate =ZonedDateTime.of(2016, 3, 4, 12, 45, 00, 0, ZoneId.systemDefault()); TradeOrder longEntryOrder = new TradeOrder("123", ticker, 100,TradeDirection.BUY); longEntryOrder.setFilledPrice(50.43); longEntryOrder.setOrderFilledTime(entryDate); TradeOrder longExitOrder = new TradeOrder("234", ticker, 100, TradeDirection.SELL); longExitOrder.setFilledPrice(51.46); longExitOrder.setOrderFilledTime(exitDate); TradeOrder shortEntryOrder = new TradeOrder( "345", shortTicker, 50, TradeDirection.SELL); shortEntryOrder.setFilledPrice(1.23); TradeOrder shortExitOrder = new TradeOrder( "456", shortTicker, 50, TradeDirection.BUY); shortExitOrder.setFilledPrice(2.34); roundTrip.longEntry = longEntryOrder; roundTrip.shortEntry = shortEntryOrder; roundTrip.longExit = longExitOrder; roundTrip.shortExit = shortExitOrder; assertEquals(expected, roundTrip.getResults()); }