mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-09 18:18:43 +08:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user