Conflicting documentation for Order.Close execution
-
Hello,
The Order.Close docs say "Execution: Using the close price of the next bar when the next bar actually CLOSES"
In contrast, the docstring of the
Strategy.buy()
method describesOrder.Close
as "An order which can only be executed with the closing price of the session (usually during a closing auction)".When using daily data, executing an order in the next bar vs. in the last bar of the session are the same thing. When using intraday data, they are obviously not the same.
I've tested it with intraday data and all orders with
exectype=bt.Order.Close
are only executed in the first bar of the following day. If that is not the intended behavior, I can provide an MWE to help with the debugging. If that's the intended behavior, maybe the docs could be updated to make it clearer.Thank you.
-
@brunof I believe the docstring of the
Strategy.buy()
is the correct one.Looking for example at the mapping of the order execution types to the IB broker order type we may see that
Order.Close
execution type is mapped to theMOC
order type.Quoting the IB docs for the
MOC
order type we may see:"""
A Market-on-Close (MOC) order is a market order that is submitted to execute as close to the closing price as possible.
"""So you are right - the docs should be updated.