aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/test_swap_index.py
blob: c197559a75654e7211b85c1e5045a8a8c546f7c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import unittest

from quantlib.indexes.swap.usd_libor_swap import UsdLiborSwapIsdaFixAm
from quantlib.time.api import Date, Period, Years
from serenitas.analytics.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)))