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的開發人員,希望為Zipline代碼庫或文檔作出貢獻的人員,或希望從源代碼進行安裝并對其Zipline副本進行本地更改的人員。
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.
所有貢獻,錯誤報告,錯誤修復,文檔改進,增強功能和創意都受到歡迎。 我們在GitHub上跟蹤問題,并且還有一個郵件列表,您可以在其中提問。
Creating a Development Environment 創建開發環境
First, you’ll need to clone Zipline by running: 首先,您需要運行以下命令克隆Zipline:
$ git clone git@github.com:your-github-username/zipline.gitThen check out to a new branch where you can make your changes: 然后簽出一個新的分支,您可以在其中進行更改:
$ 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庫依賴。 您可以按照安裝指南獲取適當的依賴關系。
The following section assumes you already have virtualenvwrapper and pip installed on your system. Suggested installation of Python library dependencies used for development:
以下部分假定您已經在系統上安裝了virtualenvwrapper和pip。 建議安裝用于開發的Python庫依賴項:
$ 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: 最后,您可以運行以下命令來構建C擴展:
$ python setup.py build_ext --inplaceTo finish, make sure tests pass. 要完成,請確保測試通過。
If you get an error running nosetests after setting up a fresh virtualenv, please try running 如果您在設置新的virtualenv后出現運行nosetests的錯誤,請嘗試運行
# 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根目錄中構建Dockerfile,然后構建Dockerfile-dev。 構建兩個容器的指令可分別在Dockerfile和Dockerfile-dev中找到。
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來運行Zipline測試。 我們的持續集成工具將運行這些命令。
Before submitting patches or pull requests, please ensure that your changes pass when running:
在提交補丁或拉取請求之前,請確保您的更改在運行時通過:
$ flake8 zipline testsIn 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 installAnd for TA-lib on OS X you can just run:
而對于OS X上的TA-lib,你可以運行:
$ brew install ta-libThen run pip install TA-lib:
然后運行pip install TA-lib:
$ pip install -r ./etc/requirements_talib.txtYou should now be free to run tests:
您現在應該可以自由運行測試:
$ nosetests?
Continuous Integration 持續集成
We use Travis CI for Linux-64 bit builds and AppVeyor for Windows-64 bit builds.
我們使用Travis CI進行Linux-64位構建,使用AppVeyor進行Windows-64位構建。
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位構建的CI。 32位構建可能可行,但不包括在我們的集成測試中。
Packaging 打包
To learn about how we build Zipline conda packages, you can read this section in our release process notes.
要了解我們如何構建Zipline 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.
如果您想對zipline.io文檔作出貢獻,您可以導航到docs/source/,其中每個reStructuredText(.rst)文件都是一個單獨的部分。 要添加節,請創建一個名為some-descriptive-name.rst的新文件,并向appendix.rst中添加一些描述性名稱。 要編輯節,只需打開一個現有文件,進行更改并保存。
We use Sphinx to generate documentation for Zipline, which you will need to install by running:
我們使用Sphinx為Zipline生成文檔,您需要通過運行來安裝它:
$ pip install -r ./etc/requirements_docs.txtTo 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 enhancementsSome 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個字符。 提交的第一行應包含上述前綴之一。 提交主題和提交主體之間應該有一條空行。 一般來說,信息應該是必要時。 最佳做法不僅包括變化是什么,而且包括變更的原因。
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. 當為類,函數等添加或編輯文檔字符串時,我們使用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文件,用于記錄不同版本的Zipline之間發生的變化。 一旦您對Zipline進行了更改,請在您的合并請求中更新最新的whatsnew文件,并附帶有關您更改內容的評論。 您可以在以前的whatsnew文件中找到示例。
轉載于:https://www.cnblogs.com/fangbei/p/9077987.html
總結
以上是生活随笔為你收集整理的Zipline Development Guidelines的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 显示point data的时均值注意事项
- 下一篇: 03-Tomcat服务器