erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.75k stars 723 forks source link

TimeCondition Fails With Invalid Date #660

Closed eljefe6a closed 7 months ago

eljefe6a commented 7 months ago

I'm adding a time condition to my order. The time is formatted using ib_insync's time formatting method and still fails. I've tried various time formats by writing my own method, and they fail too. Here are the lines:

buy_time_condition = TimeCondition()
buy_time_condition.isMore = True
buy_time_condition.time = util.formatIBDatetime(trade_live_time)

Here is the log output:

2023-11-21 08:41:52,230 ib_insync.wrapper ERROR Error 391, reqId 107: End Time: The date, time, or time-zone entered is invalid. The correct format is yyyymmdd hh:mm:ss xx/xxxx where yyyymmdd and xx/xxxx are optional. E.g.: 20031126 15:59:00 US/Eastern  Note that there is a space between the date and time, and between the time and time-zone.  If no date is specified, current date is assumed. If no time-zone is specified, local time-zone is assumed(deprecated).  You can also provide yyyymmddd-hh:mm:ss time is in UTC. Note that there is a dash between the date and time in UTC notation.

I think there is a problem with the order of the fields being sent as part of the time condition where the time is in the wrong place.

eljefe6a commented 7 months ago

Figured this out. I was using "GTD" instead of "GTC", and IB was expecting an end date.