I have read the docs on consolidators, saw github examples and tried to find examples on communnity but I still dont' understand consolidators. I have build the strategy for the backtest with minute resolution, I want to move noe from minute to 30 minute resolution.
I don't understand what's really happening, but I copy paste following code to my initialize part (don't understand what dataConsolidated property contains, what are other methods/properties, why we need to add handler, and what updates it needs to receive from engine....):
# consolidators
# define our 30 minute trade bar consolidator. we can access the 30 minute bar from the DataConsolidated events
thirtyMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=30))
# attach our event handler. the event handler is a function that will be called each time we produce a new consolidated piece of data.
thirtyMinuteConsolidator.DataConsolidated += self.ThirtyMinuteBarHandler
# this call adds our 30 minute consolidator to the manager to receive updates from the engine
self.SubscriptionManager.AddConsolidator(self.symbol, thirtyMinuteConsolidator)
If I just run the script with this change nothing happens. It seems I have to remove OnData part (just pass) and put everything I develope so far into the handler? But I don't have `data` arguments in handler as in OnData part anymore.
In nutshell, I am really confused about consolidators. What is the simplest way to consolidate data to 30 minutes? Do OnData part to handlers? Whay we have to do that?
I didn't attached the backtest since I don't want to make it visible, but it can be any backtest with simple trading rules (SMA crossover for example).
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!