Agent Skillskrakenfx/kraken-cli › kraken-rebalancing

kraken-rebalancing

GitHub

用于Kraken加密货币投资组合再平衡的Agent技能,支持目标权重设定、当前持仓与价格获取、偏差计算、最小交易阈值过滤、模拟测试及实盘订单执行验证。

skills/kraken-rebalancing/SKILL.md krakenfx/kraken-cli

Trigger Scenarios

检查当前投资组合分配是否符合目标权重 计算需要执行的再平衡交易 执行带有最小交易阈值的再平衡订单 定期安排再平衡检查

Install

npx skills add krakenfx/kraken-cli --skill kraken-rebalancing -g -y
More Options

Use without installing

npx skills use krakenfx/kraken-cli@kraken-rebalancing

指定 Agent (Claude Code)

npx skills add krakenfx/kraken-cli --skill kraken-rebalancing -a claude-code -g -y

安装 repo 全部 skill

npx skills add krakenfx/kraken-cli --all -g -y

预览 repo 内 skill

npx skills add krakenfx/kraken-cli --list

SKILL.md

Frontmatter
{
    "name": "kraken-rebalancing",
    "version": "1.0.0",
    "metadata": {
        "openclaw": {
            "category": "finance"
        },
        "requires": {
            "bins": [
                "kraken"
            ]
        }
    },
    "description": "Portfolio rebalancing to maintain target allocations across assets."
}

kraken-rebalancing

Use this skill for:

  • checking current portfolio allocation vs target weights
  • calculating rebalance trades
  • executing rebalance orders with minimum trade thresholds
  • scheduling periodic rebalance checks

Define Target Allocation

Example target: 50% BTC, 30% ETH, 20% SOL (by USD value).

The agent maintains these weights and compares against current holdings.

Read Current Portfolio

  1. Get balances:
    kraken balance -o json 2>/dev/null
    
  2. Get current prices for all held assets:
    kraken ticker BTCUSD ETHUSD SOLUSD -o json 2>/dev/null
    
  3. Calculate USD value of each holding and total portfolio value.
  4. Compute current weights: asset_value / total_value for each.

Calculate Rebalance Trades

For each asset:

  • Target value = total_portfolio * target_weight
  • Current value = holdings * current_price
  • Delta = target_value - current_value
  • If delta > threshold: buy (delta / price) units
  • If delta < -threshold: sell (|delta| / price) units

Set a minimum trade threshold (e.g., $50) to avoid placing tiny orders that waste fees.

Paper Rebalance Test

kraken workspace create sandbox --capital 10000 --mode paper -o json 2>/dev/null
export KRAKEN_WORKSPACE=sandbox

# Initial buys to establish positions
kraken paper buy BTCUSD 0.05 -o json 2>/dev/null
kraken paper buy ETHUSD 1.0 -o json 2>/dev/null
kraken paper buy SOLUSD 10 -o json 2>/dev/null

kraken workspace status -o json 2>/dev/null

# After price drift, rebalance
# Sell overweight asset, buy underweight asset
kraken paper sell BTCUSD 0.005 -o json 2>/dev/null
kraken paper buy SOLUSD 2 -o json 2>/dev/null

kraken workspace status -o json 2>/dev/null

Live Rebalance Execution

  1. Calculate all required trades.
  2. Present the rebalance plan to the user:
    • Current allocation vs target
    • Proposed trades with estimated fees
  3. Validate each order:
    kraken order sell BTCUSD 0.005 --type market --validate -o json 2>/dev/null
    kraken order buy SOLUSD 2 --type market --validate -o json 2>/dev/null
    
  4. Execute sells first (to free capital), then buys (requires human approval):
    kraken order sell BTCUSD 0.005 --type market -o json 2>/dev/null
    kraken order buy SOLUSD 2 --type market -o json 2>/dev/null
    
  5. Verify final state:
    kraken balance -o json 2>/dev/null
    

Drift Detection

