fix(verify): drop unmatched still-open TV rows from coverage denominator#69
Merged
Merged
Conversation
TV 'List of Trades' exports emit a mark-to-market row (exit Signal=='Open') for any position still open at the backtest-window end. verify_corpus counted these in the coverage denominator (tv_cov_denom = tv), but the engine reports only CLOSED trades, so a position it also holds open at end has no closed row to match -> coverage was penalised for a non-divergence. verify-engine-local's compare() (tv_still_open) and countAbsDelta already exclude these; this aligns the canonical coverage gate with them. MATCHED-AWARE (not blanket): a still-open TV row is dropped from the coverage denominator ONLY when it is UNMATCHED. A matched open row (engine opened AND closed the position for real past the window -> align_by_time pairs it on entry) stays counted. Touches ONLY the coverage denominator -- not parse_trades, the entry-time matcher, tv_cmp, or the count/entry/exit/pnl gates -- so it cannot paper over closed-trade divergences (the count gate still bites: e.g. grid bots with real post-window count deltas stay strong, not excellent). Adjudicated by a fresh-context design review: corpus-clean (0 tier drops across 251 corpus strategies, 115 of which carry open rows) vs the rejected blanket form (12 excellent->strong regressions). Regrades ~17 scraper grid/DCA bots moderate/strong->excellent whose only gap was unreproduced OPEN grid levels. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Problem
TV 'List of Trades' exports emit a mark-to-market row (exit
Signal=='Open') for any position still open at the backtest-window end.verify_corpus.pycounted these in the coverage denominator, but the engine reports only closed trades — so a position it also holds open at end has no closed row to match, and coverage was penalised for a non-divergence. The sibling harnessverify-engine-local.py(tv_still_open) andcountAbsDeltaalready exclude these; this aligns the canonical coverage gate with them.Fix (matched-aware, coverage-denominator only)
A still-open TV row is dropped from the coverage denominator only when it is unmatched. A matched open row (engine opened AND closed the position for real past the window —
align_by_timepairs on entry) stays counted. Touches only the coverage denominator — notparse_trades, the entry-time matcher,tv_cmp, or the count/entry/exit/pnl gates — so it is structurally monotonic (can only raise coverage) and cannot paper over closed-trade divergences.Validation (fresh-context R7)
abs=0identically before/after on every affected strategy.🤖 Generated with Claude Code