Skip to content

Ch 21: AI for Finance - Introduction

Track: Advanced | Try code in Playground | Back to chapter overview

Read online or run locally

You can read this content here on the web. To run the code interactively, either use the Playground or clone the repo and open chapters/chapter-21-ai-for-finance/notebooks/01_returns_and_risk.ipynb in Jupyter.


Chapter 21: AI for Finance — Notebook 01 (Returns & Risk)

Before any model, get the measurements right: how to compute returns, and how to summarize risk with the Sharpe ratio and maximum drawdown.

What you'll learn

Topic Section
Simple vs log returns §1
Annualized volatility §2
The Sharpe ratio §3
Maximum drawdown §4

Time estimate: 3.5 hours


Key concepts

  • Simple returnp[t]/p[t-1] - 1; aggregates across assets.
  • Log return — additive over time; convenient for statistics.
  • Sharpe ratio — excess return per unit of volatility, annualized.
  • Maximum drawdown — the worst peak-to-trough loss; what investors feel.

Returns (simple for aggregation, log for stats), annualized volatility, the Sharpe ratio, and maximum drawdown are the vocabulary of financial performance. Get them right and the rest follows.

Run the full notebook in the chapter folder for code and outputs.


Generated by Berta AI