nautechsystems/nautilus_trader · error

Unsupported time_in_force {other:?} for Deribit

Error message

Unsupported time_in_force {other:?} for Deribit

What it means

build_order_params maps TimeInForce values to Deribit TIF strings (gtc, ioc, fok, good_til_day, and managed GTD under conditions). Any other TimeInForce hits the catch-all and bails, since Deribit does not accept that TIF value.

Source

Thrown at crates/adapters/deribit/src/execution.rs:277

            // Deribit rejects `time_in_force` on market-style order types
            None
        } else {
            Some(
                match order.time_in_force() {
                    TimeInForce::Gtc => "good_til_cancelled",
                    TimeInForce::Ioc => "immediate_or_cancel",
                    TimeInForce::Fok => "fill_or_kill",
                    TimeInForce::Gtd => {
                        if order.expire_time().is_some() {
                            log::warn!(
                                "Deribit GTD orders expire at 8:00 UTC only - custom expire_time is ignored. \
                                For custom expiry times, use managed GTD with emulation_trigger"
                            );
                        }
                        "good_til_day"
                    }
                    other => {
                        anyhow::bail!("Unsupported time_in_force {other:?} for Deribit");
                    }
                }
                .to_string(),
            )
        };

        // Deribit's `valid_until` is a REQUEST timeout, not order expiry.
        // Deribit's `good_til_day` expires at end of trading session (8 UTC).
        let valid_until = None;

        let trigger = resolve_trigger_type(order.trigger_type());

        Ok(DeribitOrderParams {
            instrument_name: order.instrument_id().symbol.to_string(),
            amount: order.quantity().as_decimal(),
            order_type,
            label: Some(order.client_order_id().to_string()),
            price: order.price().map(|p| p.as_decimal()),

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use TimeInForce::Gtc, Ioc, Fok, Gtd (with valid expiry handling), or Day where supported
  2. For GTD, follow the adapter's requirement for managed GTD with a valid expiry/emulation_trigger as indicated by the preceding message text
  3. Validate time_in_force at order construction time before submitting to Deribit

Example fix

// before
let order = factory.limit(..., TimeInForce::AtTheOpen, ...);
// after
let order = factory.limit(..., TimeInForce::Gtc, ...);
Defensive patterns

Strategy: type-guard

Validate before calling

const SUPPORTED_TIF: &[TimeInForce] = &[
    TimeInForce::Gtc, TimeInForce::Ioc, TimeInForce::Fok, TimeInForce::Gtd, TimeInForce::Day,
];
if !SUPPORTED_TIF.contains(&order.time_in_force()) {
    return Err(anyhow::anyhow!("TIF {:#?} unsupported on Deribit", order.time_in_force()));
}

Type guard

fn deribit_supported_tif(t: TimeInForce) -> bool {
    matches!(t, TimeInForce::Gtc | TimeInForce::Ioc | TimeInForce::Fok
        | TimeInForce::Gtd | TimeInForce::Day)
}

Try / catch

match exec_client.submit_order(&order) {
    Err(e) if e.to_string().contains("Unsupported time_in_force") => rebuild_with_default_tif(&order),
    other => other,
}

Prevention

When it happens

Trigger: Submitting an order whose time_in_force() is not one of GTC/IOC/FOK/GTD(handled specially)/DAY(mapped to good_til_day) — e.g. TimeInForce::AtTheOpen or TimeInForce::GoodTilDate used incorrectly — through the Deribit execution client.

Common situations: Orders built with a default TIF unsupported by Deribit; GTD orders with expiry conditions the adapter rejects (see message about managed GTD / emulation_trigger); strategies copied from venues with different TIF sets.

Related errors


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