modscode JA

modscode / Gallery / vn-stockmarket-heatmap

vn-stockmarket-heatmap

Live Vietnam stock-market heatmap and price board (SSI iBoard) in a Claude Code pane

Code you can checkTerminal + desktopPaneStatus lineBoxButtonInputSelectSvgText

What it does

  • Draws a pane, the status line
  • Adds /vn-stock-watch
  • Hooks session.start, ui.scroll
  • Calls the network

Good points

  • Starts no processes
  • Written in TypeScript
  • Has a desktop-specific branch
  • Handles errors

Code to start from

Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.

Starter (register.tsx)

register.tsx
import type { Register } from 'claude-code'

// Drawn like vn-stockmarket-heatmap by local (pane, status), as modscode read it from the mod's code:
// https://modscode.com/gallery/ngotuong12345-vn-stockmarket-heatmap/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
  // the pane: open it with $.ui.open({ id: 'my-pane', title: "VN Stock Watch" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button, Select, Input } = $.ui.resolve(e)
    const toISOString = '…'
    const age = '…'
    const x = '…'
    const head = '…'
    const chg = '…'
    const head2 = '…'
    const chg2 = '…'
    const head3 = '…'
    const chg3 = '…'
    const t = '…'
    const t2 = '…'
    const t3 = '…'
    const t4 = '…'
    const t5 = '…'
    const t6 = '…'
    const t7 = '…'
    const t8 = '…'
    const t9 = '…'
    const head4 = '…'
    const s = '…'
    const s2 = '…'
    const s3 = '…'
    const s4 = '…'
    const s5 = '…'
    const s6 = '…'
    const value = '…'
    const q0 = '…'
    return (
      <Box flexDirection="column">
        <Text bold>
          {"HCMC "}
          {toISOString}
        </Text>
        <Text dimColor>
          {`${age}s ago`}
          {" · Closed"}
          {" · caps 0/0"}
          {" · Source: SSI API"}
        </Text>
        <Box>
          <Button label="Sector" hotkey="s" variant="primary" />
          <Button label="Exch" hotkey="e" variant="primary" />
          <Select label="" value="__sum" options={[{"value":"__sum","label":"‹value›"},{"value":"__all","label":"Clear filter (all sectors)"},{"label":"‹option›"}]} />
          <Button label="Reset" hotkey="d" variant="primary" />
        </Box>
        <Box flexWrap="wrap">
          <Text dimColor>
            {"Showing "}
          </Text>
          <Button label={`${x} ✕`} />
          <Button label={`${x} ✕`} />
          <Button label={`${x} ✕`} />
        </Box>
        <Box flexWrap="wrap">
          <Text>
            <Text bold>
              {head}
            </Text>
            <Text>
              {chg}
              {"   "}
            </Text>
          </Text>
          <Text>
            <Text bold>
              {head2}
            </Text>
            <Text>
              {chg2}
              {"   "}
            </Text>
          </Text>
          <Text>
            <Text bold>
              {head3}
            </Text>
            <Text>
              {chg3}
              {"   "}
            </Text>
          </Text>
        </Box>
        <Text dimColor>
          Loading…
        </Text>
        <Box>
          <Text>
            {t}
          </Text>
          <Text>
            {t2}
          </Text>
          <Text>
            {t3}
          </Text>
        </Box>
        <Box>
          <Text>
            {t4}
          </Text>
          <Text>
            {t5}
          </Text>
          <Text>
            {t6}
          </Text>
        </Box>
        <Box>
          <Text>
            {t7}
          </Text>
          <Text>
            {t8}
          </Text>
          <Text>
            {t9}
          </Text>
        </Box>
        <Box>
          <Button label="VN30" variant="primary" />
        </Box>
        <Text bold>
          {head4}
          {`  ${head}`}
        </Text>
        <Text dimColor>
          Loading VN30…
        </Text>
        <Box>
          <Text>
            <Text>
              {s}
            </Text>
            <Text>
              {s2}
            </Text>
            <Text>
              {s3}
            </Text>
          </Text>
          <Text>
            {"  "}
          </Text>
          <Text>
            <Text>
              {s4}
            </Text>
            <Text>
              {s5}
            </Text>
            <Text>
              {s6}
            </Text>
          </Text>
        </Box>
        <Box>
          <Button label="My Watchlist" variant="primary" />
        </Box>
        <Box>
          <Input label="Search " placeholder={`${value}`} value={`${q0}`} submitLabel="add" />
          <Text dimColor>
            {" "}
            {value}
          </Text>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const up = '…'
    const length = '…'
    const dn = '…'
    await $.ui.status(`VN ▲${up} ■${length} ▼${dn}`)
    return next(e)
  })
}

