The notebook looks to buy QQQ after a decline that is large relative to its recent moves. Before entering, it calculates value at risk, or VaR, using the 10th percentile of the latest 20 returns. The rule buys when that loss estimate is below 2%. Original notebook
An entry the filter screened out
At the February 27, 2020 close, the decline met the buy condition and VaR was 2.87%. The code uses that value for the March 2 opening order. The portfolio without the filter bought. The portfolio with VaR stayed in cash. Across the sample, the filter screened out 62 of 194 days that met the buy condition.
What happened with the same rules and prices
I repeated the test in Docker from December 2019 to December 2024. The control uses the same dates, execution timing and $1 per order.
| Version | Net return | Maximum drawdown |
|---|---|---|
| With the VaR filter | +56.50% | −4.88% |
| With the price condition alone | +40.66% | −23.08% |
The 2% cutoff applies to the estimate the rule reads. On February 25, 2020, the VaR used by the portfolio was 1.63% and its return that session was −2.72%. Across the sample there were four days with losses greater than 2%. The PDFs document the filtered version and its close-to-close comparison with SPY.
What the engine measured
Cumulative return
Worst drawdown from a peak
Ratios, with their 95% interval
- Strategy
- Reference: SPY
- Resampling range or 95% interval
Source: technical report of the test, linked below. Prices exclude dividends; the resampling uses the same historical series.
The technical report adds the margin of error to these figures. The Sharpe of the strategy was 1.40, with a 95% interval of 0.49 to 2.21. Against SPY, the average annual difference was −5.05%, with a t-statistic of −0.61: it cannot be told apart from zero.
When the same returns were resampled in blocks, the cumulative return fell between 24.75% and 99.79% in the central 90%, and the worst drawdown between 3.76% and 11.54%. What that resampling measures is explained in Block bootstrap and permutation Monte Carlo.
Test reports

How to read this document is explained in the guide to the technical report.
How to read both documents is in the guide to the technical report.
See Strateva's services if you want to measure which entries a filter changes in your strategy.