ib-api-reloaded / ib_async

Python sync/async framework for Interactive Brokers API (replaces ib_insync)
BSD 2-Clause "Simplified" License
223 stars 37 forks source link

Check contract details has time zone ID #20

Open djkelleher opened 1 month ago

djkelleher commented 1 month ago

Contracts about to expire may not have tradingHours, liquidHours, and timeZoneId set. This was causing an error when _parseSessions is called:

Exception has occurred: ValueError
ZoneInfo keys must be normalized relative paths, got: 

A simple way to avoid the error would be to check if the argument string is empty.

mattsta commented 1 month ago

Is this related to the input s or only the self.timeZoneId value?

Perhaps when s is empty then self.timeZoneId is also empty or invalid?

It looks like the fix works either way, but technically the s.split() already skips an empty s, so we are actually just checking if self.timeZoneId is a problem.

djkelleher commented 1 month ago

It's currently written for the expected behavior: if s is non-empty then timeZoneId should be valid. If s is empty then timeZoneId may not be valid.