A client holds a taxable portfolio of five ETFs and wants to rebalance toward a target allocation. Selling appreciated positions triggers capital gains taxes. The optimizer balances investment efficiency (tracking error vs. the target) against tax cost (realized capital gains). This page formalizes the problem, derives the solution, and provides an interactive tool to explore the tradeoff.
Three deposits of $100,000 each on the following dates, each split equally (20%) across five ETFs:
| Deposit | Date | Amount | Per ETF | Holding Period (as of 2018-03-14) | Tax Rate |
|---|---|---|---|---|---|
| 1 | 2010-01-04 | $100,000 | $20,000 | > 1 year (long-term) | 20% |
| 2 | 2014-01-02 | $100,000 | $20,000 | > 1 year (long-term) | 20% |
| 3 | 2018-01-02 | $100,000 | $20,000 | < 1 year (short-term) | 30% |
The rebalance date is March 14, 2018. The target allocation is equal-weighted: 20% in each ETF.
The investor solves:
$$\min_{w} \quad \lambda \cdot T \cdot (w - w^*)^\top \Sigma \, (w - w^*) \;+\; \sum_{i=1}^{N}\sum_{j=1}^{L_i} \tau_{ij} \cdot \max\!\big(0,\; g_{ij}\big) \cdot s_{ij}$$subject to:
$$\sum_{i} w_i = 1, \qquad w_i \geq 0 \;\;\forall\, i, \qquad 0 \leq s_{ij} \leq \text{shares\_held}_{ij} \;\;\forall\, i,j$$| Symbol | Definition |
|---|---|
| \(w\) | Post-rebalance portfolio weights (decision variable) |
| \(w^*\) | Target weights (equal-weighted: 20% each) |
| \(\Sigma\) | Forward-looking variance-covariance matrix (\(N \times N\)) |
| \(\lambda\) | Tradeoff parameter: penalty on tracking error vs. tax cost |
| \(T\) | Investment horizon in years |
| \(N\) | Number of assets (5) |
| \(L_i\) | Number of tax lots for asset \(i\) (3: one per deposit) |
| \(\tau_{ij}\) | Tax rate for lot \(j\) of asset \(i\) |
| \(g_{ij}\) | Capital gain per share for lot \(j\) of asset \(i\) |
| \(s_{ij}\) | Shares sold from lot \(j\) of asset \(i\) |
\(\lambda \cdot T \cdot (w - w^*)^\top \Sigma \,(w - w^*)\)
Penalizes deviation from the target allocation, weighted by the covariance structure. A larger deviation in volatile or correlated assets costs more. The penalty scales with the investment horizon \(T\): a suboptimal allocation compounds over time.
\(\sum_i \sum_j \tau_{ij} \cdot \max(0, g_{ij}) \cdot s_{ij}\)
The total capital gains tax incurred from selling. Lots with large embedded gains (especially at the 30% short-term rate) generate a real cash drag. Lots with losses can be sold "for free" or harvested for tax benefit.
The horizon \(T\) enters multiplicatively with the tracking error penalty:
$$\text{Effective penalty} = \lambda \cdot T$$| Horizon | Effect | Behavioral implication |
|---|---|---|
| \(T = 1\) year | Low effective penalty | Tolerate more deviation from target. Minimize taxes. Stay closer to current weights. |
| \(T = 5\) years | High effective penalty | Worth paying more taxes to get closer to optimal. Trade more aggressively toward target. |
When the client also holds ETFs outside the target universe, the optimization extends to a 7-asset problem:
The target now has zero weight in QQQ and VNQ: \(w^* = (0.2, 0.2, 0.2, 0.2, 0.2, 0, 0)\). The setup: $60,000 in QQQ and $40,000 in VNQ, both purchased 2010-01-04 (long-term, 20% tax rate), plus two deposits of $100,000 each in the five native ETFs.
The optimizer wants to sell all QQQ and VNQ but faces enormous embedded gains (QQQ appreciated ~300% since 2010). Two key insights:
The table below shows the current value of each tax lot, computed by compounding daily returns from the deposit date through the rebalance date. Total portfolio value is approximately $407,000.
Use the sliders below to explore how the tradeoff parameter \(\lambda\), the investment horizon, and tax rates affect the optimal portfolio. The chart traces the efficient frontier: each point is the solution for a given \(\lambda\), showing the tracking error variance (horizontal) against the tax cost paid (vertical).
Each dot represents the solution for a value of \(\lambda\). Moving right: lower tracking error (closer to target) but higher tax cost. The current portfolio (no trading) is the leftmost point.
Estimated from daily returns of the five ETFs using geometric Brownian motion simulation. Used in the base-case optimization.
| VTI | VEA | VWO | BND | EMB |
|---|