summaryrefslogtreecommitdiff
path: root/tests/integration/test_order_execution_flow.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/test_order_execution_flow.py')
-rw-r--r--tests/integration/test_order_execution_flow.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/tests/integration/test_order_execution_flow.py b/tests/integration/test_order_execution_flow.py
index 1ea0485..819b7db 100644
--- a/tests/integration/test_order_execution_flow.py
+++ b/tests/integration/test_order_execution_flow.py
@@ -1,4 +1,5 @@
"""Integration test: signal -> risk manager -> order executor -> order event."""
+
import sys
from pathlib import Path
@@ -6,7 +7,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "services" / "order
import pytest
from decimal import Decimal
-from unittest.mock import AsyncMock, MagicMock
+from unittest.mock import AsyncMock
from shared.models import Signal, OrderSide, OrderStatus
from order_executor.executor import OrderExecutor
@@ -17,8 +18,12 @@ from order_executor.risk_manager import RiskManager
async def test_signal_to_order_flow():
"""A valid signal passes risk checks and produces a filled order."""
signal = Signal(
- strategy="rsi", symbol="BTC/USDT", side=OrderSide.BUY,
- price=Decimal("50000"), quantity=Decimal("0.01"), reason="RSI oversold",
+ strategy="rsi",
+ symbol="BTC/USDT",
+ side=OrderSide.BUY,
+ price=Decimal("50000"),
+ quantity=Decimal("0.01"),
+ reason="RSI oversold",
)
exchange = AsyncMock()
@@ -35,8 +40,12 @@ async def test_signal_to_order_flow():
notifier = AsyncMock()
executor = OrderExecutor(
- exchange=exchange, risk_manager=risk_manager,
- broker=broker, db=db, notifier=notifier, dry_run=True,
+ exchange=exchange,
+ risk_manager=risk_manager,
+ broker=broker,
+ db=db,
+ notifier=notifier,
+ dry_run=True,
)
order = await executor.execute(signal)
@@ -56,8 +65,11 @@ async def test_signal_to_order_flow():
async def test_signal_rejected_by_risk_manager():
"""A signal that exceeds position size is rejected."""
signal = Signal(
- strategy="rsi", symbol="BTC/USDT", side=OrderSide.BUY,
- price=Decimal("50000"), quantity=Decimal("100"), # Way too large
+ strategy="rsi",
+ symbol="BTC/USDT",
+ side=OrderSide.BUY,
+ price=Decimal("50000"),
+ quantity=Decimal("100"), # Way too large
reason="test",
)
@@ -71,8 +83,12 @@ async def test_signal_rejected_by_risk_manager():
)
executor = OrderExecutor(
- exchange=exchange, risk_manager=risk_manager,
- broker=AsyncMock(), db=AsyncMock(), notifier=AsyncMock(), dry_run=True,
+ exchange=exchange,
+ risk_manager=risk_manager,
+ broker=AsyncMock(),
+ db=AsyncMock(),
+ notifier=AsyncMock(),
+ dry_run=True,
)
order = await executor.execute(signal)