Same bar order execution
-
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 -
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 ExecutionThings 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?
-
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 -
@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.