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/

    Force the order executed at specific price with certain size

    General Code/Help
    2
    3
    116
    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.
    • V
      VincentLee last edited by

      I am using other program to simulate trade on stock market(using tick data). And I would like to force the backtrader to execute every order by the trade records(see graph).
      475a1276-1cf4-46f0-b64a-f01fbfad81b0-image.png
      For example, when the signal above 1, all-in with open price then sell certain size with open price * (1+rate).
      I tried to use backtrader.order.limit to create order, but sometimes it will not execute with right price because of the intern logic of limit order.

      I wonder if there is any way to force the order executed at specific price with certain size, something like:

      self.buy(price=self.datas[0].open[0], size=1000, exectype=backtrader.Order.Force)
      

      will execute this order next bar without checking open price or any other price.

      run-out 1 Reply Last reply Reply Quote 0
      • run-out
        run-out @VincentLee last edited by

        @vincentlee Backtrader is meant to simulate real life as much as possible. It's decisions will seek the best fill order based up on the available data.

        RunBacktest.com

        1 Reply Last reply Reply Quote 0
        • V
          VincentLee last edited by

          @run-out see https://www.backtrader.com/blog/posts/2017-07-05-order-history/order-history/, Backtrader provide order-history function to evaluate external historical performance.

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