Skip to content

Commit

Permalink
Merge branch 'release/0.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
gbeced committed Aug 21, 2018
2 parents 2c78a21 + 8922d16 commit ad2bcc6
Show file tree
Hide file tree
Showing 262 changed files with 6,680 additions and 5,762 deletions.
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ MANIFEST
doc/_build
.idea
.coverage
.coverage.*
.ipynb_checkpoints
.ropeproject
.tox
.pytest_cache

data
dist
build
PyAlgoTrade.egg-info
/venv
/data
/dist
/build
/PyAlgoTrade.egg-info
/notebooks

testcases/twitter_credentials.py
/testcases/credentials.py
17 changes: 10 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
language: python
python:
- "2.7"

env:
global:
# https://docs.travis-ci.com/user/environment-variables/#Defining-encrypted-variables-in-.travis.yml
# travis encrypt QUANDL_API_KEY=somevalue
- secure: "YgngWTEKD6bUVgExTN8vWYCq7mrMKsVVqZaWIsepRziU++K1e9iBuQrSspQbyrdsKMqKMyMnsM3ru7M6+D0F+p/BC4gyWg6N+wn3RoqrWidyutejibsobDJnS3EsSfo4cJUFcoAOzzuXK+Du0yUZPNBxjJdF/NA1C8vDg0YAmzs="
- secure: "GUuZEQSA9x96bIJiC/Ab/RxQ+Dv2eqwhRVaZYVlmuSDQXouDJdFAF9dEcUplwt3TCKg7CbOa3gr2c1rJ7bclk1ueUSXdwzlgEfEdcu7Xm+lf6LcfZESDtWUvPgRzvVqspp3hwx+SCpSl2TzXwgCRNOX8ybDC5ZvRZRQaagT6maA="
- secure: "oAUaWICTHks6N/RNFZbF/NJE+1mB45DRZu1uvzKN5EhEp+Qys6LGHm1yZLI1sMAfwYrLro1oxNGpxD26hoMDjy2bDyBNZj59i2M7Eeo9juY3wR2sz0tKuvEdMdbuhMGyDgvXV6xlqO10hHeUUwbJOyxcQxmcp0c33B0Jse3m+pI="
- secure: "OrR5+l3HzjKWQtVRUIHB1uLCFtRt1wNAQxJjoL6mufBMIigcpMnE2QzsoP9ywSgew8St4nFMGaL/xxR/RYTi59c6fVRh8zGg/JYMSYtr4UM8M2Gk0vSYmo3JO9OihOxn3JWbF4606vzEgqtjMT9qojo3Xx/d0Hp9br5s/wwe1oQ="
- secure: "beFEPV9JWgX4wFx3mBeBwE7hBAK2h9gW5qpNolgYrevDQxHDQdfcNN5Rcda2/VGQiEKM+X4dixNttogfNu4yS21c5/DPUhsKNwV/ClZgYsmkowGwkXsaF6J/cYcE9+WvziCfDV3z3wTKMmyPMJlbeFDB+zik2idzkG3txUVo27g="

sudo: required

language: python
python:
- "2.7"

services:
- docker

before_install:
- docker pull gbecedillas/pyalgotrade:0.18
- docker pull gbecedillas/pyalgotrade:0.20-py27
- cp travis/Dockerfile .
- docker build -t testcases .
- docker build -t pyalgotrade_testcases .
- sudo pip install coveralls

script:
- docker run --name testcases --env TWITTER_CONSUMER_KEY=$TWITTER_CONSUMER_KEY --env TWITTER_CONSUMER_SECRET=$TWITTER_CONSUMER_SECRET --env TWITTER_ACCESS_TOKEN=$TWITTER_ACCESS_TOKEN --env TWITTER_ACCESS_TOKEN_SECRET=$TWITTER_ACCESS_TOKEN_SECRET testcases /bin/bash -c "cd /tmp/pyalgotrade; ./run_tests.sh"
- docker run --name testcases --env TWITTER_CONSUMER_KEY=$TWITTER_CONSUMER_KEY --env TWITTER_CONSUMER_SECRET=$TWITTER_CONSUMER_SECRET --env TWITTER_ACCESS_TOKEN=$TWITTER_ACCESS_TOKEN --env TWITTER_ACCESS_TOKEN_SECRET=$TWITTER_ACCESS_TOKEN_SECRET --env QUANDL_API_KEY=$QUANDL_API_KEY pyalgotrade_testcases /bin/bash -c "cd /tmp/pyalgotrade; ./run_tests.sh"

