anyone know how to pull stock price data for top 300 stocks in s+p 500?

Joined
1/15/15
Messages
238
Points
28
anyone know how to pull stock price data for top 300 stocks in s+p 500?i'm going to use excel or matlab but don't know how to pull the data all at once. thanks!
 
This is one way: (You'll have to write a small piece of code)

Curl request to the website
CSS selectors + regex to scrape rates and names (n times)
write to Excel/csv

You can write this in JS, C++, Python, etc...
 
There's a Matlab function called hist_stock_data, which can be found at Matlab File Exchange.

price = hist_stock_data('ddmmyyyy','ddmmyyyy','^gspc');

You can do the same in R, with the help of the package quantmod

require('quantmod')
getSymbols('^GSPC', from='yyyy-mm-dd', to='yyyy-mm-dd')
 
i don't know how to pull the data for each individual stock all at once so that i could run that function haha. do you have any advice?
 
i don't know how to pull the data for each individual stock all at once so that i could run that function haha. do you have any advice?

Don't know about Matlab but the following code works in R

x<-c('MMM','ABT','ABBV','ACN','ACE')
getSymbols(x, from='2015-11-01')


i.e. all you need is the ticker symbols of the stocks, then put them into a (character) vector and pass it to getSymbols.
 
Back
Top