yfinance 行情数据
yfinance 行情数据:通过 Yahoo Finance 获取全球多市场股票、指数、外汇及加密货币的历史行情、财务数据、实时报价和财务日历。 含 14 条反模式约束。
晶体简介
Constraints
Evidence Quality
Medium confidence — review before critical use
31 条不可违反的约束
WHENWhen implementing HTTP session initialization for Yahoo API
ACTIONUse curl_cffi.requests.Session with impersonate='chrome'
CONSEQUENCEYahoo's non-browser client blocking detects and rejects requests from standard HTTP libraries, resulting in 403 Forbidden errors and complete data access failure
WHENWhen handling HTTP request errors for Yahoo API
ACTIONRetry only transient errors (TimeoutError, socket.error, OSError, ConnectionError) and raise for permanent errors
CONSEQUENCERetrying permanent errors like ValueError or KeyError wastes resources and masks underlying code bugs instead of surfacing them for proper debugging
WHENWhen making HTTP requests to Yahoo API endpoints
ACTIONInclude crumb and cookie authentication with every request
CONSEQUENCEWithout proper crumb authentication, Yahoo API returns 401 Unauthorized or HTML error pages instead of JSON data, breaking all downstream data processing
常见问题
讨论 (0)
暂无讨论,成为第一个发言的人吧!
更新历史
v0.1.0: 首次发布到 Doramagic.ai。基于 tangweigang-jpg/doramagic-skills 的自动化 batch-v1 元数据 + 自动生成 FAQ。