diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/analytics/cms_spread.py | 2 | ||||
| -rw-r--r-- | python/tests/test_sabr_quantlib.py | 19 | ||||
| -rw-r--r-- | python/tests/test_swap_index.py | 19 | ||||
| -rw-r--r-- | python/tests/test_upfront_cds.py (renamed from python/test_upfront_cds.py) | 0 |
4 files changed, 39 insertions, 1 deletions
diff --git a/python/analytics/cms_spread.py b/python/analytics/cms_spread.py index 10a23417..9ee63e8e 100644 --- a/python/analytics/cms_spread.py +++ b/python/analytics/cms_spread.py @@ -1,6 +1,6 @@ from .tranche_functions import GHquad from math import exp, sqrt, log -from .blac import cnd_erf +from .black import cnd_erf def CMS_spread(T_alpha, X, beta, gamma): Z, w = GHquad(100) diff --git a/python/tests/test_sabr_quantlib.py b/python/tests/test_sabr_quantlib.py new file mode 100644 index 00000000..67a33ccb --- /dev/null +++ b/python/tests/test_sabr_quantlib.py @@ -0,0 +1,19 @@ +from quantlib.termstructures.volatility.sabr_interpolated_smilesection import SabrInterpolatedSmileSection +from quantlib.time.api import Date, Period, Months +from quantlib.quotes import SimpleQuote +from quantlib.settings import Settings +import numpy as np + +strikes = np.array([50, 55, 57.5, 60, 62.5, 65, 67.5, 70, 75, 80, 85]) +pvs = np.array([53.65, 37.75, 31.55, 26.45, 22.25, 18.85, 16.15, 13.95, 10.55, + 8.05, 6.15, 4.65, 3.65, 2.75]) * 1e-4 +option_date = Settings().instance().evaluation_date + Period(3, Months) +forward = SimpleQuote(58.71e-4) +strikes = np.array([50, 55, 57.5, 60, 62.5, 65, 67.5, 70, 75, 80, 85, 90, 95, 100]) * 1e-4 +vol = np.array([28.5, 31.6, 33.7, 36.1, 38.7, 41.5, 44.1, + 46.5, 50.8, 54.4, 57.3, 59.8, 61.8, 63.6]) * 1e-2 +vol_quotes = [SimpleQuote(q) for q in vol] + +section = SabrInterpolatedSmileSection(option_date, forward, strikes, False, + SimpleQuote(0.4), vol_quotes, 0.1, 1, 0.1, 0.5, + is_beta_fixed=True) diff --git a/python/tests/test_swap_index.py b/python/tests/test_swap_index.py new file mode 100644 index 00000000..f2816bac --- /dev/null +++ b/python/tests/test_swap_index.py @@ -0,0 +1,19 @@ +import unittest +import sys + +from quantlib.indexes.swap.usd_libor_swap import UsdLiborSwapIsdaFixAm +from quantlib.time.api import Date, Period, Years +from yieldcurve import YC + +class UsdLiborSwap(unittest.TestCase): + def test_creation(self): + yc = YC() + yc.extrapolation = True + USISDA30 = UsdLiborSwapIsdaFixAm(Period(30, Years), forwarding=yc, discounting=yc) + USISDA30.add_fixing(Date(25, 1, 2018), 0.02781) + USISDA02 = UsdLiborSwapIsdaFixAm(Period(2, Years), forwarding=yc, discounting=yc) + USISDA02.add_fixing(Date(25, 1, 2018), 0.02283) + USFS022 = USISDA02.underlying_swap(Date(27, 1, 2020)) + USFS0230 = USISDA30.underlying_swap(Date(27, 1, 2020)) + self.assertEqual(USFS022.fair_rate, USISDA02.fixing(Date(27, 1, 2020))) + self.assertEqual(USFS0230.fair_rate, USISDA30.fixing(Date(27, 1, 2020))) diff --git a/python/test_upfront_cds.py b/python/tests/test_upfront_cds.py index 1782ddc5..1782ddc5 100644 --- a/python/test_upfront_cds.py +++ b/python/tests/test_upfront_cds.py |
