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/

    Same bar order execution

    General Discussion
    3
    4
    915
    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
      valentin last edited by

      I have trading signals for each day, telling me whether to buy hold or sell. According to my current understanding by default the platform executes on the next bar - which in my case is the next day.
      A hacky way to solve this would be – I assume to shift all signals "up" one day in my CSV. This would be not suitable for a live strategy.
      How can I tell backtrader to execute either on opening or on the close price of the same bar/day I am currently looking at?
      I looked at the cheat-on-options, but not sure if this is the solution.
      Thanks

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

        Could you please elaborate a bit?

        @valentin said in Same bar order execution:

        I have trading signals for each day

        Do you have them? Are they generated with the data?

        @valentin said in Same bar order execution:

        According to my current understanding by default the platform executes on the next bar

        I don't know where your understanding has come from. Order execution is described in the docs. It has nothing to do with default, it has to do with order execution type. Docs - Order Management and Execution

        Things work as described for a good reason, to be as accurate as possible with backtesting, given the usual inherent limitations the data has, when compared to live action.

        @valentin said in Same bar order execution:

        I looked at the cheat-on-options, but not sure if this is the solution

        Neither can I know, given the lack of actual information. But the name cheat-on-xxxx was chosen for good reasons.

        @valentin said in Same bar order execution:

        How can I tell backtrader to execute either on opening or on the close price of the same bar/day I am currently looking at?

        Apparently you already read the pertinent docs, what else would you be expecting?

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

          Thank you. Your hints were enough to find a solution for now.
          For testing I simply shift the signal simply up a row. For live purposes I will find another way

          Suraj Thorat 0 1 Reply Last reply Reply Quote 0
          • Suraj Thorat 0
            Suraj Thorat 0 @valentin last edited by

            @valentin can you tell me how you did it? My orders get executed on next bar if I use cheat on close. The logic is clear why I want to execute on same bar. I just need a way to do execute the placed orders on the same bars close price.

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