Python and Data Analysis for Quantitative Trading: Time Series, Returns, Rolling Windows and a Sound Backtest (PDF)
A hands-on educational guide to using Python (pandas) for quantitative trading: hold price data by date, compute returns, volatility and rolling indicators, and build a backtest that does not look into the future.
Inside (51 pages, 12 chapters): why Python and what the book builds, price data and what can be wrong with it, series, dates and the index, returns in code, rolling windows, changing frequency, from signal to return without cheating, performance metrics in code, many stocks (DataFrames and portfolios), a Shariah screen in code, testing your own pipeline for look-ahead, self-test, glossary and sources.
You do not need to be a programmer, but you should be willing to type short programs and read what they print. Every number in the book was produced by running the code shown, on a synthetic price series (Python 3, pandas 2.3.3, NumPy 2.2.6).
Scope: long-only strategies in shares that pass Shariah screening, bought with owned cash, no leverage, no short selling, no derivatives. This book is not a fatwa; consult a qualified Shariah authority.
Honest notes: educational only. It gives no recommendation to buy or sell any security, guarantees no profit, and loss is always possible. Prices in the examples are synthetic, not market data. Digital PDF.
By Mohammed Ahmed Said Hassan (محمد احمد سعيد حسن), CMA | MAS Trading.