{"record":{"id":"3e9b1befbb0ac79b","repo":"nautechsystems/nautilus_trader","slug":"invalid-ticker-format-ticker-base-and-quote-c","errorCode":null,"errorMessage":"Invalid ticker format '{ticker}', base and quote cannot be empty","messagePattern":"Invalid ticker format '(.+?)', base and quote cannot be empty","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/http/parse.rs","lineNumber":158,"sourceCode":"\n    Ok(Bar::new(\n        bar_type, open, high, low, close, volume, ts_event, ts_init,\n    ))\n}\n\n/// Validates that a ticker has the correct format (BASE-QUOTE).\n///\n/// # Errors\n///\n/// Returns an error if the ticker is not in the format \"BASE-QUOTE\".\npub fn validate_ticker_format(ticker: &str) -> anyhow::Result<()> {\n    let parts: Vec<&str> = ticker.split('-').collect();\n    if parts.len() != 2 {\n        anyhow::bail!(\"Invalid ticker format '{ticker}', expected 'BASE-QUOTE' (e.g., 'BTC-USD')\");\n    }\n\n    if parts[0].is_empty() || parts[1].is_empty() {\n        anyhow::bail!(\"Invalid ticker format '{ticker}', base and quote cannot be empty\");\n    }\n    Ok(())\n}\n\n/// Parses base and quote currency codes from a ticker.\n///\n/// # Errors\n///\n/// Returns an error if the ticker format is invalid.\npub fn parse_ticker_currencies(ticker: &str) -> anyhow::Result<(&str, &str)> {\n    validate_ticker_format(ticker)?;\n    let parts: Vec<&str> = ticker.split('-').collect();\n    Ok((parts[0], parts[1]))\n}\n\n/// Returns true if the market status is Active.\n#[must_use]\npub const fn is_market_active(status: &DydxMarketStatus) -> bool {","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/http/parse.rs#L140-L176","documentation":"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.","triggerScenarios":"Passing tickers like `\"-USD\"`, `\"BTC-\"`, or `\"-\"` to `parse_ticker_currencies`/`validate_ticker_format`.","commonSituations":"Mangled string slicing when composing tickers programmatically (e.g. dropping the base currency variable); template or env variables that expand to empty values.","solutions":["Ensure both base and quote currency segments are non-empty before joining with `-`","Trim and validate currency strings before formatting the ticker"],"exampleFix":"// before\nlet ticker = format!(\"{base}-USD\"); // base was empty\n// after\nif base.is_empty() { anyhow::bail!(\"base currency is empty\"); }\nlet ticker = format!(\"{base}-USD\");","handlingStrategy":"validation","validationCode":"fn is_valid_ticker(t: &str) -> bool {\n    let parts: Vec<&str> = t.split('-').collect();\n    parts.len() == 2 && !parts[0].is_empty() && !parts[1].is_empty()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate base/quote currency strings before formatting tickers","Use typed Currency values rather than raw strings when composing tickers"],"tags":["rust","dydx","ticker","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}