B
My example was with daily bars, as I think is more close to the reality. At the end, forgetting about the -coc option for a moment, if you have a live order feed sending only daily bars, you could have that planned task at, for example, midday, that send the MOC order and gets executed with the close price of the daily bar.
There is difference between backtesting with daily bars and having a live feed which delivers daily bars. The latter probably constantly updates the current daily bar and that's why you think that already at noon time it may be possible to send a MOC order.
To achieve the same effect during backtesting you need one of this:
intraday data and replay daily bars
Set cheat-on-close and allow using the close price
Use filters and break the feed into OHL + C steps (see the Pinkfish Challenge - and the sample in the sources)
For the MOO I can send it to IB with kwargs as you´re proposing, but I cannot get the same effect with backtesting, basically because 1) Backtrader doesn´t support natively MOO orders (what about more order types support for the future? :slight_smile: ) or 2) as I don´t have "planning tasks capability" I should know which one is the last bar - 1 on the day, to send a Market Order, before it close, and simulate MOO behaviour...
Yes you can. If you use daily bars, whenever you get a bar during backtesting, you are at the end of the session. Send for both cases (backtesting and live) a Market order and the extra kwargs. The standard backtesting broker will ignore it and the IB broker will overwrite the order type.
if I do it with a background thread as proposed, I understand this is a real time capability, but no way to reproduce it on backtesting mode, isn´t?
Not at the moment
if implemented as points in lines (kind of time feed), wouldn´t be this more accurate to have same behaviour like in realtime with just 1 code?
At least it would have the same behavior right now for both scenarios.