Last active
August 8, 2017 15:46
-
-
Save karishmadudani/1576a05bf79dc535f959e0f7bc40e31f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This scripts downloads historical stock prices for a given period. | |
import quandl | |
import pandas as pd | |
import csv | |
#Get a list of S&P 500 tickers | |
Tickers = pd.read_csv("C:\Users\lenovo\Desktop\Karishma\Stocks\SP500_Symbols.csv") | |
#Extract Stock Prices from Quandl and save CSVs for all symbols/ tickers | |
quandl.ApiConfig.api_key = "xxxxxxxxxxxxxxxx" | |
Header = ["Open", "High", "Low", "Close", "Volume", "Adj. Close"] | |
#for i in range (0,len(Tickers["Symbol"])): | |
for i in range (0,50): | |
Data = quandl.get("WIKI/"+Tickers.iloc[i]["Symbol"], start_date = "2004-01-01", end_date = "2017-07-27") | |
Data.to_csv("C:\Users\lenovo\Desktop\Karishma\Stocks\Scripts\RawData\\"+Tickers.iloc[i]["Symbol"]+".csv", columns = Header) | |
print "Program has finished!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment