mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-10 00:15:30 +08:00
DOC: remake of beginner tutorial
This commit is contained in:
+166
-84
@@ -5,9 +5,8 @@ Basics
|
||||
~~~~~~
|
||||
|
||||
Catalyst is an open-source algorithmic trading simulator for crypto
|
||||
assets written in Python.
|
||||
|
||||
The source can be found at: https://github.com/enigmampc/catalyst
|
||||
assets written in Python. The source code can be found at:
|
||||
https://github.com/enigmampc/catalyst
|
||||
|
||||
Some benefits include:
|
||||
|
||||
@@ -25,8 +24,7 @@ Some benefits include:
|
||||
build profitable, data-driven investment strategies.
|
||||
|
||||
This tutorial assumes that you have Catalyst correctly installed, see the
|
||||
:doc:`installation instructions <install>` if you haven't set up
|
||||
Catalyst yet.
|
||||
:doc:`Install<install>` section if you haven't set up Catalyst yet.
|
||||
|
||||
Every ``catalyst`` algorithm consists of at least two functions you have to
|
||||
define:
|
||||
@@ -40,10 +38,12 @@ Before the start of the algorithm, ``catalyst`` calls the
|
||||
need to access from one algorithm iteration to the next.
|
||||
|
||||
After the algorithm has been initialized, ``catalyst`` calls the
|
||||
``handle_data()`` function once for each event. At every call, it passes
|
||||
the same ``context`` variable and an event-frame called ``data``
|
||||
containing the current trading bar with open, high, low, and close
|
||||
(OHLC) prices as well as volume for each crypto asset in your universe.
|
||||
``handle_data()`` function on each iteration, that's one per day (daily) or
|
||||
once every minute (minute), depending on the frequency we choose to run our
|
||||
simulation. On every iteration, ``handle_data()`` passes the same ``context``
|
||||
variable and an event-frame called ``data`` containing the current trading bar
|
||||
with open, high, low, and close (OHLC) prices as well as volume for each
|
||||
crypto asset in your universe.
|
||||
|
||||
.. For more information on these functions, see the `relevant part of the
|
||||
.. Quantopian docs <https://www.quantopian.com/help#api-toplevel>`.
|
||||
@@ -51,8 +51,8 @@ containing the current trading bar with open, high, low, and close
|
||||
My first algorithm
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Lets take a look at a very simple algorithm from the ``examples``
|
||||
directory: `buy_btc_simple.py <https://github.com/enigmampc/catalyst/blob/master/catalyst/examples/buy_btc_simple.py>`_:
|
||||
Lets take a look at a very simple algorithm from the ``examples`` directory:
|
||||
`buy_btc_simple.py <https://github.com/enigmampc/catalyst/blob/master/catalyst/examples/buy_btc_simple.py>`_:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -70,9 +70,9 @@ directory: `buy_btc_simple.py <https://github.com/enigmampc/catalyst/blob/master
|
||||
|
||||
As you can see, we first have to import some functions we would like to
|
||||
use. All functions commonly used in your algorithm can be found in
|
||||
``catalyst.api``. Here we are using :func:`~catalyst.api.order()` which takes two
|
||||
arguments: a cryptoasset object, and a number specifying how many assets you would
|
||||
like to order (if negative, :func:`~catalyst.api.order()` will sell/short
|
||||
``catalyst.api``. Here we are using :func:`~catalyst.api.order()` which takes
|
||||
twoarguments: a cryptoasset object, and a number specifying how many assets you
|
||||
wouldlike to order (if negative, :func:`~catalyst.api.order()` will sell/short
|
||||
assets). In this case we want to order 1 bitcoin at each iteration.
|
||||
|
||||
.. For more documentation on ``order()``, see the `Quantopian docs
|
||||
@@ -88,61 +88,98 @@ a bitcoin in the ``data`` event frame.
|
||||
|
||||
.. (for more information see `here <https://www.quantopian.com/help#api-event-properties>`__.
|
||||
|
||||
Running the algorithm
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To can now test this algorithm on crypto data, ``catalyst`` provides three
|
||||
interfaces:
|
||||
|
||||
- A command-line interface,
|
||||
- ``IPython Notebook`` magic,
|
||||
- and :func:`~catalyst.run_algorithm`.
|
||||
|
||||
Ingesting data
|
||||
^^^^^^^^^^^^^^
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
In previous versions of Catalyst you needed to manually ingest data before running
|
||||
your algorithm to make it available at runtime. Starting with version 0.3, the
|
||||
algorithm will automagically ingest the data it needs the first time that encounters
|
||||
a data request for data that it doesn't have.
|
||||
Before you can backtest your algorithm, you first need to load the historical
|
||||
pricing data that Catalyst needs to run your simulation through a process called
|
||||
``ingestion``. When you ingest data, Catalyst downloads that data in compressed
|
||||
form from the Enigma servers (which eventually will migrate to the Enigma Data
|
||||
Marketplace), and stores it locally to make it available at runtime.
|
||||
|
||||
Still, we believe it is important for you to have a high-level understanding
|
||||
of how data is managed:
|
||||
In order to ingest data, you need to run a command like the following:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
catalyst ingest-exchange -x bitfinex -i btc_usd
|
||||
|
||||
This instructs Catalyst to download pricing data from the ``Bitfinex`` exchange
|
||||
for the ``btc_usd`` currency pair (this follows from the simple algorithm
|
||||
presented above where we want to trade ``btc_usd``), and we're choosing to test
|
||||
our algorithm using historical pricing data from the Bitfinex exchange. By
|
||||
default, Catalyst assumes that you want data with ``daily`` frequency (one candle
|
||||
bar per day). If you want instead ``minute`` frequency (one candle bar for every
|
||||
minute), you would need to specify it as follows:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
catalyst ingest-exchange -x bitfinex -i btc_usd -f minute
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Ingesting exchange bundle bitfinex...
|
||||
[====================================] Ingesting daily price data on bitfinex: 100%
|
||||
|
||||
We believe it is important for you to have a high-level understanding of how
|
||||
data is managed, hence the following overview:
|
||||
|
||||
- Pricing data is split and packaged into ``bundles``: chunks of data organized
|
||||
as time series that are kept up to date daily on Enigma's servers. Catalyst
|
||||
downloads the bundles that needs at any given time, and reconstructs the whole
|
||||
dataset in your hard drive.
|
||||
downloads the requested bundles and reconstructs the full dataset in your
|
||||
hard drive.
|
||||
|
||||
- Pricing data is provided in ``daily`` and ``minute`` resolution. Those are different
|
||||
bundle datasets, and are managed separately.
|
||||
- Pricing data is provided in ``daily`` and ``minute`` resolution. Those are
|
||||
different bundle datasets, and are managed separately.
|
||||
|
||||
- Bundles are exchange-specific, as the pricing data is specific to the trades that
|
||||
happen in each exchange. You can optionally specify which exchange you want pricing
|
||||
data from.
|
||||
- Bundles are exchange-specific, as the pricing data is specific to the trades
|
||||
that happen in each exchange. As a result, you can must specify which
|
||||
exchange you want pricing data from when ingesting data
|
||||
|
||||
- Catalyst keeps track of all the downloaded bundles, so that it only has to download
|
||||
them once, and will do incremental updates as needed.
|
||||
- Catalyst keeps track of all the downloaded bundles, so that it only has to
|
||||
download them once, and will do incremental updates as needed.
|
||||
|
||||
- When running in ``live trading`` mode, Catalyst will first look for historical
|
||||
pricing data in the locally stored bundles. If there is anything missing, Catalyst will
|
||||
hit the exchange for the most recent data, and merge it with the local bundle to make
|
||||
it available for future iterations.
|
||||
- When running in ``live trading`` mode, Catalyst will first look for
|
||||
historical pricing data in the locally stored bundles. If there is anything
|
||||
missing, Catalyst will hit the exchange for the most recent data, and merge
|
||||
it with the local bundle to optimize the number of requests it needs to make
|
||||
to the exchange.
|
||||
|
||||
If you want to learn more, check out the :ref:`ingesting data <ingesting-data>` section
|
||||
for more detail.
|
||||
The ``ingest-exchange`` command in catalyst offers additional parameters to
|
||||
further tweak the data ingestion process. You can learn more by running the
|
||||
following from the command line:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
catalyst ingest-exchange --help
|
||||
|
||||
Running the algorithm
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can now test your algorithm using cryptoassets' historical pricing data,
|
||||
``catalyst`` provides three interfaces:
|
||||
|
||||
- A command-line interface (CLI),
|
||||
- the ``IPython Notebook`` magic,
|
||||
- and a :func:`~catalyst.run_algorithm` that you can call from other
|
||||
Python scripts.
|
||||
|
||||
We'll start with the CLI, and introduce the ``IPython Notebook`` below. Some of
|
||||
the :doc:`example algorithms <example-algos>` provide instructions on how to run
|
||||
them both from the CLI, and using the :func:`~catalyst.run_algorithm` function.
|
||||
|
||||
Command line interface
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
After you installed Catalyst you should be able to execute the following
|
||||
from your command line (e.g. ``cmd.exe`` on Windows, or the Terminal app
|
||||
on OSX). Displaying here a simplified output for eductional purposes:
|
||||
After you installed Catalyst, you should be able to execute the following
|
||||
from your command line (e.g. ``cmd.exe`` or the ``Anaconda Prompt`` on Windows,
|
||||
or the Terminal application on MacOS).
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ catalyst --help
|
||||
|
||||
This is the resulting output, simplified for eductional purposes:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
Usage: catalyst [OPTIONS] COMMAND [ARGS]...
|
||||
@@ -158,10 +195,11 @@ on OSX). Displaying here a simplified output for eductional purposes:
|
||||
live Trade live with the given algorithm.
|
||||
run Run a backtest for the given algorithm.
|
||||
|
||||
There are three main modes you can run on Catalyst. The first being ``ingest-exchange``
|
||||
for data ingestion, which we have summarized in the previous section. The second
|
||||
is ``live`` to use your algorithm to trade live against a given exchange, and the
|
||||
third mode ``run`` is to backtest your algorithm before trading live with it.
|
||||
There are three main modes you can run on Catalyst. The first being
|
||||
``ingest-exchange`` for data ingestion, which we have covered in the previous
|
||||
section. The second is ``live`` to use your algorithm to trade live against a
|
||||
given exchange, and the third mode ``run`` is to backtest your algorithm before
|
||||
trading live with it.
|
||||
|
||||
Let's start with backtesting, so run this other command to learn more about
|
||||
the available options:
|
||||
@@ -210,22 +248,24 @@ the available options:
|
||||
|
||||
|
||||
As you can see there are a couple of flags that specify where to find your
|
||||
algorithm (``-f``) as well as a parameter to specify which exchange to use.
|
||||
There are also arguments for the date range to run the algorithm over
|
||||
(``--start`` and ``--end``). Finally, you'll want to save the performance
|
||||
metrics of your algorithm so that you can analyze how it performed. This is
|
||||
done via the ``--output`` flag and will cause it to write the performance
|
||||
``DataFrame`` in the pickle Python file format. Note that you can also define
|
||||
a configuration file with these parameters that you can then conveniently pass
|
||||
to the ``-c`` option so that you don't have to supply the command line args
|
||||
all the time (see the .conf files in the examples directory).
|
||||
algorithm (``-f``) as well as a the ``-x`` flag to specify which exchange to
|
||||
use. There are also arguments for the date range to run the algorithm over
|
||||
(``--start`` and ``--end``). You also need to set the base currency for your
|
||||
algorithm through the ``-c`` flag, and the ``--capital_base``. All the
|
||||
aforementioned parameters are required. Optionally, you will want to save the
|
||||
performance metrics of your algorithm so that you can analyze how it performed.
|
||||
This is done via the ``--output`` flag and will cause it to write the
|
||||
performance ``DataFrame`` in the pickle Python file format. Note that you can
|
||||
also define a configuration file with these parameters that you can then
|
||||
conveniently pass to the ``-c`` option so that you don't have to supply the
|
||||
command line args all the time.
|
||||
|
||||
Thus, to execute our algorithm from above and save the results to
|
||||
``buy_btc_simple_out.pickle`` we would call ``catalyst run`` as follows:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
catalyst run -f buy_btc_simple.py -x bitfinex --start 2016-1-1 --end 2017-9-30 -o buy_btc_simple_out.pickle
|
||||
catalyst run -f buy_btc_simple.py -x bitfinex --start 2016-1-1 --end 2017-9-30 -c usd --capital-base 100000 -o buy_btc_simple_out.pickle
|
||||
|
||||
|
||||
.. parsed-literal::
|
||||
@@ -253,17 +293,25 @@ slippage model that ``catalyst`` uses).
|
||||
.. see the `Quantopian docs <https://www.quantopian.com/help#ide-slippage>`__
|
||||
.. for more information).
|
||||
|
||||
Let's take a quick look at the performance ``DataFrame``. For this, we
|
||||
use ``pandas`` from inside the IPython Notebook and print the first ten
|
||||
rows. Note that ``catalyst`` makes heavy usage of
|
||||
`pandas <http://pandas.pydata.org/>`_, especially for data input and
|
||||
outputting so it's worth spending some time to learn it.
|
||||
|
||||
Let's take a quick look at the performance ``DataFrame``. For this, we write
|
||||
different Python script--let's call it ``print_results.py``--and we make use of
|
||||
the fantastic ``pandas`` library to print the first ten rows. Note that
|
||||
``catalyst`` makes heavy usage of `pandas <http://pandas.pydata.org/>`_,
|
||||
especially for data analysis and outputting so it's worth spending some time to
|
||||
learn it.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import pandas as pd
|
||||
perf = pd.read_pickle('buy_btc_simple_out.pickle') # read in perf DataFrame
|
||||
perf.head()
|
||||
print(perf.head())
|
||||
|
||||
Which we execute by running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ python print_results.py
|
||||
|
||||
.. raw:: html
|
||||
|
||||
@@ -429,30 +477,48 @@ and allows us to plot the price of bitcoin. For example, we could easily
|
||||
examine now how our portfolio value changed over time compared to the
|
||||
bitcoin price.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
%load_ext catalyst
|
||||
Now we will run the simulation again, but this time we extend our original
|
||||
algorithm with the addition of the ``analyze()`` function. Somewhat analogously
|
||||
as how ``initialize()`` gets called once before the start of the algorith,
|
||||
``analyze()`` gets called once at the end of the algorithm, and receives two
|
||||
variables: ``context``, which we discussed at the very beginning, and ``perf``,
|
||||
which is the pandas dataframe containing the performance data for our algorithm
|
||||
that we reviewed above. Inside the ``analyze()`` function is where we can
|
||||
analyze and visualize the results of our strategy. Here's the revised simple
|
||||
algorithm (note the addition of Line 1, and Lines 11-18)
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
%pylab inline
|
||||
figsize(12, 12)
|
||||
import matplotlib.pyplot as plt
|
||||
from catalyst.api import order, record, symbol
|
||||
|
||||
ax1 = plt.subplot(211)
|
||||
perf.portfolio_value.plot(ax=ax1)
|
||||
ax1.set_ylabel('portfolio value')
|
||||
ax2 = plt.subplot(212, sharex=ax1)
|
||||
perf.btc.plot(ax=ax2)
|
||||
ax2.set_ylabel('bitcoin price')
|
||||
def initialize(context):
|
||||
context.asset = symbol('btc_usd')
|
||||
|
||||
.. parsed-literal::
|
||||
def handle_data(context, data):
|
||||
order(context.asset, 1)
|
||||
record(btc = data.current(context.asset, 'price'))
|
||||
|
||||
Populating the interactive namespace from numpy and matplotlib
|
||||
def analyze(context, perf):
|
||||
ax1 = plt.subplot(211)
|
||||
perf.portfolio_value.plot(ax=ax1)
|
||||
ax1.set_ylabel('portfolio value')
|
||||
ax2 = plt.subplot(212, sharex=ax1)
|
||||
perf.btc.plot(ax=ax2)
|
||||
ax2.set_ylabel('bitcoin price')
|
||||
plt.show()
|
||||
|
||||
.. parsed-literal::
|
||||
Here we make use of the external visualization library called
|
||||
`matplotlib <https://matplotlib.org/>`_, which you might recall we installed
|
||||
alongside enigma-catalyst (with the exception of the ``Conda`` install, where it
|
||||
was included by default inside the conda environment we created). If for any
|
||||
reason you don't have it installed, you can add it by running:
|
||||
|
||||
<matplotlib.text.Text at 0x10eaeadd0>
|
||||
.. code-block:: python
|
||||
|
||||
(catalyst)$ pip install matplotlib
|
||||
|
||||
If everything works well, you'll see the following chart:
|
||||
|
||||
.. image:: https://s3.amazonaws.com/enigmaco-docs/github.io/buy_btc_simple_graph.png
|
||||
|
||||
@@ -460,6 +526,22 @@ Our algorithm performance as assessed by the ``portfolio_value`` closely
|
||||
matches that of the bitcoin price. This is not surprising as our algorithm
|
||||
only bought bitcoin every chance it got.
|
||||
|
||||
If you get an error when invoking matplotlib to visualize the performance
|
||||
results refer to `MacOS + Matplotlib <install.html#macos-virtualenv-matplotlib>`_.
|
||||
Alternatively, some users have reported the following error when running an algo
|
||||
in a Linux environment:
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
ImportError: No module named _tkinter, please install the python-tk package
|
||||
|
||||
Which can easily solved by running (in Ubuntu/Debian-based systems):
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
sudo apt install python-tk
|
||||
|
||||
|
||||
|
||||
Access to previous prices using ``history``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -80,7 +80,7 @@ Once either Conda or MiniConda has been set up you can install Catalyst:
|
||||
4. Activate the environment (which you need to do every time you start a new
|
||||
session to run Catalyst):
|
||||
|
||||
**Linux or OSX:**
|
||||
**Linux or MacOS:**
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
@@ -125,7 +125,7 @@ with the following steps:
|
||||
|
||||
3. Activate the environment:
|
||||
|
||||
**Linux or OSX:**
|
||||
**Linux or MacOS:**
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
@@ -358,11 +358,11 @@ beginning of this page.
|
||||
MacOS Requirements
|
||||
------------------
|
||||
|
||||
The version of Python shipped with OSX by default is generally out of date,
|
||||
The version of Python shipped with MacOS by default is generally out of date,
|
||||
and has a number of quirks because it's used directly by the operating system.
|
||||
For these reasons, many developers choose to install and use a separate Python
|
||||
installation. The `Hitchhiker's Guide to Python`_ provides an excellent guide
|
||||
to `Installing Python on OSX <http://docs.python-guide.org/en/latest/>`_,
|
||||
to `Installing Python on MacOS <http://docs.python-guide.org/en/latest/>`_,
|
||||
which explains how to install Python with the `Homebrew`_ manager.
|
||||
|
||||
Assuming you've installed Python with Homebrew, you'll also likely need the
|
||||
@@ -372,17 +372,17 @@ following brew packages:
|
||||
|
||||
$ brew install freetype pkg-config gcc openssl
|
||||
|
||||
OSX + virtualenv + matplotlib
|
||||
MacOS + virtualenv + matplotlib
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A note about using matplotlib in virtual enviroments on OSX: it may be
|
||||
A note about using matplotlib in virtual enviroments on MacOS: it may be
|
||||
necessary to run
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc
|
||||
|
||||
in order to override the default ``macosx`` backend for your system, which
|
||||
in order to override the default ``MacOS`` backend for your system, which
|
||||
may not be accessible from inside the virtual environment. This will allow
|
||||
Catalyst to open matplotlib charts from within a virtual environment, which
|
||||
is useful for displaying the performance of your backtests. To learn more
|
||||
|
||||
+2
-2
@@ -84,7 +84,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#macos-requirements">MacOS Requirements</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#osx-virtualenv-matplotlib">OSX + virtualenv + matplotlib</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#macos-virtualenv-matplotlib">MacOS + virtualenv + matplotlib</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#windows-requirements">Windows Requirements</a></li>
|
||||
@@ -94,8 +94,8 @@
|
||||
<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#ingesting-data">Ingesting data</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>
|
||||
|
||||
+154
-86
@@ -86,7 +86,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#macos-requirements">MacOS Requirements</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#osx-virtualenv-matplotlib">OSX + virtualenv + matplotlib</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#macos-virtualenv-matplotlib">MacOS + virtualenv + matplotlib</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#windows-requirements">Windows Requirements</a></li>
|
||||
@@ -96,8 +96,8 @@
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="">Catalyst Beginner Tutorial</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#basics">Basics</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#my-first-algorithm">My first algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#ingesting-data">Ingesting data</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#running-the-algorithm">Running the algorithm</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#ingesting-data">Ingesting data</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#command-line-interface">Command line interface</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
@@ -241,8 +241,8 @@
|
||||
<div class="section" id="basics">
|
||||
<h2>Basics<a class="headerlink" href="#basics" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Catalyst is an open-source algorithmic trading simulator for crypto
|
||||
assets written in Python.</p>
|
||||
<p>The source can be found at: <a class="reference external" href="https://github.com/enigmampc/catalyst">https://github.com/enigmampc/catalyst</a></p>
|
||||
assets written in Python. The source code can be found at:
|
||||
<a class="reference external" href="https://github.com/enigmampc/catalyst">https://github.com/enigmampc/catalyst</a></p>
|
||||
<p>Some benefits include:</p>
|
||||
<ul class="simple">
|
||||
<li>Support for several of the top crypto-exchanges by trading volume.</li>
|
||||
@@ -259,8 +259,7 @@ marketplace, Catalyst empowers users to share and curate data and
|
||||
build profitable, data-driven investment strategies.</li>
|
||||
</ul>
|
||||
<p>This tutorial assumes that you have Catalyst correctly installed, see the
|
||||
<a class="reference internal" href="install.html"><em>installation instructions</em></a> if you haven’t set up
|
||||
Catalyst yet.</p>
|
||||
<a class="reference internal" href="install.html"><em>Install</em></a> section if you haven’t set up Catalyst yet.</p>
|
||||
<p>Every <code class="docutils literal"><span class="pre">catalyst</span></code> algorithm consists of at least two functions you have to
|
||||
define:</p>
|
||||
<ul class="simple">
|
||||
@@ -272,15 +271,17 @@ define:</p>
|
||||
<code class="docutils literal"><span class="pre">context</span></code> is a persistent namespace for you to store variables you
|
||||
need to access from one algorithm iteration to the next.</p>
|
||||
<p>After the algorithm has been initialized, <code class="docutils literal"><span class="pre">catalyst</span></code> calls the
|
||||
<code class="docutils literal"><span class="pre">handle_data()</span></code> function once for each event. At every call, it passes
|
||||
the same <code class="docutils literal"><span class="pre">context</span></code> variable and an event-frame called <code class="docutils literal"><span class="pre">data</span></code>
|
||||
containing the current trading bar with open, high, low, and close
|
||||
(OHLC) prices as well as volume for each crypto asset in your universe.</p>
|
||||
<code class="docutils literal"><span class="pre">handle_data()</span></code> function on each iteration, that’s one per day (daily) or
|
||||
once every minute (minute), depending on the frequency we choose to run our
|
||||
simulation. On every iteration, <code class="docutils literal"><span class="pre">handle_data()</span></code> passes the same <code class="docutils literal"><span class="pre">context</span></code>
|
||||
variable and an event-frame called <code class="docutils literal"><span class="pre">data</span></code> containing the current trading bar
|
||||
with open, high, low, and close (OHLC) prices as well as volume for each
|
||||
crypto asset in your universe.</p>
|
||||
</div>
|
||||
<div class="section" id="my-first-algorithm">
|
||||
<h2>My first algorithm<a class="headerlink" href="#my-first-algorithm" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Lets take a look at a very simple algorithm from the <code class="docutils literal"><span class="pre">examples</span></code>
|
||||
directory: <a class="reference external" href="https://github.com/enigmampc/catalyst/blob/master/catalyst/examples/buy_btc_simple.py">buy_btc_simple.py</a>:</p>
|
||||
<p>Lets take a look at a very simple algorithm from the <code class="docutils literal"><span class="pre">examples</span></code> directory:
|
||||
<a class="reference external" href="https://github.com/enigmampc/catalyst/blob/master/catalyst/examples/buy_btc_simple.py">buy_btc_simple.py</a>:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">catalyst.api</span> <span class="kn">import</span> <span class="n">order</span><span class="p">,</span> <span class="n">record</span><span class="p">,</span> <span class="n">symbol</span>
|
||||
|
||||
|
||||
@@ -295,9 +296,9 @@ directory: <a class="reference external" href="https://github.com/enigmampc/cata
|
||||
</div>
|
||||
<p>As you can see, we first have to import some functions we would like to
|
||||
use. All functions commonly used in your algorithm can be found in
|
||||
<code class="docutils literal"><span class="pre">catalyst.api</span></code>. Here we are using <code class="xref py py-func docutils literal"><span class="pre">order()</span></code> which takes two
|
||||
arguments: a cryptoasset object, and a number specifying how many assets you would
|
||||
like to order (if negative, <code class="xref py py-func docutils literal"><span class="pre">order()</span></code> will sell/short
|
||||
<code class="docutils literal"><span class="pre">catalyst.api</span></code>. Here we are using <code class="xref py py-func docutils literal"><span class="pre">order()</span></code> which takes
|
||||
twoarguments: a cryptoasset object, and a number specifying how many assets you
|
||||
wouldlike to order (if negative, <code class="xref py py-func docutils literal"><span class="pre">order()</span></code> will sell/short
|
||||
assets). In this case we want to order 1 bitcoin at each iteration.</p>
|
||||
<p>Finally, the <code class="xref py py-func docutils literal"><span class="pre">record()</span></code> function allows you to save the value
|
||||
of a variable at each iteration. You provide it with a name for the variable
|
||||
@@ -307,51 +308,80 @@ with <code class="xref py py-func docutils literal"><span class="pre">record()</
|
||||
further below). You also see how we can access the current price data of
|
||||
a bitcoin in the <code class="docutils literal"><span class="pre">data</span></code> event frame.</p>
|
||||
</div>
|
||||
<div class="section" id="running-the-algorithm">
|
||||
<h2>Running the algorithm<a class="headerlink" href="#running-the-algorithm" title="Permalink to this headline">¶</a></h2>
|
||||
<p>To can now test this algorithm on crypto data, <code class="docutils literal"><span class="pre">catalyst</span></code> provides three
|
||||
interfaces:</p>
|
||||
<ul class="simple">
|
||||
<li>A command-line interface,</li>
|
||||
<li><code class="docutils literal"><span class="pre">IPython</span> <span class="pre">Notebook</span></code> magic,</li>
|
||||
<li>and <code class="xref py py-func docutils literal"><span class="pre">run_algorithm()</span></code>.</li>
|
||||
</ul>
|
||||
<div class="section" id="ingesting-data">
|
||||
<h3>Ingesting data<a class="headerlink" href="#ingesting-data" title="Permalink to this headline">¶</a></h3>
|
||||
<p>In previous versions of Catalyst you needed to manually ingest data before running
|
||||
your algorithm to make it available at runtime. Starting with version 0.3, the
|
||||
algorithm will automagically ingest the data it needs the first time that encounters
|
||||
a data request for data that it doesn’t have.</p>
|
||||
<p>Still, we believe it is important for you to have a high-level understanding
|
||||
of how data is managed:</p>
|
||||
<h2>Ingesting data<a class="headerlink" href="#ingesting-data" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Before you can backtest your algorithm, you first need to load the historical
|
||||
pricing data that Catalyst needs to run your simulation through a process called
|
||||
<code class="docutils literal"><span class="pre">ingestion</span></code>. When you ingest data, Catalyst downloads that data in compressed
|
||||
form from the Enigma servers (which eventually will migrate to the Enigma Data
|
||||
Marketplace), and stores it locally to make it available at runtime.</p>
|
||||
<p>In order to ingest data, you need to run a command like the following:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre>catalyst ingest-exchange -x bitfinex -i btc_usd
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>This instructs Catalyst to download pricing data from the <code class="docutils literal"><span class="pre">Bitfinex</span></code> exchange
|
||||
for the <code class="docutils literal"><span class="pre">btc_usd</span></code> currency pair (this follows from the simple algorithm
|
||||
presented above where we want to trade <code class="docutils literal"><span class="pre">btc_usd</span></code>), and we’re choosing to test
|
||||
our algorithm using historical pricing data from the Bitfinex exchange. By
|
||||
default, Catalyst assumes that you want data with <code class="docutils literal"><span class="pre">daily</span></code> frequency (one candle
|
||||
bar per day). If you want instead <code class="docutils literal"><span class="pre">minute</span></code> frequency (one candle bar for every
|
||||
minute), you would need to specify it as follows:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre>catalyst ingest-exchange -x bitfinex -i btc_usd -f minute
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="highlight-python"><div class="highlight"><pre>Ingesting exchange bundle bitfinex...
|
||||
[====================================] Ingesting daily price data on bitfinex: 100%
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>We believe it is important for you to have a high-level understanding of how
|
||||
data is managed, hence the following overview:</p>
|
||||
<ul class="simple">
|
||||
<li>Pricing data is split and packaged into <code class="docutils literal"><span class="pre">bundles</span></code>: chunks of data organized
|
||||
as time series that are kept up to date daily on Enigma’s servers. Catalyst
|
||||
downloads the bundles that needs at any given time, and reconstructs the whole
|
||||
dataset in your hard drive.</li>
|
||||
<li>Pricing data is provided in <code class="docutils literal"><span class="pre">daily</span></code> and <code class="docutils literal"><span class="pre">minute</span></code> resolution. Those are different
|
||||
bundle datasets, and are managed separately.</li>
|
||||
<li>Bundles are exchange-specific, as the pricing data is specific to the trades that
|
||||
happen in each exchange. You can optionally specify which exchange you want pricing
|
||||
data from.</li>
|
||||
<li>Catalyst keeps track of all the downloaded bundles, so that it only has to download
|
||||
them once, and will do incremental updates as needed.</li>
|
||||
<li>When running in <code class="docutils literal"><span class="pre">live</span> <span class="pre">trading</span></code> mode, Catalyst will first look for historical
|
||||
pricing data in the locally stored bundles. If there is anything missing, Catalyst will
|
||||
hit the exchange for the most recent data, and merge it with the local bundle to make
|
||||
it available for future iterations.</li>
|
||||
downloads the requested bundles and reconstructs the full dataset in your
|
||||
hard drive.</li>
|
||||
<li>Pricing data is provided in <code class="docutils literal"><span class="pre">daily</span></code> and <code class="docutils literal"><span class="pre">minute</span></code> resolution. Those are
|
||||
different bundle datasets, and are managed separately.</li>
|
||||
<li>Bundles are exchange-specific, as the pricing data is specific to the trades
|
||||
that happen in each exchange. As a result, you can must specify which
|
||||
exchange you want pricing data from when ingesting data</li>
|
||||
<li>Catalyst keeps track of all the downloaded bundles, so that it only has to
|
||||
download them once, and will do incremental updates as needed.</li>
|
||||
<li>When running in <code class="docutils literal"><span class="pre">live</span> <span class="pre">trading</span></code> mode, Catalyst will first look for
|
||||
historical pricing data in the locally stored bundles. If there is anything
|
||||
missing, Catalyst will hit the exchange for the most recent data, and merge
|
||||
it with the local bundle to optimize the number of requests it needs to make
|
||||
to the exchange.</li>
|
||||
</ul>
|
||||
<p>If you want to learn more, check out the <a class="reference internal" href="bundles.html#ingesting-data"><span>ingesting data</span></a> section
|
||||
for more detail.</p>
|
||||
<p>The <code class="docutils literal"><span class="pre">ingest-exchange</span></code> command in catalyst offers additional parameters to
|
||||
further tweak the data ingestion process. You can learn more by running the
|
||||
following from the command line:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre>catalyst ingest-exchange --help
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="running-the-algorithm">
|
||||
<h2>Running the algorithm<a class="headerlink" href="#running-the-algorithm" title="Permalink to this headline">¶</a></h2>
|
||||
<p>You can now test your algorithm using cryptoassets’ historical pricing data,
|
||||
<code class="docutils literal"><span class="pre">catalyst</span></code> provides three interfaces:</p>
|
||||
<ul class="simple">
|
||||
<li>A command-line interface (CLI),</li>
|
||||
<li>the <code class="docutils literal"><span class="pre">IPython</span> <span class="pre">Notebook</span></code> magic,</li>
|
||||
<li>and a <code class="xref py py-func docutils literal"><span class="pre">run_algorithm()</span></code> that you can call from other
|
||||
Python scripts.</li>
|
||||
</ul>
|
||||
<p>We’ll start with the CLI, and introduce the <code class="docutils literal"><span class="pre">IPython</span> <span class="pre">Notebook</span></code> below. Some of
|
||||
the <a class="reference internal" href="example-algos.html"><em>example algorithms</em></a> provide instructions on how to run
|
||||
them both from the CLI, and using the <code class="xref py py-func docutils literal"><span class="pre">run_algorithm()</span></code> function.</p>
|
||||
<div class="section" id="command-line-interface">
|
||||
<h3>Command line interface<a class="headerlink" href="#command-line-interface" title="Permalink to this headline">¶</a></h3>
|
||||
<p>After you installed Catalyst you should be able to execute the following
|
||||
from your command line (e.g. <code class="docutils literal"><span class="pre">cmd.exe</span></code> on Windows, or the Terminal app
|
||||
on OSX). Displaying here a simplified output for eductional purposes:</p>
|
||||
<p>After you installed Catalyst, you should be able to execute the following
|
||||
from your command line (e.g. <code class="docutils literal"><span class="pre">cmd.exe</span></code> or the <code class="docutils literal"><span class="pre">Anaconda</span> <span class="pre">Prompt</span></code> on Windows,
|
||||
or the Terminal application on MacOS).</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>catalyst --help
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>This is the resulting output, simplified for eductional purposes:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre>Usage: catalyst [OPTIONS] COMMAND [ARGS]...
|
||||
|
||||
Top level catalyst entry point.
|
||||
@@ -366,10 +396,11 @@ Commands:
|
||||
run Run a backtest for the given algorithm.
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>There are three main modes you can run on Catalyst. The first being <code class="docutils literal"><span class="pre">ingest-exchange</span></code>
|
||||
for data ingestion, which we have summarized in the previous section. The second
|
||||
is <code class="docutils literal"><span class="pre">live</span></code> to use your algorithm to trade live against a given exchange, and the
|
||||
third mode <code class="docutils literal"><span class="pre">run</span></code> is to backtest your algorithm before trading live with it.</p>
|
||||
<p>There are three main modes you can run on Catalyst. The first being
|
||||
<code class="docutils literal"><span class="pre">ingest-exchange</span></code> for data ingestion, which we have covered in the previous
|
||||
section. The second is <code class="docutils literal"><span class="pre">live</span></code> to use your algorithm to trade live against a
|
||||
given exchange, and the third mode <code class="docutils literal"><span class="pre">run</span></code> is to backtest your algorithm before
|
||||
trading live with it.</p>
|
||||
<p>Let’s start with backtesting, so run this other command to learn more about
|
||||
the available options:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>catalyst run --help
|
||||
@@ -413,18 +444,20 @@ Options:
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>As you can see there are a couple of flags that specify where to find your
|
||||
algorithm (<code class="docutils literal"><span class="pre">-f</span></code>) as well as a parameter to specify which exchange to use.
|
||||
There are also arguments for the date range to run the algorithm over
|
||||
(<code class="docutils literal"><span class="pre">--start</span></code> and <code class="docutils literal"><span class="pre">--end</span></code>). Finally, you’ll want to save the performance
|
||||
metrics of your algorithm so that you can analyze how it performed. This is
|
||||
done via the <code class="docutils literal"><span class="pre">--output</span></code> flag and will cause it to write the performance
|
||||
<code class="docutils literal"><span class="pre">DataFrame</span></code> in the pickle Python file format. Note that you can also define
|
||||
a configuration file with these parameters that you can then conveniently pass
|
||||
to the <code class="docutils literal"><span class="pre">-c</span></code> option so that you don’t have to supply the command line args
|
||||
all the time (see the .conf files in the examples directory).</p>
|
||||
algorithm (<code class="docutils literal"><span class="pre">-f</span></code>) as well as a the <code class="docutils literal"><span class="pre">-x</span></code> flag to specify which exchange to
|
||||
use. There are also arguments for the date range to run the algorithm over
|
||||
(<code class="docutils literal"><span class="pre">--start</span></code> and <code class="docutils literal"><span class="pre">--end</span></code>). You also need to set the base currency for your
|
||||
algorithm through the <code class="docutils literal"><span class="pre">-c</span></code> flag, and the <code class="docutils literal"><span class="pre">--capital_base</span></code>. All the
|
||||
aforementioned parameters are required. Optionally, you will want to save the
|
||||
performance metrics of your algorithm so that you can analyze how it performed.
|
||||
This is done via the <code class="docutils literal"><span class="pre">--output</span></code> flag and will cause it to write the
|
||||
performance <code class="docutils literal"><span class="pre">DataFrame</span></code> in the pickle Python file format. Note that you can
|
||||
also define a configuration file with these parameters that you can then
|
||||
conveniently pass to the <code class="docutils literal"><span class="pre">-c</span></code> option so that you don’t have to supply the
|
||||
command line args all the time.</p>
|
||||
<p>Thus, to execute our algorithm from above and save the results to
|
||||
<code class="docutils literal"><span class="pre">buy_btc_simple_out.pickle</span></code> we would call <code class="docutils literal"><span class="pre">catalyst</span> <span class="pre">run</span></code> as follows:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="n">catalyst</span> <span class="n">run</span> <span class="o">-</span><span class="n">f</span> <span class="n">buy_btc_simple</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">x</span> <span class="n">bitfinex</span> <span class="o">--</span><span class="n">start</span> <span class="mi">2016</span><span class="o">-</span><span class="mi">1</span><span class="o">-</span><span class="mi">1</span> <span class="o">--</span><span class="n">end</span> <span class="mi">2017</span><span class="o">-</span><span class="mi">9</span><span class="o">-</span><span class="mi">30</span> <span class="o">-</span><span class="n">o</span> <span class="n">buy_btc_simple_out</span><span class="o">.</span><span class="n">pickle</span>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="n">catalyst</span> <span class="n">run</span> <span class="o">-</span><span class="n">f</span> <span class="n">buy_btc_simple</span><span class="o">.</span><span class="n">py</span> <span class="o">-</span><span class="n">x</span> <span class="n">bitfinex</span> <span class="o">--</span><span class="n">start</span> <span class="mi">2016</span><span class="o">-</span><span class="mi">1</span><span class="o">-</span><span class="mi">1</span> <span class="o">--</span><span class="n">end</span> <span class="mi">2017</span><span class="o">-</span><span class="mi">9</span><span class="o">-</span><span class="mi">30</span> <span class="o">-</span><span class="n">c</span> <span class="n">usd</span> <span class="o">--</span><span class="n">capital</span><span class="o">-</span><span class="n">base</span> <span class="mi">100000</span> <span class="o">-</span><span class="n">o</span> <span class="n">buy_btc_simple_out</span><span class="o">.</span><span class="n">pickle</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="highlight-python"><div class="highlight"><pre>INFO: run_algo: running algo in backtest mode
|
||||
@@ -446,14 +479,19 @@ applying the slippage model which models the influence of your order on
|
||||
the stock price, so your algorithm will be charged more than just the
|
||||
asset price. (Note, that you can also change the commission and
|
||||
slippage model that <code class="docutils literal"><span class="pre">catalyst</span></code> uses).</p>
|
||||
<p>Let’s take a quick look at the performance <code class="docutils literal"><span class="pre">DataFrame</span></code>. For this, we
|
||||
use <code class="docutils literal"><span class="pre">pandas</span></code> from inside the IPython Notebook and print the first ten
|
||||
rows. Note that <code class="docutils literal"><span class="pre">catalyst</span></code> makes heavy usage of
|
||||
<a class="reference external" href="http://pandas.pydata.org/">pandas</a>, especially for data input and
|
||||
outputting so it’s worth spending some time to learn it.</p>
|
||||
<p>Let’s take a quick look at the performance <code class="docutils literal"><span class="pre">DataFrame</span></code>. For this, we write
|
||||
different Python script–let’s call it <code class="docutils literal"><span class="pre">print_results.py</span></code>–and we make use of
|
||||
the fantastic <code class="docutils literal"><span class="pre">pandas</span></code> library to print the first ten rows. Note that
|
||||
<code class="docutils literal"><span class="pre">catalyst</span></code> makes heavy usage of <a class="reference external" href="http://pandas.pydata.org/">pandas</a>,
|
||||
especially for data analysis and outputting so it’s worth spending some time to
|
||||
learn it.</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">pandas</span> <span class="kn">as</span> <span class="nn">pd</span>
|
||||
<span class="n">perf</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_pickle</span><span class="p">(</span><span class="s">'buy_btc_simple_out.pickle'</span><span class="p">)</span> <span class="c"># read in perf DataFrame</span>
|
||||
<span class="n">perf</span><span class="o">.</span><span class="n">head</span><span class="p">()</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="n">perf</span><span class="o">.</span><span class="n">head</span><span class="p">())</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Which we execute by running:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>python print_results.py
|
||||
</pre></div>
|
||||
</div>
|
||||
<div style="max-height:1000px;max-width:1500px;overflow:auto;">
|
||||
@@ -617,31 +655,61 @@ information about the state of your algorithm. The column
|
||||
and allows us to plot the price of bitcoin. For example, we could easily
|
||||
examine now how our portfolio value changed over time compared to the
|
||||
bitcoin price.</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="o">%</span><span class="n">load_ext</span> <span class="n">catalyst</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="o">%</span><span class="n">pylab</span> <span class="n">inline</span>
|
||||
<span class="n">figsize</span><span class="p">(</span><span class="mi">12</span><span class="p">,</span> <span class="mi">12</span><span class="p">)</span>
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">as</span> <span class="nn">plt</span>
|
||||
<p>Now we will run the simulation again, but this time we extend our original
|
||||
algorithm with the addition of the <code class="docutils literal"><span class="pre">analyze()</span></code> function. Somewhat analogously
|
||||
as how <code class="docutils literal"><span class="pre">initialize()</span></code> gets called once before the start of the algorith,
|
||||
<code class="docutils literal"><span class="pre">analyze()</span></code> gets called once at the end of the algorithm, and receives two
|
||||
variables: <code class="docutils literal"><span class="pre">context</span></code>, which we discussed at the very beginning, and <code class="docutils literal"><span class="pre">perf</span></code>,
|
||||
which is the pandas dataframe containing the performance data for our algorithm
|
||||
that we reviewed above. Inside the <code class="docutils literal"><span class="pre">analyze()</span></code> function is where we can
|
||||
analyze and visualize the results of our strategy. Here’s the revised simple
|
||||
algorithm (note the addition of Line 1, and Lines 11-18)</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="kn">as</span> <span class="nn">plt</span>
|
||||
<span class="kn">from</span> <span class="nn">catalyst.api</span> <span class="kn">import</span> <span class="n">order</span><span class="p">,</span> <span class="n">record</span><span class="p">,</span> <span class="n">symbol</span>
|
||||
|
||||
<span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">211</span><span class="p">)</span>
|
||||
<span class="n">perf</span><span class="o">.</span><span class="n">portfolio_value</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">ax</span><span class="o">=</span><span class="n">ax1</span><span class="p">)</span>
|
||||
<span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s">'portfolio value'</span><span class="p">)</span>
|
||||
<span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">212</span><span class="p">,</span> <span class="n">sharex</span><span class="o">=</span><span class="n">ax1</span><span class="p">)</span>
|
||||
<span class="n">perf</span><span class="o">.</span><span class="n">btc</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">ax</span><span class="o">=</span><span class="n">ax2</span><span class="p">)</span>
|
||||
<span class="n">ax2</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s">'bitcoin price'</span><span class="p">)</span>
|
||||
<span class="k">def</span> <span class="nf">initialize</span><span class="p">(</span><span class="n">context</span><span class="p">):</span>
|
||||
<span class="n">context</span><span class="o">.</span><span class="n">asset</span> <span class="o">=</span> <span class="n">symbol</span><span class="p">(</span><span class="s">'btc_usd'</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">handle_data</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">order</span><span class="p">(</span><span class="n">context</span><span class="o">.</span><span class="n">asset</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">record</span><span class="p">(</span><span class="n">btc</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">current</span><span class="p">(</span><span class="n">context</span><span class="o">.</span><span class="n">asset</span><span class="p">,</span> <span class="s">'price'</span><span class="p">))</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">analyze</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">perf</span><span class="p">):</span>
|
||||
<span class="n">ax1</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">211</span><span class="p">)</span>
|
||||
<span class="n">perf</span><span class="o">.</span><span class="n">portfolio_value</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">ax</span><span class="o">=</span><span class="n">ax1</span><span class="p">)</span>
|
||||
<span class="n">ax1</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s">'portfolio value'</span><span class="p">)</span>
|
||||
<span class="n">ax2</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">subplot</span><span class="p">(</span><span class="mi">212</span><span class="p">,</span> <span class="n">sharex</span><span class="o">=</span><span class="n">ax1</span><span class="p">)</span>
|
||||
<span class="n">perf</span><span class="o">.</span><span class="n">btc</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">ax</span><span class="o">=</span><span class="n">ax2</span><span class="p">)</span>
|
||||
<span class="n">ax2</span><span class="o">.</span><span class="n">set_ylabel</span><span class="p">(</span><span class="s">'bitcoin price'</span><span class="p">)</span>
|
||||
<span class="n">plt</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="highlight-python"><div class="highlight"><pre>Populating the interactive namespace from numpy and matplotlib
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="highlight-python"><div class="highlight"><pre><matplotlib.text.Text at 0x10eaeadd0>
|
||||
<p>Here we make use of the external visualization library called
|
||||
<a class="reference external" href="https://matplotlib.org/">matplotlib</a>, which you might recall we installed
|
||||
alongside enigma-catalyst (with the exception of the <code class="docutils literal"><span class="pre">Conda</span></code> install, where it
|
||||
was included by default inside the conda environment we created). If for any
|
||||
reason you don’t have it installed, you can add it by running:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre>(catalyst)$ pip install matplotlib
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>If everything works well, you’ll see the following chart:</p>
|
||||
<img alt="https://s3.amazonaws.com/enigmaco-docs/github.io/buy_btc_simple_graph.png" src="https://s3.amazonaws.com/enigmaco-docs/github.io/buy_btc_simple_graph.png" />
|
||||
<p>Our algorithm performance as assessed by the <code class="docutils literal"><span class="pre">portfolio_value</span></code> closely
|
||||
matches that of the bitcoin price. This is not surprising as our algorithm
|
||||
only bought bitcoin every chance it got.</p>
|
||||
<blockquote>
|
||||
<div><p>If you get an error when invoking matplotlib to visualize the performance
|
||||
results refer to <a class="reference external" href="install.html#macos-virtualenv-matplotlib">MacOS + Matplotlib</a>.
|
||||
Alternatively, some users have reported the following error when running an algo
|
||||
in a Linux environment:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre>ImportError: No module named _tkinter, please install the python-tk package
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Which can easily solved by running (in Ubuntu/Debian-based systems):</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="n">sudo</span> <span class="n">apt</span> <span class="n">install</span> <span class="n">python</span><span class="o">-</span><span class="n">tk</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</div></blockquote>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="access-to-previous-prices-using-history">
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#macos-requirements">MacOS Requirements</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#osx-virtualenv-matplotlib">OSX + virtualenv + matplotlib</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#macos-virtualenv-matplotlib">MacOS + virtualenv + matplotlib</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#windows-requirements">Windows Requirements</a></li>
|
||||
@@ -95,8 +95,8 @@
|
||||
<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#ingesting-data">Ingesting data</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>
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#macos-requirements">MacOS Requirements</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#osx-virtualenv-matplotlib">OSX + virtualenv + matplotlib</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#macos-virtualenv-matplotlib">MacOS + virtualenv + matplotlib</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#windows-requirements">Windows Requirements</a></li>
|
||||
@@ -95,8 +95,8 @@
|
||||
<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#ingesting-data">Ingesting data</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>
|
||||
|
||||
+11
-11
@@ -86,7 +86,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#macos-requirements">MacOS Requirements</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#osx-virtualenv-matplotlib">OSX + virtualenv + matplotlib</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#macos-virtualenv-matplotlib">MacOS + virtualenv + matplotlib</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#windows-requirements">Windows Requirements</a></li>
|
||||
@@ -96,8 +96,8 @@
|
||||
<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#ingesting-data">Ingesting data</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>
|
||||
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
@@ -304,7 +304,7 @@ saved the above <code class="docutils literal"><span class="pre">python2.7-envir
|
||||
</li>
|
||||
<li><p class="first">Activate the environment (which you need to do every time you start a new
|
||||
session to run Catalyst):</p>
|
||||
<p><strong>Linux or OSX:</strong></p>
|
||||
<p><strong>Linux or MacOS:</strong></p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nb">source </span>activate catalyst
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -340,7 +340,7 @@ step #2:</p>
|
||||
</div>
|
||||
</li>
|
||||
<li><p class="first">Activate the environment:</p>
|
||||
<p><strong>Linux or OSX:</strong></p>
|
||||
<p><strong>Linux or MacOS:</strong></p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nb">source </span>activate catalyst
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -519,25 +519,25 @@ beginning of this page.</p>
|
||||
</div>
|
||||
<div class="section" id="macos-requirements">
|
||||
<span id="macos"></span><h2>MacOS Requirements<a class="headerlink" href="#macos-requirements" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The version of Python shipped with OSX by default is generally out of date,
|
||||
<p>The version of Python shipped with MacOS by default is generally out of date,
|
||||
and has a number of quirks because it’s used directly by the operating system.
|
||||
For these reasons, many developers choose to install and use a separate Python
|
||||
installation. The <a class="reference external" href="http://docs.python-guide.org/en/latest/">Hitchhiker’s Guide to Python</a> provides an excellent guide
|
||||
to <a class="reference external" href="http://docs.python-guide.org/en/latest/">Installing Python on OSX</a>,
|
||||
to <a class="reference external" href="http://docs.python-guide.org/en/latest/">Installing Python on MacOS</a>,
|
||||
which explains how to install Python with the <a class="reference external" href="http://brew.sh">Homebrew</a> manager.</p>
|
||||
<p>Assuming you’ve installed Python with Homebrew, you’ll also likely need the
|
||||
following brew packages:</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>brew install freetype pkg-config gcc openssl
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="section" id="osx-virtualenv-matplotlib">
|
||||
<h3>OSX + virtualenv + matplotlib<a class="headerlink" href="#osx-virtualenv-matplotlib" title="Permalink to this headline">¶</a></h3>
|
||||
<p>A note about using matplotlib in virtual enviroments on OSX: it may be
|
||||
<div class="section" id="macos-virtualenv-matplotlib">
|
||||
<h3>MacOS + virtualenv + matplotlib<a class="headerlink" href="#macos-virtualenv-matplotlib" title="Permalink to this headline">¶</a></h3>
|
||||
<p>A note about using matplotlib in virtual enviroments on MacOS: it may be
|
||||
necessary to run</p>
|
||||
<div class="highlight-bash"><div class="highlight"><pre><span class="nb">echo</span> <span class="s2">"backend: TkAgg"</span> > ~/.matplotlib/matplotlibrc
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>in order to override the default <code class="docutils literal"><span class="pre">macosx</span></code> backend for your system, which
|
||||
<p>in order to override the default <code class="docutils literal"><span class="pre">MacOS</span></code> backend for your system, which
|
||||
may not be accessible from inside the virtual environment. This will allow
|
||||
Catalyst to open matplotlib charts from within a virtual environment, which
|
||||
is useful for displaying the performance of your backtests. To learn more
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1 current"><a class="current reference internal" href="">Resources</a><ul>
|
||||
|
||||
+2
-2
@@ -84,7 +84,7 @@
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#macos-requirements">MacOS Requirements</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#osx-virtualenv-matplotlib">OSX + virtualenv + matplotlib</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="install.html#macos-virtualenv-matplotlib">MacOS + virtualenv + matplotlib</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="install.html#windows-requirements">Windows Requirements</a></li>
|
||||
@@ -94,8 +94,8 @@
|
||||
<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#ingesting-data">Ingesting data</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>
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -134,7 +134,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="videos.html">Videos</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-macos">Installation: MacOS</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#installation-windows">Installation: Windows</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-an-algorithm">Backtesting an algorithm</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="videos.html#backtesting-a-strategy">Backtesting a Strategy</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="resources.html">Resources</a><ul>
|
||||
|
||||
Reference in New Issue
Block a user