ZhuLinsen/daily_stock_analysis · error · ValueError
Unsupported daily source: {source}
Error message
Unsupported daily source: {source} What it means
ValueError raised by fetch_daily_history in the screening daily-data module when the source argument is not 'auto' and not one of the six explicit sources ('akshare', 'baostock', 'tushare', 'tencent', 'sina', 'yfinance'). _normalize_daily_source canonicalizes the input first; anything that still does not match the recognized names aborts before cache or network access.
Source
Thrown at src/services/screening/daily.py:199
direct HTTP K-line source before wrapper-based fallbacks. ``yfinance`` is
explicit-only (never part of ``auto``) and expects a US ticker rather than
an A-share code.
"""
normalized_code = _normalize_daily_code(code)
normalized_lookback_days = int(lookback_days)
src = _normalize_daily_source(source)
if src == "auto":
sources: tuple[str, ...] = (
("tushare", "tencent", "sina", "akshare", "baostock")
if _has_tushare_token()
else ("tencent", "sina", "akshare", "baostock")
)
sources, source_order_notes = _rank_daily_sources_by_health(sources)
elif src in ("akshare", "baostock", "tushare", "tencent", "sina", "yfinance"):
sources = (src,)
source_order_notes = []
else:
raise ValueError(f"Unsupported daily source: {source}")
cache_path = None
if cache_dir is not None:
cache_path = _daily_history_cache_path(
cache_dir,
code=normalized_code,
source=src,
lookback_days=normalized_lookback_days,
)
cached = _read_daily_history_cache(cache_path, ttl_seconds=cache_ttl_seconds)
if cached is not None:
return cached
attempts = max(int(retries), 0) + 1
errors: list[str] = []
for current in sources:
disabled_reason = _source_disabled_reason(current)
if disabled_reason:View on GitHub (pinned to 5159bd72e8)
Solutions
- Use one of: tencent, sina, akshare, baostock, tushare, yfinance, or 'auto' for the health-ranked fallback chain.
- Fix aliases in config: 'yahoo' -> 'yfinance', 'em'/'eastmoney' -> use 'tencent' or 'auto'.
- Validate config at startup: assert source in {'auto','akshare','baostock','tushare','tencent','sina','yfinance'}.
- If you want resilience rather than a fixed provider, switch to source='auto' so a failing provider degrades instead of erroring.
Example fix
# before
fetch_daily_history('600519', source='yahoo')
# after
fetch_daily_history('600519', source='yfinance')
# or let the module rank providers by health
fetch_daily_history('600519', source='auto') Defensive patterns
Strategy: validation
Validate before calling
VALID_SOURCES = {'auto', 'tencent', 'sina', 'akshare', 'baostock', 'tushare', 'yfinance'}
source = (source or '').strip().lower()
alias = {'yahoo': 'yfinance', 'em': 'auto', 'eastmoney': 'auto'}
source = alias.get(source, source)
if source not in VALID_SOURCES:
raise ValueError(f'daily source must be one of {sorted(VALID_SOURCES)}')
df = fetch_daily_history(code, source=source) Type guard
def is_valid_daily_source(value: str) -> bool:
return (value or '').strip().lower() in {'auto', 'tencent', 'sina', 'akshare', 'baostock', 'tushare', 'yfinance'} Prevention
- Use adapter names, not brand names ('yfinance', not 'yahoo').
- Prefer source='auto' so provider outages degrade through the ranked fallback chain instead of failing.
- Validate the source value when loading config so typos surface at startup.
When it happens
Trigger: Calling fetch_daily_history(code, source='eastmoney'), source='em', source='yahoo' (the accepted name is 'yfinance'), or source='' / None coerced to an invalid default. 'auto' is special-cased to pick a ranked fallback chain (Tushare first when a token is configured).
Common situations: Users writing the provider's brand name ('eastmoney', 'yahoo') instead of the adapter name; passing a source string from an older config after an adapter rename; env/config typos like 'tushare ' handled by normalization but 'tusharre' not; hardcoding a source that requires optional deps that were renamed.
Related errors
- Desktop backend origin is invalid
- Desktop window is unavailable
- Desktop share image capture returned an empty image
- capability_unsupported
- unsupported alert_type for current EventMonitor runtime: {al
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/af5cc1ace20459cb.
Report an issue: GitHub.