Returns calculator
Paste a list of prices. Get simple and log returns, cumulative and annualised return, and volatility.
How it works
A simple return is the percentage change, and simple returns add across assets in a portfolio. A log return is the change in the log price, and log returns add across time: the sum of daily log returns equals the log of the total return.
The annualised return (CAGR) is the constant yearly rate that turns the first price into the last. The arithmetic average return is always at least as large, and the gap grows with volatility; roughly, the geometric return is the arithmetic return minus half the variance.
Assumptions
- Prices are evenly spaced; choose how many periods make a year.
- Volatility uses log returns and the sample standard deviation (n - 1).
- Paste one price per line, or CSV rows whose last column is the price. Lines without a number are skipped.
- Your data never leaves the browser.
Show the codePython, runs in the playground
import numpy as np
import pandas as pd
prices = pd.Series([100, 102.0, 101.1, 104.6, 103.2, 106.9, 108.4, 107.0, 110.3, 109.1, 112.8, 114.5, 113.9])
periods_per_year = 12
simple = prices.pct_change().dropna()
log = np.log(prices).diff().dropna()
total = prices.iloc[-1] / prices.iloc[0] - 1
cagr = (1 + total) ** (periods_per_year / len(simple)) - 1
print(f"Total return: {total:.6f}")
print(f"CAGR: {cagr:.6f}")
print(f"Annualised volatility: {log.std(ddof=1) * np.sqrt(periods_per_year):.6f}")
print(f"Sum of log returns: {log.sum():.6f} (log of total: {np.log(1 + total):.6f})")
Questions
Should I use simple or log returns?
Use simple returns to combine assets into a portfolio and to report performance. Use log returns for statistics over time, because they add up across periods and are closer to normally distributed.
Why is my average return higher than my CAGR?
Volatility drag. A +50% year followed by a -50% year averages 0% but loses 25% overall. The CAGR is what you actually earned.
What periods per year should I pick?
252 for trading days, 52 for weeks, 12 for months and 1 for years.
Is my data uploaded anywhere?
No. The calculation runs in your browser and nothing is sent to a server.
Educational use only, not investment advice. Results depend on the model's assumptions listed above and on your inputs. Calculations run in your browser and nothing you enter is sent to a server.