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 31f5d10 commit c6e3146
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions python/tests/test_instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3047,6 +3047,13 @@ def test_portfolio_mixed_currencies(self) -> None:
pf.gamma(solver=combined_solver)


def test_repr(self, curve) -> None:
irs1 = IRS(dt(2022, 1, 1), "6m", "Q", fixed_rate=1.0, curves=curve)
irs2 = IRS(dt(2022, 1, 1), "3m", "Q", fixed_rate=2.0, curves=curve)
pf = Portfolio([irs1, irs2])
expected = f"<rl.Portfolio at {hex(id(pf))}>"
assert pf.__repr__() == expected

class TestFly:
@pytest.mark.parametrize("mechanism", [False, True])
def test_fly_npv(self, curve, mechanism) -> None:
Expand Down Expand Up @@ -4257,6 +4264,19 @@ def test_greeks_delta_direction(self, fxfo, notn, expected_grks, expected_ccy) -
assert abs(result["gamma_eur_1%"] - expected_ccy[1]) < 1e-2
assert abs(result["vega_usd"] - expected_ccy[2]) < 1e-2

def test_repr(self):
fxo = FXRiskReversal(
pair="eurusd",
expiry=dt(2023, 6, 16),
notional=20e6,
delivery_lag=2,
payment_lag=2,
calendar="tgt",
strike=[1.033, 1.101],
)
expected = f"<rl.FXRiskReversal at {hex(id(fxo))}>"
assert fxo.__repr__() == expected


class TestFXStraddle:
@pytest.mark.parametrize(
Expand Down Expand Up @@ -4382,6 +4402,19 @@ def test_greeks_delta_direction(self, fxfo, notn, expected_grks, expected_ccy) -
assert abs(result["gamma_eur_1%"] - expected_ccy[1]) < 1e-2
assert abs(result["vega_usd"] - expected_ccy[2]) < 1e-2

def test_repr(self):
fxo = FXStraddle(
pair="eurusd",
expiry=dt(2023, 6, 16),
notional=20e6,
delivery_lag=2,
payment_lag=2,
calendar="tgt",
strike=1.0,
)
expected = f"<rl.FXStraddle at {hex(id(fxo))}>"
assert expected == fxo.__repr__()


class TestFXStrangle:
@pytest.mark.parametrize(
Expand Down

0 comments on commit c6e3146

Please sign in to comment.