I have no problems using the R package quantmod, which uses Yahoo to obtain stock data like so:
get_stock_prices <- function(target, return_format = "tibble", ...) {
# Get stock prices
print(target)
stock_prices_xts <- getSymbols(Symbols = target, auto.assign = FALSE, ...)
# Rename
names(stock_prices_xts) <- c("Open", "High", "Low", "Close", "Volume", "Adjusted")
# Return in xts format if tibble is not specified
if (return_format == "tibble") {
stock_prices <- stock_prices_xts %>%
as_tibble() %>%
rownames_to_column(var = "Date") %>%
mutate(Date = ymd(Date))
} else {
stock_prices <- stock_prices_xts
}
write.csv(stock_prices, file = paste(target, "csv", sep = '.'))
}
I am only aware of pandas_datareader in Python to achieve something similar. Unfortunately, this package is broke as the yahoo and google APIs have changed. This code:
import pandas_datareader as pdr
panel_data = pdr.get_data_yahoo('MSFT')
results in:
Yahoo Actions has been immediately deprecated due to large breaks in the API without the
introduction of a stable replacement. Pull Requests to re-enable these data
connectors are welcome.
Is there a currently working Python package to achieve the above. I am aware of quandl but this is a paid service. Thanks.