diff options
Diffstat (limited to 'python/analytics/credit_default_swap.py')
| -rw-r--r-- | python/analytics/credit_default_swap.py | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/python/analytics/credit_default_swap.py b/python/analytics/credit_default_swap.py index 20330365..5bddbf73 100644 --- a/python/analytics/credit_default_swap.py +++ b/python/analytics/credit_default_swap.py @@ -422,57 +422,3 @@ class CreditDefaultSwap: self.spread = orig_spread ind = pd.Index(spread_shock, name="spread_shock", copy=False) return pd.DataFrame(r, index=ind, columns=actual_params) - - def __repr__(self): - if not self.spread: - raise ValueError("Market spread is missing!") - if self.days_accrued > 1: - accrued_str = "Accrued ({} Days)".format(self.days_accrued) - else: - accrued_str = "Accrued ({} Day)".format(self.days_accrued) - - s = [ - "{:<20}\tNotional {:>5.2f}MM {}\tFactor {:>28.5f}".format( - "Buy Protection" if self.notional > 0.0 else "Sell Protection", - abs(self.notional) / 1_000_000, - self.currency, - self._factor, - ), - "{:<20}\t{:>15}".format("CDS Index", colored(self.name, attrs=["bold"])), - "", - ] - rows = [ - ["Trd Sprd (bp)", self.spread, "Coupon (bp)", self.fixed_rate], - ["1st Accr Start", self.issue_date, "Payment Freq", "Quarterly"], - ["Maturity Date", self.end_date, "Rec Rate", self.recovery], - ["Bus Day Adj", "Following", "DayCount", "ACT/360"], - ] - format_strings = [ - [None, "{:.2f}", None, "{:.0f}"], - [None, "{:%m/%d/%y}", None, None], - [None, "{:%m/%d/%y}", None, None], - [None, None, None, None], - ] - s += build_table(rows, format_strings, "{:<20}{:>19}\t\t{:<20}{:>15}") - s += ["", colored("Calculator", attrs=["bold"])] - rows = [ - ["Valuation Date", self.value_date], - ["Cash Settled On", self._cash_settle_date], - ] - format_strings = [[None, "{:%m/%d/%y}"], [None, "{:%m/%d/%y}"]] - s += build_table(rows, format_strings, "{:<20}\t{:>15}") - s += [""] - rows = [ - ["Price", self.price, "Spread DV01", self.DV01], - ["Principal", self.clean_pv, "IR DV01", self.IRDV01], - [accrued_str, self.accrued, "Rec Risk (1%)", self.rec_risk], - ["Cash Amount", self.pv, "Def Exposure", self.jump_to_default], - ] - format_strings = [ - [None, "{:.8f}", None, "{:,.2f}"], - [None, "{:,.0f}", None, "{:,.2f}"], - [None, "{:,.0f}", None, "{:,.2f}"], - [None, "{:,.0f}", None, "{:,.0f}"], - ] - s += build_table(rows, format_strings, "{:<20}{:>19}\t\t{:<20}{:>15}") - return "\n".join(s) |
