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/

    Execution of Limit Orders

    General Code/Help
    2
    2
    841
    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.
    • T
      toolkmit last edited by toolkmit

      Is there a way in backtrader such that limit orders only execute if price trades through the limit order price?

      I'm running a backtest with tick data for ES futures, so I would only want a sell limit at 2700 to execute if the price goes a tick higher to 2700.25.

      I believe the default behavior is to execute the limit order when price reaches 2700, which rarely happens in live trading.

      Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        @toolkmit said in Execution of Limit Orders:

        I believe the default behavior is to execute the limit order when price reaches 2700, which rarely happens in live trading.

        backtrader is not about what rarely happens. It tries to model reality. Actually if you have a Limit order to sell at 2700, you are NOT going to be matched at 2700.25 because that would actually go AGAINST what you have specified as limit. Your broker would be breaching the contract it has with you not to executed your order at any price higher than 2700.

        You ar probably looking at these options:

        • Adding slippage: Docs - Slippage
        • Using StopLimit (i.e.: only having a Limit order active if a trigger price has been reached).

        You may also be looking for an order type which is not implemented in backtrader: Limit If Touched. When the price touches 2700 you will be looking to have a Limit order placed at 2700.25

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }