A multi-stock strategy in Backtrader loads several stock data feeds into a single Cerebro engine so you can trade them all at once. Juggling multiple stocks in a backtest doesn't have to be a headache — Backtrader handles it by letting you load several data feeds into its main engine, Cerebro. Inside your strategy, you access each stock's data using simple references like self.data0 for the first stock, self.data1 for the second, and so on.
This setup opens the door to testing more advanced ideas. You can build strategies for an entire portfolio, experiment with pairs trading (where you trade one stock against another), or manage separate positions across different securities, all in a single run. The examples below illustrate feed references and order bookkeeping; they are not a completed portfolio backtest or reported trading experiment.