Skip to content

feat(tickers): finnhub_token alias + auto-map crypto symbols (BTC-USD)#41

Merged
falkoro merged 1 commit into
masterfrom
feat/finnhub-crypto-rootenv
Jun 5, 2026
Merged

feat(tickers): finnhub_token alias + auto-map crypto symbols (BTC-USD)#41
falkoro merged 1 commit into
masterfrom
feat/finnhub-crypto-rootenv

Conversation

@falkoro
Copy link
Copy Markdown
Owner

@falkoro falkoro commented Jun 5, 2026

Follow-up to #40. Two fixes so the Finnhub ticker works with the key as it's actually stored, and so crypto keeps working after the Yahoo→Finnhub switch.

  • Var alias: FINNHUB_API_KEY now falls back to FINNHUB_TOKEN / finnhub_token (the name used in the env files).
  • Crypto symbols: finnhub_symbol() maps a Yahoo-style BTC-USDCOINBASE:BTC-USD (Finnhub returns {c:0} for a bare BTC-USD). Stocks never end in -USD, and explicit BINANCE:… symbols pass through. The displayed label keeps the user's symbol.
  • Frontend hint / README / .env.example updated — crypto (BTC-USD) is supported again.

Verified live (release binary, real key): /api/tickersINTC $111.78 −0.83%, TSLA $418.45 −1.24%, BTC-USD $62,894 −1.43%. Browser: 3 ticks, no overflow, 0 console errors. tsc + cargo build --release green.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 5, 2026 08:01
- config.rs: FINNHUB_API_KEY falls back to FINNHUB_TOKEN / finnhub_token
  (matches the key name already used in env files).
- routes.rs: finnhub_symbol() maps Yahoo-style crypto (BTC-USD) to Finnhub's
  COINBASE:BTC-USD so existing BTC-USD tickers keep working; display keeps the
  user's symbol. Verified live: INTC/TSLA + BTC-USD all return quotes.
- frontend hint + README + .env.example: crypto is supported again (BTC-USD).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@falkoro falkoro force-pushed the feat/finnhub-crypto-rootenv branch from ef927ec to 34df6a3 Compare June 5, 2026 08:01
@falkoro falkoro merged commit d41499b into master Jun 5, 2026
@falkoro falkoro deleted the feat/finnhub-crypto-rootenv branch June 5, 2026 08:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is a follow-up to the Finnhub ticker switch, aiming to (1) read the Finnhub API key from the env var names users actually have configured, and (2) restore crypto ticker support by mapping Yahoo-style symbols (e.g. BTC-USD) to an exchange-prefixed Finnhub symbol for quote fetches.

Changes:

  • Add FINNHUB_API_KEY fallbacks to FINNHUB_TOKEN / finnhub_token in server config loading.
  • Auto-map *-USD crypto tickers (e.g. BTC-USD) to COINBASE:* for Finnhub /quote requests while keeping the displayed label unchanged.
  • Update docs and UI hints/examples to reflect Finnhub + crypto support.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/routes.rs Adds finnhub_symbol() helper and uses it when fetching Finnhub quotes for tickers.
