name: recipe-emergency-flatten version: 1.0.0 description: "Cancel all orders and close all positions in an emergency." metadata: openclaw: category: "recipe" domain: "risk" requires: bins: ["kraken"] skills: ["kraken-risk-operations", "kraken-liquidation-guard"]
Emergency Flatten
PREREQUISITE: Load the following skills to execute this recipe:
kraken-risk-operations,kraken-liquidation-guard
Immediately cancel all orders and close all positions across spot and futures.
CAUTION: This closes everything at market prices. Slippage may be significant. The
--yesflag skips confirmation prompts and is only appropriate at autonomy level 4+ (seekraken-autonomy-levels). At lower levels, omit--yesand confirm each cancel with the user.
Steps
- Cancel all spot orders (dangerous):
kraken order cancel-all --yes -o json 2>/dev/null - Cancel all futures orders (dangerous):
kraken futures cancel-all --yes -o json 2>/dev/null - Check spot positions:
kraken positions -o json 2>/dev/null - Close each spot margin position with a market order (requires human approval)
- Check futures positions and extract sizes:
kraken futures positions -o json 2>/dev/null(parse each position'ssizeandsidefields) - Close each futures position with reduce-only market orders (use
sellfor longs,buyfor shorts): e.g.,kraken futures order sell PF_XBTUSD 1 --reduce-only -o json 2>/dev/null - Verify no open orders remain:
kraken open-orders -o json 2>/dev/null - Verify no futures orders remain:
kraken futures open-orders -o json 2>/dev/null - Verify all positions closed:
kraken futures positions -o json 2>/dev/null - Check final balances:
kraken balance -o json 2>/dev/null