ZhuLinsen/daily_stock_analysis · warning · RuntimeError
Longbridge temporarily unavailable for daily_data
Error message
Longbridge temporarily unavailable for daily_data
What it means
LongbridgeFetcher._fetch_raw_data guards on is_available_for_request('daily_data') and raises RuntimeError when its internal availability/circuit-breaker state says the source is temporarily down for that capability (e.g. consecutive recent failures or missing credentials made the fetcher mark itself unavailable). It is a skip-now signal, not a permanent failure.
Source
Thrown at data_provider/longbridge_fetcher.py:873
circ_mv=circ_mv,
)
logger.info(
f"[Longbridge] {symbol} 行情获取成功: "
f"价格={price}, 量比={volume_ratio}, 换手率={turnover_rate}"
)
return quote
# ------------------------------------------------------------------
# BaseFetcher abstract methods (historical daily data)
# ------------------------------------------------------------------
def _fetch_raw_data(
self, stock_code: str, start_date: str, end_date: str
) -> pd.DataFrame:
"""Fetch historical candlesticks from Longbridge."""
if not self.is_available_for_request("daily_data"):
raise RuntimeError("Longbridge temporarily unavailable for daily_data")
symbol = _to_longbridge_symbol(stock_code)
if symbol is None:
raise ValueError(f"Cannot convert {stock_code} to Longbridge symbol")
ctx = self._get_ctx()
if ctx is None:
raise RuntimeError("Longbridge QuoteContext not available")
from longbridge.openapi import Period, AdjustType
start_dt = datetime.strptime(start_date, "%Y-%m-%d").date()
end_dt = datetime.strptime(end_date, "%Y-%m-%d").date()
try:
candles = ctx.history_candlesticks_by_date(
symbol,
Period.Day,View on GitHub (pinned to 5159bd72e8)
Solutions
- Wait for the availability window to reset (or restart the process) before retrying Longbridge for daily_data.
- Fail over to the next US/HK-capable source (Finnhub/AlphaVantage/YFinance) via DataFetcherManager — the chain already handles this.
- If it never becomes available, check Longbridge credentials/config so initialization marks the capability requestable.
Example fix
# before
if fetcher.is_available_for_request('daily_data') is not enforced at call site:
df = fetcher.get_daily_data(code, ...) # RuntimeError
# after
if fetcher.is_available_for_request('daily_data'):
df = fetcher.get_daily_data(code, ...)
else:
df = manager.get_daily_data(code, ...) # failover chain Defensive patterns
Strategy: fallback
Validate before calling
if fetcher.is_available_for_request('daily_data'):
df = fetcher.get_daily_data(code, ...)
else:
df = manager.get_daily_data(code, ...) # chain skips unavailable sources Try / catch
try:
df = longbridge.get_daily_data(code, ...)
except RuntimeError as e:
if 'temporarily unavailable' in str(e):
df = manager.get_daily_data(code, ...) # immediate failover; cooldown will reset Prevention
- Check is_available_for_request(capability) before direct Longbridge calls.
- Respect the source's cooldown instead of hammering it — repeated calls extend unavailability.
- Route through DataFetcherManager so availability checks and failover are automatic.
When it happens
Trigger: Calling get_daily_data on LongbridgeFetcher after earlier Longbridge failures tripped the availability state for daily_data, or when initialization (credentials/context) did not complete, so is_available_for_request returns False.
Common situations: Failover loops that retry Longbridge too soon after an outage; process kept alive across rate-limit windows; Longbridge creds partially configured so the fetcher is registered but not requestable.
Related errors
- [{self.name}] 未获取到 {stock_code} 的数据
- {market_label} {stock_code} 获取失败: {errors joined by newline}
- 所有数据源获取 {stock_code} 失败: {errors joined by newline}
- EfinanceFetcher 不支持美股 {stock_code},请使用 AkshareFetcher 或 Yfin
- EfinanceFetcher 不支持港股日线 {stock_code},请使用 AkshareFetcher 或其他港
AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15).
Data as JSON: /api/errors/e073385148914680.
Report an issue: GitHub.