diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/analytics/tranche_basket.py | 8 | ||||
| -rw-r--r-- | python/notebooks/Tranche calculator.ipynb | 23 |
2 files changed, 10 insertions, 21 deletions
diff --git a/python/analytics/tranche_basket.py b/python/analytics/tranche_basket.py index b16c7217..9ec1a2b5 100644 --- a/python/analytics/tranche_basket.py +++ b/python/analytics/tranche_basket.py @@ -1400,6 +1400,14 @@ class TrancheBasket(BasketIndex): ) return np.hstack([np.nan, self.skew(moneyness1_eq), np.nan]) + def __repr__(self): + result = pd.concat([self.tranche_deltas(), self.tranche_thetas()], axis=1) + result["corr_01"] = self.tranche_corr01() + result["corr_at_detach"] = self.rho[1:] + result["price"] = self.tranche_pvs().bond_price + result["net_theta"] = result.theta - self.theta(self.maturity) * result.delta + return repr(result) + class MarkitTrancheBasket(TrancheBasket): def _set_tranche_quotes(self, value_date): diff --git a/python/notebooks/Tranche calculator.ipynb b/python/notebooks/Tranche calculator.ipynb index 394618a3..6039ef1e 100644 --- a/python/notebooks/Tranche calculator.ipynb +++ b/python/notebooks/Tranche calculator.ipynb @@ -19,31 +19,13 @@ "metadata": {}, "outputs": [], "source": [ - "def display_result(basket_index):\n", - " thetas = basket_index.tranche_thetas()\n", - " result = pd.concat([pd.DataFrame(basket_index.rho[0:4], index=thetas.index, columns=['att_corr']),\n", - " pd.DataFrame(basket_index.tranche_pvs().bond_price, index=thetas.index, columns=['price']),\n", - " basket_index.tranche_deltas(),\n", - " thetas],\n", - " axis=1)\n", - " result['net_theta'] = result.theta - new_index.theta()[0] * result.delta\n", - " return result" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ "index_type = 'HY'\n", "series = 35\n", "value_date = date.today()\n", "new_index = ManualTrancheBasket(index_type, series, \"5yr\", value_date=value_date, ref=104.625, quotes=[43, 92.5, 110, 120.27])\n", "new_index.tweak()\n", "new_index.build_skew()\n", - "result = display_result(new_index)\n", - "result " + "new_index " ] }, { @@ -72,8 +54,7 @@ "base_index.build_skew()\n", "\n", "new_index.rho = base_index.map_skew(new_index)\n", - "result = display_result(new_index)\n", - "result" + "new_index" ] }, { |
