Compare commits
2 Commits
feature/is
...
feature/is
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c107d2435 | ||
| 13a6d6612a |
14
src/main.py
14
src/main.py
@@ -750,6 +750,20 @@ async def process_blackout_recovery_orders(
|
||||
|
||||
accepted = result.get("rt_cd", "0") == "0"
|
||||
if accepted:
|
||||
runtime_session_id = get_session_info(market).session_id
|
||||
log_trade(
|
||||
conn=db_conn,
|
||||
stock_code=intent.stock_code,
|
||||
action=intent.order_type,
|
||||
confidence=0,
|
||||
rationale=f"[blackout-recovery] {intent.source}",
|
||||
quantity=intent.quantity,
|
||||
price=float(intent.price),
|
||||
pnl=0.0,
|
||||
market=market.code,
|
||||
exchange_code=market.exchange_code,
|
||||
session_id=runtime_session_id,
|
||||
)
|
||||
logger.info(
|
||||
"Recovered queued order executed: %s %s (%s) qty=%d price=%.4f source=%s",
|
||||
intent.order_type,
|
||||
|
||||
@@ -5837,6 +5837,7 @@ async def test_process_blackout_recovery_executes_valid_intents() -> None:
|
||||
patch("src.main.MARKETS", {"KR": market}),
|
||||
patch("src.main.get_open_position", return_value=None),
|
||||
patch("src.main.validate_order_policy"),
|
||||
patch("src.main.get_session_info", return_value=MagicMock(session_id="KRX_REG")),
|
||||
):
|
||||
await process_blackout_recovery_orders(
|
||||
broker=broker,
|
||||
@@ -5845,6 +5846,19 @@ async def test_process_blackout_recovery_executes_valid_intents() -> None:
|
||||
)
|
||||
|
||||
broker.send_order.assert_called_once()
|
||||
row = db_conn.execute(
|
||||
"""
|
||||
SELECT action, quantity, session_id, rationale
|
||||
FROM trades
|
||||
WHERE stock_code = '005930'
|
||||
ORDER BY id DESC LIMIT 1
|
||||
"""
|
||||
).fetchone()
|
||||
assert row is not None
|
||||
assert row[0] == "BUY"
|
||||
assert row[1] == 1
|
||||
assert row[2] == "KRX_REG"
|
||||
assert row[3].startswith("[blackout-recovery]")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user