From 22f9425bc059a776603e5e9ff30ffc55af419482 Mon Sep 17 00:00:00 2001 From: hmo Date: Wed, 29 Jul 2026 04:09:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8C=E6=AD=A5scripts/=E4=B8=8Edeplo?= =?UTF-8?q?y/profile-scripts/=E5=8F=8C=E8=B7=9F=E8=B8=AA=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E4=B8=80=E8=87=B4(=E6=8D=A2=E4=BB=93?= =?UTF-8?q?=E8=AF=84=E5=88=86=E5=8D=87=E7=BA=A7)=E2=80=94=E2=80=94?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E5=AE=88=E5=8D=AB=E8=B7=A8=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E4=BC=A0=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/mofin_db.py | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/deploy/profile-scripts/mofin_db.py b/deploy/profile-scripts/mofin_db.py index 88fb8820..42c7cb6a 100644 --- a/deploy/profile-scripts/mofin_db.py +++ b/deploy/profile-scripts/mofin_db.py @@ -1809,34 +1809,9 @@ def flush_rec_digest(max_items=5): LEFT JOIN live_prices lp ON hs.code = lp.code WHERE hs.status='active' AND h.shares > 0 AND hs.timing_signal IN ('弱势持有','观望','持有') + ORDER BY CASE hs.timing_signal WHEN '弱势持有' THEN 0 WHEN '观望' THEN 1 ELSE 2 END, + h.position_pct DESC """).fetchall() - # ── v7.1因子评分升序排序(2026-07-29 老爸批准:按评分套取,卖因子最差的)── - try: - import sys as _sys2 - if "/home/hmo/MoFin" not in _sys2.path: - _sys2.path.insert(0, "/home/hmo/MoFin") - from backtest_framework import prepare_bars as _pb, compute_single_score as _cs - from datetime import datetime as _dt2, timedelta as _td2 - _end2 = _dt2.now().strftime('%Y-%m-%d') - _start2 = (_dt2.now() - _td2(days=150)).strftime('%Y-%m-%d') - _scored = [] - for w in weak: - _sc = 0 - try: - _bars = _pb(w['code'], _start2, _end2) - if _bars and len(_bars) >= 25: - _r = _cs(_bars) - _sc = _r[0] if _r else 0 - except Exception: - pass - _scored.append((_sc, w)) - _scored.sort(key=lambda x: x[0]) # 评分最低 = 优先套取 - weak = [w for _, w in _scored] - print(" [换仓] 因子评分排序: " + ", ".join(f"{w['name']}({s})" for s, w in _scored[:5]), flush=True) - except Exception as _se: - print(f" [换仓] 评分排序失败(回退信号排序): {_se}", flush=True) - weak = sorted(weak, key=lambda w: ({'弱势持有': 0, '观望': 1}.get(w['timing_signal'], 2), - -(w['position_pct'] or 0))) if weak: need_pct = queued[0][1] plan = []