从雅虎财经获取 1 分钟柱 [英] Fetching 1 minute bars from Yahoo Finance

查看:29
本文介绍了从雅虎财经获取 1 分钟柱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从 Yahoo Finance 下载 1 分钟的历史股价,包括当天和前一天.

I'm trying to download 1 minute historical stock prices from Yahoo Finance, both for the current day and the previous ones.

Yahoo(就像 Google)使用以下 API 查询最多支持 15 天的数据:

Yahoo (just like Google) supports up to 15 days worth of data, using the following API query:

http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv

问题是,即使市场关闭,数据也在不断变化!尝试每隔一分钟左右刷新一次,有些分钟条会发生变化,即使从会话开始也是如此.

The thing is that data keeps on changing even when the markets are closed! Try refreshing every minute or so and some minute bars change, even from the beginning of the session.

另一个有趣的事情是,所有这些查询返回的相同柱的数据略有不同:http://chartapi.finance.yahoo.com/instrument/2.0/AAPL/chartdata;type=quote;range=1d/csv

Another interesting thing is that all of these queries return slightly different data for the same bars: http://chartapi.finance.yahoo.com/instrument/2.0/AAPL/chartdata;type=quote;range=1d/csv

用 100000 替换粗体数字,它仍然有效,但返回的数据略有不同.

Replace the bold number with 100000 and it will still work but return slightly different data.

有人懂吗?

是否有现代 YQL 查询可以代替此 API 获取历史分钟数据?

Is there a modern YQL query that can fetch historical minute data instead of this API?

谢谢!

推荐答案

历史记录数据并不像我们希望的那样容易访问.我发现收集日内股票价格数据最实惠的方法是开发自动脚本,记录市场开盘时的价格信息.

Historical minute data is not as easily accessible as we all would like. I have found that the most affordable way to gather Intraday Stock Price data is to develop automated scripts that log price information for whenever the markets are open.

与您共享的 Yahoo 数据 URL 类似,Bloomberg 以 JSON 格式维护 1 天盘中价格信息,如下所示:https://www.bloomberg.com/markets/api/bulk-time-series/price/AAPL%3AUS?timeFrame=1_DAY

Similar to the Yahoo data URL that you shared, Bloomberg maintains 1-Day Intraday Price information in JSON format like this : https://www.bloomberg.com/markets/api/bulk-time-series/price/AAPL%3AUS?timeFrame=1_DAY

一旦您拥有股票代码列表并了解一致的语法,就可以轻松输入 URL 约定.

The URL convention appears easy to input on your own once you have a list of Ticker Symbols and an understanding of the consistent syntax.

为了最初到达那个 URL,没有任何猜测/逆向工程的想法,我只是去了这里 https://www.bloomberg.com/quote/AAPL:US 并在我的浏览器上使用开发人员工具并跟踪后台 GET 请求,该请求将我引导至该 URL.如果您可以在其他与价格数据相关的网站上采用类似的方法,我不会感到惊讶.

To arrive at that URL initially though, without having any idea for guessing / reverse-engineering it, I simply went here https://www.bloomberg.com/quote/AAPL:US and used Developer Tools on my browser and tracked a background GET request which led me to that URL. I wouldn't be surprised if you could employ similar methods on other Price Data-related websites.

您还可以编写脚本以在互联网运行时尽可能快地跟踪价格数据.我觉得非常方便的一个 python 包是 ystockquote

You can also write scripts to track price data as fast as your internet goes. One python package that I find pretty handy and is ystockquote

您可以让它每隔几秒请求一次价格数据,并将其记录到每日时间序列数据库中.

You can have it request price data every couple of seconds and log that into a daily time series database.

这篇关于从雅虎财经获取 1 分钟柱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