wtfutil/wtf · error

yfinance: no results for symbol %q

Error message

yfinance: no results for symbol %q

What it means

When the chart response is otherwise healthy (HTTP 200, no chart.error) but chart.result is an empty array, fetchChartMeta reports that it got nothing usable for the symbol. This is Yahoo's silent way of saying the symbol matched no data.

Source

Thrown at modules/stocks/yfinance/yquote.go:92

		return nil, err
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("yfinance: unexpected status %d for symbol %q", resp.StatusCode, symbol)
	}

	var parsed chartResponse
	if err := json.NewDecoder(resp.Body).Decode(&parsed); err != nil {
		return nil, err
	}

	if parsed.Chart.Error != nil {
		return nil, fmt.Errorf("yfinance: API error for symbol %q: %v", symbol, parsed.Chart.Error)
	}

	if len(parsed.Chart.Result) == 0 {
		return nil, fmt.Errorf("yfinance: no results for symbol %q", symbol)
	}

	return &parsed.Chart.Result[0].Meta, nil
}

// marketState determines whether the quote is trading pre-market, in the
// regular session, post-market, or closed, based on the trading period
// windows Yahoo reports for the current day.
func marketState(periods tradingPeriods) string {
	now := time.Now().Unix()

	switch {
	case now < periods.Pre.Start:
		return "CLOSED"
	case now < periods.Regular.Start:
		return "PRE"
	case now <= periods.Regular.End:
		return "REGULAR"

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Confirm the symbol exists and has data on Yahoo Finance
  2. Check widget config for an empty or blank symbol value
  3. Replace delisted/renamed symbols with current ones
  4. Handle the empty-result case in callers if symbols are user-supplied

Example fix

// before
symbol := cfg.Get("symbol") // empty -> "no results for symbol \"\""
// after
symbol := cfg.Get("symbol")
if symbol == "" { return nil, errors.New("symbol not configured") }
Defensive patterns

Strategy: validation

Validate before calling

if symbol == "" { return errors.New("symbol not configured") }

Type guard

func hasResults(cr chartResponse) bool { return len(cr.Chart.Result) > 0 }

Try / catch

meta, err := fetchChartMeta(symbol)
if err != nil && strings.Contains(err.Error(), "no results") {
    log.Printf("symbol %q has no data; check config", symbol)
    return
}

Prevention

When it happens

Trigger: HTTP 200 with chart.error == null and len(chart.result) == 0: unknown symbols, symbols with no trading data, or empty-string symbol passed to fetchChartMeta.

Common situations: Configuring a delisted ticker; passing an empty symbol when config is missing a required field; querying illiquid/suspended securities that return no results.

Related errors


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/0634de480221868c. Report an issue: GitHub.