nautechsystems/nautilus_trader · error · anyhow::Error
Cannot cache futures spread: missing option instrument {put_
Error message
Cannot cache futures spread: missing option instrument {put_instrument_id} What it means
Same failure family as the call-side error: `cache_futures_spread` requires the put option instrument of the pair, and it was not found in the cache, so the futures-spread price cannot be computed. The call instrument was found but the put instrument lookup returned None.
Source
Thrown at crates/common/src/greeks.rs:1061
pub fn cache_futures_spread(
&self,
call_instrument_id: InstrumentId,
put_instrument_id: InstrumentId,
futures_instrument_id: InstrumentId,
) -> anyhow::Result<Price> {
let cache = self.cache.borrow();
let call_instrument = cache.instrument(&call_instrument_id).cloned();
let put_instrument = cache.instrument(&put_instrument_id).cloned();
let reference_future_instrument = cache.instrument(&futures_instrument_id).cloned();
drop(cache);
let Some(call_instrument) = call_instrument else {
anyhow::bail!(
"Cannot cache futures spread: missing option instrument {call_instrument_id}"
);
};
let Some(put_instrument) = put_instrument else {
anyhow::bail!(
"Cannot cache futures spread: missing option instrument {put_instrument_id}"
);
};
let Some(reference_future_instrument) = reference_future_instrument else {
anyhow::bail!(
"Cannot cache futures spread: no reference futures instrument for {futures_instrument_id}"
);
};
if call_instrument.instrument_class() != InstrumentClass::Option
|| put_instrument.instrument_class() != InstrumentClass::Option
{
anyhow::bail!(
"Cannot cache futures spread: non-option instruments provided call_instrument_id={call_instrument_id} put_instrument_id={put_instrument_id}"
);
}
if call_instrument.option_kind() != Some(OptionKind::Call)View on GitHub (pinned to 18893faf8b)
Solutions
- Ensure the full option chain (both call and put legs) is loaded into the cache before calling `cache_futures_spread`
- Verify the `put_instrument_id` symbol and venue against `cache.instrument_ids()`
- Register the missing put instrument definition from the provider data source
Example fix
// before
greeks.cache_futures_spread(&call_id, &put_id, &future_id)?;
// after
for id in [&call_id, &put_id, &future_id] {
assert!(cache.instrument(id).is_some(), "{id} missing from cache");
}
greeks.cache_futures_spread(&call_id, &put_id, &future_id)?; Defensive patterns
Strategy: validation
Validate before calling
fn ensure_pair_cached(cache: &Cache, call: &InstrumentId, put: &InstrumentId) -> Result<(), String> {
for id in [call, put] {
if cache.instrument(id).is_none() {
return Err(format!("{id} not in cache"));
}
}
Ok(())
} Try / catch
match greeks.cache_futures_spread(&call_id, &put_id, &future_id) {
Ok(()) => (),
Err(e) if e.to_string().contains("missing option instrument") => {
tracing::warn!("{e}; ensure put leg is loaded");
return Ok(());
}
Err(e) => return Err(e),
} Prevention
- Always load both legs of an options pair together
- Verify put symbol formatting matches cached instrument definitions
- Assert presence of all three instruments (call, put, future) before spread caching
When it happens
Trigger: Calling `cache_futures_spread(...)` with a `put_instrument_id` absent from the cache — put-leg instrument never loaded, wrong symbol/venue, or only one side of the options pair was subscribed/registered.
Common situations: Loading only call options from a chain snapshot; symbol formatting mismatch between the put leg and the cached definitions; adapter that publishes call instruments but not puts for the expiry.
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
- Cannot cache futures spread: missing option instrument {call
- cannot rebuild Wallet reservations: no instrument found for
- DataActor {} must be registered before calling `cache()` - t
- Order {client_order_id} not found
- Position {position_id} not found
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/243cd6921b328c0f.
Report an issue: GitHub.