after_success:
- docker cp testcases:/tmp/pyalgotrade/.coverage .
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Version 0.20 (20/Aug/2018)
. [NEW] Added support for Python 3.7.
. [NEW] Added setShares method for back-testing broker. Thanks winkidney for implementing this.
. [NEW] Added an option to support skipping errors while parsing CSV files.
. [NEW] Added batchSize parameter to optimizer component. Thanks micmicmichael for implementing this.
. [NEW] Added savePlot to the plotter to save the plot to a file. Thanks Kimble Young for implementing this.
. [FIX] Fixed a bug in the Event class when unsubscribing and re-subscribing while emitting. Thanks pjz for reporting this.
. [FIX] Fixed a race condition in the local optimizer that was sometimes getting blocked waiting for workers.
. [FIX] Fixed a bug while generating nonces for Bitstamp. Thanks pjz for reporting this.
. [FIX] Fixed callback for BaseStrategy.resampleBarFeed to match onBars prototype.
. [FIX] Fixed extra columns parsing in csvfeed.GenericRowParser. Thanks Jones Chung for reporting this.
. [BREAKING CHANGE] Removed support for downloading bars from Yahoo Finance.
. [BREAKING CHANGE] Removed support for downloading bars from Google Finance.

Version 0.18 (17/Aug/2016)
. [NEW] Returns analyzer now stores datetimes along with each sample. Thanks MatthiasKauer for implementing this.
. [NEW] Quandl tool to build feed supports mapping column names.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PyAlgoTrade

Copyright 2011 Gabriel Martin Becedillas Ruiz
Copyright 2011-2018 Gabriel Martin Becedillas Ruiz

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and **live trading** is now possible using:

