aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests
diff options
context:
space:
mode:
Diffstat (limited to 'python/tests')
-rw-r--r--python/tests/test_tranche_basket.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/python/tests/test_tranche_basket.py b/python/tests/test_tranche_basket.py
index a7506955..34be0af2 100644
--- a/python/tests/test_tranche_basket.py
+++ b/python/tests/test_tranche_basket.py
@@ -20,6 +20,15 @@ class TestTopDown(unittest.TestCase):
eu30 = TrancheBasket("EU", 30, "5yr", value_date=datetime.date(2019, 8, 15))
market_quotes = eu30._accrued + eu30.tranche_quotes.quotes
+ def test_invariant(self):
+ hy35 = TrancheBasket("HY", 35, "5yr", value_date=datetime.date(2020, 10, 5))
+ hy35.tweak()
+ hy35.build_skew()
+ self.assertAlmostEqual(
+ hy35.index_pv(clean=True).bond_price,
+ (hy35.tranche_pvs().bond_price * np.diff(hy35.K)).sum(),
+ )
+
def test_bottomup(self):
self.eu30.build_skew()
upfronts = 1 - self.eu30.tranche_pvs().bond_price