For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Let strategies communicate with each other

  • Hi,
    I would like to know if there is a way for a strategy to retrieve the unrealized pnl of an order placed by another strategy:

    • Strategy A : enters a long position on data0
    • Strategy B: checks on each next() iteration the pnl of the long position ordered by Strategy A (and possibly place an order)

    Where Strategy A and B run over the same period of time.


  • Strategy A can write info in the file and strategy B can read the file and process the info as required.

  • Without having tested it, perhaps you can use in next of strategy B self.cerebro.runningstrats[self._id ^ 1] to get access to strategy A

  • administrators

    The broker is a single account broker. All Strategies see the same value for a given asset.

    If that's not of your liking, your best bet will be to use a common parameter which can be used as a communication channel, like a dict or a list which will be written to by strategy A and read by B.