← All Labs
IDEA #45 · QUANTITATIVE FINANCE — PRICING & RISK

Quantitative finance: pricing and risk you can drag

Markets look like pure chaos, but the maths of finance says otherwise: prices wander randomly, yet that randomness has a shape — and that shape is exactly what gets priced, diversified and hedged. Three tabs let you drag the shape around and watch the numbers move: Black–Scholes turns volatility and time into an option's fair price and its Greeks; portfolio theory traces the efficient frontier as you blend two risky assets; Value-at-Risk runs a live Monte-Carlo of tomorrow's P&L and asks how bad a bad day gets. Every curve is computed from the real formulas in your browser — a shared market seed keeps the random scenarios consistent across tabs.

SHARED MARKET
SEED42
REGIME
The seed drives the Monte-Carlo draws in the VaR tab and the scenario cloud in the portfolio tab; the regime sets the baseline volatility all three tabs open with.
TAB 1 · BLACK–SCHOLES, 1973
Option pricer & Greeks
Drag strike, volatility and time. The value curve inflates above the payoff kink; delta, gamma, vega, theta and rho update live.
TAB 2 · MARKOWITZ, 1952
Portfolio & the frontier
Blend two risky assets; the mix traces a bowed frontier. Add a risk-free rate to find the tangency portfolio and the capital-market line.
Value-at-Risk
TAB 3 · MONTE-CARLO RISK
Simulate tomorrow's returns, drag the confidence line, watch VaR and expected shortfall carve out the tail — Normal vs fat-tailed.
01

Drive it — price an option

The straight kinked line is the payoff at expiry; the smooth curve above it is the option's value today under Black–Scholes. The gap between them is time value. Drag volatility or time up and watch the curve balloon; drag the spot marker left–right on the chart to move along it.
DRIVE IT
initialising…
SPOT  S100
STRIKE  K100
VOLATILITY  σ20%
TIME TO EXPIRY  T1.00y
RISK-FREE RATE  r5.0%
PRICE
fair premium
DELTA Δ
∂V/∂S
GAMMA Γ
∂Δ/∂S
VEGA ν
per 1% σ
THETA Θ
per day
RHO ρ
per 1% r
Every number is the exact Black–Scholes closed form, evaluated live — the price is S·N(d₁) − K·e^(−rT)·N(d₂) for a call, with the Greeks its analytic derivatives.
02

Walkthrough

Feel where an option's price comes from.
WALKTHROUGH
1
Start at-the-money (S = K = 100). The payoff line is flat then kinks up at the strike, but the value curve sits above zero everywhere — even out-of-the-money the option is worth something, because the future is uncertain. That lift is time value.
2
Drag volatility from 20% toward 60%. The whole curve puffs upward: more volatility means a fatter chance of finishing deep in the money, and options love that. This sensitivity is vega, and it's why traders quote options in "vol," not dollars.
3
Now shrink time to expiry toward zero. The value curve collapses onto the payoff kink — time value bleeds out. Watch theta (the per-day decay) grow more negative as expiry approaches. Options are melting ice.
4
Slide the spot marker across the strike and read delta: near 0 far below the strike, near 1 far above, and passing through ½ at-the-money. Delta is the curve's slope — the hedge ratio telling you how many shares replicate the option.
AHA
An option's price isn't a guess about direction — it's the cost of uncertainty and time. Black–Scholes says: tell me how much the world might move and how long you'll wait, and I'll tell you exactly what that possibility is worth.
03

Explanation

Replication, risk-neutrality, and the Greeks.
EXPLANATION

The Black–Scholes model assumes the stock price follows geometric Brownian motion — a random walk whose percentage moves are normally distributed with volatility σ. The genius of the 1973 argument is that you can replicate an option by continuously holding delta shares of the stock and some cash, rebalancing as the price moves. Because the option can be perfectly copied by a self-financing portfolio, its price is pinned down by no-arbitrage: if it traded for anything else, you could manufacture free money.

That argument makes the stock's real-world drift disappear. Under the "risk-neutral" measure every asset grows at the risk-free rate r, and the option's value is just the discounted expected payoff. Carrying out that expectation for a European call gives the famous formula C = S·N(d₁) − K·e^(−rT)·N(d₂), where N is the normal CDF and d₁, d₂ package up moneyness, volatility and time.

The Greeks are the formula's partial derivatives, and each is a risk you can hedge. Delta (∂V/∂S) is your exposure to the stock and the number of shares to short to stay neutral. Gamma (∂Δ/∂S) is how fast that hedge goes stale. Vega is sensitivity to volatility, theta the daily time-decay, and rho the interest-rate sensitivity. A trading desk lives and dies by keeping these numbers where it wants them.

