mirror of
https://github.com/silencesdg/mt5_python_ea_suite.git
synced 2026-08-08 16:37:55 +00:00
feat: 远程MT5数据源 + 信号对冲/回撤锁仓模块
新增: - core/risk/hedge.py: 对冲管理器 - 信号对冲: 加权信号反向超阈值→半仓反向 - 回撤锁仓: 浮亏超-0.3%→全仓锁死 - 自动解锁: 信号回正/对冲止盈0.5% 改动: - run/backtest.py: 支持远程数据源回测 - run/realtime.py: 远程/本地双模式 - core/risk/position.py: 集成HedgeManager - core/risk/controller.py: 传递weighted_signal - execution/realtime_trader.py: 传入加权信号 - core/data/live.py, utils.py: MetaTrader5懒加载(ARM兼容) - config.py: HEDGE_CONFIG, REMOTE配置, INITIAL_CAPITAL=1944 今日实盘: 9单, +7.4% (944→088)
This commit is contained in:
+17
-4
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""实时交易入口 — python -m run.realtime"""
|
||||
"""实时交易入口 — 支持远程/本地两种数据源"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
@@ -9,8 +9,11 @@ from datetime import datetime
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from execution.realtime_trader import RealtimeTrader
|
||||
from core.data import LiveDataProvider, DryRunDataProvider
|
||||
from config import REALTIME_CONFIG, INITIAL_CAPITAL
|
||||
from core.data import LiveDataProvider, DryRunDataProvider, RemoteDataProvider
|
||||
from config import (
|
||||
REALTIME_CONFIG, INITIAL_CAPITAL,
|
||||
REMOTE_SERVER_HOST, REMOTE_SERVER_PORT, DATA_PROVIDER_MODE,
|
||||
)
|
||||
from logger import setup_logger
|
||||
|
||||
|
||||
@@ -23,10 +26,20 @@ def main():
|
||||
print("=" * 60)
|
||||
print("MT5 智能交易系统 - 实时交易")
|
||||
print(f"启动时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f"数据源: {DATA_PROVIDER_MODE.upper()}")
|
||||
print(f"运行模式: {'模拟运行' if is_dry_run else '实盘交易'}")
|
||||
print("=" * 60)
|
||||
|
||||
if is_dry_run:
|
||||
if DATA_PROVIDER_MODE == "remote":
|
||||
data_provider = RemoteDataProvider(host=REMOTE_SERVER_HOST, port=REMOTE_SERVER_PORT)
|
||||
if not data_provider.initialize():
|
||||
print("❌ 远程 MT5 API 连接失败,请检查 Windows 端服务是否运行")
|
||||
return
|
||||
print(f"✅ 已连接远程 MT5 {REMOTE_SERVER_HOST}:{REMOTE_SERVER_PORT}")
|
||||
acct = data_provider.get_account_info()
|
||||
if acct:
|
||||
print(f" 账号: {acct.get('login','?')} 余额: ${acct.get('balance','?'):.2f}")
|
||||
elif is_dry_run:
|
||||
data_provider = DryRunDataProvider(initial_equity=INITIAL_CAPITAL)
|
||||
else:
|
||||
print("WARNING: 即将启动实盘交易模式!")
|
||||
|
||||
Reference in New Issue
Block a user