I am blown away by all of the jargon. I’m new to R, using it for a few months to get some quote info for my Excel portfolio as a VBA call to a Bert subroutine. My (stripped down) R steps are as follows:
local({r <- getOption("repos")
r["CRAN"] <- "https://cran.microsoft.com/snapshot/2022-05-05/"
options(repos=r)
})
library (quantmod)
library(jsonlite)
ticker <- "COKE"
metrics <- yahooQF(
c("Trade Time", "Last Trade (Price Only)", "Change in Percent",
"Days High", "Days Low",
"Dividend/Share", "Dividend Yield",
"Ex-Dividend Date", "Dividend Pay Date",
"Earnings/Share", "EPS Forward",
"Earnings Start Time", "Earnings End Time",
"P/E Ratio (RT)",
"Previous Close", "Open",
"50-day Moving Average", "200-day Moving Average"))
quot <- getQuote(ticker, what=metrics)
From which I get: Error in open.connection(con, “rb”) : HTTP error 401.
I know there have been several questions/suggestions about this, but being a novice I don’t see how to get around this problem (which I’m understanding is due to changes at Yahoo). Can anyone help out with actual code that I’ll understand and can integrate with mine to try to get around the getQuote problem.