Companion code and frozen result artifacts for the QuantInsti guest article
by Mikhail Makeev (founder of AlphaAI):
SEC Form 4 Insider Purchases in Python: A Filing-Date Event Study with Free
EDGAR Data
(published 2026-08-25). The article was written against release v1.0.0 of
this repository; the executed notebook also opens directly in
Colab.
The pipeline builds C-suite code-P purchase events from the SEC's free insider-transactions data sets (2022Q1–2026Q2), validates fill prices and corporate actions against Yahoo-sourced daily data, aggregates to one issuer × filing-day signal, and runs a filing-date event study with two-way clustered inference and matched placebo panels.
code/— pipeline scripts (build_events2.py→event_study3.py) plus data acquisition and figure/notebook generatorstests/— unit tests for the funnel, acquisition caching and the studydata/study3/— frozen canonical results,manifest.jsonwith input SHA-256 hashes, and a README describing each artifactdata/sec_input_manifest.json— SHA-256 manifest of the 18 SEC quarterly ZIP archives the study consumedform4_event_study.ipynb— executed companion notebook (artifact mode: verifies the script hash and persisted invariants againstdata/study3/)figs/— the article's figures, generated bycode/make_figures.py
python3.12 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt
make testRuns the unit tests and the study's synthetic self-tests against the frozen
artifacts in data/study3/.
The large inputs (SEC ZIPs ~200 MB, daily price matrices) are not redistributed here; the scripts download them:
make download-sec # 18 SEC archives, verified against the manifest
make build-events
.venv/bin/python code/download_prices2.py
.venv/bin/python code/download_splits.py
.venv/bin/python code/event_study3.py --placebo-panels 200
make figures
.venv/bin/python code/make_notebook.py --executeYahoo-sourced prices are fetched via yfinance and are subject to the data
source's terms; a fresh acquisition is not guaranteed to reproduce the frozen
numbers bit-for-bit (upstream history can change — that is exactly why the
frozen manifest exists). The SEC asks automated clients to identify
themselves and respect fair-access limits; set your own contact in the
download scripts before running them.
The study is an observational, conditional-sample event study. It is not
investment advice, not a trading strategy, not a backtest with costs, and
not a causal estimate. The article and data/study3/manifest.json state the
estimand and its limitations precisely.