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/

    Bug: IB Paper Trading Order Expiry/Valid Time

    General Code/Help
    1
    2
    61
    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.
    • L
      LisaWalters last edited by

      Tried out samples/ibtest/ibtest.py. Setting expiry time ("valid" time in Backtrader lingo) leads to orders being rejected by IB system. On the other hand, orders with no expiry time work fine.

      IB records the expiry time correctly though:
      Screenshot 2020-10-31 at 1.03.51 AM.png

      I ran:

      $ python ibtest.py
      --timeframe Days
      --port 7497
      --trade --valid 60
      --usestore --broker
      

      -- valid 60 means 60 seconds to expiry.

      I'm currently running this outside of the US. Tried running with --timezone US/Eastern and this bug still persists.

      Any ideas would be great.

      L 1 Reply Last reply Reply Quote 0
      • L
        LisaWalters @LisaWalters last edited by

        I suspected that this could be a timezone mis-match issue so I tried changing IB's timezone to UTC (GMT+0) and setting the expiry time works fine now.

        I think what happens is this:

        Backtrader's does this (pseudocode):

        dt = current date & time in UTC
        expiry_date_time = dt + valid
        place order with expiry_date_time
        

        Order reaches IB. On IB's end, expiry_date_time is interpreted in the user's IB client's timezone (e.g. for someone running IB in australia, expiry_date_time is assumed to be in australia's timezone).

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