Add market cap and supply, from a second data source - #17
Merged
Merged
Conversation
Alpaca carries no supply figure, and market cap cannot be derived from a price
without one, so this adds the first non-Alpaca source on the crypto path:
CoinGecko. Keyless like the rest of it, one batched request covering every
asset, cached five minutes, and a page that degrades to "—" rather than failing
when the source is unreachable.
New on a pair page, under "Supply & valuation": market cap and rank, fully
diluted valuation, circulating / total / max supply, all-time high with its
date and the distance from it, and aggregate 24h volume. Also on
/api/crypto/<PAIR>, tagged source: "coingecko".
Provenance is the thing to get right here, because two vendors now appear on
one page. The section is badged CoinGecko and carries its own as-of timestamp,
and the venue figures say so too. In particular the aggregate 24h volume sits
near the venue volume under Performance and is explicitly called out as not
comparable — for BTC that is $18.36B against a few hundred thousand.
Two guards, both of which fire on real assets we list:
- Non-positive supply is treated as absent. MKR migrated to SKY and now
reports zero circulating supply against a live-looking $1,272 price;
rendering "$0.00 market cap" would be a false statement.
- Stale records are treated as absent. MATIC migrated to POL and its record
last updated on 2026-02-03 — 185 days — while still returning figures. A
six-month-old supply beside a live price is the same "stale data wearing
the costume of live data" failure this codebase avoids elsewhere.
Both render an explanation rather than a bare dash, which would read as a bug
rather than as the asset having moved on. Neither is fixed by pointing at the
successor token: SKY and POL are different assets from the ones Alpaca prices.
Ids are explicit rather than resolved by symbol — tickers collide across
listings and "UNI" or "GRT" would eventually match an impostor. All 27 verified
against the API.
470 tests pass (17 new), tsc clean, verified live: BTC ($1.29T cap, 20.07M of
21M supply, -48.97% from ATH), SOL (#7, 582.05M supply), and both guards.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ThreatCrush Security Scan56 finding(s) HIGH/CRITICAL: 6 | MEDIUM: 50
…and 6 more. Full results in the Security tab. Snippets are redacted; ThreatCrush never prints matched credential material. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You said use another provider — this adds CoinGecko, the first non-Alpaca source on the crypto path.
Market cap cannot be derived from a price without a circulating supply, and Alpaca carries neither. CoinGecko is keyless like the rest of this path: one batched request covering every asset, cached five minutes, and the page degrades to "—" rather than failing if it is unreachable.
What lands
New Supply & valuation section on a pair page, and on
/api/crypto/<PAIR>taggedsource: "coingecko":market cap · rank · fully diluted valuation · circulating / total / max supply · all-time high with date and distance from it · aggregate 24h volume
Live for BTC: $1.29T cap, rank #1, 20.07M of 21M supply, ATH $126,080, -48.97% from it.
Provenance, since two vendors now share a page
The section is badged CoinGecko and carries its own as-of timestamp; the Alpaca figures say so too. The important one: aggregate 24h volume sits near the venue volume under Performance and is explicitly called out as not comparable — for BTC that is $18.36B against a few hundred thousand. Conflating them would overstate liquidity by orders of magnitude.
Two guards, both firing on assets we actually list
CoinGecko keeps serving records for tokens that have moved on, and a plausible-looking number is worse than a blank.
MKRMATICRendering
$0.00 market capfor MKR would be a false statement; a six-month-old supply beside a live price is the same failure mode this codebase avoids everywhere else. Both render the reason rather than a bare dash, which would read as a bug rather than as the asset having moved on.Neither is fixed by pointing at the successor token — SKY and POL are different assets from the ones Alpaca prices. Both guards are verified against the real API, not just mocks.
Other notes
Verification
tsc --noEmitclean🤖 Generated with Claude Code