Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Let strategies communicate with each other

    Indicators/Strategies/Analyzers
    multiple data strategy
    4
    4
    430
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Vincere
      Vincere last edited by

      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.

      Thanks

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

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

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        1 Reply Last reply Reply Quote 1
        • M
          momentum last edited by

          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

          1 Reply Last reply Reply Quote 1
          • B
            backtrader administrators last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors