mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-17 11:25:55 +08:00
reorganizing modules and scripts
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import tornado.auth
|
||||
import tornado.httpserver
|
||||
import tornado.ioloop
|
||||
from tornado.options import define, options
|
||||
import tornado.web
|
||||
import pymongo
|
||||
import bson
|
||||
import hashlib
|
||||
import base64
|
||||
import uuid
|
||||
import os
|
||||
import logging
|
||||
import datetime
|
||||
import random
|
||||
|
||||
import simulator.qbt_server as qbt_server
|
||||
|
||||
MINUTE_COUNT=390
|
||||
|
||||
define("user_email", default="qbt@quantopian.com", help="email address for qbt user")
|
||||
define("password", default="foobar", help="password for qbt user")
|
||||
|
||||
def db_main():
|
||||
tornado.options.parse_command_line()
|
||||
connection, db = qbt_server.connect_db()
|
||||
|
||||
#create a user for testing
|
||||
salt, encrypted_password = qbt_server.encrypt_password(None, options.password)
|
||||
|
||||
if not db.users.find_one({'email':options.user_email}):
|
||||
db.users.insert({'email':options.user_email, 'encrypted_password':encrypted_password, 'salt':salt})
|
||||
|
||||
#create one mythical company
|
||||
if not db.company_info.find_one({'sid':133}):
|
||||
db.company_info.insert({'sid':133, "exchange" : "NEW YORK STOCK EXCHANGE", "symbol" : "JHF", "first date" : "01/04/1993", "last date" : "10/01/2008", "sid" : 133, "industry code" : "130A", "company name" : "JACK INC"})
|
||||
|
||||
#create one mythical company
|
||||
if not db.company_info.find_one({'sid':134}):
|
||||
db.company_info.insert({'sid':134, "exchange" : "NEW YORK STOCK EXCHANGE", "symbol" : "RCF", "first date" : "01/04/1993", "last date" : "10/01/2008", "sid" : 134, "industry code" : "130A", "company name" : "ROCCO INC"})
|
||||
|
||||
#create minute equity data collection and populate with a day of random data
|
||||
prices = {133:25.0,134:45.0} #sid, initial price.
|
||||
if not db.equity.trades.minute.find().count() == MINUTE_COUNT * len(prices):
|
||||
db.equity.trades.minute.drop()
|
||||
trade_start = datetime.datetime.now()
|
||||
minute = datetime.timedelta(minutes=1)
|
||||
|
||||
for i in range(MINUTE_COUNT):
|
||||
for sid,price in prices.iteritems():
|
||||
price = price + random.uniform(-0.05,0.05)
|
||||
db.equity.trades.minute.insert({'sid':sid, 'dt':trade_start + (minute * i),'price':price, 'volume':random.randrange(100,10000,100)})
|
||||
|
||||
if __name__ == "__main__":
|
||||
db_main()
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
|
||||
#setup virtualenvironment
|
||||
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
|
||||
if [ ! -d $HOME/.venvs ]; then
|
||||
mkdir $HOME/.venvs
|
||||
fi
|
||||
export WORKON_HOME=$HOME/.venvs
|
||||
source /usr/local/bin/virtualenvwrapper.sh
|
||||
|
||||
#create the scientific python virtualenv and copy to provide qsim base
|
||||
mkvirtualenv --no-site-packages scientific_base
|
||||
workon scientific_base
|
||||
./ordered_pip.sh requirements_sci.txt
|
||||
deactivate
|
||||
#re-base qsim
|
||||
#rmvirtualenv qsim
|
||||
cpvirtualenv scientific_base qsim
|
||||
|
||||
workon qsim
|
||||
./scripts/ordered_pip.sh requirements.txt
|
||||
./scripts/ordered_pip.sh requirements_dev.txt
|
||||
|
||||
#setup the local mongodb
|
||||
python ./scripts/dev_setup.py
|
||||
|
||||
#run all the tests in test
|
||||
nosetests --with-xcoverage --with-xunit --cover-erase --cover-package=simulator,transforms
|
||||
pylint -f parseable . | tee pylint.out
|
||||
|
||||
#run sloccount analysis
|
||||
sloccount --wide --details ./ > sloccount.sc
|
||||
|
||||
deactivate
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo $hash
|
||||
while read line
|
||||
do
|
||||
if [[ $line != \#* ]] ; then
|
||||
#echo $line
|
||||
pip install $line
|
||||
fi
|
||||
done < $1
|
||||
echo "Final line count is: $a";
|
||||
@@ -0,0 +1,8 @@
|
||||
tornado
|
||||
|
||||
#data source related
|
||||
pymongo==2.1.1
|
||||
|
||||
#zeromq related
|
||||
pyzmq==2.1.11
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
# For debugger
|
||||
fancycompleter==0.2
|
||||
pyrepl==0.8.2
|
||||
Pygments==1.4
|
||||
pdbpp==0.7.2
|
||||
|
||||
ipython==0.12
|
||||
|
||||
# For unit tests
|
||||
nose==1.1.2
|
||||
unittest2==0.5.1
|
||||
requests==0.10.1
|
||||
nosexcover
|
||||
pylint
|
||||
@@ -0,0 +1,18 @@
|
||||
#date related
|
||||
pytz==2011n
|
||||
python-dateutil==1.5
|
||||
|
||||
#core scientific python
|
||||
numpy==1.6.1
|
||||
scipy==0.10.0
|
||||
matplotlib==1.1.0
|
||||
#http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0.tar.gz
|
||||
numexpr==2.0.1
|
||||
Cython==0.15.1
|
||||
tables==2.3.1
|
||||
scikits.statsmodels==0.3.1
|
||||
pandas==0.7.0rc1
|
||||
|
||||
#zeromq related
|
||||
pyzmq==2.1.11
|
||||
|
||||
Reference in New Issue
Block a user