refactor: remove duplicate scripts + JSON constants + update docs
This commit is contained in:
@@ -5,9 +5,6 @@ import json, sys, os
|
||||
from mo_data import read_portfolio, read_decisions, read_watchlist
|
||||
from mofin_db import get_conn, write_holding_strategy
|
||||
|
||||
DECISIONS_PATH = "/home/hmo/web-dashboard/data/decisions.json"
|
||||
DECISIONS_BAK = DECISIONS_PATH + ".bak"
|
||||
|
||||
try:
|
||||
dec = read_decisions()
|
||||
except Exception as e:
|
||||
@@ -40,18 +37,9 @@ for d in dec.get("decisions", []):
|
||||
if new_trig:
|
||||
print(f" {code} {name}: trigger={new_trig}")
|
||||
|
||||
# 备份
|
||||
os.makedirs(os.path.dirname(DECISIONS_BAK), exist_ok=True)
|
||||
with open(DECISIONS_BAK, 'w') as f:
|
||||
json.dump(mo_data.read_decisions(), f, indent=2, ensure_ascii=False)
|
||||
|
||||
# DB 写入(替代 json.dump)
|
||||
conn = get_conn()
|
||||
for d in dec.get("decisions", []):
|
||||
write_holding_strategy(conn, d.get("code", ""), d.get("name", ""), d)
|
||||
conn.close()
|
||||
# [migrated to DB] — cold backup removed
|
||||
# with open(DECISIONS_PATH, 'w') as f:
|
||||
# json.dump(dec, f, indent=2, ensure_ascii=False)
|
||||
|
||||
print(f"\n共{count}只,已更新trigger字段")
|
||||
|
||||
Reference in New Issue
Block a user