mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-07 11:20:19 +08:00
Merge branch 'master' into develop
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
from catalyst.api import order, record, symbol
|
||||
|
||||
|
||||
def initialize(context):
|
||||
context.asset = symbol('btc_usd')
|
||||
|
||||
|
||||
def handle_data(context, data):
|
||||
order(context.asset, 1)
|
||||
record(btc=data.current(context.asset, 'price'))
|
||||
@@ -1,3 +1,24 @@
|
||||
'''
|
||||
This is a very simple example referenced in the beginner's tutorial:
|
||||
https://enigmampc.github.io/catalyst/beginner-tutorial.html
|
||||
|
||||
Run this example, by executing the following from your terminal:
|
||||
catalyst run -f buy_btc_simple.py -x bitfinex --start 2016-1-1 --end 2017-9-30 -o buy_btc_simple_out.pickle
|
||||
|
||||
If you want to run this code using another exchange, make sure that
|
||||
the asset is available on that exchange. For example, if you were to run
|
||||
it for exchange Poloniex, you would need to edit the following line:
|
||||
|
||||
context.asset = symbol('btc_usdt') # note 'usdt' instead of 'usd'
|
||||
|
||||
and specify exchange poloniex as follows:
|
||||
|
||||
catalyst run -f buy_btc_simple.py -x poloniex --start 2016-1-1 --end 2017-9-30 -o buy_btc_simple_out.pickle
|
||||
|
||||
To see which assets are available on each exchange, visit:
|
||||
https://www.enigma.co/catalyst/status
|
||||
'''
|
||||
|
||||
from catalyst.api import order, record, symbol
|
||||
|
||||
def initialize(context):
|
||||
|
||||
@@ -429,6 +429,10 @@ 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
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
%pylab inline
|
||||
@@ -484,7 +488,8 @@ a function we use in the ``handle_data()`` section:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
%%catalyst --start 2016-1-1 --end 2017-9-30 -x bitfinex -o dma.pickle
|
||||
%%catalyst --start 2016-4-1 --end 2017-9-30 -x bitfinex
|
||||
|
||||
from catalyst.api import order, record, symbol, order_target
|
||||
|
||||
def initialize(context):
|
||||
@@ -492,16 +497,16 @@ a function we use in the ``handle_data()`` section:
|
||||
context.asset = symbol('btc_usd')
|
||||
|
||||
def handle_data(context, data):
|
||||
# Skip first 300 days to get full windows
|
||||
# Skip first 150 days to get full windows
|
||||
context.i += 1
|
||||
if context.i < 300:
|
||||
if context.i < 150:
|
||||
return
|
||||
|
||||
# Compute averages
|
||||
# data.history() has to be called with the same params
|
||||
# from above and returns a pandas dataframe.
|
||||
short_mavg = data.history(context.asset, 'price', bar_count=100, frequency="1d").mean()
|
||||
long_mavg = data.history(context.asset, 'price', bar_count=300, frequency="1d").mean()
|
||||
short_mavg = data.history(context.asset, 'price', bar_count=50, frequency="1d").mean()
|
||||
long_mavg = data.history(context.asset, 'price', bar_count=150, frequency="1d").mean()
|
||||
|
||||
# Trading logic
|
||||
if short_mavg > long_mavg:
|
||||
@@ -518,7 +523,7 @@ a function we use in the ``handle_data()`` section:
|
||||
|
||||
def analyze(context, perf):
|
||||
import matplotlib.pyplot as plt
|
||||
fig = plt.figure()
|
||||
fig = plt.figure(figsize=(12,12))
|
||||
ax1 = fig.add_subplot(211)
|
||||
perf.portfolio_value.plot(ax=ax1)
|
||||
ax1.set_ylabel('portfolio value in $')
|
||||
|
||||
@@ -39,6 +39,7 @@ version:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ pip install virtualenv
|
||||
$ virtualenv catalyst-venv
|
||||
$ source ./catalyst-venv/bin/activate
|
||||
$ pip install enigma-catalyst
|
||||
@@ -132,6 +133,15 @@ it and install it before proceeding to the next step.
|
||||
For windows, the easiest and best supported way to install Catalyst is to use
|
||||
:ref:`Conda <conda>`.
|
||||
|
||||
Troubleshooting Visual C++ Compiler Install
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
We run into two different errors when trying to install the the `Microsoft Visual C++
|
||||
Compiler for Python 2.7` mentioned above:
|
||||
|
||||
-
|
||||
|
||||
|
||||
Amazon Linux AMI
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@@ -1,30 +1,22 @@
|
||||
name: catalyst
|
||||
channels:
|
||||
- statiskit
|
||||
- defaults
|
||||
dependencies:
|
||||
- certifi=2016.2.28=py27_0
|
||||
- coverage=4.4.1=py27_0
|
||||
- nose=1.3.7=py27_1
|
||||
- openssl=1.0.2l=0
|
||||
- path.py=10.3.1=py27_0
|
||||
- mkl=2017.0.3
|
||||
- numpy=1.13.1=py27_0
|
||||
- openssl=1.0.2l
|
||||
- pip=9.0.1=py27_1
|
||||
- python=2.7.13=0
|
||||
- pyyaml=3.12=py27_0
|
||||
- readline=6.2=2
|
||||
- setuptools=36.4.0=py27_0
|
||||
- six=1.10.0=py27_0
|
||||
- sqlite=3.13.0=0
|
||||
- tk=8.5.18=0
|
||||
- python=2.7.13
|
||||
- scipy=0.19.1=np113py27_0
|
||||
- setuptools=36.4.0=py27_1
|
||||
- sqlite=3.13.0
|
||||
- tk=8.5.18
|
||||
- wheel=0.29.0=py27_0
|
||||
- yaml=0.1.6=0
|
||||
- zlib=1.2.11=0
|
||||
- libdev=1.0.0=py27_0
|
||||
- python-dev=1.0.0=py27_0
|
||||
- python-scons=3.0.0=py27_0
|
||||
- zlib=1.2.11
|
||||
- pip:
|
||||
- alembic==0.9.5
|
||||
- backports.shutil-get-terminal-size==1.0.0
|
||||
- alembic==0.9.6
|
||||
- backports.functools-lru-cache==1.4
|
||||
- bcolz==0.12.1
|
||||
- bottleneck==1.2.1
|
||||
- chardet==3.0.4
|
||||
@@ -32,36 +24,22 @@ dependencies:
|
||||
- contextlib2==0.5.5
|
||||
- cycler==0.10.0
|
||||
- cyordereddict==1.0.0
|
||||
- cython==0.26.1
|
||||
- cython==0.27.1
|
||||
- decorator==4.1.2
|
||||
- empyrical==0.2.1
|
||||
- enigma-catalyst>=0.2.dev2
|
||||
- enum34==1.1.6
|
||||
- functools32==3.2.3.post2
|
||||
- idna==2.6
|
||||
- intervaltree==2.1.0
|
||||
- ipdb==0.10.3
|
||||
- ipdbplugin==1.4.5
|
||||
- ipython==5.5.0
|
||||
- ipython-genutils==0.2.0
|
||||
- logbook==1.1.0
|
||||
- lru-dict==1.1.6
|
||||
- mako==1.0.7
|
||||
- markupsafe==1.0
|
||||
- matplotlib==2.0.2
|
||||
- matplotlib==2.1.0
|
||||
- multipledispatch==0.4.9
|
||||
- networkx==1.11
|
||||
- networkx==2.0
|
||||
- numexpr==2.6.4
|
||||
- numpy==1.13.1
|
||||
- pandas==0.19.2
|
||||
- pandas-datareader==0.5.0
|
||||
- pathlib2==2.3.0
|
||||
- patsy==0.4.1
|
||||
- pexpect==4.2.1
|
||||
- pickleshare==0.7.4
|
||||
- prompt-toolkit==1.0.15
|
||||
- ptyprocess==0.5.2
|
||||
- pygments==2.2.0
|
||||
- pyparsing==2.2.0
|
||||
- python-dateutil==2.6.1
|
||||
- python-editor==1.0.3
|
||||
@@ -69,16 +47,12 @@ dependencies:
|
||||
- requests==2.18.4
|
||||
- requests-file==1.4.2
|
||||
- requests-ftp==0.3.1
|
||||
- scandir==1.5
|
||||
- scipy==0.19.1
|
||||
- scons==3.0.0a20170821
|
||||
- simplegeneric==0.8.1
|
||||
- six==1.11.0
|
||||
- sortedcontainers==1.5.7
|
||||
- sqlalchemy==1.1.14
|
||||
- statsmodels==0.8.0
|
||||
- subprocess32==3.2.7
|
||||
- tables==3.4.2
|
||||
- toolz==0.8.2
|
||||
- traitlets==4.3.2
|
||||
- urllib3==1.22
|
||||
- wcwidth==0.1.7
|
||||
- enigma-catalyst>=0.3
|
||||
|
||||
Reference in New Issue
Block a user