aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics')
-rw-r--r--python/analytics/tranche_basket.py10
-rw-r--r--python/analytics/tranche_functions.py2
2 files changed, 6 insertions, 6 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py
index 0bf661e7..3bc5b104 100644
--- a/python/analytics/tranche_basket.py
+++ b/python/analytics/tranche_basket.py
@@ -253,7 +253,7 @@ class TrancheBasket(BasketIndex):
def aux2(x, index1, index2, K2):
newrho = expit(index1._skew(logit(x)))
return np.log(self.probability_trunc(x, newrho)) - \
- np.log(index2.probability_trunc(x, newrho))
+ np.log(index2.probability_trunc(K2, newrho))
if method not in ["ATM", "TLP", "PM"]:
raise ValueError("method needs to be one of 'ATM', 'TLP' or 'PM'")
@@ -269,14 +269,14 @@ class TrancheBasket(BasketIndex):
K1eq = []
m = np.nanmax(index2.K)
for K2 in index2.K[1:-1]:
- K1eq.append(brentq(aux, 0., m, (self, el1, index2, K2)))
+ K1eq.append(brentq(aux, 0., m, (self, el1, index2, el2, K2)))
K1eq = np.array(K1eq)
elif method == "PM":
K1eq = []
- m = np.nanmax(K2) + 0.25
+ m = np.nanmax(index2.K) + 0.25
for K2 in index2.K[1:-1]:
- K1eq.append(brentq(aux, K2 * 0.1, K2*1.8,
+ K1eq.append(brentq(aux2, K2 * 0.1, K2 * 1.8,
(self, index2, K2)))
- return np.hstack([np.nan, K1eq, np.nan])
+ return np.hstack([np.nan, expit(self._skew(logit(K1eq))), np.nan])
diff --git a/python/analytics/tranche_functions.py b/python/analytics/tranche_functions.py
index 7910a1d0..ec097c3c 100644
--- a/python/analytics/tranche_functions.py
+++ b/python/analytics/tranche_functions.py
@@ -341,7 +341,7 @@ def cds_accrued(tradedate, coupon):
DC = Actual360()
cal = WeekendsOnly()
sched = Schedule(tradedate, end, Period('3M'), cal, date_generation_rule=CDS2015)
- prevpaydate = sched.previous_date(tradedate)
+ prevpaydate = sched.previous_date(start_protection)
return DC.year_fraction(prevpaydate, start_protection) * coupon
def dist_transform(q):