Skip to content

Commit

Permalink
TST
Browse files Browse the repository at this point in the history
  • Loading branch information
attack68 committed Jan 26, 2025
1 parent d342d18 commit 5e1d488
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions python/tests/test_instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ def test_null_priced_delta(self, inst) -> None:
)
],
)
def test_null_priced_gamma2(self, inst) -> None:
def test_null_priced_delta2(self, inst) -> None:
c1 = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.99}, id="usdusd")
c2 = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.98}, id="eureur")
c3 = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.982}, id="eurusd")
Expand All @@ -756,8 +756,16 @@ def test_null_priced_gamma2(self, inst) -> None:
instrument_labels=["eur 1y", "usd 1y", "eur 1y xcs adj.", "1y cpi"],
fx=fxf,
)
result = inst.gamma(solver=solver)
assert isinstance(result, DataFrame)
result = inst.delta(solver=solver)
assert abs(result.iloc[1, 0] - 25.0) < 1.0
result2 = inst.npv(solver=solver)
assert abs(result2) < 1e-3

# test that instruments have not been set by the previous pricing action
solver.s = [1.3, 1.4, 1.36, 0.55]
solver.iterate()
result3 = inst.npv(solver=solver)
assert abs(result3) < 1e-3

@pytest.mark.parametrize(
"inst",
Expand All @@ -770,7 +778,7 @@ def test_null_priced_gamma2(self, inst) -> None:
)
],
)
def test_null_priced_delta2(self, inst) -> None:
def test_null_priced_gamma2(self, inst) -> None:
c1 = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.99}, id="usdusd")
c2 = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.98}, id="eureur")
c3 = Curve({dt(2022, 1, 1): 1.0, dt(2023, 1, 1): 0.982}, id="eurusd")
Expand All @@ -793,16 +801,8 @@ def test_null_priced_delta2(self, inst) -> None:
instrument_labels=["eur 1y", "usd 1y", "eur 1y xcs adj.", "1y cpi"],
fx=fxf,
)
result = inst.delta(solver=solver)
assert abs(result.iloc[1, 0] - 25.0) < 1.0
result2 = inst.npv(solver=solver)
assert abs(result2) < 1e-3

# test that instruments have not been set by the previous pricing action
solver.s = [1.3, 1.4, 1.36, 0.55]
solver.iterate()
result3 = inst.npv(solver=solver)
assert abs(result3) < 1e-3
result = inst.gamma(solver=solver)
assert isinstance(result, DataFrame)

@pytest.mark.parametrize(
("inst", "param"),
Expand Down

0 comments on commit 5e1d488

Please sign in to comment.