QuantConnect/Lean · error · RegressionTestException
There should be no open orders
Error message
There should be no open orders
What it means
Asserts that after the full lifecycle there are no open orders: Transactions.GetOpenOrders().Count == 0. The delisting/cancellation should have cleared all orders. A non-empty open-orders list means an order was left dangling.
Source
Thrown at Algorithm.CSharp/DuplicateOptionAssignmentRegressionAlgorithm.cs:188
if (!_optionDelistedWarningReceived)
{
throw new RegressionTestException("Option delisting warning was not received");
}
if (!_optionDelisted)
{
throw new RegressionTestException("Option was not delisted");
}
if (!_orderCanceled)
{
throw new RegressionTestException("Order was not canceled");
}
var openOrders = Transactions.GetOpenOrders();
if (openOrders.Count != 0)
{
throw new RegressionTestException("There should be no open orders");
}
if (!Portfolio.Invested)
{
throw new RegressionTestException("Portfolio should be invested");
}
// We should have the stock since the option was assigned
if (Portfolio.Positions.Groups.Single().Single().Symbol != _stock)
{
throw new RegressionTestException("Portfolio should have the stock");
}
}
/// <summary>
/// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
/// </summary>
public bool CanRunLocally { get; } = true;View on GitHub (pinned to d2c3659f87)
Solutions
- Log the contents of GetOpenOrders() to identify the dangling order(s) and their status.
- Confirm the delisting/cancel sweep in the TransactionHandler cancels orders for the delisted symbol.
- Ensure the test's own logic does not submit an order that is never resolved.
Example fix
// before
var openOrders = Transactions.GetOpenOrders();
if (openOrders.Count != 0)
{
throw new RegressionTestException("There should be no open orders");
}
// after
var openOrders = Transactions.GetOpenOrders();
if (openOrders.Count != 0)
{
throw new RegressionTestException(
$"There should be no open orders. Open: {string.Join(", ", openOrders)}");
} Defensive patterns
Strategy: validation
Validate before calling
var openOrders = Transactions.GetOpenOrders();
if (openOrders.Count > 0)
{
foreach (var o in openOrders) Log($"Open order remains: {o.Symbol} {o.Type} {o.Quantity} status={o.Status}");
} Prevention
- Always include the open-order details in the assertion message.
- Ensure the delisting-driven cancel sweep covers every open order symbol.
- Avoid leaving the algorithm with partially-filled orders.
When it happens
Trigger: An order remains open because it was not filled and not canceled, or the delisting-driven cancellation did not cover it.
Common situations: New order type not handled by the delisting cancel sweep; a partial fill left a residual open order; cancellation logic scoped to the wrong symbol.
Related errors
- Order was not canceled
- Option was not sold
- Option was not assigned
- Stock was not assigned
- Option delisting warning was not received
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/195420b1e802f788.
Report an issue: GitHub.