EODTradingStrategy implements Level1QuoteListener, OrderEventListener, BrokerErrorListener { public ZonedDateTime getNextBusinessDay(ZonedDateTime date) { if( exitSeconds != 0 ) { date = date.plusSeconds(exitSeconds); return date; } date = date.plusDays(1); while (date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY) { date = date.plusDays(1); } date = ZonedDateTime.of(date.getYear(),date.getMonthValue(),date.getDayOfMonth(), exitTime.getHour(), exitTime.getMinute(), exitTime.getSecond(), 0, ZoneId.systemDefault()); return date; }  void start(String propFile); synchronized void placeMOCOrders(Ticker longTicker, Ticker shortTicker, ZonedDateTime lastReportedTime); @Override void orderEvent(OrderEvent event); @Override void quoteRecieved(ILevel1Quote quote); ZonedDateTime getNextBusinessDay(ZonedDateTime date); @Override void brokerErrorFired(BrokerError error); static void main(String[] args);  }
@Test public void testGetNextBusinessDay_ExitSecondsSet() { ZonedDateTime ldt = ZonedDateTime.of(2016, 2, 25, 6, 45, 55, 0, ZoneId.systemDefault()); ZonedDateTime expectedDatetime = ZonedDateTime.of(2016, 2, 25, 6, 46, 55, 0, ZoneId.systemDefault()); strategy.exitSeconds = 60; assertEquals(expectedDatetime, strategy.getNextBusinessDay(ldt)); }
@Test public void testGetNextBusinessDay_Thursday() { ZonedDateTime ldt = ZonedDateTime.of(2016, 2, 25, 6, 45, 55, 0, ZoneId.systemDefault()); ZonedDateTime expectedDatetime = ZonedDateTime.of(2016, 2, 26, 6, 30, 2, 0, ZoneId.systemDefault()); strategy.exitTime = LocalTime.of(6,30,2); assertEquals(expectedDatetime, strategy.getNextBusinessDay(ldt)); }
@Test public void testGetNextBusinessDay_Friday() { ZonedDateTime ldt = ZonedDateTime.of(2016, 2, 26, 6, 45, 55, 0, ZoneId.systemDefault()); ZonedDateTime expectedDatetime = ZonedDateTime.of(2016, 2, 29, 6, 30, 2, 0, ZoneId.systemDefault()); strategy.exitTime = LocalTime.of(6,30,2); assertEquals(expectedDatetime, strategy.getNextBusinessDay(ldt)); }
@Test public void testGetNextBusinessDay_Satruday() { ZonedDateTime ldt = ZonedDateTime.of(2016, 2, 27, 6, 45, 55, 0, ZoneId.systemDefault()); ZonedDateTime expectedDatetime = ZonedDateTime.of(2016, 2, 29, 6, 30, 2, 0, ZoneId.systemDefault()); strategy.exitTime = LocalTime.of(6,30,2); assertEquals(expectedDatetime, strategy.getNextBusinessDay(ldt)); }