From 5fbfb46b057370858d688116dc742d318462a94e Mon Sep 17 00:00:00 2001 From: silencesdg Date: Thu, 21 May 2026 20:30:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=91=A8=E9=87=8D=E7=BD=AE=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E5=85=A8=E5=B9=B3=E6=8C=81=E4=BB=93=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E6=B8=85=E5=B3=B0=E5=80=BC+=E9=87=8D=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/monday_reset.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/scripts/monday_reset.py b/scripts/monday_reset.py index 1b6b547..d9187f1 100644 --- a/scripts/monday_reset.py +++ b/scripts/monday_reset.py @@ -1,9 +1,8 @@ #!/usr/bin/env python3 -"""开市后全平持仓 + 清峰值 + 重启 EA""" -import requests, json, time, sys, os, subprocess +"""开市后清峰值 + 重启 EA(不平仓,让持仓自然运行)""" +import time, sys, os, subprocess, requests API = "http://192.168.1.5:5555/api" -SYMBOL = "XAUUSDz" PROJECT_DIR = "/home/songkl/mt5_python_ea_suite" def log(msg): @@ -26,30 +25,17 @@ else: log("❌ 等待超时,市场未开市") sys.exit(1) -# 2. 获取所有持仓并平仓 -log("获取持仓...") -r = requests.get(f"{API}/positions/{SYMBOL}") -positions = r.json().get("positions", []) -log(f"共 {len(positions)} 单") - -total_pnl = 0 -for p in positions: - resp = requests.post(f"{API}/close", - json={"ticket": p["ticket"], "symbol": SYMBOL, "volume": p["volume"]}) - ok = resp.json().get("success", False) - total_pnl += p["profit"] - log(f"{'✅' if ok else '❌'} {p['ticket']} ${p['profit']:+.2f}") -log(f"总盈亏: ${total_pnl:+.2f}") - -# 3. 清峰值数据 +# 2. 清峰值数据(让拖尾从新一周的峰值重新开始) peak_file = os.path.join(PROJECT_DIR, "position_peaks.json") if os.path.exists(peak_file): os.remove(peak_file) log("✅ 峰值数据已清除") -# 4. 杀掉旧 EA,启动新 EA -subprocess.run(["pkill", "-9", "-f", "python.*run/realtime.py"], capture_output=True) +# 3. 杀掉旧 EA,启动新 EA(新一周用新配置) +subprocess.run(["pkill", "-f", "python.*run/realtime.py"], capture_output=True) time.sleep(2) +subprocess.run(["pkill", "-9", "-f", "python.*run/realtime.py"], capture_output=True) +time.sleep(1) log_file = os.path.join(PROJECT_DIR, "logs", "strategy.log") with open(log_file, "a") as f: