{"record":{"id":"69ed1dc450ff64f0","repo":"nautechsystems/nautilus_trader","slug":"leverage-requires-spot-account-type-margin-curren","errorCode":null,"errorMessage":"leverage requires spot_account_type=Margin (current: Cash)","messagePattern":"leverage requires spot_account_type=Margin \\(current: Cash\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/kraken/src/http/spot/client.rs","lineNumber":3141,"sourceCode":"\n        if let Some(tif) = timeinforce {\n            builder.timeinforce(tif);\n        }\n\n        if let Some(expire) = expiretm {\n            builder.expiretm(expire);\n        }\n\n        if let Some(dq) = display_qty {\n            builder.displayvol(dq.to_string());\n        }\n\n        if let Some(ac) = asset_class {\n            builder.asset_class(ac);\n        }\n\n        if leverage.is_some() && account_type != AccountType::Margin {\n            anyhow::bail!(\"leverage requires spot_account_type=Margin (current: Cash)\");\n        }\n\n        if let Some(n) = leverage {\n            let tiers = self.leverage_tiers_cache.get_cloned(&raw_symbol);\n            let (buy_tiers, sell_tiers) = tiers.ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Leverage tiers not loaded for {raw_symbol}; cannot validate leverage {n}:1 (instruments must be initialized before submitting margin orders)\"\n                )\n            })?;\n            let valid_tiers = match order_side {\n                OrderSide::Buy => buy_tiers,\n                _ => sell_tiers,\n            };\n            let side_label = match order_side {\n                OrderSide::Buy => \"buy\",\n                _ => \"sell\",\n            };\n","sourceCodeStart":3123,"sourceCodeEnd":3159,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/kraken/src/http/spot/client.rs#L3123-L3159","documentation":"Leverage on Kraken Spot is only available on margin accounts. The adapter checks the configured spot account type before applying leverage and fails fast when the account is a Cash account, because Kraken's API would otherwise reject or misinterpret the leverage field.","triggerScenarios":"Submitting a Kraken Spot order with leverage set to Some(n) while the client is configured with spot_account_type = AccountType::Cash.","commonSituations":"Default account configuration left as Cash while running a strategy that trades with leverage; switching strategies from a margin account to a cash account without removing leverage parameters.","solutions":["Reconfigure the client with spot_account_type = AccountType::Margin.","Remove the leverage parameter from the order request if cash trading is intended.","Verify the Kraken account actually has margin enabled, since the account type in config must match the real Kraken account."],"exampleFix":"// before\nspot_account_type: AccountType::Cash, leverage: Some(3)\n// after\nspot_account_type: AccountType::Margin, leverage: Some(3)","handlingStrategy":"validation","validationCode":"if leverage.is_some() && account_config.spot_account_type != AccountType::Margin {\n    return Err(\"leverage requested but account is Cash; use Margin or drop leverage\");\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = client.submit_order(req) {\n    if e.to_string().contains(\"requires spot_account_type=Margin\") {\n        // reconfigure to Margin or resubmit without leverage\n    }\n}","preventionTips":["Keep spot_account_type in config in sync with the actual Kraken account.","Assert at strategy startup that margin config matches order intents.","Fail fast at config load if leverage is configured for a Cash account."],"tags":["kraken","spot","leverage","margin","configuration"],"backgroundTag":"invalid-config-value","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"}