Yahoo API version 7
bcoles opened this issue · 15 comments
Yahoo API version 7 is superior to the current implementation.
The new API has more accurate data.
The data in the old API does not appear to updated any more for properties such as free float and shares outstanding. Basic properties such as change, volume, open, close are still accurate using the old API - for the time being.
Version 7 still supports multiple stocks in a single call:
Version 7 supports options, which the old API does not:
Hey @bcoles ! Would you be interested on porting that? I'm slightly flooded at the moment and won't be able to take on this any time soon..
@herval upon requesting yahoo_client.quote..
,
it gives the following response: OpenURI::HTTPError: 999 Request denied
.
I think its the right time to update the end point to v7.
Anyone currently working on this? I have time to jump in and make the changes
Looking at Yahoo Finance it looks like they are now using a v8
Probably best to stick with version 7 rather than 8 for now.
Version 8 API endpoint returns no data for quotes; or maybe the endpoint has changed.
Note that many of the properties originally available in version 7, in particular the fundamentals such as EBITDA, are no longer available.
Here's an example response for the quote
endpoint, using a stock ticker and an option ticker as an example. Should be pretty easy to convert to a hash.
- hxxps://query1.finance.yahoo.com/v7/finance/quote?symbols=TLS.AX,LPIO.AX
{
"quoteResponse": {
"result": [
{
"language": "en-US",
"quoteType": "EQUITY",
"currency": "AUD",
"exchange": "ASX",
"financialCurrency": "AUD",
"averageDailyVolume3Month": 28446096,
"averageDailyVolume10Day": 27888822,
"fiftyTwoWeekLowChange": 0.09500003,
"fiftyTwoWeekLowChangePercent": 0.02818992,
"fiftyTwoWeekHighChange": -1.825,
"fiftyTwoWeekHighChangePercent": -0.34499055,
"fiftyTwoWeekLow": 3.37,
"fiftyTwoWeekHigh": 5.29,
"earningsTimestamp": 1502910900,
"earningsTimestampStart": 1518605940,
"earningsTimestampEnd": 1519041600,
"trailingAnnualDividendRate": 0.31,
"trailingPE": 10.661538,
"trailingAnnualDividendYield": 0.09037901,
"market": "au_market",
"regularMarketPrice": 3.465,
"regularMarketTime": 1510894799,
"regularMarketChange": 0.0349998,
"regularMarketOpen": 3.45,
"regularMarketDayHigh": 3.475,
"regularMarketDayLow": 3.43,
"regularMarketVolume": 15289576,
"priceHint": 3,
"epsTrailingTwelveMonths": 0.325,
"epsForward": 0.34,
"sharesOutstanding": 11878899712,
"bookValue": 1.224,
"fiftyDayAverage": 3.4888237,
"fiftyDayAverageChange": -0.023823738,
"fiftyDayAverageChangePercent": -0.0068285875,
"twoHundredDayAverage": 3.9805634,
"priceToBook": 2.8308823,
"sourceInterval": 20,
"exchangeTimezoneName": "Australia/Sydney",
"exchangeTimezoneShortName": "AEDT",
"gmtOffSetMilliseconds": 39600000,
"tradeable": false,
"regularMarketChangePercent": 1.0204,
"regularMarketPreviousClose": 3.43,
"bid": 3.65,
"ask": 3.2,
"bidSize": 1165,
"askSize": 289,
"messageBoardId": "finmb_91774",
"fullExchangeName": "ASX",
"longName": "Telstra Corporation Limited",
"shortName": "Telstra Corp Ltd",
"twoHundredDayAverageChange": -0.5155635,
"twoHundredDayAverageChangePercent": -0.12952024,
"marketCap": 41160384512,
"forwardPE": 10.191176,
"exchangeDataDelayedBy": 0,
"marketState": "CLOSED",
"symbol": "TLS.AX"
},
{
"language": "en-US",
"quoteType": "EQUITY",
"currency": "AUD",
"exchange": "ASX",
"fiftyTwoWeekLowChange": 0.030000001,
"fiftyTwoWeekLowChangePercent": 1.5000001,
"fiftyTwoWeekHighChange": -0.0069999993,
"fiftyTwoWeekHighChangePercent": -0.122807,
"fiftyTwoWeekLow": 0.02,
"fiftyTwoWeekHigh": 0.057,
"market": "au_market",
"regularMarketPrice": 0.05,
"regularMarketTime": 1510892471,
"regularMarketChange": 0.038,
"regularMarketOpen": 0.024,
"regularMarketDayHigh": 0.057,
"regularMarketDayLow": 0.02,
"regularMarketVolume": 4386630,
"priceHint": 2,
"sourceInterval": 20,
"exchangeTimezoneName": "Australia/Sydney",
"exchangeTimezoneShortName": "AEDT",
"gmtOffSetMilliseconds": 39600000,
"tradeable": false,
"regularMarketChangePercent": 316.667,
"regularMarketPreviousClose": 0.012,
"bid": 0.045,
"ask": 0.05,
"bidSize": 40000,
"askSize": 218048,
"fullExchangeName": "ASX",
"exchangeDataDelayedBy": 0,
"marketState": "CLOSED",
"symbol": "LPIO.AX"
}
],
"error": null
}
}
A nice feature of version 7 is that it now supports data for options, which wasn't supported in the original API. There's an API endpoint for options
, however I've found that the quote
endpoint is just as good for option data. (Neither endpoint contains the option expiry date or exercise price).
For what it's worth, here's an example response from the options
endpoint.
- hxxps://query1.finance.yahoo.com/v7/finance/options/LPIO.AX
{
"optionChain": {
"result": [
{
"underlyingSymbol": "LPIO.AX",
"expirationDates": [],
"strikes": [],
"hasMiniOptions": false,
"quote": {
"language": "en-US",
"quoteType": "EQUITY",
"currency": "AUD",
"exchangeDataDelayedBy": 0,
"fiftyTwoWeekHighChange": -0.0069999993,
"fiftyTwoWeekHighChangePercent": -0.122807,
"fiftyTwoWeekLow": 0.02,
"fiftyTwoWeekHigh": 0.057,
"priceHint": 2,
"market": "au_market",
"regularMarketPrice": 0.05,
"regularMarketTime": 1510892471,
"regularMarketChange": 0.038,
"regularMarketOpen": 0.024,
"regularMarketDayHigh": 0.057,
"regularMarketDayLow": 0.02,
"regularMarketVolume": 4386630,
"sourceInterval": 20,
"exchangeTimezoneName": "Australia/Sydney",
"exchangeTimezoneShortName": "AEDT",
"gmtOffSetMilliseconds": 39600000,
"tradeable": false,
"regularMarketChangePercent": 316.667,
"regularMarketPreviousClose": 0.012,
"bid": 0.045,
"ask": 0.05,
"bidSize": 40000,
"askSize": 218048,
"fullExchangeName": "ASX",
"fiftyTwoWeekLowChange": 0.030000001,
"fiftyTwoWeekLowChangePercent": 1.5000001,
"marketState": "CLOSED",
"exchange": "ASX",
"symbol": "LPIO.AX"
},
"options": []
}
],
"error": null
}
}
@bcoles - Thanks for the good info.
Do you have any idea on a new endpoint for the splits calculation
"https://ichart.finance.yahoo.com/x?#{params.map{|k, v| "#{k}=#{v}"}.join("&")}"
@brettallred nope, sorry, never used that functionality.
The quote endpoint still contains EBITDA. The default endpoint, as listed in your earlier post, has a list of a few default outputs, but modification of the endpoint will return EBITDA (see the example below). I'm trying to hunt down all the available values for the [fields] parameter, so if you find some documentation for this then please pass it along.
https://query1.finance.yahoo.com/v7/finance/quote?symbols=UNP&fields=ebitda,shortRatio,priceToSales
@bcoles,
I noticed the v7 doesn't have certain fields too, like Forward Annual Dividend Yield that can be found in the web version.
@matthewherbert
Thanks. That's useful to know. Any idea how to get other fields like forward dividend? I tried a few different parameters but couldn't get it.
Is there some kind of API rate limiting for Yahoo API v7? I would like to get some quotes every second using https://query1.finance.yahoo.com/v7/finance/quote?symbols=
.
@HLFH Did you find answer to your question?