nautechsystems/nautilus_trader · error · anyhow::Error

actual order side mismatch: expected

Error message

actual order side mismatch: expected {:?}, was {:?}

What it means

Algo order reconciliation also asserts that the order side on the algo record matches the side of the matched actual order. A mismatch means Long/Short (or Buy/Sell) sides disagree, so the exchange records cannot describe the same order.

Solutions

  1. Check hedge-mode vs one-way mode handling; ensure side mapping accounts for BinancePositionSide.
  2. Re-fetch the algo order via REST to get a consistent pair.
  3. Fix test fixtures so sides match.

Example fix

// before
// side: Long, actual side: Short
// after
// reconcile with correct side (both Long) via fresh REST snapshot
Defensive patterns

Strategy: try-catch

Try / catch

match result {
    Err(e) if e.to_string().contains("actual order side mismatch") => {
        tracing::error!("algo/actual side mismatch (check hedge mode): {e}");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Parsing an algo order update where self.side differs from actual.side, e.g. parent says Long but child order says Short.

Common situations: Hedge-mode payloads where position side and order side were conflated; incorrect fixture data; exchange data anomalies or wrong record pairing during reconciliation.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/aac996e9ae6eb511. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/binance/src/futures/http/models.rs:1635

            .context("algo order has no actual_order_id")?;

        if expected_actual_order_id != actual.order_id.to_string() {
            anyhow::bail!(
                "actual order ID mismatch: expected {expected_actual_order_id}, was {}",
                actual.order_id
            );
        }

        if self.symbol != actual.symbol {
            anyhow::bail!(
                "actual order symbol mismatch: expected {}, was {}",
                self.symbol,
                actual.symbol
            );
        }

        if self.side != actual.side {
            anyhow::bail!(
                "actual order side mismatch: expected {:?}, was {:?}",
                self.side,
                actual.side
            );
        }

        let mut report = self.to_order_status_report(
            account_id,
            instrument_id,
            price_precision,
            size_precision,
            ts_init,
        )?;
        let actual_report = actual.to_order_status_report(
            account_id,
            instrument_id,
            price_precision,
            size_precision,

View on GitHub (pinned to 18893faf8b)