使用Quandl API和Quandl Python库,我试图批量下载过去100天的EOD数据。
批量下载使用此调用来下载最后一个收集日的所有股票的所有EOD数据。删除download_type = partial参数将下载所有历史EOD数据: https://www.quandl.com/api/v3/databases/EOD/data?download_type=partial
此呼叫将为单个报价下载最后n天的EOD: https://www.quandl.com/api/v3/datasets/EOD/AAPL?start_date=2019-02-07
是否可以将这些结合起来并一次下载所有股票的最近n天的EOD数据? 此时,看来我唯一的选择是:
答案 0 :(得分:1)
Quandle不再免费工作。曾经是过去。 如果需要,可以使用IEX。请查看下面的示例,该示例将为您提供每日收益:
from datetime import datetime
from iexfinance.stocks import get_historical_data
from pandas_datareader import data
import pandas as pd
start = '2014-01-01'
end = datetime.today().utcnow()
datasets_original_test = ['AAPL', 'MSFT','NFLX','FB','GS','TSLA','BAC','TWTR','COF','TOL','EA','PFE','MS','C','SKX','GLD','SPY','EEM','XLF','GDX','EWZ','QQQ','FXI','XOP','EFA','VXXB','HYG','XLI','XLU','JNK','USO','IWM','XLP','XLE','EWJ','XLK','KRE','XLV','VNQ','MBB','OIH','FEZ','RSX','EWG','SMH','TLT','IBB','SLV','IYR','XRT','XLB','EMB','AGG','INDA','EWW','DBO','SPLV','KBE','VGK','XLY','EWH','EWT','DIA','IVV','XLRE','EPI','IJR','IEF']
dataset_names_test = ['AAPL', 'MSFT','NFLX','FB','GS','TSLA','BAC','TWTR','COF','TOL','EA','PFE','MS','C','SKX','GLD','SPY','EEM','XLF','GDX','EWZ','QQQ','FXI','XOP','EFA','VXXB','HYG','XLI','XLU','JNK','USO','IWM','XLP','XLE','EWJ','XLK','KRE','XLV','VNQ','MBB','OIH','FEZ','RSX','EWG','SMH','TLT','IBB','SLV','IYR','XRT','XLB','EMB','AGG','INDA','EWW','DBO','SPLV','KBE','VGK','XLY','EWH','EWT','DIA','IVV','XLRE','EPI','IJR','IEF']
datasets_test = []
for d in datasets_original_test:
data_original = data.DataReader(d, 'iex', start, end)
data_original.index = pd.to_datetime(data_original.index, format='%Y/%m/%d')
data_ch = data_original['close'].pct_change()
datasets_test.append(data_ch)
df_returns = pd.concat(datasets_test, axis=1, join_axes=[datasets_test[0].index])
df_returns.columns = dataset_names_test