nautechsystems/nautilus_trader · error
Invalid symbol format: missing quote currency in '{symbol}'
Error message
Invalid symbol format: missing quote currency in '{symbol}' What it means
The sibling failure of 3406: after extracting the base part from an OKX symbol, parse_base_quote_from_symbol requires a second '-'-separated segment for the quote currency. If the symbol contains no '-' (e.g. 'BTCUSDT' or 'BTC-'), no quote can be extracted and this error is returned.
Source
Thrown at crates/adapters/okx/src/common/parse.rs:291
_ if dash_count > 4 => OKXInstrumentType::Events,
_ => OKXInstrumentType::Spot, // Default fallback
}
}
/// Extracts base and quote currencies from an OKX symbol.
///
/// All OKX instrument symbols start with {BASE}-{QUOTE}, regardless of type.
///
/// # Errors
///
/// Returns an error if the symbol doesn't contain at least two parts separated by '-'.
pub fn parse_base_quote_from_symbol(symbol: &str) -> anyhow::Result<(&str, &str)> {
let mut parts = symbol.split('-');
let base = parts.next().ok_or_else(|| {
anyhow::anyhow!("Invalid symbol format: missing base currency in '{symbol}'")
})?;
let quote = parts.next().ok_or_else(|| {
anyhow::anyhow!("Invalid symbol format: missing quote currency in '{symbol}'")
})?;
Ok((base, quote))
}
/// Extracts the instrument family from an OKX symbol string.
///
/// All OKX derivative symbols encode the family as the first two segments:
/// `BTC-USD-250328-92000-C` -> `BTC-USD`, `BTC-USDT-SWAP` -> `BTC-USDT`.
///
/// # Errors
///
/// Returns an error if the symbol does not contain at least two dash-separated parts.
pub fn extract_inst_family(symbol: &str) -> anyhow::Result<Ustr> {
let (base, quote) = parse_base_quote_from_symbol(symbol)?;
Ok(Ustr::from(&format!("{base}-{quote}")))
}
/// Maps an [`OKXInstrumentStatus`] to a Nautilus [`MarketStatusAction`].View on GitHub (pinned to 18893faf8b)
Solutions
- Use OKX's exact instId format with the dash: 'BTC-USDT', 'ETH-USDT-SWAP', 'BTC-USD-240329' — not concatenated or Binance-style symbols.
- Validate symbol format (must contain '-') before calling any API that takes it.
- Fetch valid instrument ids from the OKX /public/instruments endpoint instead of constructing them by hand.
- Normalize symbols at configuration load time and fail early with a clear config error if they don't match the OKX format.
Example fix
// before let symbol = "BTCUSDT"; // Binance-style parse_base_quote_from_symbol(symbol)?; // after let symbol = "BTC-USDT"; // OKX instId format parse_base_quote_from_symbol(symbol)?;
Defensive patterns
Strategy: validation
Validate before calling
fn is_okx_inst_id(s: &str) -> bool {
let parts: Vec<&str> = s.split('-').collect();
parts.len() >= 2 && parts.iter().all(|p| !p.is_empty())
} Try / catch
if let Err(e) = parse_base_quote_from_symbol(symbol) {
anyhow::bail!("'{symbol}' is not an OKX instId (expected BASE-QUOTE[-...]): {e}");
} Prevention
- Always use dash-separated OKX instIds ('BTC-USDT'), never concatenated or Binance-style symbols.
- Reject non-conforming symbols during configuration parsing with a clear message.
- Cross-check configured ids against the instruments endpoint at startup.
When it happens
Trigger: extract_inst_family, parse_position_status_report, subscribe/unsubscribe_index_prices, or request_index_price receives a symbol without a '-' separator, such as a concatenated symbol ('BTCUSDT'), a bare coin id, or a trailing-dash string.
Common situations: Configuring instrument ids in compact form ('BTC-USDT' written as 'BTCUSDT'); reusing symbols from another exchange's format (Binance-style); using swap ticker instead of the full instId; copy-paste dropping part of the instrument id.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Invalid symbol format: missing base currency in '{symbol}'
- instrument update lock poisoned
- option_summary_family_subs mutex poisoned
- Conditional order types must use OKXAlgoOrderType
- Invalid `OrderType` cannot be represented on OKX: {value:?}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/f384bdc54780a4fa.
Report an issue: GitHub.