feat: macro_context/market数据全部DB优先,JSON回退
- 建 macro_context_log 表,macro_context_collector.py 双写 - strategy_lifecycle.py load_macro_context() 优先DB - strategy_tree.py detect_scenario() 优先DB - stale_push_wlin.py load_macro_line() 优先DB - xiaoguo_signal_consumer.py 大盘判断优先DB - stock_profile.py load_macro() 优先DB - system_audit.py 管道审计改查DB market_snapshots - JSON保留作fallback,确保过渡期不中断
This commit is contained in:
+15
-1
@@ -119,7 +119,21 @@ def load_mtf_cache() -> dict:
|
||||
|
||||
|
||||
def load_macro() -> dict:
|
||||
"""加载宏观上下文"""
|
||||
"""加载宏观上下文,优先DB"""
|
||||
try:
|
||||
import sqlite3
|
||||
conn = sqlite3.connect(os.path.join(DATA_DIR, "mofin.db"))
|
||||
row = conn.execute(
|
||||
"SELECT indices, structure, key_sectors FROM macro_context_log "
|
||||
"WHERE has_valid_data=1 ORDER BY created_at DESC LIMIT 1"
|
||||
).fetchone()
|
||||
conn.close()
|
||||
if row:
|
||||
return {"indices": json.loads(row[0] or "{}"),
|
||||
"structure": json.loads(row[1] or "{}"),
|
||||
"key_sectors": json.loads(row[2] or "[]")}
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
with open(MACRO_PATH) as f:
|
||||
return json.load(f)
|
||||
|
||||
Reference in New Issue
Block a user