{"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/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/python/data.rs#L75-L111","documentation":"The Python loader load_binance_order_book_deltas(file_path, nrows) expects Binance order book delta CSVs with columns symbol,timestamp,last_update_id,side,update_type,price,qty, where side must be 'b' or 'a' (compared case-insensitively). Any other value in the side column ('buy', 'sell', '', 'bid', garbage from shifted columns) raises this error while mapping rows.","triggerScenarios":"Calling nautilus_trader.adapters.binance load_binance_order_book_deltas on a CSV whose side column is not Binance's single-letter b/a format, e.g. an export from another exchange or a hand-written file using 'buy'/'sell'.","commonSituations":"Reusing data pipelines built for generic book CSVs; schema drift after re-export; files with extra or reordered columns putting wrong data into the side field.","solutions":["Re-export or transform the file so side contains only 'b' or 'a' (any case)","Preprocess the CSV: map buy->b, sell->a and reject empty values before loading","Verify the header and column order match the expected schema (symbol,timestamp,last_update_id,side,update_type,price,qty) and that update_type uses 'snap' for snapshots"],"exampleFix":"# before\ndf.to_csv(\"deltas.csv\")  # side column holds 'buy' / 'sell'\n\n# after\nside_map = {\"buy\": \"b\", \"sell\": \"a\", \"b\": \"b\", \"a\": \"a\"}\ndf[\"side\"] = df[\"side\"].str.strip().str.lower().map(side_map)\nassert df[\"side\"].isin([\"b\", \"a\"]).all(), \"unmapped side values remain\"\ndf.to_csv(\"deltas.csv\")","handlingStrategy":"validation","validationCode":"import pandas as pd\n\ndf = pd.read_csv(path)\nallowed = {\"b\", \"a\"}\nnormalized = df[\"side\"].str.strip().str.lower()\nassert normalized.isin(allowed).all(), (\n    f\"CSV has non-Binance side values: {set(normalized) - allowed}\"\n)","typeGuard":"def is_binance_side(value: str) -> bool:\n    return value.strip().lower() in {\"b\", \"a\"}","tryCatchPattern":null,"preventionTips":["Standardize exports to Binance b/a side codes before saving CSVs","Validate the side column distribution in a pre-pass before loading","Check header/column order matches the expected schema"],"tags":["csv","parsing","python","order-book","binance"],"backgroundTag":"csv-column-validation-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}