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



  • 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?



  • @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.



  • @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?



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


  • administrators

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



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


Log in to reply
 

});