import pytest from okx_codex_trader.strategy import validate_signal def test_validate_signal_rejects_leverage_out_of_range(): with pytest.raises(ValueError): validate_signal( { "action": "long", "confidence": 0.9, "leverage": 4, "entry_price": None, "take_profit_price": None, "stop_loss_price": None, "reason": "x", } ) def test_validate_signal_rejects_unknown_action(): with pytest.raises(ValueError): validate_signal( { "action": "hold", "confidence": 0.9, "leverage": 2, "entry_price": None, "take_profit_price": None, "stop_loss_price": None, "reason": "x", } ) def test_validate_signal_rejects_confidence_out_of_range(): with pytest.raises(ValueError): validate_signal( { "action": "long", "confidence": 1.2, "leverage": 2, "entry_price": None, "take_profit_price": None, "stop_loss_price": None, "reason": "x", } ) def test_validate_signal_requires_full_shape(): with pytest.raises(ValueError): validate_signal({"action": "long", "confidence": 0.9, "leverage": 2})