summaryrefslogtreecommitdiff
path: root/shared/tests/test_models.py
diff options
context:
space:
mode:
Diffstat (limited to 'shared/tests/test_models.py')
-rw-r--r--shared/tests/test_models.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/shared/tests/test_models.py b/shared/tests/test_models.py
index 25ab4c9..b23d71d 100644
--- a/shared/tests/test_models.py
+++ b/shared/tests/test_models.py
@@ -94,6 +94,35 @@ def test_order_creation():
assert order.created_at is not None
+def test_signal_conviction_default():
+ """Test Signal defaults for conviction, stop_loss, take_profit."""
+ from shared.models import Signal, OrderSide
+
+ signal = Signal(
+ strategy="rsi", symbol="BTCUSDT", side=OrderSide.BUY,
+ price=Decimal("50000"), quantity=Decimal("0.01"), reason="test",
+ )
+ assert signal.conviction == 1.0
+ assert signal.stop_loss is None
+ assert signal.take_profit is None
+
+
+def test_signal_with_stops():
+ """Test Signal with explicit conviction, stop_loss, take_profit."""
+ from shared.models import Signal, OrderSide
+
+ signal = Signal(
+ strategy="rsi", symbol="BTCUSDT", side=OrderSide.BUY,
+ price=Decimal("50000"), quantity=Decimal("0.01"), reason="test",
+ conviction=0.8,
+ stop_loss=Decimal("48000"),
+ take_profit=Decimal("55000"),
+ )
+ assert signal.conviction == 0.8
+ assert signal.stop_loss == Decimal("48000")
+ assert signal.take_profit == Decimal("55000")
+
+
def test_position_unrealized_pnl():
"""Test Position unrealized_pnl computed property."""
from shared.models import Position