aboutsummaryrefslogtreecommitdiffstats
path: root/python/analytics
diff options
context:
space:
mode:
Diffstat (limited to 'python/analytics')
-rw-r--r--python/analytics/tranche_basket.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py
index 93cf32cc..b1c03702 100644
--- a/python/analytics/tranche_basket.py
+++ b/python/analytics/tranche_basket.py
@@ -8,7 +8,7 @@ from copy import deepcopy
from pyisda.cdsone import upfront_charge
from pandas.tseries.offsets import BDay
from scipy.optimize import brentq
-from scipy.interpolate import CubicSpline
+from scipy.interpolate import CubicSpline, PchipInterpolator
from scipy.special import logit, expit
import concurrent.futures
import pandas as pd
@@ -166,6 +166,18 @@ class TrancheBasket(BasketIndex):
self._Z, self._w, self._Ngrid)
return - np.dot(np.diff(np.hstack((K, ELt))), self.cs.df)
+ def probability_trunc(self, K, rho=None):
+ if rho is None:
+ rho = expit(self._skew(logit(K)))
+ L, _ = BCloss_recov_dist(self.default_prob.values[:,-1,np.newaxis],
+ self.weights,
+ self.recovery_rates,
+ rho,
+ self._Z, self._w, self._Ngrid)
+ p = np.cumsum(L)
+ support = np.linspace(0, 1, self._Ngrid)
+ probfun = PchipInterpolator(support, p)
+ return probfun(K)
@property
def recovery_rates(self):