{"record":{"id":"cc250441e88d0f10","repo":"nautechsystems/nautilus_trader","slug":"fok-time-in-force-is-not-supported-by-hyperliquid","errorCode":null,"errorMessage":"FOK time in force is not supported by Hyperliquid","messagePattern":"FOK time in force is not supported by Hyperliquid","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/hyperliquid/src/common/parse.rs","lineNumber":384,"sourceCode":"        Some(leading.to_string())\n    }\n}\n\n/// Converts a Nautilus `TimeInForce` to Hyperliquid TIF.\n///\n/// # Errors\n///\n/// Returns an error if the time in force is not supported.\npub fn time_in_force_to_hyperliquid_tif(\n    tif: TimeInForce,\n    is_post_only: bool,\n) -> anyhow::Result<HyperliquidExchangeTif> {\n    match (tif, is_post_only) {\n        (_, true) => Ok(HyperliquidExchangeTif::Alo), // Always use ALO for post-only orders\n        (TimeInForce::Gtc, false) => Ok(HyperliquidExchangeTif::Gtc),\n        (TimeInForce::Ioc, false) => Ok(HyperliquidExchangeTif::Ioc),\n        (TimeInForce::Fok, false) => {\n            anyhow::bail!(\"FOK time in force is not supported by Hyperliquid\")\n        }\n        _ => anyhow::bail!(\"Unsupported time in force for Hyperliquid: {tif:?}\"),\n    }\n}\n\nfn determine_tpsl_type(\n    order_type: OrderType,\n    order_side: OrderSide,\n    trigger_price: Decimal,\n    current_price: Option<Decimal>,\n) -> HyperliquidExchangeTpSl {\n    match order_type {\n        // Stop orders are protective - always SL\n        OrderType::StopMarket | OrderType::StopLimit => HyperliquidExchangeTpSl::Sl,\n\n        // If Touched orders are profit-taking or entry orders - always TP\n        OrderType::MarketIfTouched | OrderType::LimitIfTouched => HyperliquidExchangeTpSl::Tp,\n","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/hyperliquid/src/common/parse.rs#L366-L402","documentation":"Hyperliquid's exchange API does not offer a Fill-or-Kill time in force; its order types map to GTC, IOC, and ALO only. time_in_force_to_hyperliquid_tif rejects TIF::Fok with this message when translating a Nautilus order into a Hyperliquid exchange request, because silently converting FOK to something else would change execution semantics.","triggerScenarios":"Submitting or modifying an order with TimeInForce::Fok and is_post_only=false (or unset) through order_to_hyperliquid_request_with_asset_and_cloid, modify_order, or when hyperliquid_order_kind derives the order kind — e.g. submit_order with a FOK limit/market order.","commonSituations":"Strategy code or config carrying over FOK defaults from another adapter (Binance/Bybit support FOK), a venue-agnostic strategy parameterization that sets FOK, or an order event reconstructed from a template with FOK TIF.","solutions":["Change the order's time_in_force to Gtc or Ioc before submission (Ioc is the closest partial-fill-averse alternative).","If true all-or-nothing execution is required, implement client-side size checks or use Hyperliquid's ALO post-only semantics where appropriate — the venue simply cannot guarantee FOK.","Pre-validate order TIF in the strategy layer and route FOK orders to a venue that supports them."],"exampleFix":"// before\nlet mut order = order_factory.limit(...);\norder.time_in_force = TimeInForce::Fok;\nsubmit_order(order)?;\n// after\norder.time_in_force = TimeInForce::Ioc; // FOK unsupported on Hyperliquid\nsubmit_order(order)?;","handlingStrategy":"validation","validationCode":"fn supports_tif_hyperliquid(tif: TimeInForce) -> bool {\n    matches!(tif, TimeInForce::Gtc | TimeInForce::Ioc)\n}\nif !supports_tif_hyperliquid(order.time_in_force()) { /* convert to Ioc or reject at strategy layer */ }","typeGuard":null,"tryCatchPattern":"match adapter.submit_order(order).await {\n    Err(e) if e.to_string().contains(\"FOK time in force\") => {\n        let mut fixed = order.clone();\n        fixed.set_time_in_force(TimeInForce::Ioc);\n        adapter.submit_order(fixed).await?;\n    }\n    r => r?,\n}","preventionTips":["Keep venue-agnostic TIF config out of venue-specific strategies","Default to Gtc/Ioc for Hyperliquid orders","Check adapter-supported TIFs when porting strategies from other venues"],"tags":["hyperliquid","time-in-force","unsupported-feature","rust"],"backgroundTag":"unsupported-enum-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}