Commit Graph

60 Commits

Author SHA1 Message Date
Jeremiah Lowin cc39ec3aef ENH: Add support for TALib based transforms.
Provide a subclass of BatchTransforms that are powerd by the ta-lib
library.
2013-04-30 17:35:56 -04:00
Thomas Wiecki 2be7014d51 ENH: Rewrite of batch_transform to use rolling panel.
- Added unittest to test for newly appearing sids.
- Fixed logic bug where window was only full after
  window_length+1 events got passed.
2013-04-29 15:30:40 -04:00
fawce 9062b9636a MAINT: refactoring for orders api
- moved Order and Blotter to zipline.finance.blotter
- moved order method from AlgoSimulator to Blotter
- eliminated the set_order method in algorithm
- moved blotter to the algorithm
2013-04-26 19:45:59 -04:00
Eddie Hebert b3efb5eb69 MAINT: Remove ndict class.
Now that ndict is no longer used in any part of the system during
a backtest, remove all remaining references in tests, etc.
2013-04-26 16:03:01 -04:00
Eddie Hebert 1909a0576f MAINT: Removes unused frame_count member from algorithm class.
frame_count is only over incremented, but never read or otherwise
used.
2013-03-19 20:36:53 -04:00
fawce a12eeb2383 incorporating feedback from @richafrank 2013-03-06 16:49:31 -05:00
fawce b8144cea2a added tests to ensure:
- repeated calls with the same data window do not update batch transform
    windows.
    - repeated calls with the same data and same supplemental parameters do
    not update batch transform results
    - repeated calls with the same data and different supplemental params
    do update batch transform results
2013-03-05 22:59:31 -05:00
fawce a47143099c refining the batch transform interface:
- removed use_panel
  - default for refresh_period is now 0
  - refresh_period will only affect the recreation of the datapanel
  - user's transform method is invoked on every call to batch transform
2013-03-04 21:08:15 -05: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
Eddie Hebert 97cbea2514 Fixes crashes when using numpy log on a batch transform data panel.
The recent change to the creation of the data panel ended up with
a panel with the dtype of 'object', which was causing numpy ufuncs
like `log` to crash out on an `AttributeError`.

This forces all frames in the panel to use a dtype of 'float',
we may want to look at seeting a dtype on a frame by frame basis,
e.g. 'volume' may more accurately be 'int'.
2013-02-19 11:20:04 -05:00
Eddie Hebert 1bc19c052b Removes unused test transform. 2013-02-01 21:05:49 -05:00
Eddie Hebert 81337d1306 Adds the ability to record variables.
Takes the value set for a variable on handle_data and records it,
e.g.:
```
    def initialize(self):
        self.incr = 0
        self.record_variables(['incr'])

    def handle_data(self, data):
        self.incr += 1
```

Would record a variable of `incr`.

Emits the recorded variables as part of the daily performance.

This batch combins work from:
Thomas Wiecki <thomas.wiecki@gmail.com> (@twiecki)
fawce <fawce@quantopian.com> (@fawce)
2013-01-31 08:16:54 -05:00
Eddie Hebert 2587cd6512 Enriches message returned for test batch transform.
Adds formatting of the failing values when ReturnPriceBatchTransform's
data shape does not match the window_length.
2013-01-30 14:04:17 -05:00
Thomas Wiecki 456639d02c ENH: New batch_transform feature: compute_only_full. 2013-01-16 10:30:37 -05:00
Thomas Wiecki 52b099f6db ENH: Added new kwarg to batch_transform: create_panel. 2013-01-16 10:30:37 -05:00
Thomas Wiecki b815a57430 ENH: batch_transform now supports field filtering. 2013-01-16 10:30:37 -05:00
Thomas Wiecki b68c51afb4 ENH: batch_transform now supports sid-filtering. DOC: Added docs to batch_transform. 2013-01-16 10:30:37 -05:00
Thomas Wiecki 79a8a08812 STY: Renamed fillna to clean_nans. 2012-12-06 17:23:26 -05:00
Thomas Wiecki ecb26e9eec BUG: Can not test for length when dropping nans. 2012-12-06 16:07:18 -05:00
Thomas Wiecki ba46c6292f ENH: DataPanel is now created more flexible over all sids and all given fields. Added unittest to test for nan-filling. Added backwards filling by default. 2012-12-06 14:43:20 -05:00
Thomas Wiecki 5f6839beea BUG: Refactored batch_transform unittests and fixed some bugs. 2012-12-06 12:36:47 -05:00
Thomas Wiecki c69858f8b9 ENH: Added kwarg to turn off fillna or use different fill method. 2012-12-06 12:35:46 -05:00
Thomas Wiecki f81addb7df ENH: batch_transform now adds arbitrary keys to datapanel. 2012-12-03 13:41:37 -05:00
Eddie Hebert ab6b754922 Changes EventWindow parameter of days to window length.
The days parameter was causing confusion when explaining the
usage of the batch_transform decorator.
2012-11-20 11:52:27 -05:00
Thomas Wiecki 4c02fea6e2 BUG: batch_transform was wrongly updating when days < refresh_period. 2012-11-19 10:20:24 -05:00
Tobias Brandt ff9093d226 DOC: Fixed some paragraph alignment and table formatting issues. 2012-11-13 12:20:07 -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
Eddie Hebert 086c12ddf8 Locks down the ability to easily override the algo's portfolio.
Starting down the path of making the portfolio completely read-only
with respect to the handle_data in algo.

