mirror of
https://github.com/silencesdg/mt5_python_ea_suite.git
synced 2026-07-29 03:37:43 +00:00
feat: 适应度门槛95+swing_point策略+多项改进
- 新增适应度门槛: min_backtest_fitness=95, 适应度<95暂停开仓 - 新增 SwingPointRetest 策略替代 Turtle - 新增 monday_reset.py 周重置脚本 - exit_rules: 拖尾止损相对回撤模式 - market_state: 趋势检测优化 - position: 一票制并发锁+合约规格缓存 - optimize: Optuna 替代 DEAP 遗传算法 - realtime_trader: 适应度门槛+同向递增 - weights: 动态权重管理 - cron_optimize: PYTHONPATH 修复 - .gitignore: 排除生成文件
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import fcntl
|
||||
from datetime import datetime
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
@@ -16,8 +17,18 @@ from config import (
|
||||
)
|
||||
from logger import setup_logger
|
||||
|
||||
LOCK_FILE = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), '.ea.lock')
|
||||
|
||||
|
||||
def main():
|
||||
# ★ 进程锁:防止多实例同时运行
|
||||
lock_fd = os.open(LOCK_FILE, os.O_CREAT | os.O_RDWR, 0o644)
|
||||
try:
|
||||
fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except BlockingIOError:
|
||||
print("❌ 已有 EA 实例在运行,退出")
|
||||
os.close(lock_fd)
|
||||
return
|
||||
log_level = REALTIME_CONFIG.get('logging_level', 'INFO')
|
||||
setup_logger(log_level)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user