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/

    Why is my backtest order not being executed on the next candle?

    General Code/Help
    2
    3
    21
    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.
    • A
      alex0110 last edited by

      When I use a CSV file with daily data like this:

      Date,Open,High,Low,Close,Adj Close,Volume 1995-01-03,45.703125,45.84375,45.6875,45.78125,28.202983856201200,324300 1995-01-04,45.984375,46.0,45.75,46.0,28.337736129760700,351800

      When I use self.order = self.buy() the order is executed on the open the next day.

      What is I'm using 1 min data like this:

      Date,Open,High,Low,Adj Close,volume,trade_count,vwap 2022-05-25 08:00:00+00:00,141.19,141.19,140.7,140.7,2236,66,140.883658 2022-05-25 08:01:00+00:00,140.78,140.78,140.66,140.66,1938,49,140.705335

      ... The order is never executed.
      I would like to have the order executed on the next candle.

      How can I have the backtest order executed on a 1 min chart?

      Do I have to use a certain parameter for that?

      A 1 Reply Last reply Reply Quote 0
      • A
        alex0110 @alex0110 last edited by

        I'm using this for the daily thing:

        data = btfeeds.GenericCSVData(dataname='intraday-data.csv',dtformat='%Y-%m-%d')

        And I'm using this for the 1 min candle, which seems to be problematic:

        data = btfeeds.GenericCSVData(dataname='intraday-data.csv',dtformat='%Y-%m-%d %H:%M:%S+00:00')

        1 Reply Last reply Reply Quote 0
        • AnsonCHOWcm
          AnsonCHOWcm last edited by

          Hey Alex,

          I encounter the similar problem before (just different in timeframe which I am using 1 hour)

          Please check out my post here:

          https://community.backtrader.com/topic/5770/problem-delayed-market-order-execution-with-hour-data-feed

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