A pandas pipeline that turns raw daily price files into a clean table, a monthly signal and a backtest, with a test that catches any peek at the future.
Download ten years of daily prices for 20 large NYSE and Nasdaq stocks and two LSE stocks, plus FRED's daily pound-to-dollar rate (DEXUSUK).
Load them into one long table, pivot to dates down and stocks across, join the two trading calendars by date, and forward-fill gaps of at most three days.
Convert the LSE prices from pence to dollars, then print every daily move over 40% and explain each one as a split, a data error or real news.
Compute daily returns, 20-day rolling volatility and month-end returns, and rank the stocks each month on the past 12 months' return, skipping the latest month.
Write a vectorised backtest in about 20 lines that holds the top five and shorts the bottom five, with positions shifted one month.
Write a truncation test: rebuild the signals from data cut at 20 random dates, and check that every signal up to each cut is unchanged.
How you'll know it worksThe truncation test passes at all 20 cut dates and fails when you delete the shift on purpose, and the pipeline runs in under a second once the files are loaded.
Python with pandas, NumPy and matplotlib. You download the price CSVs yourself from a free source such as Stooq or Yahoo Finance; FRED's data is free. Uses lessons 02 to 10.
Project: A price pipeline with no look-ahead
From insideout, Python for Market Data: A pandas pipeline that turns raw daily price files into a clean table, a monthly signal and a backtest, with a test that catches any peek at the future.
Steps:
1. Download ten years of daily prices for 20 large NYSE and Nasdaq stocks and two LSE stocks, plus FRED's daily pound-to-dollar rate (DEXUSUK).
2. Load them into one long table, pivot to dates down and stocks across, join the two trading calendars by date, and forward-fill gaps of at most three days.
3. Convert the LSE prices from pence to dollars, then print every daily move over 40% and explain each one as a split, a data error or real news.
4. Compute daily returns, 20-day rolling volatility and month-end returns, and rank the stocks each month on the past 12 months' return, skipping the latest month.
5. Write a vectorised backtest in about 20 lines that holds the top five and shorts the bottom five, with positions shifted one month.
6. Write a truncation test: rebuild the signals from data cut at 20 random dates, and check that every signal up to each cut is unchanged.
How you'll know it works: The truncation test passes at all 20 cut dates and fails when you delete the shift on purpose, and the pipeline runs in under a second once the files are loaded.
Runs on: Python with pandas, NumPy and matplotlib. You download the price CSVs yourself from a free source such as Stooq or Yahoo Finance; FRED's data is free.
Help me build this on my machine, one step at a time. Ask what I've tried first, give hints before full answers, and check my work against "How you'll know it works".