There is such a code. He is looking for correlations among various stocks of Yahoo finance. The only thing that he does not know how to do is to build correlations for a variety of instruments (6 pieces will build, and 10 will not be able to). The question is how to teach? For example, I want to use stock tickets not in the format ('SAN.MC', 'GAM.MC', 'BBVA.MC' ..., but so that they are recorded by the file.
import pandas as pd from pandas_datareader import data import datetime import numpy as np from bokeh.plotting import figure, show from bokeh.palettes import Spectral6 from bokeh.io import output_notebook output_notebook() start = datetime.datetime(2016, 1, 1) end = datetime.datetime(2016, 12, 31) symbols = ('SAN.MC', 'GAM.MC', 'BBVA.MC', 'GAS.MC', 'ENG.MC', 'REP.MC') prices_df = pd.DataFrame() for symbol in symbols: df = data.DataReader(symbol, 'yahoo', start, end) prices_df.loc[:, symbol] = df['Adj Close'] prices_df.tail() numlines=len(prices_df.columns) mypalette=Spectral6[0:numlines] # график p = figure(width=1000, height=600, x_axis_type="datetime") color_ix = 0 for symbol in symbols: p.line(prices_df.index.values, prices_df[symbol].values, legend=symbol, line_color=mypalette[color_ix], line_width=2) color_ix += 1 show(p) # corr_df = prices_df.corr(method='pearson') corr_df