Maintain portfolio allocations over time using calendar-based, threshold-based, and tax-efficient rebalancing strategies. Use when the user asks about when to rebalance, rebalancing bands, transaction cost trade-offs, tax-efficient rebalancing, or the rebalancing premium. Also trigger when users mention 'my portfolio drifted', 'how often should I rebalance', 'rebalancing across taxable and IRA accounts', 'volatility harvesting', 'buy low sell high automatically', or ask whether to use cash flows to rebalance.
npx skills add https://github.com/JoelLewis/finance_skills --skill rebalancing
Rebalance at fixed time intervals regardless of drift magnitude:
Calendar rebalancing is simple to implement and schedule but may miss large dislocations between dates or trigger unnecessary trades when drift is minimal.
Rebalance when any asset weight drifts beyond a defined tolerance band around its target:
Threshold rebalancing is more responsive to market dislocations and avoids unnecessary trades when markets are calm. However, it requires more frequent monitoring.
Leland (2000) derived the optimal no-trade band width as a function of transaction costs, risk aversion, and asset variance:
Band width proportional to (3 * transaction_cost / (2 * risk_aversion * variance))^(1/3)
Key intuition:
Systematic rebalancing generates a "volatility harvesting" or "rebalancing premium" through the buy-low/sell-high mechanism:
This effect is sometimes called Shannon's Demon: in a two-asset portfolio with equal expected returns but independent volatility, the constantly rebalanced portfolio outperforms buy-and-hold. The rebalancing premium is larger when:
Note: The rebalancing premium is not a free lunch — it underperforms in trending markets where winners keep winning.
Costs incurred when rebalancing that reduce net returns:
Total implementation cost = commissions + half-spread + market impact + opportunity cost
Strategies to minimize tax impact when rebalancing in taxable accounts:
Rebalancing and TLH should be planned together, not as separate trade lists:
Tax benefit = Realized loss * Marginal tax rate. For the 61-day wash-sale window, the $3,000 ordinary-income offset, replacement selection, and full TLH mechanics, see the tax-loss-harvesting skill.
When an investor has multiple account types (taxable, IRA, 401k), optimize rebalancing by:
Factors that determine optimal band width:
Use regular deposits or withdrawals to move toward target weights without explicit rebalancing trades:
The concepts above describe the *what* and *why* of rebalancing. This section covers the operational *how* — the step-by-step process an advisor follows to execute a rebalance for a client household.
Step 1: Aggregate Household View
Assemble the complete picture across all accounts (taxable brokerage, Traditional IRA, Roth IRA, 401(k), 529, trust). Calculate the household-level allocation by summing positions across all accounts, not just individual account allocations. Many drift problems are invisible at the account level but obvious at the household level.
Step 2: Asset Location Review
Before proposing trades, document which account types hold which asset classes:
If asset location is suboptimal, the rebalance is an opportunity to improve it — but only if the tax cost of repositioning is justified by the long-term tax savings.
Step 3: Drift Analysis and Trade Generation
For each asset class, calculate drift from target and compare against tolerance bands (from the IPS or firm default):
Step 4: Tax-Impact Estimation
For each proposed sell trade in a taxable account, estimate the tax consequence:
Step 5: Cross-Account Optimization
Minimize total household tax impact by choosing *where* to execute each trade:
Step 6: Before/After Comparison
Generate a before/after allocation comparison for advisor review and client communication:
This comparison serves as both a decision tool (does the rebalance justify its costs?) and a compliance artifact (documenting the rationale for the trades).
Step 7: Execution and Confirmation
| Formula | Expression | Use Case |
|---------|-----------|----------|
| Threshold Trigger | |w_actual - w_target| > tolerance | Rebalancing trigger condition |
| Optimal Band Width | band ~ (3*tc / (2*lambda*sigma^2))^(1/3) | Leland optimal no-trade zone |
| Tax-Loss Benefit | Benefit = Loss * Tax Rate | Value of harvested losses |
| Transaction Cost | TC = commission + spread/2 + impact | Total rebalancing cost |
| Drift | Drift_i = w_actual_i - w_target_i | Weight deviation from target |
| Trade Size | Trade_i = (w_target_i - w_actual_i) * Portfolio Value | Dollar amount to trade |
| Rebalancing Premium | RP ~ (1/2) * Σ w_i * sigma_i^2 - (1/2) * sigma_p^2 | Volatility harvesting estimate |
Given:
Calculate: Rebalancing trigger and required trades
Solution:
Check drift:
Target dollar amounts:
Required trades:
Proceeds from equity sales fund the bond purchases. In a taxable account, check the cost basis of equity lots being sold to estimate tax impact before executing.
Given:
Calculate: Tax benefit of harvesting the loss
Solution:
Realized loss from sale: $10,000
Tax benefit calculation:
If the investor had no capital gains to offset:
Implementation:
Note: TLH creates a lower cost basis in the replacement security, so taxes are deferred, not eliminated. However, the time value of the tax deferral and the ability to offset gains at favorable rates makes TLH valuable.
Run with uv run scripts/rebalancing.py (the PEP 723 header resolves dependencies automatically) or with python3 scripts/rebalancing.py after pip install numpy scipy. The bare run prints a demo covering drift analysis, threshold checks, trade generation, cash flow rebalancing, transaction costs, tax-aware lot selection, Leland bands, and the rebalancing premium. Pass --verify to assert the demo outputs match this skill's worked examples (prints PASS/FAIL), or --help for an overview of the available classes. The file is primarily meant to be imported as a module (e.g., from rebalancing import DriftAnalyzer, TradeGenerator, TaxAwareLotSelector).
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.
Intelligently organizes your files and folders across your computer by understanding context, finding duplicates, suggesting better structures, and automating cleanup tasks. Reduces cognitive load and keeps your digital workspace tidy without manual effort.
Generates creative domain name ideas for your project and checks availability across multiple TLDs (.com, .io, .dev, .ai, etc.). Saves hours of brainstorming and manual checking.
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Implements Manus-style file-based planning for complex tasks. Creates task_plan.md, findings.md, and progress.md. Use when starting complex multi-step tasks, research projects, or any task requiring >5 tool calls.
Creative research ideation and exploration. Use for open-ended brainstorming sessions, exploring interdisciplinary connections, challenging assumptions, or identifying research gaps. Best for early-stage research planning when you do not have specific observations yet. For formulating testable hypotheses from data use hypothesis-generation.
Comprehensive GitHub project management with swarm-coordinated issue tracking, project board automation, and sprint planning
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
Take joellewis/rebalancing from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference pip.
Without those the skill loads but fails at the first command.