mirror of
https://github.com/silencesdg/mt5_python_ea_suite.git
synced 2026-07-28 11:17:43 +00:00
4cb4f4a15e
- 重构核心模块:DataProvider 依赖注入、RiskController 门面、信号注册表 - 新增 FastAPI 代理服务 (run/server.py),支持局域网远程调用 MT5 - 新增 RemoteDataProvider + AttrDict,远端无缝替代 LiveDataProvider - 新增序列化模块,MT5 对象转 JSON 兼容格式 - 重构入口点至 run/ 包,支持 python -m run.realtime/server/backtest/optimize - 更新 CLAUDE.md 文档 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
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):
|
|
"""发送订单"""
|
|
|
|
@abstractmethod
|
|
def close_position(self, ticket, symbol, volume):
|
|
"""平仓"""
|