Custom live trading with multiple instances of Cerebro
LAbrk last edited by
I am working on a project to perform live trading with several strategies running at the same time. We already have a GUI that allows us to start and stop strategies. We are planning to use backtrader as the core of our application. For that we are going to develop our own Data, Store and Broker. The main idea is to override default lines with the following lines.
linesoverride = True lines = ('bid_price_0', 'bid_price_1', 'bid_price_2', 'bid_price_3', 'bid_price_4', 'bid_size_0', 'bid_size_1', 'bid_size_2', 'bid_size_3', 'bid_size_4', 'ask_price_0', 'ask_price_1', 'ask_price_2', 'ask_price_3', 'ask_price_4', 'ask_size_0', 'ask_size_1', 'ask_size_2', 'ask_size_3', 'ask_size_4', 'datetime')
'bid_price_0'is the current bid price, and
'bid_price_1', 'bid_price_2', 'bid_price_3', 'bid_price_4'make up the depth of the market (prices that are not the current best offer).
Since the user can start and stop strategies dynamically, we opt to have a Cerebro for each strategy. Another reason is that strategies can have different associated instruments.
One of my concerns is the CPU overhead that several instances of Cerebro may cause running at the same time (there would be no problem in terms of memory despite the multiple lines). Do you think it is possible to perform live trading using BT in this way?