Files
catalyst/development-guidelines.html
T
Victor Grau Serrat 3a0bb67f16 DOC: videos
2017-10-30 11:17:28 -06:00

341 lines
17 KiB
HTML

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Development Guidelines &mdash; Catalyst 0.3 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="top" title="Catalyst 0.3 documentation" href="index.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> Catalyst
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul>
<li class="toctree-l1"><a class="reference internal" href="install.html">Install</a><ul>
<li class="toctree-l2"><a class="reference internal" href="install.html#installing-with-pip">Installing with <code class="docutils literal"><span class="pre">pip</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="install.html#gnu-linux">GNU/Linux</a></li>
<li class="toctree-l3"><a class="reference internal" href="install.html#osx">OSX</a><ul>
<li class="toctree-l4"><a class="reference internal" href="install.html#osx-virtualenv-matplotlib">OSX + virtualenv + matplotlib</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="install.html#windows">Windows</a><ul>
<li class="toctree-l4"><a class="reference internal" href="install.html#troubleshooting-visual-c-compiler-install">Troubleshooting Visual C++ Compiler Install</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="install.html#amazon-linux-ami">Amazon Linux AMI</a></li>
<li class="toctree-l3"><a class="reference internal" href="install.html#troubleshooting-pip-install">Troubleshooting <code class="docutils literal"><span class="pre">pip</span></code> Install</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="install.html#installing-with-conda">Installing with <code class="docutils literal"><span class="pre">conda</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="install.html#troubleshooting-conda-install">Troubleshooting <code class="docutils literal"><span class="pre">conda</span></code> Install</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="install.html#getting-help">Getting Help</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="beginner-tutorial.html">Catalyst Beginner Tutorial</a><ul>
<li class="toctree-l2"><a class="reference internal" href="beginner-tutorial.html#basics">Basics</a></li>
<li class="toctree-l2"><a class="reference internal" href="beginner-tutorial.html#my-first-algorithm">My first algorithm</a></li>
<li class="toctree-l2"><a class="reference internal" href="beginner-tutorial.html#running-the-algorithm">Running the algorithm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="beginner-tutorial.html#ingesting-data">Ingesting data</a></li>
<li class="toctree-l3"><a class="reference internal" href="beginner-tutorial.html#command-line-interface">Command line interface</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="beginner-tutorial.html#access-to-previous-prices-using-history">Access to previous prices using <code class="docutils literal"><span class="pre">history</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="beginner-tutorial.html#working-example-dual-moving-average-cross-over">Working example: Dual Moving Average Cross-Over</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="beginner-tutorial.html#conclusions">Conclusions</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="naming-convention.html">Naming Convention</a></li>
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a></li>
</ul>
</div>
&nbsp;
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Catalyst</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li>Development Guidelines</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/development-guidelines.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document">
<div class="section" id="development-guidelines">
<h1>Development Guidelines<a class="headerlink" href="#development-guidelines" title="Permalink to this headline"></a></h1>
<p>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.</p>
<p>All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome. We <a class="reference external" href="https://github.com/quantopian/zipline/issues">track issues</a> on <a class="reference external" href="https://github.com/">GitHub</a> and also have a <a class="reference external" href="https://groups.google.com/forum/#!forum/zipline">mailing list</a> where you can ask questions.</p>
<div class="section" id="creating-a-development-environment">
<h2>Creating a Development Environment<a class="headerlink" href="#creating-a-development-environment" title="Permalink to this headline"></a></h2>
<p>First, you&#8217;ll need to clone Zipline by running:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>git clone git@github.com:your-github-username/zipline.git
</pre></div>
</div>
<p>Then check out to a new branch where you can make your changes:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>git checkout -b some-short-descriptive-name
</pre></div>
</div>
<p>If you don&#8217;t already have them, you&#8217;ll need some C library dependencies. You can follow the <a class="reference external" href="install.html">install guide</a> to get the appropriate dependencies.</p>
<p>The following section assumes you already have virtualenvwrapper and pip installed on your system. Suggested installation of Python library dependencies used for development:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>mkvirtualenv zipline
<span class="nv">$ </span>./etc/ordered_pip.sh ./etc/requirements.txt
<span class="nv">$ </span>pip install -r ./etc/requirements_dev.txt
<span class="nv">$ </span>pip install -r ./etc/requirements_blaze.txt
</pre></div>
</div>
<p>Finally, you can build the C extensions by running:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>python setup.py build_ext --inplace
</pre></div>
</div>
<p>To finish, make sure <a class="reference external" href="#style-guide-running-tests">tests</a> pass.</p>
<p>If you get an error running nosetests after setting up a fresh virtualenv, please try running</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="c"># where zipline is the name of your virtualenv</span>
<span class="nv">$ </span>deactivate zipline
<span class="nv">$ </span>workon zipline
</pre></div>
</div>
</div>
<div class="section" id="development-with-docker">
<h2>Development with Docker<a class="headerlink" href="#development-with-docker" title="Permalink to this headline"></a></h2>
<p>If you want to work with zipline using a <a class="reference external" href="https://docs.docker.com/get-started/">Docker</a> container, you&#8217;ll need to build the <code class="docutils literal"><span class="pre">Dockerfile</span></code> in the Zipline root directory, and then build <code class="docutils literal"><span class="pre">Dockerfile-dev</span></code>. Instructions for building both containers can be found in <code class="docutils literal"><span class="pre">Dockerfile</span></code> and <code class="docutils literal"><span class="pre">Dockerfile-dev</span></code>, respectively.</p>
</div>
<div class="section" id="style-guide-running-tests">
<h2>Style Guide &amp; Running Tests<a class="headerlink" href="#style-guide-running-tests" title="Permalink to this headline"></a></h2>
<p>We use <a class="reference external" href="http://flake8.pycqa.org/en/latest/">flake8</a> for checking style requirements and <a class="reference external" href="http://nose.readthedocs.io/en/latest/">nosetests</a> to run Zipline tests. Our <a class="reference external" href="https://en.wikipedia.org/wiki/Continuous_integration">continuous integration</a> tools will run these commands.</p>
<p>Before submitting patches or pull requests, please ensure that your changes pass when running:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>flake8 zipline tests
</pre></div>
</div>
<p>In order to run tests locally, you&#8217;ll need <a class="reference external" href="https://mrjbq7.github.io/ta-lib/install.html">TA-lib</a>, which you can install on Linux by running:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz
<span class="nv">$ </span>tar -xvzf ta-lib-0.4.0-src.tar.gz
<span class="nv">$ </span><span class="nb">cd </span>ta-lib/
<span class="nv">$ </span>./configure --prefix<span class="o">=</span>/usr
<span class="nv">$ </span>make
<span class="nv">$ </span>sudo make install
</pre></div>
</div>
<p>And for <code class="docutils literal"><span class="pre">TA-lib</span></code> on OS X you can just run:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>brew install ta-lib
</pre></div>
</div>
<p>Then run <code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span></code> TA-lib:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>pip install -r ./etc/requirements_talib.txt
</pre></div>
</div>
<p>You should now be free to run tests:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>nosetests
</pre></div>
</div>
</div>
<div class="section" id="continuous-integration">
<h2>Continuous Integration<a class="headerlink" href="#continuous-integration" title="Permalink to this headline"></a></h2>
<p>We use <a class="reference external" href="https://travis-ci.org/quantopian/zipline">Travis CI</a> for Linux-64 bit builds and <a class="reference external" href="https://ci.appveyor.com/project/quantopian/zipline">AppVeyor</a> for Windows-64 bit builds.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">We do not currently have CI for OSX-64 bit builds. 32-bit builds may work but are not included in our integration tests.</p>
</div>
</div>
<div class="section" id="packaging">
<h2>Packaging<a class="headerlink" href="#packaging" title="Permalink to this headline"></a></h2>
<p>To learn about how we build Zipline conda packages, you can read <a class="reference external" href="release-process.html#uploading-conda-packages">this</a> section in our release process notes.</p>
</div>
<div class="section" id="contributing-to-the-docs">
<h2>Contributing to the Docs<a class="headerlink" href="#contributing-to-the-docs" title="Permalink to this headline"></a></h2>
<p>If you&#8217;d like to contribute to the documentation on zipline.io, you can navigate to <code class="docutils literal"><span class="pre">docs/source/</span></code> where each <a class="reference external" href="https://en.wikipedia.org/wiki/ReStructuredText">reStructuredText</a> (<code class="docutils literal"><span class="pre">.rst</span></code>) file is a separate section there. To add a section, create a new file called <code class="docutils literal"><span class="pre">some-descriptive-name.rst</span></code> and add <code class="docutils literal"><span class="pre">some-descriptive-name</span></code> to <code class="docutils literal"><span class="pre">appendix.rst</span></code>. To edit a section, simply open up one of the existing files, make your changes, and save them.</p>
<p>We use <a class="reference external" href="http://www.sphinx-doc.org/en/stable/">Sphinx</a> to generate documentation for Zipline, which you will need to install by running:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>pip install -r ./etc/requirements_docs.txt
</pre></div>
</div>
<p>To build and view the docs locally, run:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="c"># assuming you&#39;re in the Zipline root directory</span>
<span class="nv">$ </span><span class="nb">cd </span>docs
<span class="nv">$ </span>make html
<span class="nv">$ </span><span class="o">{</span>BROWSER<span class="o">}</span> build/html/index.html
</pre></div>
</div>
</div>
<div class="section" id="commit-messages">
<h2>Commit messages<a class="headerlink" href="#commit-messages" title="Permalink to this headline"></a></h2>
<p>Standard prefixes to start a commit message:</p>
<div class="highlight-text"><div class="highlight"><pre>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
</pre></div>
</div>
<p>Some commit style guidelines:</p>
<p>Commit lines should be no longer than <a class="reference external" href="https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project">72 characters</a>. 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.</p>
<p><strong>Example:</strong></p>
<div class="highlight-text"><div class="highlight"><pre>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.
</pre></div>
</div>
</div>
<div class="section" id="formatting-docstrings">
<h2>Formatting Docstrings<a class="headerlink" href="#formatting-docstrings" title="Permalink to this headline"></a></h2>
<p>When adding or editing docstrings for classes, functions, etc, we use <a class="reference external" href="https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt">numpy</a> as the canonical reference.</p>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2017, Enigma MPC, Inc..
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'0.3',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>