nautechsystems/nautilus_trader · error

Unsupported `TimeInForce` for Polymarket: {value:?}

Error message

Unsupported `TimeInForce` for Polymarket: {value:?}

What it means

Conversion of a Nautilus TimeInForce into a Polymarket API time-in-force fails because Polymarket only supports GTC, GTD, FOK (and IOC mapped to FAK). Any other TimeInForce variant has no Polymarket equivalent.

Source

Thrown at crates/adapters/polymarket/src/common/enums.rs:313

            PolymarketOrderType::GTC => Self::Gtc,
            PolymarketOrderType::GTD => Self::Gtd,
            PolymarketOrderType::FOK => Self::Fok,
            // Fill-And-Kill is equivalent to Immediate-Or-Cancel
            PolymarketOrderType::FAK => Self::Ioc,
        }
    }
}

impl TryFrom<TimeInForce> for PolymarketOrderType {
    type Error = anyhow::Error;

    fn try_from(value: TimeInForce) -> anyhow::Result<Self> {
        match value {
            TimeInForce::Gtc => Ok(Self::GTC),
            TimeInForce::Gtd => Ok(Self::GTD),
            TimeInForce::Fok => Ok(Self::FOK),
            TimeInForce::Ioc => Ok(Self::FAK),
            _ => anyhow::bail!("Unsupported `TimeInForce` for Polymarket: {value:?}"),
        }
    }
}

impl PolymarketOrderType {
    pub(crate) fn from_market_time_in_force(value: TimeInForce) -> anyhow::Result<Self> {
        match value {
            TimeInForce::Fok => Ok(Self::FOK),
            TimeInForce::Ioc => Ok(Self::FAK),
            _ => anyhow::bail!("Unsupported `TimeInForce` for Polymarket market order: {value:?}"),
        }
    }
}

impl From<PolymarketOrderStatus> for OrderStatus {
    fn from(value: PolymarketOrderStatus) -> Self {
        match value {
            PolymarketOrderStatus::Invalid => Self::Rejected,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set the order's time_in_force to Gtc, Gtd, Fok, or Ioc before submitting to Polymarket
  2. If a Day-style order is needed, explicitly convert it to Gtc for Polymarket
  3. Match on the variant in your order-building code and reject unsupported values early

Example fix

// before
let tif = TimeInForce::Day;
let poly_tif = PolymarketTimeInForce::try_from(tif)?; // panics/bails
// after
let tif = TimeInForce::Gtc; // or Gtd/Fok/Ioc
let poly_tif = PolymarketTimeInForce::try_from(tif)?;
Defensive patterns

Strategy: validation

Validate before calling

const POLYMARKET_TIFS: &[TimeInForce] = &[TimeInForce::Gtc, TimeInForce::Gtd, TimeInForce::Fok, TimeInForce::Ioc];
assert!(POLYMARKET_TIFS.contains(&order.time_in_force()), "unsupported Polymarket TIF");

Type guard

fn is_polymarket_tif(tif: TimeInForce) -> bool {
    matches!(tif, TimeInForce::Gtc | TimeInForce::Gtd | TimeInForce::Fok | TimeInForce::Ioc)
}

Try / catch

match PolymarketTimeInForce::try_from(order.time_in_force()) {
    Ok(t) => submit_with(t),
    Err(e) => { log::error!("{e}"); /* fall back to Gtc or reject order */ }
}

Prevention

When it happens

Trigger: Submitting a Polymarket order whose TimeInForce is one of the unsupported variants (e.g. TimeInForce::Day, AtTheOpen, AtTheClose, or any new variant) via TryFrom<TimeInForce> for PolymarketTimeInForce.

Common situations: Default order templates using TimeInForce::Day from other venues being reused with the Polymarket adapter.

Related errors


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