nautechsystems/nautilus_trader · error · anyhow::Error
BinanceFuturesWebSocketClient requires UsdM or CoinM…
Error message
BinanceFuturesWebSocketClient requires UsdM or CoinM product type, was {product_type:?} What it means
BinanceFuturesWebSocketClient::new only supports BinanceProductType::UsdM and CoinM, since the futures websocket endpoint only serves those. Any other product type (Spot, Options, etc.) is rejected before building the connection URL.
Solutions
- Pass BinanceProductType::UsdM for USD-M futures or BinanceProductType::CoinM for COIN-M futures.
- Use the spot adapter/client instead if you intend spot trading.
- Fix the product_type in your configuration source.
Example fix
// before let client = BinanceFuturesWebSocketClient::new(BinanceProductType::Spot, ...); // after let client = BinanceFuturesWebSocketClient::new(BinanceProductType::UsdM, ...);
Defensive patterns
Strategy: validation
Validate before calling
fn futures_ws_product(pt: BinanceProductType) -> bool {
matches!(pt, BinanceProductType::UsdM | BinanceProductType::CoinM)
}
assert!(futures_ws_product(pt), "futures websocket requires UsdM or CoinM"); Type guard
fn is_futures_product(pt: &BinanceProductType) -> bool {
matches!(pt, BinanceProductType::UsdM | BinanceProductType::CoinM)
} Prevention
- Keep separate config constants for spot and futures product types.
- Validate product type at config load time.
- Use the spot adapter for spot markets instead of the futures client.
When it happens
Trigger: Constructing BinanceFuturesWebSocketClient::new(...) with product_type set to BinanceProductType::Spot, Options, or any variant other than UsdM/CoinM.
Common situations: Sharing one product-type constant across spot and futures clients; a config file that names the wrong product type; copying a spot client setup into a futures context.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Binance Futures does not support native GTD
- BinanceFuturesExecutionClient requires UsdM or CoinM…
- Both `api_key` and `api_secret` must be provided together
- Cannot configure both ping_handler and epoch_ping_handler
- Connection rate keys require a connection rate limiter
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/4d91f649b3ec18a3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/binance/src/futures/websocket/streams/client.rs:148
///
/// # Errors
///
/// Returns an error if:
/// - `product_type` is not a futures type (UsdM or CoinM).
/// - Credential creation fails.
pub fn new(
product_type: BinanceProductType,
environment: BinanceEnvironment,
api_key: Option<String>,
api_secret: Option<String>,
url_override: Option<String>,
heartbeat: Option<u64>,
transport_backend: TransportBackend,
) -> anyhow::Result<Self> {
match product_type {
BinanceProductType::UsdM | BinanceProductType::CoinM => {}
_ => {
anyhow::bail!(
"BinanceFuturesWebSocketClient requires UsdM or CoinM product type, was {product_type:?}"
);
}
}
let url = SecretString::from(
url_override.unwrap_or_else(|| get_ws_base_url(product_type, environment).to_string()),
);
let credential = match (api_key, api_secret) {
(Some(key), Some(secret)) => Some(Arc::new(SigningCredential::new(key, secret))),
_ => None,
};
Ok(Self {
url,
product_type,
credential,View on GitHub (pinned to 18893faf8b)