Skip to content

Wait out a brokerage disconnection when the algorithm has only custom data - #10261

Closed
quantconnect-kronos[bot] wants to merge 1 commit into
masterfrom
kronos/bug-67-outage-disconnect-grace-period
Closed

quantconnect-kronos[bot] wants to merge 1 commit into
masterfrom
kronos/bug-67-outage-disconnect-grace-period

Conversation

@quantconnect-kronos

Copy link
Copy Markdown
Contributor

DefaultBrokerageMessageHandler now waits out a disconnection, then stops the algorithm if it's still disconnected, when the algorithm has only custom data securities.

Part of QuantConnect/Lean.Brokerages.Tradier#68, which reports a Tradier outage as a disconnection that Lean waits out instead of stopping the algorithm at once.

What changed

  • With the markets closed, the handler looks for the next market open among the securities that aren't custom data (SecurityType.Base). When every security was custom data, it took Min() of an empty sequence, so HandleMessage threw InvalidOperationException: Sequence contains no elements and never started the wait. A brokerage that reports a disconnection only once, until it reconnects, never stopped that algorithm while still disconnected.
  • It now uses the fallback it already had for an algorithm without securities: the next check is an hour from now, minus the open threshold. Nothing changes for algorithms with other securities.

Tests

  • New DefaultBrokerageMessageHandlerTests.SetsAlgorithmRunTimeErrorOnPersistentDisconnectWithOnlyCustomData: an algorithm with only custom data stays disconnected, and the handler sets the runtime error once the wait is over. It fails without the fix (Sequence contains no elements) and passes with it. It takes about a minute because the handler checks once a minute.
  • Full suite as CI runs it (TestCategory!=TravisExclude&TestCategory!=ResearchRegressionTests): 40049 passed, 0 failed, 112 skipped.
  • Tested end to end with the Tradier plugin's change: during a simulated Tradier outage that doesn't end, an algorithm with only custom data was stopped with the outage's message after the wait.

DefaultBrokerageMessageHandler looked for the next market open among the
securities that aren't custom data and took the minimum of an empty
sequence when there were none, so it threw and never started the wait
that stops an algorithm still disconnected. It now falls back to an hour
from now, as it already did for an algorithm without securities.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@quantconnect-kronos

Copy link
Copy Markdown
Contributor Author

Closing: as decided in QuantConnect/Lean.Brokerages.Tradier#68, the Tradier change doesn't take a Lean change. The bug is tracked in #10262 for Lean's maintainers to decide.

@quantconnect-kronos
quantconnect-kronos Bot deleted the kronos/bug-67-outage-disconnect-grace-period branch November 27, 2026 19:46
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot removed the kronos:review:working review: in progress label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kronos:develop:working develop: in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants