feat: backtest excursions by horizon and outcome by feature - #104
Merged
Merged
Conversation
Each backtest window gains two tables. Excursions by horizon: median MFE and MAE within 5 / 10 / 20 / 40 / 60 bars after the fill, in percent and in ATR, with the share of signals at target, at the stop or neither by then, overall and per pattern. Outcome by feature: traded signals bucketed on fixed edges by features measured at the scan day from the history the scan saw (close vs SMA200, SMA50 vs SMA200, SMA200 change over 40 bars, distance from SMA200 in ATR, stop and target distance in ATR, bars from the last anchor to the breakout) plus volume ratio, risk %, reward:risk and breakout age, each with N, hit rate, mean and median R and the month-block interval. Every replay row carries the features; nothing is added to scan.Signal or the nightly report. summarise_rows is the former inner function of breakdown, now shared with the bucket table. Closes #92. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements #92 on top of #103.
row_features): close vs SMA200, SMA50 vs SMA200, the SMA200's change over 40 bars, distance from the SMA200 in ATR, stop and target distance in ATR, and bars from the pattern's last anchor (handle low, right shoulder, point 5, read fromnotesthe wayscan._drop_reasondoes) to the breakout. Nothing is added toscan.Signal,signals.jsonor the nightly report.FEATURE_BUCKETS) by those features plus volume ratio, risk %, reward:risk and breakout age, each bucket with N, hit rate, mean and median R and the month-block interval; empty buckets omitted, rows without a value counted as missing. Fixed edges keep two replays, or the two windows of a--split, comparable bucket by bucket.summarise_rowsis the former inner function ofbreakdown, now shared with the bucket table. JSON output gainsfeaturesandhorizonsper window.Verified locally:
ruffclean, 124 tests pass (4 new), and a 30-ticker--period 5y --days 250 --bars 500run renders both tables and writes the JSON with the feature keys on every row.Related Issues
Closes #92
Checklist
scan.py(no thresholds changed)python -m pytest -q)docs/wiki/CHANGELOG.mdupdated🤖 Generated with Claude Code