Commit Graph

2470 Commits

Author SHA1 Message Date
Jonathan Kamens 6cd2f4f1f2 TEST: Update Security class unit tests for Python3 compatibility 2015-03-12 10:32:26 -04:00
Jonathan Kamens e19f02a2ec BUG: Handle all possible types of Security object __richcmp__ args
A cython __richcmp__ function isn't allowed to assume that its first
argument is the same as the type of the class to which it belongs, so
our code needs to account for either of its two arguments being of the
wrong type.

Furthermore, the correct way for __richcmp__ to handle when it doesn't
know how to do a comparison is to return NotImplemented.
2015-03-10 20:36:52 -04:00
Jonathan Kamens c46a3afa3c BUG: Don't download benchmarks / treasury curves unnecessary
Fix an off-by-one error which was causing us to download the benchmark
and treasury curves over and over again even when they weren't needed.
2015-03-08 09:31:50 -04:00
Jonathan Kamens aa585b1cf8 BUG: Fix Python 3 support for Cythonized Security object
Python 3 for some reason doesn't like usage of the cmp() built-in, so
instead of using cmp(), just subtract the two ints being compared.

In addition to making this work with Python 3, it should also be more
performant since it no longer requires calling the cmp() method.
2015-03-08 09:31:50 -04:00
Jonathan Kamens 716bdbb7cd BUG: Fix >= comparison for Cythonized Security object
The >= comparison for the Cythonized Security object was actually
doing <=. Fix this and add unit tests for all the Security object rich
comparison operators.
2015-03-08 09:31:50 -04:00
Thomas Wiecki 16a88557f4 BLD Add cython as a conda build dependency. 2015-03-06 14:53:25 +01:00
Delaney Granizo-Mackenzie c49b00e9a1 Merge pull request #510 from quantopian/move-serialization-methods-into-zipline
MAINT: Added pickle protocol methods into zipline.
2015-03-05 15:06:54 -05:00
Delaney Granizo-Mackenzie f6f69e9106 MAINT: Updated iteritems for python3 compatibility 2015-03-05 14:05:24 -05:00
Delaney Granizo-Mackenzie b095f09472 MAINT: Added pandas version check to version testing
Now version testing will only be run if the pandas version is
current. This is to allow the test matrix to pass on travis.
The version must be updated in file whenever pandas is upgraded.
2015-03-05 11:47:57 -05:00
Delaney Granizo-Mackenzie a2bc6dd1f5 BUG: Fixed bug with returning non-primitive dicts. 2015-03-04 17:47:48 -05:00
Delaney Granizo-Mackenzie 51677ea700 ENH: Added Dale's verbose serialization error tracking.
Thanks, Dale.
2015-03-04 17:18:29 -05:00
Delaney Granizo-Mackenzie fd0f07aab9 MAINT: Added new sample saved state. 2015-03-04 16:28:36 -05:00
Delaney Granizo-Mackenzie f9afb132e3 BUG: Fixed bugs in the file paths to the sample saved state. 2015-03-04 15:57:59 -05:00
jfkirk 0375b350b8 ENH: Adds Security cython class in new package 'zipline.assets'
The class is not yet used. Adding this class is part of the effort to allow Zipline
simulation of more types of assets than stocks.

DEV: Adds build_ext to .travis.yml
2015-03-04 14:19:29 -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 1f69126854 ENH: Added testing for versioning of serialized state. 2015-03-04 14:17:13 -05:00
Delaney Granizo-Mackenzie 5c756a84c5 ENH: Added tests for pickling zipline objects. 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 b2ee0e179e MAINT: Added script to generate new sample saved state.
This will be used for testing versioning. By having saved state
generated by each code version, we can ensure that the version
logic is correct.
2015-03-04 14:17:12 -05:00
Delaney Granizo-Mackenzie 0f0b97e5ac MAINT: Refactored testing code. 2015-03-04 14:17:12 -05:00
Delaney Granizo-Mackenzie 56d87c5170 ENH: Added testing for serialization. 2015-03-04 14:17:12 -05:00
Delaney Granizo-Mackenzie ca210f0778 MAINT: Refactored serialization code. 2015-03-04 14:17:12 -05:00
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
theandycamps d192b1846f MAINT: Move knowledge date for existing DNT list 2015-03-03 16:46:56 -05:00
Eddie Hebert 82378f720d Merge performance improvements to simple transforms. 2015-03-03 15:23:05 -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
Dale Jung 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
Eddie Hebert 94d25a54c6 PERF: Merge blotter performance improvements. 2015-02-27 05:06:51 -05:00
Dale Jung 29aab7755f TST: updated test to the fact that we aren't creating new lists to store
orders
2015-02-27 05:06:02 -05:00
Dale Jung 69815d1695 PRF: limit the subset of orders we check for bookkeeping 2015-02-27 05:06:02 -05:00
Dale Jung 4c5f38d7b1 MAINT: There is no place where orders are put in out of place 2015-02-27 05:06:02 -05:00
Dale Jung 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 Jung 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 Jung 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 Jung 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
Sebastian Nilsson c4168c2ba6 DOC Fix broken link to Getting started tutorials. 2015-02-22 16:47:04 +01: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 Jung 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