nautechsystems/nautilus_trader · error · anyhow::Error

GTD time in force is not supported for BitMEX order submit;

Error message

GTD time in force is not supported for BitMEX order submit; use GTC, Day, IOC, or FOK

What it means

BitmexOrderType::try_from_time_in_force explicitly rejects TimeInForce::Gtd for order submission because BitMEX does not support good-til-date on order submit. The message directs users to GTC, Day, IOC, or FOK instead.

Source

Thrown at crates/adapters/bitmex/src/common/enums.rs:357

            TimeInForce::Gtc => Ok(Self::GoodTillCancel),
            TimeInForce::Gtd => Ok(Self::GoodTillDate),
            TimeInForce::Ioc => Ok(Self::ImmediateOrCancel),
            TimeInForce::Fok => Ok(Self::FillOrKill),
            TimeInForce::AtTheOpen => Ok(Self::AtTheOpening),
            TimeInForce::AtTheClose => Ok(Self::AtTheClose),
        }
    }
}

impl BitmexTimeInForce {
    /// Try to convert from Nautilus TimeInForce with anyhow::Result.
    ///
    /// # Errors
    ///
    /// Returns an error if the time in force is not supported by BitMEX.
    pub fn try_from_time_in_force(value: TimeInForce) -> anyhow::Result<Self> {
        if value == TimeInForce::Gtd {
            anyhow::bail!(
                "GTD time in force is not supported for BitMEX order submit; use GTC, Day, IOC, or FOK"
            );
        }

        Self::try_from(value)
    }
}

/// Represents the available contingency types on BitMEX.
#[derive(
    Copy,
    Clone,
    Debug,
    Display,
    PartialEq,
    Eq,
    AsRefStr,
    EnumIter,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Change the order's time_in_force to Gtc, Day, Ioc, or Fok before submitting to BitMEX
  2. If expiry semantics are needed, emulate GTD by scheduling a cancel at the expiry time with a GTC order
  3. Add a pre-submit guard that rewrites Gtd to Gtc for the BitMEX venue

Example fix

// before
let order = factory.limit(..., time_in_force=GTD, expire_time=...);
// after
let order = factory.limit(..., time_in_force=GTC, expire_time=None);
// plus scheduled cancel at the desired expiry
Defensive patterns

Strategy: validation

Validate before calling

if order.time_in_force() == TimeInForce::Gtd {
    return Err("rewrite Gtd to Gtc for BitMEX and schedule a cancel at expiry");
}

Prevention

When it happens

Trigger: Building a BitMEX order submit (BitmexOrderType::try_from_time_in_force) with an order whose TimeInForce is Gtd.

Common situations: Strategies ported from venues that support GTD (e.g. futures with expiry-based orders) run against BitMEX without adjusting TIF; Nautilus defaults some bracket/repeat orders to GTD with an expiry.

Related errors


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