Bug: IB Paper Trading Order Expiry/Valid Time
-
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:
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.
-
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).