migrate: remove JSON, DB-only — mo_data, server, scripts, prompts (27 files)
This commit is contained in:
@@ -19,6 +19,7 @@ import os
|
||||
import threading
|
||||
import time
|
||||
from datetime import datetime, time
|
||||
from mo_data import read_portfolio, read_decisions
|
||||
|
||||
# ── MoFin unified model ──────────────────────────────────────────────
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
@@ -226,8 +227,7 @@ def trigger_regen_sync(stock_codes=None):
|
||||
def load_cash():
|
||||
"""从 portfolio.json 实时读可用现金(可用 ≈ 实时买力),不硬编码"""
|
||||
try:
|
||||
with open(PORTFOLIO_PATH) as f:
|
||||
data = json.load(f)
|
||||
data = read_portfolio()
|
||||
if isinstance(data, dict):
|
||||
# 先读 cash_available(拆分了可用/冻结),fallback 到 cash
|
||||
return data.get("cash_available", data.get("cash", 0))
|
||||
@@ -338,8 +338,7 @@ def main():
|
||||
# 读 decisions.json 获取完整策略数据
|
||||
code_data = {}
|
||||
try:
|
||||
with open("/home/hmo/web-dashboard/data/decisions.json") as f:
|
||||
dec = json.load(f)
|
||||
dec = read_decisions()
|
||||
for e in dec.get("decisions", []):
|
||||
code_data[e["code"]] = e
|
||||
except Exception:
|
||||
@@ -395,8 +394,7 @@ def main():
|
||||
# 重评完成,re-read decisions.json 获取最新策略
|
||||
code_data = {}
|
||||
try:
|
||||
with open("/home/hmo/web-dashboard/data/decisions.json") as f:
|
||||
dec = json.load(f)
|
||||
dec = read_decisions()
|
||||
for e in dec.get("decisions", []):
|
||||
code_data[e["code"]] = e
|
||||
except Exception:
|
||||
@@ -417,8 +415,7 @@ def main():
|
||||
# 加载portfolio获取持仓信息(A/H去重用)
|
||||
pf = {"holdings": []}
|
||||
try:
|
||||
with open(PORTFOLIO_PATH) as f:
|
||||
pf = json.load(f)
|
||||
pf = read_portfolio()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@@ -492,8 +489,7 @@ def main():
|
||||
total_assets = 0
|
||||
available_cash = 0
|
||||
try:
|
||||
with open("/home/hmo/web-dashboard/data/portfolio.json") as f:
|
||||
pf = json.load(f)
|
||||
pf = read_portfolio()
|
||||
available_cash = pf.get("cash_available", pf.get("cash", 0)) or 0
|
||||
# 直接取 portfolio.json 的总资产(导入时已做港币→人民币换算)
|
||||
total_assets = pf.get("total_assets", 0) or 0
|
||||
@@ -845,7 +841,7 @@ def main():
|
||||
# ── T+2前瞻:扫描近期可能入买区的A股,提前准备现金 ──
|
||||
t2_lines = []
|
||||
try:
|
||||
dec_t2 = json.loads(open("/home/hmo/web-dashboard/data/decisions.json").read())
|
||||
dec_t2 = read_decisions()
|
||||
for entry in dec_t2.get("decisions", []):
|
||||
if entry.get("status") == "closed" or entry.get("type") != "自选策略":
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user