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.
This commit is contained in:
Eddie Hebert
2015-02-25 13:41:50 -05:00
parent 1054134bd9
commit a0bd57555d
+6 -3
View File
@@ -122,9 +122,7 @@ class PerformancePeriod(object):
self.keep_transactions = keep_transactions
self.keep_orders = keep_orders
# Arrays for quick calculations of positions value
self._position_amounts = OrderedDict()
self._position_last_sale_prices = OrderedDict()
self.initialize_position_calc_arrays()
self.calculate_performance()
@@ -142,6 +140,11 @@ class PerformancePeriod(object):
self.loc_map = {}
def initialize_position_calc_arrays(self):
# Arrays for quick calculations of positions value.
self._position_amounts = OrderedDict()
self._position_last_sale_prices = OrderedDict()
def set_positions(self, positions):
self.positions = positions
for sid, pos in positions.iteritems():