Commit Graph

57 Commits

Author SHA1 Message Date
Richard Frank 73a61caaeb MAINT: Removing unused array and unused attribute 2016-09-19 15:19:30 -04:00
Jean Bredeche 7d4b19a7f0 ENH: Use bundle name as exchange value 2016-08-02 23:21:39 -04:00
Joe Jevnik 5925107052 TST: fix doctests to actually run 2016-06-21 15:07:03 -04:00
Scott Sanderson 392ac2f9d6 DOC/TEST: Add example algo using Pipeline. 2016-05-24 22:34:05 -04:00
Joe Jevnik 59c8e371a2 ENH: Updates the cli, data bundles and extensions.
Adds the data bundle concept which makes it easy for users to register
loading functions to build out minute and daily data along with an
assets db and adjustments db. By default we have provided a `quandl`
bundle which pulls from the public domain WIKI dataset. Users may
register new bundles by decorating an ingest function with
`zipline.data.bundles.register(<name>)`. This also provides a
`yahoo_equities` function for creating an ingestion function that will
load a static set of assets from yahoo.

The cli is now structured as a couple of subcommands and has been
changed to `python -m zipline`. The old behavior of `run_algo.py` has
been moved to the `run` subcommand. This is almost entirely the same
except that it now takes the name of the data bundle to use, defaulting
to `quandl`.

The next subcommand is `ingest` which takes the name of
a data bundle to ingest. This will run the loading machinery and write
the data to a specified location that `run` can find.

There is also a `clean` subcommand which deletes the data that was
written with `ingest`.

Extensions have also been added to zipline. This is an experimental
feature where users can provide an extra set of python files to run at
the start of the process. These can be used to configure aspects of
zipline. Right now the only thing that is supported in an extension file
is the registration of a new data bundle.
2016-05-03 18:38:24 -04:00
Scott Sanderson 85ae664d8c BUG: Don't crash on dataframes with assets in index. 2016-04-28 15:19:57 -04:00
Joe Jevnik bc0b117dc9 MAINT: make the data loading apis more consistent.
Changes BcolzDailyBarWriter to not be an abc, data is passed as an
iterator of (sid, dataframe) pairs to the write method.

Changes the AssetsDBWriter to be a single class which accepts an engine
at construction time and has a `write` method for writing dataframes for
the various tables. We no longer support writing the various other data
types, callers should coerce their data into a dataframe themselves. See
zipline.assets.synthetic for some helpers to do this.

Adds many new fixtures and updates some existing fixtures to use the new
ones:

WithDefaultDateBounds
  A fixture that provides the suite a START_DATE and END_DATE. This is
  meant to make it easy for other fixtures to synchronize their date
  ranges without depending on eachother in strange ways. For example,
  WithBcolzMinuteBarReader and WithBcolzDailyBarReader by default should
  both have data for the same dates, so they may use depend on
  WithDefaultDates without forcing a dependency between them.

WithTmpDir, WithInstanceTmpDir
  Provides the suite or individual test case a temporary directory.

WithBcolzDailyBarReader
  Provides the suite a BcolzDailyBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from
  dataframes and then converted to bcolz files with
  BcolzDailyBarWriter.write

WithBcolzDailyBarReaderFromCSVs
  Provides the suite a BcolzDailyBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from a
  collection of CSV files and then converted into the bcolz data through
  BcolzDailyBarWriter.write_csvs

WithBcolzMinuteBarReader
  Provides the suite a BcolzMinuteBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from
  dataframes and then converted to bcolz files with
  BcolzMinuteBarWriter.write

WithAdjustmentReader
  Provides the suite a SQLiteAdjustmentReader which reads from an in
  memory sqlite database. The data will be read from dataframes and then
  converted into sqlite with SQLiteAdjustmentWriter.write

WithDataPortal
  Provides each test case a DataPortal object with data from temporary
  resources.
2016-04-15 23:46:10 -04:00
Eddie Hebert 16fd6681a6 ENH: Rewrite of Zipline to use lazy access pattern
More documentation to follow in release notes.

Based on lazy-mainline branch, see for more details.

Also-By: Jean Bredeche <jean@quantopian.com>
Also-By: Andrew Liang <aliang@quantopian.com>
Also-By: Abhijeet Kalyan <akalyan@quantopian.com>
2016-04-04 16:12:58 -04:00
Richard Frank 2976280a76 DOC: Fixed example notebook to include required calls to symbol 2016-03-15 11:08:44 -04:00
Jonathan Kamens 11465d907d MAINT: Upgrade Logbook version
Upgrade Logbook to 0.12.5. This required changing a usage of
`logbook.NullHandler()` which passed `bubble=True`, since
`NullHandler` no longer supports the `bubble` argument.
2016-02-16 13:32:25 -05:00
Scott Sanderson 5f49fa22cb MAINT: Upgrade numpy and fix warnings.
Mostly fixes ambiguous calls to numpy.full, and uses explicitly-united
NaT values.
2016-02-11 18:46:39 -05:00
Scott Sanderson 84d8cc4d41 DOC: Add simple buy and hold example. 2015-12-13 15:06:15 -05:00
Stewart Douglas 29321af1b4 DEP: Remove quantopian_buy_applye.py as logic covered in buyapple.py 2015-09-10 17:17:46 -04:00
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