feat(strategy): WeChat notify on trend and roll plan start/end

Add shared strategy_wechat_notify helpers; hook trend execute/finalize and roll group open/close across four exchanges and Gate bot.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-04 13:35:21 +08:00
parent 3b4120a36e
commit 52d97482f2
5 changed files with 373 additions and 6 deletions
+39
View File
@@ -4604,6 +4604,23 @@ def _trend_finalize_plan(conn, row, result_label, exit_price, closed_at=None):
if not getattr(cur, "rowcount", 0):
return
conn.commit()
try:
from strategy_trend_register import build_trend_config
from strategy_wechat_notify import notify_trend_plan_ended
_tcfg = build_trend_config(sys.modules[__name__])
notify_trend_plan_ended(
_tcfg,
plan_id=plan_id,
symbol=sym,
direction=direction,
end_type=result_label,
result_label=res,
exit_price=float(exit_price) if exit_price is not None else None,
pnl_amount=float(pnl_amount) if pnl_amount is not None else None,
)
except Exception:
pass
try:
cfg = app.extensions.get("strategy_trend_cfg") or {}
closed = conn.execute(
@@ -6624,6 +6641,28 @@ def execute_trend_pullback():
)
conn.execute("DELETE FROM trend_pullback_previews WHERE id=?", (pid,))
conn.commit()
try:
from strategy_trend_register import build_trend_config
from strategy_wechat_notify import notify_trend_plan_started
_tcfg = build_trend_config(sys.modules[__name__])
notify_trend_plan_started(
_tcfg,
plan_id=new_plan_id,
symbol=symbol,
direction=direction,
leverage=leverage,
stop_loss=stop_loss,
take_profit=take_profit,
add_upper=add_upper,
risk_percent=risk_percent,
dca_legs=n_legs,
first_order_amount=first_amt,
avg_entry=fill1,
snapshot_usdt=snap,
)
except Exception:
pass
conn.close()
flash(
f"趋势回调已执行:可用余额(执行时){round(snap, 2)}U;计划保证金约 {round(margin_plan, 2)}U"