You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PortfolioTargetCollection.Contains(KeyValuePair) recurses instead of returning #10130
PortfolioTargetCollection.Contains(KeyValuePair<Symbol, IPortfolioTarget>) calls itself with the same argument, so it recurses until the stack overflows instead of returning.
The argument is still a KeyValuePair<Symbol, IPortfolioTarget>, so overload resolution picks the same method. It's the same pattern as the Add(KeyValuePair<...>) overload in #10125; the sibling Remove(KeyValuePair<...>) forwards target.Value and works.
It returns whether the pair is in the collection, and a regression test covers it through the generic collection interface. Suggestion: forward the pair's value to Contains(IPortfolioTarget), as Remove(KeyValuePair<...>) does; whoever fixes it picks the approach.
ContainsKey and Contains(IPortfolioTarget) work and are the workaround.
Fix in #10132. I checked the other Contains(KeyValuePair<...>) implementations in Common: CashBook and SecurityManager pass the pair to their inner collection and don't recurse, and the fix follows SecurityManager. SecurityPortfolioManager.Contains(KeyValuePair<Symbol, SecurityHolding>) doesn't recurse either, but it only checks the key.
Activity
quantconnect-kronos commentedon Nov 13, 2026
Fix in #10132. I checked the other
Contains(KeyValuePair<...>)implementations in Common:CashBookandSecurityManagerpass the pair to their inner collection and don't recurse, and the fix followsSecurityManager.SecurityPortfolioManager.Contains(KeyValuePair<Symbol, SecurityHolding>)doesn't recurse either, but it only checks the key.