Monday, August 26, 2013

Two useful python configurations

1 Manually select the source of packages when using easy_install

Put such a file in your $HOME$ path:

[easy_install]
index-url=http://mirrors.tuna.tsinghua.edu.cn/pypi/simple

and name the file as : pydistutils.cfg
From now on the easy_install will use the index-url you just defined as a preferred source of packages.

More useful settings can be found here: Configure pydistutils.cfg - example python distutils config file

2 A python snippet to make updating easy_install package update easier

from setuptools.command.easy_install import main as install
from pkg_resources import Environment, working_set
import sys

plist = [dist.key for dist in working_set]

def autoUp():
    for p in Environment():
        try:
            install(['-U', '-v'] + [p])
        except:
            print "Update of %s failed!"%p
        print "Done!"

def stepUp():
    for p in Environment():
        a = raw_input("updating %s, confirm?(y/n)"%p)
        if a== 'y':
            try:
                install(['-U'] + [p])
            except:
                print "Update of %s failed!"%p
        else:
            print "Skipping %s"%p
        print "Done!"

print "You have %s packages currently managed through easy_install"%len(plist)
print plist

ans = raw_input('Do you want to update them... (N) not at all, (O) one by one, (A) All')

if ans == "N":
    sys.exit()
elif ans == "O":
    stepUp()
elif ans == "A":
    autoUp()
else:
    pass

Written with StackEdit.

Saturday, August 10, 2013

Recent updates

Since I got Day One app on all of my Apple products, I haven't have log on this blog for quite a while.

Recently I have been developing a few quant strategies with a hedge fund in Wall Street. So my day time job is to program in C and Python. I use python to rapid-prototype ideas, and use C to develop serious and dependable apps to trade. 

Some packages I would really love to recommend : 


An data source for most mainstream languages and excel. The data is clean and neat.


An open source backtest framework for python. You can use Quantopian for 1 min data resolution. And Zipline for more flexibility and local backtest.



And my favorite IDE for python and C:


I didn't mean to be political in editor war, but gVim is so f***** superior and comfortable to use. 


In the end I would like to post an Instagram photo. The cloud is simply dream-like that afternoon.