diff options
Diffstat (limited to 'python/analytics/tranche_data.py')
| -rw-r--r-- | python/analytics/tranche_data.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/python/analytics/tranche_data.py b/python/analytics/tranche_data.py index b27b09f5..316543d7 100644 --- a/python/analytics/tranche_data.py +++ b/python/analytics/tranche_data.py @@ -133,30 +133,30 @@ def tranche_returns( lambda s: s.diff().astype("timedelta64[D]") / 360 ) index_loss = g.cumulativeloss - g.cumulativeloss.shift(1) - tranche_loss = np.maximum( + tranche_loss = ( ( - g.orig_thickness * g.indexfactor - - g.orig_thickness.shift(1) * g.indexfactor.shift(1) + g.adj_thickness.shift(1) * g.indexfactor.shift(1) + - g.adj_thickness * g.indexfactor ) - / g.orig_thickness, - 0, + / g.orig_thickness + if g.detach[0] != 100 + else 0 ) - tranche_return = ( + tranche_return = g.close_price - ( 1 - - ((1 - g.close_price) * g.tranche_factor - tranche_loss) - / g.tranche_factor.shift(1) - - g.close_price.shift(1) + - ((1 - g.close_price.shift(1)) * g.tranche_factor.shift(1) - tranche_loss) + / g.tranche_factor ) - index_return = ( + index_return = g.index_price - ( 1 - - ((1 - g.index_price) * g.indexfactor - index_loss) - / g.indexfactor.shift(1) - - g.index_price.shift(1) + - ((1 - g.index_price.shift(1)) * g.indexfactor.shift(1) - index_loss / 100) + / g.indexfactor ) tranche_return += day_frac * g.tranche_spread / 10000 index_return += day_frac * g.coupon delhedged_return = ( - tranche_return - g.delta.shift(1) * index_return * g.indexfactor + tranche_return + - g.delta.shift(1) * index_return * g.indexfactor / g.tranche_factor ) returns.append( pd.concat( |
