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:
+11
-20
@@ -4,9 +4,10 @@
|
||||
支持策略动态调整——输出状态变化。
|
||||
"""
|
||||
|
||||
import json, os, sys, urllib.request
|
||||
import json, os, sys
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from mo_data import get_price as md_get_price
|
||||
|
||||
STATE_PATH = "/home/hmo/.hermes/300308_monitor_state.json"
|
||||
|
||||
@@ -22,26 +23,16 @@ LEVEL_WEAK = {"label": "○ 弱信号", "price_min": 1307, "price_breach": 1298,
|
||||
|
||||
|
||||
def get_price():
|
||||
url = "https://qt.gtimg.cn/q=sz300308"
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
|
||||
resp = urllib.request.urlopen(req, timeout=10)
|
||||
data = resp.read().decode("gbk")
|
||||
parts = data.split("~")
|
||||
price = float(parts[3])
|
||||
high = float(parts[33])
|
||||
low = float(parts[34])
|
||||
change_pct = float(parts[32])
|
||||
volume = int(parts[6])
|
||||
buy_vol = int(parts[7]) if parts[7] else 0
|
||||
sell_vol = int(parts[8]) if parts[8] else 0
|
||||
"""从统一入口获取实时价"""
|
||||
price, change_pct = md_get_price('300308')
|
||||
return {
|
||||
"price": price,
|
||||
"high": high,
|
||||
"low": low,
|
||||
"change_pct": change_pct,
|
||||
"volume": volume,
|
||||
"buy_vol": buy_vol,
|
||||
"sell_vol": sell_vol,
|
||||
"price": price or 0,
|
||||
"high": 0,
|
||||
"low": 0,
|
||||
"change_pct": change_pct or 0,
|
||||
"volume": 0,
|
||||
"buy_vol": 0,
|
||||
"sell_vol": 0,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user