nautechsystems/nautilus_trader · error · anyhow::Error
Invalid ticker format '{ticker}', base and quote cannot be e
Error message
Invalid ticker format '{ticker}', base and quote cannot be empty What it means
Validation in validate_ticker_format: the ticker split on '-' yields two parts but at least one is empty, meaning it is malformed like '-USD' or 'BTC-'. A valid dYdX ticker is BASE-QUOTE with both sides non-empty.
Source
Thrown at crates/adapters/dydx/src/http/parse.rs:158
Ok(Bar::new(
bar_type, open, high, low, close, volume, ts_event, ts_init,
))
}
/// Validates that a ticker has the correct format (BASE-QUOTE).
///
/// # Errors
///
/// Returns an error if the ticker is not in the format "BASE-QUOTE".
pub fn validate_ticker_format(ticker: &str) -> anyhow::Result<()> {
let parts: Vec<&str> = ticker.split('-').collect();
if parts.len() != 2 {
anyhow::bail!("Invalid ticker format '{ticker}', expected 'BASE-QUOTE' (e.g., 'BTC-USD')");
}
if parts[0].is_empty() || parts[1].is_empty() {
anyhow::bail!("Invalid ticker format '{ticker}', base and quote cannot be empty");
}
Ok(())
}
/// Parses base and quote currency codes from a ticker.
///
/// # Errors
///
/// Returns an error if the ticker format is invalid.
pub fn parse_ticker_currencies(ticker: &str) -> anyhow::Result<(&str, &str)> {
validate_ticker_format(ticker)?;
let parts: Vec<&str> = ticker.split('-').collect();
Ok((parts[0], parts[1]))
}
/// Returns true if the market status is Active.
#[must_use]
pub const fn is_market_active(status: &DydxMarketStatus) -> bool {View on GitHub (pinned to 18893faf8b)
Solutions
- Ensure both base and quote currency segments are non-empty before joining with `-`
- Trim and validate currency strings before formatting the ticker
Example fix
// before
let ticker = format!("{base}-USD"); // base was empty
// after
if base.is_empty() { anyhow::bail!("base currency is empty"); }
let ticker = format!("{base}-USD"); Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_ticker(t: &str) -> bool {
let parts: Vec<&str> = t.split('-').collect();
parts.len() == 2 && !parts[0].is_empty() && !parts[1].is_empty()
} Prevention
- Validate base/quote currency strings before formatting tickers
- Use typed Currency values rather than raw strings when composing tickers
When it happens
Trigger: Passing tickers like `"-USD"`, `"BTC-"`, or `"-"` to `parse_ticker_currencies`/`validate_ticker_format`.
Common situations: Mangled string slicing when composing tickers programmatically (e.g. dropping the base currency variable); template or env variables that expand to empty values.
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 ticker format '{ticker}', expected 'BASE-QUOTE' (e.g
- Stop buy trigger_price ({trigger_price}) must be >= limit pr
- Stop sell trigger_price ({trigger_price}) must be <= limit p
- Take profit buy trigger_price ({trigger_price}) must be <= l
- Limit order missing price
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/3e9b1befbb0ac79b.
Report an issue: GitHub.