From 4c1d754a1754818b2644a47ab54012ab3b909d6a Mon Sep 17 00:00:00 2001 From: Dan Kelleher Date: Wed, 15 May 2024 13:46:19 -0400 Subject: [PATCH] check empty arg --- ib_async/contract.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/ib_async/contract.py b/ib_async/contract.py index 73ec7d2..fc70999 100644 --- a/ib_async/contract.py +++ b/ib_async/contract.py @@ -582,19 +582,15 @@ def liquidSessions(self) -> List[TradingSession]: return self._parseSessions(self.liquidHours) def _parseSessions(self, s: str) -> List[TradingSession]: - tz = util.ZoneInfo(self.timeZoneId) sessions = [] - for sess in s.split(";"): - if not sess or "CLOSED" in sess: - continue - sessions.append( - TradingSession( - *[ - dt.datetime.strptime(t, "%Y%m%d:%H%M").replace(tzinfo=tz) - for t in sess.split("-") - ] - ) - ) + if s: + tz = util.ZoneInfo(self.timeZoneId) + for sess in s.split(";"): + if not sess or 'CLOSED' in sess: + continue + sessions.append(TradingSession(*[ + dt.datetime.strptime(t, "%Y%m%d:%H%M").replace(tzinfo=tz) + for t in sess.split("-")])) return sessions