nautechsystems/nautilus_trader · error
Market orders on Betfair are only supported with AtTheClose…
Error message
Market orders on Betfair are only supported with AtTheClose time in force (BSP MarketOnClose)
What it means
Betfair only supports market orders as BSP MarketOnClose bets, which require TimeInForce::AtTheClose. When converting an order to a PlaceInstruction, a Market order with any other time in force is rejected with this error.
Solutions
- Use OrderType::Market only with TimeInForce::AtTheClose (BSP MarketOnClose bet)
- For continuous markets, switch to Limit orders (Betfair's native order type)
- Use OrderType::MarketOnClose (MarketOnCloseOrder with liability) if that is the intent
Example fix
// before
let order = order_factory.market(
instrument_id, OrderSide::Buy, qty, TimeInForce::Gtc, ...
);
// after
let order = order_factory.limit(
instrument_id, OrderSide::Buy, qty, price, TimeInForce::Gtc, ...
);
// or market with AtTheClose for BSP MarketOnClose Defensive patterns
Strategy: validation
Validate before calling
if order.order_type() == OrderType::Market
&& order.time_in_force() != TimeInForce::AtTheClose {
return Err(anyhow!("Betfair market orders require AtTheClose TIF"));
} Type guard
fn betfair_market_ok(o: &dyn Order) -> bool {
o.order_type() != OrderType::Market || o.time_in_force() == Some(TimeInForce::AtTheClose)
} Try / catch
match exec_client.submit_order(&order).await {
Err(e) if e.to_string().contains("AtTheClose") => {
warn!("converting to limit order");
}
other => other?,
} Prevention
- On Betfair, use Limit orders for continuous trading; Market only as MarketOnClose (AtTheClose)
- Add a pre-submit order-type allowlist per venue in strategy code
- Read the Betfair adapter docs on BSP MarketOnClose semantics
When it happens
Trigger: submitting a SubmitOrder with OrderType::Market and time_in_force not equal to AtTheClose (e.g. GTC, IOC, or None) to the Betfair execution client.
Common situations: Reusing a generic strategy that emits plain market orders against a Betfair venue; forgetting that Betfair 'market' means MarketOnClose; migrating code from a FX/crypto adapter.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Unsupported order type for Betfair
- Binance Futures does not support GTD for order type
- Execution PostOnly not supported for
- failed to resolve positive quantity for current order
- failed to resolve positive quantity for stream order update
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/ac05f88e551870fc.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/betfair/src/execution.rs:3419
handicap,
side,
limit_order: Some(LimitOrder {
size,
price,
persistence_type,
time_in_force,
min_fill_size,
bet_target_type: None,
bet_target_size: None,
}),
limit_on_close_order: None,
market_on_close_order: None,
customer_order_ref,
})
}
OrderType::Market => {
if order.time_in_force() != TimeInForce::AtTheClose {
anyhow::bail!(
"Market orders on Betfair are only supported with AtTheClose \
time in force (BSP MarketOnClose)"
);
}
Ok(PlaceInstruction {
order_type: BetfairOrderType::MarketOnClose,
selection_id,
handicap,
side,
limit_order: None,
limit_on_close_order: None,
market_on_close_order: Some(MarketOnCloseOrder { liability: size }),
customer_order_ref,
})
}
other => anyhow::bail!("Unsupported order type for Betfair: {other:?}"),
}View on GitHub (pinned to 18893faf8b)