[R-SIG-Finance] Downloaded stock prices from Yahoo Finance
Dennis Fisher
||@her @end|ng |rom p|e@@th@n@com
Fri May 5 17:30:37 CEST 2023
R 4.2.3
OS X
Colleagues
For years, I have been downloaded stock prices using something like:
require("jsonlite")
cmd <- "https://query1.finance.yahoo.com/v7/finance/quote?fields=symbol,longName,regularMarketPrice,regularMarketTime,regularMarketChange&formatted=false&symbols=AAPL"
fromJSON(cmd)
Yesterday, this stopped working -- the message is:
Error in open.connection(con, "rb") :
cannot open the connection to 'https://query1.finance.yahoo.com/v7/finance/quote?fields=symbol,longName,regularMarketPrice,regularMarketTime,regularMarketChange&formatted=false&symbols=AAPL'
In addition: Warning message:
In open.connection(con, "rb") :
cannot open URL 'https://query1.finance.yahoo.com/v7/finance/quote?fields=symbol,longName,regularMarketPrice,regularMarketTime,regularMarketChange&formatted=false&symbols=AAPL': HTTP status was '401 Unauthorized'
When I paste that code directly into a browser, I get:
{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Crumb"}}}
I need the most recent closing price and the today's real-time price. What other options exist to download prices for multiple stocks?
Dennis
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
More information about the R-SIG-Finance
mailing list