Skip to content

Fix Yahoo Finance module showing all zeroes - #2142

Merged
Seanstoppable merged 3 commits into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-issue-1701-yahoo-finance-module-shows-all-zeroes-0bb588
Jul 26, 2026
Merged

Seanstoppable merged 3 commits into
wtfutil:trunkfrom
Seanstoppable:seanstoppable-issue-1701-yahoo-finance-module-shows-all-zeroes-0bb588

Conversation

@Seanstoppable

@Seanstoppable Seanstoppable commented Jul 26, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Fixes #1701 (and duplicate #1709). Also addresses #1785 (piquette/finance-go dep is a dead project). The yfinance module rendered every field as 0.00 for all symbols.

Root cause

modules/stocks/yfinance used github.com/piquette/finance-go, which calls Yahoo's legacy v7/v10 finance/quote endpoints. Yahoo now requires a session cookie + crumb token on those endpoints, and the library (unmaintained since ~2021, flagged as a dead dependency in #1785) never supplies one — Yahoo responds with a quote object that deserializes to all zeroes instead of an error, so the widget couldn't tell anything had gone wrong.

There's no official Yahoo Finance Go library; the unofficial alternatives are newer/single-maintainer projects with no real advantage over calling the endpoint directly, so this avoids adding a new dependency.

Fix

  • Drop the piquette/finance-go dependency and fetch quotes directly from Yahoo's v8/finance/chart/{symbol} endpoint, which is still reachable without any crumb/cookie and returns everything the widget needs (regularMarketPrice, chartPreviousClose, currency, trading-period windows).
  • Market state (PRE/REGULAR/POST/CLOSED) is now derived from the reported trading-period windows instead of a field Yahoo no longer reliably returns for this endpoint.
  • Unknown/invalid symbols (e.g. the issue's NIFTY50) still fall back to the existing "?" display.
  • Removed github.com/piquette/finance-go from go.mod/go.sum via go mod tidy (verified unused elsewhere in the repo), which also resolves piquette/finance-go dep is a dead project #1785.

Tests

  • Added yquote_test.go, settings_test.go, and widget_test.go covering: equity/FX chart parsing, API-error and malformed-JSON responses, previous-close fallback, network errors, unknown-symbol fallback, market-state transitions, settings parsing, widget construction, and content rendering (including sort-by-change).
  • Module coverage went from 34.9% → 97.6% of statements.

Verification

  • go build ./..., go vet ./modules/stocks/yfinance/..., and golangci-lint run ./modules/stocks/yfinance/... all pass with 0 issues.
  • go test ./modules/stocks/yfinance/... passes.
  • Manually confirmed against the live API with symbols from the issue (AMD, ^NSEI, EURUSD=X, and the invalid NIFTY50) — all return correct non-zero prices/changes, with NIFTY50 gracefully falling back to ?.
  • Added a yfinance module block to my local config.yml for manual verification of the rendered widget.

Seanstoppable and others added 3 commits July 25, 2026 20:26
…finance-go

Yahoo's v7/v10 finance/quote endpoints (used by piquette/finance-go) now
require a session cookie + crumb token that the unmaintained library never
sends, causing Yahoo to silently return zero-valued quotes instead of an
error.

Replace it with a direct call to Yahoo's v8/finance/chart/{symbol}
endpoint, which is still accessible without any crumb/cookie and provides
everything the widget needs (price, previous close, currency, trading
session windows). Market state (PRE/REGULAR/POST/CLOSED) is now derived
from the reported trading period windows instead of the API.

Fixes wtfutil#1701

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add tests for GetTrend, GetTrendIcon, GetMarketIcon, tableStyle,
NewSettingsFromYAML, NewWidget, Widget.content, and Widget.Refresh.
Also add fetchChartMeta/quotes tests for the API-error, malformed-JSON,
previous-close-fallback, network-error, and success paths that weren't
previously exercised.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Seanstoppable
Seanstoppable force-pushed the seanstoppable-issue-1701-yahoo-finance-module-shows-all-zeroes-0bb588 branch from 3d6c9b4 to d67d29f Compare July 26, 2026 03:28
@Seanstoppable
Seanstoppable enabled auto-merge (squash) July 26, 2026 03:31
@Seanstoppable
Seanstoppable merged commit a145823 into wtfutil:trunk Jul 26, 2026
4 checks passed
@Seanstoppable
Seanstoppable deleted the seanstoppable-issue-1701-yahoo-finance-module-shows-all-zeroes-0bb588 branch July 26, 2026 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

piquette/finance-go dep is a dead project Yahoo Finance Module shows all zeroes

1 participant

⌂ 换网址