M28 Python Lab & Python Library Atlas

What you will learn: a separate, self-contained section — learn Python from zero, then master the libraries used across finance, quant research, ML and trading systems. Every lesson has runnable code in the browser (Pyodide) and a downloadable notebook. Shown in Part A after M26 and before M04 Statistics.

Learn first: M18 Mathematics for Trading

Module exam

When you have finished the topics, a timed exam on the whole module earns a certificate you can share and anyone can check.

See the module exam

Chapters

  1. C01 Setup & Tooling Chapter quiz

    • Installing Python; versions and the interpreter · Coming soon
    • Virtual environments: venv, conda, uv/poetry; pip basics · Coming soon
    • Jupyter, VS Code and running scripts · Coming soon
    • Project layout and the "requirements" file · Coming soon
    • Getting help: docs, `help()`, error messages · Coming soon
  2. C02 Language Basics Chapter quiz

    • Numbers, strings, booleans and None · Coming soon
    • Variables, operators and f-strings · Coming soon
    • Conditions: if / elif / else · Coming soon
    • Loops: for, while, break, continue, enumerate, zip · Coming soon
    • Input, output and formatting numbers (currency, percent) · Coming soon
  3. C03 Data Structures Chapter quiz

    • Lists, tuples, sets and dictionaries · Coming soon
    • Slicing, sorting and comprehensions · Coming soon
    • Nested structures and JSON-like data · Coming soon
    • Choosing the right structure (complexity in plain words) · Coming soon
    • Mutable vs immutable; copying pitfalls · Coming soon
  4. C04 Functions, Modules & OOP Chapter quiz

    • Functions, arguments, defaults, *args/**kwargs · Coming soon
    • Scope, closures, lambda and higher-order functions · Coming soon
    • Importing modules and packages; writing your own · Coming soon
    • Classes and objects: Position, Order, Portfolio · Coming soon
    • Inheritance, composition and dataclasses · Coming soon
    • Generators, iterators and decorators · Coming soon
  5. C05 Standard Library for Finance Chapter quiz

    • datetime, zoneinfo, calendar: trading days and time zones · Coming soon
    • collections, itertools, functools · Coming soon
    • math, statistics, decimal and fractions (money precision!) · Coming soon
    • pathlib, os, csv, json, sqlite3 · Coming soon
    • random and seeds for reproducible simulations · Coming soon
    • logging, argparse, typing · Coming soon
  6. C06 Writing Reliable Code Chapter quiz

    • Errors and exceptions; defensive coding · Coming soon
    • Testing with pytest; test data for finance code · Coming soon
    • Type hints, linting and formatting · Coming soon
    • Debugging and profiling · Coming soon
    • Documentation, docstrings and style (PEP 8) · Coming soon
  7. C07 NumPy: Numerical Arrays Chapter quiz

    • Arrays, dtypes, shapes and broadcasting · Coming soon
    • Vectorised returns, cumulative products and rolling maths · Coming soon
    • Random numbers, Monte Carlo and the Generator API · Coming soon
    • Linear algebra: dot, solve, eig, svd · Coming soon
    • Pitfalls: NaN handling, float precision, views vs copies · Coming soon
  8. C08 pandas: Time-Series Data Analysis Chapter quiz

    • Series, DataFrame, index and dtypes · Coming soon
    • Reading/writing CSV, Excel, Parquet, SQL · Coming soon
    • Selecting, filtering, groupby, merge/join, pivot · Coming soon
    • Time-series: DatetimeIndex, resample, rolling, shift, expanding · Coming soon
    • Missing data, outliers and corporate-action adjustment · Coming soon
    • MultiIndex for multi-asset panels · Coming soon
    • Performance and memory tips; pitfalls (chained assignment, look-ahead via shift) · Coming soon
  9. C09 Visualisation Libraries Chapter quiz

    • Matplotlib: figure, axes, styling · Coming soon
    • seaborn: distributions, heatmaps, pair plots · Coming soon
    • Plotly and Bokeh: interactive charts · Coming soon
    • Candlesticks: mplfinance, Plotly, lightweight-charts · Coming soon
    • Altair and declarative charts · Coming soon
    • Visual design for honest charts (links to the dataviz principles) · Coming soon
  10. C10 SciPy & statsmodels: Statistics & Modelling Chapter quiz

    • scipy.stats: distributions, tests and fitting · Coming soon
    • scipy.optimize: minimise, root-finding, constraints · Coming soon
    • scipy.interpolate, signal and sparse · Coming soon
    • statsmodels: OLS, GLM, ARIMA, VAR, state-space · Coming soon
    • Diagnostics: residual tests, ADF, Ljung-Box, cointegration · Coming soon
    • arch: GARCH and volatility models · Coming soon
  11. C11 Market Data Libraries Chapter quiz

    • yfinance, pandas-datareader, OpenBB · Coming soon
    • Local-exchange data wrappers (e.g. NSE/BSE tools, jugaad-data) *(country pack)* · Coming soon
    • FRED/fredapi, Nasdaq Data Link and economic data · Coming soon
    • Alpha Vantage, Polygon, Tiingo, Twelve Data (paid/free tiers) · Coming soon
    • ccxt for crypto exchanges · Coming soon
    • Data quality: adjusted prices, splits, time zones, rate limits and licences · Coming soon
  12. C12 Technical Indicator Libraries Chapter quiz

    • TA-Lib: installation, functions and speed · Coming soon
    • pandas-ta and ta: pure-python indicators · Coming soon
    • Writing your own indicator (and verifying it against a library) · Coming soon
    • Indicator pitfalls: warm-up periods, repainting, look-ahead · Coming soon
  13. C13 Backtesting Libraries Chapter quiz

    • backtesting.py: a quick first backtest · Coming soon
    • vectorbt: vectorised research at speed · Coming soon
    • backtrader and zipline-reloaded: event-driven engines · Coming soon
    • bt and other portfolio-level back-testers · Coming soon
    • QuantConnect Lean and cloud platforms (overview) · Coming soon
    • Comparing libraries on the same strategy; common hidden biases · Coming soon
  14. C14 Portfolio, Performance & Risk Libraries Chapter quiz

    • quantstats, empyrical and pyfolio-reloaded: tear-sheets · Coming soon
    • PyPortfolioOpt, Riskfolio-Lib and skfolio: optimisation · Coming soon
    • cvxpy: convex optimisation from scratch · Coming soon
    • Risk: VaR/ES with numpy, scipy and arch · Coming soon
    • Factor models and attribution tools · Coming soon
  15. C15 Derivatives & Fixed-Income Libraries Chapter quiz

    • QuantLib-Python: curves, bonds, options, swaps · Coming soon
    • py_vollib / mibian: Black-Scholes, implied volatility, Greeks · Coming soon
    • Option-chain handling with pandas · Coming soon
    • Monte Carlo pricing with numpy/numba · Coming soon
  16. C16 Machine-Learning Libraries Chapter quiz

    • scikit-learn: pipelines, estimators, cross-validation · Coming soon
    • XGBoost, LightGBM and CatBoost · Coming soon
    • Time-series CV, purged k-fold implementations · Coming soon
    • SHAP, permutation importance and interpretability · Coming soon
    • Optuna / hyperopt for tuning; MLflow for experiment tracking · Coming soon
    • sktime, tsfresh, tslearn, Prophet and darts for time series · Coming soon
  17. C17 Deep-Learning Libraries Chapter quiz

    • PyTorch: tensors, autograd, nn.Module, training loops · Coming soon
    • TensorFlow/Keras and JAX (overview) · Coming soon
    • PyTorch Lightning, pytorch-forecasting and GPU basics · Coming soon
    • Hugging Face transformers and datasets · Coming soon
    • Reproducibility: seeds, determinism and checkpoints · Coming soon
  18. C18 Reinforcement-Learning Libraries Chapter quiz

    • Gymnasium: building a custom trading environment · Coming soon
    • Stable-Baselines3: PPO, A2C, SAC, DQN · Coming soon
    • FinRL and other finance-RL frameworks · Coming soon
    • Ray RLlib (overview) and evaluation tooling · Coming soon
  19. C19 NLP & LLM Libraries Chapter quiz

    • NLTK, spaCy and text cleaning · Coming soon
    • Transformers: FinBERT and sentence embeddings · Coming soon
    • Scraping and feeds: requests, BeautifulSoup, feedparser, newsapi clients · Coming soon
    • LLM SDKs, tool-calling and structured output · Coming soon
    • Agent frameworks: LangChain/LangGraph, LlamaIndex (overview) and building without a framework · Coming soon
    • Vector stores and retrieval over filings · Coming soon
  20. C20 Performance & Big-Data Libraries Chapter quiz

    • numba and Cython: speeding up loops · Coming soon
    • polars and DuckDB: fast analytics · Coming soon
    • dask, ray and multiprocessing · Coming soon
    • pyarrow, Parquet and memory-mapped files · Coming soon
    • Choosing between pandas, polars and DuckDB · Coming soon
  21. C21 Apps, Dashboards & Services Chapter quiz

    • Streamlit, Dash and Gradio: dashboards in minutes · Coming soon
    • FastAPI and Flask: serving models and strategies · Coming soon
    • Jinja reports, PDF and Excel export (openpyxl, xlsxwriter, reportlab) · Coming soon
    • Packaging an app: Docker and deployment basics · Coming soon
  22. C22 Broker, Exchange & Execution APIs Chapter quiz

    • Broker SDKs (e.g. Zerodha Kite Connect, Upstox, Angel One, Dhan; Alpaca, Interactive Brokers) *(country pack)* · Coming soon
    • ib_insync / ib_async and streaming order updates · Coming soon
    • FIX with QuickFIX (overview) · Coming soon
    • Order wrappers: idempotency, retries, kill-switch · Coming soon
    • Paper-trading sandboxes vs live accounts · Coming soon
  23. C23 Databases & Messaging Libraries Chapter quiz

    • sqlite3, SQLAlchemy and psycopg · Coming soon
    • TimescaleDB, ClickHouse and ArcticDB for time-series · Coming soon
    • Redis for caching and state · Coming soon
    • Kafka and message queues (overview) · Coming soon
    • Schema design and migration tools · Coming soon
  24. C24 Automation, Scheduling & Alerts Chapter quiz

    • cron, schedule, APScheduler · Coming soon
    • Workflow tools: Prefect and Airflow (overview) · Coming soon
    • Alerts: Telegram/e-mail bots · Coming soon
    • Monitoring: logging, health checks, retries · Coming soon
  25. C25 Quality, Packaging & Dev Tools Chapter quiz

    • pytest, hypothesis (property-based tests) · Coming soon
    • ruff, black, mypy and pre-commit · Coming soon
    • Packaging with pyproject, uv/poetry · Coming soon
    • Documentation with Sphinx/MkDocs · Coming soon
  26. C26 Library Selection Guide & Cheat Sheets Chapter quiz

    • Decision table: which library for which job · Coming soon
    • How to evaluate a library: maintenance, licence, community, speed, docs · Coming soon
    • Pinning versions, handling deprecations and breaking changes · Coming soon
    • Common library-conflict problems and fixes · Coming soon
    • One-page cheat sheets: NumPy, pandas, Matplotlib, scikit-learn, SQL · Coming soon
  27. C28 Debugging Finance Code: the Bug Clinic Chapter quiz

    • Look-ahead bugs via shift, rolling and resample · Coming soon
    • Units, annualisation and percent-vs-fraction errors · Coming soon
    • Time zones, calendars, holidays and missing data · Coming soon
    • Floating-point and money rounding · Coming soon
    • Silent merge/join errors and duplicated index values · Coming soon
    • A debugging routine: reproduce, isolate, test, fix, prevent · Coming soon
  28. C29 Coding Challenges Lab & Assessment Chapter quiz

    • Auto-graded challenge bank (easy / medium / hard) · Coming soon
    • Code-review exercises: find the flaw · Coming soon
    • Performance challenges: make it 100× faster · Coming soon
    • The Python Lab exam: timed practical test · Coming soon
    • Portfolio of solved challenges · Coming soon
  29. C30 Beyond Python: Other Languages & Tools Chapter quiz

    • R for statistics and time-series; when to prefer it · Coming soon
    • Julia, MATLAB and Excel LAMBDA in quant work · Coming soon
    • C++ and Rust for low-latency components (overview) · Coming soon
    • SQL, DuckDB and notebooks as part of a polyglot workflow · Coming soon
    • Calling other languages from Python · Coming soon
  30. C27 Python Projects (Capstone for the Section) Chapter quiz

    • Project 1: Download, clean and store daily prices · Coming soon
    • Project 2: Returns, risk and correlation dashboard · Coming soon
    • Project 3: Moving-average backtest and tear-sheet · Coming soon
    • Project 4: Portfolio optimiser with constraints · Coming soon
    • Project 5: Options pricer and Greeks calculator · Coming soon
    • Project 6: News-sentiment scraper and scorer · Coming soon
    • Project 7: Alert bot with scheduling · Coming soon
    • Project 8: Mini algo stack (data → signal → paper order → log) · Coming soon