Files
MoFin/clients/tdx-relay/src/relay/tdx_client.py
T
zhiwei 9b9c37002a Initial: MoFin 持仓分析与策略管理系统
核心模块:
- 策略生命周期管理 (strategy_lifecycle.py)
- 技术分析引擎 (technical_analysis.py)
- 双维度策略评估 (strategy_evaluator.py)
- 实时行情获取 (get_realtime_prices.py)
- Web Dashboard (server.py, :8899)

提示词版本管理:
- prompt_manager 模块 — 统一管理所有知微提示词
- 8个提示词共24个版本已录入
- 策略→提示词版本关联追踪
- Dashboard「提示词」Tab

数据源增强:
- 服务端 POST /api/update/realtime 端点已就绪
- clients/tdx-relay/ — 小小莫在Windows上开发的通达信中继
- 解决港股15分钟延迟问题
2026-06-12 22:54:51 +08:00

63 lines
2.0 KiB
Python

"""TDX 行情客户端 — 连接通达信行情服务器获取实时数据
小小莫:
1. pip install opentdx
2. 在 config.py 中填入招商证券行情主站IP
3. 实现下面的方法
4. 运行 test_tdx_connect.py 验证
"""
# ═══════════════════════════════════════════
# 配置区 — 请替换为你的招商证券行情主站IP
# ═══════════════════════════════════════════
from .config import MARKET_SERVERS, HK_STOCKS
class TDXClient:
"""通达信行情客户端封装
用法:
client = TDXClient()
client.connect("113.105.73.88", 7709)
data = client.get_hk_quotes()
client.close()
"""
def __init__(self):
self.client = None
def connect(self, ip: str, port: int = 7709):
"""连接到通达信行情服务器"""
# TODO: 小小莫实现
# from opentdx.client.macExtendedClient import MacExtendedClient
# self.client = MacExtendedClient()
# self.client.connect(ip, port)
raise NotImplementedError("由小小莫实现")
def get_hk_quote(self, market_code: int, code: str) -> dict:
"""获取单只港股实时报价
Args:
market_code: 港股主板=31
code: 如 "00700"
Returns:
{"code": "00700", "name": "腾讯控股", "price": 463.6,
"change_pct": 1.55, "high": 468.0, "low": 460.2, ...}
"""
raise NotImplementedError("由小小莫实现")
def get_hk_quotes(self, codes: list = None) -> list:
"""批量获取港股实时报价"""
if codes is None:
codes = [(31, code) for _, code in HK_STOCKS]
raise NotImplementedError("由小小莫实现")
def close(self):
if self.client:
try:
self.client.disconnect()
except Exception:
pass
self.client = None