public void testSignalGenerationSize() throws Exception { Rule buySell = new BuySellNextDayRule(account, asset, conditions); Session session = buySell.generateSignals(today.minusDays(5), today.minusDays(2)); assertEquals(2, session.getTrades().size()); account = new Account(new BigDecimal(1000), today.minusDays(6)); buySell = new BuySellNextDayRule(account, asset, conditions); assertEquals( 2, buySell.generateSignals(today.minusDays(5), today.minusDays(1)).getTrades().size()); }
public void quitsIfInsufficientFunds() throws Exception { account = new Account(new BigDecimal(1), today.minusDays(6)); Rule buyAndHold = new BuyAndHoldRule(account, asset, conditions); assertEquals( 0, buyAndHold.generateSignals(today.minusDays(5), today.minusDays(4)).getTrades().size()); }
public void testOnlyShorting() throws Exception { Rule noTrades = new OnlyShortRule(account, asset, conditions); Session session = noTrades.generateSignals(today.minusDays(5), today.minusDays(1)); assertEquals(1, session.getTrades().size()); }
public void testNotEnteringMarket() throws Exception { Rule noTrades = new NeverEnterMarketRule(account, asset, conditions); assertEquals( 0, noTrades.generateSignals(today.minusDays(5), today.minusDays(1)).getTrades().size()); }
public void testCloseLastTrade() throws Exception { Rule buySell = new BuySellNextDayRule(account, asset, conditions); Session signals = buySell.generateSignals(today.minusDays(5), today.minusDays(2)); assertTrue(signals.lastTrade().isClosed()); assertEquals(today.minusDays(2), signals.lastTrade().getClose()); }
public void testDontEmitMultipleIdenticalSignals() throws Exception { Rule buyAndHold = new BuyAndHoldRule(account, asset, conditions); assertEquals( 1, buyAndHold.generateSignals(today.minusDays(5), today.minusDays(3)).getTrades().size()); }