Back

Portfolio Return Calculator

See a portfolio as linear algebra: weights and returns as vectors, multi-period returns as a matrix-vector product, and variance as a quadratic form.

Feb 23, 2026, Eric

The Core Idea

A portfolio is a weight vector w ∈ ℝᴹ dotted with a return vector r ∈ ℝᴹ. Over N days, returns form a matrix R ∈ ℝᴺˣᴹ and daily portfolio returns are R · w. Portfolio variance is the quadratic form wᵀ Σ w.

Portfolio Weights

Sliders set relative weights — auto-normalized so they sum to 100%.

SPY S&P 500w1 = 40.0%
QQQ Nasdaqw2 = 30.0%
IWM Small-Capw3 = 20.0%
TLT Long Bondw4 = 10.0%

Part 1 — Single-Period Return: w · r

Asset Returns (%)

r_p = w · r (step by step)

w




40.0%
30.0%
20.0%
10.0%



·

r




+1.20%
+2.10%
-0.40%
+0.30%



=

r_portfolio

+1.06%

Dot product expansion:

40.0% × +1.20% + 30.0% × +2.10% + 20.0% × -0.40% + 10.0% × +0.30%

= +0.4800% + +0.6300% + -0.0800% + +0.0300%

= +1.0600%

Return contribution per asset (w_i × r_i):

SPY
+0.480%
QQQ
+0.630%
IWM
-0.080%
TLT
+0.030%

Portfolio Variance: wᵀ Σ w

Σ is the 4×4 covariance matrix estimated from the 20-day simulated return series. Values shown ×10⁴ (basis points squared).

SPYQQQIWMTLT
SPY0.991.120.93-0.19
QQQ1.121.591.35-0.26
IWM0.931.351.49-0.30
TLT-0.19-0.26-0.300.78

Intermediate step — Σ · w (×10⁴):

SPY: 0.901
QQQ: 1.169
IWM: 1.046
TLT: -0.132

Variance (daily, ×10⁴)

0.907

Vol σ (daily)

0.952%

Annualized σ

15.1%

Part 2 — 20-Day Matrix: R · w

R is a 20×4 returns matrix (rows = days, columns = assets). The rightmost column is the portfolio return for that day: r_p[t] = R[t] · w.

DaySPYQQQIWMTLTPortfolio
1+1.59%+1.86%+2.53%+0.32%+1.73%
2+0.61%+0.25%+0.78%+0.39%+0.52%
3+2.11%+2.52%+2.34%-0.48%+2.02%
4+0.20%+0.91%+1.41%-1.94%+0.44%
5+0.42%-0.01%-0.15%-0.30%+0.10%
6-0.11%+0.46%+0.88%-0.34%+0.24%
7-0.52%-0.73%-0.93%+0.91%-0.52%
8+0.16%-0.16%-0.49%+1.41%+0.06%
9+2.11%+1.84%+1.41%-2.08%+1.47%
10+0.13%-0.09%+0.21%-0.53%+0.02%
11+0.27%+0.63%+1.00%-1.49%+0.35%
12+1.05%+1.13%+1.87%+0.49%+1.18%
13+0.11%-0.93%-1.68%+0.19%-0.55%
14-0.76%-0.89%+0.31%-0.37%-0.54%
15-0.00%-0.22%-0.79%-0.94%-0.32%
16+1.38%+2.60%+1.58%+0.24%+1.67%
17-1.72%-1.02%-1.13%+0.38%-1.18%
18-0.42%-1.41%-0.79%+0.05%-0.75%
19-0.34%-0.70%-0.51%-0.60%-0.51%
20+1.64%+2.26%+1.12%-0.16%+1.54%
Total+7.92%+8.29%+8.97%-4.87%+6.96%

Cumulative portfolio return: