Commit Graph

182 Commits

Author SHA1 Message Date
John Ricklefs 1f859d34e5 MAINT: Add additional fields to __getitem__ for Order (#1483)
These were previously available like the others.
2016-09-13 15:49:16 -04:00
Joe Jevnik 863e2ffbea ENH: improve warning for protocol getitem 2016-09-06 15:11:43 -04:00
Joe Jevnik b66d9ae976 DEV: update copyright in protocol.py (added code) 2016-09-06 12:42:06 -04:00
Joe Jevnik 631984e1f5 ENH: just deprecate __getitem__, don't remove 2016-09-06 12:39:29 -04:00
Joe Jevnik fcde54297c MAINT: remove __getitem__ as alias of __getattr__ 2016-08-31 12:38:20 -04:00
Andrew Liang fdf8cdcd68 BUG: Account object missing initial total_positions_exposure attr 2016-07-25 10:05:47 -04:00
Andrew Liang 4ffe04e4a5 FIX: Add last_sale_date to Position init for consistency 2016-04-26 16:13:07 -04:00
Andrew Liang d69b960c49 BUG: Don't save empty positions when user access non-existent position
Previously, whenever we try to access a missing value on the Positions
dict, we return a default Position and save it to the dict. Instead,
just return the Position
2016-04-26 13:28:35 -04:00
Richard Frank 70befd490b MAINT: Don't store data portal everywhere
Removed lots of data portal references that participated in ref cycles
and prevented deterministic cleanup of dbs.
2016-04-12 19:33:22 -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 ede1eb7aa0 PERF: Look up expired futures from in-memory Futures
instead of queries to the db.
2016-02-04 18:55:34 -05:00
Scott Sanderson 8220d1ee86 ENH: Adds support for different typed adjusted arrays and adds an
EarningsCalendar loader.

- Moves most of AdjustedArray back into Python. The window iterator is
  the only part that's performance-intensive.

- Adds a bootleg templating system for creating specialized versions of
  AdjustedArrayWindow for each concrete type we care about.

- Adds support for differently dtyped terms in pipeline. This allows us
  to use datetime64s which are needed in the EarningsCalendar.

- Adds EarningsCalendar dataset for the next and previous earnings
  announcements in pipeline.

- Adds in memory loader for EarningsCalendar.

- Adds blaze loader for EarningsCalendar.
2015-12-08 20:24:06 -05:00
llllllllll e9376453f4 BUG: the simple transform caching caused the length of the siddata object to change which would mark it as not-empty 2015-11-10 12:03:46 -05:00
Scott Sanderson 8e59d12daf ENH: Pipeline API
- Adds `zipline.pipeline.Pipeline`, a new user-facing class for managing
  pipelines of Modeling API expressions.

- Adds `attach_pipeline` and `drain_pipeline` as API methods

- Removes `add_factor` and `add_filter` as API methods.  These have been
  replaced two new methods on `Pipeline`: `add`, and `apply_screen`.

- Adding a `Filter` as a column no longer implicitly truncates rows from
  the Modelling API output.  It simply causes a new column, of dtype
  `bool` to show up in the output. Removal of rows is now handled by the
  new `apply_screen` method of `Pipeline`.

- Refactors the existing Modeling API tests to reflect the new APIs.
2015-10-01 18:03:53 -04:00
Scott Sanderson 26fd6fda8b ENH/BUG: Modeling API enhancements.
- Fixes an error where Modeling API data known as of the close of `day
  N` would be shown to algorithms during `before_trading_start` as of
  the close of the same day.  Algorithms should now only receive data
  during `before_trading_start/handle_data` that was known as of the
  simulation time at which the function would be called.

- All Term instances now have a `mask` attribute that must be a `Filter`
  or an instance of `AssetExists()`.  `mask` can be used to specify that
  a Factor should be computed in a manner that ignores the values that
  were not `True` in the mask.

- Changed the interface for `FFCLoader.load_adjusted_array` and
  `Term._compute` from `(columns, mask)`, with mask as a DataFrame, to
  `(columns, dates, assets, mask)`, where mask is a numpy array.  This
  is primarily to avoid having to reconstruct extra DataFrames when
  using masks produced by non `AssetExists` filters.

- Adds `BoundColumn.latest`, which gives the most-recently-known value
  of a column.
2015-09-16 01:47:11 -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
Scott Sanderson ef4f642e62 ENH: Compute engine architecture for FFC API.
This patch lays the groundwork for a compute engine designed to
facilitate construction of factor-based universe screening and portfolio
allocation.  It contains:

A new module, `zipline.modelling`, containing entities that can be used
to express computations as dependency graphs.  Each node in such a graph
is an instance of the base `Term` class, defined in
`zipline.modelling.term`.  Dependency graphs are executed by instances
of `FFCEngine`, defined in `zipline.modelling.engine`.

A new module, `zipline.data.ffc`, containing loaders and dataset
definitions for inputs to the modelling API.

New `TradingAlgorithm` api methods: `add_factor`, and `add_filter`.
These methods can only be called from `initialize`, and are used to
inform the algorithm that each day it should compute the given terms.
Computed factor results are made available through a new attribute of
the `data` object in `before_trading_start` and `handle_data`.  Computed
filter results control which assets are available in the factor matrix
on each day.
2015-07-29 12:30:46 -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
warren-oneill 44fbdff4ac added CLOSE_POSITION as source type, added pt.close_position_event(), added process_close_postion(), added close processing to tradesimulation, added unittest for close_position_event 2015-06-04 14:23:46 +02:00
Delaney Granizo-Mackenzie a2bc6dd1f5 BUG: Fixed bug with returning non-primitive dicts. 2015-03-04 17:47:48 -05:00
Delaney Granizo-Mackenzie 8b3fce94a3 MAINT: Refactored serialization parent class out.
Previously the class SerializeableZiplineObject was used to
house basic __setstate__ and __getstate__ methods. It wasn't
really doing much that was helpful, so it is now gone.
2015-03-04 14:17:13 -05:00
Delaney Granizo-Mackenzie 0fd1efff5f BUG: Updated some bugs in serialization.
The state dictionaries weren't being copied, so the state version
label was being injected into the original object.
2015-03-04 14:17:13 -05:00
Delaney Granizo-Mackenzie c6596e2ee2 ENH: Added versioning logic to objects.
In order to be able to load from saved state generated by old
code, we need to have a notion of the version of the saved state.
2015-03-04 14:17:12 -05:00
Delaney Granizo-Mackenzie 64eed84bff MAINT: Added pickle protocol methods into zipline.
Added pickle support to many zipline methods. This will enable
them to be serialized.
2015-03-04 14:17:12 -05:00
Dale Jung 4d1437cf5c PRF: Normalize the history requested for SIDData rolling transforms. 2015-03-03 15:21:19 -05:00
Dale Jung 4c5cb867db PRF: Sped up the SIDData transforms by using raw values. Also fixed a
vwap zero division error.
2015-03-03 15:21:19 -05:00
fawce 3d4d3d0c2b adding gross leverage to the perf packet. 2014-12-19 11:31:59 -05:00
Joe Jevnik aac87ada5d BUG: Ensure that the bar count is an integer in minutely mode simple
transforms

total_seconds can return a float, which when divided by `60` would
still yield a float causing a value error when passed to range.
2014-11-18 11:25:23 -05:00
Joe Jevnik a2fb729c00 DOC: Updates the comments around the caching in siddata 2014-11-17 13:16:30 -05: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
Delaney Granizo-Mackenzie 1c08f60f7c MAINT: Updated the naming scheme from reconstruct to set_state 2014-10-29 14:30:26 -04:00
Delaney Granizo-Mackenzie 589c014f73 ENH: Updated naming scheme of serialization methods. 2014-10-29 14:15:04 -04:00
Brian Fink 677f5ecde0 BUG: Hide account methods from repr 2014-10-29 13:41:15 -04:00
Brian Fink 287023498e BUG: Fix flake8 2014-10-28 22:10:28 -04:00
Brian Fink 93296d7ef5 ENH: Add serialization to account 2014-10-28 21:54:14 -04:00
Scott Sanderson 7104725e3c DEV: Cleanup from PR comments.
Flip axes of numpy array in frame_from_bardata.
Add default=None to SidData.get.
2014-10-17 11:55:30 -04:00
Scott Sanderson 30c4a1a1dc PERF: Optimized rewrite of HistoryContainer.update.
Uses a numpy array instead of a dict of dicts when initializing history
container.

In testing this reduced the total time spent in HistoryContainer.update
by 66%.

BEFORE COMMIT:
Thu Oct 16 22:30:46 2014    results/cprofile/unoptimized

         185223320 function calls (182210491 primitive calls) in 401.351
         seconds

   Ordered by: cumulative time
   List reduced from 2398 to 27 due to restriction <'update'>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     8580    0.461    0.000  160.571    0.019
     qexec/zipline/history/history_container.py:388(update)

AFTER COMMIT:
Thu Oct 16 22:12:28 2014    results/cprofile/optimized

         143177181 function calls (140164352 primitive calls) in 272.403
         seconds

   Ordered by: cumulative time
   List reduced from 2395 to 27 due to restriction <'update'>

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     8580    0.086    0.000   47.294    0.006 qexec/zipline/history/history_container.py:388(update)
2014-10-16 22:32:43 -04:00
Brian Fink 50c5b73a7b add account object to context 2014-10-10 17:10:45 -04:00
Scott Sanderson 1b2d79988f BUG: Fix exception when comparing Event to object with no __dict__.
In particular don't throw an exception on comparison to `None`.
2014-09-02 20:42:49 -04:00
Scott Sanderson d610ea0a3b DOC: Rename 'guid' to 'id' in dividend tracking logic. 2014-07-18 15:04:20 -04:00
Scott Sanderson 4712891e88 ENH: Remove dividends from the event stream.
Removes support for handling dividends as part of the algorithm
simulation stream, replacing it with an API in `TradingAlgorithm` for
supplying dividends as a DataFrame.
2014-07-18 15:04:20 -04:00
Scott Sanderson cfe00b0c37 ENH/TEST: Enable '1m' history and add tests for the frequency. 2014-06-05 15:25:49 -04:00
Scott Sanderson de3be983ad BUG: BarData.values() no longer causes in an infinite loop on Python 3. 2014-06-05 15:14:26 -04:00
David Edwards c045f3a868 MAINT: deleted duplicate attribute in Portfolio
Deleted duplicate of Portfolio.portfolio_value in zipline.protocol. It
was defined on line 75 and line 82.
2014-05-13 10:17:50 -04: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 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
Richard Frank 2cc9cab17f MAINT: Initialize Portfolio object with default values for attributes
instead of no attributes at all
2013-12-20 17:11:53 -05:00
Eddie Hebert 457ac2630c BUG: Make BarData iterkeys method match dict iterkeys behavior.
Use a generator, instead of creating a list.
2013-12-20 12:41:51 -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
Thomas Wiecki 5f4d8817e8 ENH: Add len() functionality to BarData. 2013-12-03 16:29:17 -05:00