nautechsystems/nautilus_trader · error · anyhow::Error

Unsupported `OrderSide` for Binance: {value:?}

Error message

Unsupported `OrderSide` for Binance: {value:?}

What it means

Converting a NautilusTrader OrderSide to a BinanceSide supports only Buy and Sell - Binance has no representation for any other side. The TryFrom conversion fails, typically while encoding a submit/amend request in the execution client.

Source

Thrown at crates/adapters/binance/src/common/enums.rs:174

/// Order side for Binance orders and trades.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum BinanceSide {
    /// Buy side.
    Buy,
    /// Sell side.
    Sell,
}

impl TryFrom<OrderSide> for BinanceSide {
    type Error = anyhow::Error;

    fn try_from(value: OrderSide) -> Result<Self, Self::Error> {
        match value {
            OrderSide::Buy => Ok(Self::Buy),
            OrderSide::Sell => Ok(Self::Sell),
            _ => anyhow::bail!("Unsupported `OrderSide` for Binance: {value:?}"),
        }
    }
}

impl From<BinanceSide> for OrderSide {
    fn from(value: BinanceSide) -> Self {
        match value {
            BinanceSide::Buy => Self::Buy,
            BinanceSide::Sell => Self::Sell,
        }
    }
}

/// Position side for dual-side position mode.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
#[cfg_attr(
    feature = "python",

View on GitHub (pinned to a4b06ed870)

Solutions

  1. Set the order side explicitly to OrderSide::Buy or OrderSide::Sell before submitting to a Binance execution client
  2. Validate/normalize externally sourced sides to Buy/Sell at your trust boundary before building the order
  3. Check for a default-constructed OrderRequest whose side was never assigned

Example fix

// before
let side = OrderSide::default(); // non-directional -> conversion fails

// after
let side = OrderSide::Buy; // or OrderSide::Sell
Defensive patterns

Strategy: type-guard

Validate before calling

fn is_binance_supported_side(side: OrderSide) -> bool {
    matches!(side, OrderSide::Buy | OrderSide::Sell)
}

Type guard

fn is_binance_supported_side(side: OrderSide) -> bool {
    matches!(side, OrderSide::Buy | OrderSide::Sell)
}

Try / catch

match BinanceSide::try_from(order.side()) {
    Ok(side) => submit(order, side),
    Err(_) => log::error!("order {} has side {:?} unsupported by Binance - rejected locally", order.id(), order.side()),
}

Prevention

When it happens

Trigger: Creating a Binance order whose OrderSide is any variant other than Buy or Sell (e.g. a default-constructed, undetermined, or non-directional side reaching the encoder), or porting a strategy/config from an adapter that accepts more sides.

Common situations: Uninitialized/default side leaking from a hand-built order request; parsing sides from external signals that yield an unexpected value; cross-venue strategy code reused against Binance.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/130ec311a4726286. Report an issue: GitHub.