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/

    Order modification feature request

    General Discussion
    3
    6
    806
    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.
    • exu
      exu last edited by

      Hi,
      I know it's been requested already, but I'm just asking how it could be better achieved when backtesting with daily data.
      Suppose you are a position/swing trader and you're long in the market so, to close the position, you may issue two orders: OCO orders, one stop loss and one take profit. Every day you'd go to your home broker and adjust the limit price on your stop loss order till you are either stopped or the price goes in your TP direction. You can do that here where I live.

      To simulate that in BT, one would have to cancel the OCO orders and issue new ones with the recent limit price levels, but you lose one next() just for that as they would have to be accepted/submitted by the broker first, consuming one bar. I thought of adding a data1 with a lower resolution (minutes) and two rows for each day, the first just to cancel the orders and the next to submit new ones, all happening in the "same" data0 bar.

      Is that more efficient than speeding the notifications?

      B 1 Reply Last reply Reply Quote 1
      • A
        ab_trader last edited by

        @exu said in Order modification feature request:

        but you lose one next() just for that as they would have to be accepted/submitted by the broker first, consuming one bar.

        If you issue orders on the current [0] bar, than they will be active at the next [+1] bar. No bars are missed. Broker processes order in between current and next bar.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        exu 1 Reply Last reply Reply Quote 1
        • exu
          exu @ab_trader last edited by

          @ab_trader
          Yes, sure, but what I meant is that, to simulate an order update, they would have to be cancelled and new ones issued between current [0] and next [+1], can you do that with only daily data0?

          A 1 Reply Last reply Reply Quote 0
          • A
            ab_trader @exu last edited by

            @exu I did it some time ago, worked as expected.

            • If my answer helped, hit reputation up arrow at lower right corner of the post.
            • Python Debugging With Pdb
            • New to python and bt - check this out
            1 Reply Last reply Reply Quote 1
            • B
              backtrader administrators @exu last edited by

              @exu said in Order modification feature request:

              To simulate that in BT, one would have to cancel the OCO orders and issue new ones with the recent limit price levels

              Which effectively is what happens in the market. You make a change and your order goes to the back of the queue (as if it had been cancelled and then re-issued. If brokers didn't do that, they would be giving you an unfair advantage)

              @exu said in Order modification feature request:

              can you do that with only daily data0?

              The timeframe is not relevant and is not looked into.

              1 Reply Last reply Reply Quote 0
              • exu
                exu last edited by

                thanks guys, I'll try and implement just that...

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