# Can I download today's open/close/high/low data for all stocks (in bulk)? [duplicate]

EDIT: Regarding the [duplicate] designation: I carefully checked all the sites listed in the Equities and Equity Indices section of What data sources are available online?. I was not able to find what I am looking for (as described in the post below) in any of them. If what I am looking is there, and somehow I missed it, please provide a specific link.

I would like to get a table of the form

 symbol | open  | close | high  | low
A      | 90.32 | 89.81 | 90.58 | 89.46
AA     | 12.51 | 12.17 | 12.61 | 11.93
AAAU   | 17.20 | 17.35 | 17.35 | 17.09
⋮       ⋮       ⋮      ⋮      ⋮
ZYME   | 37.77 | 36.16 | 38.00 | 36.50
ZYNE   | 5.41  | 5.21  | 5.48  | 5.13
ZYXI   | 20.40 | 21.26 | 22.25 | 20.10


...where the numeric column's are today's open, close, high, and low prices, and the rows range over all ~9000 symbols traded in AMEX, NYSE, and NASDAQ.

I have found many ways to programmatically query for data for individual, but with this approach, generating such a table would require at least ~9000 queries (assuming I can get all four values of interest in a single query).

EDIT: Judging from the answers I've received so far, the last paragraph above was not explicit enough. So let me be even more clear: I am not interested in solutions that entail iterating over ~9000 stock symbols, and querying some site for each symbol's data.

Is there a low-cost (preferably free) source that would allow me to download such data (for today) in bulk, as a single file?

I imagine that today's data (if it's available sometime before midnight) may not be available for free. In that case, what about yesterday's data?

I have studied the thread Where to download list of all common stocks traded on NYSE, NASDAQ and AMEX?, and tried several of the sites mentioned in it, but with one exception, all the answers seem to limit themselves to providing a list of all traded symbols, which is not what I'm after.

The one exception I alluded to are the files one can download from https://old.nasdaq.com/screening/company-list.aspx, which at least seem to include yesterday's close price. This is still less than what I'm looking for.

I should add that I have no problem with scripting and data munging. In other words, as long as I can download the data in some form, I am confident that I will be able to parse it and reformat it if necessary to achieve the format described above.

EDIT: Originally, my question asked for a free source, but, after reading What data sources are available online? I suspect that I won't find the data I'm looking for for free.

I'd try Pandas DataReader library in Python (which has to be installed separately from Pandas): this library allows direct data feed from Google, Yahoo Finance or Morningstar fo equity data:

Code: (I typed this just now, it's a very short code: in your case, you don't need time series, but a cross-section, so you can just add all your equity names into an array and adjust the code accordingly, to get all data at once).

You could use a Python library such as PandasDatareader for downloading the data. The main issue here is that you need the list of tickers for the stocks you want to download, and writing 9000 tickers by hand is not the best. You could exploit the fact that wikipedia offers you the list of tickers in the main indices. Here is the code for creating a list of all the tickers of the S&P500:

import bs4 as bs
import pickle
import requests
import datetime as dt
import os
import pandas as pd

def save_sp_500_tickers():
resp = requests.get("https://en.wikipedia.org/wiki/List_of_S%26P_500_companies")
soup = bs.BeautifulSoup(resp.text) #it creates the html file in text
table = soup.find("table", {"class":"wikitable sortable"})
tickers = []
#we are gonna pick the data from wikipedia table defined above
for row in table.findAll("tr")[1:]:
ticker = row.findAll("td")[0].text
ticker = ticker[:-1]
tickers.append(ticker)
with open("sp500tickers.pickle", "wb") as f:
pickle.dump(tickers, f)

print(tickers)

return tickers
save_sp_500_tickers()


Then you can iterate through this list saving all the data in a folder:

start = dt.datetime(2016,01,01)
end = dt.datetime.now()

if not os.path.exists('Stock_data'):
os.makedirs('Stock_data')
for ticker in tickers:
df = web.DataReader(ticker, 'yahoo', start, end)
df.to_csv('Stock_data/{}.csv'.format(ticker))