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
+7 -14
View File
@@ -16,28 +16,21 @@ branch_scanner.py — 分支自成长数据采集器(全静默)
import json, sys, re
from datetime import datetime
from urllib.request import Request, urlopen
from mo_data import read_decisions
from mo_data import get_price as md_get_price
from mofin_db import get_conn, write_holding_strategy
SCANNER_STATE = "/home/hmo/web-dashboard/data/scanner_state.json"
def get_price(code):
# DB 优先
try: from mofin_db import get_price_from_db; p, _ = get_price_from_db(code); return p if p else 0
except: pass
# Fallback: 腾讯
mkt = "sh" if code.startswith("6") or code.startswith("5") else "sz"
url = f"http://qt.gtimg.cn/q={mkt}{code}"
req = Request(url, headers={"User-Agent": "Mozilla/5.0"})
# 统一走 mo_data.get_price(含 DB 优先 + API 兜底)
try:
resp = urlopen(req, timeout=5).read().decode("gbk")
parts = resp.split("~")
if len(parts) > 3:
return float(parts[3])
except Exception:
return None
p, _ = md_get_price(code)
return p if p else 0
except:
try: from mofin_db import get_price_from_db; p, _ = get_price_from_db(code); return p if p else 0
except: return None
def get_scenario():