Skip to content

feat: richer pnl reporting + CLI ergonomics polish - #7

Merged
tanem merged 32 commits into
mainfrom
feat/cli-read-views-and-reporting
Jun 17, 2026
Merged

feat: richer pnl reporting + CLI ergonomics polish#7
tanem merged 32 commits into
mainfrom
feat/cli-read-views-and-reporting

Conversation

@tanem

@tanem tanem commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

Two complete chunks of the read-views-and-reporting expansion (design: docs/superpowers/specs/2026-06-15-cli-read-views-and-reporting-design.md).

CLI ergonomics & polish bundle — drops the --json alias so --format table|json|csv is the single spelling, adds Examples sections to command help, enriches --version with commit and build date, adds --quiet/-q to silence stderr warnings, right-aligns numeric table columns via a manual table writer, shows the account currency in the pnl summary footer, and adds sign-based --color output (auto/always/never with TTY detection honouring NO_COLOR/TERM=dumb).

Phase 2 — richer reporting — splits net P&L into trade-profit/commission/swap/fee subtotals across every output, adds expectancy plus average and largest win/loss and a realised-P&L max drawdown to the summary, surfaces all of it in JSON and (rows-only) CSV, and replaces the old single-line summary with a two-group performance/breakdown block in table and JSON output.

Full-precision sums throughout; all display rounding stays in the render layer. README and CLAUDE.md are updated to match.

Test Plan

  • go test ./... passes
  • CI green across ubuntu/macos/windows (incl. -race)
  • Eyeball the regenerated pnl_table.golden diff for alignment and the two-group block
  • Spot-check pnl --format json|csv component subtotals sum to net
  • Confirm --color auto detects a TTY and respects NO_COLOR

🤖 Generated with Claude Code

tanem and others added 30 commits June 15, 2026 13:40
Spec for rounding out the CLI's read-views (positions, trades,
cash-flows), deeper P&L reporting (expectancy, avg/largest win-loss,
max drawdown), a P&L component breakdown (trade profit / commission /
swap / fee) driven by the NZ IR3B tax workflow, --by symbol|magic, a
--format table|json|csv contract, help/exit-code fixes, a mixed-currency
guard, and a deal-time timezone verify-and-document task. Flags-only and
no-config stance kept and recorded as a deliberate decision.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… plan

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…t 1)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… guard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Closes coverage gaps flagged by the Task 7 and final code reviews.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Brings the British/Commonwealth English convention and the privacy/audience
sweep (PR #6) onto the feature branch, plus the targeted-coverage-gaps tests.

Conflict resolutions:
- main.go: keep the --version alias and use main's resolveVersion() for the
  version string (the alias resolves the same way as the subcommand).
- cli_test.go: keep both sides' added tests (Phase 1 format/help/mixed-currency
  tests and main's coverage tests); no name collisions.
- e2e_test.go: --version is an alias of version, so its smoke assertion now
  checks the stable surrounding format rather than the literal "dev".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nomics review

Brings the branch-only recent docs into line with the conventions main
adopted in PR #6 (British/Commonwealth English; jurisdiction-neutral
examples):
- reporting spec: drop the NZD-specific reporting-currency example.
- new CLI ergonomics & feature review (approved; recommendations accepted,
  nothing scheduled for build), written under the same conventions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sequenced TDD plan for the approved ergonomics review's self-contained
bundle: drop the --json alias, help examples, richer --version, --quiet,
right-aligned numeric columns (manual table writer), currency footer, and
sign-based colour. Independent of the unmerged reporting roadmap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both pnl and accounts commands now accept --quiet (-q) to silence
staleness and mixed-currency warnings on stderr; errors still print.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace text/tabwriter with a small manual column-width writer so numeric
columns (P&L, TRADES, WINS, LOSSES, BALANCE, EQUITY) are right-aligned.
Introduces writeTable, colSpec, cell, tone, TableOpts, and signTone; wires
opts through PnLTable and AccountsTable for use by later colour and currency
tasks. JSON/CSV renderers are unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…subtotals

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.77836% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.14%. Comparing base (44047eb) to head (08c58cc).

Files with missing lines Patch % Lines
internal/render/render.go 90.72% 6 Missing and 8 partials ⚠️
cmd_accounts.go 89.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #7      +/-   ##
==========================================
+ Coverage   84.29%   89.14%   +4.85%     
==========================================
  Files          12       13       +1     
  Lines         452      783     +331     
==========================================
+ Hits          381      698     +317     
- Misses         64       71       +7     
- Partials        7       14       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Resolves staticcheck QF1001; logically equivalent, no behaviour change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tanem
tanem merged commit a0781b7 into main Jun 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant