Development Guidelines
开发指南
This page is intended for developers of Zipline, people who want to contribute to the Zipline codebase or documentation, or people who want to install from source and make local changes to their copy of Zipline.
这个页面是为Zipline开发、但愿为ZiPin代码库或文档提供帮助,或者但愿从源文件安装并对ZiPrin的副本进行本地修改的人编写的。
All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome. We track issues on GitHub and also have a mailing list where you can ask questions.
全部的贡献、bug报告、bug修复、文档改进、加强和想法都是受欢迎的。咱们跟踪GITHUB上的问题,也有一个邮件列表,你能够问问题。html
Creating a Development Environment
建立开发环境
First, you’ll need to clone Zipline by running:
首先,你须要经过运行下面代码克隆ZIPLIN:python
$ git clone git@github.com:your-github-username/zipline.git
Then check out to a new branch where you can make your changes:
而后检查到一下你能够作过修改的分支:git
$ git checkout -b some-short-descriptive-name
If you don’t already have them, you’ll need some C library dependencies. You can follow the install guide to get the appropriate dependencies.
若是您尚未这些文件,则须要一些C库依赖项。您能够按照安装指南得到适当的依赖关系。
The following section assumes you already have virtualenvwrapper and pip installed on your system. Suggested installation of Python library dependencies used for development:
下面的部分假定您已经在系统上安装了ValualEnvRePrPress和PIP。建议安装用于开发的Python库依赖项:github
$ mkvirtualenv zipline $ ./etc/ordered_pip.sh ./etc/requirements.txt $ pip install -r ./etc/requirements_dev.txt $ pip install -r ./etc/requirements_blaze.txt
Finally, you can build the C extensions by running:
最后,您能够经过运行来构建C扩展:api
$ python setup.py build_ext --inplace
To finish, make sure tests pass.
要完成,确保测试经过。
If you get an error running nosetests after setting up a fresh virtualenv, please try running
若是在建立新的虚拟机后运行nosetests出错,请尝试运行app
# where zipline is the name of your virtualenv $ deactivate zipline $ workon zipline
Development with Docker
使用Docker开发
If you want to work with zipline using a Docker container, you’ll need to build the Dockerfile in the Zipline root directory, and then build Dockerfile-dev. Instructions for building both containers can be found in Dockerfile and Dockerfile-dev, respectively.
若是您想使用Docker容器与Zipline一块儿工做,则须要在zipline的root目录中构建Dockerfile文件,而后构建Dockerfile-dev。在Dockerfile and Dockerfile-dev中分别找到用于构建这两个容器的指令。ide
Style Guide & Running Tests
样式指南;运行测试
We use flake8 for checking style requirements and nosetests to run Zipline tests. Our continuous integration tools will run these commands.
咱们使用FLAKE8来检查样式需求和nosetests来运行ZiPiLin测试。咱们的连续集成工具将运行这些命令。
Before submitting patches or pull requests, please ensure that your changes pass when running:
在提交补丁或提请请求以前,请确保在运行时您的更改经过测试:函数
$ flake8 zipline tests
In order to run tests locally, you’ll need TA-lib, which you can install on Linux by running:
为了在本地运行测试,您须要TA LIB,您能够经过在Linux上安装运行:工具
$ wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz $ tar -xvzf ta-lib-0.4.0-src.tar.gz $ cd ta-lib/ $ ./configure --prefix=/usr $ make $ sudo make install
And for TA-lib on OS X you can just run:
对于OSX上的TA LIB,您能够运行:测试
$ brew install ta-lib
Then run pip install TA-lib:
而后运行PIP安装TA LIB:
$ pip install -r ./etc/requirements_talib.txt
You should now be free to run tests:
您如今应该能够自由运行测试:
$ nosetests
Continuous Integration
持续集成
We use CI for Linux-64 bit builds and AppVeyor for Windows-64 bit builds.
咱们使用Travis CI为Linux-64位构建和 AppVeyor为Windows 64位构建。
Packaging
包装
To learn about how we build Zipline conda packages, you can read this section in our release process notes.
要了解咱们如何构建ZiPin CONDA软件包,您能够在咱们的发布过程日记中阅读这一部分。
Contributing to the Docs
对文档的贡献
If you’d like to contribute to the documentation on zipline.io, you can navigate to docs/source/ where each reStructuredText (.rst) file is a separate section there. To add a section, create a new file called some-descriptive-name.rst and add some-descriptive-name to appendix.rst. To edit a section, simply open up one of the existing files, make your changes, and save them.
若是您想为ZiPix.IO的文档做出贡献,您能够导航到docs/source/的每一个 reStructuredText (.rst)文件,其中的每个都是单独的一个部分。要添加一个部分,建立一个名为some-descriptive-name.rst的新文件,并将some-descriptive-name添加到appendix.rst。要编辑一个部分,只需打开现有文件中的一个,进行更改,而后保存它们。
We use Sphinx to generate documentation for Zipline, which you will need to install by running:
咱们使用Sphinx生成ZIPLIN文档,您须要经过运行来安装:
$ pip install -r ./etc/requirements_docs.txt
To build and view the docs locally, run:
要在本地构建和查看文档,请运行:
# assuming you're in the Zipline root directory $ cd docs $ make html $ {BROWSER} build/html/index.html
Commit messages
提交消息
Standard prefixes to start a commit message:
启动提交消息的标准前缀:
BLD: change related to building Zipline BUG: bug fix DEP: deprecate something, or remove a deprecated object DEV: development tool or utility DOC: documentation ENH: enhancement MAINT: maintenance commit (refactoring, typos, etc) REV: revert an earlier commit STY: style fix (whitespace, PEP8, flake8, etc) TST: addition or modification of tests REL: related to releasing Zipline PERF: performance enhancements
Some commit style guidelines:
一些提交风格指南:
Commit lines should be no longer than 72 characters. The first line of the commit should include one of the above prefixes. There should be an empty line between the commit subject and the body of the commit. In general, the message should be in the imperative tense. Best practice is to include not only what the change is, but why the change was made.
提交行不该超过72个字符。提交的第一行应该包括上面的前缀之一。在提交主体和提交主体之间应该有一个空行。通常来讲,信息应该是祈使语气。最好的作法是不只包括改变是什么,并且包括改变的缘由。
例如:
MAINT: Remove unused calculations of max_leverage, et al. In the performance period the max_leverage, max_capital_used, cumulative_capital_used were calculated but not used. At least one of those calculations, max_leverage, was causing a divide by zero error. Instead of papering over that error, the entire calculation was a bit suspect so removing, with possibility of adding it back in later with handling the case (or raising appropriate errors) when the algorithm has little cash on hand.
Formatting Docstrings
格式化文档字符串
When adding or editing docstrings for classes, functions, etc, we use numpy as the canonical reference.
当为类、函数等添加或编辑docstrings时,咱们使用numpy做为规范引用。
Updating the Whatsnew
更新新事物We have a set of whatsnew files that are used for documenting changes that have occurred between different versions of Zipline. Once you’ve made a change to Zipline, in your Pull Request, please update the most recent whatsnew file with a comment about what you changed. You can find examples in previous whatsnew files.咱们有一套whatsnew文件用于记录不一样版本的ZIPLIN之间发生的变化。一旦你改变了ZIPLIN,在你提需求,请更新最新的Whatsnew并说明你改变了什么。你能够在之前的whatsnew中找到例子。