Commit Graph

44 Commits

Author SHA1 Message Date
Stewart Douglas 283c959cc4 MAINT: Move analyze methods into algorithm files 2015-09-10 11:36:14 -04:00
Stewart Douglas 723c5bb069 ENH: Add if name == main blocks to examples 2015-09-10 11:32:41 -04:00
Stewart Douglas 3f4bbc521a ENH: Add axis label to olmar output plot 2015-09-10 11:32:41 -04:00
Stewart Douglas dee69f39fe BUG: Allow dual_em_talib.py to be executed with run_algo.py 2015-09-08 11:55:06 -04:00
Jonathan Kamens dca679edcb BUG: Logbook 0.10.0 requires explicit handler
As of logbook 0.10.0, logbook no longer installs a default handler,
which means that if the application doesn't install one, log messages
disappear into the ether.

Therefore, all of our scripts with `__main__` endpoints need to push a
`logbook.StderrHandler` if they're not already pushing some other
handler.
2015-07-28 04:38:41 -04:00
jfkirk 258b5ea2ca API: DataFrame/Panel sources expect integer sids, not identifiers
This commit modifies the DataFrameSource and DataPanelSource to accept only Int64Indexes on the incoming data and moves the burden of mapping user identifiers to TradingAlgorithm.run().
2015-07-01 13:43:31 -04:00
jfkirk b84ac01cbf ENH: Adds futures trading and asset management logic to TradingAlgorithm and performance classes 2015-06-11 11:35:49 -04:00
Thomas Wiecki 71effa5e98 MAINT: Replace old ema_talib example with new one. 2014-12-19 14:04:27 +01:00
Mete Atamel 9d8bb3dfa9 DEV: Add quantopian_dual_ema_talib.py
This file is identical to dual_ema_talib.py but it's in Quantopian syntax for easy copy/paste to Quantopian.
2014-12-19 14:04:27 +01:00
Joe Jevnik e3d8b1034e ENH: Replaces the simple transforms with history calls. Switches
transforms to quantopian syntax.

Adds the sid attribute to the siddata so it is aware of which security
it represents.
2014-11-17 13:16:30 -05:00
Thomas Wiecki c12304ce40 DOC: Updated dual moving average example to use symbol lookup. 2014-08-04 12:21:50 +02:00
Thomas Wiecki 6dc9c1b8ae BUG: Fix comparison for pandas 0.14. Closes #377. 2014-07-25 19:31:25 +02:00
Thomas Wiecki eae41b8e7a DOC: Add tutorial and update examples to use history. 2014-07-16 17:30:23 +02:00
twiecki f5086e4b0e ENH: Add IPython cell magic.
When zipline is imported it checks whether
it runs in the IPython notebook. If it does,
it registers a %%zipline magic that takes the
same arguments as the CLI with the addition of
a -o for specifying the output variable to store
the performance frame in.

The algo code in the cell is, as of yet, executed
in its own environment rather than that of the
IPython NB which is probably what we want.

Also adds cli option to save the perf dataframe
to a pickle file.

Also adds an IPython notebook buyapple example.
2014-05-07 15:34:41 -04:00
twiecki f9fded97ac ENH: Implement CLI.
Add a CLI that reads in an algorithm, loads data,
run the algorithm, and output performance metrics.

The examples are adapted to the new zipline API and
analyses are split into separate files.

Also add config files that run the example
algorithms with preset settings.
2014-05-07 15:34:36 -04:00
Eddie Hebert 9feed61748 MAINT: Use more exact boolean checks for pandas structures.
To prepare for being compatible with pandas==0.13.0, which is stricter
on boolean checks.
2014-01-29 17:13:13 -05:00
Thomas Wiecki b69590a2f7 ENH: Factor out API methods. Add support for algo scripts.
This is a step towards the goal of uniting Quantopian scripts
and zipline.

To make the syntax of zipline identical to Quantopian
we break out the API methods (like order) and turn them into
functions. To access the algo object we add a thread local reference
to the current algorithm that is accessed in the API functions.

TradingAlgorithm now takes either a string or two functions
(initialize and handle_data) that it executes.

Use api method decorator for methods available in algoscript.

Ported appropriate algorithm tests from internal code.
2014-01-16 12:07:33 -05:00
Eddie Hebert 770d8b4e29 MAINT: Use date range in example that that has 1 Month curves.
So that the 1-Month Sharpe ratio has a curve to use during calculation,
use data from 2002, since the Treasury returns 1 Month data starting
in July, 2001.
2014-01-09 13:38:16 -05:00
Eddie Hebert 54ddd1c109 MAINT: print function clean up in preparation for Python 3
- Use `print()` function for all print calls
- Fix strip and format calls that were on the outside of the
  print function for some reason.
  (Which were breaking in Python 3 because of print returning None.)
