Two anomaly detectors, agreeing just enough to be honest
Isolation Forest and a PCA reconstruction-error autoencoder under strictly causal walk-forward refit. They agree on a small core of known stress dates, and the flags are diagnostic, not tradable.
00Overview
Two unsupervised detectors look for anomalous trading days from completely different angles. Where they agree, you have something worth a second look. Where they disagree, you have a reminder that anomaly detection without ground-truth labels is description, not prediction.
01Method
- Isolation Forest (Liu, Ting and Zhou 2008): score is the negative of sklearn's score_samples.
- PCA reconstruction-error autoencoder (Sakurada and Yairi 2014): score is reconstruction MSE, no torch.
- Anchored walk-forward refits the scaler, both detectors and all thresholds on the train slice only.
- A .shift(1) chokepoint guarantees zero lookahead into the out-of-sample folds.
02The honest test
The two detectors agree on a small core of genuine macro-stress dates (March 2020, Q4 2018, the 2022 selloff), but day-level agreement is modest (Jaccard 0.50) and precision against a naive |z| > 3 proxy is low (0.04). With no curated ground-truth labels, no alpha is claimed: the flags are a diagnostic.