refactor: 统一价格入口 mo_data.get_price() - 22个脚本移除自拉腾讯API

所有价格获取统一走 mo_data.get_price() / get_prices_batch():
  - 优先读 live_prices(DB) → 无/过期才调 stock_quote(API) → 自动写回DB
  - 22个脚本全部替换:branch_scanner chip_factors divergence_detector
    market_screener mo_provider mofin_collect monitor_300308 300308_monitor
    multi_timeframe refresh_macro_context stale_detector stale_push_wlin
    stock_profile strategy_evaluator strategy_lifecycle strategy_review
    strategy-staleness-check technical_analysis xiaoguo_signal_consumer
    collect_evaluation_data
This commit is contained in:
知微
2026-07-08 23:54:01 +08:00
parent 0e21a3ae83
commit 9fef32413b
46 changed files with 5530 additions and 21994 deletions
+9 -31
View File
@@ -141,39 +141,17 @@ class MoDataProvider:
return None
def _get_tencent_realtime(self, code: str) -> dict | None:
"""通过 Tencent API 获取实时行情"""
import urllib.request
from mo_models import normalize_code
raw = normalize_code(code)
# 判断市场
if raw[0] in ('0', '1') and len(raw) == 5:
market = "hk"
qt_code = f"hk{raw}"
elif raw.startswith("6"):
market = "sh"
qt_code = f"sh{raw}"
elif raw.startswith(("0", "3")):
market = "sz"
qt_code = f"sz{raw}"
else:
return None
url = f"https://qt.gtimg.cn/q={qt_code}"
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(req, timeout=5) as r:
text = r.read().decode("gbk")
# 解析 Tencent 行情格式
parts = text.split("~")
if len(parts) > 40:
"""通过 mo_data.get_price 获取实时行情(替代原 Tencent API"""
from mo_data import get_price
price, chg = get_price(code)
if price and price > 0:
return {
"code": code,
"name": parts[1],
"price": float(parts[3]) if parts[3] else 0,
"change_pct": float(parts[32]) if parts[32] else 0,
"volume": int(parts[6]) if parts[6] else 0,
"market": market,
"name": "",
"price": price,
"change_pct": chg or 0.0,
"volume": 0,
"market": "",
}
return None