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/

    Interactive Broker order OutsideRth attribute

    General Code/Help
    4
    7
    1086
    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.
    • Z
      z_kvn last edited by z_kvn

      In both IB API and ibPy API there is reference to the OutsideRth attribute of an order.

      https://interactivebrokers.github.io/tws-api/classIBApi_1_1Order.html#a60dcca6e3c3ae6ae6e0c5f3fdffc5a4a
      https://github.com/blampe/IbPy/blob/master/ib/ext/EClientSocket.py

      Looks like in Backtrader the attribute is not exposed. Is there any way I can tweak the attribute inside Backtrader for live trading? And is the default attribute of this setting False?

      Thanks,

      Kevin

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

        Actucally, you can set the OutsideRth attribute like this:

        self.order = self.buy(
                            size=1,
                            exectype=bt.Order.Limit,
                            price=someprice,
                            outsideRth=True
                        )
        
        Z 1 Reply Last reply Reply Quote 2
        • Z
          z_kvn @jmoons last edited by

          @jmoons thanks I will try it.

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

            Documented here: Docs - Live Data Feeds and Live Trading - Interactive Brokers

            Because ibpy was using the Java API source as the building cornerstone, the actual argument name is: m_outsideRth.

            But you can pass it without the leading m_ and the code will dynamically add it for you in the background.

            Z 1 Reply Last reply Reply Quote 2
            • Z
              z_kvn @backtrader last edited by

              @backtrader cool thanks a lot!

              1 Reply Last reply Reply Quote 0
              • B
                bigdavediode last edited by bigdavediode

                Hi Kevin --

                Another option for you is to use the IB data cache code that brettelliot wrote at https://community.backtrader.com/topic/1007/how-to-cached-data-from-ib-and-use-it-later/2

                It exposes the IB connection so that the ib api parameter for RTH is available (use_rth).

                Also gets you a nice cache and a bit of a speedup as well.

                B.

                Z 1 Reply Last reply Reply Quote 1
                • Z
                  z_kvn @bigdavediode last edited by

                  @bigdavediode thanks I will look into this.

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