Add key-level auto trade, AI analysis, and trading UX improvements.

Key monitors use 5m close triggers with WeChat alerts and box/convergence auto orders; add pending-order worker, structured WeChat notify, AI settings/messages, session clock, CTP margin sizing, and dual-layer position limits.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-28 10:36:56 +08:00
parent 0109b59f27
commit 840e88daad
33 changed files with 2514 additions and 143 deletions
+30
View File
@@ -285,6 +285,36 @@ def sync_trade_logs_from_ctp(
row_vals + ("ctp", key, 1),
)
stats["synced"] += 1
try:
from trade_notify import notify_trade_log_close
from trading_context import trading_mode_label
from app import get_setting, send_wechat_msg
from ai_worker import schedule_ai_event_analysis
from db_conn import DB_PATH
notify_trade_log_close(
send_wechat=send_wechat_msg,
get_setting=get_setting,
mode_label=trading_mode_label(get_setting),
capital=capital,
sym=ths,
symbol_name=codes.get("name") or mon.get("symbol_name") or ths,
direction=direction,
entry=entry,
close_price=close_px,
sl=float(sl) if sl is not None else None,
tp=float(tp) if tp is not None else None,
lots=lots,
pnl_net=pnl_net,
equity_after=equity_after,
holding_minutes=minutes,
result=result,
monitor_type=monitor_type,
schedule_ai_fn=schedule_ai_event_analysis,
db_path=DB_PATH,
)
except Exception as exc:
logger.debug("ctp close notify: %s", exc)
if stats["synced"] or stats["updated"]:
try: