Linear Algebra for Quantitative Finance › Vectors in Finance
Quantitative FinanceAll chapters Linear Algebra for Quantitative Finance › Vectors in FinanceOne section · Sections in this chapter2 / 9 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
A vector is an ordered list of numbers. In finance, vectors appear everywhere: asset returns, portfolio weights, and factor exposures. The power of vectors lies in how we can manipulate them mathematically to answer financial questions.
Why do we need vectors rather than simply tracking individual numbers? Consider the alternative: if you manage a portfolio of 500 stocks, you could track 500 separate weight variables and 500 separate return variables. But this approach quickly becomes unwieldy. You'd need to write out 500 terms every time you calculate portfolio return, and any formula involving all assets would span pages. Vectors solve this organizational challenge by packaging related quantities into a single mathematical object that we can manipulate as a unit. This abstraction isn't merely notational convenience; it reveals structure. Operations that require hundreds of scalar terms can be written compactly and evaluated with standard vector routines.
Vector Basics
Consider a portfolio containing three assets. We can represent the weights allocated to each asset as a vector:
where:
- : the portfolio weight vector
- : the fraction of portfolio value allocated to asset
Here means 40% of the portfolio value is in asset 1. The vector lives in (three dimensional real space) because it has three components. Geometrically, each asset corresponds to an axis, and the weight vector points to a specific location in this three-dimensional "asset space." Every possible portfolio allocation corresponds to some point in this space. Portfolio constraints, like requiring weights to sum to one, define surfaces or regions within it.
Similarly, we can represent the returns of these three assets on a given day:
where:
- : the return vector for a single time period
- : the return of asset (expressed as a decimal, so 0.02 = 2%)
This says asset 1 returned 2%, asset 2 lost 1%, and asset 3 gained 1.5%. Notice how naturally this representation captures a snapshot of market behavior: all three returns belong together because they occurred simultaneously, and the vector keeps them organized as a coherent unit.
Vector Operations
The fundamental vector operations translate directly into financial calculations:
Scalar multiplication scales every element by a constant. If you double your position in everything:
Geometrically, multiplication by a positive scalar stretches or shrinks a nonzero vector without changing its direction. A negative scalar reverses its orientation, and zero maps it to the zero vector. Financially, scaling risky-asset weights by a positive factor preserves their relative allocations while changing exposure relative to the same equity base. Doubling the weights above gives 200% risky-asset exposure, which requires a cash or borrowing weight of -100% to keep net weights summing to one. The gross linear gains and losses from those assets double; the total portfolio return also includes financing and trading costs. Doubling both the positions and the capital instead leaves the normalized weights unchanged.
Vector addition combines vectors element-wise. If and are returns on consecutive days:
where denotes the return of asset on day .
For small returns, this approximates cumulative returns (the exact formula uses geometric compounding). Vector addition also models combining different portfolios. If two funds with values and are combined at the same valuation time, their combined weight vector is exactly before transaction costs or other value changes. The numerator adds the allocated amounts in each asset; dividing by the total capital converts those amounts back into weights. Equal capital contributions give the average of the two weight vectors, not their unscaled sum.
The Dot Product: Portfolio Returns
The dot product (or inner product) of two vectors is the sum of the products of corresponding elements:
where:
- : the number of assets in the portfolio.
This single number is the one-period portfolio simple return when contains beginning-of-period weights, contains same-period simple returns, the weights sum to one, and there are no intra-period cash flows or trading costs. It is not generally the exact portfolio log return when contains log returns. Each asset contributes to the simple return in proportion to both its individual simple return and the fraction of beginning capital allocated to it. The dot product sums these contributions.
Why does this work? Consider a $1 portfolio allocated at the beginning of the period and held without intra-period rebalancing. The amount invested in asset 1 is \w_1$w_1(1 + r_1)$\sum w_i(1 + r_i) = $(\sum w_i + \sum w_i r_i)$(1 + \sum w_i r_i)\mathbf{w} \cdot \mathbf{r}$. Portfolios with borrowing or short positions must include their cash or financing leg, and a new period uses the weights prevailing at that period's start.
import numpy as np
# Portfolio weights (must sum to 1 for a fully invested portfolio)
weights = np.array([0.4, 0.35, 0.25])
# Daily returns for three assets
returns = np.array([0.02, -0.01, 0.015])
# Portfolio return is the dot product
portfolio_return = np.dot(weights, returns)Asset weights: [0.4 0.35 0.25] Asset returns: [ 0.02 -0.01 0.015] Portfolio return: 0.0083 (0.83%) Calculation: 0.4×0.02 + 0.35×(-0.01) + 0.25×0.015 = 0.0083

The portfolio earned a 0.83% simple return by beginning the period with 40% in the 2% gainer, 35% in the 1% loser, and 25% in the 1.5% gainer. Under the conditions stated above, this dot product aggregates the asset simple returns into the one-period portfolio simple return.
Vector Norms: Measuring Size
The norm of a vector measures its "size" in various ways. But what does "size" mean for a vector? There's no single answer. Different norms capture different notions of magnitude, each useful in different contexts. The Euclidean norm (or L2 norm) is:
where:
- : the L2 (Euclidean) norm of vector
- : the -th component of the vector
- : the dimension of the vector
The Euclidean norm corresponds to our intuitive notion of distance: it's the straight-line distance from the origin to the point represented by the vector. To connect it to volatility, consider daily returns of one asset and first subtract their mean. The L2 norm of that centered vector divided by gives the descriptive standard deviation; dividing by , for , gives the sample standard deviation. A vector of simultaneous returns across different assets describes a cross-section instead, not a portfolio's time-series volatility.
The L1 norm sums absolute values:
The L1 norm measures total "travel distance" if you could only move along coordinate axes, like navigating a city grid where you can only travel along streets, not diagonally through blocks. In portfolio optimization, an L1 penalty can promote sparse positions when weights may take either sign or when the budget does not already fix their L1 norm. For a long-only, fully invested portfolio, however, , so an L1 penalty alone cannot select a sparser portfolio. An L2 penalty can discourage concentrated weights under a specified objective and constraints, but it does not guarantee an evenly spread allocation.
# Five daily simple returns of one asset
returns_vector = np.array([0.02, -0.01, 0.015, -0.005, 0.01])
l2_norm = np.linalg.norm(returns_vector, ord=2) # Euclidean norm
l1_norm = np.linalg.norm(returns_vector, ord=1) # Sum of absolute values
linf_norm = np.linalg.norm(returns_vector, ord=np.inf) # Max absolute valueReturn vector: [ 0.02 -0.01 0.015 -0.005 0.01 ] L2 norm: 0.029155 L1 norm: 0.060000 L∞ norm (max absolute): 0.020000
The L2 norm of 0.029 represents the Euclidean magnitude of these five raw returns, not their standard deviation. Centering and normalizing as described above is necessary for a volatility measure: even constant nonzero returns have a positive raw norm but zero standard deviation. The L1 norm of 0.06 sums absolute returns and can support sparsity-inducing penalties when the surrounding constraints do not make it constant. The L∞ norm of 0.02 identifies the largest absolute return, which shows the most extreme daily movement.