Commit Graph
1694 Commits
Author SHA1 Message Date
Delaney Granizo-Mackenzie ccbc52d803 MAINT: Added license to test_serialization.py 2015-03-04 14:17:12 -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
theandycampsandBrian Fink d192b1846f MAINT: Move knowledge date for existing DNT list 2015-03-03 16:46:56 -05:00
Dale JungandEddie Hebert 4d1437cf5c PRF: Normalize the history requested for SIDData rolling transforms. 2015-03-03 15:21:19 -05:00
Dale JungandEddie Hebert 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
Dale JungandEddie Hebert 29e5f7ee86 PRF: Added nanmean, nanstd, nansum that will default to bottleneck if available 2015-03-03 15:21:19 -05:00
Eddie Hebert fd21b4697e STY: Remove unused import. 2015-03-02 11:32:46 -05:00
Eddie Hebert a64a1ee619 TST: Use pandas relativedelta for calendar end to account for leap year.
Some unit tests for test_tradingcalendar failed on 2015-03-01, because the
addition of 365 days put the end date at 2016-02-29; when the replaces
the year on that date it fails because there is no 2017-02-29.

Instead use relativedelta with a year argument which accounts for leap
years.

Fixes the following test failure:

```
======================================================================
ERROR: test_day_after_thanksgiving (tests.test_tradingcalendar.TestTradingCalendar)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/test_tradingcalendar.py", line 211, in test_day_after_thanksgiving
    tradingcalendar.end.replace(year=tradingcalendar.end.year + 1)
  File "tslib.pyx", line 297, in pandas.tslib.Timestamp.replace (pandas/tslib.c:7325)
ValueError: day is out of range for month

----------------------------------------------------------------------
Ran 1 test in 0.001s
```
2015-03-02 11:02:13 -05:00
Dale Jung 98ee8efe3d BUG: Added sorting back to orders. This isn't a functional bug so much
as it is a backwards compat. Without sorting the orders are filled by
order date. With sorting the orders are moved to back of queue after
partil fills. If all orders are fully filled, there is no
deviation. Also there is no portfolio difference as this is about
assigning fills to equivalent orders.
2015-02-27 08:19:41 -05:00
Dale JungandEddie Hebert 69815d1695 PRF: limit the subset of orders we check for bookkeeping 2015-02-27 05:06:02 -05:00
Dale JungandEddie Hebert 4c5f38d7b1 MAINT: There is no place where orders are put in out of place 2015-02-27 05:06:02 -05:00
Dale JungandEddie Hebert 7a5af8a098 ENH/PRF: Allow SlippageModels to alert that no more liquidity exists and
to stop processing orders
2015-02-27 05:06:02 -05:00
Eddie Hebert faf856a736 MAINT: Print benchmark return value to assertion message.
For when the attempted midnight fails, print more information about the
returns for debugging.
2015-02-26 13:43:15 -05:00
Dale JungandEddie Hebert e908fa9f5c BUG: Initial digest frame was set with object dtype. Older verison of
numpy can error when expecting numeric dtypes and not np.array([1,2,3],
dtype=object)
2015-02-26 11:57:34 -05:00
Eddie Hebert a0bd57555d MAINT: Provide a function to create the position calc containers.
For use in a function that wraps de-serialization, to call instead of
creating the OrderedDicts from a module outside of the object.

So that the other module does not need to the internals of this object,
also to ensure that the cythonized OrderedDict is used, when available.

This need should be superseded with serialization versioning.
2015-02-25 13:41:50 -05:00
Eddie Hebert 1054134bd9 BUG: Fix div by 0 error due to changed return type.
When calculate_positions_value used np.dot, the return type was a
np.float64. Which allows the use of 0.0 in division to not raise an
exception.

Fix by expliciting creating an np.float64 with 0 value.
2015-02-23 11:57:07 -05:00
Eddie Hebert 83b0e51b59 BUG: Fix missed cache invalidations on assignment.
_position_values needs to be invalidated on every assignment.
2015-02-23 11:57:07 -05:00
Eddie Hebert eda323dcd4 ENH: Performance period compatibility with internal serialization.
Add a set_positions method so that the serialization process can rebuild
from just the positions, since the last_sale and amounts are derivable
from those values.

Also, use the private naming convention for last sale price and amount
members, so that those members are ignored by the serialization process.
2015-02-23 11:57:07 -05:00
Dale JungandEddie Hebert 25c762138e PERF: Use cached list of price and volume value.
Reduce the number of times the multiplication is done for the
position values to once per bar.
2015-02-23 11:57:07 -05:00
Dale JungandEddie Hebert 913fbb0568 PERF: Replaced use of a pandas.Series for dict-like duties to a cython
based OrderedDict. Series/ndarray can only be sped up so much because
they weren't designed for fast iterative mutations.

This also cut down on the # of intermediate Series being generated
during perf stat generation. Things like s[s > 0] will create a new
Series for s > 0.

