{"record":{"id":"05fe9cf9bdb974f7","repo":"hsliuping/TradingAgents-CN","slug":"alpha-vantage-api-limit-info-msg","errorCode":null,"errorMessage":"Alpha Vantage API limit: {info_msg}","messagePattern":"Alpha Vantage API limit: (.+?)","errorType":"error_code","errorClass":"AlphaVantageRateLimitError","httpStatus":429,"severity":"error","filePath":"tradingagents/dataflows/providers/us/alpha_vantage_common.py","lineNumber":238,"sourceCode":"                    raise AlphaVantageRateLimitError(\n                        \"Alpha Vantage API rate limit exceeded. \"\n                        \"Please wait a moment and try again, or upgrade your API plan.\"\n                    )\n            \n            # 检查信息字段（可能包含限制提示）\n            if \"Information\" in data:\n                info_msg = data[\"Information\"]\n                logger.warning(f\"⚠️ [Alpha Vantage] 信息: {info_msg}\")\n                \n                # 如果是速率限制信息\n                if \"premium\" in info_msg.lower() or \"limit\" in info_msg.lower():\n                    if attempt < max_retries - 1:\n                        wait_time = retry_delay * (attempt + 1)\n                        logger.info(f\"⏳ 等待 {wait_time} 秒后重试...\")\n                        time.sleep(wait_time)\n                        continue\n                    else:\n                        raise AlphaVantageRateLimitError(\n                            f\"Alpha Vantage API limit: {info_msg}\"\n                        )\n            \n            # 成功获取数据\n            logger.debug(f\"✅ [Alpha Vantage] 请求成功: {function}\")\n            return data\n            \n        except requests.exceptions.Timeout:\n            logger.warning(f\"⚠️ [Alpha Vantage] 请求超时 (尝试 {attempt + 1}/{max_retries})\")\n            if attempt < max_retries - 1:\n                time.sleep(retry_delay)\n                continue\n            else:\n                raise AlphaVantageAPIError(\"Alpha Vantage API request timeout\")\n                \n        except requests.exceptions.RequestException as e:\n            logger.error(f\"❌ [Alpha Vantage] 请求失败: {e}\")\n            if attempt < max_retries - 1:","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/hsliuping/TradingAgents-CN/blob/74783e8817d6cf6de29867880631cc555153f36b/tradingagents/dataflows/providers/us/alpha_vantage_common.py#L220-L256","documentation":"Raised as AlphaVantageRateLimitError when the response's 'Information' field indicates a limit (e.g. free-tier monthly/day cap messages) and retries with backoff did not resolve it. Distinct from the 'Note' frequency case: 'Information' covers general limit notices.","triggerScenarios":"Exhausting the free-tier call allowance; Alpha Vantage returns {'Information': '...limit reached...'}, the loop retries a few times, then raises with the upstream info_msg.","commonSituations":"Free key hitting the 25/day cap mid-run, key shared across environments, or a long-running job that accumulates calls over days.","solutions":["Upgrade the API plan or switch to a paid key","Cache quote/kline/news responses aggressively to cut call volume","Distribute calls across the day or batch through a single throttled worker","Monitor remaining quota and stop before the cap"],"exampleFix":"# before\nkey = 'FREE_KEY'  # 25 calls/day\n# after\nkey = os.environ['ALPHA_VANTAGE_PREMIUM_KEY']  # higher limit","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from tradingagents.dataflows.providers.us.alpha_vantage_common import AlphaVantageRateLimitError\ntry:\n    data = _make_api_request(params)\nexcept AlphaVantageRateLimitError as e:\n    if 'API limit' in str(e):\n        data = fallback_datasource_fetch(params)  # or queue for tomorrow\n    else:\n        raise","preventionTips":["Track quota usage locally and stop before the cap","Cache aggressively; many endpoints are immutable history","Upgrade the key for production volume","Spread batch jobs across days"],"tags":["python","alpha-vantage","rate-limit","quota"],"backgroundTag":"api-rate-limit-exceeded","analyzedSha":"74783e8817d6cf6de29867880631cc555153f36b","analyzedAt":"2026-08-28T11:39:07.729Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}