liveBook · Manning

Backtesting

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

Backtesting is the evaluation of an investment strategy by simulating its application to historical market data.

Backtesting evaluates an investment strategy by simulating it over historical market data. For portfolio rebalancing, the simulation advances one day at a time, grows holdings using prices and dividends, generates trades, and records taxes, trading costs, and deviations from target weights. section 13.4 section 13.4.2

A practical backtester typically:

  • Retrieves non-adjusted closing prices and dividend data, preserving dividends as cash rather than automatically reinvesting them. section 13.4.2
  • Summarizes annualized return, volatility, turnover, spread cost, tax cost, rebalance frequency, and deviations from target weights. section 13.4.4

Comparing three rebalancing policies

A portfolio with six assets, $10,000 of starting capital, 0.2% target cash, and 0.03% spreads can be tested over 2013–2022. Weekly interval rebalancing produced 7.00% mean return, 39.8% turnover, and 0.21% mean maximum deviation; threshold rebalancing produced 7.04%, 31.9%, and 0.26%; optimization produced 7.04%, 17.6%, and 0.60%. The comparison exposes trade-offs among trading activity, taxes, and tracking precision. section 13.4.3

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

How deep it goes
Implements a daily simulation with holdings, dividends, trades, spreads, taxes, weights, and annualized summary statistics.
Examples
Compares interval-based, threshold-based, and optimization-based rebalancing using six assets and a ten-year historical period.
What you can do after
Build it from scratch in Python with yfinance, then compare strategy performance, costs, turnover, and tracking behavior.
How it connects
Connects rebalancing with portfolio weights, dividends, taxes, trading costs, optimization, and tracking deviation.

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.