@Test public void waitForSinceLastBuyRuleIsSatisfied() { rule = new WaitForRule(Order.OrderType.BUY, 3); assertFalse(rule.isSatisfied(0, null)); assertFalse(rule.isSatisfied(1, tradingRecord)); tradingRecord.enter(10); assertFalse(rule.isSatisfied(10, tradingRecord)); assertFalse(rule.isSatisfied(11, tradingRecord)); assertFalse(rule.isSatisfied(12, tradingRecord)); assertTrue(rule.isSatisfied(13, tradingRecord)); assertTrue(rule.isSatisfied(14, tradingRecord)); tradingRecord.exit(15); assertTrue(rule.isSatisfied(15, tradingRecord)); assertTrue(rule.isSatisfied(16, tradingRecord)); tradingRecord.enter(17); assertFalse(rule.isSatisfied(17, tradingRecord)); assertFalse(rule.isSatisfied(18, tradingRecord)); assertFalse(rule.isSatisfied(19, tradingRecord)); assertTrue(rule.isSatisfied(20, tradingRecord)); }
@Override public boolean isSatisfied(int index, TradingRecord tradingRecord) { boolean satisfied = false; if (tradingRecord != null) { Order lastOrder = tradingRecord.getLastOrder(orderType); if (lastOrder != null) { int currentNumberOfBars = index - lastOrder.getIndex(); satisfied = currentNumberOfBars >= numberOfBars; } } traceIsSatisfied(index, satisfied); return satisfied; }
WaitForRule extends AbstractRule { @Override public boolean isSatisfied(int index, TradingRecord tradingRecord) { boolean satisfied = false; if (tradingRecord != null) { Order lastOrder = tradingRecord.getLastOrder(orderType); if (lastOrder != null) { int currentNumberOfBars = index - lastOrder.getIndex(); satisfied = currentNumberOfBars >= numberOfBars; } } traceIsSatisfied(index, satisfied); return satisfied; } }
WaitForRule extends AbstractRule { @Override public boolean isSatisfied(int index, TradingRecord tradingRecord) { boolean satisfied = false; if (tradingRecord != null) { Order lastOrder = tradingRecord.getLastOrder(orderType); if (lastOrder != null) { int currentNumberOfBars = index - lastOrder.getIndex(); satisfied = currentNumberOfBars >= numberOfBars; } } traceIsSatisfied(index, satisfied); return satisfied; } WaitForRule(OrderType orderType, int numberOfBars); }
WaitForRule extends AbstractRule { @Override public boolean isSatisfied(int index, TradingRecord tradingRecord) { boolean satisfied = false; if (tradingRecord != null) { Order lastOrder = tradingRecord.getLastOrder(orderType); if (lastOrder != null) { int currentNumberOfBars = index - lastOrder.getIndex(); satisfied = currentNumberOfBars >= numberOfBars; } } traceIsSatisfied(index, satisfied); return satisfied; } WaitForRule(OrderType orderType, int numberOfBars); @Override boolean isSatisfied(int index, TradingRecord tradingRecord); }
WaitForRule extends AbstractRule { @Override public boolean isSatisfied(int index, TradingRecord tradingRecord) { boolean satisfied = false; if (tradingRecord != null) { Order lastOrder = tradingRecord.getLastOrder(orderType); if (lastOrder != null) { int currentNumberOfBars = index - lastOrder.getIndex(); satisfied = currentNumberOfBars >= numberOfBars; } } traceIsSatisfied(index, satisfied); return satisfied; } WaitForRule(OrderType orderType, int numberOfBars); @Override boolean isSatisfied(int index, TradingRecord tradingRecord);  }