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.
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.
The >= comparison for the Cythonized Security object was actually
doing <=. Fix this and add unit tests for all the Security object rich
comparison operators.
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.
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
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.
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
```
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.
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.
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.
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.
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