Finance

Stock analysis

Return, risk and beta for a share against the market, and the portfolio mix with the best return for its risk.

Describe a share’s return and risk, measure its beta against the market, and find the portfolio mix that earns the most for the risk it takes.

Prices

Daily closing prices for a few shares and a market index. Use the simulated set, or bring your own: a table with dates in the first column and one column of prices per share, or one or more price files downloaded from a site such as Yahoo Finance.

Prices

Return and risk

How much a share earned, how bumpy the ride was, and the worst fall from a peak. Every share is in the table; the charts follow the one you pick.

Growth of $100
Price with its 50- and 200-day moving averages

When the short average crosses above the long one, traders call it a golden cross; below, a death cross. A description of the past, not a forecast.

Drawdown: distance below the last peak
Every share side by side
  • Annual return is the average daily return × 252; growth rate (CAGR) is what the price actually compounded at. Volatility drags the second below the first.
  • Sharpe divides the return above the risk-free rate by volatility; Sortino counts only the downside.
  • Prices should be adjusted for dividends and splits, or the returns will be wrong on those days.

Beta and alpha

The capital asset pricing model regresses a share’s daily excess return on the market’s. The slope, beta, is the market risk you can’t diversify away; the intercept, alpha, is return the market doesn’t explain.

Rolling beta window
Daily excess returns

Each dot is a day. The line’s slope is beta.

Beta over time

Measured over a trailing window. Betas drift, which is one reason to treat a single estimate with care.

Efficient frontier

Markowitz’s question: of all the ways to split money between these shares, which give the most return for each level of risk? No short selling: every weight is zero or more.

Shares to combine (two to eight)
Portfolio to show
Risk and return, per year

The curve is the efficient frontier; the straight line from the risk-free rate touches it at the max-Sharpe mix (the capital market line).

Weights
Stability check: the same method on each half of the data

Average returns are measured with a lot of noise, and the optimiser leans hard on them. If the weights swing between halves, don’t trust the decimals.

  • Built from past average returns, volatilities and correlations, assumed to hold in future. They won’t exactly.
  • Solved exactly: for every subset of shares the best mix has a closed form, and the best subset with no negative weights is the answer.

Sources

  1. Markowitz, H. (1952). Portfolio selection. The Journal of Finance, 7(1), 77–91.
  2. Sharpe, W. F. (1964). Capital asset prices: a theory of market equilibrium under conditions of risk. The Journal of Finance, 19(3), 425–442.
  3. Sortino, F. A. and Price, L. N. (1994). Performance measurement in a downside risk framework. The Journal of Investing, 3(3), 59–64.
  4. The simulated prices follow a GARCH(1,1) market with Student-t shocks (Bollerslev, 1986) and a one-factor model for each share. The companies are invented.