From 12cee156c8b2ae6cddfb62b8bc4f48610f24a7bd Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Wed, 22 Jul 2026 17:36:29 +0700 Subject: [PATCH] docs(portfolio): document mobile column layout --- README.md | 6 ++- .../260722-1705-mobile-portfolio-columns.md | 47 +++++++++++++++++++ .../phase-01-compact-portfolio-columns.md | 45 ++++++++++++++++++ .../plan.md | 42 +++++++++++++++++ ...pm-260722-1705-mobile-portfolio-columns.md | 37 +++++++++++++++ 5 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 docs/journals/260722-1705-mobile-portfolio-columns.md create mode 100644 plans/260722-1705-mobile-portfolio-columns/phase-01-compact-portfolio-columns.md create mode 100644 plans/260722-1705-mobile-portfolio-columns/plan.md create mode 100644 plans/260722-1705-mobile-portfolio-columns/reports/pm-260722-1705-mobile-portfolio-columns.md diff --git a/README.md b/README.md index c47b9a4..6fd2831 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,10 @@ P&L; full sells remove the position and its basis. Stock share dividends add shares without adding cost, which lowers the derived average price, while cash dividends do not change position basis. -`/stock_portfolio` and `/coin_portfolio` show aligned monospace tables with -average entry price and unrealized P&L for each priced position. `Account P&L` remains the broader +`/stock_portfolio` and `/coin_portfolio` show compact aligned monospace tables +with separate unrealized P&L amount and percentage columns for each priced +position. Stock `Avg` and `Now` use thousand VND as their implicit unit; coin +position amounts use implicit USD without a `$` prefix. `Account P&L` remains the broader account value minus all top-ups, so it also reflects realized proceeds, dividend cash, and idle cash. If any current quote is unavailable, totals are marked partial and numeric Account P&L is withheld. diff --git a/docs/journals/260722-1705-mobile-portfolio-columns.md b/docs/journals/260722-1705-mobile-portfolio-columns.md new file mode 100644 index 0000000..dca6114 --- /dev/null +++ b/docs/journals/260722-1705-mobile-portfolio-columns.md @@ -0,0 +1,47 @@ +--- +title: Mobile Stock and Coin Portfolio Columns +date: 2026-07-22 17:05 +component: stock and coin portfolio UI +status: completed +--- + +# Mobile Stock and Coin Portfolio Columns + +## Context + +The stock and coin position tables were still too wide for Telegram-sized screens. Long headers and a combined unrealized P&L cell made each row harder to scan on mobile. + +## What Happened + +Both position tables now use `Sym`, `Qty`, `Avg`, `Now`, `Val`, `P&L`, and `%`. Stock `Avg` and `Now` use thousand VND as an implicit unit without `k`; coin position money omits `$`. P&L amount and percentage are separate cells without parentheses. Summary formatting remains unchanged. + +## Reflection + +The useful part of this change is that it stayed local to the portfolio renderer. We did not touch command behavior, storage, or trade accounting, so the formatting work did not leak into unrelated output paths. + +The review callout about implicit `VND` was intentional, not a bug. The user explicitly removed `(VND)` from the stock title and accepted stock-domain context as sufficient. Keeping full currency labels in the summary would have widened the output and contradicted that decision. + +## Decisions + +- Keep compact `k/M/B/T` suffixes for position value and P&L amounts. +- Treat stock `Avg` and `Now` as thousand VND without a `k` suffix. +- Treat coin position money as implicit USD without `$`. +- Preserve explicit `VND` in non-portfolio replies where the standalone context is useful. +- Keep existing summary formats unchanged. +- Leave command and storage contracts unchanged. + +## Verification + +We validated the change with focused tests first, then the full suite. The final checks all passed: + +- focused tests +- `go test -count=1 ./...` +- `go build ./...` +- `go vet ./...` +- `golangci-lint run` + +Coverage landed at `76.7%` statement coverage, which is acceptable for this change because the work was formatting-heavy and stayed inside existing rendering paths. + +## Next + +The code change is done, but the commit is still pending user approval. The next step is to package this as a focused commit once that approval lands. diff --git a/plans/260722-1705-mobile-portfolio-columns/phase-01-compact-portfolio-columns.md b/plans/260722-1705-mobile-portfolio-columns/phase-01-compact-portfolio-columns.md new file mode 100644 index 0000000..0f71891 --- /dev/null +++ b/plans/260722-1705-mobile-portfolio-columns/phase-01-compact-portfolio-columns.md @@ -0,0 +1,45 @@ +--- +phase: 1 +title: Compact Portfolio Columns +status: completed +priority: P1 +dependencies: [] +effort: small +--- + +# Phase 1: Compact Portfolio Columns + +## Overview + +Apply the approved seven-column mobile layout to stock and coin position rows. + +## Requirements + +- Use `Sym | Qty | Avg | Now | Val | P&L | %` in both modules. +- Render stock `Avg` and `Now` in thousand VND without a `k` suffix. +- Omit currency from both titles and omit `$` from coin position money. +- Keep compact suffixes for stock value/P&L and coin position money. +- Preserve full summary formats, P&L calculations, and `N/A` behavior. + +## Architecture + +Only private position formatters and row renderers change. Exported formatters, +portfolio persistence, trading operations, quote providers, summaries, and +dividend workflows remain unchanged. + +## Implementation Checklist + +- [x] Add stock thousand-VND position formatter. +- [x] Split stock position P&L amount and percentage. +- [x] Remove `$` from coin position-only compact formatting. +- [x] Split coin position P&L amount and percentage. +- [x] Update renderer, edge-path, and formatter tests. +- [x] Update README and pass all verification gates. + +## Risks + +- Seven-column `N/A` rows could become misaligned; covered by partial and + overflow tests. +- Removing currency markers is intentionally limited to position displays; + coin summaries retain `$`, while stock uses implicit VND throughout. + diff --git a/plans/260722-1705-mobile-portfolio-columns/plan.md b/plans/260722-1705-mobile-portfolio-columns/plan.md new file mode 100644 index 0000000..9da66e0 --- /dev/null +++ b/plans/260722-1705-mobile-portfolio-columns/plan.md @@ -0,0 +1,42 @@ +--- +title: Mobile Portfolio Columns +description: Compact stock and coin position tables for narrow Telegram screens. +status: completed +priority: P1 +effort: small +branch: main +tags: + - stock + - coin + - telegram + - formatting +created: 2026-07-22 +--- + +# Mobile Portfolio Columns + +## Overview + +Shorten stock and coin position tables while preserving calculations, summary +formatting, missing-price behavior, and Telegram reply limits. + +## Phases + +| Phase | Name | Status | Progress | +|---|---|---|---| +| 1 | [Compact Portfolio Columns](./phase-01-compact-portfolio-columns.md) | Completed | 6/6 (100%) | + +## Dependencies + +- Builds on the completed compact-number formatter plan. +- No storage, command, provider, or migration dependency. + +## Success Criteria + +- [x] Both position tables use `Sym`, `Qty`, `Avg`, `Now`, `Val`, `P&L`, `%`. +- [x] Stock `Avg` and `Now` use implicit thousand VND without `k`. +- [x] Coin position money uses implicit USD without `$`. +- [x] P&L amount and signed percentage render in separate columns. +- [x] Summary formatting and unavailable-price behavior remain compatible. +- [x] Focused/full tests, build, vet, lint, and diff checks pass. + diff --git a/plans/260722-1705-mobile-portfolio-columns/reports/pm-260722-1705-mobile-portfolio-columns.md b/plans/260722-1705-mobile-portfolio-columns/reports/pm-260722-1705-mobile-portfolio-columns.md new file mode 100644 index 0000000..aa69eb5 --- /dev/null +++ b/plans/260722-1705-mobile-portfolio-columns/reports/pm-260722-1705-mobile-portfolio-columns.md @@ -0,0 +1,37 @@ +--- +title: Mobile Portfolio Columns Completion Report +status: completed +created: 2026-07-22 +--- + +# Mobile Portfolio Columns Completion Report + +## Summary + +| Metric | Result | +|---|---| +| Phases | 1/1 completed | +| Tasks | 6/6 completed | +| Code review | Pass; no remaining findings | +| Focused tests | Pass | +| Full tests | Pass | +| Build / vet / lint | Pass / pass / 0 issues | +| Statement coverage | 76.7% | + +## Achievements + +- Reduced both position tables to concise seven-column mobile layouts. +- Made stock price columns implicit thousand VND. +- Made coin position currency implicit while preserving `$` in summaries. +- Separated P&L amount and percentage without parentheses. +- Preserved missing-price, overflow, truncation, and portfolio behavior. + +## Known Limitations + +- Stock summary VND is intentionally implicit after removing title currency. +- Go coverage reports statement coverage; branch coverage was not generated. + +## Next Step + +- Commit and push after user approval. +