---
name: kraken-liquidation-guard-6915425384a5
version: 1.0.0
description: "Prevent futures liquidation through margin monitoring and emergency procedures."
metadata:
  openclaw:
    category: "finance"
  requires:
    bins: ["kraken"]
    skills: ["kraken-futures-risk"]
---

# 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

```bash
kraken futures accounts -o json 2>/dev/null
```

Key fields:
- `equity`: total account value
- `initialMargin`: margin held for positions
- `maintenanceMargin`: minimum margin before liquidation
- `availableFunds`: free margin for new positions

Margin ratio = maintenanceMargin / equity. Liquidation approaches as this ratio nears 1.0.

## 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

```bash
kraken futures ws balances -o json 2>/dev/null | while read -r line; do
  # Parse equity and maintenanceMargin
  # Calculate ratio
  # Alert or act when threshold is breached
done
```

Or poll periodically:

```bash
kraken futures accounts -o json 2>/dev/null
```

## Unwind Queue Check

If a position enters the unwind queue, liquidation is imminent:

```bash
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:

```bash
# 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> --reduce-only -o json 2>/dev/null
```

## Margin Top-Up

Transfer funds from spot wallet to futures to increase margin:

```bash
kraken futures transfer 5000 USD -o json 2>/dev/null
```

Or from main account:

```bash
kraken wallet-transfer USD 5000 --from <SPOT_IIBAN> --to <FUTURES_IIBAN> -o json 2>/dev/null
```

## Leverage Reduction

Lower leverage to reduce margin requirements:

```bash
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:

```bash
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+.
- Never increase position size when margin ratio is above 0.3.
- `futures set-leverage` is 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`.


---
Source attribution: jiayaoqijia
Original project: https://github.com/jiayaoqijia/cryptoskill/blob/bcc0d208deaa4f1f80aa0df7ca26c4bed6318918/skills/exchanges/kraken-official-liquidation-guard/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) Payward, Inc. (Kraken)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: jiayaoqijia
Original project: https://github.com/jiayaoqijia/cryptoskill/blob/bcc0d208deaa4f1f80aa0df7ca26c4bed6318918/skills/exchanges/kraken-official-liquidation-guard/SKILL.md
Attribution basis: Source repository record

Fields of work: Finance & Accounting
Roles: Accountant, CFO / FP&A, Financial Analyst
Specialties: API
Tools: Kraken
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: a6834984e23b2ada105d71628a7bfbeed6340006bea7664bcb20e18ef6b4523e
