Backtrader Community

    • 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/

    Executing the placed orders on the same bar close price, cheat on close executes order on next bar

    General Discussion
    4
    6
    432
    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.
    • Suraj Thorat 0
      Suraj Thorat 0 last edited by

      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. The buy gets created on the current bar but still it gets executed on next bar. I used cheat on close.
      Please tell me a way to do so or change the code in the backtrader library to help me do it.

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

        Please prove with the logs of the execution date and price.

        • 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
        Suraj Thorat 0 2 Replies Last reply Reply Quote 1
        • Suraj Thorat 0
          Suraj Thorat 0 @ab_trader last edited by

          @ab_trader thank you for the quick reply. I have the logs in office actually and I am on a timeline where in I have to solve the problem quickly, I will post them once I reach office tomorrow, about 9 hours from now.

          I added coc True in cerebro.broker, I also did the same in adding coc True to order to itself.
          I failed at it, don't know what mistake I am doing.

          If the signal comes on 7th september for example, the execution is shown on 8th September (from notify trade)

          At last I thought maybe I can just get two types of data adjusting ones date (shift function of pandas and deleting the top most row) above the others using dataframe so that I can get signals from one data and place an order on another and avoid cheat on close altogether, but for some reason/mistake backtrader is adjusting the data to the same date while importing the CSV using backtradercustomcsv function (interestingly the last date is repeated twice when this is done).

          I understand it is really hard to give me a solution without the logs and codes and maybe I am making some mistake I gotta figure this out somehow.
          Thank you.

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

            @ab_trader said in Executing the placed orders on the same bar close price, cheat on close executes order on next bar:

            price

            Also one more thing I would like to add is
            7th September the order is created in next()
            8th September the order is shown as executed from notify_trade.

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

              @suraj-thorat-0 have you found the solution? I'm facing the same problem.

              S 1 Reply Last reply Reply Quote 0
              • S
                sarnab11496 @mcb last edited by

                @mcb I am also facing the same issue

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