The portfolio should only be changed during the course of running
the algorithm by the simulator.

This doesn't do a 100% protection, i.e. an algo could use _portfolio,
or the set_attr property, but hoping this helps guides algo writing
to treat the portfolio as read-only.
2012-11-05 13:40:23 -05:00
Thomas Wiecki 15ac658024 Restructured file hierarchy. Transforms now live in transforms (transform.py is now transforms/utils.py). Sources are in sources.py. VWAP is now MovingVWAP. 2012-10-19 18:10:51 -04:00
fawce 96fed05fc0 support for test fixes in qexec 2012-10-10 16:09:40 -04:00
fawce 16b0d71506 refactoring of algorithm to make it work for both batch style run method, and generator style consumption. removed the portfolio property from the data parameter. added set_slippage and set_commission methods to algorithm. removed timeout tracking. 2012-10-10 16:06:32 -04:00
Eddie Hebert 9500163ed8 Adds Apache 2.0 license header to source files. 2012-10-08 17:32:41 -04:00
Eddie Hebert 77af1ca632 Applies PEP-8 and pyflakes style to tests and zipline.
Mostly whitespace, line width and other spacing changes.
Also, removes use of deprecated has_key in favor of `in`

Going forward new patches should pass running `flake8` before
submission.
2012-10-05 12:14:09 -04:00
fawce 7a8697f0e5 updated based on PR feedback. 2012-09-30 22:12:00 -04:00
fawce 1caefbff43 tests are passing for independent commission model 2012-09-28 23:12:41 -04:00
Thomas Wiecki 188a9502b0 Added passing of arguments to algorithm initialize and batch transform. 2012-09-25 11:48:37 -04:00
Thomas Wiecki 4324f95f36 Better unittest coverage. DataFrameSource is now filtering sids. Fixed outstanding issues. 2012-09-21 11:59:46 -04:00
Thomas Wiecki 4526cde4c5 Fixed weird regression in TestAlgorithm. 2012-09-19 19:37:21 -04:00
Thomas Wiecki 280f122353 WIP: Lot of refactoring and bugfixing. 2012-09-17 18:35:21 -04:00
Thomas Wiecki 5d00099243 example code now retrieves data from yahoo finance. 2012-09-17 12:15:36 -04:00
fawce 0bb0df525a pluggable slippage. 2012-09-14 12:33:10 -04:00
fawce 1f55e8a033 added exception handling tests back. updates to support integration. 2012-09-10 23:06:13 -04:00
Thomas Wiecki 7c0329bb76 Resolved conflicts 2012-08-23 10:54:02 -04:00
scottsanderson 57f1c6056c unit test for heartbeating 2012-08-20 18:24:17 -04:00
scottsanderson 69ac68af2e heartbeating for handle_data 2012-08-19 02:22:16 -04:00
Thomas Wiecki 51f01c0f1f ENH: Implemented new Zipline interface. Implemented Algorithm base class. Implemented example algorithm. Implemented example.py code. 2012-08-10 17:23:08 -04:00
fawce e4a21e7c61 resolved conflicts 2012-08-01 11:04:35 -04:00
fawce 08cce15ef9 added name and message to exception message 2012-07-31 16:02:28 -04:00
fawce 80f2acc674 test fixes 2012-07-27 23:33:43 -04:00
fawce abf9c8efa5 exception handling code revised. gevent, pypy, and threadsim vestiges removed.
devel flag removed.
2012-07-26 16:22:13 -04:00