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/

    Multi Execution Problem

    General Code/Help
    2
    2
    643
    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.
    • Y
      Yu Malcolm last edited by

      Hi, I am new here, Sorry for the maybe stupid question.
      I have backtested multi asssets simultaneously, one buy order was executed for multi times, like this:

      2011-08-26, BUY EXECUTED, Size: 19500.00, Price: 5.00, Cost: 97480.50, Comm 1949.61
      2011-09-06, 300206 Order 12 Status Submitted
      2011-09-06, 300206 Order 12 Status Accepted
      2011-09-07, 300206 Order 13 Status Submitted
      2011-09-07, 300206 Order 13 Status Accepted
      2011-09-07, 300206 Order 12 Status Completed
      2011-09-07, SELL EXECUTED, Size: -19500.00, Price: 4.56, Cost: 97480.50, Comm 1779.18
      2011-09-07, 300206 Order 13 Status Completed
      2011-09-07, SELL EXECUTED, Size: -19500.00, Price: 4.56, Cost: -88959.00, Comm 1779.18
      2011-09-07, OPERATION PROFIT, GROSS -8521.50, NET -12250.29

      Through debug I found it is because asset 300206 has no data at the day 2011-09-06, when in 2011-09-05 the exit rule was met, it should sell at the next open price (which should be at 2011-09-06 ) .
      When I backtest with the single asset, it works fine, for 2011-09-06 was omitted.
      But when multi asset were used, the data were synchronized, day 2011-09-06 was added to asset 300206, but trade cant be executed. So strategy submitted a new sell the next day. And they all being executed.

      I am not familiar with the mechnism, how can I fix this?
      Thank you!

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

        When multiple data feeds are in play, if others have data for 2011-09-06, your next will be called to let you know that some data feeds have advanced.

        But the data feed with no data for 2011-09-06 remains paused at 2011-09-05, because no new data is available.

        You can control if a data feed has advanced by checking its len(data). If the value remains constante the data feed is not advancing.

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