Let strategies communicate with each other
Vincere last edited by
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
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
listwhich will be written to by strategy A and read by B.