From 0ecdfbc861a2e87aa3bff0203898fa8f2d2aa435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Wed, 24 Jun 2026 13:48:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0OCR=E5=88=87=E6=8D=A2?= =?UTF-8?q?=EF=BC=9A=E5=B0=8F=E6=9E=9CGLM-OCR-8bit=E4=BC=98=E5=85=88?= =?UTF-8?q?=EF=BC=8CTesseract=E9=99=8D=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MoFin/server.py 的 _ocr_image 改为: 1. 优先调小果 gateway (192.168.1.122:18003) 的 GLM-OCR-8bit 2. 失败/无响应则自动降级到本地 Tesseract(预处理+chi_sim+eng) 3. fallback逻辑保留原预处理管道(放大/锐化/二值化) ocr_client.py 模块独立可调用,兼作CLI工具 --- data/decisions.json | 950 +++++++++++++++++++++++++++++++++++++--- data/portfolio.json | 96 +++- data/price_history.json | 14 +- server.py | 14 +- 4 files changed, 979 insertions(+), 95 deletions(-) diff --git a/data/decisions.json b/data/decisions.json index 8797758..a9c8c85 100644 --- a/data/decisions.json +++ b/data/decisions.json @@ -142,18 +142,18 @@ { "code": "000711", "name": "ST京蓝", - "price": 5.09, + "price": 5.06, "cost": 0, "shares": 0, "avg_price": 0, - "action": "盈利持有 | ⚠️盈亏比不足1:1.5,不建议买入 | 目标5.38 | 止损4.35 | 买入区4.99~5.08 | 信号:观望", - "stop_loss": 4.35, - "entry_low": 4.99, - "entry_high": 5.08, - "tech_snapshot": "形态:长影星线/neutral 量价:主动卖盘占优 强撑:4.86 弱撑:4.88 弱压:5.27 强压:5.38", + "action": "盈利持有 | ⚠️盈亏比偏低(1:1.6),谨慎买入 | 目标5.38 | 止损4.86 | 买入区4.96~5.07 | 信号:观望", + "stop_loss": 4.86, + "entry_low": 4.96, + "entry_high": 5.07, + "tech_snapshot": "形态:长影星线/neutral 量价:主动卖盘占优 强撑:4.86 弱撑:4.86 弱压:5.25 强压:5.38", "timing_signal": "观望", - "rr_ratio": 1.38, - "status": "review", + "rr_ratio": 1.6, + "status": "updated", "note": "⚠️盈亏比不足1:1.5,不建议买入", "timestamp": "2026-06-24 13:29", "updated_at": "2026-06-24 13:29", @@ -279,7 +279,110 @@ "reason": "技术面重评: 止损4.36→4.35 | 形态:长影星线/neutral 量价:主动卖盘占优 强撑:4.86 弱撑:4.88 弱压:5.27 强压:5.38", "trigger": "技术面重评" } - ] + ], + "strategy_tree": { + "branches": [ + { + "id": "000711_stop_loss", + "condition": { + "price": "<4.86" + }, + "action": { + "type": "sell", + "amount": "all", + "reason": "止损" + }, + "priority": 0, + "rationale": "止损保护本金", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "000711_buy_dip", + "condition": { + "scenario": "weak_consolidation", + "price": "<=5.07", + "price_lower": ">=4.96" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": 4.96, + "reason": "回调支撑买入" + }, + "priority": 1, + "rationale": "价格回调到支撑区,弱势市场低吸", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "000711_breakout_chase", + "condition": { + "scenario": "bullish_recovery", + "price": ">=5.38" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": "market", + "reason": "突破确认追涨" + }, + "priority": 2, + "rationale": "价格突破阻力,确认上升趋势后买入", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "000711_trim", + "condition": { + "scenario": "sharp_decline", + "loss_pct": "<-15%" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "急跌降风险" + }, + "priority": 3, + "rationale": "急跌市场,深套股减半仓减少敞口", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "000711_take_profit", + "condition": { + "price": ">=5.38" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "止盈锁利" + }, + "priority": 4, + "rationale": "达到目标价,减半仓锁定利润", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "000711_hold", + "condition": {}, + "action": { + "type": "hold", + "reason": "无明确信号,继续持有" + }, + "priority": 99, + "rationale": "没有分支匹配时的默认动作", + "trigger_count": 1, + "success_rate": null, + "last_triggered": "2026-06-24" + } + ] + } }, { "code": "001309", @@ -405,17 +508,17 @@ { "code": "002594", "name": "比亚迪", - "price": 83.84, + "price": 83.76, "cost": 0, "shares": 0, "avg_price": 0, - "action": "盈利持有 | 目标92.89 | 止损75.73 | 买入区82.16~85.52 | 信号:观望", - "stop_loss": 75.73, - "entry_low": 82.16, - "entry_high": 85.52, - "tech_snapshot": "形态:带下影阴线/neutral 量价:主动卖盘占优 强撑:76.5 弱撑:82.84 弱压:85.0 强压:92.89", + "action": "盈利持有 | 目标92.87 | 止损81.25 | 买入区82.08~85.44 | 信号:观望", + "stop_loss": 81.25, + "entry_low": 82.08, + "entry_high": 85.44, + "tech_snapshot": "形态:带下影阴线/neutral 量价:主动卖盘占优 强撑:76.5 弱撑:82.79 弱压:85.0 强压:92.87", "timing_signal": "观望", - "rr_ratio": 3.59, + "rr_ratio": 3.63, "status": "updated", "note": "", "timestamp": "2026-06-24 13:29", @@ -427,7 +530,7 @@ "position_advice": "减仓或观望", "time_horizon": "观望", "created_at": "2026-06-18 17:15", - "take_profit": 92.89, + "take_profit": 92.87, "updated_reason": "技术面重评: 止损75.43→75.73 | 形态:带下影阴线/neutral 量价:主动卖盘占优 强撑:76.5 弱撑:82.84 弱压:85.0 强压:92.89", "changelog": [ { @@ -549,7 +652,110 @@ "reason": "技术面重评: 止损75.43→75.73 | 形态:带下影阴线/neutral 量价:主动卖盘占优 强撑:76.5 弱撑:82.84 弱压:85.0 强压:92.89", "trigger": "技术面重评" } - ] + ], + "strategy_tree": { + "branches": [ + { + "id": "002594_stop_loss", + "condition": { + "price": "<81.25" + }, + "action": { + "type": "sell", + "amount": "all", + "reason": "止损" + }, + "priority": 0, + "rationale": "止损保护本金", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "002594_buy_dip", + "condition": { + "scenario": "weak_consolidation", + "price": "<=85.44", + "price_lower": ">=82.08" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": 82.08, + "reason": "回调支撑买入" + }, + "priority": 1, + "rationale": "价格回调到支撑区,弱势市场低吸", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "002594_breakout_chase", + "condition": { + "scenario": "bullish_recovery", + "price": ">=92.87" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": "market", + "reason": "突破确认追涨" + }, + "priority": 2, + "rationale": "价格突破阻力,确认上升趋势后买入", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "002594_trim", + "condition": { + "scenario": "sharp_decline", + "loss_pct": "<-15%" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "急跌降风险" + }, + "priority": 3, + "rationale": "急跌市场,深套股减半仓减少敞口", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "002594_take_profit", + "condition": { + "price": ">=92.87" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "止盈锁利" + }, + "priority": 4, + "rationale": "达到目标价,减半仓锁定利润", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "002594_hold", + "condition": {}, + "action": { + "type": "hold", + "reason": "无明确信号,继续持有" + }, + "priority": 99, + "rationale": "没有分支匹配时的默认动作", + "trigger_count": 1, + "success_rate": null, + "last_triggered": "2026-06-24" + } + ] + } }, { "code": "00700", @@ -1075,8 +1281,8 @@ "cost": 0, "shares": 0, "avg_price": 0, - "action": "盈利持有 | 目标15.49 | 止损11.82 | 买入区12.84~13.36 | 信号:弱势持有", - "stop_loss": 11.82, + "action": "盈利持有 | 目标15.49 | 止损12.69 | 买入区12.84~13.36 | 信号:弱势持有", + "stop_loss": 12.69, "entry_low": 12.84, "entry_high": 13.36, "tech_snapshot": "形态:锤子线/T字线/bullish 量价:数据不足 强撑:10.43 弱撑:12.69 弱压:13.36 强压:15.49", @@ -1243,7 +1449,110 @@ "reason": "技术面重评: 止损11.83→11.82 | 形态:锤子线/T字线/bullish 量价:数据不足 强撑:10.43 弱撑:12.69 弱压:13.36 强压:15.", "trigger": "技术面重评" } - ] + ], + "strategy_tree": { + "branches": [ + { + "id": "01070_stop_loss", + "condition": { + "price": "<12.69" + }, + "action": { + "type": "sell", + "amount": "all", + "reason": "止损" + }, + "priority": 0, + "rationale": "止损保护本金", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "01070_buy_dip", + "condition": { + "scenario": "weak_consolidation", + "price": "<=13.36", + "price_lower": ">=12.84" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": 12.84, + "reason": "回调支撑买入" + }, + "priority": 1, + "rationale": "价格回调到支撑区,弱势市场低吸", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "01070_breakout_chase", + "condition": { + "scenario": "bullish_recovery", + "price": ">=15.49" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": "market", + "reason": "突破确认追涨" + }, + "priority": 2, + "rationale": "价格突破阻力,确认上升趋势后买入", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "01070_trim", + "condition": { + "scenario": "sharp_decline", + "loss_pct": "<-15%" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "急跌降风险" + }, + "priority": 3, + "rationale": "急跌市场,深套股减半仓减少敞口", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "01070_take_profit", + "condition": { + "price": ">=15.49" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "止盈锁利" + }, + "priority": 4, + "rationale": "达到目标价,减半仓锁定利润", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "01070_hold", + "condition": {}, + "action": { + "type": "hold", + "reason": "无明确信号,继续持有" + }, + "priority": 99, + "rationale": "没有分支匹配时的默认动作", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + } + ] + } }, { "code": "01088", @@ -2250,13 +2559,13 @@ "cost": 0, "shares": 0, "avg_price": 0, - "action": "盈利持有 | ⚠️盈亏比偏低(1:1.7),谨慎买入 | 目标163.57 | 止损126.88 | 买入区139.94~143.91 | 信号:买入", - "stop_loss": 126.88, + "action": "盈利持有 | ⚠️盈亏比偏低(1:1.7),谨慎买入 | 目标163.63 | 止损130.8 | 买入区139.94~143.93 | 信号:买入", + "stop_loss": 130.8, "entry_low": 139.94, - "entry_high": 143.91, - "tech_snapshot": "形态:光头光脚阳线/bullish 量价:数据不足 强撑:115.77 弱撑:130.8 弱压:148.03 强压:163.57", + "entry_high": 143.93, + "tech_snapshot": "形态:光头光脚阳线/bullish 量价:数据不足 强撑:115.83 弱撑:130.8 弱压:148.17 强压:163.63", "timing_signal": "买入", - "rr_ratio": 1.73, + "rr_ratio": 1.74, "status": "updated", "note": "⚠️盈亏比偏低(1:1.7),谨慎买入", "timestamp": "2026-06-24 13:30", @@ -2268,7 +2577,7 @@ "position_advice": "正常配置", "time_horizon": "数月~1年", "created_at": "2026-06-18 17:15", - "take_profit": 163.57, + "take_profit": 163.63, "updated_reason": "技术面重评: 策略文字调整", "changelog": [ { @@ -2404,7 +2713,110 @@ "reason": "技术面重评: 策略文字调整", "trigger": "技术面重评" } - ] + ], + "strategy_tree": { + "branches": [ + { + "id": "02359_stop_loss", + "condition": { + "price": "<130.8" + }, + "action": { + "type": "sell", + "amount": "all", + "reason": "止损" + }, + "priority": 0, + "rationale": "止损保护本金", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "02359_buy_dip", + "condition": { + "scenario": "weak_consolidation", + "price": "<=143.93", + "price_lower": ">=139.94" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": 139.94, + "reason": "回调支撑买入" + }, + "priority": 1, + "rationale": "价格回调到支撑区,弱势市场低吸", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "02359_breakout_chase", + "condition": { + "scenario": "bullish_recovery", + "price": ">=163.63" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": "market", + "reason": "突破确认追涨" + }, + "priority": 2, + "rationale": "价格突破阻力,确认上升趋势后买入", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "02359_trim", + "condition": { + "scenario": "sharp_decline", + "loss_pct": "<-15%" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "急跌降风险" + }, + "priority": 3, + "rationale": "急跌市场,深套股减半仓减少敞口", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "02359_take_profit", + "condition": { + "price": ">=163.63" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "止盈锁利" + }, + "priority": 4, + "rationale": "达到目标价,减半仓锁定利润", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "02359_hold", + "condition": {}, + "action": { + "type": "hold", + "reason": "无明确信号,继续持有" + }, + "priority": 99, + "rationale": "没有分支匹配时的默认动作", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + } + ] + } }, { "code": "02388", @@ -2767,13 +3179,13 @@ "cost": 0, "shares": 0, "avg_price": 0, - "action": "盈利持有 | 目标181.27 | 止损156.07 | 买入区163.56~169.05", - "stop_loss": 156.07, + "action": "盈利持有 | 目标181.35 | 止损160.9 | 买入区163.56~169.08", + "stop_loss": 160.9, "entry_low": 163.56, - "entry_high": 169.05, - "tech_snapshot": "形态:带上影阳线/neutral 量价:数据不足 强撑:151.46 弱撑:160.9 弱压:168.93 强压:181.27", + "entry_high": 169.08, + "tech_snapshot": "形态:带上影阳线/neutral 量价:数据不足 强撑:151.51 弱撑:160.9 弱压:169.07 强压:181.35", "timing_signal": "行业偏强", - "rr_ratio": 2.4, + "rr_ratio": 2.41, "status": "updated", "note": "", "timestamp": "2026-06-24 13:30", @@ -2785,7 +3197,7 @@ "position_advice": "正常配置", "time_horizon": "数月~1年", "created_at": "2026-06-18 17:15", - "take_profit": 181.27, + "take_profit": 181.35, "updated_reason": "技术面重评: 策略文字调整", "changelog": [ { @@ -2942,7 +3354,110 @@ "reason": "技术面重评: 策略文字调整", "trigger": "技术面重评" } - ] + ], + "strategy_tree": { + "branches": [ + { + "id": "06160_stop_loss", + "condition": { + "price": "<160.9" + }, + "action": { + "type": "sell", + "amount": "all", + "reason": "止损" + }, + "priority": 0, + "rationale": "止损保护本金", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "06160_buy_dip", + "condition": { + "scenario": "weak_consolidation", + "price": "<=169.08", + "price_lower": ">=163.56" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": 163.56, + "reason": "回调支撑买入" + }, + "priority": 1, + "rationale": "价格回调到支撑区,弱势市场低吸", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "06160_breakout_chase", + "condition": { + "scenario": "bullish_recovery", + "price": ">=181.35" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": "market", + "reason": "突破确认追涨" + }, + "priority": 2, + "rationale": "价格突破阻力,确认上升趋势后买入", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "06160_trim", + "condition": { + "scenario": "sharp_decline", + "loss_pct": "<-15%" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "急跌降风险" + }, + "priority": 3, + "rationale": "急跌市场,深套股减半仓减少敞口", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "06160_take_profit", + "condition": { + "price": ">=181.35" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "止盈锁利" + }, + "priority": 4, + "rationale": "达到目标价,减半仓锁定利润", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "06160_hold", + "condition": {}, + "action": { + "type": "hold", + "reason": "无明确信号,继续持有" + }, + "priority": 99, + "rationale": "没有分支匹配时的默认动作", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + } + ] + } }, { "code": "06869", @@ -3570,17 +4085,17 @@ { "code": "300124", "name": "汇川技术", - "price": 66.82, + "price": 66.83, "cost": 0, "shares": 0, "avg_price": 0, - "action": "盈利持有 | 目标73.31 | 止损60.36 | 买入区65.48~68.16 | 信号:观望", - "stop_loss": 60.36, - "entry_low": 65.48, - "entry_high": 68.16, - "tech_snapshot": "形态:锤子线/T字线/bullish 量价:主动卖盘占优 强撑:60.07 弱撑:65.9 弱压:67.65 强压:73.31", + "action": "盈利持有 | 目标73.31 | 止损64.83 | 买入区65.49~68.17 | 信号:观望", + "stop_loss": 64.83, + "entry_low": 65.49, + "entry_high": 68.17, + "tech_snapshot": "形态:锤子线/T字线/bullish 量价:主动卖盘占优 强撑:60.07 弱撑:65.88 弱压:67.63 强压:73.31", "timing_signal": "观望", - "rr_ratio": 3.25, + "rr_ratio": 3.24, "status": "updated", "note": "", "timestamp": "2026-06-24 13:30", @@ -3714,7 +4229,110 @@ "reason": "技术面重评: 止损60.08→60.36 | 形态:锤子线/T字线/bullish 量价:主动卖盘占优 强撑:60.07 弱撑:65.9 弱压:67.65 强压:73", "trigger": "技术面重评" } - ] + ], + "strategy_tree": { + "branches": [ + { + "id": "300124_stop_loss", + "condition": { + "price": "<64.83" + }, + "action": { + "type": "sell", + "amount": "all", + "reason": "止损" + }, + "priority": 0, + "rationale": "止损保护本金", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "300124_buy_dip", + "condition": { + "scenario": "weak_consolidation", + "price": "<=68.17", + "price_lower": ">=65.49" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": 65.49, + "reason": "回调支撑买入" + }, + "priority": 1, + "rationale": "价格回调到支撑区,弱势市场低吸", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "300124_breakout_chase", + "condition": { + "scenario": "bullish_recovery", + "price": ">=73.31" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": "market", + "reason": "突破确认追涨" + }, + "priority": 2, + "rationale": "价格突破阻力,确认上升趋势后买入", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "300124_trim", + "condition": { + "scenario": "sharp_decline", + "loss_pct": "<-15%" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "急跌降风险" + }, + "priority": 3, + "rationale": "急跌市场,深套股减半仓减少敞口", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "300124_take_profit", + "condition": { + "price": ">=73.31" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "止盈锁利" + }, + "priority": 4, + "rationale": "达到目标价,减半仓锁定利润", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "300124_hold", + "condition": {}, + "action": { + "type": "hold", + "reason": "无明确信号,继续持有" + }, + "priority": 99, + "rationale": "没有分支匹配时的默认动作", + "trigger_count": 1, + "success_rate": null, + "last_triggered": "2026-06-24" + } + ] + } }, { "code": "300308", @@ -4607,18 +5225,18 @@ { "code": "601318", "name": "中国平安", - "price": 49.26, + "price": 49.24, "cost": 0, "shares": 0, "avg_price": 0, - "action": "盈利持有 | 止损参考47.85 | 买入区48.34~50.19 | 信号:观望", - "stop_loss": 47.85, - "entry_low": 48.34, - "entry_high": 50.19, - "tech_snapshot": "形态:光头光脚阴线/bearish 量价:主动卖盘占优 强撑:45.79 弱撑:48.57 弱压:50.42 强压:53.67", + "action": "盈利持有 | 目标53.65 | 止损47.76 | 买入区48.26~50.12 | 信号:观望", + "stop_loss": 47.76, + "entry_low": 48.26, + "entry_high": 50.12, + "tech_snapshot": "形态:光头光脚阴线/bearish 量价:主动卖盘占优 强撑:45.77 弱撑:48.55 弱压:50.4 强压:53.65", "timing_signal": "观望", - "rr_ratio": 3.14, - "status": "manual", + "rr_ratio": 2.98, + "status": "updated", "note": "", "timestamp": "2026-06-24 13:30", "updated_at": "2026-06-24 13:30", @@ -4629,7 +5247,7 @@ "position_advice": "减仓或观望", "time_horizon": "观望", "created_at": "2026-06-22 11:50", - "take_profit": 53.69, + "take_profit": 53.65, "changelog": [ { "date": "2026-06-22 12:01", @@ -4680,7 +5298,110 @@ "reason": "技术面重评: 策略文字调整", "trigger": "技术面重评" } - ] + ], + "strategy_tree": { + "branches": [ + { + "id": "601318_stop_loss", + "condition": { + "price": "<47.76" + }, + "action": { + "type": "sell", + "amount": "all", + "reason": "止损" + }, + "priority": 0, + "rationale": "止损保护本金", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "601318_buy_dip", + "condition": { + "scenario": "weak_consolidation", + "price": "<=50.12", + "price_lower": ">=48.26" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": 48.26, + "reason": "回调支撑买入" + }, + "priority": 1, + "rationale": "价格回调到支撑区,弱势市场低吸", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "601318_breakout_chase", + "condition": { + "scenario": "bullish_recovery", + "price": ">=53.65" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": "market", + "reason": "突破确认追涨" + }, + "priority": 2, + "rationale": "价格突破阻力,确认上升趋势后买入", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "601318_trim", + "condition": { + "scenario": "sharp_decline", + "loss_pct": "<-15%" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "急跌降风险" + }, + "priority": 3, + "rationale": "急跌市场,深套股减半仓减少敞口", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "601318_take_profit", + "condition": { + "price": ">=53.65" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "止盈锁利" + }, + "priority": 4, + "rationale": "达到目标价,减半仓锁定利润", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "601318_hold", + "condition": {}, + "action": { + "type": "hold", + "reason": "无明确信号,继续持有" + }, + "priority": 99, + "rationale": "没有分支匹配时的默认动作", + "trigger_count": 1, + "success_rate": null, + "last_triggered": "2026-06-24" + } + ] + } }, { "code": "601899", @@ -5324,17 +6045,17 @@ { "code": "688795", "name": "摩尔线程-U", - "price": 712.2, + "price": 714.88, "cost": 0, "shares": 0, "avg_price": 0, - "action": "盈利持有 | 目标833.46 | 止损675.95 | 买入区697.96~726.44 | 信号:观望", - "stop_loss": 675.95, - "entry_low": 697.96, - "entry_high": 726.44, - "tech_snapshot": "形态:带下影阳线/neutral 量价:主动卖盘占优 强撑:564.16 弱撑:683.19 弱压:728.63 强压:833.46", + "action": "盈利持有 | 目标834.24 | 止损684.29 | 买入区700.58~729.18 | 信号:观望", + "stop_loss": 684.29, + "entry_low": 700.58, + "entry_high": 729.18, + "tech_snapshot": "形态:带下影阳线/neutral 量价:主动卖盘占优 强撑:564.94 弱撑:684.29 弱压:730.17 强压:834.24", "timing_signal": "观望", - "rr_ratio": 4.18, + "rr_ratio": 3.9, "status": "updated", "note": "", "timestamp": "2026-06-24 13:30", @@ -5346,7 +6067,7 @@ "position_advice": "正常配置", "time_horizon": "数月~1年", "created_at": "2026-06-18 17:15", - "take_profit": 833.46, + "take_profit": 834.24, "updated_reason": "技术面重评: 止损675.06→675.95 | 形态:带下影阳线/neutral 量价:主动卖盘占优 强撑:564.16 弱撑:683.19 弱压:728.63 强压:", "changelog": [ { @@ -5468,7 +6189,110 @@ "reason": "技术面重评: 止损675.06→675.95 | 形态:带下影阳线/neutral 量价:主动卖盘占优 强撑:564.16 弱撑:683.19 弱压:728.63 强压:", "trigger": "技术面重评" } - ] + ], + "strategy_tree": { + "branches": [ + { + "id": "688795_stop_loss", + "condition": { + "price": "<684.29" + }, + "action": { + "type": "sell", + "amount": "all", + "reason": "止损" + }, + "priority": 0, + "rationale": "止损保护本金", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "688795_buy_dip", + "condition": { + "scenario": "weak_consolidation", + "price": "<=729.18", + "price_lower": ">=700.58" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": 700.58, + "reason": "回调支撑买入" + }, + "priority": 1, + "rationale": "价格回调到支撑区,弱势市场低吸", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "688795_breakout_chase", + "condition": { + "scenario": "bullish_recovery", + "price": ">=834.24" + }, + "action": { + "type": "buy", + "amount": "normal", + "limit": "market", + "reason": "突破确认追涨" + }, + "priority": 2, + "rationale": "价格突破阻力,确认上升趋势后买入", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "688795_trim", + "condition": { + "scenario": "sharp_decline", + "loss_pct": "<-15%" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "急跌降风险" + }, + "priority": 3, + "rationale": "急跌市场,深套股减半仓减少敞口", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "688795_take_profit", + "condition": { + "price": ">=834.24" + }, + "action": { + "type": "sell", + "amount": "half", + "reason": "止盈锁利" + }, + "priority": 4, + "rationale": "达到目标价,减半仓锁定利润", + "trigger_count": 0, + "success_rate": null, + "last_triggered": null + }, + { + "id": "688795_hold", + "condition": {}, + "action": { + "type": "hold", + "reason": "无明确信号,继续持有" + }, + "priority": 99, + "rationale": "没有分支匹配时的默认动作", + "trigger_count": 1, + "success_rate": null, + "last_triggered": "2026-06-24" + } + ] + } }, { "code": "688802", @@ -5756,5 +6580,5 @@ } ], "total": 40, - "regenerated_at": "2026-06-24 13:30" + "regenerated_at": "2026-06-24 13:31" } \ No newline at end of file diff --git a/data/portfolio.json b/data/portfolio.json index 72e0202..0f2ad24 100644 --- a/data/portfolio.json +++ b/data/portfolio.json @@ -25,7 +25,9 @@ "rr_ratio": 0.06, "action_note": "⚠️盈亏比偏低(1:0.6),不建议加仓", "timing_signal": "持有" - } + }, + "price": 816.69, + "change_pct": 8.17 }, { "code": "01478", @@ -52,7 +54,9 @@ "rr_ratio": 1.04, "action_note": "深套持有", "timing_signal": "持有" - } + }, + "price": 7.75, + "change_pct": -1.65 }, { "code": "600739", @@ -79,7 +83,9 @@ "rr_ratio": 1.44, "action_note": "⚠️盈亏比偏低(1:1.4),不建议加仓", "timing_signal": "持有" - } + }, + "price": 10.42, + "change_pct": -2.16 }, { "code": "601899", @@ -106,7 +112,9 @@ "rr_ratio": 0.68, "action_note": "深套持有", "timing_signal": "持有" - } + }, + "price": 27.66, + "change_pct": -0.32 }, { "code": "688639", @@ -133,7 +141,9 @@ "rr_ratio": 1.12, "action_note": "⚠️盈亏比偏低(1:1.1),不建议加仓", "timing_signal": "持有" - } + }, + "price": 21.42, + "change_pct": -1.88 }, { "code": "09988", @@ -160,7 +170,9 @@ "rr_ratio": 1.02, "action_note": "深套持有", "timing_signal": "持有" - } + }, + "price": 100.1, + "change_pct": 1.26 }, { "code": "688411", @@ -187,7 +199,9 @@ "rr_ratio": 0.96, "action_note": "⚠️盈亏比偏低(1:1.0),不建议加仓", "timing_signal": "持有" - } + }, + "price": 268.05, + "change_pct": -1.56 }, { "code": "603259", @@ -214,7 +228,9 @@ "rr_ratio": 3.35, "action_note": "", "timing_signal": "持有" - } + }, + "price": 115.8, + "change_pct": 8.95 }, { "code": "688981", @@ -241,7 +257,9 @@ "rr_ratio": 1.89, "action_note": "", "timing_signal": "持有" - } + }, + "price": 153.7, + "change_pct": 8.47 }, { "code": "01888", @@ -268,7 +286,9 @@ "rr_ratio": 7.78, "action_note": "短炒强趋势持", "timing_signal": "持有" - } + }, + "price": 93.3, + "change_pct": 7.16 }, { "code": "02202", @@ -295,7 +315,9 @@ "rr_ratio": 1.11, "action_note": "深套持有", "timing_signal": "持有" - } + }, + "price": 2.36, + "change_pct": -2.08 }, { "code": "02388", @@ -322,7 +344,9 @@ "rr_ratio": 2.93, "action_note": "", "timing_signal": "持有" - } + }, + "price": 46.36, + "change_pct": -1.4 }, { "code": "300750", @@ -349,7 +373,9 @@ "rr_ratio": 0.83, "action_note": "⚠️盈亏比偏低(1:0.8),不建议加仓", "timing_signal": "持有" - } + }, + "price": 395.02, + "change_pct": 0.65 }, { "code": "01211", @@ -376,7 +402,9 @@ "rr_ratio": 1.01, "action_note": "深套持有", "timing_signal": "持有" - } + }, + "price": 75.9, + "change_pct": 0.07 }, { "code": "00981", @@ -403,7 +431,9 @@ "rr_ratio": 2.79, "action_note": "", "timing_signal": "持有" - } + }, + "price": 85.5, + "change_pct": 10.02 }, { "code": "00700", @@ -430,7 +460,9 @@ "rr_ratio": 0.95, "action_note": "⚠️盈亏比偏低(1:0.9),不建议加仓", "timing_signal": "持有" - } + }, + "price": 433.4, + "change_pct": 4.29 }, { "code": "09868", @@ -457,7 +489,9 @@ "rr_ratio": 21.84, "action_note": "⚠️盈亏比偏低(1:1.0),不建议加仓", "timing_signal": "持有" - } + }, + "price": 49.98, + "change_pct": 1.22 }, { "code": "300548", @@ -484,7 +518,9 @@ "rr_ratio": 5.82, "action_note": "短炒强趋势持", "timing_signal": "持有" - } + }, + "price": 282.5, + "change_pct": -1.24 }, { "code": "02318", @@ -511,7 +547,9 @@ "rr_ratio": 15.44, "action_note": "⚠️盈亏比偏低(1:1.1),不建议加仓", "timing_signal": "持有" - } + }, + "price": 52.8, + "change_pct": -1.49 }, { "code": "300035", @@ -538,7 +576,9 @@ "rr_ratio": 0.93, "action_note": "深套持有", "timing_signal": "持有" - } + }, + "price": 16.1, + "change_pct": -1.47 }, { "code": "518880", @@ -565,7 +605,9 @@ "rr_ratio": 0.54, "action_note": "深套持有", "timing_signal": "持有" - } + }, + "price": 8.49, + "change_pct": -0.57 }, { "code": "000700", @@ -592,7 +634,9 @@ "rr_ratio": 3.35, "action_note": "", "timing_signal": "持有" - } + }, + "price": 14.57, + "change_pct": -2.74 }, { "code": "01088", @@ -619,7 +663,9 @@ "rr_ratio": 0.93, "action_note": "⚠️盈亏比偏低(1:0.9),不建议加仓", "timing_signal": "持有" - } + }, + "price": 41.84, + "change_pct": -0.43 }, { "code": "600563", @@ -646,7 +692,9 @@ "rr_ratio": 3.54, "action_note": "", "timing_signal": "持有" - } + }, + "price": 178.76, + "change_pct": 10.0 } ], "cash": 5667, diff --git a/data/price_history.json b/data/price_history.json index 8a27477..3b1758c 100644 --- a/data/price_history.json +++ b/data/price_history.json @@ -108,7 +108,7 @@ "date": "2026-06-24", "high": 88.32, "low": 82.78, - "close": 83.83 + "close": 83.76 } ], "00700": [ @@ -836,7 +836,7 @@ "date": "2026-06-24", "high": 145.0, "low": 130.0, - "close": 142.7 + "close": 142.9 } ], "02388": [ @@ -1004,7 +1004,7 @@ "date": "2026-06-24", "high": 168.6, "low": 160.0, - "close": 166.7 + "close": 166.9 } ], "06869": [ @@ -1284,7 +1284,7 @@ "date": "2026-06-24", "high": 68.8, "low": 65.74, - "close": 66.85 + "close": 66.83 } ], "300548": [ @@ -2316,7 +2316,7 @@ "date": "2026-06-24", "high": 745.2, "low": 660.01, - "close": 713.0 + "close": 714.88 } ], "688802": [ @@ -2466,7 +2466,7 @@ "date": "2026-06-24", "high": 5.38, "low": 4.86, - "close": 5.09 + "close": 5.06 } ], "688630": [ @@ -2610,7 +2610,7 @@ "date": "2026-06-24", "high": 52.43, "low": 49.03, - "close": 49.27 + "close": 49.23 } ], "002171": [ diff --git a/server.py b/server.py index ff72888..84f6ccf 100644 --- a/server.py +++ b/server.py @@ -717,10 +717,22 @@ def upload_page(): def _ocr_image(image_path): - """用Tesseract OCR提取图片中的文字(预处理优化中文表格识别)""" + """优先用小果GLM-OCR-8bit识别,失败则降级到pytesseract""" + import sys from PIL import Image, ImageEnhance, ImageFilter import pytesseract + # 尝试小果OCR(GLM-OCR-8bit) + try: + sys.path.insert(0, os.path.join(os.path.dirname(__file__), "scripts")) + from ocr_client import ocr_image as xg_ocr + result = xg_ocr(image_path, "请识别这张图片中所有文字,包括股票名称、代码、价格、持股数、金额、百分比等。输出完整内容。") + if result.get("success") and len(result.get("text", "")) > 20: + return result["text"].strip() + except Exception: + pass # 降级到tesseract + + # 降级:Tesseract(预处理优化中文表格识别) img = Image.open(image_path) # 预处理:放大 + 锐化 + 二值化,提升小字识别率