nautechsystems/nautilus_trader · error

Execution algorithm {restore_actor_id} not found while resto

Error message

Execution algorithm {restore_actor_id} not found while restoring subscriptions

What it means

The subscription-restore closure registered by add_exec_algorithm looks the algorithm up by actor id via try_get_actor_unchecked when it needs to restore cached strategy subscriptions. If the actor is not resolvable in the registry at that moment, it fails with this message. This indicates the algorithm was unregistered or the lookup id does not match any live actor.

Source

Thrown at crates/system/src/trader.rs:763

        }

        let component_id = exec_algorithm.component_id();
        let clock = self.create_component_clock(component_id);

        exec_algorithm.register(self.trader_id, clock, self.cache.clone())?;
        exec_algorithm
            .exec_algorithm_core_mut()
            .set_portfolio(self.portfolio.clone());

        register_component_actor(exec_algorithm);

        // Register the {id}.execute endpoint so the order manager can
        // route TradingCommands to this algorithm via msgbus::send_any
        let actor_id = exec_algorithm_id.inner();
        let restore_actor_id = actor_id;
        let restore_fn: ExecutionAlgorithmSubscriptionFn = Box::new(move || {
            let Some(mut algo) = try_get_actor_unchecked::<T>(&restore_actor_id) else {
                anyhow::bail!(
                    "Execution algorithm {restore_actor_id} not found while restoring subscriptions"
                );
            };

            let mut strategy_ids = {
                let cache = algo.exec_algorithm_core_mut().cache_ref();
                cache
                    .orders_for_exec_algorithm(&exec_algorithm_id, None, None, None, None, None)
                    .into_iter()
                    .filter(|order| {
                        !order.is_closed() && order.exec_algorithm_id() == Some(exec_algorithm_id)
                    })
                    .map(|order| order.strategy_id())
                    .collect::<Vec<_>>()
            };
            strategy_ids.sort_unstable();
            strategy_ids.dedup();

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Ensure the exec algorithm remains registered/live for the whole trader lifecycle; do not dispose it while the trader can restart.
  2. Verify the component_id used at registration matches the actor id stored in the registry.
  3. Re-register the exec algorithm (add_exec_algorithm) after any teardown so its restore hook references a live actor.

Example fix

// before
trader.stop();
dispose_exec_algorithm(algo);
trader.start()?; // restore_fn can't find actor

// after
trader.stop();
trader.add_exec_algorithm(algo)?; // re-register before restart
trader.start()?;
Defensive patterns

Strategy: try-catch

Try / catch

if let Err(e) = trader.start() {
    if e.to_string().contains("not found while restoring subscriptions") {
        trader.add_exec_algorithm(algo)?; // re-register then retry
        trader.start()?;
    } else { return Err(e); }
}

Prevention

When it happens

Trigger: The restore_fn runs (typically during trader start/restart when restoring strategy subscriptions) while try_get_actor_unchecked::<T>(&actor_id) returns None — the algorithm was removed, never registered under that id, or the registry was cleared.

Common situations: Stopping and restarting a trader where the exec algorithm was disposed in between; a mismatch between the registered component_id and the id used for actor lookup; hot-reload code that tears down actors without unregistering the restore hook.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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