This script creates a correlation-based network for 30 Dow Jones companies. It computes correlations using the closing stock prices for each of 30 companies. Time range is from 01 Jan 2010 till 23 Sep 2012.
You can explore this script online without downloading it:
http://nbviewer.ipython.org/3950921/
- pandas how to install
- networkx how to install
- GraphViz and pygraphviz. In Ubuntu:
sudo apt-get install graphviz graphviz-dev; sudo pip install pygraphviz
- An Internet access to fetch the stock data from Yahoo Finance.
python cnetwork.py
The code was exported from ipython notebook. You can import it back.
First, install the notebook if needed. For Ubuntu:
sudo apt-get install ipython-notebook
Run it with the options:
ipython notebook --pylab=inline
You will see a prompt for importing files:
To import a notebook, drag the file onto the listing below or click here.
A review paper on correlation-based financial networks:
Michele Tumminello, Fabrizio Lillo, Rosario N. Mantegna, Correlation, hierarchies, and networks in financial markets, Journal of Economic Behavior and Organization, Volume 75, Issue 1, July 2010, Pages 40-58.
Keywords:
- Multivariate analysis
- Hierarchical clustering
- Correlation based networks
- Bootstrap validation
- Factor models
- Kullback–Leibler distance