src/config.rs Adds env var aliasing for the Finnhub API key.
README.md Documents key aliases and crypto symbol mapping behavior.
frontend/actions.ts Updates settings editor placeholder/hint to include crypto example.
public/actions.js Updates built JS placeholder/hint to include crypto example.
.env.example Updates ticker/key guidance for Finnhub + crypto and key aliases.
.gitignore Ignores .opencode/ directory.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/config.rs
Comment on lines +156 to +159
finnhub_api_key: env::var("FINNHUB_API_KEY")
.or_else(|_| env::var("FINNHUB_TOKEN"))
.or_else(|_| env::var("finnhub_token"))
.unwrap_or_default(),
Comment thread frontend/actions.ts
overlay.id = 'settingsEditor';
const panels = dashboardSettings.panels;
overlay.innerHTML = `<form class="links-editor-box settings-editor-box"><div class="links-editor-head"><div><h2>Configure</h2><p class="muted">Sidebar widgets and stock tickers are saved in dashboard-config.json.</p></div><button type="button" class="ghost" data-close-settings>Cancel</button></div><div class="settings-grid"><label><input type="checkbox" name="machine" ${panels.machine ? 'checked' : ''}> Machine</label><label class="settings-subsetting"><input type="checkbox" name="machineSensors" ${panels.machineSensors ? 'checked' : ''}> Thermal sensors</label><label><input type="checkbox" name="remoteHosts" ${panels.remoteHosts ? 'checked' : ''}> Remote hosts</label><label><input type="checkbox" name="containers" ${panels.containers ? 'checked' : ''}> Local containers</label><label><input type="checkbox" name="links" ${panels.links ? 'checked' : ''}> Links</label><label><input type="checkbox" name="tickers" ${panels.tickers ? 'checked' : ''}> Ticker bar</label><label><input type="checkbox" name="expandLists" ${panels.expandLists ? 'checked' : ''}> Expand lists (no scrollbars)</label></div><label>Tickers</label><div class="ticker-editor"><div class="ticker-chips" id="tickerChips"></div><div class="ticker-add"><input id="tickerInput" type="text" spellcheck="false" autocapitalize="characters" placeholder="Add symbol — e.g. NVDA, TSLA"><button type="button" id="addTickerBtn"><span class="ticker-add-plus">+</span> Add</button></div><p class="muted ticker-hint">Enter to add · Finnhub symbols (US stocks) · max 16</p></div><div class="links-editor-actions"><button type="submit" class="primary">${icon('settings')}<span>Save config</span></button></div></form>`;
overlay.innerHTML = `<form class="links-editor-box settings-editor-box"><div class="links-editor-head"><div><h2>Configure</h2><p class="muted">Sidebar widgets and stock tickers are saved in dashboard-config.json.</p></div><button type="button" class="ghost" data-close-settings>Cancel</button></div><div class="settings-grid"><label><input type="checkbox" name="machine" ${panels.machine ? 'checked' : ''}> Machine</label><label class="settings-subsetting"><input type="checkbox" name="machineSensors" ${panels.machineSensors ? 'checked' : ''}> Thermal sensors</label><label><input type="checkbox" name="remoteHosts" ${panels.remoteHosts ? 'checked' : ''}> Remote hosts</label><label><input type="checkbox" name="containers" ${panels.containers ? 'checked' : ''}> Local containers</label><label><input type="checkbox" name="links" ${panels.links ? 'checked' : ''}> Links</label><label><input type="checkbox" name="tickers" ${panels.tickers ? 'checked' : ''}> Ticker bar</label><label><input type="checkbox" name="expandLists" ${panels.expandLists ? 'checked' : ''}> Expand lists (no scrollbars)</label></div><label>Tickers</label><div class="ticker-editor"><div class="ticker-chips" id="tickerChips"></div><div class="ticker-add"><input id="tickerInput" type="text" spellcheck="false" autocapitalize="characters" placeholder="Add symbol — e.g. NVDA, TSLA, BTC-USD"><button type="button" id="addTickerBtn"><span class="ticker-add-plus">+</span> Add</button></div><p class="muted ticker-hint">Enter to add · Finnhub symbols · US stocks + crypto (BTC-USD) · max 16</p></div><div class="links-editor-actions"><button type="submit" class="primary">${icon('settings')}<span>Save config</span></button></div></form>`;
Comment thread public/actions.js
overlay.id = 'settingsEditor';
const panels = dashboardSettings.panels;
overlay.innerHTML = `<form class="links-editor-box settings-editor-box"><div class="links-editor-head"><div><h2>Configure</h2><p class="muted">Sidebar widgets and stock tickers are saved in dashboard-config.json.</p></div><button type="button" class="ghost" data-close-settings>Cancel</button></div><div class="settings-grid"><label><input type="checkbox" name="machine" ${panels.machine ? 'checked' : ''}> Machine</label><label class="settings-subsetting"><input type="checkbox" name="machineSensors" ${panels.machineSensors ? 'checked' : ''}> Thermal sensors</label><label><input type="checkbox" name="remoteHosts" ${panels.remoteHosts ? 'checked' : ''}> Remote hosts</label><label><input type="checkbox" name="containers" ${panels.containers ? 'checked' : ''}> Local containers</label><label><input type="checkbox" name="links" ${panels.links ? 'checked' : ''}> Links</label><label><input type="checkbox" name="tickers" ${panels.tickers ? 'checked' : ''}> Ticker bar</label><label><input type="checkbox" name="expandLists" ${panels.expandLists ? 'checked' : ''}> Expand lists (no scrollbars)</label></div><label>Tickers</label><div class="ticker-editor"><div class="ticker-chips" id="tickerChips"></div><div class="ticker-add"><input id="tickerInput" type="text" spellcheck="false" autocapitalize="characters" placeholder="Add symbol — e.g. NVDA, TSLA"><button type="button" id="addTickerBtn"><span class="ticker-add-plus">+</span> Add</button></div><p class="muted ticker-hint">Enter to add · Finnhub symbols (US stocks) · max 16</p></div><div class="links-editor-actions"><button type="submit" class="primary">${icon('settings')}<span>Save config</span></button></div></form>`;
overlay.innerHTML = `<form class="links-editor-box settings-editor-box"><div class="links-editor-head"><div><h2>Configure</h2><p class="muted">Sidebar widgets and stock tickers are saved in dashboard-config.json.</p></div><button type="button" class="ghost" data-close-settings>Cancel</button></div><div class="settings-grid"><label><input type="checkbox" name="machine" ${panels.machine ? 'checked' : ''}> Machine</label><label class="settings-subsetting"><input type="checkbox" name="machineSensors" ${panels.machineSensors ? 'checked' : ''}> Thermal sensors</label><label><input type="checkbox" name="remoteHosts" ${panels.remoteHosts ? 'checked' : ''}> Remote hosts</label><label><input type="checkbox" name="containers" ${panels.containers ? 'checked' : ''}> Local containers</label><label><input type="checkbox" name="links" ${panels.links ? 'checked' : ''}> Links</label><label><input type="checkbox" name="tickers" ${panels.tickers ? 'checked' : ''}> Ticker bar</label><label><input type="checkbox" name="expandLists" ${panels.expandLists ? 'checked' : ''}> Expand lists (no scrollbars)</label></div><label>Tickers</label><div class="ticker-editor"><div class="ticker-chips" id="tickerChips"></div><div class="ticker-add"><input id="tickerInput" type="text" spellcheck="false" autocapitalize="characters" placeholder="Add symbol — e.g. NVDA, TSLA, BTC-USD"><button type="button" id="addTickerBtn"><span class="ticker-add-plus">+</span> Add</button></div><p class="muted ticker-hint">Enter to add · Finnhub symbols · US stocks + crypto (BTC-USD) · max 16</p></div><div class="links-editor-actions"><button type="submit" class="primary">${icon('settings')}<span>Save config</span></button></div></form>`;
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