feat: mofin_db get_price_from_db/get_prices_batch helpers + strategy_evaluator DB-first

This commit is contained in:
知微
2026-07-01 22:56:24 +08:00
parent 8ed755bff9
commit 0aef122b69
2 changed files with 81 additions and 1 deletions
+13 -1
View File
@@ -44,9 +44,21 @@ def save_json(path, data):
def fetch_prices(codes):
"""批量拉腾讯行情"""
"""批量拉价格。DB 优先(price_monitor 维护),腾讯 API fallback"""
if not codes:
return {}
# 主通道: DB
try:
from mofin_db import get_prices_batch_from_db
db_results = get_prices_batch_from_db(codes)
if db_results:
return {code: {"name": "", "price": p, "prev_close": 0, "change_pct": chg or 0,
"high": 0, "low": 0} for code, (p, chg) in db_results.items()}
except Exception:
pass
# Fallback: 腾讯 API
symbols = []
code_map = {}
for c in codes: