{"record":{"id":"7c462e0c56f4d7e0","repo":"nautechsystems/nautilus_trader","slug":"unrecognized-side-side","errorCode":null,"errorMessage":"unrecognized side '{side}'","messagePattern":"unrecognized side '(.+?)'","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/python/data.rs","lineNumber":93,"sourceCode":"    let mut reader = csv::Reader::from_path(file_path).with_context(|| {\n        format!(\n            \"failed to open Binance order book CSV {}\",\n            file_path.display(),\n        )\n    })?;\n\n    reader\n        .deserialize::<BinanceOrderBookDeltaCsvRow>()\n        .take(nrows.unwrap_or(usize::MAX))\n        .map(|row| map_row(&row?))\n        .collect()\n}\n\nfn map_row(row: &BinanceOrderBookDeltaCsvRow) -> anyhow::Result<BinanceOrderBookDeltaRow> {\n    let side = match row.side.to_ascii_lowercase().as_str() {\n        \"b\" => \"BUY\",\n        \"a\" => \"SELL\",\n        side => anyhow::bail!(\"unrecognized side '{side}'\"),\n    };\n    let is_snapshot = row.update_type == \"snap\";\n    let action = if is_snapshot {\n        \"ADD\"\n    } else if row.qty == 0.0 {\n        \"DELETE\"\n    } else {\n        \"UPDATE\"\n    };\n\n    Ok(BinanceOrderBookDeltaRow {\n        timestamp: row.timestamp,\n        instrument_id: format!(\"{}.BINANCE\", row.symbol),\n        action,\n        side,\n        price: row.price,\n        size: row.qty,\n        order_id: 0,","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/python/data.rs#L75-L111","documentation":"When loading Binance order-book delta CSV data, map_row normalizes the side column: 'b' maps to BUY and 'a' to SELL. Any other value in the side column cannot be translated to the internal enum, so loading the row fails with this message naming the offending raw value.","triggerScenarios":"Calling the CSV data loader (load_rows) on a Binance order-book delta CSV whose side column contains a value other than 'b' or 'a' (case-insensitive) — e.g. an empty field, a corrupted row, or a CSV from a different export format.","commonSituations":"Hand-edited or truncated download files; using a market/dataset whose CSV schema differs from the expected Binance depth-dump format (e.g. full 'buy'/'sell' words or numeric sides); mixing columns after custom preprocessing.","solutions":["Inspect the offending CSV row's side column and fix it to 'b' or 'a'","Validate/preprocess the CSV: drop or repair rows whose side is not b/a before loading","Confirm the file is an official Binance order-book depth dump (side column is b/a, update_type snap/update) and not another dataset format","If your Binance export uses different tokens, normalize them in a preprocessing pass (e.g. map 'buy'->'b') before handing the file to the loader"],"exampleFix":"// before\ndf = pd.read_csv(path)  # side column contains 'buy'/'sell'\n// after\ndf = pd.read_csv(path)\ndf[\"side\"] = df[\"side\"].str.lower().map({\"b\": \"b\", \"a\": \"a\", \"buy\": \"b\", \"sell\": \"a\"})\nassert df[\"side\"].isin([\"b\", \"a\"]).all(), df.loc[~df[\"side\"].isin([\"b\", \"a\"]), \"side\"].unique()","handlingStrategy":"validation","validationCode":"import csv\nwith open(path) as f:\n    bad = [row[\"side\"] for row in csv.DictReader(f) if row[\"side\"].strip().lower() not in (\"b\", \"a\")]\nassert not bad, f\"rows with invalid side: {bad[:5]}\"","typeGuard":"def is_valid_side(value: str) -> bool:\n    return value.strip().lower() in (\"b\", \"a\")","tryCatchPattern":"try:\n    rows = load_rows(path)\nexcept Exception as e:\n    if \"unrecognized side\" in str(e):\n        print(\"CSV side column invalid — clean/repair the file and retry\")\n    else:\n        raise","preventionTips":["Only feed official Binance order-book depth dumps to this loader (side is b/a, update_type is snap/update)","Validate the side column with a script before loading large files","Re-download files rather than hand-editing; check for truncated/corrupted downloads","Normalize variant formats (buy/sell) to b/a in a preprocessing pass"],"tags":["csv","parsing","validation","orderbook","data-loader"],"backgroundTag":"invalid-enum-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"}