The model is famously wrong in its details — real returns have fat tails and volatility isn't constant, which shows up as the volatility smile in quoted prices. Yet it remains the lingua franca of derivatives because it gives a single, arbitrage-free translation between price and volatility, and its Greeks are still how risk is measured and neutralised on every options desk in the world. Merton and Scholes won the 1997 Nobel for it; Black had died two years earlier.

04

Research note

The closed form and its d-terms.
RESEARCH NOTE
A European call and put on a non-dividend stock, with N the standard-normal CDF:
where the moneyness terms are
The Greeks are analytic derivatives (call shown; φ is the normal PDF):
Put–call parity C − P = S − K·e^(−rT) links the two and is enforced exactly by the applet. Source: Black & Scholes, The Pricing of Options and Corporate Liabilities (1973); Merton (1973).
01

Drive it — blend two assets

Each dot is a portfolio: horizontal is risk (σ), vertical is expected return. Drag the weight to slide along the bowed frontier joining the two assets; drag correlation to bend it. Turn on the risk-free rate to draw the capital-market line to the tangency (max-Sharpe) portfolio.
DRIVE IT
initialising…
WEIGHT IN ASSET A (stock)50%
CORRELATION  ρ(A,B)+0.20
A · return μA8%
A · risk σA12%
B · return μB14%
B · risk σB22%
RISK-FREE RATE  rf3.0%
RETURN μp
expected
RISK σp
st. dev.
SHARPE
(μ−rf)/σ
The faint dots are a scenario cloud of random long-only mixes drawn from the shared market seed — change the seed in the bar above and the same cloud reshuffles here and in the VaR tab.
02

Walkthrough

Watch diversification do its work.
WALKTHROUGH
1
With the weight at the ends you hold pure A or pure B — the two labelled dots. Slide the weight and the portfolio traces a curve, not a straight line, bowing left toward less risk. That leftward bow is diversification.
2
Find the leftmost point of the curve: the minimum-variance portfolio. Notice it can have less risk than either asset alone — combining two risky things can be safer than holding either one, as long as they don't move perfectly together.
3
Drag correlation down toward −1. The bow deepens dramatically until the frontier nearly touches the vertical axis — with perfectly anti-correlated assets you can build an almost risk-free mix. Push ρ to +1 and the bow flattens to a straight line: no free lunch.
4
Raise the risk-free rate line. The straight capital-market line pivots up from rf until it just kisses the frontier at the tangency portfolio — the single mix with the highest Sharpe ratio. Every investor should hold that mix, levered up or down with cash.
AHA
Risk isn't additive. Because assets don't move in lockstep, blending them cancels part of the wobble for free — so the smart question was never "which asset?" but "which combination?"
03

Explanation

Mean–variance, the frontier, and the tangency portfolio.
EXPLANATION

Harry Markowitz's 1952 insight was to describe an investment by just two numbers: its expected return and the variance of that return. A portfolio's expected return is simply the weighted average of its holdings — but its variance is not. Because assets co-move, the portfolio variance includes covariance terms, and when two assets are less than perfectly correlated those cross-terms subtract risk. That is the whole mechanism of diversification, written in one equation.

Plot every possible mix on a risk–return chart and the reachable region has a smooth left edge: the efficient frontier. For any level of risk it names the highest-return portfolio; for any target return it names the lowest-risk one. The far-left tip is the minimum-variance portfolio. Everything strictly inside the frontier is dominated — you could get more return for the same risk, so no rational investor would hold it.

Add a risk-free asset and the picture simplifies beautifully. Mixing cash with any risky portfolio traces a straight line from the risk-free point through that portfolio. The best such line is the one with the steepest slope — the highest Sharpe ratio — and it touches the frontier at a single spot: the tangency portfolio. This is the Capital Market Line, and its slope is the market price of risk.

