Open temph2020 opened 1 month ago
fixed factor should add to DataLoader, there is no reason to add pre-calculated data during the calculation stage.
I guess you want to fine-tune the backtest parameters on last factor, but you should use various statistical tools to evaluate the factors, instead of backtest. we only perform backtesting before real trading.
this involves too much basic knowledge, and I am not going to answer any more of this.
I’ve modified the CustomAlgorithm._data_updated() method to prevent recalculating the factors each time. Instead, it now extracts the required period’s factor data from the already obtained full-period factor data. The full-period factor data has already been calculated in SimulationEventManager.run_simulation_alg(). Does this approach seem reasonable, and are there any potential side effects?
Here are my modifications:
1 In SimulationEventManager.run_simulation_alg(), I store the full-period factor data in the algorithm’s factorall attribute (which I added to the algorithm class) as follows: data, = run_engine(start, end, delay_factor) # Obtain the full-period factor data starting from 'start' alg.factor_all = data # I add this line
2 In CustomAlgorithm._data_updated(), instead of running run_engine each time to calculate the factors, I extract the required period’s factor data from factor_all. This improves performance. def _data_updated(self, event_source=None):
self._data, self._last_row = self.run_engine(None, None) # Original code