{"record":{"id":"23b034b178bc7a4e","repo":"nautechsystems/nautilus_trader","slug":"unsupported-time-in-force-for-hyperliquid-tif","errorCode":null,"errorMessage":"Unsupported time in force for Hyperliquid: {tif:?}","messagePattern":"Unsupported time in force for Hyperliquid: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/hyperliquid/src/common/parse.rs","lineNumber":386,"sourceCode":"}\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\n        // For other trigger types, try to infer from price relationship if available\n        _ => {","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/hyperliquid/src/common/parse.rs#L368-L404","documentation":"Catch-all rejection in time_in_force_to_hyperliquid_tif for any (TimeInForce, is_post_only) combination not explicitly mapped. Only Gtc/Ioc/Fok with post_only=false and any TIF with post_only=true (mapped to ALO) are recognized; anything else (e.g. a newer TimeInForce variant like Day or Gtd, or an unexpected combination) fails with this debug-formatted message.","triggerScenarios":"Passing a TimeInForce value outside {Gtc, Ioc, Fok} with post_only=false — commonly a newly added or venue-agnostic TIF variant such as TimeInForce::Gtd or ::Day — to any order submission or modification path that builds a Hyperliquid request.","commonSituations":"Strategy code written against a newer Nautilus core with TIF variants this adapter doesn't map; TIF set from config/templates without checking Hyperliquid support; version mismatch between nautilus-core and the hyperliquid adapter crate.","solutions":["Set the order's time_in_force to Gtc or Ioc (the TIFs Hyperliquid supports with non-post-only orders).","If you need Gtd/Day semantics, emulate them by scheduling cancellation client-side instead of relying on the exchange TIF.","Check the adapter's supported TIF mapping and your crate versions; upgrade the hyperliquid adapter if it lacks a mapping for a core TIF variant you need.","Verify is_post_only/TIF combination explicitly before calling submit or modify."],"exampleFix":"// before\norder.time_in_force = TimeInForce::Gtd; // unmapped variant\n// after\norder.time_in_force = TimeInForce::Gtc; // supported by Hyperliquid","handlingStrategy":"validation","validationCode":"fn tif_is_mapped(tif: TimeInForce) -> bool {\n    matches!(tif, TimeInForce::Gtc | TimeInForce::Ioc | TimeInForce::Fok)\n}\nassert!(tif_is_mapped(order.time_in_force()), \"TIF not mapped for Hyperliquid\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = adapter.submit_order(order).await {\n    if e.to_string().starts_with(\"Unsupported time in force\") {\n        log::warn!(\"downgrading TIF to Gtc: {e}\");\n        // resubmit with TimeInForce::Gtc\n    } else { return Err(e); }\n}","preventionTips":["Pin nautilus-core and adapter crate versions so TIF enums stay in sync","Only assign TIFs from the documented Hyperliquid-supported set","Emulate Gtd/Day semantics client-side via scheduled cancels"],"tags":["hyperliquid","time-in-force","enum-mapping","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-14T00:17:10.932Z"}