diff options
| -rw-r--r-- | python/analytics/tranche_basket.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index 5a2289e5..475f9ebb 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -17,6 +17,7 @@ from scipy.special import logit, expit import datetime import logging +import matplotlib.pyplot as plt import pandas as pd import numpy as np import analytics @@ -80,6 +81,24 @@ class Skew(): Skew._cache[key] = s return s + def plot(self, moneyness_space=True): + if moneyness_space: + moneyness = np.linspace(0, 10, 100) + rho = self(moneyness) + plt.plot(moneyness, rho) + plt.xlabel("moneyness") + plt.ylabel("rho") + plt.plot(self.skew_fun.x, self(self.skew_fun.x), "ro") + else: + attach = np.linspace(0, 1, 100) + rho = self(attach / self.el) + plt.plot(attach, rho) + plt.xlabel("attach") + plt.ylabel("rho") + k = np.exp(self.skew_fun.x) * self.el + plt.plot(k, self(np.exp(self.skew_fun.x)), "ro") + + class DualCorrTranche(): _cache = LRU(512) _Legs = namedtuple('Legs', 'coupon_leg, protection_leg, bond_price') |
