Zipline Development Guidelines
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的開發(fā)人員,希望為Zipline代碼庫或文檔作出貢獻(xiàn)的人員,或希望從源代碼進(jìn)行安裝并對(duì)其Zipline副本進(jìn)行本地更改的人員。
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.
所有貢獻(xiàn),錯(cuò)誤報(bào)告,錯(cuò)誤修復(fù),文檔改進(jìn),增強(qiáng)功能和創(chuàng)意都受到歡迎。 我們?cè)贕itHub上跟蹤問題,并且還有一個(gè)郵件列表,您可以在其中提問。
Creating a Development Environment 創(chuàng)建開發(fā)環(huán)境
First, you’ll need to clone Zipline by running: 首先,您需要運(yùn)行以下命令克隆Zipline:
$ git clone git@github.com:your-github-username/zipline.gitThen check out to a new branch where you can make your changes: 然后簽出一個(gè)新的分支,您可以在其中進(jìn)行更改:
$ git checkout -b some-short-descriptive-nameIf 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庫依賴。 您可以按照安裝指南獲取適當(dāng)?shù)囊蕾囮P(guān)系。
The following section assumes you already have virtualenvwrapper and pip installed on your system. Suggested installation of Python library dependencies used for development:
以下部分假定您已經(jīng)在系統(tǒng)上安裝了virtualenvwrapper和pip。 建議安裝用于開發(fā)的Python庫依賴項(xiàng):
$ mkvirtualenv zipline $ ./etc/ordered_pip.sh ./etc/requirements.txt $ pip install -r ./etc/requirements_dev.txt $ pip install -r ./etc/requirements_blaze.txtFinally, you can build the C extensions by running: 最后,您可以運(yùn)行以下命令來構(gòu)建C擴(kuò)展:
$ python setup.py build_ext --inplaceTo finish, make sure tests pass. 要完成,請(qǐng)確保測(cè)試通過。
If you get an error running nosetests after setting up a fresh virtualenv, please try running 如果您在設(shè)置新的virtualenv后出現(xiàn)運(yùn)行nosetests的錯(cuò)誤,請(qǐng)嘗試運(yùn)行
# where zipline is the name of your virtualenv $ deactivate zipline $ workon zipline?
Development with Docker 使用Docker進(jìn)行開發(fā)
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根目錄中構(gòu)建Dockerfile,然后構(gòu)建Dockerfile-dev。 構(gòu)建兩個(gè)容器的指令可分別在Dockerfile和Dockerfile-dev中找到。
Style Guide & Running Tests 風(fēng)格指南和運(yùn)行測(cè)試
We use flake8 for checking style requirements and nosetests to run Zipline tests. Our continuous integration tools will run these commands.
我們使用flake8來檢查樣式要求和nosetests來運(yùn)行Zipline測(cè)試。 我們的持續(xù)集成工具將運(yùn)行這些命令。
Before submitting patches or pull requests, please ensure that your changes pass when running:
在提交補(bǔ)丁或拉取請(qǐng)求之前,請(qǐng)確保您的更改在運(yùn)行時(shí)通過:
$ flake8 zipline testsIn order to run tests locally, you’ll need TA-lib, which you can install on Linux by running:
為了在本地運(yùn)行測(cè)試,您需要TA-lib,您可以通過運(yùn)行以下命令在Linux上進(jìn)行安裝:
$ 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 installAnd for TA-lib on OS X you can just run:
而對(duì)于OS X上的TA-lib,你可以運(yùn)行:
$ brew install ta-libThen run pip install TA-lib:
然后運(yùn)行pip install TA-lib:
$ pip install -r ./etc/requirements_talib.txtYou should now be free to run tests:
您現(xiàn)在應(yīng)該可以自由運(yùn)行測(cè)試:
$ nosetests?
Continuous Integration 持續(xù)集成
We use Travis CI for Linux-64 bit builds and AppVeyor for Windows-64 bit builds.
我們使用Travis CI進(jìn)行Linux-64位構(gòu)建,使用AppVeyor進(jìn)行Windows-64位構(gòu)建。
Note
We do not currently have CI for OSX-64 bit builds. 32-bit builds may work but are not included in our integration tests.
我們目前沒有用于OSX-64位構(gòu)建的CI。 32位構(gòu)建可能可行,但不包括在我們的集成測(cè)試中。
Packaging 打包
To learn about how we build Zipline conda packages, you can read this section in our release process notes.
要了解我們?nèi)绾螛?gòu)建Zipline conda軟件包,可以在我們的發(fā)布流程說明中閱讀本節(jié)。
Contributing to the Docs 為文檔做出貢獻(xiàn)
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.
如果您想對(duì)zipline.io文檔作出貢獻(xiàn),您可以導(dǎo)航到docs/source/,其中每個(gè)reStructuredText(.rst)文件都是一個(gè)單獨(dú)的部分。 要添加節(jié),請(qǐng)創(chuàng)建一個(gè)名為some-descriptive-name.rst的新文件,并向appendix.rst中添加一些描述性名稱。 要編輯節(jié),只需打開一個(gè)現(xiàn)有文件,進(jìn)行更改并保存。
We use Sphinx to generate documentation for Zipline, which you will need to install by running:
我們使用Sphinx為Zipline生成文檔,您需要通過運(yùn)行來安裝它:
$ pip install -r ./etc/requirements_docs.txtTo build and view the docs locally, run: 要在本地構(gòu)建和查看文檔,請(qǐng)運(yùn)行:
# 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: 用于啟動(dòng)提交消息的標(biāo)準(zhǔn)前綴:
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 enhancementsSome commit style guidelines: 一些提交樣式準(zhǔn)則:
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.
提交行不應(yīng)超過72個(gè)字符。 提交的第一行應(yīng)包含上述前綴之一。 提交主題和提交主體之間應(yīng)該有一條空行。 一般來說,信息應(yīng)該是必要時(shí)。 最佳做法不僅包括變化是什么,而且包括變更的原因。
Example:
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 格式化Docstrings
When adding or editing docstrings for classes, functions, etc, we use numpy as the canonical reference. 當(dāng)為類,函數(shù)等添加或編輯文檔字符串時(shí),我們使用numpy作為規(guī)范引用。
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文件,用于記錄不同版本的Zipline之間發(fā)生的變化。 一旦您對(duì)Zipline進(jìn)行了更改,請(qǐng)?jiān)谀暮喜⒄?qǐng)求中更新最新的whatsnew文件,并附帶有關(guān)您更改內(nèi)容的評(píng)論。 您可以在以前的whatsnew文件中找到示例。
轉(zhuǎn)載于:https://www.cnblogs.com/fangbei/p/9077987.html
總結(jié)
以上是生活随笔為你收集整理的Zipline Development Guidelines的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 显示point data的时均值注意事项
- 下一篇: Python"***.