{"record":{"id":"859cab73d2edc104","repo":"nautechsystems/nautilus_trader","slug":"expected-a-coin-m-definition-for-instrument-id","errorCode":null,"errorMessage":"expected a COIN-M definition for {instrument_id}","messagePattern":"expected a COIN-M definition for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":511,"sourceCode":"        };\n\n        Ok(period.to_string())\n    }\n\n    fn coinm_open_interest_hist_params(\n        http: &BinanceFuturesHttpClient,\n        instrument_id: &InstrumentId,\n    ) -> anyhow::Result<(String, String)> {\n        let symbol = format_binance_symbol(instrument_id);\n        if let Some(pair) = symbol.strip_suffix(\"_PERP\") {\n            return Ok((pair.to_string(), \"PERPETUAL\".to_string()));\n        }\n\n        let definition = http\n            .instrument_metadata(*instrument_id)\n            .with_context(|| format!(\"missing COIN-M definition for {instrument_id}\"))?;\n        let BinanceFuturesInstrument::CoinM(definition) = definition else {\n            anyhow::bail!(\"expected a COIN-M definition for {instrument_id}\");\n        };\n\n        Ok((definition.pair.to_string(), definition.contract_type))\n    }\n\n    fn parse_open_interest_decimal(field: &str, value: &str) -> anyhow::Result<Decimal> {\n        Decimal::from_str_exact(value)\n            .with_context(|| format!(\"invalid Binance open interest `{field}` value `{value}`\"))\n    }\n\n    fn liquidation_data_type(instrument_id: InstrumentId) -> DataType {\n        let mut metadata = Params::new();\n        metadata.insert(\n            \"instrument_id\".to_string(),\n            serde_json::Value::String(instrument_id.to_string()),\n        );\n        DataType::new(\n            \"BinanceFuturesLiquidation\",","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L493-L529","documentation":"For COIN-M historical open interest, the adapter resolves the instrument's definition to get its `pair` and contract type. If the stored definition for the instrument is not the COIN-M variant (e.g. it is a USD-M futures definition), this invariant-style bail fires.","triggerScenarios":"request_data for BinanceFuturesOpenInterestHist with a COIN-M-style instrument whose resolved definition from http.instrument_metadata is a BinanceFuturesInstrument::UsdM (or another variant) instead of CoinM.","commonSituations":"Passing a USD-M instrument id (e.g. BTCUSDT-PERP.BINANCE) where a COIN-M instrument (BTCUSD_PERP.BINANCE_COINM) is expected, or requesting OI hist for the wrong venue suffix.","solutions":["Use a COIN-M instrument id ending in the COIN-M venue (e.g. BTCUSD_PERP.BINANCE_COINM-style identifier)","Confirm the instrument was loaded from the COIN-M exchange info endpoints, not USD-M","Check whether the request should target the USD-M open interest handler instead","Rebuild the instrument definitions cache if it was populated with the wrong product type"],"exampleFix":"// before\ninstrument_id = \"BTCUSDT-PERP.BINANCE\" // USD-M definition\n// after\ninstrument_id = \"BTCUSD_PERP.BINANCE_COINM\" // COIN-M definition","handlingStrategy":"type-guard","validationCode":"let def = http.instrument_metadata(instrument_id).await?;\nassert!(matches!(def, BinanceFuturesInstrument::CoinM(_)), \"instrument must be COIN-M for OI hist\");","typeGuard":"fn is_coinm(def: &BinanceFuturesInstrument) -> bool {\n    matches!(def, BinanceFuturesInstrument::CoinM(_))\n}","tryCatchPattern":"match client.request_data(data_type).await {\n    Err(e) if e.to_string().contains(\"expected a COIN-M definition\") => return Err(anyhow::anyhow!(\"use a COIN-M instrument id\")),\n    other => other,\n}","preventionTips":["Use COIN-M instrument ids (e.g. BTCUSD_PERP.* with COIN-M venue) for COIN-M OI hist","Verify instruments were loaded from COIN-M exchange info","Route COIN-M requests to the COIN-M data client"],"tags":["rust","coinm","instruments","binance"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}