The startling conclusion (Tobin's two-fund separation) is that everyone should hold the same risky portfolio — the tangency one — and then dial their total risk purely by splitting between it and cash. A cautious investor lends (holds cash); an aggressive one borrows to lever it up. This logic, extended to the whole market, becomes the Capital Asset Pricing Model and earned Markowitz, Sharpe and Miller the 1990 Nobel. Its limitation is that it needs estimates of returns and covariances, and those are noisy — which is exactly what the scenario cloud is hinting at.

04

Research note

Two-asset variance and the tangency weights.
RESEARCH NOTE
For weight w in A (and 1−w in B), return is linear but risk is not:
The cross-term 2w(1−w)ρσ_Aσ_B is what diversification exploits; the minimum-variance weight is
With a risk-free rate r_f, the tangency (max-Sharpe) portfolio maximises
solved by w ∝ Σ⁻¹(μ − r_f·𝟙). The Capital Market Line runs from (0, r_f) through it with slope equal to that maximal Sharpe ratio. Source: Markowitz, Portfolio Selection, J. Finance (1952); Sharpe (1964); Tobin (1958).
01

Drive it — how bad is a bad day?

A live Monte-Carlo rains down thousands of simulated one-period P&L outcomes into the histogram. Drag the confidence line left–right (or use the slider): the shaded tail is the worst 1−c of outcomes. VaR is the loss you won't exceed with confidence c; expected shortfall is the average loss when you do.
DRIVE IT
initialising…
CONFIDENCE  c95%
HORIZON1 day
PORTFOLIO VALUE$1.0M
ANNUAL VOL  σ20%
ANNUAL DRIFT  μ8%
VaRc
empirical loss
EXP. SHORTFALL
avg tail loss
DRAWS
0
simulated
The dashed gold curve is the parametric Normal VaR from the closed form; the shaded bars are the empirical distribution from the seed-driven simulation. Switch to t₄ and watch the empirical tail poke out past the Normal line — that gap is model risk.
02

Walkthrough

Find the edge of the tail.
WALKTHROUGH
1
Let the draws rain in. A bell shape builds up — most days cluster near a small gain, but the left side stretches into losses. The histogram is the shape of the portfolio's randomness, sampled outcome by outcome.
2
Read the shaded tail at 95% confidence: the VaR card is the loss the red line sits at. Interpretation: "on 95% of days we lose no more than this." Nudge the horizon to 10 days and watch VaR grow by roughly √10 — risk scales with the square root of time.
3
Drag the confidence line toward 99%. The line marches left into the thinner tail and VaR jumps — you're now asking about rarer, worse days. Compare VaR with expected shortfall: ES is always worse, because it averages the whole tail beyond the line, not just its edge.
4
Switch from Normal to fat tails (t₄). The bell keeps almost the same middle, but the empirical tail now pokes past the dashed Normal curve. A Normal model would have under-reported the risk — precisely the blind spot that detonated in 2008.
AHA
VaR compresses a whole future into one honest sentence — "how bad, how often" — but its honesty is only as good as the tail you assume. Get the shape of the rare days wrong and the number lies with a straight face.
03

Explanation

Quantiles, expected shortfall, and why tails matter.
EXPLANATION

Value-at-Risk answers a deceptively simple question: over some horizon, what loss will I not exceed with a given confidence? At 95% one-day VaR of $32,000, you're saying that on 95 days out of 100 the loss stays below $32k — and on the other 5, it doesn't. Mathematically VaR is just a quantile of the loss distribution: draw the histogram of outcomes and slice off the worst (1−c) fraction; the cut point is the VaR.

There are three ways to get it. The parametric method assumes returns are Normal and reads the quantile straight off the formula VaR = −(μ + z·σ). The historical method just re-orders past returns and reads off the percentile. The Monte-Carlo method — the one running here — simulates thousands of scenarios from a chosen model and takes the empirical quantile. More flexible, but only as trustworthy as the model you sample from.

VaR has a famous flaw: it tells you the threshold of the tail but nothing about how deep it goes. Two portfolios can share a VaR while one occasionally loses ten times more. Expected Shortfall (also called CVaR or conditional VaR) fixes this by averaging all losses beyond the VaR line. It is a coherent risk measure — crucially, it rewards diversification instead of occasionally punishing it — which is why Basel bank regulation shifted from VaR to Expected Shortfall.

The deepest lesson is about tails. Real market returns are leptokurtic — fat-tailed — so extreme days happen far more often than a Normal bell predicts. A 5-sigma daily move should be a once-in-millennia event under the Normal; markets deliver them every few years. Switching this sim to a Student-t makes the point visible: the same middle, but a tail that reaches out past the Normal line. Much of quantitative risk management is the humble admission that you don't really know the shape of the worst day — so you stress-test, backtest, and hold capital against being wrong.

04

Research note

The quantile, the √t rule, and expected shortfall.
RESEARCH NOTE
Parametric VaR at confidence c over horizon h days, with z_c = Φ⁻¹(1−c) (e.g. −1.645 at 95%):
Independent daily returns make risk scale as √h — the "square-root-of-time" rule the horizon slider demonstrates.
VaR is a quantile; Expected Shortfall averages the tail beyond it and is coherent (sub-additive):
For a Normal loss, ES has the closed form ES = μ_h·(−1)+σ_h·φ(z_c)/(1−c), always exceeding VaR. Sources: Jorion, Value at Risk (2006); Artzner et al., Coherent Measures of Risk (1999); Basel FRTB (2019).
Idea #45 of the maths-visual-teaching series · Black–Scholes · Markowitz frontier · Monte-Carlo Value-at-Risk · every curve computed live from the real formulas, shared market seed, no data faked.