For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Bracket order persistence in live trading (IB) across sessions



  • I have built trading and analysis platform using backtrader framework. So thank you for all the time and effort on the project.

    I use bracket orders when placing (live) in IB to have profit taking and stop-loss orders all in one.

    The issue I currently have once a bracket order is placed in the current application session (or one single trading day) and stop the app overnight for maintenance and then restart it following morning for the 2nd session the bracket order information doesn't get loaded into the strategy, as a result the application doesn't have a sense of bracket order that could be in the live platform.

    The adverse effect of this issue is that my strategy does have other logic which initiates a SELL based on indicator signals, the 2nd app session doesn't have a sense of currently open bracket orders at the broker, app initiates a "SHORT" position.

    So far I see two solutions

    1. Some way to resync broker (IB) bracket orders back in strategy.
    2. Save strategy / application state

    I don't know if IB bracket order sync capability is there, if someone could explain how to use this that would solve my issue. I tried application save using pickle, dill and other serialisation methods but always break due to socket connections and other serialisation issues (which seems like a bad way to solve this issue anyway so I have given up on this approach).

    Keen to know other approaches or a potential solution for this.


  • administrators

    The IB store implementation isn't designed for persistence across session.

    @purinda-gunasekara said in Bracket order persistence in live trading (IB) across sessions:

    Keen to know other approaches or a potential solution for this.

    You need to implement a custom IB Store/Broker.