-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getQuote cannot open URL #197
Comments
A JSON version of the call still works. You might try something like this: `require(jsonlite) getQuote <- function(ticks) { |
That works great - thanks! Any possibility of adding the daily open, high and low to this call? |
Thanks a lot, works for me too! |
I haven't found documentation for the API but if you just don't specify any "fields" and run this:
it look like you get just about everything and from that you can customize the URL by specifying the fields you want. For for a nice list, just look at the names of the columns in the result. I'll transpose this below so that they're easier to read.
language "en-US"
quoteType "EQUITY"
quoteSourceName "Nasdaq Real Time Price"
currency "USD"
priceHint "2"
regularMarketPrice "153.76"
regularMarketTime "1509638054"
regularMarketChange "-0.2700043"
regularMarketOpen "154.18"
regularMarketDayHigh "154.49"
regularMarketDayLow "152.92"
regularMarketVolume "1440836"
regularMarketChangePercent "-0.1752933"
regularMarketPreviousClose "154.03"
bid "153.63"
ask "153.66"
bidSize "2"
askSize "4"
messageBoardId "finmb_112350"
fullExchangeName "NYSE"
longName "International Business Machines Corporation"
financialCurrency "USD"
averageDailyVolume3Month "4384179"
averageDailyVolume10Day "5503657"
fiftyTwoWeekLowChange "14.62999"
fiftyTwoWeekLowChangePercent "0.1051534"
fiftyTwoWeekHighChange "-29.03"
fiftyTwoWeekHighChangePercent "-0.1588161"
exchangeDataDelayedBy "0"
fiftyTwoWeekLow "139.13"
fiftyTwoWeekHigh "182.79"
dividendDate "1504915200"
earningsTimestamp "1508270400"
earningsTimestampStart "1516222800"
earningsTimestampEnd "1516654800"
trailingAnnualDividendRate "1.4"
trailingPE "12.82616"
trailingAnnualDividendYield "0.009089138"
sharesOutstanding "931939968"
bookValue "21.118"
fiftyDayAverage "149.19"
fiftyDayAverageChange "4.569992"
shortName "International Business Machines"
marketState "REGULAR"
market "us_market"
exchange "NYQ"
fiftyDayAverageChangePercent "0.03063203"
twoHundredDayAverage "150.346"
twoHundredDayAverageChange "3.413956"
twoHundredDayAverageChangePercent "0.02270732"
marketCap "143295086592"
forwardPE "11.03805"
priceToBook "7.280992"
sourceInterval "15"
exchangeTimezoneName "America/New_York"
exchangeTimezoneShortName "EDT"
gmtOffSetMilliseconds "-14400000"
tradeable "TRUE"
epsTrailingTwelveMonths "11.988"
epsForward "13.93"
symbol "IBM"
>
|
@pjheink brilliant!!! thanks a lot, I was just searching for that |
@pjheink This is great, will be using this as a temp solution. Thanks. |
the JSON code works great -- is it possible to obtain index quotes (e.g., Dow, S+P, NASDAQ)? I have tried various permutations of symbols for these without success. |
Have you tried ^DJI, ^GSPC and ^IXIC? |
That worked — the problem was that I needed to select different column names.
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com <http://www.plessthan.com/>
… On Nov 3, 2017, at 7:17 AM, mmullinsm ***@***.***> wrote:
Have you tried ^DJI, ^GSPC and ^IXIC?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#197 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AHKsUcVHWnr6l23qJkkzRP4miqcIGlaaks5syyCHgaJpZM4QPDir>.
|
Here's another approach that uses the suggested URL with defined fields but without a call to jsonlite: resp <- GET(url) db <- content(resp) |
The commands are from the httr package, which allows the user to deal with URLs |
noticed that there is no ex-div-date from the JSON API... |
never mind, even though there is no ex-div-date from the list @pjheink provided (thanks a lot btw), it;s actually available via the API. and the true name is exDividendDate. upper D's. cheers! |
I have a similar error, do you can help in my issure? getQuote(c("UAHUSD=X","RUBUSD=X","EURUSD=X")) sessionInfo: Matrix products: default locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
Yahoo Finance deprecated the CSV-based quote API in favor of a JSON API (similar to what they did with the historical data API in May, 2017). Create a static matrix of yahoo quote field codes, names, and short names. I did my best to map the old CSV fields to the new JSON fields. Old fields that I could not find a new counterpart for are left as comments, for future reference. See #197.
I just pushed an update to the There is one minor issue regarding the "Last Time" field. It's currently in your local timezone, not the exchange timezone. The fix needs to account for the possibility that users may request multiple symbols, and those symbols may be from exchanges in different timezones. You cannot mix timezones in a |
Thanks, Josh! I've been messing with this branch and it seems to work just fine as long as you avoid the older compact quote format codes (i.e. While it's not really relevant anymore, I noticed that the www.gummy-stuff.org URL, which is included as a reference in the quantmod documentation is almost certainly NOT owned by Peter Ponzo anymore. The original material from that site is now stored at: http://www.financialwisdomforum.org/gummy-stuff/Yahoo-data.htm. |
We should use the exchange timezone if only one symbol is requested, or if all symbols have the same timezone. We need to convert all timestamps to a common timezone if there are multiple exchange timezones, because a POSIXt (POSIXct and POSIXlt) vector can only have a single timezone. Convert the string to POSIXct using the exchange timezone, then strip the `tzone` attribute so the POSIXct object will use the local timezone. Throw a warning so the user knows the timezones have been converted. See #197.
Yahoo Finance deprecated the CSV-based quote API in favor of a JSON API (similar to what they did with the historical data API in May, 2017). Create a static matrix of yahoo quote field codes, names, and short names. I did my best to map the old CSV fields to the new JSON fields. Old fields that I could not find a new counterpart for are left as comments, for future reference. See #197.
We should use the exchange timezone if only one symbol is requested, or if all symbols have the same timezone. We need to convert all timestamps to a common timezone if there are multiple exchange timezones, because a POSIXt (POSIXct and POSIXlt) vector can only have a single timezone. Convert the string to POSIXct using the exchange timezone, then strip the `tzone` attribute so the POSIXct object will use the local timezone. Throw a warning so the user knows the timezones have been converted. See #197.
Thanks for the update regarding the getQuote function Josh. For me, it is working fine, but when I try to get the value of some pairs, I get the following error: Error in This happens, so far, with EURJPY, EURCAD, GBPJPY, EURAUD, AUDCAD. Do you know if there is a reason for this? quantmod updated with branch 197_getQuote Thanks! |
I just tried to update on this branch.
and I'm getting the following download error.
i also don't see the branch listed anymore? |
@wave-electron Apologies, I deleted the branch after merging it to master, but I forgot to close this issue. The fix for this issue is currently on CRAN, so you can get the patch via |
@joshuaulrich I know this issue is now closed. But it appears that empty fields are not being handled the same way as previously by quantmod. I haven't had time to debug my own code yet... but based on the way empty fields are breaking my own code it seems something has changed there. it might also be related to @parayamelo issue above on
|
this is my code using quantmod
when the ticker is AAPL the returned fields all have a value so it doesn't throw the error above. when the ticker is AMZN the Dividend Yield field is empty so it throws the error. If I have ticker "AAPL;AMZN" the error won't throw and I get NA in the Dividend Yield. But it will if the other way around "AMZN;AAPL" |
@wave-electron Thanks for the report! I consider the error in your comment a new issue, because this issue has been closed and is already in a CRAN release. Please open a new issue (edit: now in #208), and include the code you run and the output/error generated, as wells as your FWIW, I only get an error if |
Using dby <- getQuote("AAPL",src="yahoo", auto.assign = FALSE)
gets the following response:
Error in download.file(paste("https://finance.yahoo.com/d/quotes.csv?s=", :
cannot open URL 'https://finance.yahoo.com/d/quotes.csv?s=AAPL&f=d1t1l1c1p2ohgv'
In addition: Warning message:
In download.file(paste("https://finance.yahoo.com/d/quotes.csv?s=", :
cannot open URL 'https://finance.yahoo.com/d/quotes.csv?s=AAPL&f=d1t1l1c1p2ohgv': HTTP status was '999 Request denied'
This problem started after the market close on Nov 1 but had not been an issue in prior use for several months.
Note: getSymbols, as in dbx <- getSymbols("AAPL",src="yahoo", auto.assign = FALSE), seems to work, though it is not picking up Nov 1 data.
The text was updated successfully, but these errors were encountered: