warming up your workspace

Quantitative Finance with Python

Build quant finance from scratch: returns, bonds, portfolios, risk, options, the Greeks, and a backtester.

11 projects, 275 hands-on levels, run in your browser.

Syllabus

  • Foundations: code through finance: Learn Python output, variables, types, comparisons, loops, lists and functions through small finance-themed examples. Trace inputs and outputs before moving into the numerical projects.
  • Financial Foundations: Calculate simple and log price returns, combine them into cumulative growth, and compound or discount amounts using explicit rate conventions. Practice with a synthetic price series and finish with a report of endpoint return, CAGR and mean daily return.
  • The Time Value of Money: Place signed cash flows on a timeline and value them under explicit discount and reinvestment assumptions. Build annuity and perpetuity models, NPV, bracketed IRR and whole-period payback, then combine them in a report for an illustrative investment forecast.
  • Fixed Income and Bonds: Price a plain fixed-rate bond from promised coupons and redemption, infer its yield with a validated bracket, and measure local yield sensitivity with duration, DV01 and convexity. Compare shock estimates with repricing and assemble a numerical report under explicit annual coupon-date assumptions.
  • Risk and Statistics: Measure return dispersion, explore normal and lognormal models, and calculate covariance and correlation between assets. Estimate historical and normal-model loss thresholds, with explicit assumptions and time horizons. Combine annualized volatility, daily tail statistics and a Sharpe ratio into a small report for synthetic daily returns.
  • Portfolio Theory: Calculate portfolio weights, expected return and covariance-based risk. Explore two-asset allocations, sample portfolios and solve the net-budget minimum-variance problem. Compare a sampled Sharpe search with equal weight, then assemble allocation vectors for four illustrative assets with explicit assumptions and constraints.
  • Stochastic Models of Prices: Build random walks, sampled Brownian motion and constant-parameter geometric Brownian price paths. Use Monte Carlo samples to estimate means, event probabilities and a discounted European call payoff. Finish with a reproducible terminal-price report that separates outcome dispersion from uncertainty in the estimated mean.
  • Options Pricing: Calculate option payoffs and spot moneyness, then relate matching European call and put prices through parity. Build a binomial terminal sum and Black-Scholes call/put formulas under explicit assumptions. The capstone compares an analytic call price with Monte Carlo, estimates vega and recovers implied volatility through validated bisection.
  • The Greeks and Hedging: Compute local Black-Scholes sensitivities for European options on a stock without dividends. Connect their units to signed position exposure, stock hedging and price-change approximations. Assemble a call-risk summary with explicit model limits.
  • Time Series and Trading Signals: Build trailing price indicators, historical volatility estimates and descriptive dependence statistics. Define signal states, exposure units and return timing, then assemble an inspectable unit-weight crossover pipeline on synthetic data.
  • Capstone: Backtesting a Strategy: Track compounded equity and historical drawdowns, calculate defined performance metrics, compare matched benchmarks and model proportional trading costs. Assemble an inspectable single-asset crossover backtest with explicit execution and risk limits.

Key concepts

  • Black-Scholes: A model pricing European options from the spot, strike, time, rate, and volatility, assuming lognormal prices.
  • Compounding: Earning returns on prior returns; value grows as principal*(1+r)^n, the exponential engine of long-term growth.
  • Convexity: The curvature of the price-yield relationship; a second-order correction to duration that matters for large rate moves.
  • Duration: The sensitivity of a bond's price to interest rates: the price-weighted average time to its cash flows. Longer duration means more rate risk.
  • Portfolio variance: The variance of a portfolio's return, which depends on each asset's variance and the covariances between them; diversification lowers it.
  • Present value: Today's worth of a future cash flow, discounted by a rate: PV = CF / (1+r)^n. The basis of all valuation.
  • Return: The gain or loss on an investment over a period, as a fraction of the starting value. Log returns add over time.
  • Sharpe ratio: Excess return per unit of volatility, the standard risk-adjusted performance measure. Higher is better.
  • The Greeks: Sensitivities of an option's price: delta (to spot), gamma (to delta), vega (to volatility), theta (to time), rho (to rates). Used to hedge.
  • Value at Risk (VaR): The loss not expected to be exceeded at a given confidence over a horizon (e.g., 95% 1-day VaR). Parametric VaR uses the normal distribution.
  • Volatility: The standard deviation of returns, a measure of risk. Scales with the square root of time.