nautechsystems/nautilus_trader · error
Account ID not found for trader {}
Error message
Account ID not found for trader {} What it means
When the matching engine processes (or child-dispatches) an order it needs an AccountId. It first reads the order's own account_id; failing that it falls back to a trader_id -> account_id map maintained on the engine. If neither yields an account, processing cannot proceed and this error is raised.
Source
Thrown at crates/execution/src/matching_engine/mod.rs:5269
&child_order.strategy_id(),
)
.unwrap();
log::debug!(
"Added position id {position_id} to cache for order {client_order_id}"
);
}
if (!child_order.is_open())
|| (matches!(child_order.status(), OrderStatus::PendingUpdate)
&& child_order
.previous_status()
.is_some_and(|s| matches!(s, OrderStatus::Submitted)))
{
let account_id = order
.account_id()
.or_else(|| self.account_ids.get(&order.trader_id()).copied())
.ok_or_else(|| {
anyhow::anyhow!(
"Account ID not found for trader {}",
order.trader_id()
)
})?;
self.process_order(&mut child_order, account_id);
}
}
} else {
log::error!(
"OTO order {} does not have linked orders",
order.client_order_id()
);
}
}
ContingencyType::Oco => {
if let Some(linked_orders_ids) = order.linked_order_ids() {
for client_order_id in linked_orders_ids {
let child_order = match self.order_snapshot(*client_order_id) {View on GitHub (pinned to 18893faf8b)
Solutions
- Register the trader's account on the matching engine (account_ids map) before submitting orders for that trader_id.
- Ensure orders are built with account_id set at creation by the execution client.
- Verify trader_id spelling/configuration matches exactly between the client and matching engine setup.
- If the order is synthesized internally, propagate the parent order's account_id to child orders.
Example fix
// before: engine without the trader's account registered let engine = MatchingEngine::new(venue, omc, clock, ...); // no register_account engine.iteration(...)?; // 'Account ID not found for trader T' // after: register account for the trader up front engine.register_account(trader_id, account_id); engine.iteration(...)?;
Defensive patterns
Strategy: validation
Validate before calling
// before submitting, confirm the order carries an account or the trader is registered
let resolvable = order.account_id().is_some()
|| engine_account_ids.contains_key(&order.trader_id());
assert!(resolvable, "no account for trader {}", order.trader_id()); Try / catch
match engine.iteration(&mut command_queue) {
Err(e) if e.to_string().starts_with("Account ID not found for trader") => {
log::error!("{e}; registering account and retrying");
engine.register_account(trader_id, account_id);
// retry once
}
other => other,
} Prevention
- Call register_account for every trader before submitting orders to the matching engine.
- Set account_id on every order at creation time in the execution client.
- Keep trader_id configuration identical between client and matching engine.
When it happens
Trigger: Submitting an order whose account_id was never set and whose trader_id is absent from the engine's account_ids map — e.g. orders generated internally (child/contingent/settlement orders) before register_account was called, or a trader_id mismatch between client and matching engine configuration.
Common situations: Adding a matching engine/venue without registering all trader accounts; mismatched trader_id naming between the execution client config and the matching engine; child orders derived from a parent order lacking account_id in custom adapters.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Chain ID mismatch at connect: expected {expected_chain_id},
- Unsupported blockchain {blockchain} for RPC connection
- Kraken Spot does not support the demo environment
- Matching engine not found for instrument {order_instrument_i
- Matching engine not found for instrument {instrument_id}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/81b3f324a5e9c07a.
Report an issue: GitHub.