nautechsystems/nautilus_trader · error · anyhow::Error

AT_THE_CLOSE time in force is not supported by Hyperliquid

Error message

AT_THE_CLOSE time in force is not supported by Hyperliquid

What it means

nautilus_time_in_force_to_hyperliquid cannot map an AtTheClose time-in-force; Hyperliquid has no closing-auction TIF concept, so this Nautilus TIF variant has no equivalent and the conversion is rejected.

Source

Thrown at crates/adapters/hyperliquid/src/common/converters.rs:262

    tif: TimeInForce,
) -> anyhow::Result<HyperliquidTimeInForce> {
    match tif {
        TimeInForce::Gtc => Ok(HyperliquidTimeInForce::Gtc),
        TimeInForce::Ioc => Ok(HyperliquidTimeInForce::Ioc),
        TimeInForce::Fok => {
            anyhow::bail!("FOK time in force is not supported by Hyperliquid")
        }
        TimeInForce::Gtd => {
            anyhow::bail!("GTD time in force is not supported by Hyperliquid")
        }
        TimeInForce::Day => {
            anyhow::bail!("DAY time in force is not supported by Hyperliquid")
        }
        TimeInForce::AtTheOpen => {
            anyhow::bail!("AT_THE_OPEN time in force is not supported by Hyperliquid")
        }
        TimeInForce::AtTheClose => {
            anyhow::bail!("AT_THE_CLOSE time in force is not supported by Hyperliquid")
        }
    }
}

/// Converts a Hyperliquid time in force to a Nautilus `TimeInForce`.
pub fn hyperliquid_time_in_force_to_nautilus(hl_tif: HyperliquidTimeInForce) -> TimeInForce {
    match hl_tif {
        HyperliquidTimeInForce::Gtc => TimeInForce::Gtc,
        HyperliquidTimeInForce::Ioc
        | HyperliquidTimeInForce::FrontendMarket
        | HyperliquidTimeInForce::LiquidationMarket => TimeInForce::Ioc,
        HyperliquidTimeInForce::Alo => TimeInForce::Gtc,
    }
}

/// Determines the TP/SL type based on order type and side.
///
/// # Logic

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use a market/limit order with GTC or IOC submitted at your desired close time.
  2. Cancel remaining quantity after your close window to emulate MOC behavior.
  3. Add a venue-capability check that blocks AtTheClose for Hyperliquid.

Example fix

// before
let tif = TimeInForce::AtTheClose;
// after
let tif = TimeInForce::Gtc; // schedule submission near session close yourself
Defensive patterns

Strategy: validation

Validate before calling

fn hyperliquid_tif_ok(tif: TimeInForce) -> bool {
    matches!(tif, TimeInForce::Gtc | TimeInForce::Ioc)
}
if !hyperliquid_tif_ok(tif) { return Err(anyhow::anyhow!("unsupported TIF {tif:?} for Hyperliquid")); }

Try / catch

match nautilus_time_in_force_to_hyperliquid(tif) {
    Ok(t) => send(t),
    Err(e) => anyhow::bail!("adjust time in force: {e}"),
}

Prevention

When it happens

Trigger: Converting TimeInForce::AtTheClose via nautilus_time_in_force_to_hyperliquid when routing an order to Hyperliquid.

Common situations: Strategies liquidating at the close ported from equities; shared order templates across venues.

Related errors


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