Logo: Rebalancing

Rebalancing

Communautéit
JoelLewis
rebalancing

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.

Iwwersiicht

EditeurJoelLewis
Repositoryfinance_skills
Skill-Nummrebalancing
Stären
217
Forks
37
Matgeliwwert Dateien
1
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 1 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    JoelLewis huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Rebalancing an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vu GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
    https://github.com/JoelLewis/finance_skills/tree/main/plugins/wealth-management/skills/rebalancing
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill derbäisetzen → Iwwer eng GitHub-URL. Pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an d'Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/JoelLewis/finance_skills.git /tmp/finance_skills
mkdir -p .claude/skills
cp -r /tmp/finance_skills/plugins/wealth-management/skills/rebalancing .claude/skills/rebalancing
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Rebalancing an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Rebalancing automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Rebalancing net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Rebalancing

Core Concepts

Calendar Rebalancing

Rebalance at fixed time intervals regardless of drift magnitude:

  • Monthly: Tightest tracking to targets; highest transaction costs
  • Quarterly: Common institutional frequency; good balance of tracking and costs
  • Annually: Lowest cost; may allow significant drift between dates

Calendar rebalancing is simple to implement and schedule but may miss large dislocations between dates or trigger unnecessary trades when drift is minimal.

Threshold (Band) Rebalancing

Rebalance when any asset weight drifts beyond a defined tolerance band around its target:

  • Monitor weights continuously (or at regular intervals)
  • Trigger rebalancing when |w_actual - w_target| > tolerance
  • Typical bands: +/- 3% to +/- 5% (absolute) or +/- 20% to +/- 25% (relative)

Threshold rebalancing is more responsive to market dislocations and avoids unnecessary trades when markets are calm. However, it requires more frequent monitoring.

Optimal Band Width (Leland Model)

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:

  • Higher transaction costs → wider bands (trade less)
  • Higher risk aversion → narrower bands (maintain target more tightly)
  • Higher variance → narrower bands (drift happens faster, risk of deviation is greater)

Rebalancing Premium

Systematic rebalancing generates a "volatility harvesting" or "rebalancing premium" through the buy-low/sell-high mechanism:

  • When an asset rises, its weight increases → rebalancing sells some (sell high)
  • When an asset falls, its weight decreases → rebalancing buys some (buy low)

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:

  • Asset volatilities are higher
  • Correlations are lower
  • Assets have similar expected returns (so mean-reversion dominates trends)

Note: The rebalancing premium is not a free lunch — it underperforms in trending markets where winners keep winning.

Transaction Costs

Costs incurred when rebalancing that reduce net returns:

  • Commissions: Per-trade or per-share fees (increasingly zero for retail)
  • Bid-ask spread: The cost of crossing the spread; wider for less liquid assets
  • Market impact: Price movement caused by the trade itself; significant for large positions in less liquid markets
  • Opportunity cost: Delay cost if rebalancing is deferred to avoid transaction costs

Total implementation cost = commissions + half-spread + market impact + opportunity cost

Tax-Efficient Rebalancing

Strategies to minimize tax impact when rebalancing in taxable accounts:

  1. Use cash flows: Direct new contributions to underweight assets and withdrawals from overweight assets
  2. Redirect dividends and interest: Reinvest income from overweight assets into underweight assets
  3. Rebalance with new contributions: The most tax-efficient method — no selling required
  4. Asset location: Hold tax-inefficient assets (bonds, REITs) in tax-deferred accounts; rebalance these freely
  5. Selective lot identification: When selling, choose tax lots with the highest cost basis (lowest gain) or lots held over one year (long-term capital gains rate)

Coordinating with Tax-Loss Harvesting (TLH)

Rebalancing and TLH should be planned together, not as separate trade lists:

  • Combine TLH sells with rebalance sells to reduce total trade count and transaction costs
  • An overweight position sitting at a loss is the ideal dual-purpose trade — the harvest and the rebalance are the same sell
  • Check open wash-sale windows before buying back or before rebalance buys in any account (including IRAs and spouse accounts)

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.

Rebalancing Across Account Types

When an investor has multiple account types (taxable, IRA, 401k), optimize rebalancing by:

  • Tax-deferred accounts (IRA, 401k): Rebalance freely — no tax consequences
  • Taxable accounts: Minimize selling; use cash flows, TLH, and selective lot sales
  • Cross-account rebalancing: Consider the aggregate portfolio across all accounts and rebalance within the most tax-efficient account

