liveBook · Manning

Historical return

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

A historical return is the realized percentage change in an investment's value over a completed past period.

A historical return measures an asset’s realized percentage change over a completed period. It estimates average returns from past price data and supports portfolio analysis. section 3.1.1

Compute historical returns by following a short data workflow:

  • Download adjusted closing prices, which account for dividends and corporate actions such as stock splits. section 3.1.1
  • Calculate each period’s percentage change with pandas pct_change(). section 3.1.1
  • Remove or account for the initial NaN, then average daily returns and multiply by 252 to annualize the estimate. section 3.1.1

Three-stock estimate

For AAPL, First Energy, and Walmart, average historical returns annualized from daily observations are approximately 30.7%, 10.0%, and 8.1%, respectively. These figures summarize the selected historical sample rather than guaranteeing future performance. section 3.1.1

Listing 3.1 Downloading historical stock prices
import yfinance as yf

df = yf.download('AAPL', start='2000-01-03', end='2023-12-30')
df.tail()

Download a stock’s historical prices with yfinance before selecting adjusted closing prices and calculating returns. section 3.1.1

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

How deep it goes
Calculates daily percentage changes and annualizes their mean, while deferring more sophisticated volatility estimation.
Examples
Uses AAPL, First Energy, and Walmart prices, returns, annualized means, and a yfinance download.
What it assumes
Requires historical asset prices and basic Python or pandas operations, while demonstrating data retrieval and return calculation.
What you can do after
Apply it via Python and pandas to estimate annualized returns from historical price data.
How it connects
Connects adjusted closing prices, expected returns, volatility, correlation matrices, covariance matrices, and multifactor models.

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.