Skip to content

cli: Add --format html support to all commands and Adventure theme#162

Draft
huacnlee wants to merge 24 commits into
mainfrom
html-result
Draft

cli: Add --format html support to all commands and Adventure theme#162
huacnlee wants to merge 24 commits into
mainfrom
html-result

Conversation

@huacnlee
Copy link
Copy Markdown
Member

@huacnlee huacnlee commented Apr 29, 2026

Summary

  • Extracts the HTML output template to a standalone `html_render.html` file (compiled in via `include_str!`) replacing fragile inline Rust strings
  • Replaces all custom CSS with Tailwind CSS (CDN) and applies a brand-aligned dark palette across all pages and ECharts charts
  • Theme palette derived from Longbridge brand colors (`#00dcb5` teal, `#ffe100` yellow, `#ff5100` orange-red), dark-adapted for dark backgrounds
  • Adds `HtmlPayload::RawJson` variant plus `open_html_table` / `open_html_raw` helpers to eliminate per-command boilerplate
  • Wires `--format html` to open a real browser page in every data-querying CLI command
  • Refactors all ECharts JS into external `src/cli/html_render/*.js` files (compiled in via `include_str!`)
  • Adds HTML support for all commands merged from `main` after this branch diverged (business-segments, institution-rating --views/--history/--industry-rank, industry-rank, industry-peers, financial-report snapshot, etc.)
  • IPO commands now render structured multi-section HTML tables (HK/US split) instead of raw JSON
  • Symbol columns across all HTML tables show stock logo + clickable quote link, with correct counter_id type prefix (ST/ETF/IX/WT) from CSV lookup
  • `financial-statement --format html` renders an ECharts bar+line chart (level-2 fields as bars, percentage fields as lines on secondary Y-axis) above a full pivot table with indented metrics, formatted values, and YoY column
  • `financial-report --format html` renders IS/BS/CF each with a bar+line chart + data table; x-axis labels are now horizontal
  • `valuation-rank --format html` renders a percentile trend line chart (PE/PB/PS/Div over time) + data table
  • `institution-rating --history --format html` renders a stacked bar chart (Buy/Hold/Sell over time) + data table
  • `institution-rating --industry-rank --format html` renders a horizontal stacked bar chart (peers sorted by buy+outperform) + data table
  • `business-segments --format html` renders a donut pie chart (current) or stacked bar chart (history) + formatted data table
  • `financial-report --latest --format html` renders a horizontal YoY-change bar chart + key metrics table with formatted values
  • `industry-rank --format html` renders a data table (涨跌幅 is not suitable for chart visualization)

Command review

Legend: ✅ reviewed OK · 📋 table OK · 🔧 implemented (no extra review needed) · ⬜ needs verification

Market data

  • `quote` ✅ — snapshot table
  • `kline` ✅ — candlestick + volume chart
  • `intraday` ✅ — price/avg line + volume bars
  • `history-intraday` 🔧
  • `depth` 🔧 — horizontal orderbook bars
  • `trades` 📋 — tick table
  • `brokers` 📋 — broker queue table
  • `static` 📋 — reference data table
  • `calc-index` 📋 — financial metrics table

Capital & flow

  • `capital` (distribution) 🔧 — grouped bars
  • `capital --flow` 🔧 — inflow bars
  • `short-positions` 🔧 — line + bar combo
  • `ah-premium` ✅ — historical A/H ratio → dual-axis line chart
  • `ah-premium intraday` ✅ — intraday A/H ratio → line chart
  • `trade-stats` ✅ — summary stats + horizontal stacked bar (price × buy/sell/neutral)

Options & warrants

  • `option quote` 📋 — snapshot table
  • `option chain` 📋 — calls/puts table
  • `option volume` 🔧 — stacked bars + P/C ratio
  • `option volume stats` 📋 — stats table
  • `warrant quote` 📋 — snapshot table
  • `warrant list` 📋 — table
  • `warrant issuers` 📋 — table

