Skip to content

feat(fetcher): add crypto_watchlist (CoinGecko, 9 shapes) - #210

Merged
unhappychoice merged 2 commits into
mainfrom
feat/crypto-watchlist
May 10, 2026
Merged

unhappychoice merged 2 commits into
mainfrom
feat/crypto-watchlist

Conversation

@unhappychoice

Copy link
Copy Markdown
Owner

Summary

CoinGecko /coins/markets snapshot fetcher for a configurable list of coin ids. First member of the crypto_* family; ticks [ ] crypto_watchlist on the Life & Ambient fetcher roadmap (#68).

  • Zero-config: defaults to ["bitcoin", "ethereum"] in USD, renders without any [widget.options] editing.
  • Safety::Safe — host fixed at api.coingecko.com, query-string options sanitised against allowlists (coins: [a-z0-9-], vs_currency: [a-z]{2,5}) so config can't redirect traffic off-host. No API key, no token leaves the machine.
  • 9 shapes (the full Bars / Text / *TextBlock / series / Badge set), so the same fetcher feeds grid_table, text_ascii, list_links, chart_sparkline, chart_line, chart_bar, list_ranking, status_badge, etc. without any reshaping.
  • Direction-neutral Status mapping on Entries / Badge: large absolute moves (≥ 5%) flip Ok → Warn so the badge stands out, but direction stays in the arrow / sign so the gauge doesn't bake in a sentiment that depends on whether the user is long or short.
Kind cached
Safety Safe
Shapes entries (default), text, text_block, markdown_text_block, linked_text_block, number_series, point_series, bars, badge

Options

Option Type Required Default Description
coins list of strings (CoinGecko coin ids) no ["bitcoin", "ethereum"] CoinGecko coin ids to include. Capped at 20 entries.
vs_currency string (lowercase 2-5 letter code) no "usd" Quote currency code passed to CoinGecko (usd, jpy, eur, btc, …). Letters only.

Compatible renderers

Shape Renderers
entries grid_table
text text_ascii, text_plain, animated_typewriter, animated_figlet_morph
text_block list_plain
markdown_text_block text_markdown
linked_text_block list_links
number_series chart_sparkline, chart_histogram
point_series chart_line, chart_scatter
bars chart_bar, chart_pie, list_ranking
badge status_badge

(Animated post-process wrappers — animated_postfx, animated_boot, animated_scanlines, animated_splitflap, animated_wave — accept every shape via ALL_SHAPES and are omitted from the table for brevity.)

Shape decisions

The full 14-row accept/reject table from the spec, in case anyone wants to re-litigate:

Shape Verdict Rationale
Text ✅ Top-mover headline (▲ BTC \$42,150.32 (+2.34%)).
TextBlock ✅ One row per coin.
MarkdownTextBlock ✅ Same with **SYMBOL** for text_markdown.
LinkedTextBlock ✅ Each row links to coingecko.com/en/coins/<id>.
Entries ✅ (default) coin → \"\$price (±%)\", status flips above ±5%.
Ratio ❌ No 0..=1 mapping (% is signed).
NumberSeries ✅ First coin's 7d hourly price as cents (negatives clamp to 0).
PointSeries ✅ Multi-series price chart, capped at 5 coins so the chart stays readable.
Bars ✅ 24h `
Image ❌ No natural single-image rendering for a watchlist.
Calendar ❌ No day-of-month dimension.
Heatmap ❌ Forced 2D — would need extra historical API calls.
Badge ✅ Top mover, volatility-coded Status.
Timeline ❌ Not chronological event data.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test — 27 inline unit tests cover URL building, coin/currency sanitisation (incl. injection-style inputs), shape branches, NumberSeries cents scaling, top-mover selection, volatility-status thresholds, options parsing, sample-body coverage of every supported shape, and a metadata round-trip.
  • cargo run --bin splashboard -- catalog fetcher crypto_watchlist — 9 shapes + compatible renderers reflect correctly.
  • #[ignore]-gated live smoke against CoinGecko (cargo test -- --ignored fetcher::crypto_watchlist::tests::live) for opt-in offline-safe verification.

🤖 Generated with Claude Code

CoinGecko `/coins/markets` snapshot for a configurable list of coin ids.
Safety::Safe — host fixed at `api.coingecko.com`, options sanitised
(`coins` allowlist `[a-z0-9-]`, `vs_currency` allowlist `[a-z]{2,5}`)
so config can't redirect traffic off-host. No API key required;
zero-config rendering with default `["bitcoin", "ethereum"]` in USD.

Shapes: Entries (default), Text (top mover headline), TextBlock,
MarkdownTextBlock, LinkedTextBlock (links to coin pages),
NumberSeries (first coin's 7d hourly price as cents), PointSeries
(per-coin price series for line/scatter), Bars (24h |% change|
basis points, direction encoded in the arrow label), Badge
(top mover with volatility-coded Status — direction-neutral
since a watchlist isn't sentiment-bearing).

Ticks the `crypto_watchlist` checkbox in the Life & Ambient
fetcher roadmap (#68).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 10, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@unhappychoice has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 57 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6b499f10-35c2-48ae-bc1d-5199b893a0c8

📥 Commits

Reviewing files that changed from the base of the PR and between 90c6c3c and 45ea15a.

📒 Files selected for processing (2)
  • src/fetcher/crypto_watchlist.rs
  • src/fetcher/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/crypto-watchlist

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented May 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.06250% with 70 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.26%. Comparing base (90c6c3c) to head (45ea15a).

Files with missing lines Patch % Lines
src/fetcher/crypto_watchlist.rs 89.04% 70 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #210      +/-   ##
==========================================
- Coverage   96.37%   96.26%   -0.11%     
==========================================
  Files         149      150       +1     
  Lines       43446    44086     +640     
==========================================
+ Hits        41872    42441     +569     
- Misses       1574     1645      +71     
Files with missing lines Coverage Δ
src/fetcher/mod.rs 99.08% <100.00%> (+<0.01%) ⬆️
src/fetcher/crypto_watchlist.rs 89.04% <89.04%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

`chart_sparkline` normalises against the series max with an implicit zero
floor, so emitting raw cents flattens the trace for any high-magnitude
asset — BTC at \$40k with a 1 % daily swing collapsed into a band glued
to the top of the slot, indistinguishable from a flat line.

Subtract the 7d period minimum before the cents conversion so the
variation occupies the full bar height. The unit becomes "cents above
the period low", which is the right framing for a glance-at-the-trend
sparkline anyway. `chart_line` / `chart_scatter` (PointSeries) already
auto-fit y bounds to (min, max), so PointSeries is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@unhappychoice
unhappychoice merged commit d6132dd into main May 10, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/crypto-watchlist branch May 10, 2026 12:29
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