feat: 市场抽象层market_config.py——市场判断/行情符号/市场配置唯一事实源,收敛6处散落实现(market_data/price_monitor x2/stale_push_wlin/technical_analysis/strategy_lab)。纯重构行为等价,为港股接入打底

This commit is contained in:
hmo
2026-08-14 15:56:47 +08:00
parent 442427b214
commit 4c2821aa67
6 changed files with 202 additions and 30 deletions
+10 -9
View File
@@ -13,9 +13,14 @@
import json
import os
import sys
import urllib.request
from datetime import datetime, date
# 确保本文件所在目录可导入(market_config 与之同目录;本模块会被 MoFin 根脚本跨目录 import
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from market_config import kline_symbol
# 腾讯API字段索引
F = {
"name": 1, "code": 2, "price": 3, "close_yest": 4, "open": 5,
@@ -43,15 +48,11 @@ def _save_history(h):
def _market_prefix(code):
"""根据代码确定腾讯API前缀"""
if code.startswith("sh") or code.startswith("sz") or code.startswith("hk"):
code = code[2:] if code[2:].isdigit() else code
raw = str(code).split("_")[0]
if len(raw) == 5 and raw.isdigit():
return "hk"
if raw.startswith("6") or raw.startswith("5"):
return "sh"
return "sz"
"""根据代码确定腾讯API前缀(统一走 market_config.kline_symbol,规则以它为准)"""
sym = kline_symbol(code)
if not sym:
return "sz" # 兼容旧兜底(非5/6位数字等)
return sym[:2]
def get_quote(code):