Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
attack68 committed Sep 25, 2024
1 parent 98f3928 commit f791604
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions python/tests/test_instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3106,6 +3106,13 @@ def test_gamma(self, simple_solver) -> None:
expected = np.array([[-0.02944899, 0.009254014565], [0.009254014565, 0.0094239781314]])
assert np.all(np.isclose(result, expected))

def test_repr(self):
irs1 = IRS(dt(2022, 1, 1), "3m", "Q", fixed_rate=1.0)
irs2 = IRS(dt(2022, 1, 1), "4m", "Q", fixed_rate=2.0)
spd = Spread(irs1, irs2)
expected = f"<rl.Spread at {hex(id(spd))}>"
assert expected == spd.__repr__()


class TestSpread:
@pytest.mark.parametrize("mechanism", [False, True])
Expand Down Expand Up @@ -3146,9 +3153,11 @@ def test_local_npv(self, curve) -> None:
def test_repr(self):
irs1 = IRS(dt(2022, 1, 1), "3m", "Q", fixed_rate=1.0)
irs2 = IRS(dt(2022, 1, 1), "4m", "Q", fixed_rate=2.0)
spd = Spread(irs1, irs2)
expected = f"<rl.Spread at {hex(id(spd))}>"
assert expected == spd.__repr__()
irs3 = IRS(dt(2022, 1, 1), "5m", "Q", fixed_rate=1.0)
fly = Fly(irs1, irs2, irs3)
expected = f"<rl.Fly at {hex(id(fly))}>"
assert expected == fly.__repr__()


class TestSensitivities:
def test_sensitivity_raises(self) -> None:
Expand Down

0 comments on commit f791604

Please sign in to comment.