nautechsystems/nautilus_trader · error
Invalid config type for DeribitExecutionClientFactory. Expec
Error message
Invalid config type for DeribitExecutionClientFactory. Expected DeribitExecutionClientConfig, was {config:?} What it means
DeribitExecutionClientFactory::create requires the config to be a DeribitExecutionClientConfig. It downcasts the type-erased ClientConfig; if the concrete type differs the downcast fails and this error is raised with the actual config's Debug output. It exists to catch wiring a non-execution (e.g. data-client) config into the execution factory.
Source
Thrown at crates/adapters/deribit/src/factories.rs:147
impl Default for DeribitExecutionClientFactory {
fn default() -> Self {
Self::new()
}
}
impl ExecutionClientFactory for DeribitExecutionClientFactory {
fn create(
&self,
trader_id: TraderId,
name: &str,
config: &dyn ClientConfig,
cache: CacheView,
) -> anyhow::Result<Box<dyn ExecutionClient>> {
let deribit_config = config
.as_any()
.downcast_ref::<DeribitExecutionClientConfig>()
.ok_or_else(|| {
anyhow::anyhow!(
"Invalid config type for DeribitExecutionClientFactory. Expected DeribitExecutionClientConfig, was {config:?}",
)
})?
.clone();
// Deribit uses netting (derivatives only, no hedging)
let oms_type = OmsType::Netting;
let account_type = AccountType::Margin;
let client_id = ClientId::from(name);
let core = ExecutionClientCore::new(
trader_id,
client_id,
*DERIBIT_VENUE,
oms_type,
deribit_config.account_id,
account_type,
None, // base_currencyView on GitHub (pinned to 18893faf8b)
Solutions
- Pass a DeribitExecutionClientConfig to this factory; inspect the printed Debug type name in the message to confirm what was actually passed.
- Build the execution config explicitly (DeribitExecutionClientConfig::new(instrument_provider_config, ...)) and wire it only into DeribitExecutionClientFactory.
- In generic bootstrap code, match the config concrete type to the corresponding factory instead of passing every config to every factory.
Example fix
// before let config = DeribitDataClientConfig::new(provider_config); let exec = DeribitExecutionClientFactory.create(name, Rc::new(config), cache, clock)?; // after let config = DeribitExecutionClientConfig::new(provider_config); let exec = DeribitExecutionClientFactory.create(name, Rc::new(config), cache, clock)?;
Defensive patterns
Strategy: type-guard
Validate before calling
let Some(cfg) = config.as_any().downcast_ref::<DeribitExecutionClientConfig>() else {
return Err(anyhow::anyhow!("expected DeribitExecutionClientConfig, got {config:?}"));
}; Type guard
fn is_deribit_execution_config(config: &dyn ClientConfig) -> bool {
config.as_any().is::<DeribitExecutionClientConfig>()
} Try / catch
match factory.create(name, config, cache, clock) {
Ok(client) => client,
Err(e) => { eprintln!("deribit execution client init failed: {e:#}"); return Err(e); }
} Prevention
- Use distinct variable names for data and execution configs to avoid swapping them.
- Assert the concrete config type in bootstrap tests before wiring clients.
- Never reuse one shared 'deribit config' for both factories; construct each explicitly.
When it happens
Trigger: Calling DeribitExecutionClientFactory::create(name, config, cache, ...) with any config other than DeribitExecutionClientConfig — most commonly a DeribitDataClientConfig or another venue's config.
Common situations: Duplicating data-client wiring for the execution client without changing the config type; bootstrapping all Deribit clients from one shared config; typos in generic bootstrap code that pass the wrong Rc'd config to the wrong factory.
Related errors
- Invalid config type for DeribitDataClientFactory. Expected D
- Invalid config type for BlockchainDataClientFactory. Expecte
- Invalid config type for BlockchainExecutionClientFactory. Ex
- Invalid config type for DatabentoDataClientFactory. Expected
- Invalid config type for AxExecutionClientFactory. Expected A
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/ba49463fe765aaa2.
Report an issue: GitHub.