{"record":{"id":"424c46c76658129e","repo":"nautechsystems/nautilus_trader","slug":"close-position-cannot-be-combined-with-reduce-o","errorCode":null,"errorMessage":"`close_position` cannot be combined with `reduce_only` on Binance","messagePattern":"`close_position` cannot be combined with `reduce_only` on Binance","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/execution.rs","lineNumber":2557,"sourceCode":"            .params\n            .as_ref()\n            .and_then(|p| p.get_bool(\"close_position\"))\n            .unwrap_or(false);\n\n        if close_position {\n            let order_type = order.order_type();\n\n            if !matches!(\n                order_type,\n                OrderType::StopMarket | OrderType::MarketIfTouched\n            ) {\n                anyhow::bail!(\n                    \"`close_position` is not supported for order type {order_type:?} on Binance\"\n                );\n            }\n\n            if order.is_reduce_only() {\n                anyhow::bail!(\"`close_position` cannot be combined with `reduce_only` on Binance\");\n            }\n        }\n\n        if let Some(pm_str) = cmd.params.as_ref().and_then(|p| p.get_str(\"price_match\")) {\n            BinancePriceMatch::from_param(pm_str)?;\n            let order_type = order.order_type();\n            anyhow::ensure!(\n                !order.is_post_only(),\n                \"price_match cannot be combined with post-only orders\"\n            );\n            anyhow::ensure!(\n                order_type == OrderType::Limit,\n                \"price_match is not supported for order type {order_type:?}\"\n            );\n        }\n\n        let lifetime = determine_futures_order_lifetime(\n            self.product_type,","sourceCodeStart":2539,"sourceCodeEnd":2575,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/futures/execution.rs#L2539-L2575","documentation":"Binance Futures treats closePosition and reduceOnly as mutually exclusive: closePosition already implies closing the whole position, so combining them is rejected by the venue. The adapter validates this before submission and fails fast with this message.","triggerScenarios":"SubmitOrder where params has close_position=true and the order was built with reduce_only=true.","commonSituations":"Risk-management wrappers that mark every exit order reduce-only; ported strategies stacking protective flags on close orders.","solutions":["Set reduce_only=false when using close_position — the flag is redundant for a whole-position close","Or keep reduce_only and drop close_position, sizing the order to the position manually"],"exampleFix":"// before — both flags set\n// order: reduce_only = true; params: close_position = true\n\n// after — close_position implies the reduce\n// order: reduce_only = false; params: close_position = true","handlingStrategy":"validation","validationCode":"// Before submit_order()\nlet close_position = params.get_bool(\"close_position\").unwrap_or(false);\nif close_position {\n    assert!(!order.is_reduce_only(), \"close_position cannot combine with reduce_only\");\n}","typeGuard":"fn close_position_flags_valid(close_position: bool, reduce_only: bool) -> bool {\n    !(close_position && reduce_only)\n}","tryCatchPattern":"On this local rejection, rebuild the order with reduce_only=false (close_position already implies the reduce) and resubmit.","preventionTips":["Do not apply blanket reduce-only flags to exit orders in risk wrappers","Test flag combinations for exit orders before deployment","Keep exit-order parameter sets in one reviewed location"],"tags":["binance","futures","close-position","reduce-only","order-validation","rust"],"backgroundTag":"conflicting-order-parameters","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}