QuantConnect/Lean · error · RegressionTestException

Expected open order for emitted insight

Error message

Expected open order for emitted insight

What it means

After EmitInsights(Insight.Price(... Down)), the test asserts an open order now exists for _symbol. The Portfolio Construction Model must have converted the emitted insight into an order. If GetOpenOrders returns null/empty, the insight-to-order pipeline did not produce an order, indicating the PCM did not react to the insight.

Source

Thrown at Algorithm.CSharp/EmitInsightNoAlphaModelAlgorithm.cs:82

        public override void OnData(Slice slice)
        {
            if (!Portfolio.Invested)
            {
                var order = Transactions.GetOpenOrders(_symbol).FirstOrDefault();

                if (order != null)
                {
                    throw new RegressionTestException($"Unexpected open order {order}");
                }

                EmitInsights(Insight.Price(_symbol, Resolution.Daily, 10, InsightDirection.Down));

                // emitted insight should have triggered a new order
                order = Transactions.GetOpenOrders(_symbol).FirstOrDefault();

                if (order == null)
                {
                    throw new RegressionTestException("Expected open order for emitted insight");
                }
                if (order.Direction != OrderDirection.Sell
                    || order.Symbol != _symbol)
                {
                    throw new RegressionTestException($"Unexpected open order for emitted insight: {order}");
                }

                SetHoldings(_symbol, 1);
            }
        }

        public override void OnEndOfAlgorithm()
        {
            var holdings = Securities[_symbol].Holdings;
            if (Math.Sign(holdings.Quantity) != -1)
            {
                throw new RegressionTestException("Unexpected holdings");
            }

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Check which Portfolio Construction Model is set and confirm it emits targets for the insight direction.
  2. Inspect the insight (symbol, direction, period, magnitude) for validity that the PCM requires.
  3. Trace the insight through InsightManager -> PCM -> Execution to find where it was dropped.
Defensive patterns

Strategy: validation

Validate before calling

// Before asserting an order exists, validate the insight would drive one
var pcm = PortfolioConstruction as IPortfolioConstructionModel;
if (pcm == null) Log("No Portfolio Construction Model set; insight will not produce an order");

Prevention

When it happens

Trigger: The Portfolio Construction Model ignored the insight (wrong direction handling, zero target weight), or the insight was filtered/dropped before reaching the PCM. Insight magnitude/closedTime invalid.

Common situations: A custom or default PCM that does not act on InsightDirection.Down; the Execution model not immediately creating a market order; insight validation rejecting the insight.

Related errors


AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13). Data as JSON: /api/errors/db9c0a446b878d90. Report an issue: GitHub.