Notebooks
The notebooks contain the Python code for the topics in the notes. Each one links to its Quarto source, which you can download and run. Notebooks that use WRDS data need a WRDS account; the others use free public data.
Building with AI
Python, Data and WRDS Loading data from WRDS and public APIs, returns, plots and a first regression.
Neural Networks and Language Models
Reading Handwritten Digits The digits banks’ check readers learned from: a linear classifier and a network with one hidden layer, what their weights look like, and the digits they still get wrong.
Predicting Mortgage Denials Public HMDA data on mortgage applications: a logit and a network predicting denials, the underwriting cliff the network finds, and what the data leave out.
Pricing Options with Neural Networks Training a network on option prices from OptionMetrics and comparing it with Black-Scholes.
Predicting Returns with a Neural Network Forecasting the equity premium with the Welch and Goyal predictors, re-estimating a regression and a network every year from 2000 to 2025, and seeing why both lose to the historical average.
Text as Data Turning FOMC statements into numbers with word counts and embeddings, mapping a decade of Fed communication, and searching statements by meaning.
Blockchain
Proof of Work Example A minimal blockchain: hashing, mining, verifying blocks, and what happens when a block is changed.
Mining Economics Miner revenue, hash rate and difficulty around the Bitcoin halvings.
A Market Index for Cryptocurrencies A value-weighted crypto index, coin betas, and how crypto moves with the stock market.
Decentralized Finance
Trading Against an Automated Market Maker Simulating a constant-product pool, arbitrage, and liquidity providers’ fees against their losses.
Liquidation Cascades How falling collateral prices trigger liquidations, and how liquidations can push prices further.
The USDC Depeg Hourly USDC prices around the Silicon Valley Bank failure in March 2023.