Fungible Clouds

Break the cloud services vendor lock-in

Computational Investing

| Comments

I just discovered an online course on Computational Investing that Prof. Tucker Balch from the College of Computing at Georgia Tech is offering on coursera. It nicely blends my interests in the financial markets and computers so I immediately registered for it. The course has not started yet but for those interested in getting a headstart, here is a quick step-by-step on how I set my computer up with the QuantSoftware ToolKit

Getting the basics down

ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
brew install wget
brew install pyqt # brew installed sip as sip is a dependency
brew install gfortran
brew install gtk
brew install ghostscript
brew install swig

Use a virtual environment for use with QSTK (so it wont mess up existing setup) See my other post on setting up a virtualenv and create a quant virtualenv

mkvirtualenv quant
cd ~/domains/quant

The rest of the steps take place inside the newly created quant virtualenv.

Install numpy from source

pip install -e git+https://github.com/numpy/numpy.git#egg=numpy-dev

Install other dependencies via a requirements.txt file created by pip freeze > requirements.txt from a working installation.

PIP Requirements File (requirements.txt) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Cython==0.16
distribute==0.6.28
epydoc==3.0.1
ipython==0.13
lxml==2.3.5
patsy==0.1.0
python-dateutil==1.5
pytz==2012d
pyzmq==2.2.0.1
tornado==2.3
wsgiref==0.1.2
Jinja2==2.6
Pygments==1.5
Sphinx==1.1.3
docutils==0.9.1
readline==6.2.2
six==1.1.0
xlrd==0.8.0
-e git+https://github.com/pydata/pandas.git#egg=pandas-dev
-e git+https://github.com/sympy/sympy.git#egg=sympy-dev
-e git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev
-e git+https://github.com/scipy/scipy.git#egg=scipy-dev

wget http://blog.fungibleclouds.com/downloads/code/requirements.txt
pip install -r requirements.txt

Install statsmodels from source

pip install -e git+https://github.com/statsmodels/statsmodels.git#egg=statsmodels-dev

Install CVXopt from source

pip install cvxopt should work but seems there is a bug with cvxopt.

cd ~/domains/quant/src
wget http://abel.ee.ucla.edu/src/cvxopt-1.1.5.tar.gz
tar zxvf cvxopt-1.1.5.tar.gz
cd cvxopt-1.1.5/src
python setup.py install

Install QSTK

cd ~/domains/quant/
mkdir QSTK
cd QSTK
svn checkout http://svn.quantsoftware.org/openquantsoftware/trunk .

Install QSDATA - sample data from the stock market

wget http://www.quantsoftware.org/QSData.zip
unzip QSData.zip

Configure the qstk specific env variables

cp config.sh local.sh
vi local.sh # edit the $QSDATA env var to point to $QS/QSData/
vi local.sh # edit this to match path of QSTK and QSDATA
	$QS : This is the path to your installation (The location of the Bin, Example, Docs) folders.
	$QSDATA : This is where all the stock data will be.
source local.sh

Test the env variables

echo $QS # would show ~/domains/quant/QSTK
echo $QSDATA # would show ~/domains/quant/QSTK/QSData

Now you are ready to run the QSTK examples

ipython notebook --pylab inline # This will open your default browser http://localhost:8888

Click on new notebook to create a new tab with new empty notebook. In that new notebook, type this code segment to test your setup

import numpy as np
import pandas as pand
import matplotlib.pyplot as plt
from pylab import *
x = np.random.randn(1000)
plt.hist(x,100)
plt.savefig('test.png',format='png')

Press SHIFT-ENTER to see something like this below.

The class is not started yet but here are the two recommended readings that I ordered already.

I am looking forward to applying the learnings from this class to my personal portfolio.

Comments