You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 factor_all 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
# The following is my code
start = self._current_dt - self._history_window
end = self._current_dt
# Extract records from self.factor_all for the period from 'start' to 'end'
self._data = self.factor_all.loc[start:end]
self._last_row = self._data.loc[end]
The text was updated successfully, but these errors were encountered:
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 factor_all 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
The text was updated successfully, but these errors were encountered: