name: recipe-weekly-rebalance version: 1.0.0 description: "Run a weekly portfolio rebalance to maintain target asset allocations." metadata: openclaw: category: "recipe" domain: "portfolio" requires: bins: ["kraken"] skills: ["kraken-rebalancing"]
Weekly Rebalance
PREREQUISITE: Load the following skill to execute this recipe:
kraken-rebalancing
Check portfolio drift and rebalance to target weights once per week.
Steps
- Get balances:
kraken balance -o json 2>/dev/null - Get prices:
kraken ticker BTCUSD ETHUSD SOLUSD -o json 2>/dev/null - Calculate current weights (agent computes USD value per asset / total)
- Compare to targets (e.g., 50% BTC, 30% ETH, 20% SOL)
- If any asset drifts more than 5% from target, compute rebalance trades:
SELL_VOL=$(echo "scale=8; ($CURRENT_BTC_VALUE - $TARGET_BTC_VALUE) / $BTC_PRICE" | bc)andBUY_VOL=$(echo "scale=8; ($TARGET_SOL_VALUE - $CURRENT_SOL_VALUE) / $SOL_PRICE" | bc) - Present the rebalance plan to the user with estimated fees
- Validate sell orders:
kraken order sell BTCUSD $SELL_VOL --type market --validate -o json 2>/dev/null - Execute sells first (requires human approval):
kraken order sell BTCUSD $SELL_VOL --type market -o json 2>/dev/null - Execute buys with freed capital:
kraken order buy SOLUSD $BUY_VOL --type market -o json 2>/dev/null - Verify final allocations:
kraken balance -o json 2>/dev/null