Commit Graph

1338 Commits

Author SHA1 Message Date
Thomas Wiecki fd9bbbebfa Fix for stddev during merging. 2013-01-16 11:53:35 -05:00
Thomas Wiecki 77e9147a8b Merge branch 'master' of github.com:quantopian/zipline into stddev_multifield 2013-01-16 11:42:11 -05:00
Elektra58 d0640d56c8 Refactored stdev transform to be applied to multiple fields, not just price
UnitTest for transforms refactored to account for changed stdev transform, introduced AssertAlmostEqual
2013-01-16 10:33:38 -05:00
Eddie Hebert a2b1b1b71e Uses vdot and numpy arrays for position totals.
Gets almost 100x speed up over iterating over the values and
summing up the values in Python.

Farms out the work to numpy and atlas by using the vector dot
product of the amounts and last sale prices.

Adds some wiring of keeping track of an index into the numpy arrays
for each position, so that value can be overwritten as events update
those amounts and sale prices.
2013-01-16 10:30:38 -05:00
Eddie Hebert c044648275 Rolls over existing PerformancePeriod.
Instead of doing the rollover by creating a new PerformancePeriod,
introduces a `rollover` method that resets the values that need
to be fresh in a new period, and moves the ending values to starting
values, and leaves positions intact.

This isn't a major runtime improvement in of itself, but it does
allow us to more easily keep track of position values from period
to period, which other improvements will use.
2013-01-16 10:30:38 -05:00
Jonathan Kamens 61773a2ebe Upgrade requests module to 1.1.0 2013-01-16 10:30:38 -05:00
Eddie Hebert a3235bb1a5 Recycles objects for positions.
Instead of creating a new ndict for each position on every event,
we change the values in the object that held the previous position.

The creation of new objects on each event was incurring too much
overhead.

Changes the position type returned by performance module.

For improved speed, changes from ndict to a simple Python object,
since the cost of setting ndict values is too expensive for the
number of times that positions are returned.

Also, changes the containing type of the positions to be dictionary
with the __missing__ overloaded, instead of the ndict that had that
behavior, to reduce the penalty of using ndicts.
2013-01-16 10:30:38 -05:00
Eddie Hebert a889f814fc Recycles the portfolio container to be passed to handle_data.
The creation of a new portfolio ndict on each call of handle_data
was creating a very high performance overhead.

Instead, we use the same the portfolio object for each event,
and replace the values contained within.
2013-01-16 10:30:38 -05:00
Eddie Hebert 48dba943db Uses a Portfolio object instead of an ndict.
Gains some performance by using a 'regular' object instead of
an ndict.

Also, directly sets up the values that we return, instead of going in
between with __core_dict and then removing values.

In it's entirety performanc.as_portfolio is the current
highest bottleneck, working on reducing time spent in that function.
2013-01-16 10:30:38 -05:00
Thomas Wiecki 0ecdac83f4 DOC: Typo. 2013-01-16 10:30:38 -05:00
Thomas Wiecki abf482c2a6 MIN: Changed isinstance check to allow more types. 2013-01-16 10:30:38 -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 a63d4bca28 ENH: sid and field filter kwargs can also be strings or ints. 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
Eddie Hebert 018ac67966 Uses vdot and numpy arrays for position totals.
Gets almost 100x speed up over iterating over the values and
summing up the values in Python.

Farms out the work to numpy and atlas by using the vector dot
product of the amounts and last sale prices.

Adds some wiring of keeping track of an index into the numpy arrays
for each position, so that value can be overwritten as events update
those amounts and sale prices.
2013-01-14 21:47:14 -05:00
Eddie Hebert e7405d04ad Rolls over existing PerformancePeriod.
Instead of doing the rollover by creating a new PerformancePeriod,
introduces a `rollover` method that resets the values that need
to be fresh in a new period, and moves the ending values to starting
values, and leaves positions intact.

This isn't a major runtime improvement in of itself, but it does
allow us to more easily keep track of position values from period
to period, which other improvements will use.
2013-01-14 21:47:13 -05:00
Jonathan Kamens 3227ba49a4 Upgrade requests module to 1.1.0 2013-01-14 11:05:58 -05:00
Eddie Hebert fc031f9c39 Merge pull request #58 from quantopian/placeholder-object-in-performance-inner-loop
Recycles objects for portfolio and positions.
2013-01-12 13:57:01 -08:00
Eddie Hebert 34d577d3d7 Recycles objects for positions.
Instead of creating a new ndict for each position on every event,
we change the values in the object that held the previous position.

The creation of new objects on each event was incurring too much
overhead.

Changes the position type returned by performance module.

For improved speed, changes from ndict to a simple Python object,
since the cost of setting ndict values is too expensive for the
number of times that positions are returned.

Also, changes the containing type of the positions to be dictionary
with the __missing__ overloaded, instead of the ndict that had that
behavior, to reduce the penalty of using ndicts.
2013-01-12 15:37:18 -05:00
Eddie Hebert 1ddfadf5b4 Recycles the portfolio container to be passed to handle_data.
The creation of a new portfolio ndict on each call of handle_data
was creating a very high performance overhead.

Instead, we use the same the portfolio object for each event,
and replace the values contained within.
2013-01-12 15:35:49 -05:00
Eddie Hebert ca9fdcfe84 Uses a Portfolio object instead of an ndict.
Gains some performance by using a 'regular' object instead of
an ndict.

Also, directly sets up the values that we return, instead of going in
between with __core_dict and then removing values.