Drift Tolerance Setting

Factors that determine optimal band width:

  • Tighter bands (e.g., +/- 2%): Better risk control, higher costs, appropriate for low-cost/institutional settings
  • Wider bands (e.g., +/- 10%): Lower costs, more drift risk, appropriate for taxable accounts with high tax impact
  • Asset-specific bands: More volatile assets may need wider absolute bands but tighter relative bands

Cash Flow Rebalancing

Use regular deposits or withdrawals to move toward target weights without explicit rebalancing trades:

  • Calculate current vs. target weights
  • Direct 100% of new contributions to the most underweight asset(s)
  • Process withdrawals from the most overweight asset(s)
  • This "natural rebalancing" is the most cost-effective and tax-efficient approach

Rebalancing Workflow

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:

  • Tax-inefficient assets (bonds, REITs, high-turnover funds) should be in tax-deferred accounts
  • Tax-efficient assets (index equity ETFs, municipal bonds) should be in taxable accounts
  • Highest-growth assets should be in Roth accounts (permanent tax-free growth)

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):

  • Generate a preliminary trade list: sell overweight positions, buy underweight positions
  • Prioritize trades by drift magnitude — address the largest deviations first
  • Check whether cash flows (pending contributions, withdrawals, dividends) can partially or fully close the drift without explicit trades

Step 4: Tax-Impact Estimation For each proposed sell trade in a taxable account, estimate the tax consequence:

  • Identify available tax lots and their holding periods (short-term vs long-term)
  • Calculate the estimated capital gain or loss for each lot using specific identification (HIFO preferred)
  • Sum the estimated tax liability across all proposed sells
  • Compare the tax cost against the risk-reduction benefit of rebalancing — defer trades where tax cost outweighs the tracking error reduction
  • Coordinate with any pending tax-loss harvesting opportunities (see tax-loss-harvesting skill)

Step 5: Cross-Account Optimization Minimize total household tax impact by choosing where to execute each trade:

  • Execute sells of appreciated positions in tax-deferred accounts when possible (no tax consequence)
  • Execute sells of depreciated positions in taxable accounts (harvest the loss)
  • Use cross-account rebalancing: if equities are overweight in the taxable account and underweight in the IRA, sell equities in the IRA and buy bonds in the IRA, rather than selling equities in the taxable account
  • Check for wash-sale conflicts: if harvesting a loss in the taxable account, ensure no purchase of a substantially identical security occurs within 30 days in any account (including IRA, 401(k), and spouse accounts)

Step 6: Before/After Comparison Generate a before/after allocation comparison for advisor review and client communication:

  • Current allocation vs target allocation vs post-rebalance allocation (three columns)
  • Estimated transaction costs (commissions, spreads)
  • Estimated tax impact (net gains/losses realized)
  • Expected tracking error reduction
  • Number of trades and accounts affected

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

  • Submit the approved trade list through the order management system
  • For block trades across multiple accounts, ensure fair allocation per the firm's allocation policy
  • Confirm fills and reconcile actual vs intended post-rebalance weights
  • Document the rebalance event: date, reason (scheduled, threshold trigger, or ad-hoc), trades executed, and resulting allocation

Key Formulas

FormulaExpressionUse Case
Threshold Triggerw_actual - w_target
Optimal Band Widthband ~ (3tc / (2lambda*sigma^2))^(1/3)Leland optimal no-trade zone
Tax-Loss BenefitBenefit = Loss * Tax RateValue of harvested losses
Transaction CostTC = commission + spread/2 + impactTotal rebalancing cost
DriftDrift_i = w_actual_i - w_target_iWeight deviation from target
Trade SizeTrade_i = (w_target_i - w_actual_i) * Portfolio ValueDollar amount to trade
Rebalancing PremiumRP ~ (1/2) * Σ w_i * sigma_i^2 - (1/2) * sigma_p^2Volatility harvesting estimate

Worked Examples

Example 1: Threshold Rebalancing — 60/40 Portfolio

Given:

  • Target: 60% equity / 40% bonds
  • Rebalancing threshold: +/- 5% (absolute)
  • Current portfolio value: $1,000,000
  • After market movement: equity = $680,000 (68%), bonds = $320,000 (32%)

