liveBook · Manning

Minimum-variance frontier

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

The minimum-variance frontier is the set of portfolios that achieve the lowest possible variance for specified expected returns when no risk-free asset is included.

The minimum-variance frontier traces portfolios achieving the lowest possible variance for each specified expected return when all assets are risky. Its upper branch is the efficient frontier; its lower branch is inefficient because another portfolio offers higher return at the same volatility. section 2.3 section 2.9

The frontier provides several useful portfolio-construction landmarks:

  • It appears as a hyperbola in expected-return–standard-deviation space and as a sideways parabola in expected-return–variance space. section 2.7
  • Its leftmost point is the global minimum-variance portfolio, with expected return B/A and variance 1/A. section 2.7
  • For covariance matrix Σ and expected-return vector μ, define A = 1ᵀΣ⁻¹1, B = 1ᵀΣ⁻¹μ, and C = μᵀΣ⁻¹μ. section 2.7
  • The standard-deviation equation is σₚ = √[(Aμₚ² − 2Bμₚ + C)/(AC − B²)]. section 2.7

Plotting the frontier with random portfolios

A practical workflow first generates 1,000 random weights, computes each portfolio’s mean and standard deviation with matrix operations, and plots the resulting risk–reward points. Computing A, B, and C then adds the analytical frontier: plot the lower segment as the minimum-variance frontier and the upper segment as the efficient frontier. section 2.3

Listing 2.8 Adding minimum-variance frontier to risk–reward plot
def plot_min_var_frontier(mu, Cov):  #1
    A,B,C = compute_ABC(mu, Cov)
    y = np.linspace(0,B/A,100)   #2
    x = np.sqrt((A*y*y-2*B*y+C)/(A*C-B*B))   #2
    plt.plot(x,y, color='black', lw=2.5, linestyle='--')  #2

    y = np.linspace(B/A,.45,100)  #3
    x = np.sqrt((A*y*y-2*B*y+C)/(A*C-B*B))  #3
    plt.plot(x,y, color='black', lw=2.5, label='Efficient Frontier')  #3
    plt.legend()


def compute_ABC(mu, Cov):  #4
    Cov_inv = np.linalg.inv(Cov)
    ones = np.ones(n_assets)
    A = ones @ Cov_inv @ ones
    B = ones @ Cov_inv @ mu
    C = mu @ Cov_inv @ mu
    return A,B,C

plot_points(mu, sigma, stocks)
plot_random_portfolios(mu, Cov, n_simulations)    
plot_min_var_frontier(mu, Cov)
plt.show()

Inspect the Python implementation that computes A, B, and C and overlays both frontier branches on a risk–reward plot. section 2.3

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

How deep it goes
Derives the closed-form equation and global minimum-variance point, while deferring the derivation to an optional appendix.
Examples
Uses 1,000 random portfolios of three stocks, risk–reward plots, and Python functions for weights, statistics, and frontier curves.
What it assumes
Assumes portfolio expected returns, covariance matrices, portfolio weights, and matrix multiplication, while making the derivation optional.
What you can do after
Build it from scratch by simulating portfolios, calculating matrix-based statistics, and plotting the analytical frontier.
How it connects
Connects portfolio construction with efficient frontier, global minimum-variance portfolio, covariance matrix, and risk-free asset.

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.