Skip to content

fix(ticker): carry a rounded thousand to the next unit in compact() - #321

Merged
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/ticker-compact-boundary-carry
Aug 8, 2026
Merged

fix(ticker): carry a rounded thousand to the next unit in compact()#321
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/ticker-compact-boundary-carry

Conversation

@clawedassistant26

Copy link
Copy Markdown
Contributor

compact() (src/advisor.mjs) chooses its magnitude unit from the raw value but rounds the displayed number to 2 decimals after the unit is fixed. A value just under a boundary then prints a full thousand of the smaller unit instead of carrying to the next one:

  • 999,999,999 -> "1000M" (should be "1B")
  • 999,999 -> "1000K" (should be "1M")
  • 999,999,999,999 -> "1000B" (should be "1T")

So a market cap a hair under $1B renders in a ticker report as "1000M".

Reproduce:

node -e 'const {renderAdvisor}=await import("./src/advisor.mjs");console.log(renderAdvisor("report",{ticker:"AAA",lastPrice:null,disclaimer:"d",facts:{source:"sec",marketCap:999999999}},{columns:88}))' | grep cap
# before: cap 1000M

Fix: round first, then carry. When the scaled value rounds to >= 1000 of the current unit, promote it to the next unit up. Values that genuinely sit below a boundary (e.g. 999.5M) keep their more precise smaller-unit form, so this only changes the mis-rendered boundary cases.

Test: adds a regression test that renders a report whose fundamentals land just under the million / billion / trillion boundaries and asserts the carried form ("1B", "1M", "1T") with no "1000X" leaking through. Fails before, passes after. Full suite green (1122 pass, 0 fail).

compact() picks its unit from the raw value but rounds the displayed
number to 2 decimals afterward, so a value just under a boundary prints
a thousand of the smaller unit instead of carrying: 999,999,999 rendered
as "1000M" and 999,999,999,999 as "1000B". A market cap a hair under
$1B read as "1000M".

Round first, then carry: when the scaled value rounds to >= 1000 of the
current unit, promote it to the next unit up. Values that legitimately
sit below a boundary (999.5M) keep their more precise smaller-unit form.

Adds a regression test that renders a report whose fundamentals land just
under the million/billion/trillion boundaries.
@ralyodio
ralyodio merged commit 45dcf21 into moshcoder:main Aug 8, 2026
4 checks passed
@ralyodio ralyodio mentioned this pull request Aug 8, 2026
ralyodio added a commit that referenced this pull request Aug 8, 2026
Bump to v0.27.0, releasing `/crypto` — crypto market data from advis0r.com as
a CLI verb, a pit command, and a second Claude Code plugin (#322) — alongside
two commits that have been sitting on main unreleased: the compact() carry fix
for `ticker` (#321) and the move off the deprecated Node 20 runtime (#320).

Minor rather than patch: it adds a command and a plugin, and changes no
existing one.

As with v0.26.0 and `ticker`, the release is what makes the plugin's primary
path work. install.sh serves the latest release tarball, not main, so until a
release carries it every installed binary answers `unknown command "crypto"`
and the plugin's slash commands fall back to curl — which works, but skips the
rendering the verb exists to do.

Co-authored-by: Claude Opus 5 (1M context) <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.

2 participants