Skip to content

Commit

Permalink
data_1
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghan1990 committed Apr 5, 2017
1 parent e6b535e commit 468f2d9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 58 deletions.
71 changes: 17 additions & 54 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,31 @@ Zipline:当前在线的量化平台基本都是基于zipline进行开发,使
安装方法
========

运行环境:linux, OSX,建议不要使用windows,因为zipline涉及到gcc的编译,windows可能编译过程中有一些问题

运行环境:linux, OSX,建议不要使用windows,因为zipline涉及到gcc的编译,windows可能编译过程中有一些问题, windows的用户,可以使用virtual box虚拟机,虚拟机地址


以ubuntu 为例:

- sudo pip install virtualenv
- git clone https://github.com/zhanghan1990/zipline
- cd zipline
- . venv/bin/activate
- sudo apt-get install python-pip
- sudo apt-get install mongodb
- sudo pip install virtualenv
- sudo apt-get install python-tk
- virtualenv zipline_env
- source zipline_env/bin/activate
- pip install -r requirements.txt
- python setup.py install
- sudo service mongodb start
- pip install xlrd
- pip3 install jupyter


安装过程中出现的问题
==============
(1) bottleneck 和 numpy版本问题:

build_ext = self.get_finalized_command('build_ext')
File "/usr/lib/python2.7/distutils/cmd.py", line 312, in get_finalized_command
cmd_obj.ensure_finalized()
File "/usr/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
self.finalize_options()
File "/tmp/easy_install-TJlXeR/Bottleneck-1.2.0/setup.py", line 24, in finalize_options
join,
AttributeError: 'dict' object has no attribute '__NUMPY_SETUP__'


解决办法:pip install bottleneck==1.0.0,然后继续执行
python setup.py install

(2)

```/tmp/easy_install-nGdcR9/scipy-0.19.0/setup.py:323: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
warnings.warn("Unrecognized setuptools command, proceeding with "
/home/zhanghan/zipline_2/zipline/venv/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:572: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
/home/zhanghan/zipline_2/zipline/venv/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:572: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
self.calc_info()
/home/zhanghan/zipline_2/zipline/venv/local/lib/python2.7/site-packages/numpy/distutils/system_info.py:572: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
self.calc_info()
Running from scipy source directory.
non-existing path in 'scipy/integrate': 'quadpack.h'
error: no lapack/blas resources found```


解决办法:pip install pip install scipy==0.15.1,然后继续执行
python setup.py install



本版本完成的主要工作
========


version_1.0 完成的主要工作
=======================

- 交易日历纠正,从1990年开始的所有有效交易日都包含其中,剔除非交易时段
- A股数据源,把数据写入mongodb中,每次从mongodb中读取需要的数据
Expand All @@ -85,6 +47,7 @@ python setup.py install

- 您可以使用自己的数据,也可以使用我配置的数据源,数据源我已经配置好,如果自己配置,需要修改文件 data/constants.py 下的IP和PORT
- 本版本的数据源,只更新到2017.02.28,后面我会每天更新数据
- 日线数据导入,参考文件

关于例子
========
Expand Down
17 changes: 13 additions & 4 deletions zipline/data/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
from os import walk

from pandas import DataFrame
from constants import BASEDIR



class LoadDataCVS:
stockdata="/home/vserver5/zipline_v1/tradedata/stock data"
indexdata="/home/vserver5/zipline_v1/tradedata/index data"

basedir="~/zipline"
stockdata=self.basedir+"/tradedata/stock data"
indexdata=self.basedir+"/tradedata/index data"

#treasurvity
in_package_data = range(2002, 2017)
Expand Down Expand Up @@ -54,7 +57,7 @@ def Close(self):


#store data information into database, do not always call this
def storagedate(self):
def storagedata(self):
#get the filelist
onlyfiles = [ f for f in listdir(self.stockdata) if isfile(join(self.stockdata,f)) ]
#read from using pandas
Expand Down Expand Up @@ -294,7 +297,13 @@ def storageStockName(self):


if __name__ == '__main__':
l=LoadDataCVS('166.111.68.233',27017)
l=LoadDataCVS('127.0.0.1',27017)
l.Conn()
l.stockdata()
l.storageindex()
l.storagepool()
l.storageStockName()
l.insert_zipline_treasure_format()

#l.storageStockName()
print l.getstocklist('all')

0 comments on commit 468f2d9

Please sign in to comment.