In it's entirety performanc.as_portfolio is the current
highest bottleneck, working on reducing time spent in that function.
2013-01-11 14:50:00 -05:00
Eddie Hebert df18dd1682 Merge pull request #54 from quantopian/enhance_batch_full_panel
Enhance batch full panel
2013-01-07 12:13:31 -08:00
Thomas Wiecki bf2e8e3586 DOC: Typo. 2013-01-07 13:26:27 -05:00
Richard Frank 471521f305 Merge pull request #53 from quantopian/performance-improvements-sorting-and-done-message
Performance improvements sorting and done message
2013-01-07 10:13:09 -08:00
Eddie Hebert ee02ff6445 Adds _ prefix to decorate_source to imply internal usage. 2013-01-07 13:03:12 -05:00
Thomas Wiecki 48b05397e2 MIN: Changed isinstance check to allow more types. 2013-01-07 12:50:52 -05:00
Thomas Wiecki 0f88e4133d ENH: New batch_transform feature: compute_only_full. 2013-01-07 12:44:55 -05:00
Thomas Wiecki d1dace948e ENH: Added new kwarg to batch_transform: create_panel. 2013-01-07 12:44:19 -05:00
Thomas Wiecki 5deeb38fb6 ENH: sid and field filter kwargs can also be strings or ints. 2013-01-07 12:44:00 -05:00
Thomas Wiecki 2729936aff ENH: batch_transform now supports field filtering. 2013-01-07 12:43:41 -05:00
Thomas Wiecki 0e3b1e76e8 ENH: batch_transform now supports sid-filtering. DOC: Added docs to batch_transform. 2013-01-07 12:43:26 -05:00
Eddie Hebert fc03e80cdf Removes done message.
Instead of checking for 'DONE' on each call uses generators
builtin StopIteration for signalling the end of input.
2013-01-07 12:06:31 -05:00
Eddie Hebert e7a31c0661 Removes sort module.
Sort module is now unneeded with use of heapq.merge

Also adapts test_perf_tracking so that it uses date_sorted_sources.
2013-01-07 12:06:10 -05:00
Eddie Hebert 13a2b1c637 Changes date_sort to use heapq module.
Uses heapq.merge to sort input from mulitple sources instead of
our own sort module.

From profiling heapq.merge is more efficient than our own efforts.
2013-01-07 12:03:50 -05:00
Eddie Hebert 0d841503a7 Uses dictionary update instead of iterating through keys.
update_universe is a bottleneck on large data sets.

A large portion of that bottleneck is the call to getitem while
looping over the keys, so using update while passing along the internal
__dict__

Seeing about a 40% improvement.
2013-01-06 17:31:03 -05:00
Eddie Hebert dd64bb0fbf Changes type emitted from DataSource to Event.
Moving DataSource to Event for improvements in member access
and setting.
2013-01-06 17:23:26 -05:00
Eddie Hebert 799a357d98 Changes test factory to use Event instead of ndict.
As more sources are moving off of ndict,
changing the factory to use Event, so that when testing we are
exercising use of Event.
2013-01-06 17:13:07 -05:00
Eddie Hebert 59dbffb3aa Changes test sources to use unit test's assert instead of plain assert. 2013-01-06 17:11:38 -05:00
Jonathan Kamens 27df611b8e Upgrade pytz 2013-01-04 12:45:53 -05:00
Eddie Hebert d1784b26c3 Adds an init to protocol.Event to enable setting of initial values.
So that an Event can use an initial dict to set all values,
instead of needing to set initial values one by one.

i.e. enables:

```
foo = Event({'bar': 1, 'baz': 2})
```

in favor of:

```
foo = Event()
foo.bar = 1
foo.baz = 2
```
2013-01-02 14:58:12 -05:00
Eddie Hebert a25590b0a1 Exposes the list of trading days contained in a trading environment.
Previously, the list was generated, but only used to calculate
the number of days in the environment.

With exposing this list, working towards a path where the simulation
uses the trading days to determine when to handle market closes.
2013-01-01 13:01:49 -05:00
Eddie Hebert 7b1b9887ba Removes timeout handling from simulator's simulate_snapshot.
The delta was ensuring that the backtester wouldn't exceed the
delta of a bar if it were being run against live data.

However, this extra overhead of getting the current time on each
side of the handle_data adds a penalty in pure backtest mode.

Also, it makes the backtest results potentially non-repeatable,
since it is sensitive to current conditions on a box for processing
time.

Favoring having the timeout handled by whatever is running the
zipline algorithm.
2012-12-31 18:02:11 -05:00
Eddie Hebert a71226c400 Merge pull request #49 from quantopian/granularity
Granularity
2012-12-30 09:52:06 -08:00
Thomas Wiecki fccc5e8006 ENH: Added constants.py which contains financial constants. 2012-12-30 12:02:38 -05:00
Thomas Wiecki 4615b29713 REF: Renamed granularity to data_frequency. 2012-12-30 11:50:46 -05:00
Eddie Hebert 75e60fdc91 Fixes number of bars to create covering date range in test.
There are only 6 trading days between the open and close specified
in test_perf test.

Also, removes getting the period_end off of the last trade,
since the test can now use the end date specified for the trading
environment.
2012-12-29 18:45:31 -05:00
Eddie Hebert ec745736ac Fixes period_start in test_perf test. 2012-12-28 13:48:47 -05:00
Eddie Hebert 50f4e1fff2 Fixes bug in test where period_end is too early.
Grabs period end before we remove trades.
2012-12-28 13:46:44 -05:00