aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/test_swap_index.py
blob: f2816bac9a5b45448664545fd75483bd8852e027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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)))