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