{"record":{"id":"e073385148914680","repo":"ZhuLinsen/daily_stock_analysis","slug":"longbridge-temporarily-unavailable-for-daily-data","errorCode":null,"errorMessage":"Longbridge temporarily unavailable for daily_data","messagePattern":"Longbridge temporarily unavailable for daily_data","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"warning","filePath":"data_provider/longbridge_fetcher.py","lineNumber":873,"sourceCode":"            circ_mv=circ_mv,\n        )\n\n        logger.info(\n            f\"[Longbridge] {symbol} 行情获取成功: \"\n            f\"价格={price}, 量比={volume_ratio}, 换手率={turnover_rate}\"\n        )\n        return quote\n\n    # ------------------------------------------------------------------\n    # BaseFetcher abstract methods (historical daily data)\n    # ------------------------------------------------------------------\n\n    def _fetch_raw_data(\n        self, stock_code: str, start_date: str, end_date: str\n    ) -> pd.DataFrame:\n        \"\"\"Fetch historical candlesticks from Longbridge.\"\"\"\n        if not self.is_available_for_request(\"daily_data\"):\n            raise RuntimeError(\"Longbridge temporarily unavailable for daily_data\")\n\n        symbol = _to_longbridge_symbol(stock_code)\n        if symbol is None:\n            raise ValueError(f\"Cannot convert {stock_code} to Longbridge symbol\")\n\n        ctx = self._get_ctx()\n        if ctx is None:\n            raise RuntimeError(\"Longbridge QuoteContext not available\")\n\n        from longbridge.openapi import Period, AdjustType\n\n        start_dt = datetime.strptime(start_date, \"%Y-%m-%d\").date()\n        end_dt = datetime.strptime(end_date, \"%Y-%m-%d\").date()\n\n        try:\n            candles = ctx.history_candlesticks_by_date(\n                symbol,\n                Period.Day,","sourceCodeStart":855,"sourceCodeEnd":891,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/data_provider/longbridge_fetcher.py#L855-L891","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nif fetcher.is_available_for_request('daily_data') is not enforced at call site:\n    df = fetcher.get_daily_data(code, ...)  # RuntimeError\n# after\nif fetcher.is_available_for_request('daily_data'):\n    df = fetcher.get_daily_data(code, ...)\nelse:\n    df = manager.get_daily_data(code, ...)  # failover chain","handlingStrategy":"fallback","validationCode":"if fetcher.is_available_for_request('daily_data'):\n    df = fetcher.get_daily_data(code, ...)\nelse:\n    df = manager.get_daily_data(code, ...)  # chain skips unavailable sources","typeGuard":null,"tryCatchPattern":"try:\n    df = longbridge.get_daily_data(code, ...)\nexcept RuntimeError as e:\n    if 'temporarily unavailable' in str(e):\n        df = manager.get_daily_data(code, ...)  # immediate failover; cooldown will reset","preventionTips":["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."],"tags":["longbridge","circuit-breaker","availability","failover"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}