liveBook · Manning

Tax

As explained in Build a Robo-Advisor with Python (From Scratch)

A compulsory charge imposed by a government on income, transactions, property, or other taxable bases.

Tax becomes a portfolio-management cost when selling appreciated assets realizes capital gains. Rebalancing therefore involves both trading costs and potential tax consequences, except in tax-advantaged accounts such as 401(k)s. section 13.1.2

Avoiding a taxable ETF rebalance

An ETF holds $500,000 of Stock A with a $300,000 cost basis. Rebalancing by selling A would realize a $200,000 gain. A heartbeat trade instead exchanges new securities for Stock A without selling it, aligning the portfolio without creating a realized gain. section 4.2.3

Tax-aware portfolio decisions include:

  • Sell lots with the least tax exposure first when rebalancing. section 13.5
  • Compare taxable, tax-deferred, and tax-exempt account locations when distributing assets. section 1.3
  • Extend retirement-income analysis to include taxes on Social Security income and benefits withheld above an income threshold. section 1.3
Table 4.2 Old and new index weights
A B C D E
Old weight 50% 30% 20% 0% 0%
New weight 0% 45% 30% 15% 10%

Compare old and new index weights to see why an ETF must exchange holdings during the heartbeat trade. section 4.2.3

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Explains realized gains, cost basis, tax-advantaged accounts, tax-aware lot selection, and ETF heartbeat trades, but does not calculate tax rates.
Examples
Uses an ETF heartbeat trade, a $200,000 realized-gain calculation, tax-aware lot selection, and Social Security income assumptions.
What it assumes
Assumes familiarity with portfolios, asset allocation, rebalancing, account types, and cost basis.
What you can do after
Diagnose tax consequences and design rebalancing strategies that reduce taxable gains under explicit constraints.
How it connects
Connects taxes with capital gains, rebalancing, ETFs, mutual funds, asset location, and Social Security benefits.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.