Skip to content
Back to formatted view

Raw Message

Message-ID: <5A364FB4-CFE6-4DD3-B8F6-1DC31BCC68A6@plessthan.com>
Date: 2023-05-05T15:30:37Z
From: Dennis Fisher
Subject: Downloaded stock prices from Yahoo Finance

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