def _create_generator(self, sim_params, source_filter=None): """ Create a basic generator setup using the sources and transforms attached to this algorithm. ::source_filter:: is a method that receives events in date sorted order, and returns True for those events that should be processed by the zipline, and False for those that should be skipped. """ sim_params.data_frequency = self.data_frequency self.data_gen = self._create_data_generator(source_filter, sim_params) # if live execution is active instantiate perf_tracker with # the portfolio downloaded from IB if self.asset_type == self.asset_types.EQUITY: self.perf_tracker = PerformanceTracker(sim_params) elif self.asset_type == self.asset_types.FUTURES: self.perf_tracker = FuturesPerformanceTracker(sim_params) else: self.perf_tracker = PerformanceTracker(sim_params) if self.live_execution: self._init_positions() self.trading_client = AlgorithmSimulator(self, sim_params) transact_method = transact_partial(self.slippage, self.commission) self.set_transact(transact_method) return self.trading_client.transform(self.data_gen)