* [Bitstamp](https://www.bitstamp.net/) for Bitcoins

To get started with PyAlgoTrade take a look at the [tutorial](http://gbeced.github.io/pyalgotrade/docs/v0.18/html/tutorial.html) and the [full documentation](http://gbeced.github.io/pyalgotrade/docs/v0.18/html/index.html).
To get started with PyAlgoTrade take a look at the [tutorial](http://gbeced.github.io/pyalgotrade/docs/v0.20/html/tutorial.html) and the [full documentation](http://gbeced.github.io/pyalgotrade/docs/v0.20/html/index.html).

Main Features
-------------
Expand All @@ -32,7 +32,7 @@ Main Features
Installation
------------

PyAlgoTrade is developed using Python 2.7 and depends on:
PyAlgoTrade is developed and tested using Python 2.7/3.7 and depends on:

* [NumPy and SciPy](http://numpy.scipy.org/).
* [pytz](http://pytz.sourceforge.net/).
Expand Down
1 change: 0 additions & 1 deletion build_sdist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

python setup.py sdist

4 changes: 0 additions & 4 deletions cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,3 @@ find . -name *.pyc -delete
find . -name .coverage -delete
find . -name .noseids -delete
find . -name htmlcov -exec rm -rf {} \;

find . -name *.egg-info -exec rm -rf {} \;
find . -name dist -exec rm -rf {} \;

1 change: 1 addition & 0 deletions coverage.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[report]
show_missing = 1
exclude_lines =
pragma: no cover
raise NotImplementedError()
4 changes: 2 additions & 2 deletions doc/bitstamp_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The key things to highlight are:
as the base class. This is not a backtest.
2. Trade events get notified via the call to **onBars**. No need to manually subscribe.
3. Order book update events are handled by manually subscribing to :class:`pyalgotrade.bitstamp.barfeed.LiveTradeFeed.getOrderBookUpdateEvent`.
This is needed to be up to date with latest bid and ask prices.
This is needed to stay up to date with latest bid and ask prices.

.. literalinclude:: ../samples/tutorial_bitstamp_1.py

Expand Down Expand Up @@ -134,5 +134,5 @@ In order to live trade this strategy you should use :class:`pyalgotrade.bitstamp
:class:`pyalgotrade.bitstamp.broker.PaperTradingBroker`.

**Note that if you try to live trade this strategy you will probably loose money.**
Before jumping to live trading, be sure to write your own strategy, backtest and paper trade it thoroughly
Before jumping into live trading, be sure to write your own strategy, backtest and paper trade it thoroughly
before risking real money.
62 changes: 6 additions & 56 deletions doc/compinvpart1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ Computational Investing Part I
==============================

As I was taking the `Computational Investing Part I <https://class.coursera.org/compinvesting1-2012-001/class>`_ course in 2012
I had to work on a set of assignments and for some of them I used PyAlgoTrade.
I had to work on a set of assignments and for one of them I used PyAlgoTrade.

Homework 1
----------

For this assignment I had to pick 4 stocks, invest a total of $100000 during 2011, and calculate:
For this assignment I had to pick 4 stocks, invest a total of $1000000 during 2011, and calculate:

* Final portfolio value
* Anual return
Expand All @@ -17,10 +17,10 @@ For this assignment I had to pick 4 stocks, invest a total of $100000 during 201

Download the data with the following commands: ::

python -c "from pyalgotrade.tools import yahoofinance; yahoofinance.download_daily_bars('aeti', 2011, 'aeti-2011-yahoofinance.csv')"
python -c "from pyalgotrade.tools import yahoofinance; yahoofinance.download_daily_bars('egan', 2011, 'egan-2011-yahoofinance.csv')"
python -c "from pyalgotrade.tools import yahoofinance; yahoofinance.download_daily_bars('glng', 2011, 'glng-2011-yahoofinance.csv')"
python -c "from pyalgotrade.tools import yahoofinance; yahoofinance.download_daily_bars('simo', 2011, 'simo-2011-yahoofinance.csv')"
python -m "pyalgotrade.tools.quandl" --source-code="WIKI" --table-code="IBM" --from-year=2011 --to-year=2011 --storage=. --force-download --frequency=daily
python -m "pyalgotrade.tools.quandl" --source-code="WIKI" --table-code="AES" --from-year=2011 --to-year=2011 --storage=. --force-download --frequency=daily
python -m "pyalgotrade.tools.quandl" --source-code="WIKI" --table-code="AIG" --from-year=2011 --to-year=2011 --storage=. --force-download --frequency=daily
python -m "pyalgotrade.tools.quandl" --source-code="WIKI" --table-code="ORCL" --from-year=2011 --to-year=2011 --storage=. --force-download --frequency=daily

Although the deliverable was an Excel spreadsheet, I validated the results using this piece of code:

Expand All @@ -29,53 +29,3 @@ Although the deliverable was an Excel spreadsheet, I validated the results using
The results were:

.. literalinclude:: ../samples/compinv-1.output

Homework 3 and 4
----------------

For these assignments I had to build a market simulation tool that loads orders from a file, executes those,
and prints the results for each day.

The orders file for homework 3 look like this: ::

2011,1,10,AAPL,Buy,1500,
2011,1,13,AAPL,Sell,1500,
2011,1,13,IBM,Buy,4000,
2011,1,26,GOOG,Buy,1000,
2011,2,2,XOM,Sell,4000,
2011,2,10,XOM,Buy,4000,
2011,3,3,GOOG,Sell,1000,
2011,3,3,IBM,Sell,2200,
2011,6,3,IBM,Sell,3300,
2011,5,3,IBM,Buy,1500,
2011,6,10,AAPL,Buy,1200,
2011,8,1,GOOG,Buy,55,
2011,8,1,GOOG,Sell,55,
2011,12,20,AAPL,Sell,1200,

This is the market simulation tool that I built:

.. literalinclude:: ../samples/compinv-3.py

The output for homework 3 looks like this: ::

First date 2011-01-10 00:00:00
Last date 2011-12-20 00:00:00
Symbols ['AAPL', 'IBM', 'GOOG', 'XOM']
2011-01-10 00:00:00: Portfolio value: $1000000.00
2011-01-11 00:00:00: Portfolio value: $998785.00
2011-01-12 00:00:00: Portfolio value: $1002940.00
2011-01-13 00:00:00: Portfolio value: $1004815.00
.
.
.
2011-12-15 00:00:00: Portfolio value: $1113532.00
2011-12-16 00:00:00: Portfolio value: $1116016.00
2011-12-19 00:00:00: Portfolio value: $1117444.00
2011-12-20 00:00:00: Portfolio value: $1133860.00
Final portfolio value: $1133860.00
Anual return: 13.39 %
Average daily return: 0.05 %
Std. dev. daily return: 0.0072
Sharpe ratio: 1.21

4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
# built documents.
#
# The short X.Y version.
version = '0.18'
version = '0.20'
# The full version, including alpha/beta/rc tags.
release = '0.18'
release = '0.20'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion doc/eventprofiler.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Event profiler
==============

Inspired in QSTK (http://wiki.quantsoftware.org/index.php?title=QSTK_Tutorial_9), the **eventprofiler** module is a tool to analyze,
Inspired in `QSTK <http://wiki.quantsoftware.org/index.php?title=QSTK_Tutorial_9>`_, the **eventprofiler** module is a tool to analyze,
statistically, how events affect future equity prices.
The event profiler scans over historical data for a specified event and then calculates the impact of that event on the equity prices in the past
and the future over a certain lookback period.
Expand Down
2 changes: 1 addition & 1 deletion doc/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PyAlgoTrade is an event driven algorithmic trading Python library with support f

It should also make it easy to optimize a strategy using multiple computers.

PyAlgoTrade is developed using Python 2.7 and depends on:
PyAlgoTrade is developed and tested using Python 2.7/3.7 and depends on:
* NumPy and SciPy (http://numpy.scipy.org/).
* pytz (http://pytz.sourceforge.net/).
* matplotlib (http://matplotlib.sourceforge.net/) for plotting support.
Expand Down
2 changes: 1 addition & 1 deletion doc/optimizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ optimizer -- Parallel optimizers
:show-inheritance:

.. note::
* The server component will split strategy executions in chunks which are distributed among the different workers. **pyalgotrade.optimizer.server.Server.defaultBatchSize** controls the chunk size.
* The server component will split strategy executions in chunks which are distributed among the different workers. You can optionally set the chunk size by passing in **batchSize** to the constructor of **pyalgotrade.optimizer.xmlrpcserver.Server**.
* The :meth:`pyalgotrade.strategy.BaseStrategy.getResult` method is used to select the best strategy execution. You can override that method to rank executions using a different criteria.

2 changes: 1 addition & 1 deletion doc/sample_market_timing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ returns in the last month.

This is what the output should look like:

.. literalinclude:: ../samples/market_timing.output
.. literalinclude:: ../samples/market_timing.output.27

This is what the plot should look like:

Expand Down
3 changes: 1 addition & 2 deletions doc/sample_vwap_momentum.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
VWAP Momentum Trade
===================

This example is based on:
* https://www.quantopian.com/posts/momentum-trade
This example is based on `Momentum Trade <https://www.quantopian.com/posts/momentum-trade>`_

.. literalinclude:: ../samples/vwap_momentum.py

Expand Down
7 changes: 0 additions & 7 deletions doc/tools.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
Tools
=====

Yahoo! Finance
--------------

.. automodule:: pyalgotrade.tools.yahoofinance
:members:
:show-inheritance:

Quandl
------

Expand Down
Loading

0 comments on commit ad2bcc6

Please sign in to comment.