kraken-liquidation-guard
Prevent futures liquidation through margin monitoring and emergency procedures.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- kraken-liquidation-guard
- version
- 1.0.0
- metadata
- { "openclaw": { "category": "finance" }, "requires": { "bins": [ "kraken" ], "skills": [ "kraken-futures-risk" ] } }
- description
- Prevent futures liquidation through margin monitoring and emergency procedures.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md171 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
kraken-liquidation-guard
Use this skill for:
- monitoring margin ratio to detect liquidation risk
- automated position reduction when thresholds are breached
- emergency flatten procedures
- proactive margin top-up patterns
Margin Health Check
kraken futures accounts -o json 2>/dev/null
Key fields of the multi-collateral account, under .accounts.flex:
marginEquity: account value that counts as margin, unrealized P&L includedinitialMargin: margin held for positionsmaintenanceMargin: minimum margin before liquidationavailableMargin: free margin for new positions
Margin ratio = .accounts.flex.maintenanceMargin / .accounts.flex.marginEquity. Liquidation approaches as this ratio nears 1.0. A single-collateral account (.accounts.fi_*) reports maintenance margin, portfolio value and available funds as marginRequirements.mm, auxiliary.pv and auxiliary.af.
Alert Thresholds
| Ratio | Status | Action |
|---|---|---|
| < 0.3 | Healthy | Normal operation |
| 0.3 - 0.5 | Caution | Reduce position or add margin |
| 0.5 - 0.7 | Warning | Reduce position immediately |
| > 0.7 | Critical | Emergency flatten |
Monitoring Loop
kraken futures ws balances -o json 2>/dev/null | while read -r line; do
# Read margin equity and maintenance margin from the frame
# Calculate ratio
# Alert or act when threshold is breached
done
Or poll periodically:
kraken futures accounts -o json 2>/dev/null
Unwind Queue Check
If a position enters the unwind queue, liquidation is imminent:
kraken futures unwind-queue -o json 2>/dev/null
Any result here requires immediate action.
Emergency Flatten
Cancel all open orders, then close all positions:
# Cancel all orders to free held margin
kraken futures cancel-all --yes -o json 2>/dev/null
# Close each position with reduce-only market orders
kraken futures positions -o json 2>/dev/null
# For each position:
kraken futures order sell PF_XBTUSD <SIZE> --type market --reduce-only -o json 2>/dev/null
Margin Top-Up
Transfer funds from spot wallet to futures to increase margin:
kraken futures transfer 5000 USD -o json 2>/dev/null
Or from main account:
kraken wallet-transfer USD 5000 --from <SPOT_IIBAN> --to <FUTURES_IIBAN> -o json 2>/dev/null
Leverage Reduction
Lower leverage to reduce margin requirements:
kraken futures set-leverage PF_XBTUSD 2 -o json 2>/dev/null
Dead Man's Switch
Always run a dead man's switch during futures sessions:
kraken futures cancel-after 600 -o json 2>/dev/null
If the agent crashes, orders auto-cancel, preventing further margin consumption.
Hard Rules
- Monitor margin ratio continuously during any futures session.
- Alert at 0.5 ratio; act at 0.7. Do not wait for the exchange to liquidate.
- Emergency flatten requires human approval unless the agent operates at autonomy level 4+.
- Margin top-ups move funds:
futures transferandwallet-transferare flagged dangerous and need human approval. - Never increase position size when margin ratio is above 0.3.
futures set-leverageis flagged dangerous: it changes the margin requirement on open positions, so de-risking with it needs the same human approval as flattening.- If you hit a mismatch between what you are trying to do and the CLI's interface or responses — including a mismatch between this skill and the installed CLI version's contract — feel free to submit feedback with
kraken feedback.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.