# special IPython command to prepare the notebook for matplotlib
%matplotlib inline
import numpy as np
import pandas as pd
import math
import scipy
import random
import Quandl
import matplotlib.pyplot as plt
import string
# set some nicer defaults for matplotlib
from matplotlib import rcParams
import scipy.stats as stats
#these colors come from colorbrewer2.org. Each is an RGB triplet
dark2_colors = [(0.10588235294117647, 0.6196078431372549, 0.4666666666666667),
(0.8509803921568627, 0.37254901960784315, 0.00784313725490196),
(0.4588235294117647, 0.4392156862745098, 0.7019607843137254),
(0.9058823529411765, 0.1607843137254902, 0.5411764705882353),
(0.4, 0.6509803921568628, 0.11764705882352941),
(0.9019607843137255, 0.6705882352941176, 0.00784313725490196),
(0.6509803921568628, 0.4627450980392157, 0.11372549019607843),
(0.4, 0.4, 0.4)]
rcParams['figure.figsize'] = (10, 6)
rcParams['figure.dpi'] = 150
rcParams['axes.color_cycle'] = dark2_colors
rcParams['lines.linewidth'] = 2
rcParams['axes.grid'] = True
rcParams['axes.facecolor'] = '#eeeeee'
rcParams['font.size'] = 14
rcParams['patch.edgecolor'] = 'none'
authtoken='Cx1CtXeu61zjTzpehmNV'
data = {'gold_price':'BUNDESBANK/BBK01_WT5511.1',
'usd_to_pound':'QUANDL/USDGBP.1',
'cpi':'FRED/CPIAUCSL.1',
'unemployment':'FRED/UNRATE.1',
'gas_price':'BTS_MM/RETAILGAS.1',
'house_sales':'FRED/HSN1F.1',
'usd_to_euro':'QUANDL/USDEUR.1',
's_and_p_500':'YAHOO/INDEX_GSPC.6'}
'''
takes a dictionary of Quandl codes and returns a list of dataframes
the colom name of each dataframe is its repective key from the dictionary
'''
def get_quandl_data(quandl_codes):
list_of_data = []
for number, code in enumerate(quandl_codes.values()):
data = Quandl.get([code], authtoken=authtoken)
data.columns = [quandl_codes.keys()[number]]
list_of_data.append(data)
return list_of_data
d = get_quandl_data(data)
Token Cx1CtXeu61zjTzpehmNV activated and saved for later use. Returning Dataframe for [u'FRED.CPIAUCSL.1'] Token Cx1CtXeu61zjTzpehmNV activated and saved for later use. Returning Dataframe for [u'FRED.HSN1F.1'] Token Cx1CtXeu61zjTzpehmNV activated and saved for later use. Returning Dataframe for [u'BTS_MM.RETAILGAS.1'] Token Cx1CtXeu61zjTzpehmNV activated and saved for later use. Returning Dataframe for [u'BUNDESBANK.BBK01_WT5511.1'] Token Cx1CtXeu61zjTzpehmNV activated and saved for later use. Returning Dataframe for [u'QUANDL.USDGBP.1'] Token Cx1CtXeu61zjTzpehmNV activated and saved for later use. Returning Dataframe for [u'QUANDL.USDEUR.1'] Token Cx1CtXeu61zjTzpehmNV activated and saved for later use. Returning Dataframe for [u'FRED.UNRATE.1'] Token Cx1CtXeu61zjTzpehmNV activated and saved for later use. Returning Dataframe for [u'YAHOO.INDEX_GSPC.6']