{"record":{"id":"8c5e9ded5e7c060d","repo":"nautechsystems/nautilus_trader","slug":"position-side-long-conflicts-with-negative-positio","errorCode":null,"errorMessage":"position_side LONG conflicts with negative position_amt","messagePattern":"position_side LONG conflicts with negative position_amt","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/execution.rs","lineNumber":1025,"sourceCode":"\n        if position_amount.is_zero() {\n            anyhow::bail!(\"Position is flat\");\n        }\n\n        let entry_price: Decimal = position\n            .entry_price\n            .parse()\n            .context(\"invalid entry_price\")?;\n\n        let position_side = if position_amount > Decimal::ZERO {\n            PositionSide::Long\n        } else {\n            PositionSide::Short\n        };\n\n        if self.config.use_position_ids {\n            match position.position_side {\n                Some(BinancePositionSide::Long) => anyhow::ensure!(\n                    position_side == PositionSide::Long,\n                    \"position_side LONG conflicts with negative position_amt\"\n                ),\n                Some(BinancePositionSide::Short) => anyhow::ensure!(\n                    position_side == PositionSide::Short,\n                    \"position_side SHORT conflicts with positive position_amt\"\n                ),\n                _ => {}\n            }\n        }\n\n        let venue_position_id = make_venue_position_id(\n            self.config.use_position_ids,\n            instrument_id,\n            position.position_side,\n        )?;\n\n        if let Some(venue_position_id) = venue_position_id {","sourceCodeStart":1007,"sourceCodeEnd":1043,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/execution.rs#L1007-L1043","documentation":"During position-report reconciliation, the adapter derives a local PositionSide purely from the sign of Binance's position_amt (positive=Long, negative=Short). When use_position_ids=true and Binance's explicit positionSide field says LONG, the adapter requires the derived side to match; a mismatch means the position_amt sign contradicts the venue's declared hedge side, so the report would be internally inconsistent and is rejected.","triggerScenarios":"generate_order_status_reports -> generate_position_status_reports -> create_position_report with a BinancePositionRisk where position_side=Some(Long) but position_amt parses to a negative Decimal (or vice versa for 1841). Typically caused by stale/restored one-way-mode data or hedge-mode positions flipped without a corresponding amt sign change.","commonSituations":"Switching an account between one-way and hedge mode while old position snapshots are cached; running with use_position_ids=true (venue position identity mode) on an account whose positionSide metadata is inconsistent with the AMT sign after manual liquidation in the Binance UI; race during reconciliation where a position just crossed zero.","solutions":["Verify the account's position mode (one-way vs hedge) in Binance Futures settings and ensure it matches the adapter's configuration; reconcile after switching.","Set use_position_ids=false in the Binance Futures execution config to skip venue-position-ID validation (virtual hedging).","Re-pull fresh position risk data; a transient mid-close snapshot can produce sign/side disagreement.","If persisting, clear stale cached Nautilus positions for the instrument so reconciliation starts clean."],"exampleFix":"// config: skip venue position-ID identity checks\n// before\nBinanceFuturesExecClientConfig { use_position_ids: true, .. }\n// after\nBinanceFuturesExecClientConfig { use_position_ids: false, .. }","handlingStrategy":"validation","validationCode":"if cfg.use_position_ids {\n    let amt: Decimal = position.position_amt.parse()?;\n    if position.position_side == Some(BinancePositionSide::Long) && amt < Decimal::ZERO {\n        log::warn!(\"inconsistent LONG side with negative amt for {}\", position.symbol);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep Binance position mode (one-way/hedge) aligned with use_position_ids","Reconcile from fresh position risk snapshots, not cached ones","Avoid manual venue-side trades while the adapter runs"],"tags":["reconciliation","position-side","binance-futures","config"],"backgroundTag":"invalid-state-transition","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"}