aboutsummaryrefslogtreecommitdiffstats
path: root/python/populate_tranche_cashflows.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/populate_tranche_cashflows.py')
-rw-r--r--python/populate_tranche_cashflows.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/python/populate_tranche_cashflows.py b/python/populate_tranche_cashflows.py
index 80a32eec..99080597 100644
--- a/python/populate_tranche_cashflows.py
+++ b/python/populate_tranche_cashflows.py
@@ -36,8 +36,14 @@ def insert_tranche_cashflows(
for r in c:
direction = 1.0 if r.protection == "Buyer" else -1.0
notional = r.notional / (r.orig_detach - r.orig_attach)
- accrued = -direction * severity * acc * r.coupon_rate / 360 * notional
- principal = direction * notional * severity
+ if r.orig_detach == 100:
+ accrued = (
+ -direction * (1 - severity) * acc * r.coupon_rate / 360 * notional
+ )
+ principal = 0
+ else:
+ accrued = -direction * severity * acc * r.coupon_rate / 360 * notional
+ principal = direction * notional * severity
data.append([r.id, principal, accrued])
with dawndb.cursor() as c: