ZhuLinsen/daily_stock_analysis · error · DataFetchError

TickFlow daily K-line request failed: {exc}

Error message

TickFlow daily K-line request failed: {exc}

What it means

DataFetchError raised when the client.klines.get(...) call to the TickFlow API throws any exception (HTTP error, timeout, SDK error, malformed response). The original exception is chained ('from exc') so the root cause stays visible; no partial data is returned.

Source

Thrown at data_provider/tickflow_fetcher.py:197

            return cached

        client = self._get_client()
        if client is None:
            raise DataFetchError("TickFlow API key is not configured")

        request_count = self._daily_kline_count(start_date, end_date)
        try:
            df = client.klines.get(
                symbol,
                period="1d",
                count=request_count,
                start_time=self._date_to_ms(start_date),
                end_time=self._date_to_ms(end_date, end_of_day=True),
                adjust=self.kline_adjust,
                as_dataframe=True,
            )
        except Exception as exc:
            raise DataFetchError(f"TickFlow daily K-line request failed: {exc}") from exc

        raw_df = self._prepare_daily_frame(
            df,
            symbol=symbol,
            start_date=start_date,
            end_date=end_date,
            count=request_count,
            context="single",
        )
        self._set_daily_cache(cache_key, raw_df)
        return raw_df.copy()

    def _normalize_data(self, df: pd.DataFrame, stock_code: str) -> pd.DataFrame:
        raw = self._coerce_frame(df)
        if raw.empty:
            return pd.DataFrame(columns=["code", *STANDARD_COLUMNS])

        normalized = pd.DataFrame()

View on GitHub (pinned to 5159bd72e8)

Solutions

  1. Log and inspect exc.__cause__ to classify: auth (fix key), rate limit (back off), network (fix egress), or 5xx (wait/fallback).
  2. Catch DataFetchError in the manager and fall back to Akshare/Tencent for A-share daily data.
  3. For predictable transient failures, rely on the project's retry/fallback layer rather than tight loops against TickFlow.

Example fix

# before
try:
    df = tickflow_fetcher.get_stock_data(code, start, end)
except DataFetchError:
    raise

# after
try:
    df = tickflow_fetcher.get_stock_data(code, start, end)
except DataFetchError as e:
    logger.warning(f"TickFlow failed ({e.__cause__}), falling back to akshare")
    df = akshare_fetcher.get_stock_data(code, start, end)
Defensive patterns

Strategy: fallback

Try / catch

try:
    df = tickflow_fetcher.get_stock_data(code, start, end)
except DataFetchError as e:
    cause = str(e.__cause__ or "")
    logger.warning(f"TickFlow kline error: {cause}")
    df = akshare_fetcher.get_stock_data(code, start, end)  # transient/outage fallback

Prevention

When it happens

Trigger: TickFlow HTTP API unreachable, 4xx/5xx responses, rate limiting, expired/invalid API key producing auth errors, or SDK deserialization failures while fetching daily klines with period='1d'.

Common situations: TickFlow service outage; quota exhausted; network egress blocked from the runtime host; key revoked; SDK version drift changing exception types.

Related errors


AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15). Data as JSON: /api/errors/6ed75b9f5ba03810. Report an issue: GitHub.