Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. xingweicmu
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    X
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Groups 0

    xingweicmu

    @xingweicmu

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    xingweicmu Unfollow Follow

    Latest posts made by xingweicmu

    • RE: Trade outside of Regular Trading Hour on IB

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

      posted in General Code/Help
      X
      xingweicmu
    • 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' % self.data.close[0])
                      self.order = self.buy(
                              size=self.p.size,
                              exectype=bt.Order.Limit,
                              price=round(self.data.close[0] * 1.01, 2),
                              valid=bt.Order.DAY,
                      )
      

      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.

      Thanks~

      posted in General Code/Help
      X
      xingweicmu