diff options
Diffstat (limited to 'python/tests')
| -rw-r--r-- | python/tests/test_cds.py | 9 | ||||
| -rw-r--r-- | python/tests/test_index.py | 22 | ||||
| -rw-r--r-- | python/tests/test_scenarios.py | 4 | ||||
| -rw-r--r-- | python/tests/test_swaption.py | 8 |
4 files changed, 21 insertions, 22 deletions
diff --git a/python/tests/test_cds.py b/python/tests/test_cds.py index 26ec809e..defafd64 100644 --- a/python/tests/test_cds.py +++ b/python/tests/test_cds.py @@ -11,7 +11,7 @@ from yieldcurve import YC, ql_to_jp class TestUpfront(unittest.TestCase): index = Index.from_name("ig", 26, "5yr", - trade_date = datetime.date(2016, 9, 21)) + value_date=datetime.date(2016, 9, 21)) index.notional = 50e6 index.spread = 70 @@ -19,19 +19,18 @@ class TestUpfront(unittest.TestCase): self.assertAlmostEqual(-self.index.pv, 685292.81, 2) def test_cdsone(self): - settings = Settings() - settings.evaluation_date = Date.from_datetime(self.index.trade_date) + Settings().evaluation_date = Date.from_datetime(self.index.value_date) yc = YC() jp_yc = ql_to_jp(yc) fee_dirty = self.index.notional * ( - upfront_charge(self.index.trade_date, self.index._value_date, + upfront_charge(self.index.value_date, self.index._cash_settle_date, self.index.start_date, self.index._step_in_date, self.index.start_date, self.index.end_date, self.index.fixed_rate*1e-4, jp_yc, 70e-4, self.index.recovery, False)) fee_clean = self.index.notional * ( - upfront_charge(self.index.trade_date, self.index._value_date, + upfront_charge(self.index.value_date, self.index._cash_settle_date, self.index.start_date, self.index._step_in_date, self.index.start_date, self.index.end_date, self.index.fixed_rate*1e-4, diff --git a/python/tests/test_index.py b/python/tests/test_index.py index edf15a4c..59dbfe88 100644 --- a/python/tests/test_index.py +++ b/python/tests/test_index.py @@ -11,7 +11,7 @@ import pickle class TestPickle(unittest.TestCase): index = Index.from_name("ig", 26, "5yr", - trade_date=datetime.date(2016, 7, 1)) + value_date=datetime.date(2016, 7, 1)) index.notional = 50e6 index.spread = 75 @@ -21,29 +21,29 @@ class TestPickle(unittest.TestCase): class TestStrike(unittest.TestCase): index = Index.from_name("ig", 26, "5yr", - trade_date = datetime.date(2016, 7, 1)) - index.notional = 50e6 + value_date=datetime.date(2016, 7, 1)) + index.notional = 50_000_000. index.spread = 75 exercise_date = datetime.date(2016, 8, 19) def test_pv(self): self.assertAlmostEqual(self.index.clean_pv, - g(self.index, self.index.spread, self.index.trade_date) * + g(self.index, self.index.spread, self.index.value_date) * self.index.notional) def test_strike(self): """strike price equals clean_pv using expected forward yield curve""" strike = g(self.index, self.index.spread, self.exercise_date) * self.index.notional old_yc = self.index._yc - self.index.trade_date = self.exercise_date + self.index.value_date = self.exercise_date self.index._yc = old_yc.expected_forward_curve(self.exercise_date) self.index._update() self.assertAlmostEqual(self.index.clean_pv, strike) def test_strike_vec(self): - self.index.trade_date = datetime.date(2016, 8, 19) - r = pv_vec(np.array([70, 75])*1e-4, self.index._yc, self.index.trade_date, - self.index._value_date, self.index.start_date, self.index.end_date, + self.index.value_date = datetime.date(2016, 8, 19) + r = pv_vec(np.array([70, 75])*1e-4, self.index._yc, self.index.value_date, + self.index._cash_settle_date, self.index.start_date, self.index.end_date, self.index.recovery, self.index.fixed_rate * 1e-4) self.index.notional = 1 self.index.spread = 70 @@ -57,8 +57,8 @@ class TestStrike(unittest.TestCase): class TestForwardIndex(unittest.TestCase): index = Index.from_name("ig", 26, "5yr", - trade_date = datetime.date(2016, 7, 1)) - index.notional = 50e6 + value_date=datetime.date(2016, 7, 1)) + index.notional = 50_000_000. index.spread = 75 exercise_date = datetime.date(2016, 8, 19) fi = ForwardIndex(index, exercise_date) @@ -71,7 +71,7 @@ class TestForwardIndex(unittest.TestCase): def test_forward_pv(self): """default adjusted forward price for trade_date equals clean pv""" - fi = ForwardIndex(self.index, self.index.trade_date) + fi = ForwardIndex(self.index, self.index.value_date) self.assertAlmostEqual(fi.forward_pv, self.index.clean_pv / self.index.notional) if __name__=="__main__": diff --git a/python/tests/test_scenarios.py b/python/tests/test_scenarios.py index 4e695864..d079b1c9 100644 --- a/python/tests/test_scenarios.py +++ b/python/tests/test_scenarios.py @@ -12,13 +12,13 @@ class TestSenarios(unittest.TestCase): option1 = BlackSwaption.from_tradeid(7, option_delta) option2 = BlackSwaption.from_tradeid(8, option_delta) portf = Portfolio([option1, option2, option_delta]) - date_range = pd.bdate_range(option_delta.trade_date, pd.Timestamp('2017-05-17') - BDay(), freq = '5B') + date_range = pd.bdate_range(option_delta.value_date, pd.Timestamp('2017-05-17') - BDay(), freq = '5B') def test_portfolio(self): """ check that run_portfolio_scenarios match the sum of the individual pieces""" vol_shock = np.arange(-0.15, 0.3, 0.01) spread_shock = np.arange(-0.2, 0.3, 0.01) - vs = BlackSwaptionVolSurface("IG", 28, trade_date=self.option_delta.trade_date) + vs = BlackSwaptionVolSurface("IG", 28, value_date=self.option_delta.value_date) vol_surface = vs[vs.list(source="BAML")[-1]] df = run_portfolio_scenarios(self.portf, self.date_range, spread_shock, vol_shock, vol_surface) diff --git a/python/tests/test_swaption.py b/python/tests/test_swaption.py index 36e08b1a..1f5b808a 100644 --- a/python/tests/test_swaption.py +++ b/python/tests/test_swaption.py @@ -8,7 +8,7 @@ from analytics import Index, Swaption, BlackSwaption class TestPutCallParity(unittest.TestCase): index = Index.from_name("ig", 27, "5yr", - trade_date = datetime.date(2016, 10, 25)) + value_date= datetime.date(2016, 10, 25)) index.spread = 74 exercise_date = datetime.date(2017, 3, 15) strike = 82.5 @@ -43,7 +43,7 @@ class TestPutCallParity(unittest.TestCase): def test_hy(self): index = Index.from_name("hy", 27, "5yr", - trade_date=datetime.date(2016, 11, 8)) + value_date=datetime.date(2016, 11, 8)) index.price = 103.875 exercise_date = datetime.date(2017, 3, 15) strike = 102.5 @@ -55,12 +55,12 @@ class TestBreakeven(unittest.TestCase): exercise_date = datetime.date(2017, 3, 15) hyindex = Index.from_name("hy", 27, "5yr", - trade_date=datetime.date(2016, 11, 16)) + value_date=datetime.date(2016, 11, 16)) hyindex.price = 103.75 hystrike = 102.5 igindex = Index.from_name("ig", 27, "5yr", - trade_date=datetime.date(2016, 11, 18)) + value_date=datetime.date(2016, 11, 18)) igindex.spread = 76.5 igstrike = 80 |
