Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
llazzaro committed May 8, 2015
1 parent 0bb8bb6 commit 0a8a1a4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/unit/test_trading_engine.py
Expand Up @@ -19,9 +19,21 @@ def setUp(self):
self.symbols = ['GOOG']
self.strategy.setSymbols(self.symbols)

self.strategy2 = StrategyFactory.createStrategy(self.config.getOption(CONF_ULTRAFINANCE_SECTION, CONF_STRATEGY_NAME),
self.config.getSection(CONF_ULTRAFINANCE_SECTION))
self.symbols = ['GOOG']
self.strategy2.setSymbols(self.symbols)

def tearDown(self):
pass

def test_stop(self):
trading_engine = TradingEngine()
self.assertFalse(trading_engine._stop)
trading_engine.stop()

self.assertTrue(trading_engine._stop)

def test_register_strategy(self):
trading_engine = TradingEngine()
trading_engine.register(self.strategy)
Expand All @@ -33,3 +45,31 @@ def test_register_strategy(self):
self.assertEquals(self.strategy, strategy)
self.assertEquals(self.symbols, event[strategy]['symbols'])
self.assertEquals(0, event[strategy]['fail'])

def test_unregister_strategy(self):
trading_engine = TradingEngine()
trading_engine.register(self.strategy)

self.assertEquals(len(trading_engine.subs.keys()), 2)
trading_engine.unregister(self.strategy)
# since this was the only strategy check if events is empty
self.assertEquals(len(trading_engine.subs.keys()), 0)
trading_engine.register(self.strategy)
trading_engine.register(self.strategy2)
self.assertEquals(len(trading_engine.subs.keys()), 2)
self.assertEquals(len(map(lambda vdict: vdict.keys(), trading_engine.subs.values())[0]), 2)
self.assertEquals(len(map(lambda vdict: vdict.keys(), trading_engine.subs.values())[1]), 2)
trading_engine.unregister(self.strategy)
self.assertEquals(len(trading_engine.subs.keys()), 2)
self.assertEquals(len(map(lambda vdict: vdict.keys(), trading_engine.subs.values())[0]), 1)
self.assertEquals(len(map(lambda vdict: vdict.keys(), trading_engine.subs.values())[1]), 1)


def test_consume_ticks(self):
pass

def test_consume_executed_order(self):
pass

def test_place_order(self):
pass

0 comments on commit 0a8a1a4

Please sign in to comment.