kraken-liquidation-guard

Prevent futures liquidation through margin monitoring and emergency procedures.

23 stars

Best use case

kraken-liquidation-guard is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Prevent futures liquidation through margin monitoring and emergency procedures.

Teams using kraken-liquidation-guard should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/kraken-official-liquidation-guard/SKILL.md --create-dirs "https://raw.githubusercontent.com/jiayaoqijia/cryptoskill/main/skills/exchanges/kraken-official-liquidation-guard/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/kraken-official-liquidation-guard/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How kraken-liquidation-guard Compares

Feature / Agentkraken-liquidation-guardStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Prevent futures liquidation through margin monitoring and emergency procedures.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

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

Related Skills

Kraken Crypto Skill

23
from jiayaoqijia/cryptoskill

Use the kraken_cli.py wrapper to query your Kraken account.

openclaw_kraken

23
from jiayaoqijia/cryptoskill

Use a Bash CLI to query Kraken Spot and Futures APIs, inspect account state, run guarded trading and funding actions, and work with Kraken websocket payloads using OpenClaw-managed secrets.

kraken-ws-streaming

23
from jiayaoqijia/cryptoskill

Real-time data streaming via WebSocket for spot and futures.

kraken-twap-execution

23
from jiayaoqijia/cryptoskill

Execute large orders as time-weighted slices to reduce market impact.

kraken-tax-export

23
from jiayaoqijia/cryptoskill

Export trade history, ledgers, and cost basis data for tax reporting.

kraken-subaccount-ops

23
from jiayaoqijia/cryptoskill

Create and manage subaccounts with inter-account transfers.

kraken-stop-take-profit

23
from jiayaoqijia/cryptoskill

Manage stop-loss and take-profit orders for risk-bounded positions.

kraken-spot-execution

23
from jiayaoqijia/cryptoskill

Execute spot orders with validation, confirmation gates, and post-trade checks.

kraken-shared

23
from jiayaoqijia/cryptoskill

Shared runtime contract for kraken-cli: auth, invocation, parsing, and safety.

kraken-risk-operations

23
from jiayaoqijia/cryptoskill

Operational risk controls for live agent trading sessions.

kraken-rebalancing

23
from jiayaoqijia/cryptoskill

Portfolio rebalancing to maintain target allocations across assets.

kraken-rate-limits

23
from jiayaoqijia/cryptoskill

Understand Kraken API rate limits and adapt agent behavior when limits are hit.