feat(insights): read-only insights + journaling reporting surface - #149
Merged
Conversation
Adds a strictly read-only `keel insights` command group -- `summary` (per-rule promotion-gate distance projected off `paper.track_record`/`strategy.promotion`, plus an account-level view of `gather_status`) and `journal` (a filterable, fee-honest trade journal off `trade_outcomes`, enriched with R-multiples where a matching paper trade can be found). Both support `--json` (no trailing prose) and the shared DISCLAIMER footer in human mode. Removes the unused Phase-4 `insights` stub command that this supersedes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two render-only fixes from independent review, no data-layer changes: - render_journal's "showing N of total_count closed trades" line counted --include-open's appended outcome="open" rows in N, so it could read e.g. "showing 4 of 3 closed trades". N now excludes open rows and an "(+K open)" suffix is appended when any were shown. - render_summary/render_journal now quantize Decimal money/ratio fields to 2dp for human display (via a shared _quantized/_money/_ratio helper that passes non-finite Decimals and sentinel strings through unchanged). --json is untouched -- json.dumps(..., default=str) still emits full precision -- and gate.blocking_reasons stays verbatim from promotion.can_promote, as intended. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jul 25, 2026
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.
What
Adds a read-only insights/journaling reporting surface — a pure view over the existing
keel.db, in the same spirit askeel tui. Turns the slow, months-long paper-forward evidence accrual into something legible.Two subcommands under a new
keel insightsgroup:keel insights summary [--json] [--rule KIND] [--mode paper|live]— per-rule track record (n, win rate, R:R, expectancy, profit factor, max DD), an account/drawdown summary projected fromgather_status, and a "distance to the promotion gate" view: how many more trades and which floors each paper rule still needs before it could be promoted to live.keel insights journal [--json] [--rule] [--asset] [--limit] [--since] [--until] [--include-open]— chronological per-trade log with fee-honest net P&L, R-multiples, win/loss/open/scratch outcome, and DCA rows flagged "no stop — excluded from R/expectancy."Design
Repositorygains no new methods — every read goes through existingget_rules/get_trade_outcomes/track_record/gather_status.can_promote+floor_for_class(promotion_class_of(rule))verbatim — so thetrend_followfloor (min_trades=100) is read, never hardcoded.keel/commands/status.py/tui.py.Decimalthroughout;--jsonis validjson.loads-able (full-precision Decimals viadefault=str, no disclaimer footer); human render quantizes money/ratios to 2dp.Tests
tests/commands/test_insights.py— 31 new tests (empty-DB-first, gate distance, DCAr_multiple=None,--limitpre-count,--include-opencount line, small-sample note, ratio quantization,--jsonvalidity for both subcommands). Full suite: 1597 passed, ruff clean.Review
Designed (Opus), built TDD (Sonnet), then reviewed end-to-end by an independent fresh-context Opus agent. Review found and this branch fixes: (1) journal count line was counting open rows as "closed" (
showing N of M), (2) full-precision Decimal leaking into the human render, plus (3) the missing regression test. Verdict after fixes: read-only airtight, gate/promotion reuse correct.🤖 Generated with Claude Code