From 6fa805b0a4f948744ee5894d11b4e7552c84d731 Mon Sep 17 00:00:00 2001 From: goodboy Date: Tue, 3 Mar 2026 15:50:27 -0500 Subject: [PATCH] Fall back to `Contract.exchange` in `has_holiday()` Use `con.exchange` as fallback when `con.primaryExchange` is empty in `has_holiday()` to handle contracts like futures that don't always set a `primaryExchange`. Deats, - extract `con: Contract` from `con_deats.contract` for reuse. - use `con.primaryExchange or con.exchange` to ensure a valid exchange code is always passed to the calendar lookup. - add `Contract` to `TYPE_CHECKING` imports. (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- piker/brokers/ib/venues.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/piker/brokers/ib/venues.py b/piker/brokers/ib/venues.py index cd2dc7b1..a24635bd 100644 --- a/piker/brokers/ib/venues.py +++ b/piker/brokers/ib/venues.py @@ -43,6 +43,7 @@ from pendulum import ( if TYPE_CHECKING: from ib_async import ( TradingSession, + Contract, ContractDetails, ) from exchange_calendars.exchange_calendars import ( @@ -82,7 +83,12 @@ def has_holiday( ''' tz: str = con_deats.timeZoneId - exch: str = con_deats.contract.primaryExchange + con: Contract = con_deats.contract + exch: str = ( + con.primaryExchange + or + con.exchange + ) # XXX, ad-hoc handle any IB exchange which are non-std # via lookup table..