ValueError:必须提供Quandl API密钥

时间:2019-02-15 11:48:51

标签: python quandl

我已经导入了quandl,但是我仍然收到此错误消息

import quandl
quandl.ApiConfig.api_key = 'X6mZSY79yeySfpCVJaKg'
  

ValueError:必须通过api_key变量或环境变量QUANDL_API_KEY提供Quandl API密钥。

Mr_Techie = ['MSFT', 'NFLX', 'FB', 'AMZN']
Mr_Allstar = ['MSFT', 'PFE', 'F', 'WMT']

techie_potfolio = pd.DataFrame()
allstar_portfolio = pd.DataFrame()

for tech,allstar in zip(Mr_Techie, Mr_Allstar):
    techie_portfolio[tech]= wb.DataReader(tech, data_source='quandl', start='2013-1-1')['AdjClose']
    allstar_portfolio[allstar]= wb.DataReader(allstar, data_source='quandl', start='2013-1-1')['AdjClose']

1 个答案:

答案 0 :(得分:0)

source显示了DataReader工厂函数如何将其传递给Quandl阅读器:

elif data_source == "quandl":
        return QuandlReader(symbols=name, start=start, end=end,
                            retry_count=retry_count, pause=pause,
                            session=session, api_key=access_key).read()

因此,请尝试使用access_key参数将其传递给DataReader:

 techie_portfolio[tech]=wb.DataReader(tech, data_source='quandl', start='2013-1-1',access_key=api-key)