- Remove commented out print calls.
2014-01-04 20:55:43 -05:00
Jonathan Kamens 73faf9133e MAINT: Clean up imports of zipline.finance.trading
Use "from zipline.finance import trading" instead of "import
zipline.finance.trading as trading".
2013-10-29 13:50:14 -04:00
Eddie Hebert 37c56b9aa4 MAINT: Use Series throughout for daily returns.
Remove the lists of DailyReturn objects in favor of using pd.Series
to store the return values.

Should make it easier to inspect the values when stepping through,
make the windowing of data to a certain range more facile by using,
and have some performance increases due to removing object creation
and member access.
2013-10-19 23:06:18 -04:00
Thomas Wiecki b89886297f STY: autopep8 codebase. 2013-08-08 16:46:44 -04:00
Thomas Wiecki 963324723c STY: Flake8 line break. 2013-08-01 17:14:56 -04:00
Ben McCann 8dd4230fd0 ENH: Plot benchmark returns in DMA example. 2013-08-01 16:55:12 -04:00
Thomas Wiecki 1635a54fb8 ENH: Add print of monthly Sharpe to DMA example. 2013-08-01 16:09:38 -04:00
Jeremi Joslin 8e1cdac77d BUG: Fix talib sample; parameter for window length is called timeperiod 2013-07-22 10:38:04 -04:00
Eddie Hebert 5758f885c5 TST: Update talib example for compatibility with multiple sids.
To support mulitple sids the TALib transforms now return a dict,
instead of a float. Accordingly, the TALib example script now needs
to index into the transform result.
2013-07-10 15:37:03 -04:00
Eddie Hebert c7c55399be BUG: Fix TALib example due to parameter changes.
Remove use of `sid` parameter, which was recently removed.
2013-06-27 21:10:09 -04:00
Thomas Wiecki 9931812745 BUG: Buy/sell triggers not correct in example. Thanks @FerMartin. 2013-06-27 13:23:48 -04:00
Ben McCann eb027833b3 DEV: Make the other example charts larger as well 2013-06-14 15:47:44 -04:00
Matti Hanninen 8e27cc053c DEV: Don't invoke hardwired Python
Instead use /urs/bin/env to detect the Python interpreter. This way the
scripts work better with the possible virtual environment.
2013-06-14 15:38:45 -04:00
Ben McCann cc7969e777 DEV: Make the example chart larger so that it's readable 2013-06-07 10:15:33 -04:00
Thomas Wiecki c1c71398d6 ENH: Add example that uses talib transform.
The new example is almost identical to the dual_moving_average one.
However, instead of our in-house mavg transform it uses the new
talib exponential moving average (EMA).
2013-05-13 16:38:40 -04:00
Thomas Wiecki b748ba62e0 MAINT: Shortened time frame over which examples are run to speed up tests.
Minor fix pairtrade to now use record.
2013-05-02 16:54:57 -04:00
Thomas Wiecki d56f1b73f8 BUG: Removed SlippageModel from olmar example.
Fix crash due to 'delay' was no longer supported.
But removing SlippageModel override, since current configs
should be functionally equivalent to FixedSlippage.
2013-05-02 16:54:08 -04:00
Eddie Hebert 58af62f18d REL: Update copyright on all files touched since end of 2012.
s/Copyright 2012/Copyright 2013/
2013-04-05 14:28:15 -04:00
Eddie Hebert e901e06f39 Changes the API for recording variables.
Uses a method called 'record' that provides a key value,
instead of providing keys to extract from context.

The variables are stored internally to the algorithm in a dictionary,
and not just stared as a property of the algorithm.

Main intent behind this change is to make the API more user friendly,
since the previous recorded_variables relies on the value to be set
in the algorithms context/self, the hope is that only having to use
the `record` method means less moving pieces and a more understandable
API.

i.e., instead of:

```
def initialize(self):
    recorded_variables('foo', bar')

def handle_data(self, data):
    self.foo = 1
    self.bar = 2
```

The API is now:

```
def initialize(self):
    pass

def handle_data(self, data):
    self.record(foo=1, bar=2)
```
2013-03-02 18:28:35 -05:00
Thomas Wiecki f1ff9cee0d ENH: New example algorithm OLMAR. 2013-03-01 15:33:12 -05:00
Matti Hanninen 4026e6122f Fixes an incorrect order in examples. 2013-02-01 18:17:23 +02:00
Eddie Hebert c298cfda03 Adds recorded variable to dual moving average example.
Attr: Thomas Wiecki <thomas.wiecki@gmail.com> (@twiecki)
2013-01-31 08:19:07 -05:00
Eddie Hebert 0ba6f88a84 Fixes event window length in example algo.
It was using the old days parameter.
2012-11-20 16:38:56 -05:00
Eddie Hebert 9f715258e6 Updates pairtrade example to use window_length.
Batch transforms now use window_length instead of days.
2012-11-20 16:31:18 -05:00
Thomas Wiecki 126e9fdf26 Fixed batch_transform window length not being market aware.
Added accompanying unittest.

Minor refactoring of unittests and factory.
2012-11-06 21:13:27 -05:00
Thomas Wiecki 42c2a6b892 Adds example algorithm scripts. 2012-10-23 17:46:02 -04:00