feat(stock): webai report — edge diff→agent-office push→상태/이력(전송성공시만)

This commit is contained in:
2026-07-02 19:56:58 +09:00
parent 134b9e5d07
commit 2906a2ae3e
3 changed files with 112 additions and 1 deletions

View File

@@ -5,6 +5,9 @@ Windows 워커가 GET /api/webai/trade-alert/monitor-set 로 받는 응답을
NAS는 watchlist screener 최신 성공 run 후보를 buy_targets로, 보유 종목을
sell_targets로 병합해 넘긴다. TA/조건판정은 워커 쪽 책임.
"""
import os
import httpx
from datetime import datetime, timedelta, timezone, time as _time
from typing import Optional
@@ -117,3 +120,18 @@ def diff_firing(reported: list, prev: set) -> dict:
"cleared": cleared,
"seen": sorted(cur_keys),
}
def notify_agent_office(alerts: list) -> bool:
"""신규 alert들을 agent-office로 push (계약 §5.2). 전송 성공 시 True.
실패(네트워크 오류/비-200)는 False — 호출부가 상태/이력 미채택 후 다음
사이클에 동일 alert를 재시도하도록 한다(멱등, at-least-once).
"""
url = os.getenv("AGENT_OFFICE_URL", "http://agent-office:8000") + "/api/agent-office/stock/trade-alert"
try:
with httpx.Client(timeout=10) as c:
resp = c.post(url, json={"alerts": alerts})
return resp.status_code == 200
except httpx.HTTPError:
return False