Fetching 1 minute bars from Yahoo Finance

2020-05-27 04:51发布

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

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.

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

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

Does anyone understand this?

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

Thanks!

2条回答
Explosion°爆炸
2楼-- · 2020-05-27 05:15

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.

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

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.

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.

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.

查看更多
男人必须洒脱
3楼-- · 2020-05-27 05:34

Yes there is other APIs. I don't know if it can still help but if you need intraday data, there is a API on rapidapi called (Quotient) which allows to pull intraday (at 1-min level), EOD market (FX, Crypto, Stocks (US, CANADIAN, UK, AUSTRALIA, EUROPE), ETFs and Futures. It also provides earnings, dividends, splits and a lot others informations.

查看更多
登录 后发表回答