Navigation

    Backtrader Community

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

    Conflicting documentation for Order.Close execution

    General Code/Help
    2
    2
    51
    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.
    • B
      brunof last edited by

      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 describes Order.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.

      vladisld 1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld @brunof last edited by

        @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 the MOC 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.

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