mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-02 12:30:45 +08:00
MAINT: Move ZiplineAPI context so that it always wraps main loop.
Move the responsibility of wrapping the main simulation loop in the ZiplineAPI context from the algorithm modules generator setup to the main trade simulation loop, so that different methods of invoking loop do not need to duplicate how the context is set. To make it easier for internal implementation of handle_data to transition off of calling the ZiplineAPI every bar, to only invoking the context once per simulation.
This commit is contained in:
@@ -510,15 +510,14 @@ class TradingAlgorithm(object):
|
||||
self.sim_params.data_frequency,
|
||||
)
|
||||
|
||||
with ZiplineAPI(self):
|
||||
# loop through simulated_trading, each iteration returns a
|
||||
# perf dictionary
|
||||
perfs = []
|
||||
for perf in self.gen:
|
||||
perfs.append(perf)
|
||||
# loop through simulated_trading, each iteration returns a
|
||||
# perf dictionary
|
||||
perfs = []
|
||||
for perf in self.gen:
|
||||
perfs.append(perf)
|
||||
|
||||
# convert perf dict to pandas dataframe
|
||||
daily_stats = self._create_daily_stats(perfs)
|
||||
# convert perf dict to pandas dataframe
|
||||
daily_stats = self._create_daily_stats(perfs)
|
||||
|
||||
self.analyze(daily_stats)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user