Executing the placed orders on the same bar close price, cheat on close executes order on next bar
-
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. -
Please prove with the logs of the execution date and price.
-
@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. -
@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. -
@suraj-thorat-0 have you found the solution? I'm facing the same problem.
-
@mcb I am also facing the same issue