Skip to content

fix(crypto): lead the change with its sign so a down move is not "$-186.36" - #330

Merged
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/crypto-change-sign-currency-mark
Aug 8, 2026
Merged

fix(crypto): lead the change with its sign so a down move is not "$-186.36"#330
ralyodio merged 1 commit into
moshcoder:mainfrom
clawedassistant26:fix/crypto-change-sign-currency-mark

Conversation

@clawedassistant26

Copy link
Copy Markdown
Contributor

The report/quote price line signs the day change inconsistently by direction.

priceLine() only ever prepends + for a gain and hands a loss straight to price(), which renders the minus inside the number — after the currency mark. So the two directions do not read alike:

up move:   $3,200.55  +$186.36  (+5.50%)   live · us venue · 24/7
down move: $3,200.55  $-186.36  (-5.50%)   live · us venue · 24/7

$-186.36 puts the sign in the wrong place. pct() already signs its own output for exactly this reason ("+0.29% and -0.29% must never look alike"); the absolute change now does the same — it formats the magnitude and leads with a single +/-, so a loss reads -$186.36 and a non-USD quote keeps its sign too (-0.02950 BTC).

Reproduce (before):

node -e 

…6.36"

priceLine only ever prepended "+" for a gain and let price() render a loss,
which puts the minus after the currency mark: an up move showed "+$186.36"
but a down move showed "$-186.36". pct() already signs its own output for
exactly this reason; the absolute change now does the same, formatting the
magnitude and leading with a single +/- so both directions read alike
("-$186.36") and non-USD quotes keep their sign too ("-0.02950 BTC").

Regression test renders a report at a negative and a positive change and pins
the sign placement; it fails before this change and passes after.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@ralyodio
ralyodio merged commit 1d46456 into moshcoder:main Aug 8, 2026
4 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.

2 participants