Calculate: Rebalancing trigger and required trades

Solution:

Check drift:

  • Equity drift: 68% - 60% = +8% → exceeds +5% threshold → TRIGGER
  • Bond drift: 32% - 40% = -8% → exceeds -5% threshold → TRIGGER

Target dollar amounts:

  • Equity target: 60% * $1,000,000 = $600,000
  • Bond target: 40% * $1,000,000 = $400,000

Required trades:

  • Sell equity: $680,000 - $600,000 = $80,000
  • Buy bonds: $400,000 - $320,000 = $80,000

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.

Example 2: Tax-Loss Harvesting Benefit

Given:

  • Position purchased for $50,000, current value $40,000
  • Unrealized loss: $10,000
  • Investor's marginal federal tax rate: 37% (ordinary income) / 20% (long-term capital gains)
  • Investor has $15,000 in realized capital gains this year

Calculate: Tax benefit of harvesting the loss

Solution:

Realized loss from sale: $10,000

Tax benefit calculation:

  • The $10,000 loss offsets $10,000 of the $15,000 in realized capital gains
  • Tax saved: $10,000 * 20% = $2,000 (assuming long-term gains rate)
  • Remaining gains: $15,000 - $10,000 = $5,000 (still taxable)

If the investor had no capital gains to offset:

  • First $3,000 offsets ordinary income: $3,000 * 37% = $1,110
  • Remaining $7,000 carries forward to future years
  • Total immediate benefit: $1,110; total eventual benefit up to $2,000+ depending on future gains

Implementation:

  1. Sell the losing position for $40,000
  2. Immediately purchase a similar but not substantially identical replacement (e.g., swap a total US stock ETF for an S&P 500 ETF)
  3. Do NOT repurchase the original security within 30 days (wash sale rule)
  4. After 31 days, may swap back to original security if preferred

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.

Common Pitfalls

  • Over-rebalancing: trading too frequently erodes returns through transaction costs and taxes, especially in taxable accounts
  • Under-rebalancing: allowing excessive drift exposes the portfolio to unintended risk levels and style drift
  • Wash sale violations when tax-loss harvesting: purchasing a substantially identical security within the 61-day window triggers wash sale rules, disallowing the loss
  • Ignoring tax impact of rebalancing in taxable accounts: rebalancing by selling winners generates taxable capital gains
  • Calendar rebalancing may miss large dislocations between dates (e.g., a 20% market crash between quarterly rebalancing dates)
  • Not accounting for the rebalancing premium when comparing strategies — buy-and-hold backtests may understate rebalanced portfolio returns
  • Forgetting to consider the full 61-day wash sale window (30 days before and after the sale)
  • Rebalancing into the wrong account: selling appreciated assets in taxable accounts when the same rebalancing could be done in tax-deferred accounts

Cross-References

  • asset-allocation (wealth-management plugin): rebalancing maintains the target asset allocation over time
  • diversification (wealth-management plugin): rebalancing preserves the intended diversification structure
  • bet-sizing (wealth-management plugin): position sizes drift and need rebalancing to maintain conviction weighting
  • historical-risk (wealth-management plugin): drift changes portfolio risk profile; rebalancing controls it
  • financial-statements (wealth-management plugin): tax implications of rebalancing require understanding of tax accounting
  • tax-loss-harvesting (wealth-management plugin): TLH trades should be coordinated with rebalancing to minimize total transaction count and avoid wash-sale conflicts
  • tax-efficiency (wealth-management plugin): asset location and tax-lot selection strategies directly affect rebalancing trade decisions
  • client-review-prep (advisory-practice plugin): drift analysis and rebalancing recommendations are core agenda items in periodic client reviews

Running the script

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

Matgeliwwert Dateien

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Rebalancing?

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.

Firwat Rebalancing op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Rebalancing besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Rebalancing an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/JoelLewis/finance_skills/tree/main/plugins/wealth-management/skills/rebalancing an. TypingMind liest d'Datei SKILL.md, bëndelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Rebalancing benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Rebalancing benotzen?

Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Rebalancing domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Rebalancing gratis?

Jo. JoelLewis huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.

Alleguer weisen

Elo Ären eegene KI-Aarbechtsberäich ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