Token导航 LogoToken导航TokenDH.com
待分类需要联网github未标认证来源可访问许可证需确认审计提醒

rebalancingrebalancing 命令行

Agent Skill

rebalancing 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,723

周安装

74

GitHub Stars

58

下载量

604
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:rebalancing(rebalancing 命令行)
来源仓库:https://github.com/joellewis/finance_skills
仓库路径:skills/rebalancing
安装命令:
npx skills add https://github.com/joellewis/finance_skills --skill rebalancing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/joellewis/finance_skills --skill rebalancing

简介

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中整理仓库状态或协作事项。

  • 支持围绕代码变更、分支合并或项目进度进行信息组织与协调。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装使用。
  • 安装前需确认权限范围、维护状态及是否涉及命令执行或文件读写。
  • rebalancing 属于待分类类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Rebalancing

Purpose

Provides frameworks for maintaining portfolio allocations over time as market movements cause weights to drift from targets. Covers calendar and threshold rebalancing strategies, optimal band widths, transaction cost considerations, tax-efficient approaches including tax-loss harvesting, and practical implementation across account types.

Layer

4 — Portfolio Construction

Direction

both

When to Use

  • Deciding when and how to rebalance a portfolio back to target weights
  • Comparing calendar-based vs. threshold-based rebalancing strategies
  • Setting optimal rebalancing bands that balance tracking error against transaction costs
  • Implementing tax-efficient rebalancing and tax-loss harvesting
  • Managing rebalancing across taxable and tax-deferred accounts
  • Using cash flows (contributions/withdrawals) to rebalance opportunistically
  • Evaluating the rebalancing premium and its contribution to portfolio returns

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)

Tax-Loss Harvesting (TLH)

Proactively selling losing positions to realize capital losses that offset capital gains:

Tax benefit = Realized loss * Marginal tax rate

Rules and implementation:

  • Wash sale rule: Cannot repurchase a "substantially identical" security within 30 days before or after the sale (61-day window total)
  • Replacement security: Substitute a similar but not identical asset to maintain market exposure (e.g., sell one S&P 500 ETF, buy a total market ETF)
  • Timing: Most opportunities arise during market drawdowns
  • Long-term benefit: Harvested losses can offset current gains, and unused losses carry forward indefinitely. Up to $3,000 of net losses can offset ordinary income per year.

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

Reference Implementation

See scripts/rebalancing.py for computational helpers.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.62%
按下载量换算233

Claude

27.87%
按下载量换算168

Cursor

20.65%
按下载量换算125

Gemini CLI

9.97%
按下载量换算60

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills