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

Trade outside of Regular Trading Hour on IB

  • Hi everyone,

    I am using paper account to trade on IB. My problem is I cannot put DAY order with limit order in after-hours on IB.

    So I was trying to put a limit order in after-hours on IB using the following piece of code:

                    self.log('BUY CREATE, %.2f' %[0])
                    self.order =
                            price=round([0] * 1.01, 2),

    The order wasn't executed even when the limit price is reached. But if I put the limit order with the same value on TWS directly, the order was executed instantly. So by comparing those two orders, I find the order that I manually put on TWS has a DAY time in force while the one created by backtrader don't have a time in force(even though I put valid param as DAY in above code), see the following screenshot.

    Order generated by backtrader:
    Screen Shot 2020-06-22 at 11.35.28 PM.png

    So I wonder if I was doing it in the wrong way or how I could put a limit order with DAY time in force in after-hours.


  • I'm using the following code to buy/sell outside of regular hours:,
           exectype=Order.Limit ,

  • @vladisld Thank you man! outsideRth=True is what I am looking for!

Log in to reply