Sub topic 11
Transaction costs and taxes
This chapter covers what a rebalancing trade costs and how those costs change your rebalancing rule. It assumes you can compute weights, drift, and trade amounts as in the earlier chapters, and that you know the calendar, threshold, and hybrid rules. The Python is optional but runs as shown.
The tax examples use simple, US-style rules: a flat rate on realized gains, and a split between short-term and long-term gains. Rates and rules differ by country and account type, so treat the numbers as illustrations and check your own jurisdiction.
Why costs belong in the rule
A rebalancing rule decides when to trade. Every trade has a price, so a rule that trades often pays more. A rule that trades rarely lets risk drift further from the target. Costs and taxes are the force that pushes against frequent trading.
Rebalancing is a risk-control tool, and its benefit is hard to measure in dollars. The cost is easy to measure. This lopsidedness is why practical policies set limits such as a minimum trade size, wider bands, or a preference for certain accounts.
The explicit and implicit costs of trading
Trading costs fall into four groups.
- Commissions. A fee charged by the broker per trade. Many brokers now charge zero for common funds and ETFs, but not all.
- Bid-ask spread. The gap between the price buyers offer (the bid) and sellers ask (the ask). When you trade, you cross part of that gap. A common estimate is half the quoted spread per trade.
- Market impact. Large orders can move the price against you. For small personal portfolios in liquid funds this is close to zero. For thinly traded holdings it can be the biggest cost.
- Fund-level frictions. Some mutual funds charge redemption fees or block quick resales. Those fees can make a rebalance trade expensive even with no commission.
The expense ratio, the yearly fee a fund charges, is not a trading cost. You pay it whether or not you rebalance. It matters only when choosing which fund to hold in each asset class.
A cost estimate in code
The function below estimates the cost of one trade as a flat commission plus half the spread. It then applies the cost to the trades from the earlier chapter: sell 6,000 of stocks and buy 6,000 of bonds.
def trade_cost(amount, spread_bps, commission=0.0):
"""Estimated cost of one trade.
spread_bps: full bid-ask spread in basis points (1 bp = 0.01%).
The trade pays half the spread, plus any flat commission.
"""
return commission + abs(amount) * spread_bps / 10000 / 2
trades = {"stocks": -6000.0, "bonds": 6000.0}
spread_bps = {"stocks": 2.0, "bonds": 6.0}
total_cost = sum(trade_cost(trades[a], spread_bps[a]) for a in trades)
print(f"Trading cost: {total_cost:.2f}")This prints Trading cost: 2.40. On 12,000 of total trades, that is 0.02%. For large, liquid funds, trading costs are often this small, and that is why taxes usually dominate in taxable accounts.
Taxes: the larger cost in taxable accounts
Selling an asset for more than you paid creates a realized capital gain, and a taxable account owes tax on it. Three facts shape rebalancing.
- Account type decides everything. In a tax-advantaged account, such as a retirement account, trades inside the account usually trigger no tax. In a taxable account, each sale can.
- Only sales realize gains. Buying never creates a tax bill. This is why a rule that fixes drift with purchases is tax-friendlier than one that sells.
- Gain depends on cost basis. The cost basis is what you originally paid for the shares. A sale of shares with a high basis produces a small gain. A sale of shares with a low basis produces a large one.
Many tax systems tax short-term gains (assets held about a year or less) at higher rates than long-term gains. Selling a lot only days before it turns long-term can cost real money.
A tax estimate in code
For a first estimate, use the average-cost method. The fraction of your position that is gain is (value - basis) / value. A sale realizes that same fraction of gain.
def realized_tax(sale, value, basis, rate):
"""Estimated tax on selling `sale` from a position.
value: current market value of the whole position.
basis: total cost basis of the whole position.
rate: tax rate on gains, for example 0.15.
A loss returns a negative number, a saving if losses are usable.
"""
gain_fraction = (value - basis) / value
return sale * gain_fraction * rate
values = {"stocks": 72000.0, "bonds": 38000.0}
basis = {"stocks": 50000.0, "bonds": 38000.0}
trades = {"stocks": -6000.0, "bonds": 6000.0}
spread_bps = {"stocks": 2.0, "bonds": 6.0}
rate = 0.15
def trade_cost(amount, spread_bps, commission=0.0):
return commission + abs(amount) * spread_bps / 10000 / 2
costs = sum(trade_cost(trades[a], spread_bps[a]) for a in trades)
tax = sum(
realized_tax(-t, values[a], basis[a], rate)
for a, t in trades.items()
if t < 0
)
print(f"Trading cost: {costs:.2f}")
print(f"Estimated tax: {tax:.2f}")
print(f"Total: {costs + tax:.2f}")The output is:
Trading cost: 2.40
Estimated tax: 275.00
Total: 277.40The stock position is 30.6% gain, so selling 6,000 realizes about 1,833 of gain. At 15% that is 275 of tax, over 100 times the trading cost. This is typical for a taxable account with large unrealized gains.
Real lot-by-lot accounting can differ from average cost. Brokers let you choose which lots to sell, and that choice is a tool covered below.
How costs change each rule
| Rule | Effect of costs and taxes |
|---|---|
| Calendar | Trades happen on every review date, even when drift is tiny. Small, pointless trades pay costs and may realize gains. |
| Threshold | Trades only after a breach. Fewer trades, but a breach can force a large sale at a bad moment for taxes. |
| Hybrid | Reviews on a schedule, trades only if a band is breached. This avoids both pointless small trades and constant monitoring. |
Costs also affect the parameters of each rule.
- Calendar interval. A longer interval means fewer taxable events. An annual review typically costs less than a monthly one with little loss of risk control.
- Band width. Wider bands mean fewer trades. Raise the band width as costs rise.
- Destination. Rebalancing only to the band edge sells less than rebalancing fully to target. In the example, with a 5-point absolute band, the stock edge is 65% of 110,000, or 71,500. Selling 500 instead of 6,000 cuts the estimated tax from 275.00 to about 22.92.
Ways to reduce the bill
You can lower costs without abandoning the rule.
- Rebalance inside tax-advantaged accounts first. Trades there carry no tax. If the household target is 60/40 across all accounts, you can often fix drift using only the retirement account.
- Use new cash. Direct contributions, dividends, and interest to the underweight class. This requires no sale. A later chapter covers it in detail.
- Choose tax lots. Sell the lots with the highest basis first, or lots that are already long-term, to realize the least gain.
- Harvest losses. If a holding is below its basis, selling it realizes a loss that can offset gains elsewhere. Beware wash-sale rules in the US: if you buy a substantially identical security within 30 days before or after the sale, the loss is disallowed.
- Set a minimum trade size. Skip trades below an amount, such as 500 or 1% of the portfolio. They change the risk little and cost a fixed commission or lot-tracking effort.
- Donate appreciated shares. Where the law allows, giving highly appreciated shares to charity removes the gain without a sale.
The helper below applies idea 1. It sells the required amount from tax-advantaged accounts first, then from taxable accounts.
def plan_sale(amount, accounts):
"""Split a required sale across accounts, tax-advantaged first.
accounts: list of dicts with name, taxable (bool), and stock_value.
Returns (plan, remaining) where remaining is any amount not covered.
"""
plan = {}
remaining = amount
for acct in sorted(accounts, key=lambda a: a["taxable"]):
sell = min(remaining, acct["stock_value"])
if sell > 0:
plan[acct["name"]] = sell
remaining -= sell
return plan, remaining
accounts = [
{"name": "brokerage", "taxable": True, "stock_value": 52000.0},
{"name": "ira", "taxable": False, "stock_value": 20000.0},
]
print(plan_sale(6000.0, accounts))This prints ({'ira': 6000.0}, 0.0). The sale sits in the IRA. The bond purchase must also happen in the IRA, using the sale proceeds, so the account stays cash-neutral.
A decision flow for one trade
The diagram shows how to decide on a single rebalancing trade once a rule has said "trade".
Common errors
- Ignoring the tax bill until filing time. Estimate the gain before you trade, not after.
- Selling the wrong lots. The default lot method may be first-in, first-out, which sells the oldest and often lowest-basis lots. Set the method on purpose.
- Triggering short-term gains. Check holding periods before a sale that could wait a few weeks.
- Counting each account separately. If your target applies to the household, rebalance across all accounts together. Fixing each account separately can create taxable trades that are not needed.
- Forgetting fund frictions. Redemption fees and minimum holding periods do not show up in a spread estimate.
- Wash sales. Rebuying a loss position too soon cancels the loss.
Summary
- Trading costs are usually small for liquid funds. Taxes in taxable accounts are often far larger.
- Buying never realizes a gain, and sales in tax-advantaged accounts usually do not either.
- Costs push toward longer intervals, wider bands, partial rebalances, and minimum trade sizes.
- Use cash flows, tax-advantaged accounts, and lot selection before selling taxable gains.
Exercise
A taxable position is worth 40,000 and has a total cost basis of 30,000. The rule requires selling 4,000 of it. The fund has a full bid-ask spread of 10 basis points, there is no commission, and the tax rate on gains is 20%. Using the average-cost method and the half-spread cost model, what are the trading cost, the estimated tax, and the total?
Show answer
The trading cost is 4,000 × 10 / 10,000 / 2 = 2.00. The gain fraction is (40,000 − 30,000) / 40,000 = 0.25, so the sale realizes 4,000 × 0.25 = 1,000 of gain. The tax is 1,000 × 0.20 = 200.00. The total is 202.00, or about 5.05% of the amount sold. Nearly all of it is tax.
Exercise
Your household holds the same stock fund in an IRA (20,000) and a taxable account (52,000, with large unrealized gains). A rebalance needs 6,000 of stocks sold and 6,000 of bonds bought. Where should you make the trades, and why? Name one situation where you would still trade in the taxable account.
Show answer
Make both trades inside the IRA. The sale realizes no tax there, and the IRA can buy the bonds with the sale proceeds. You would still trade in the taxable account if the IRA did not hold enough of the overweight asset to cover the sale, or if the sale there realizes a loss that can offset other gains.