Periodically compare current weights to targets. Trigger rebalance when any asset drifts beyond a threshold (e.g., 5% absolute drift):

# Agent checks balance and prices on a schedule
# If |current_weight - target_weight| > 0.05 for any asset → rebalance

Rebalance with Limit Orders

For lower fees, use limit orders instead of market:

PRICE=$(kraken ticker SOLUSD -o json 2>/dev/null | jq -r '.[].ask_price')
kraken order buy SOLUSD 2 --type limit --price $PRICE -o json 2>/dev/null

Check fills before declaring rebalance complete:

kraken open-orders -o json 2>/dev/null

Hard Rules

  • Never execute rebalance trades without explicit human approval.
  • Always present the full rebalance plan (sells and buys) before execution.
  • Execute sells before buys to ensure sufficient quote currency.
  • Respect minimum order sizes for each pair (check pair info with kraken pairs).
  • Apply a minimum trade threshold to skip negligible adjustments.
  • 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.

Version History

  • aa56e59 Current 2026-08-20 04:45
  • aa32814 2026-07-25 10:28

Same Skill Collection

skills/kraken-alert-patterns/SKILL.md
skills/kraken-autonomy-levels/SKILL.md
skills/kraken-basis-trading/SKILL.md
skills/kraken-dca-strategy/SKILL.md
skills/kraken-earn-staking/SKILL.md
skills/kraken-error-recovery/SKILL.md
skills/kraken-fee-optimization/SKILL.md
skills/kraken-funding-carry/SKILL.md
skills/kraken-funding-ops/SKILL.md
skills/kraken-futures-risk/SKILL.md
skills/kraken-grid-trading/SKILL.md
skills/kraken-lab-experiment/SKILL.md
skills/kraken-liquidation-guard/SKILL.md
skills/kraken-market-intel/SKILL.md
skills/kraken-mcp-integration/SKILL.md
skills/kraken-multi-pair/SKILL.md
skills/kraken-order-types/SKILL.md
skills/kraken-paper-strategy/SKILL.md
skills/kraken-paper-to-live/SKILL.md
skills/kraken-playground/SKILL.md
skills/kraken-portfolio-intel/SKILL.md
skills/kraken-rate-limits/SKILL.md
skills/kraken-risk-operations/SKILL.md
skills/kraken-setup/SKILL.md
skills/kraken-spot-execution/SKILL.md
skills/kraken-stop-take-profit/SKILL.md
skills/kraken-subaccount-ops/SKILL.md
skills/kraken-tax-export/SKILL.md
skills/kraken-twap-execution/SKILL.md
skills/kraken-ws-streaming/SKILL.md
skills/recipe-basis-trade-entry/SKILL.md
skills/recipe-daily-pnl-report/SKILL.md
skills/recipe-drawdown-circuit-breaker/SKILL.md
skills/recipe-earn-yield-compare/SKILL.md
skills/recipe-emergency-flatten/SKILL.md
skills/recipe-fee-tier-progress/SKILL.md
skills/recipe-funding-rate-scan/SKILL.md
skills/recipe-futures-hedge-spot/SKILL.md
skills/recipe-launch-grid-bot/SKILL.md
skills/recipe-morning-market-brief/SKILL.md
skills/recipe-multi-pair-breakout-watch/SKILL.md
skills/recipe-paper-strategy-backtest/SKILL.md
skills/recipe-playground-dca-triggered/SKILL.md
skills/recipe-playground-dca/SKILL.md
skills/recipe-playground-price-alert/SKILL.md
skills/recipe-playground-rebalance/SKILL.md
skills/recipe-playground-webhook/SKILL.md
skills/recipe-portfolio-snapshot-csv/SKILL.md
skills/recipe-price-level-alerts/SKILL.md

Metadata

Files
0
Version
aa56e59
Hash
1eb2f1ff
Indexed
2026-07-25 10:28

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-20 23:07
浙ICP备14020137号-1 $방문자$