Market info

  • `market-temp` ✅ — 3 gauge dials + 90-day history line chart
  • `market-temp --history` ✅ — temperature/valuation/sentiment area chart
  • `market-status` 📋 — table
  • `trading-session` 📋 — table
  • `trading-days` 📋 — table
  • `security-list` 📋 — table
  • `participants` 📋 — table

Fundamentals

  • `valuation` ✅ — current metrics table, `--history` → line chart (PE/PB/PS over time)
  • `financial-report` ✅ — IS/BS/CF each with bar+line chart + table; x-axis labels horizontal
  • `financial-statement` ✅ — ECharts bar+line chart (level-2 fields) + pivot table with YoY column
  • `institution-rating` ✅ — consensus summary + horizontal rating breakdown bar chart
  • `industry-valuation` ✅ — peer radar chart
  • `industry-valuation dist` ✅ — grouped bar distribution chart
  • `forecast-eps` 📋 — table
  • `consensus` 📋 — table
  • `dividend` 📋 — table
  • `finance-calendar` 📋 — table
  • `filing` 📋 — table
  • `company` 📋 — key/value card
  • `executive` 📋 — table
  • `shareholder` 📋 — table
  • `operating` 📋 — table
  • `corp-action` 📋 — table
  • `invest-relation` 📋 — table
  • `news` ✅ — article card list with clickable links
  • `topic` 📋 — table
  • `financial-report --latest` ✅ — horizontal YoY bar chart + key metrics table (values formatted B/M/K)
  • `valuation-rank ` ✅ — percentile trend line chart (PE/PB/PS/Div) + data table
  • `institution-rating --history` ✅ — stacked bar chart (Buy/Hold/Sell over time) + table
  • `institution-rating --industry-rank` ✅ — horizontal stacked bar (peers by buy+outperform) + table
  • `institution-rating --views` ⬜ — institutional views table (new from cli: Add business-segments, institution-rating --views, industry-rank, industry-peers, financial-report snapshot #202)
  • `business-segments ` ✅ — donut pie (current) / stacked bar (history) + formatted table
  • `industry-rank` 📋 — sorted table with chg% and leading stock (涨跌幅 not suited for chart)
  • `industry-peers ` ⬜ — industry peers raw JSON tree (new from cli: Add business-segments, institution-rating --views, industry-rank, industry-peers, financial-report snapshot #202)
  • `financial-report snapshot ` ⬜ — earnings snapshot raw JSON (new from cli: Add business-segments, institution-rating --views, industry-rank, industry-peers, financial-report snapshot #202)

Broker data

  • `broker-holding top` 📋 — table
  • `broker-holding detail` 📋 — table
  • `broker-holding daily` 📋 — table

Portfolio & account

  • `positions` 📋 — table
  • `fund-positions` 📋 — table
  • `assets` 📋 — key/value summary
  • `portfolio` ✅ — asset distribution pie + holdings bar chart + holdings table
  • `cash-flow` 📋 — table
  • `statement` 📋 — table
  • `order` 📋 — table
  • `order detail` 📋 — table
  • `order executions` 📋 — table
  • `margin-ratio` 📋 — table
  • `max-qty` 📋 — table
  • `exchange-rate` 📋 — table
  • `alert` 📋 — table
  • `portfolio short-margin` ⬜ — short margin table

ATM / Account management

  • `bank-cards` ⬜ — bank card table
  • `withdrawals` ⬜ — withdrawal history table
  • `deposits` ⬜ — deposit history table

IPO

  • `ipo subscriptions` ✅ — HK + US sections with symbol logos and links
  • `ipo wait-listing` ✅ — HK + US sections
  • `ipo listed` ✅ — HK + US sections
  • `ipo calendar` ✅ — HK + US + Other sections
  • `ipo detail ` ✅ — Profile / Eligibility / Timeline / Holdings sections
  • `ipo orders` ✅ — Active + History sections
  • `ipo profit-loss` ✅ — Summary + Items sections
  • `ipo orders detail ` ⬜ — raw JSON key/value
  • `ipo us-subscriptions` ⬜ — US subscriptions table
  • `ipo us-wait-listing` ⬜ — US wait-listing table
  • `ipo us-listed` ⬜ — US listed table

Discovery & lists

  • `watchlist` 📋 — table
  • `constituent` 📋 — table
  • `sharelist` 📋 — table
  • `fund-holder` 📋 — table
  • `anomaly` 📋 — table

US market

  • `insider-trades` 📋 — table
  • `investors` 📋 — table
  • `investors ` 📋 — holdings table
  • `investors changes` 📋 — changes table

DCA

  • `dca` 📋 — plan list table
  • `dca history` 📋 — trade history table
  • `dca stats` 📋 — summary table

Search

  • `search --tab news` ⬜ — news results table
  • `search --tab topics` ⬜ — topic results table

🤖 Generated with Claude Code

huacnlee and others added 10 commits April 29, 2026 19:38
- Extract HTML template to a standalone `html_render.html` file compiled
  in via `include_str!`; replace all inline CSS with Tailwind CSS (CDN)
- Apply Adventure theme palette across all pages and ECharts charts:
  background #040404, border #282828, accent #41b3a9 (cyan),
  up #5da602 (green), down #d84a33 (red)
- Add `HtmlPayload::RawJson` variant and `open_html_table` / `open_html_raw`
  convenience helpers to reduce per-command boilerplate
- Wire `--format html` to open a browser page in every CLI command across
  quote.rs, trade.rs, fundamental.rs, asset.rs, investors.rs,
  insider_trades.rs, dca.rs, sharelist.rs, and watchlist.rs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Green = up, red = down (global convention) for candlestick and volume bars
- buildTable() now prefixes '$' to monetary columns (price, value, turnover, etc.)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Command label uses teal accent color and the command text uses bright white
to visually distinguish it from the Generated row below.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Current temperature renders as 3 ECharts gauge dials (Temperature,
Valuation, Sentiment) with cold/warm/hot color zones, plus a 90-day
history line chart below and a data table. Description is shown above
the gauges, colored to match the temperature zone.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tables are capped at 420px with internal vertical scroll.
th is sticky so header stays visible while scrolling.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces open_html_raw with a dedicated ValuationHistory chart payload.
Each indicator (PE, PB, PS, etc.) is rendered as a separate line series
on a shared axis with a unified date/value table below.

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

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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@huacnlee huacnlee marked this pull request as draft April 30, 2026 16:05
huacnlee and others added 14 commits May 7, 2026 18:51
- Convert bank-cards, withdrawals, deposits, short-margin, search
  news/topics, ipo us-subscriptions/us-wait-listing/us-listed, and
  institution-rating --views to use open_html_table instead of open_html_raw
- Fix command strings in open_html_raw calls to match actual CLI syntax
  (e.g. institution-rating --history, ipo orders detail <id>)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add Sections HtmlPayload variant and open_html_sections helper to support
multiple named table sections on a single HTML page. Convert ipo
subscriptions, wait-listing, listed, calendar, orders, and profit-loss
Html arms from open_html_raw to open_html_sections.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Symbol cells in any table or sections page with header "symbol" are
rendered as clickable links to https://longbridge.com/quote/{symbol}.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Symbol cells now render as: logo image (onerror hidden) + symbol text,
linked to https://longbridge.com/quote/{symbol}. Logo URL format:
https://assets.lbkrs.com/ticker/ST/{MARKET}/{CODE}.png

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Logo URL now resolves ETF/IX/WT prefixes via the embedded CSV lookup
instead of always using ST. e.g. SPY.US -> ETF/US/SPY.png

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use flex-shrink-0 + gap-1.5 instead of inline-block/align-middle to
correctly center logo and text in the inline-flex container.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Profile, Eligibility, Timeline, and Holdings each render as a named
table section using open_html_sections.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Build headers from period labels and rows from field entries, using
HTML entities for indentation and <strong> for section headers.

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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ess-segments, financial-report --latest, industry-rank

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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