mirror of
https://github.com/silencesdg/mt5_python_ea_suite.git
synced 2026-07-28 03:07:48 +00:00
430376eb61
- 一票制: _pending_long/_pending_short 计数器防同一周期内多信号穿透 - 硬止损: MT5下单时附带sl/tp,倍率1.5x(止损)/1.3x(止盈),比EA软止损更宽 - config.py: 新增 hard_sl_multiplier/hard_tp_multiplier - 全部 send_order 链路(abc/remote/live/server/dryrun/backtest) 支持 sl/tp 参数 - 对冲模块: 彻底移除 - 日志: 去重+30轮摘要
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
from abc import ABC, abstractmethod
|
|
|
|
|
|
class DataProvider(ABC):
|
|
"""数据提供者抽象基类 — 定义所有数据访问的统一接口"""
|
|
|
|
@property
|
|
def is_live(self):
|
|
return False
|
|
|
|
@abstractmethod
|
|
def initialize(self):
|
|
"""初始化连接"""
|
|
|
|
@abstractmethod
|
|
def shutdown(self):
|
|
"""关闭连接"""
|
|
|
|
@abstractmethod
|
|
def get_current_price(self, symbol):
|
|
"""获取当前价格: {'bid', 'ask', 'last', 'time'}"""
|
|
|
|
@abstractmethod
|
|
def get_historical_data(self, symbol, timeframe, count, **kwargs):
|
|
"""获取历史K线数据"""
|
|
|
|
@abstractmethod
|
|
def get_account_info(self):
|
|
"""获取账户信息"""
|
|
|
|
@abstractmethod
|
|
def get_positions(self, symbol):
|
|
"""获取当前持仓"""
|
|
|
|
@abstractmethod
|
|
def get_symbol_info(self, symbol):
|
|
"""获取品种信息(合约规格等)"""
|
|
|
|
@abstractmethod
|
|
def send_order(self, symbol, order_type, volume, sl=None, tp=None):
|
|
"""发送订单"""
|
|
|
|
@abstractmethod
|
|
def close_position(self, ticket, symbol, volume):
|
|
"""平仓"""
|