yahoo-finance - 雅虎财经 URL 不起作用

标签 yahoo-finance

我使用以下 URL 从雅虎财经获取历史数据已经有一段时间了,但从昨天开始就停止工作了。

https://ichart.finance.yahoo.com/table.csv?s=SPY

浏览此网站时显示:

Will be right back...

Thank you for your patience.

Our engineers are working quickly to resolve the issue.

但是,由于这个问题从昨天开始仍然存在,我开始认为他们已经停止了这项服务?

我的 SO 搜索仅指向 this topic ,虽然与 https 有关...

还有其他人遇到这个问题吗? 我该如何解决这个问题?他们是否提供对历史数据的不同访问?

最佳答案

雅虎已经采用了 Reactjs 前端,这意味着如果您分析从客户端到后端的请求 header ,您可以获得它们用于填充客户端存储的实际 JSON。

主机:

如果您计划使用代理或持久连接,请使用query2.finance.yahoo.com。但就本文而言,用于示例 URL 的主机并不意味着暗示其所使用的路径的任何信息。

<小时/>

基本数据

(用您的符号替换:AAPL)

  • /v10/finance/quoteSummary/AAPL?modules=

?modules= 查询的输入:

    [
       'assetProfile',
       'summaryProfile',
       'summaryDetail',
       'esgScores',
       'price',
       'incomeStatementHistory',
       'incomeStatementHistoryQuarterly',
       'balanceSheetHistory',
       'balanceSheetHistoryQuarterly',
       'cashflowStatementHistory',
       'cashflowStatementHistoryQuarterly',
       'defaultKeyStatistics',
       'financialData',
       'calendarEvents',
       'secFilings',
       'recommendationTrend',
       'upgradeDowngradeHistory',
       'institutionOwnership',
       'fundOwnership',
       'majorDirectHolders',
       'majorHoldersBreakdown',
       'insiderTransactions',
       'insiderHolders',
       'netSharePurchaseActivity',
       'earnings',
       'earningsHistory',
       'earningsTrend',
       'industryTrend',
       'indexTrend',
       'sectorTrend']

示例 URL: 查询上述所有模块

  • https://query2.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=assetProfile%2CsummaryProfile%2CsummaryDetail%2CesgScores%2Cprice%2CvenueStatementHistory%2CvenueStatementHistoryQuarterly%2CbalanceSheetHistory%2CbalanceSheetHistoryQuarterly%2CcashflowStatementHistory%2C现金流报表历史季度% 2CdefaultKeyStatistics%2CfinancialData%2CcalendarEvents%2CsecFilings%2CrecommendationTrend%2CupgradeDowngradeHistory%2CinstitutionOwnership%2CfundOwnership%2CmajorDirectHolders%2CmajorHoldersBreakdown%2CinsiderTransactions%2CinsiderHolders%2CnetSharePurchaseActivity%2Cearnings% 2CearningsHistory%2CearningsTrend%2CindustryTrend%2CindexTrend%2CsectorTrend

%2C, 的十六进制表示形式,需要插入到您请求的每个模块之间。 details about the hex encoding bit (如果你关心的话)

<小时/>

期权合约

  • /v7/finance/options/AAPL(当前到期)
  • /v7/finance/options/AAPL?date=1679011200(2023 年 3 月 17 日到期)

示例网址:

  • https://query2.finance.yahoo.com/v7/finance/options/AAPL(当前到期)
  • https://query2.finance.yahoo.com/v7/finance/options/AAPL?date=1679011200(第 17 场比赛,2023 年到期)

任何表示为 UNIX 时间戳的有效 future 到期时间都可以在 ?date= 查询中使用。如果您查询当前过期时间,JSON 响应将包含可在 ?date= 查询中使用的所有有效过期时间的列表。 (here is a post explaining converting human-readable dates to UNIX timestamp in Python)

<小时/>

价格

  • /v8/finance/chart/AAPL?symbol=AAPL&period1=0&period2=9999999999&interval=3mo

&interval= 的可能输入: 1m, 5m, 15m, 30m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo

m (minute) intervals are limited to 30days with period1 and period2 spaning a maximum of 7 days per/request. Exceeding either of these limits will result in an error and will not round

h (hour) interval is limited to 730days with no limit to span. Exceeding this will result in an error and will not round

period1=:UNIX 时间戳表示您希望开始的日期。

d (day), wk (week), mo (month) intervals with values less than the initial trading date will be rounded up to the initial trading date.

period2=:UNIX 时间戳表示您希望结束的日期。

For all intervals: values greater than the last trading date will be rounded down to the most recent timestamp available.

添加上市前和上市后数据

&includePrePost=true

添加股息和分割

&events=div%7Csplit

%7C| 的十六进制。 , 可以工作,但雅虎内部使用管道

示例网址:

  • https://query1.finance.yahoo.com/v8/finance/chart/AAPL?symbol=AAPL&period1=0&period2=9999999999&interval=1d&includePrePost=true&events=div%7Csplit

上述请求将返回股票代码 AAPL 以 1 天为间隔的所有价格数据,包括盘前和盘后数据以及股息和分割。

注意: 价格示例 URL 中使用的 period1=period2= 值用于演示各自的舍入行为每个输入的。`

关于yahoo-finance - 雅虎财经 URL 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44030983/

相关文章:

Python/DataReader/Yahoo - 随着 pandas 面板的弃用,我怎样才能将股票数据放入多索引数据框中?

php - 雅虎金融 API 未找到表 yahoo.finance.quotes 的定义

r - 如何将 getReturns 与 Yahoo Finance API 结合使用

python-3.x - 使用 Candlestick_OHLC 绘制图表

javascript - 谷歌图表 API 问题

python - python For循环中跳过错误的方法

python - 使用 BS4 抓取雅虎财经统计数据的网页

python - 在pandas df python中滚动计算坡度

php - 使用 file_get_contents 在提取 RSS 提要而不是常规 URL 时会使内存过载?

html - 使用 R 从雅虎财经抓取头条新闻和日期