nautechsystems/nautilus_trader · error

Lighter has no fill-or-kill TIF; reject FOK at the strategy

Error message

Lighter has no fill-or-kill TIF; reject FOK at the strategy or use IOC explicitly

What it means

Raised when translating an order's time-in-force for a Lighter market order with TimeInForce::Fok. Lighter's market orders only support GTC (mapped to ImmediateOrCancel) and IOC; there is no fill-or-kill TIF on the venue, so FOK is rejected with this guidance message.

Source

Thrown at crates/adapters/lighter/src/websocket/dispatch.rs:1992

/// execution instruction, but their trigger lifetime is controlled by a
/// positive `OrderExpiry`.
///
/// FOK ("fill or kill") is rejected because Lighter has no native
/// fill-or-kill primitive: routing FOK as IOC would let a partial fill
/// satisfy the request, violating the FOK guarantee.
pub(crate) fn nautilus_to_lighter_tif(
    order_type: OrderType,
    tif: TimeInForce,
    post_only: bool,
) -> anyhow::Result<LighterTimeInForce> {
    if post_only {
        return Ok(LighterTimeInForce::PostOnly);
    }

    if order_type == OrderType::Market {
        return match tif {
            TimeInForce::Gtc | TimeInForce::Ioc => Ok(LighterTimeInForce::ImmediateOrCancel),
            TimeInForce::Fok => anyhow::bail!(
                "Lighter has no fill-or-kill TIF; reject FOK at the strategy or use IOC explicitly",
            ),
            other => anyhow::bail!(
                "Lighter market orders support only TimeInForce::Gtc or TimeInForce::Ioc, was TimeInForce::{other:?}",
            ),
        };
    }

    if is_conditional_market_order(order_type) {
        return match tif {
            TimeInForce::Gtc | TimeInForce::Day | TimeInForce::Gtd => {
                Ok(LighterTimeInForce::ImmediateOrCancel)
            }
            TimeInForce::Ioc => anyhow::bail!(
                "Lighter conditional market orders require a positive expiry; Nautilus IOC cannot be represented because the venue uses IOC for post-trigger execution",
            ),
            TimeInForce::Fok => anyhow::bail!(
                "Lighter has no fill-or-kill TIF; reject FOK at the strategy or use IOC explicitly",

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Change the strategy/submit call to use TimeInForce::Ioc for market orders (nearest semantics to FOK on Lighter).
  2. Use a LIMIT PostOnly or IOC order if fill-all-or-nothing semantics are mandatory; emulate FOK at the strategy level (cancel unfilled remainder).
  3. Update the order factory/emulator config so market orders default to GTC or IOC.
  4. Add pre-submit validation in your strategy that rejects FOK for Lighter instruments.
  5. If FOK support appears in a newer Lighter API, upgrade the adapter and revisit this mapping.

Example fix

// before
let order = order_factory.market(
    instrument_id, OrderSide::Buy, qty,
    TimeInForce::Fok, None, // rejected by Lighter
);

// after
let order = order_factory.market(
    instrument_id, OrderSide::Buy, qty,
    TimeInForce::Ioc, None,
);
Defensive patterns

Strategy: validation

Validate before calling

// reject FOK market orders before submission
if order_type == OrderType::Market && tif == TimeInForce::Fok {
    return Err("Lighter market orders do not support FOK; use IOC".into());
}

Try / catch

match translate_tif(order_type, tif) {
    Err(e) if e.to_string().contains("fill-or-kill") => {
        log::warn!("downgrading FOK to IOC for Lighter");
        translate_tif(order_type, TimeInForce::Ioc)?
    }
    r => r?,
}

Prevention

When it happens

Trigger: Submitting a Lighter MARKET order with tif = TimeInForce::Fok — e.g. a strategy configured for FOK market entries, or code defaulting market orders to FOK — hits this bail in the TIF translation before the order reaches the exchange.

Common situations: Porting a strategy from another venue (e.g. Binance/Crypto.com) that supports FOK without adjusting TIF for Lighter; backtest code that assumes universal FOK support; a default TimeInForce::Fok in an order factory configuration.

Related errors


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