diff --git a/tests/test_exception_handling.py b/tests/test_exception_handling.py index 0778a037..83e6c7f4 100644 --- a/tests/test_exception_handling.py +++ b/tests/test_exception_handling.py @@ -55,7 +55,7 @@ class ExceptionTestCase(TestCase): self.assertEqual(len(output), 1) self.assertEqual(output[-1]['prefix'], 'EXCEPTION') payload = output[-1]['payload']['stack'] - #check(self, payload, INITIALIZE_TB) + check(self, payload, INITIALIZE_TB) self.assertTrue(zipline.sim.ready()) self.assertFalse(zipline.sim.exception) @@ -94,59 +94,66 @@ class ExceptionTestCase(TestCase): INITIALIZE_TB =\ -[{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', +[{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', 'line': 'self._run()', - 'lineno': 229, + 'lineno': 204, 'method': 'run'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', 'line': 'self.loop()', - 'lineno': 220, + 'lineno': 195, 'method': '_run'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', - 'line': 'self.do_work()', - 'lineno': 257, - 'method': 'loop'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', - 'line': 'self.initialize_algo()', - 'lineno': 100, - 'method': 'do_work'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', - 'line': 'self.do_op(self.algorithm.initialize)', - 'lineno': 83, - 'method': 'initialize_algo'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', - 'line': 'callable_op(*args, **kwargs)', - 'lineno': 208, - 'method': 'do_op'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/test_algorithms.py', - 'line': 'raise Exception("Algo exception in initialize")', - 'lineno': 162, - 'method': 'initialize'}] - -HANDLE_DATA_TB =\ -[{'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', 'line': 'self._run()', 'lineno': 204, 'method': 'run'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', 'line': 'self.loop()', 'lineno': 195, 'method': '_run'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', 'line': 'self.do_work()', 'lineno': 235, 'method': 'loop'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', - 'line': 'self.process_event(event)', - 'lineno': 116, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', + 'line': 'self.initialize_algo()', + 'lineno': 97, 'method': 'do_work'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', - 'line': 'self.run_algorithm()', - 'lineno': 164, - 'method': 'process_event'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', - 'line': 'self.do_op(self.algorithm.handle_data, data)', - 'lineno': 186, - 'method': 'run_algorithm'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', + 'line': 'self.do_op(self.algorithm.initialize)', + 'lineno': 80, + 'method': 'initialize_algo'}, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', 'line': 'callable_op(*args, **kwargs)', 'lineno': 206, 'method': 'do_op'}, - {'file': '/Users/fawce/projects/qexec/zipline_repo/zipline/test_algorithms.py', + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/test_algorithms.py', + 'line': 'raise Exception("Algo exception in initialize")', + 'lineno': 166, + 'method': 'initialize'}] + + +HANDLE_DATA_TB =\ +[{'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', + 'line': 'self._run()', + 'lineno': 204, + 'method': 'run'}, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', + 'line': 'self.loop()', + 'lineno': 195, + 'method': '_run'}, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/core/component.py', + 'line': 'self.do_work()', + 'lineno': 235, + 'method': 'loop'}, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', + 'line': 'self.process_event(event)', + 'lineno': 116, + 'method': 'do_work'}, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', + 'line': 'self.run_algorithm()', + 'lineno': 164, + 'method': 'process_event'}, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', + 'line': 'self.do_op(self.algorithm.handle_data, data)', + 'lineno': 186, + 'method': 'run_algorithm'}, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/components/tradesimulation.py', + 'line': 'callable_op(*args, **kwargs)', + 'lineno': 206, + 'method': 'do_op'}, + {'filename': '/Users/fawce/projects/qexec/zipline_repo/zipline/test_algorithms.py', 'line': 'raise Exception("Algo exception in handle_data")', - 'lineno': 183, + 'lineno': 187, 'method': 'handle_data'}] diff --git a/tests/test_finance.py b/tests/test_finance.py index 3ac50997..d108e019 100644 --- a/tests/test_finance.py +++ b/tests/test_finance.py @@ -41,12 +41,12 @@ class FinanceTestCase(TestCase): self.zipline_test_config = { 'allocator' : allocator, 'sid' : 133, - 'devel' : True, + #'devel' : True, 'results_socket' : allocator.lease(1)[0] } self.ctx = zmq.Context() - setup_logger(self, '/var/log/qexec/qexec.log') + setup_logger(self) def tearDown(self): teardown_logger(self) @@ -128,7 +128,7 @@ class FinanceTestCase(TestCase): #@timed(DEFAULT_TIMEOUT) def test_sid_filter(self): - """Ensure the algorithm's filter prevents events from arriving.""" + # Ensure the algorithm's filter prevents events from arriving. # create a test algorithm whose filter will not match any of the # trade events sourced inside the zipline. order_amount = 100 diff --git a/zipline/finance/sources.py b/zipline/finance/sources.py index 0aba2186..9cde473c 100644 --- a/zipline/finance/sources.py +++ b/zipline/finance/sources.py @@ -40,14 +40,7 @@ class TradeDataSource(DataSource): if event.sid in self.filter['sid']: message = zp.DATASOURCE_FRAME(event) - else: - blank = ndict({ - "type" : zp.DATASOURCE_TYPE.TRADE, - "source_id" : self.get_id - }) - message = zp.DATASOURCE_FRAME(blank) - - self.data_socket.send(message) + self.data_socket.send(message) class RandomEquityTrades(TradeDataSource): diff --git a/zipline/test_algorithms.py b/zipline/test_algorithms.py index 1755bc53..d66cdef0 100644 --- a/zipline/test_algorithms.py +++ b/zipline/test_algorithms.py @@ -54,7 +54,7 @@ class TestAlgorithm(): at the close of a simulation. """ - def __init__(self, sid, amount, order_count): + def __init__(self, sid, amount, order_count, sid_filter=None): self.count = order_count self.sid = sid self.amount = amount @@ -63,6 +63,10 @@ class TestAlgorithm(): self.order = None self.frame_count = 0 self.portfolio = None + if sid_filter: + self.sid_filter = sid_filter + else: + self.sid_filter = [self.sid] def initialize(self): pass @@ -84,7 +88,7 @@ class TestAlgorithm(): self.incr += 1 def get_sid_filter(self): - return [self.sid] + return self.sid_filter # class HeavyBuyAlgorithm():