Downloading Adjusted Close Prices for Multiple Stocks at Once
Summary
The document addresses the tedious process of downloading adjusted closing prices for several stocks individually and merging the resulting files. It presents two programmatic alternatives: using a Python data-reader library to request multiple symbols over a date range, and using an R finance package to retrieve a set of symbols and combine their adjusted-close series into one table.
The examples show the basic workflow of specifying tickers and dates, fetching historical data, selecting adjusted-close columns, and merging the series. The R example also demonstrates checking the resulting table’s leading rows. These approaches can reduce manual downloads when assembling a multi-stock dataset. The document does not discuss data quality, missing observations, corporate-action adjustment details, provider reliability, or the current availability and behavior of the named services and libraries, so users would need to verify those aspects for their own research.
Key ideas
- Multiple stock histories can be retrieved programmatically instead of downloaded one at a time.
- The Python example requests several tickers for a specified date range.
- The R example selects adjusted-close series and merges them into one table.
- The examples omit data validation and do not address missing values or provider changes.
Tags
Full text
# Yahoo finance: download adjusted close prices of different stocks in one file
# Yahoo finance: download adjusted close prices of different stocks in one file
I am trying to download adjusted close prices of different stocks from yahoo finance. I used "Download to Spreadsheet" to download historical prices for each stock and then join these files into one. But it takes a lot of time. I wonder whether there exists a faster way to do it.
Thanks
## Answer by JOHN (score 2)
https://quant.stackexchange.com/a/24912
Take a look at pandas-datareader. you will need to use python and write something like this:
```
# import package and notebook setting
import pandas as pd
import pandas_datareader.data as web
import datetime
pd.set_option('display.max_rows', 999)
pd.set_option('display.max_columns', 999)
pd.set_option('precision', 4)
# load data
start = datetime.datetime(2010, 1, 1)
end = datetime.datetime(2015, 5, 9)
quotes = web.DataReader(["AAPL", "GOOGL", "TSLA"], 'yahoo', start, end)
```
## Answer by Atul Agarawal (score 0)
https://quant.stackexchange.com/a/25454
Best to download in R studio. use below code to download.
```
library(quantmod)
tickers = c("^NSEI","ITC.NS", "SBIN.NS", "COALINDIA.NS", "ICICIBANK.NS", "ADANIPORTS.NS", "ONGC.NS", "MOTHERSUMI.NS", "INFY.NS", "TCS.NS", "WIPRO.NS")
getSymbols(tickers, from = "2015-01-01", to = "2016-03-31")
prices.data <- merge(NSEI[,6], ITC.NS[,6], SBIN.NS[,6], COALINDIA.NS[,6], ICICIBANK.NS[,6], ADANIPORTS.NS[,6], ONGC.NS[,6], INFY.NS[,6], TCS.NS[,6], MOTHERSUMI.NS[,6], WIPRO.NS[,6])
head(prices.data)
```
you can use head(prices.data) to check the downloaded prices.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.