Commit Graph

19 Commits

Author SHA1 Message Date
jfkirk 88495ce9b7 MAINT: Batch transform uses get_algo_instance 2015-09-18 14:17:53 -04:00
jfkirk dc964a7e7d MAINT: Removes the ability to reference a global TradingEnvironment
This commit removes the ability to reference a shared TradingEnvironment through the zipline.finance.trading module. In place, the classes that require a TradingEnvironment, or its child AssetFinder, contain their own references to those objects.

This commit also adds serialization utilities that allow for the pickling/unpickling of objects without unintentionally their TradingEnvironments or AssetFinders.
2015-09-10 11:53:28 -04:00
Eddie Hebert 314b22656f MAINT: Remove left over simple transform code.
Remove pieces that are no longer used now that the simple transforms are
wrappers around history via the SIDData object.

Move window length related pieces into batch_transform, since the rest
of the utils module is no longer used.
2015-03-30 14:18:39 -04: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
Scott Sanderson 235954d480 DEV: Overhaul core history logic.
Overhaul the core HistoryContainer logic to be more robust to changing
universes.

Major Changes
-------------
* Remove `return_frame` cache.  The original purpose of using
  return_frames was to avoid having to create new DataFrames on each
  iteration of handle_data, but we ended up having to copy the return
  frames anyway because user code could mutate the frames in place.
  Removing the return_frames reduces unnecessary copying, and reduces
  the logic of `get_history` to just forward-filling and concatenating
  two DataFrames.

* Use a `MultiIndex`ed DataFrame to represent
  `last_known_prior_values`.  This makes lookups faster and greatly
  simplifies the logic of adding and dropping sids.

* HistoryContainer no longer attempts to determine its universe based on
  the contents of its internal buffers.  The TradingAlgorithm
  controlling the container is now responsible for explicitly calling
  `add_sids` or `drop_sids` when securities enter or leave the
  algorithm's universe.  These methods, along with the internal
  `_realign` method, provide a clean interface for changing the universe
  of securities managed by the container.

* Refactor index mutation logic in `RollingPanel` into a
  `MutableIndexRollingPanel` subclass.  Maintenance of the old behavior
  is regrettably necessary to support `BatchTransform`.

* Refactor shared logic from `roll` and `get_history` into a single
  `aggregate_ohlcv_panel` method that's responsible for collapsing an
  OHLCV buffer into a frame.
2014-09-29 14:42:57 -04:00
twiecki 4bdecd6402 STY: PEP8 fixes. 2014-03-26 20:46:20 +09:00
Eddie Hebert a203f69635 PERF: Remove alias_dt transform in favor of property on SIDData.
Adding a copy of the Event's dt field as datetime via the
`alias_dt` generator, so that the API was forgiving and allowed
both datetime and dt on a SIDData object, was creating noticeable
overhead, even on an noop algorithms.

Instead of incurring the cost of copying the datetime value and
assigning it to the Event object on every event that is passed
through the system, add a property to SIDData which acts as an
alias `datetime` to `dt`.

Eventually support for `data['foo'].datetime` may be removed,
and could be considered deprecated.
2014-03-07 10:55:59 -05: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
Eddie Hebert b4959e46cf MAINT: Use six for Python 3 compatible names and behavior.
Use the six module to import functions and types that are
consistent between Python 2 and 3, so that one code base can
support both versions.

- Use integer types instead of int and long.
- Use string_types instead of basestring.
- Account for iteritems, itervalues, iterkeys.
- Use six.moves for filter and zip, reduce
- Use compatible bytes for md5 hasher.
- xrange and range
2014-01-07 11:33:50 -05:00
Eddie Hebert f2dc979fbc BUG: Make all iteration related methods fo BarData match __iter__
`for s in data` and methods like `for s in data.keys` were not producing
the same list of active sids

Make the other iteration methods match __iter__ by using the contains
method to check whether or not the sid is active.

For use of data outside of the algoscript context, which needs access
to all data fields use data._data
2013-12-20 00:05:53 -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
fawce 279605dfb5 BUG: Fix excessive recalcuations in batch.
Downsampled batch transforms should only recalcuate on close
2013-10-20 08:06:39 -04:00
fawce 76887e2855 BUG: Fix non-trading advancement of trading day count and downsample.
Add a guard so that we do not advance trading day count or downsample
on non-trading days.
2013-10-18 14:07:49 -04:00
fawce 0ceabb590b BUG: Group and aggregate downsampling by trading day.
Otherwise, out of market events would result in a mishaped
panel.
2013-10-17 22:41:20 -04:00
fawce 3a1ca1ddb2 BUG: Mask of batch_transform columns to match keys in data parameter.
The underlying RollingPanel in batch_transform was always accumulating
all values to ever appear in data.

However, at any given algo time the desired return value is what the
current active sids are.

Instead, mask down to the sids that are passed in as the data parameter.
2013-10-16 15:16:03 -04:00
Eddie Hebert 0224aeb552 MAINT: Use enviroment normalize_date instead of dt.replace
Continue path of removing scattered calls to dt.replace.
2013-10-16 15:14:24 -04:00
fawce f8ce7d944b ENH: Add downsampling to BatchTransform.
So that with minute data, 2.5 orders of magnitude of data can
be cut, allowing for longer window_lenghts, when the daily
values are what are desired for a signal.
2013-10-11 16:48:08 -04:00
Eddie Hebert ddb541b9b3 MAINT: Change shape of supplemental data to match batch data.
Expect the same shape of data for the supplemental data, to make
working and preparing with the supplemental data consistent with
what is passed to the algorithm.
2013-09-16 11:51:22 -04:00
Eddie Hebert fa845cbf03 MAINT: Move batch transform into a dedicated module.
Break the BatchTransform class and decorator function into a
separate module, with hope that it makes it easier to zero in on
batch transform logic.
2013-07-10 17:56:32 -04:00