liveBook · Manning

Portfolio weight

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

A portfolio weight is the proportion of a portfolio allocated to a particular asset, with weights commonly constrained to sum to one.

A portfolio weight is an asset’s share of a portfolio. Represent weights as a vector w; a fully allocated portfolio satisfies 1ᵀw = 1. Weights turn expected returns and a covariance matrix into portfolio expected return, μᵀw, and volatility, √(wᵀΣw). section 2.7 section 12.1.1 section 2.3

Three-stock allocation

For FE, WMT, and AAPL, weights specify how the portfolio is divided among the three holdings. Randomly generated values can be normalized by their sum, producing weights that total 1; negative weights represent short positions. Computing return and volatility for many such allocations makes the attainable risk–reward pattern visible. section 2.1 section 2.3

Weights are decision variables in portfolio construction. Minimum-variance optimization selects weights that minimize variance for a target expected return while requiring their sum to equal 1. Constraints can substantially change optimized allocations, and allocation between risky assets and a risk-free asset reflects risk tolerance. section 2.7 section 10.3 section 2.9

Weights need not remain fixed. Starting from a 60/40 stock–bond allocation, higher stock returns can shift the stock weight toward 83% over 30 years and raise portfolio volatility, motivating periodic rebalancing toward a target portfolio. section 13.1.1

Listing 2.5 Generating random portfolio weights
def random_weights(n_assets):
    k = np.random.randn(n_assets)
    return k / sum(k)
print(random_weights(3))

This small function generates random asset weights and normalizes them to sum to 1. section 2.3

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

How deep it goes
Derives minimum-variance weights with Lagrange multipliers and implements random-weight simulations, while deferring frontier derivation to an appendix.
Examples
Uses FE, WMT, and AAPL; six ETF asset classes; a two-asset risk-parity portfolio; and a drifting 60/40 stocks–bonds portfolio.
What it assumes
Assumes expected returns, volatility, covariance matrices, matrix multiplication, and basic Python numerical arrays.
What you can do after
Build it from scratch by normalizing weights, calculating portfolio metrics, and formulating constrained minimum-variance allocations.
How it connects
Connects portfolio weights to expected return, covariance matrices, minimum-variance optimization, risk parity, and rebalancing.

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.