Cox-Ross-Rubinstein binomial model prices options via recombinant tree. More intuitive than Black-Scholes—shows exact paths and early exercise value.
u = e^(σ√dt), d = 1/u
p = (e^(r·dt) - d) / (u - d)
// Binomial option pricing
function binomial(S, K, T, sigma, r, n) {
const dt = T / n;
const u = Math.exp(sigma * Math.sqrt(dt));
const d = 1 / u;
const p = (Math.exp(r * dt) - d) / (u - d);
// Build price tree
const prices = [];
for (let i = 0; i <= n; i++) {
prices[i] = S * Math.pow(u, n - i) * Math.pow(d, i);
}
// Option values at maturity
let callVals = prices.map(s => Math.max(0, s - K));
let putVals = prices.map(s => Math.max(0, K - s));
// Backward induction
for (let i = n - 1; i >= 0; i--) {
for (let j = 0; j <= i; j++) {
const exercise = j === 0 ? Math.max(0, S * Math.pow(u, i - j) * Math.pow(d, j) - K) :
Math.max(0, S * Math.pow(u, i - j + 1) * Math.pow(d, j - 1) - K);
callVals[j] = Math.exp(-r * dt) * (p * callVals[j] + (1 - p) * callVals[j + 1]);
}
}
return callVals[0];
}