Skip to content

Instantly share code, notes, and snippets.

@marketcalls
Created November 15, 2016 10:58
Show Gist options
  • Save marketcalls/1d2ba65cb5ba1da38cf542947d2885bc to your computer and use it in GitHub Desktop.
Save marketcalls/1d2ba65cb5ba1da38cf542947d2885bc to your computer and use it in GitHub Desktop.
Compute and Plot
#Compute Percentage Change
rets = d.pct_change()
#Compute Correlation
corr = rets.corr()
#Plot Correlation Matrix using Matplotlib
%pylab inline
plt.figure(figsize=(10, 10))
plt.imshow(corr, cmap='RdYlGn', interpolation='none', aspect='auto')
plt.colorbar()
plt.xticks(range(len(corr)), corr.columns, rotation='vertical')
plt.yticks(range(len(corr)), corr.columns);
plt.suptitle('Stock Correlations Heat Map', fontsize=15, fontweight='bold')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment