zipline-- 開發指南

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中找到例子。

相關文章
相關標籤/搜索