Repository navigation
sim report: word an empty-side Avg win/loss (R) by counting the R sample (#1004) - #1007
Merged
Merged
Conversation
…does (#1004) The edge table's `Avg win (R)` / `Avg loss (R)` printed the engine's empty-side `0` as `0.000`, which reads as a measured flat side. They now print `n/a (no wins yet)` / `n/a (no losses yet)` through `undefined_reading` and a new shared `insights.avg_r_reason_of`, whose side is decided by counting the R sample (`n_wins_r` / `n_losses_r`), not by reading a zero -- so a side whose trades truly average 0 R keeps `0.000`. A row with no R stays a bare `n/a`. `BacktestResult`, `pool_stats` and the gates are unchanged; insights stays a lazy import in the report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eaitbrahim
commented
Oct 14, 2026
eaitbrahim
left a comment
Contributor
Author
There was a problem hiding this comment.
Review of #1007. The counting-over-reading logic, the bare n/a for no-R rows, the lazy import, and the unchanged engine values / pool_stats all check out. The tests pin values per row, and the fixtures are asserted to reach each case. The 0.000 zero-R sides and the unrisked-sample no trades yet case would catch the obvious mutants. One false docstring claim, inline.
…the empty-side words come from (#1004) Co-Authored-By: Claude Opus 5.5 <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.
Closes #1004
What
The
keel simedge table'sAvg win (R)/Avg loss (R)cells printed the engine's empty-side0as0.000, which reads as a measured flat side. They now print:n/a (no losses yet)n/a (no wins yet)n/a (no wins yet)n/a (no losses yet)0.0000.000n/an/aHow
keel/commands/insights.py: newavg_r_reason_of(stats, outcome), besideprofit_factor_r_reason_of. It decides the side by counting the R sample (n_wins_r/n_losses_r), never by reading the average, and reuses the existingNO_WINS_YET/NO_LOSSES_YET/NO_TRADES_YETconstants. No new strings.keel/sim/report.py: new_avg_r_cell, built the same way as_profit_factor_r_cell: baren/awith no R, thenundefined_reading(reason), otherwise_r_cell(value).keel.commands.insightsis still imported lazily, so the existing subprocess import-isolation test keeps passing.BacktestResult,stats._r_aggregates,promotion.pool_statsand the gates are unchanged.pool_statsstill multiplies by the engine's 0.Tests (TDD)
test_edge_section_words_an_empty_side_average_r_by_counting_the_r_samplefails on main (('wins:A', '1.500', '0.000')) and passes here. It covers all-wins, all-scratch, all-losses, a hand-built zero-R win plus zero-R loss (to check that sides are counted, not read), both sides, no trades, and the pooled row.test_avg_r_reason_of_an_empty_r_sample_is_no_trades_yet_on_either_sidecovers the empty-sample and all-unrisked branch.cmpand each killed: reading the average instead of the count (both sides), a swapped count, dropping the empty-sample branch, dropping the no-R guard, reverting the loss cell, and an outcome-blind value.ruff check,ruff format --checkand baremypyare clean.🤖 Generated with Claude Code