mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-13 12:00:16 +08:00
ENH: Makes breakpoints work in algoscripts started with the run_algo.py
script. Adds an option kwarg to TradingAlgorithm named 'algo_filename' that represents the file where the algoscript came from (if any). The run_algo.py script will pass this argument with the value passed to the '-f' flag. The default name is '<string>' to represent that the script is coming from a string in python and not a file. This matches the behavior of exec and the python convention for compiling code objects.
This commit is contained in:
@@ -197,7 +197,9 @@ class TradingAlgorithm(object):
|
||||
self.event_manager = EventManager()
|
||||
|
||||
if self.algoscript is not None:
|
||||
exec_(self.algoscript, self.namespace)
|
||||
filename = kwargs.pop('algo_filename', '<string>')
|
||||
code = compile(self.algoscript, filename, 'exec')
|
||||
exec_(code, self.namespace)
|
||||
self._initialize = self.namespace.get('initialize')
|
||||
if 'handle_data' not in self.namespace:
|
||||
raise ValueError('You must define a handle_data function.')
|
||||
|
||||
Reference in New Issue
Block a user