The mod's own code

Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.

hooks/index.tsx lines 317–476 · Pane
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    if (!isOpen) { // pane survived a /reload-plugins: module state reset, command.run not re-run
      isOpen = true
      startTimers($)
      void refresh($)
      void refreshWatch($)
    }
    try {
    const { Box, Text, Button, Input, Select, Svg } = $.ui.resolve(e) as any
    const desktop = e.surface === 'desktop'
    const q = await read($, quotes)
    const m = await read($, meta)
    const v = await read($, view)
    const sel = await read($, only)
    const z = await read($, zoom)
    const ix = await read($, idx)
    const cols = Math.max(30, (e.props as any)?.bodyColumns ?? e.viewport?.columns ?? 80)
    const rows = (e.viewport?.rows ?? 30) - 6

    const age = m.at ? Math.round((Date.now() - m.at) / 1000) : 0

    const sectors = [...new Set(q.map(x => x.g))].sort()
    const picked = sel ? sel.split('|') : []
    const pool = picked.length ? q.filter(y => picked.includes(y.g)) : q
    const by = new Map<string, Quote[]>()
    for (const x of pool) {
      const key = v === 'sector' ? x.g : EXCHANGE[x.x] || '?'
      by.set(key, [...(by.get(key) ?? []), x])
    }
    const groups: Group[] = [...by.entries()].map(([name, xs]) => {
      const avg = wavg(xs)
      const s = SHORT[name] ?? name.split(' ')[0] ?? name
      return {
        heads: [`${name} ${fmt(avg)}`, `${s} ${fmt(avg)}`, s, ...[TINY[name]].filter((x): x is string => !!x)],
        tone: avg >= 0 ? '#7CE0A0' : '#FF8A80',
        v: xs.reduce((s, x) => s + x.m, 0),
        tiles: xs.map(x => ({ label: x.s, sub: fmt(x.p), bg: COLOR(x), v: x.m })),
      }
    }).sort((a, b) => b.v - a.v)
    const n2 = (v: number) => v.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })
    const ixs = ix.map(x => ({
      key: x.name,
      head: `${x.name} ${n2(x.price)} `,
      chg: `${x.change > 0 ? '▲' : x.change < 0 ? '▼' : '■'}${n2(x.change)} (${n2(x.pct)}%)`,
      color: x.change > 0 ? '#2FA55A' : x.change < 0 ? '#C0392B' : '#C9A227',
    }))
    const ixLen = ixs.reduce((n, x) => n + x.head.length + x.chg.length + 3, 0)
    const ixRows = (ixs.length ? Math.ceil(ixLen / cols) : 0) + (sel && !desktop ? 1 : 0) // + chips row
    const W = Math.max(30, cols - 1)
    const narrow = W < 62 // short labels so no control row wraps
    const bodyRows = (e.props as any)?.scroll?.bodyRows ?? (e.viewport?.rows ?? 30) - 3
    const t = await read($, tab)
    const l = await read($, lists)
    const wr = await read($, wrows)
    const wm = await read($, wmeta)
    const wl = (await read($, wlrows)).slice(0, 8)
    const q0 = await read($, wq)
    const msg = await read($, wmsg)
    const cap = Math.max(1, Math.floor(bodyRows * 0.3) - 4)
    const kind = t === 'port' ? 'port' : 'vol'
    // Two side-by-side tables only when the list overflows one AND each half still fits (dropping at most Buy/Sell);
    // otherwise one table, dropping low-priority columns until it fits. Never wraps.
    const dualCols = t !== 'port' && wr.length > cap ? fit(kind, Math.floor((W - 2) / 2), kind === 'vol' ? 0 : 2) : undefined
    const dual = !!dualCols
    const cs = dualCols ?? fit(kind, W, kind === 'vol' ? 0 : 99) ?? (kind === 'vol' ? COLS[kind] : COLS[kind].filter(c => !DROP[kind].includes(c.h)))
    const shown = wr // pane scrolls: show every row instead of truncating
    const half = dual ? Math.ceil(shown.length / 2) : shown.length
    const H = Math.max(8, Math.floor(bodyRows * 0.55) - 3 - ixRows) // fixed share; tables below scroll
    const grid = q.length && !desktop ? buildGrid(groups, W, H, z) : []
    gridTop = 3 + ixRows // clock, status, buttons, index row(s)
    gridLen = grid.length
    scrollOff = (e.props as any)?.scroll?.offset ?? 0
    const cut = (s: string) => (s.length > W ? s.slice(0, W) : s)
    const head = cs.map(c => (c.left ? c.h.padEnd(c.w) : c.h.padStart(c.w))).join('')

    const rowCell = (r: WRow) => {
      const pos = l.port[r.s]
      const bg = r.fl > 0 ? UP_BG : r.fl < 0 ? DN_BG : undefined
      return (
        <Text>
          {cs.map(c => {
            const v = c.cell(r, pos)
            return <Text key={c.h} bold={v.b} dimColor={v.dim} color={v.c} backgroundColor={bg}>{c.left ? v.s.padEnd(c.w) : v.s.padStart(c.w)}</Text>
          })}
        </Text>
      )
    }

    if (desktop) {
      // Fill the pane: ~8px per column. Table zoom (A-/A+) scales the SVG text; once two tables fit side by side, it shows two.
      const mapW = Math.max(480, Math.round(cols * 8))
      const tz0 = await read($, tzoom)
      const adj = await read($, mapadj)
      const slIdx = Math.max(0, Math.min(SL_N - 1, Math.round(adj / SL_STEP) + SL_AUTO))
      const table = (rs: WRow[], k: 'vol' | 'port' | 'wl', fs: number, pl = false) => {
        const lh = Math.round(fs * 1.65)
        const pxCells = (px: number) => Math.floor(px / (fs * 0.62))
        const two = rs.length > 1 ? fit(k, pxCells((mapW - 24) / 2), k === 'vol' ? 3 : 2) : undefined // VN30 (vol): drops Room/F.Sell/F.Buy to fit two tables; Vol/Buy/Sell stay
        const cs = two ?? fit(k, pxCells(mapW), k === 'vol' ? 0 : 99) ?? (k === 'vol' ? COLS[k] : COLS[k].filter(c => !DROP[k].includes(c.h)))
        const h = ((two ? Math.ceil(rs.length / 2) : rs.length) + 1) * lh + 4
        const svg = () => tableSvg(cs, rs.map(r => ({ cells: cs.map(c => c.cell(r, pl ? l.port[r.s] : undefined)), bg: r.fl > 0 ? '#2ECC71' : r.fl < 0 ? '#FF5A4D' : undefined } as TRow)), mapW, fs, !!two)
        return { svg, h }
      }
      const tblH = (fs: number) => (wr.length ? table(wr, kind, fs, t === 'port').h : 40) + (wl.length ? table(wl, 'wl', fs).h : 0)
      // ~19px per row; fixed chrome (header, selects, index row, 2 sliders, tab, total, search, hint, watchlist title + remove row) ≈ 400px.
      const total = (e.viewport?.rows ?? 60) * 19 - 400
      const clampMap = (h: number) => Math.max(200, Math.min(1100, Math.round(h)))
      // Auto text size (tz0 < 0): the map keeps the space it gets at the default size (+ the map-size slider), and the tables take whatever height is left, so the biggest text that still fits wins. Smaller map => bigger text; bigger map => smaller text.
      const refFs = TABLE_FS[tz0 >= 0 ? Math.min(TABLE_FS.length - 1, tz0) : TABLE_FS_DEF]!
      const mapH = Math.max(160, Math.min(2400, clampMap(total - tblH(refFs)) + adj))
      const autoIdx = TABLE_FS.map((_, i) => i).reverse().find(i => tblH(TABLE_FS[i]!) <= total - mapH) ?? 0
      const tz = tz0 >= 0 ? Math.min(TABLE_FS.length - 1, tz0) : autoIdx
      const fs = TABLE_FS[tz]!
      const mainT = wr.length ? table(wr, kind, fs, t === 'port') : undefined
      const wlT = wl.length ? table(wl, 'wl', fs) : undefined
      return (
        <Box flexDirection="column" backgroundColor="#202226" flexGrow={1}>
          <Text bold>HCMC {new Date(Date.now() + 7 * 3600_000).toISOString().slice(11, 19)} <Text dimColor>{m.status === 'live' ? `${age}s ago` : m.status}<Text color={session().c}> · {session().t}</Text>{capsHave < capsOf ? ` · caps ${capsHave}/${capsOf}` : ''} · Source: SSI API</Text></Text>
          <Box flexWrap="wrap">
            <Select
              key="sel-view"
              label="Group by "
              value={v}
              options={[{ value: 'sector', label: 'Sector' }, { value: 'exchange', label: 'Exchange' }]}
              onSelect={(x: string) => { void update($, view, () => x as View) }}
            />
            <Select
              key="sel-filter"
              label="Filter "
              value="__sum"
              options={[
                { value: '__sum', label: picked.length ? picked.join(', ').slice(0, 40) : 'All sectors' },
                { value: '__all', label: 'Clear filter (all sectors)' },
                ...sectors.map(x => ({ value: x, label: `${picked.includes(x) ? '✓ ' : '   '}${x}` })),
              ]}
              onSelect={(x: string) => {
                if (x === '__sum') return
                void update($, only, cur => {
                  if (x === '__all') return ''
                  const c = cur ? cur.split('|') : []
                  return (c.includes(x) ? c.filter(y => y !== x) : [...c, x]).join('|')
                })
              }}
            />
          </Box>
          {picked.length > 0 && (
            <Box flexWrap="wrap">
              <Text dimColor>Showing </Text>
              {picked.map(x => <Button key={`chip-${x}`} label={`${x} ✕`} onPress={() => update($, only, cur => cur.split('|').filter(y => y !== x).join('|'))} />)}
            </Box>
          )}
          {ixs.length > 0 && <Box flexWrap="wrap">{ixs.map(x => <Text key={x.key}><Text bold>{x.head}</Text><Text color={x.color}>{x.chg}{'   '}</Text></Text>)}</Box>}
          {q.length === 0 ? <Text dimColor>Loading…</Text> : <Svg source={buildSvg(groups, mapW, mapH)} alt="Vietnam stock-market treemap by market cap, coloured by daily change" />}
          <Box>
            <Text dimColor>Map size </Text>
            {Array.from({ length: SL_N }, (_, k) => (
              <Button key={`ms${k}`} plain label={k <= slIdx ? '█' : '░'} onPress={() => update($, mapadj, () => (k - SL_AUTO) * SL_STEP)} />
            ))}
            <Button key="map-auto" label="⟲" onPress={() => update($, mapadj, () => 0)} />
          </Box>
Licence text (MIT)
MIT License

Copyright (c) 2026 NgoTuong12345

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

What its code calls

networkwrites files

The design, read from code

Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.

What its code shows

Read from the source at commit 94eefd67ea88 on 2026-10-06. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.

Decides the listing: code you can check
Entry readEvery module hooks/hooks.json names was read.hooks/index.tsx
ParsesEvery file parses as TypeScript or JavaScript.4 files parsed
All its code is in the modEvery import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod
ReadableNo minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs
Calls in the openNetwork and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open
For you to weigh before installing
Where it drawsThe terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app, with its own branch for the desktop
Install lineWhether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there
Programs on WindowsWhether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks
NetworkWhether every fetch names its https host in the code.hooks/index.tsx:48 fetch(`${SSI}${path}`); hooks/index.tsx:157 fetch(url); hooks/index.tsx:205 fetch(`${STATS}/company/sectors-data`)
ProgramsWhether every program it starts is named in the code and is not a shell, an interpreter or a network tool.starts no programs
Reads and sendsWhether it both reads files or environment variables and reaches the network.reads files and reaches the network
Keys in the sourceWhether the source holds what looks like an API key or a private key.no keys in the source
LicenceAn open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets modscode show its code; otherwise the code is linked.MIT

This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen

Install it

Check it yourself before you install it. Mods run unsandboxed, with your permissions, and modscode does not vouch for what this code does. Read the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.

Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:

/plugin marketplace add NgoTuong12345/claude-mod-vn-stock-watch
/plugin install vn-stockmarket-heatmap@vn-stock-watch

This installs the marketplace's latest commit, which may not be the one read here (94eefd67ea88). Compare them before you install.

Ask Claude about it

With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:

Read the modscode design "ngotuong12345-vn-stockmarket-heatmap" with its code and make me a pane like it

Search them from Claude: the MCP connector

Similar designs