nautechsystems/nautilus_trader · error · anyhow::Error

filter_callable {filter_callable:?} requires the Interactive

Error message

filter_callable {filter_callable:?} requires the Interactive Brokers adapter to be built with the python feature

What it means

The adapter supports an optional Python filter_callable to accept/reject instruments during contract detail processing, but that functionality only exists when the adapter is compiled with the `python` feature. When built without it, calling the filter unconditionally fails with this error instead of silently ignoring the filter.

Source

Thrown at crates/adapters/interactive_brokers/src/providers/instruments.rs:1805

                        )
                    })?;
                let callable = PyModule::import(py, module_name)
                    .map_err(|e| anyhow::anyhow!("Failed to import {module_name}: {e}"))?
                    .getattr(callable_name)
                    .map_err(|e| anyhow::anyhow!("Failed to resolve {filter_callable}: {e}"))?;
                let py_instrument = instrument_any_to_pyobject(py, instrument.clone())
                    .map_err(|e| anyhow::anyhow!("Failed to convert instrument to Python: {e}"))?;
                callable
                    .call1((py_instrument,))
                    .and_then(|result| result.extract::<bool>())
                    .map_err(|e| anyhow::anyhow!("filter_callable {filter_callable} failed: {e}"))
            })
        }

        #[cfg(not(feature = "python"))]
        {
            let _ = instrument;
            anyhow::bail!(
                "filter_callable {filter_callable:?} requires the Interactive Brokers adapter to be built with the python feature"
            );
        }
    }

    /// Batch load multiple instrument IDs.
    ///
    /// This method fetches and caches contract details for multiple instrument IDs in parallel.
    ///
    /// # Arguments
    ///
    /// * `client` - The IB API client
    /// * `instrument_ids` - Vector of instrument IDs to load
    /// * `filters` - Optional filters to apply (not yet implemented, reserved for future use)
    ///
    /// # Returns
    ///
    /// Returns a vector of successfully loaded instrument IDs.

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Reinstall/build the adapter with the python feature enabled (e.g. cargo build --features python or the python feature-enabled wheel).
  2. Remove the filter_callable from configuration if Python filtering is not needed.
  3. Verify the installed package actually includes the python feature (check build flags/docs).
  4. Filter instruments before passing them to the adapter instead of via filter_callable.

Example fix

// before: build without python feature
cargo build -p nautilus-ib
cargo build -p nautilus-ib --features python
Defensive patterns

Strategy: type-guard

Validate before calling

#[cfg(not(feature = "python"))]
fn python_filter_configured(filter: &Option<FilterCallable>) -> bool { filter.is_some() }
// guard before config: if python_filter_configured(&cfg.filter) { rebuild with --features python }

Prevention

When it happens

Trigger: process_contract_detail processes a contract while a filter_callable is configured, and the binary/library was compiled without feature "python" (cfg(not(feature = "python")).

Common situations: Installing a prebuilt wheel or Rust build without the python feature and then supplying a Python filter callback in config; mixing a Python host app with a non-python-feature build.

Related errors


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