diff options
Diffstat (limited to 'python/tests/test_scenarios.py')
| -rw-r--r-- | python/tests/test_scenarios.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/python/tests/test_scenarios.py b/python/tests/test_scenarios.py index d079b1c9..c22c8be3 100644 --- a/python/tests/test_scenarios.py +++ b/python/tests/test_scenarios.py @@ -1,18 +1,20 @@ import unittest -import datetime import numpy as np import pandas as pd -from analytics import Index, BlackSwaption, Portfolio, BlackSwaptionVolSurface +from analytics import CreditIndex, BlackSwaption, Portfolio, BlackSwaptionVolSurface from pandas.tseries.offsets import BDay -from analytics.scenarios import run_portfolio_scenarios, run_swaption_scenarios, run_index_scenarios +from analytics.scenarios import (run_portfolio_scenarios, + run_swaption_scenarios, run_index_scenarios) + class TestSenarios(unittest.TestCase): - option_delta = Index.from_tradeid(874) + option_delta = CreditIndex.from_tradeid(874) 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.value_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""" @@ -21,7 +23,9 @@ class TestSenarios(unittest.TestCase): 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) + spread_shock=spread_shock, + vol_shock=vol_shock, + vol_surface=vol_surface) df = df.set_index(['spread', 'vol_shock'], append=True) df1 = run_swaption_scenarios(self.option1, self.date_range, @@ -38,5 +42,5 @@ class TestSenarios(unittest.TestCase): df_orig = df_orig.set_index('vol_shock', append=True) self.assertFalse(np.any((df-df_orig).values)) -if __name__=="__main__": +if __name__ == "__main__": unittest.main() |