Moved cython to requirements.txt and added cyordereddict
2015-02-23 11:57:07 -05:00
Delaney Granizo-Mackenzie 68c41eab1c Merge pull request #470 from quantopian/remove-overnight-minutes
BUG: Changed benchmark returns to only contain market minutes.
2015-02-19 12:29:28 -05:00
Dale JungandEddie Hebert b3bc7e166d BUG: Remove sid entry from open_orders when there are none.
TST: updated tests for new open_orders behavior
2015-02-19 11:22:54 -05:00
Delaney Granizo-Mackenzie 2853830264 BUG: Changed benchmark returns to only contain market minutes.
The series was being generated as all minutes between two times.
It should be only the trading minutes.
2015-02-18 16:42:26 -05:00
Thomas Wiecki 760bbced73 Revert "ENH Allow order_percent to work with various market values"
This reverts commit dd37a49f2f as it lead to different algo behavior we have to investigate first.
2015-02-17 20:27:59 +01:00
Joe Jevnik fdf4e9b737 PERF: Makes get_datetime not make a copy.
datetime.datetime objects are immutable.
2015-02-17 11:50:20 -05:00
Thomas Wiecki 21c23c324d Bump version: 0.8.0 → 0.8.0rc1 2015-02-13 17:53:02 +01:00
Scott SandersonandThomas Wiecki 357f1a88a4 BUG: Remove Pokemon exception handling.
This was masking real errors that were occurring during registration of
cell magic.
2015-02-13 10:11:27 +01:00
Eddie Hebert 7059ba1e6a PERF: Avoid using attribute access in inner event processing.
Reduce overhead of the attribute access of grabbing the process_event
and process_trade from both the algorithm object and the perf_tracekr or
blotter, by assigning those functions to a variable once per snapshot.
2015-02-12 16:14:09 -05:00
Thomas Wiecki 439f404bed MAINT Increase default volume from 1000 to 1e9
For more discussion see https://github.com/quantopian/zipline/pull/485.

Basically, 1000 is just a number that was supposed to be high enough if no volume was available. It turns out that number is actually very low so now we are increasing it so that volume restrictions should no matter. 1e9 of shares ought to be enough for anybody ;).

Thanks to @jlowin for pointing that out.
2015-02-12 16:42:52 +01:00
Jeremiah LowinandThomas Wiecki dd37a49f2f ENH Allow order_percent to work with various market values
Currently, `order_percent()` and `order_target_percent()` both operate as a percentage of `self.portfolio.portfolio_value`. This PR lets them operate as percentages of other important MVs.

(also adds `context.get_market_value()`, which enables this functionality)

For example:
```python
order_percent('AAPL', 0.5)

order_percent('AAPL', 0.5, percent_of='cash')

order_target_percent('MSFT', 0.1, percent_of='shorts')

tech_stocks = ('AAPL', 'MSFT', 'GOOGL')
tech_filter = lambda p: p.sid in tech_stocks
for stock in tech_stocks:
    order_target_percent(stock, 1/3, percent_of_fn=tech_filter)
```
2015-02-12 14:15:20 +01:00
Dale JungandEddie Hebert 38e8d5214d PERF: History Perf Enhancements
Limited use of `pandas` data structures in both `HistoryContainer` and
`RollingPanel`. Where possible, methods were amended to return raw
`ndarrays` with the indexing logic done separately. This allows us to
cut down the number of times pandas objects are created both as returns
and intermediate values. The separation of indexing from data access
allowed us to minimize the times we’d make use of pandas indexes.

This required that that certain methods like `NDFrame.ffill` be replaced
with versions that work with `ndarrays`. Some of this was done via
straight numpy methods and others by access pandas internal
machinery. Outside of allowing us to use faster ndarrays, many of these
function provided speedups over their pandas counterparts as we didn’t
require the extra features like handling multiple dtypes. i.e. np.isnan
is faster than pd.isnull, but only works with certain dtypes.
2015-02-11 06:25:53 -05:00
Dale JungandEddie Hebert 33cef17396 PERF: make next_window_start faster 2015-02-10 16:34:32 -05:00
Thomas Wiecki a7188187e6 DEV Add preemptive check that benchmark return exists. 2015-02-10 14:54:52 +01:00
fawce 233bf3080d security list type is a class level property now 2015-02-09 13:32:01 -05:00
fawce 67da7ca7a3 import statement cleanup 2015-02-09 12:54:50 -05:00
fawce e3b21835f3 name changed to protect the innocent 2015-02-09 12:27:30 -05:00
fawce 1c2560a1fa added cutpoint for overriding SecurityList implementation. 2015-02-09 12:23:46 -05:00
fawce 412baa3c3f fixed catastrophic bug in load_from_directory
and added a new test case
was not iterating over lookup date directory names, and
therefore mising all by one list of stocks.
discovered because of differing sort orders between
my local machine, other devs, and travis ci.
2015-02-05 13:57:41 -05:00
fawce 08a0d1b604 python 3.3 compatible iterators 2015-02-05 13:57:40 -05:00
fawce 1ab082102a first edition of leveraged etf list 2015-02-05 13:57:28 -05:00
fawce 536ace94b8 new security list class
and tests
2015-02-05 13:57:27 -05:00
fawce 909b412e9b modified do not order guard to take an iteratble or a container
container allows for dynamic restrictions, necessary for a
point in time implementation of the restricted list.
2015-02-05 13:56:46 -05:00
fawce 52f78fcbc7 restricted list trading control added. 2015-02-05 13:56:45 -05:00
Eddie Hebert 4255016747 PERF: Add a wrapper around Series to speed up perf tracker bottleneck.
Alleviates bottleneck caused re-indexing into a pd.Series during a tight
loop, by keeping track of the index value into the underlying `.values`
in a lookup table.

Based on suggestion from @dalejung
2015-02-03 12:57:32 -05:00
Thomas Wiecki c734f23102 BUG: kwargs.pop() requires default argument. 2015-02-03 12:20:45 +01:00
Thomas Wiecki 9bdc2c8734 BUG: Support algo_filename being None. Fixes #480. 2015-02-03 11:36:00 +01:00
fawce 9ccb2c571f added cumulative risk measures to the
datapanel produced from perf frames.
2015-01-22 22:31:40 -05:00
fawce ec055b62bc Merge pull request #464 from quantopian/expand_perf_packet
adding net leverage, long/short exposure, long/short position count
2015-01-08 17:33:22 -05:00
fawce 7ed5461f8f de-linting 2015-01-07 21:47:01 -05:00