MAINT: Make split method coarse.

In preparation for removal of widespread events, change the split
methods to use params for sid and cost, instead of an event, for
compatibility with lazy branch.

co-author: @jbredeche <jean@quantopian.com>
This commit is contained in:
Eddie Hebert
2015-12-17 14:58:14 -05:00
parent 7eae960b21
commit 104245bb19
2 changed files with 5 additions and 7 deletions
+4 -6
View File
@@ -82,20 +82,18 @@ class Position(object):
payment_owed = zp.dividend_payment(out)
return payment_owed
def handle_split(self, split):
def handle_split(self, sid, ratio):
"""
Update the position by the split ratio, and return the resulting
fractional share that will be converted into cash.
Returns the unused cash.
"""
if self.sid != split.sid:
if self.sid != sid:
raise Exception("updating split with the wrong sid!")
ratio = split.ratio
log.info("handling split for sid = " + str(split.sid) +
", ratio = " + str(split.ratio))
log.info("handling split for sid = " + str(sid) +
", ratio = " + str(ratio))
log.info("before split: " + str(self))
# adjust the # of shares by the ratio
@@ -327,7 +327,7 @@ class PositionTracker(object):
# Make the position object handle the split. It returns the
# leftover cash from a fractional share, if there is any.
position = self.positions[split.sid]
leftover_cash = position.handle_split(split)
leftover_cash = position.handle_split(split.sid, split.ratio)
self._update_asset(split.sid)
return leftover_cash