mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-01 18:37:40 +08:00
updated exception test tracebacks
This commit is contained in:
@@ -19,7 +19,6 @@ EXTENDED_TIMEOUT = 90
|
||||
|
||||
allocator = AddressAllocator(1000)
|
||||
|
||||
|
||||
class ExceptionTestCase(TestCase):
|
||||
|
||||
leased_sockets = defaultdict(list)
|
||||
@@ -104,73 +103,32 @@ class ExceptionTestCase(TestCase):
|
||||
# components, exception in Monitor, etc. write tests
|
||||
# for those scenarios.
|
||||
|
||||
|
||||
|
||||
INITIALIZE_TB =\
|
||||
{'message': 'Algo exception in initialize',
|
||||
'name': 'Exception',
|
||||
'stack': [{'filename': '/zipline/lines.py', 'line': 'for event in self.gen:', 'lineno': 152, 'method': 'stream_results'},
|
||||
'stack': [{'filename': '/zipline/lines.py', 'line': 'for event in self.gen:', 'lineno': 157, 'method': 'stream_results'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'self.algo,', 'lineno': 93, 'method': 'simulate'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'self.algo.initialize()',
|
||||
'lineno': 123,
|
||||
'method': '__init__'},
|
||||
{'filename': '/zipline/test_algorithms.py',
|
||||
'line': 'raise Exception("Algo exception in initialize")',
|
||||
'lineno': 166,
|
||||
'method': 'initialize'}]}
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'self.algo.initialize()', 'lineno': 123, 'method': '__init__'},
|
||||
{'filename': '/zipline/test_algorithms.py', 'line': 'raise Exception("Algo exception in initialize")', 'lineno': 166, 'method': 'initialize'}]}
|
||||
|
||||
HANDLE_DATA_TB =\
|
||||
{'message': 'Algo exception in handle_data',
|
||||
'name': 'Exception',
|
||||
'stack': [{'filename': '/zipline/lines.py', 'line': 'for event in self.gen:', 'lineno': 152, 'method': 'stream_results'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'for message in algo_results:',
|
||||
'lineno': 100,
|
||||
'method': 'simulate'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'return self.__generator.next()',
|
||||
'lineno': 144,
|
||||
'method': 'next'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'self.update_current_snapshot(event)',
|
||||
'lineno': 199,
|
||||
'method': '_gen'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'self.simulate_current_snapshot()',
|
||||
'lineno': 221,
|
||||
'method': 'update_current_snapshot'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'self.algo.handle_data(self.universe)',
|
||||
'lineno': 246,
|
||||
'method': 'simulate_current_snapshot'},
|
||||
{'filename': '/zipline/test_algorithms.py',
|
||||
'line': 'raise Exception("Algo exception in handle_data")',
|
||||
'lineno': 187,
|
||||
'method': 'handle_data'}]}
|
||||
'stack': [{'filename': '/zipline/lines.py', 'line': 'for event in self.gen:', 'lineno': 157, 'method': 'stream_results'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'for message in algo_results:', 'lineno': 100, 'method': 'simulate'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'return self.__generator.next()', 'lineno': 144, 'method': 'next'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'self.update_current_snapshot(event)', 'lineno': 199, 'method': '_gen'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'self.simulate_current_snapshot()', 'lineno': 221, 'method': 'update_current_snapshot'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'self.algo.handle_data(self.universe)', 'lineno': 246, 'method': 'simulate_current_snapshot'},
|
||||
{'filename': '/zipline/test_algorithms.py', 'line': 'raise Exception("Algo exception in handle_data")', 'lineno': 187, 'method': 'handle_data'}]}
|
||||
|
||||
ZERO_DIV_TB= \
|
||||
{'message': 'integer division or modulo by zero',
|
||||
'name': 'ZeroDivisionError',
|
||||
'stack': [{'filename': '/zipline/lines.py', 'line': 'for event in self.gen:', 'lineno': 152, 'method': 'stream_results'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'for message in algo_results:',
|
||||
'lineno': 100,
|
||||
'method': 'simulate'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'return self.__generator.next()',
|
||||
'lineno': 144,
|
||||
'method': 'next'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'self.update_current_snapshot(event)',
|
||||
'lineno': 199,
|
||||
'method': '_gen'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'self.simulate_current_snapshot()',
|
||||
'lineno': 221,
|
||||
'method': 'update_current_snapshot'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py',
|
||||
'line': 'self.algo.handle_data(self.universe)',
|
||||
'lineno': 246,
|
||||
'method': 'simulate_current_snapshot'},
|
||||
'stack': [{'filename': '/zipline/lines.py', 'line': 'for event in self.gen:', 'lineno': 157, 'method': 'stream_results'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'for message in algo_results:', 'lineno': 100, 'method': 'simulate'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'return self.__generator.next()', 'lineno': 144, 'method': 'next'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'self.update_current_snapshot(event)', 'lineno': 199, 'method': '_gen'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'self.simulate_current_snapshot()', 'lineno': 221, 'method': 'update_current_snapshot'},
|
||||
{'filename': '/zipline/gens/tradesimulation.py', 'line': 'self.algo.handle_data(self.universe)', 'lineno': 246, 'method': 'simulate_current_snapshot'},
|
||||
{'filename': '/zipline/test_algorithms.py', 'line': '5/0', 'lineno': 218, 'method': 'handle_data'}]}
|
||||
|
||||
@@ -85,9 +85,17 @@ def sequential_transforms(stream_in, *transforms):
|
||||
stream_out = reduce(lambda stream, tnfm: tnfm.transform(stream),
|
||||
transforms,
|
||||
stream_in)
|
||||
return stream_out
|
||||
|
||||
|
||||
dt_aliased = alias_dt(stream_out)
|
||||
return dt_aliased
|
||||
|
||||
def alias_dt(stream_in):
|
||||
"""
|
||||
Alias the dt field to datetime on each message.
|
||||
"""
|
||||
for message in stream_in:
|
||||
message['datetime'] = message['dt']
|
||||
yield message
|
||||
|
||||
|
||||
|
||||
|
||||
+4
-3
@@ -74,7 +74,7 @@ from zipline.utils import factory
|
||||
from zipline.test_algorithms import TestAlgorithm
|
||||
|
||||
from zipline.gens.composites import \
|
||||
date_sorted_sources, merged_transforms
|
||||
date_sorted_sources, merged_transforms, sequential_transforms
|
||||
from zipline.gens.transform import Passthrough, StatefulTransform
|
||||
from zipline.gens.tradesimulation import TradeSimulationClient as tsc
|
||||
from logbook import Logger, NestedSetup, Processor
|
||||
@@ -103,9 +103,10 @@ class SimulatedTrading(object):
|
||||
self.date_sorted = date_sorted_sources(*sources)
|
||||
self.transforms = transforms
|
||||
self.transforms.append(StatefulTransform(Passthrough))
|
||||
self.merged = merged_transforms(self.date_sorted, *self.transforms)
|
||||
# Formerly merged_transforms.
|
||||
self.with_tnfms = sequential_transforms(self.date_sorted, *self.transforms)
|
||||
self.trading_client = tsc(algorithm, environment, style)
|
||||
self.gen = self.trading_client.simulate(self.merged)
|
||||
self.gen = self.trading_client.simulate(self.with_tnfms)
|
||||
self.results_uri = results_socket_uri
|
||||
self.results_socket = None
|
||||
self.context = context
|
||||
|
||||
Reference in New Issue
Block a user