nautechsystems/nautilus_trader · error

Continuous future ratio adjustment requires positive prices,

Error message

Continuous future ratio adjustment requires positive prices, was {row_value}

What it means

Ratio-style adjustment (BackwardRatio/ForwardRatio) computes price ratios between the pre and post contracts at each transition, which is undefined for non-positive prices. When a ratio adjustment mode is selected, every transition's pre_price and post_price must be strictly positive.

Source

Thrown at crates/data/src/engine/requests.rs:573

                "Continuous future segment venue mismatch for {target_bar_type}: target venue {target_venue}, segment venues pre={}, post={}",
                pre_instrument_id.venue,
                post_instrument_id.venue,
            );
        }

        if let Some(previous) = previous_post_instrument_id
            && pre_instrument_id != previous
        {
            anyhow::bail!(
                "Continuous future chain discontinuity for {target_bar_type}: previous post {previous} != current pre {pre_instrument_id}",
            );
        }
        previous_post_instrument_id = Some(post_instrument_id);

        let pre_price = parse_transition_price(row.get("pre_price"), row_value, "pre_price")?;
        let post_price = parse_transition_price(row.get("post_price"), row_value, "post_price")?;
        if is_ratio && (pre_price <= Decimal::ZERO || post_price <= Decimal::ZERO) {
            anyhow::bail!(
                "Continuous future ratio adjustment requires positive prices, was {row_value}"
            );
        }

        transitions.push(ContinuousFutureTransition {
            transition_time_ns,
            pre_instrument_id,
            post_instrument_id,
            pre_price,
            post_price,
        });
    }

    Ok(transitions)
}

fn parse_transition_instrument_id(
    value: Option<&Value>,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Provide real positive outright contract prices for pre_price and post_price in every transition row.
  2. If the underlying contract can trade at or below zero, use a spread adjustment mode (BackwardSpread/ForwardSpread) instead of ratio.
  3. Validate all transition prices > 0 before issuing the request when using ratio adjustment.

Example fix

// before
{"pre_price": 0, "post_price": 21.5} // ratio mode
// after
{"pre_price": 20.75, "post_price": 21.5} // or switch to adjustment_mode 1 (spread)
Defensive patterns

Strategy: validation

Validate before calling

if is_ratio {
    for t in &transitions {
        assert!(t.pre_price > Decimal::ZERO && t.post_price > Decimal::ZERO);
    }
}

Prevention

When it happens

Trigger: parse_transitions receives a transition row with pre_price <= 0 or post_price <= 0 while the request's adjustment mode is a ratio type — e.g. zero, negative, or placeholder prices in the roll table.

Common situations: Using 0 as a placeholder for an unknown transition price; signed/adjusted price series that dip at or below zero (e.g. negative oil futures); building rows from spreads rather than outright contract prices.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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