diff --git a/__pycache__/strategy_lifecycle.cpython-312.pyc b/__pycache__/strategy_lifecycle.cpython-312.pyc index bc5d3db..53b3788 100644 Binary files a/__pycache__/strategy_lifecycle.cpython-312.pyc and b/__pycache__/strategy_lifecycle.cpython-312.pyc differ diff --git a/data/mofin.db-shm b/data/mofin.db-shm new file mode 100644 index 0000000..c9e3001 Binary files /dev/null and b/data/mofin.db-shm differ diff --git a/data/mofin.db-wal b/data/mofin.db-wal new file mode 100644 index 0000000..e507e1c Binary files /dev/null and b/data/mofin.db-wal differ diff --git a/data/portfolio.json b/data/portfolio.json index d22799d..ba95f0b 100644 --- a/data/portfolio.json +++ b/data/portfolio.json @@ -5,9 +5,9 @@ "name": "中际旭创", "shares": 100, "cost": 1316.53, - "price": 1145.0, + "price": 1143.84, "market_value": 114101.0, - "change_pct": 0.17, + "change_pct": 0.07, "currency": "CNY", "position_pct": 15.27, "_currency": "CNY" @@ -17,9 +17,9 @@ "name": "长飞光纤光缆", "shares": 500, "cost": 228.65, - "price": 178.26, + "price": 177.39, "market_value": 89910.0, - "change_pct": 3.859, + "change_pct": 3.35, "currency": "CNY", "position_pct": 13.47, "_currency": "CNY" @@ -29,9 +29,9 @@ "name": "丘钛科技", "shares": 11000, "cost": 11.68, - "price": 6.1, + "price": 6.09, "market_value": 67210.0, - "change_pct": 4.762, + "change_pct": 4.464, "currency": "CNY", "position_pct": 7.97, "_currency": "CNY" @@ -41,9 +41,9 @@ "name": "紫金矿业", "shares": 2400, "cost": 39.89, - "price": 27.8, + "price": 27.86, "market_value": 66864.0, - "change_pct": 5.7, + "change_pct": 5.93, "currency": "CNY", "position_pct": 7.34, "_currency": "CNY" @@ -53,9 +53,9 @@ "name": "海博思创", "shares": 200, "cost": 266.95, - "price": 254.75, + "price": 254.42, "market_value": 50842.0, - "change_pct": -0.38, + "change_pct": -0.5, "currency": "CNY", "position_pct": 6.31, "_currency": "CNY" @@ -65,9 +65,9 @@ "name": "中芯国际", "shares": 300, "cost": 126.07, - "price": 142.97, + "price": 143.01, "market_value": 42600.0, - "change_pct": -0.78, + "change_pct": -0.76, "currency": "CNY", "position_pct": 5.44, "_currency": "CNY" @@ -77,9 +77,9 @@ "name": "建滔积层板", "shares": 500, "cost": 76.5, - "price": 74.17, + "price": 73.96, "market_value": 37325.0, - "change_pct": 2.088, + "change_pct": 1.79, "currency": "CNY", "position_pct": 5.28, "_currency": "CNY" @@ -89,9 +89,9 @@ "name": "华恒生物", "shares": 2800, "cost": 21.51, - "price": 16.72, + "price": 16.71, "market_value": 46900.0, - "change_pct": -1.36, + "change_pct": -1.42, "currency": "CNY", "position_pct": 5.25, "_currency": "CNY" @@ -101,9 +101,9 @@ "name": "宁德时代", "shares": 100, "cost": 401.78, - "price": 380.24, + "price": 380.88, "market_value": 38032.0, - "change_pct": -0.55, + "change_pct": -0.38, "currency": "CNY", "position_pct": 4.64, "_currency": "CNY" @@ -113,9 +113,9 @@ "name": "比亚迪股份", "shares": 600, "cost": 90.92, - "price": 71.83, + "price": 71.4, "market_value": 43044.0, - "change_pct": 5.811, + "change_pct": 5.172, "currency": "CNY", "position_pct": 4.62, "_currency": "CNY" @@ -137,9 +137,9 @@ "name": "腾讯", "shares": 100, "cost": null, - "price": 376.8, + "price": 374.72, "market_value": 37541.0, - "change_pct": 1.023, + "change_pct": 0.465, "currency": "CNY", "position_pct": null, "_currency": "CNY" @@ -149,9 +149,9 @@ "name": "中芯国际", "shares": 500, "cost": 65.84, - "price": 68.41, + "price": 67.63, "market_value": 34440.0, - "change_pct": -1.866, + "change_pct": -2.985, "currency": "CNY", "position_pct": 4.2, "_currency": "CNY" @@ -161,9 +161,9 @@ "name": "长芯博创", "shares": 100, "cost": 231.46, - "price": 226.5, + "price": 226.24, "market_value": 22599.0, - "change_pct": 2.03, + "change_pct": 1.91, "currency": "CNY", "position_pct": 3.2, "_currency": "CNY" @@ -185,9 +185,9 @@ "name": "中科电气", "shares": 1400, "cost": 22.29, - "price": 14.38, + "price": 14.37, "market_value": 20062.0, - "change_pct": 1.48, + "change_pct": 1.41, "currency": "CNY", "position_pct": 2.42, "_currency": "CNY" @@ -197,9 +197,9 @@ "name": "模塑科技", "shares": 1400, "cost": 14.83, - "price": 17.62, + "price": 17.66, "market_value": 25088.0, - "change_pct": 4.45, + "change_pct": 4.68, "currency": "CNY", "position_pct": 2.41, "_currency": "CNY" @@ -209,9 +209,9 @@ "name": "法拉电子", "shares": 100, "cost": 147.18, - "price": 160.0, + "price": 160.15, "market_value": 15900.0, - "change_pct": -2.62, + "change_pct": -2.53, "currency": "CNY", "position_pct": 2.3, "_currency": "CNY" @@ -221,20 +221,20 @@ "name": "中国神华", "shares": 500, "cost": 39.79, - "price": 34.59, + "price": 34.56, "market_value": 17305.0, - "change_pct": 0.758, + "change_pct": 0.657, "currency": "CNY", "position_pct": 2.14, "_currency": "CNY" } ], - "total_assets": 860913.13, - "total_mv": 780437.13, + "total_assets": 859635.43, + "total_mv": 779159.43, "stock_value": null, "cash": 80476.0, "frozen_cash": 0.0, - "position_pct": 90.65, + "position_pct": 90.64, "currency": "CNY", - "updated_at": "2026-07-03 13:42" + "updated_at": "2026-07-03 13:44" } \ No newline at end of file diff --git a/scripts/price_monitor.py b/scripts/price_monitor.py index 99c1854..34b5901 100644 --- a/scripts/price_monitor.py +++ b/scripts/price_monitor.py @@ -314,7 +314,7 @@ def refresh_data_prices(): if code in prices: p, c, chg = prices[code] live["prices"][code] = {"price": p, "change_pct": chg} - json.dump(live, open("/home/hmo/web-dashboard/data/live_prices.json", "w"), indent=2) + # json.dump(live, ...) — 已迁移到 DB,见根 price_monitor.py except Exception: pass @@ -739,7 +739,8 @@ def run_once(round_label=""): # === 3.5 资金流异常检测(2026-06-27 新增)=== try: - cf = json.load(open("/home/hmo/web-dashboard/data/capital_flow_cache.json")) + from mofin_db import get_conn, read_capital_flow_cache + cf = read_capital_flow_cache(get_conn()) # 检查所有 active decision 中的资金流异常 for d in active: code = d["code"] diff --git a/strategy_lifecycle.py b/strategy_lifecycle.py index fb7e8a1..c475b3f 100644 --- a/strategy_lifecycle.py +++ b/strategy_lifecycle.py @@ -989,7 +989,7 @@ def reassess_strategy(code, name, price, cost, shares, current_action, time_horizon = "2周~3月" position_advice = "中等仓位" try: - mtf_cache = json.load(open("/home/hmo/web-dashboard/data/multi_tf_cache.json")) + mtf_cache = mtf._load_mtf_cache() stock_data = mtf_cache.get(code, {}) daily_klines = stock_data.get("daily", []) fund = stock_data.get("fundamentals", {}) @@ -1537,11 +1537,8 @@ def load_stock_news_sentiment(code): def load_fundamentals(code): """加载个股基本面""" try: - path = "/home/hmo/web-dashboard/data/multi_tf_cache.json" - if not os.path.exists(path): - return {} - m = json.load(open(path)) - return m.get(code, {}).get("fundamentals", {}) or {} + cache = mtf._load_mtf_cache() + return cache.get(code, {}).get("fundamentals", {}) or {} except Exception: return {}