From 88db6921ebfcb297e517f075ec70366a4787a6bf Mon Sep 17 00:00:00 2001 From: Romazes Date: Sat, 17 Aug 2024 02:01:43 +0300 Subject: [PATCH] fix: skip subscribe on Expired Option Symbol --- .../InteractiveBrokersBrokerage.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/QuantConnect.InteractiveBrokersBrokerage/InteractiveBrokersBrokerage.cs b/QuantConnect.InteractiveBrokersBrokerage/InteractiveBrokersBrokerage.cs index e281acd..b9ae72c 100644 --- a/QuantConnect.InteractiveBrokersBrokerage/InteractiveBrokersBrokerage.cs +++ b/QuantConnect.InteractiveBrokersBrokerage/InteractiveBrokersBrokerage.cs @@ -3634,6 +3634,13 @@ private bool Subscribe(IEnumerable symbols) continue; } + // Skip subscribing to expired option contracts + if (OptionSymbol.IsOptionContractExpired(symbol, DateTime.UtcNow)) + { + Log.Trace($"InteractiveBrokersBrokerage.Subscribe(): Skipping subscription for {symbol} because the contract has expired."); + continue; + } + var id = GetNextId(); var contract = CreateContract(subscribeSymbol, includeExpired: false); var symbolProperties = _symbolPropertiesDatabase.GetSymbolProperties(subscribeSymbol.ID.Market, subscribeSymbol, subscribeSymbol.SecurityType, Currencies.USD);