Created
August 7, 2017 03:40
-
-
Save karishmadudani/36387f6213adf88127984ae8efb39cdc 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 and Vix Data 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 = "ksFG6WAoxkyevKLz4rwV" | |
vixData = quandl.get("CBOE/VIX",start_date = "2004-01-01", end_date = "2017-07-27") | |
vixData.to_csv("C:\Users\lenovo\Desktop\Karishma\Stocks\Scripts\RawData\VixData.csv") | |
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