nautechsystems/nautilus_trader · error
Unknown venue code: {code}
Error message
Unknown venue code: {code} What it means
Venue::from_code looks up a venue code string in a global registry (VENUE_MAP) of known exchange venues. If the code was never registered (venues register themselves at init, typically via PyO3/Currency registration), the lookup fails and this error is returned.
Source
Thrown at crates/model/src/identifiers/venue.rs:120
#[must_use]
pub fn from_str_unchecked<T: AsRef<str>>(s: T) -> Self {
Self(Ustr::from(s.as_ref()))
}
#[must_use]
pub const fn from_ustr_unchecked(s: Ustr) -> Self {
Self(s)
}
/// # Errors
///
/// Returns an error if the venue code is unknown.
pub fn from_code(code: &str) -> anyhow::Result<Self> {
let map_guard = VENUE_MAP.lock();
map_guard
.get(code)
.copied()
.ok_or_else(|| anyhow::anyhow!("Unknown venue code: {code}"))
}
#[must_use]
pub fn synthetic() -> Self {
Self::new(SYNTHETIC_VENUE)
}
#[must_use]
pub fn is_synthetic(&self) -> bool {
self.0 == SYNTHETIC_VENUE
}
/// Returns true if the venue represents a decentralized exchange (contains ':').
#[cfg(feature = "defi")]
#[must_use]
pub fn is_dex(&self) -> bool {
self.0.contains(':')
}View on GitHub (pinned to 18893faf8b)
Solutions
- Correct the venue code spelling and case to a registered venue identifier.
- Ensure the relevant adapter/venue registration code runs before from_code (import and initialize the adapter crate or call the registration entry point).
- If the venue is intentionally custom, use Venue::new (internal) or the synthetic venue instead of from_code.
Example fix
// before
let venue = Venue::from_code("binance")?;
// after
let venue = Venue::from_code("BINANCE")?; Defensive patterns
Strategy: validation
Validate before calling
match Venue::from_code(code) {
Ok(v) => v,
Err(e) => { log::error!("venue code not registered: {e}"); return; }
} Try / catch
// Rust let venue = Venue::from_code(code).map_err(|e| ConfigError::BadVenue(e.to_string()))?;
Prevention
- Keep venue codes in a central constant list validated at config load
- Initialize/import all needed adapters before resolving venues from strings
- Use exact uppercase canonical codes; validate config at startup
When it happens
Trigger: Calling Venue::from_code("BINANCE") (or any string) before the corresponding venue has been registered into VENUE_MAP, or with a misspelled/unknown code such as wrong case or an unsupported exchange.
Common situations: Typo in venue config (e.g. "BINANCE-FUTURE" vs "BINANCE_FUTURES"), using an adapter venue without importing/initializing its adapter crate, case mismatch (lowercase input), or running a stripped build where the adapter never registered.
Related errors
- Invalid venue {}, expected Blockchain DEX format
- failed to allocate Lighter nonce: {e}
- failed to parse any of {input_len} Lighter instruments: {}
- {label} must not be empty
- {label} contains invalid characters (only alphanumeric and u
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/d8dc76954e38a480.
Report an issue: GitHub.