Does 'preload' have to be set as 'False' while bt running in live-trading mode?
-
What are the merits for one another: 'preload' and not 'preload'?
And does 'preload' have to be set as 'False' if we want bt to run in live-trading mode?
-
You cannot have both live trading and data preloading, because the data isn't there yet to be preloaded.
A quick google query took to the
Cerebro
documentation: https://www.backtrader.com/docu/cerebro.htmlFrom the top of the reference of the class:
preload (default: True) Whether to preload the different data feeds passed to cerebro for the Strategies runonce (default: True) Run Indicators in vectorized mode to speed up the entire system. Strategies and Observers will always be run on an event based basis live (default: False) If no data has reported itself as live (via the data’s islive method but the end user still want to run in live mode, this parameter can be set to true This will simultaneously deactivate preload and runonce. It will have no effect on memory saving schemes. Run Indicators in vectorized mode to speed up the entire system. Strategies and Observers will always be run on an event based basis
-
@Paska-Houso Many thanks! I'm still at sea with the internals of backtrader, does it provide a method to get our current holdings (i.e. a list containing all the stocks we are now holding) ?
-
Not to by knowledge. But you have
self.datas
andself.getposition(data=None)
A simple comprehension should do it:
d_with_pos = [d for d in self.datas if self.getposition(d)]
-
@Paska-Houso said in Does 'preload' have to be set as 'False' while bt running in live-trading mode?:
Not to by knowledge. But you have
self.datas
andself.getposition
A simple comprehension should do it:
d_with_pos = [d for d in self.datas if self.getposition(d)]
From the docs: https://www.backtrader.com/docu/strategy.html