mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-12 11:50:11 +08:00
BUG: Put initialization of perf_tracker back in __init__
The initialization of perf_tracker had been moved from __init__ in TradingAlgorithm to _create_generator. This caused perf_tracker to not be ready when portfolio requested it. portfolio was consequently not ready for access in init. portfolio can now be accessed in init again, assuming valid sim_params are passed. Otherwise it will be available in handle_data() after _create_generator() is called.
This commit is contained in:
@@ -157,9 +157,7 @@ class TradingAlgorithm(object):
|
||||
self.sim_params = create_simulation_parameters(
|
||||
capital_base=self.capital_base
|
||||
)
|
||||
|
||||
# perf_tacker gets instantiated in ._create_generator()
|
||||
self.perf_tracker = None
|
||||
self.perf_tracker = PerformanceTracker(self.sim_params)
|
||||
|
||||
self.blotter = kwargs.pop('blotter', None)
|
||||
if not self.blotter:
|
||||
@@ -318,8 +316,8 @@ class TradingAlgorithm(object):
|
||||
skipped.
|
||||
"""
|
||||
# Instantiate perf_tracker
|
||||
if self.perf_tracker is None:
|
||||
self.perf_tracker = PerformanceTracker(sim_params)
|
||||
self.perf_tracker = PerformanceTracker(sim_params)
|
||||
self.portfolio_needs_update = True
|
||||
|
||||
self.data_gen = self._create_data_generator(source_filter, sim_params)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user