持仓导入完成:holding.xls→SQLite+portfolio.json全同步

1. 从 ~/stocks/holding.xls 导入25只持仓(14A/11H)
2. 同时写入 portfolio.json + SQLite holdings 表
3. stale_push_wlin 现金来源从 stale_report 改为 portfolio.json
4. portfolio.json 增加 total_assets 字段兼容 stale_detector
5. 导入脚本已规范化为 MoFin/scripts/import_holding_xls.py
   用法:python3 import_holding_xls.py [--cash 金额]
6. 全量策略重评+决策树重建立即执行

Dad下次更新holding.xls后跑:
  cd MoFin && python3 scripts/import_holding_xls.py
This commit is contained in:
知微
2026-06-24 11:21:51 +08:00
parent df4f898bc4
commit e2646c36cb
5 changed files with 414 additions and 158 deletions
+62 -62
View File
@@ -315,18 +315,18 @@
{
"code": "000711",
"name": "ST京蓝",
"price": 5.16,
"price": 5.0,
"cost": 0,
"shares": 0,
"avg_price": 0,
"action": "盈利持有 | ⚠️盈亏比不足1:1.5,不建议买入 | 目标5.38 | 止损4.4 | 买入区5.06~5.11 | 信号:观望",
"stop_loss": 4.4,
"entry_low": 5.06,
"entry_high": 5.11,
"tech_snapshot": "形态:带下影阳线/neutral 量价:主动卖盘占优 强撑:4.86 弱撑:4.93 弱压:5.32 强压:5.38",
"action": "盈利持有 | 目标5.38 | 止损4.82 | 买入区4.9~5.04 | 信号:观望",
"stop_loss": 4.82,
"entry_low": 4.9,
"entry_high": 5.04,
"tech_snapshot": "形态:倒T线/射击之星/bearish 量价:主动卖盘占优 强撑:4.86 弱撑:4.82 弱压:5.21 强压:5.38",
"timing_signal": "观望",
"rr_ratio": 0.96,
"status": "review",
"rr_ratio": 2.11,
"status": "updated",
"note": "⚠️盈亏比不足1:1.5,不建议买入",
"timestamp": "2026-06-24 11:16",
"updated_at": "2026-06-24 11:16",
@@ -430,7 +430,7 @@
{
"id": "000711_stop_loss",
"condition": {
"price": "<4.4"
"price": "<4.82"
},
"action": {
"type": "sell",
@@ -447,13 +447,13 @@
"id": "000711_buy_dip",
"condition": {
"scenario": "weak_consolidation",
"price": "<=5.11",
"price_lower": ">=5.06"
"price": "<=5.04",
"price_lower": ">=4.9"
},
"action": {
"type": "buy",
"amount": "normal",
"limit": 5.06,
"limit": 4.9,
"reason": "回调支撑买入"
},
"priority": 1,
@@ -743,17 +743,17 @@
{
"code": "002594",
"name": "比亚迪",
"price": 82.82,
"price": 82.79,
"cost": 0,
"shares": 0,
"avg_price": 0,
"action": "盈利持有 | 目标92.55 | 止损80.34 | 买入区81.16~84.48 | 信号:观望",
"stop_loss": 80.34,
"entry_low": 81.16,
"entry_high": 84.48,
"tech_snapshot": "形态:光头光脚阴线/bearish 量价:主动卖盘占优 强撑:76.5 弱撑:82.17 弱压:85.0 强压:92.55",
"action": "盈利持有 | 目标92.54 | 止损80.31 | 买入区81.13~84.45 | 信号:观望",
"stop_loss": 80.31,
"entry_low": 81.13,
"entry_high": 84.45,
"tech_snapshot": "形态:光头光脚阴线/bearish 量价:主动卖盘占优 强撑:76.5 弱撑:82.15 弱压:85.0 强压:92.54",
"timing_signal": "观望",
"rr_ratio": 3.92,
"rr_ratio": 3.93,
"status": "updated",
"note": "",
"timestamp": "2026-06-24 11:16",
@@ -765,7 +765,7 @@
"position_advice": "减仓或观望",
"time_horizon": "观望",
"created_at": "2026-06-18 17:15",
"take_profit": 92.55,
"take_profit": 92.54,
"updated_reason": "技术面重评: 止损77.92→77.93 | 形态:光头光脚阴线/bearish 量价:主动卖盘占优 强撑:76.5 弱撑:82.17 弱压:85.0 强压:92.5",
"changelog": [
{
@@ -865,7 +865,7 @@
{
"id": "002594_stop_loss",
"condition": {
"price": "<80.34"
"price": "<80.31"
},
"action": {
"type": "sell",
@@ -882,13 +882,13 @@
"id": "002594_buy_dip",
"condition": {
"scenario": "weak_consolidation",
"price": "<=84.48",
"price_lower": ">=81.16"
"price": "<=84.45",
"price_lower": ">=81.13"
},
"action": {
"type": "buy",
"amount": "normal",
"limit": 81.16,
"limit": 81.13,
"reason": "回调支撑买入"
},
"priority": 1,
@@ -901,7 +901,7 @@
"id": "002594_breakout_chase",
"condition": {
"scenario": "bullish_recovery",
"price": ">=92.55"
"price": ">=92.54"
},
"action": {
"type": "buy",
@@ -935,7 +935,7 @@
{
"id": "002594_take_profit",
"condition": {
"price": ">=92.55"
"price": ">=92.54"
},
"action": {
"type": "sell",
@@ -5192,17 +5192,17 @@
{
"code": "300124",
"name": "汇川技术",
"price": 65.87,
"price": 66.01,
"cost": 0,
"shares": 0,
"avg_price": 0,
"action": "盈利持有 | 目标72.99 | 止损63.89 | 买入区64.55~67.19 | 信号:观望",
"stop_loss": 63.89,
"entry_low": 64.55,
"entry_high": 67.19,
"tech_snapshot": "形态:带上影阴线/bearish 量价:主动卖盘占优 强撑:59.75 弱撑:65.24 弱压:66.99 强压:72.99",
"action": "盈利持有 | 目标73.03 | 止损64.03 | 买入区64.69~67.33 | 信号:观望",
"stop_loss": 64.03,
"entry_low": 64.69,
"entry_high": 67.33,
"tech_snapshot": "形态:带上影阴线/bearish 量价:主动卖盘占优 强撑:59.79 弱撑:65.34 弱压:67.09 强压:73.03",
"timing_signal": "观望",
"rr_ratio": 3.6,
"rr_ratio": 3.55,
"status": "updated",
"note": "",
"timestamp": "2026-06-24 11:17",
@@ -5214,7 +5214,7 @@
"position_advice": "减仓或观望",
"time_horizon": "观望",
"created_at": "2026-06-18 17:15",
"take_profit": 72.99,
"take_profit": 73.03,
"updated_reason": "技术面重评: 止损61.97→62.13 | 形态:带上影阴线/bearish 量价:主动卖盘占优 强撑:59.78 弱撑:65.32 弱压:67.07 强压:73.",
"changelog": [
{
@@ -5307,7 +5307,7 @@
{
"id": "300124_stop_loss",
"condition": {
"price": "<63.89"
"price": "<64.03"
},
"action": {
"type": "sell",
@@ -5324,13 +5324,13 @@
"id": "300124_buy_dip",
"condition": {
"scenario": "weak_consolidation",
"price": "<=67.19",
"price_lower": ">=64.55"
"price": "<=67.33",
"price_lower": ">=64.69"
},
"action": {
"type": "buy",
"amount": "normal",
"limit": 64.55,
"limit": 64.69,
"reason": "回调支撑买入"
},
"priority": 1,
@@ -5343,7 +5343,7 @@
"id": "300124_breakout_chase",
"condition": {
"scenario": "bullish_recovery",
"price": ">=72.99"
"price": ">=73.03"
},
"action": {
"type": "buy",
@@ -5377,7 +5377,7 @@
{
"id": "300124_take_profit",
"condition": {
"price": ">=72.99"
"price": ">=73.03"
},
"action": {
"type": "sell",
@@ -7264,11 +7264,11 @@
"cost": 0,
"shares": 0,
"avg_price": 0,
"action": "盈利持有 | 目标53.71 | 止损47.9 | 买入区48.39~50.22 | 信号:观望",
"action": "盈利持有 | 目标53.72 | 止损47.9 | 买入区48.39~50.23 | 信号:观望",
"stop_loss": 47.9,
"entry_low": 48.39,
"entry_high": 50.22,
"tech_snapshot": "形态:光头光脚阴线/bearish 量价:主动卖盘占优 强撑:45.81 弱撑:48.65 弱压:50.5 强压:53.71",
"entry_high": 50.23,
"tech_snapshot": "形态:光头光脚阴线/bearish 量价:主动卖盘占优 强撑:45.82 弱撑:48.65 弱压:50.5 强压:53.72",
"timing_signal": "观望",
"rr_ratio": 2.93,
"status": "updated",
@@ -7282,7 +7282,7 @@
"position_advice": "减仓或观望",
"time_horizon": "观望",
"created_at": "2026-06-22 11:50",
"take_profit": 53.71,
"take_profit": 53.72,
"changelog": [
{
"date": "2026-06-22 12:01",
@@ -7335,7 +7335,7 @@
"id": "601318_buy_dip",
"condition": {
"scenario": "weak_consolidation",
"price": "<=50.22",
"price": "<=50.23",
"price_lower": ">=48.39"
},
"action": {
@@ -7354,7 +7354,7 @@
"id": "601318_breakout_chase",
"condition": {
"scenario": "bullish_recovery",
"price": ">=53.71"
"price": ">=53.72"
},
"action": {
"type": "buy",
@@ -7388,7 +7388,7 @@
{
"id": "601318_take_profit",
"condition": {
"price": ">=53.71"
"price": ">=53.72"
},
"action": {
"type": "sell",
@@ -8426,17 +8426,17 @@
{
"code": "688795",
"name": "摩尔线程-U",
"price": 678.5,
"price": 679.95,
"cost": 0,
"shares": 0,
"avg_price": 0,
"action": "盈利持有 | 目标816.82 | 止损658.14 | 买入区664.93~692.07 | 信号:观望",
"stop_loss": 658.14,
"entry_low": 664.93,
"entry_high": 692.07,
"tech_snapshot": "形态:带下影阴线/neutral 量价:主动卖盘占优 强撑:563.22 弱撑:665.33 弱压:704.03 强压:816.82",
"action": "盈利持有 | 目标817.3 | 止损659.55 | 买入区666.35~693.55 | 信号:观望",
"stop_loss": 659.55,
"entry_low": 666.35,
"entry_high": 693.55,
"tech_snapshot": "形态:带下影阴线/neutral 量价:主动卖盘占优 强撑:563.22 弱撑:666.3 弱压:704.03 强压:817.3",
"timing_signal": "观望",
"rr_ratio": 6.79,
"rr_ratio": 6.73,
"status": "updated",
"note": "",
"timestamp": "2026-06-24 11:17",
@@ -8448,7 +8448,7 @@
"position_advice": "正常配置",
"time_horizon": "数月~1年",
"created_at": "2026-06-18 17:15",
"take_profit": 816.82,
"take_profit": 817.3,
"updated_reason": "技术面重评: 止损635.13→637.94 | 形态:光头光脚阴线/bearish 量价:主动卖盘占优 强撑:563.22 弱撑:665.0 弱压:704.03 强压:",
"changelog": [
{
@@ -8541,7 +8541,7 @@
{
"id": "688795_stop_loss",
"condition": {
"price": "<658.14"
"price": "<659.55"
},
"action": {
"type": "sell",
@@ -8558,13 +8558,13 @@
"id": "688795_buy_dip",
"condition": {
"scenario": "weak_consolidation",
"price": "<=692.07",
"price_lower": ">=664.93"
"price": "<=693.55",
"price_lower": ">=666.35"
},
"action": {
"type": "buy",
"amount": "normal",
"limit": 664.93,
"limit": 666.35,
"reason": "回调支撑买入"
},
"priority": 1,
@@ -8577,7 +8577,7 @@
"id": "688795_breakout_chase",
"condition": {
"scenario": "bullish_recovery",
"price": ">=816.82"
"price": ">=817.3"
},
"action": {
"type": "buy",
@@ -8611,7 +8611,7 @@
{
"id": "688795_take_profit",
"condition": {
"price": ">=816.82"
"price": ">=817.3"
},
"action": {
"type": "sell",
@@ -9065,5 +9065,5 @@
}
],
"total": 42,
"regenerated_at": "2026-06-24 11:19"
"regenerated_at": "2026-06-24 11:21"
}
+47 -39
View File
@@ -5,21 +5,22 @@
"name": "德明利",
"shares": 100,
"avail_shares": 100,
"price": 790.0,
"price": 790.9,
"cost_price": 737.0374,
"pl": 5096.26,
"pl_pct": 6.91,
"currency": "CNY",
"market_val": 78800.0,
"cost_amount": 73703.74,
"exchange_rate": 0.866
"exchange_rate": 0.866,
"change_pct": 4.75
},
{
"code": "01478",
"name": "丘钛科技",
"shares": 11000,
"avail_shares": 11000,
"price": 7.57,
"price": 7.54,
"cost_price": 13.8089,
"pl": -59438.6,
"pl_pct": -45.18,
@@ -27,14 +28,14 @@
"market_val": 72120.15,
"cost_amount": 131558.75,
"exchange_rate": 0.8661,
"change_pct": -3.93
"change_pct": -4.19
},
{
"code": "600739",
"name": "辽宁成大",
"shares": 6600,
"avail_shares": 6600,
"price": 10.44,
"price": 10.45,
"cost_price": 12.2862,
"pl": -11789.02,
"pl_pct": -14.54,
@@ -42,14 +43,14 @@
"market_val": 69300.0,
"cost_amount": 81089.02,
"exchange_rate": 0.866,
"change_pct": -1.97
"change_pct": -1.88
},
{
"code": "601899",
"name": "紫金矿业",
"shares": 2400,
"avail_shares": 2400,
"price": 27.38,
"price": 27.36,
"cost_price": 40.2685,
"pl": -30572.29,
"pl_pct": -31.63,
@@ -63,21 +64,22 @@
"name": "华恒生物",
"shares": 2800,
"avail_shares": 0,
"price": 21.31,
"price": 21.35,
"cost_price": 21.5085,
"pl": -135.75,
"pl_pct": -0.23,
"currency": "CNY",
"market_val": 60088.0,
"cost_amount": 60223.75,
"exchange_rate": 0.866
"exchange_rate": 0.866,
"change_pct": -2.2
},
{
"code": "09988",
"name": "阿里巴巴-W",
"shares": 700,
"avail_shares": 700,
"price": 98.55,
"price": 98.6,
"cost_price": 126.1516,
"pl": -16582.48,
"pl_pct": -21.68,
@@ -85,7 +87,7 @@
"market_val": 59899.48,
"cost_amount": 76481.96,
"exchange_rate": 0.8661,
"change_pct": -0.4
"change_pct": -0.35
},
{
"code": "603259",
@@ -106,7 +108,7 @@
"name": "中芯国际",
"shares": 300,
"avail_shares": 300,
"price": 149.89,
"price": 150.64,
"cost_price": 126.0681,
"pl": 7173.58,
"pl_pct": 18.97,
@@ -114,7 +116,7 @@
"market_val": 44994.0,
"cost_amount": 37820.42,
"exchange_rate": 0.866,
"change_pct": 5.78
"change_pct": 6.31
},
{
"code": "01888",
@@ -150,7 +152,7 @@
"name": "中银香港",
"shares": 1000,
"avail_shares": 1000,
"price": 46.22,
"price": 46.26,
"cost_price": 43.7892,
"pl": 2053.39,
"pl_pct": 5.41,
@@ -158,14 +160,14 @@
"market_val": 39979.18,
"cost_amount": 37925.79,
"exchange_rate": 0.8661,
"change_pct": -1.66
"change_pct": -1.62
},
{
"code": "300750",
"name": "宁德时代",
"shares": 100,
"avail_shares": 100,
"price": 391.09,
"price": 391.19,
"cost_price": 401.7803,
"pl": -1063.03,
"pl_pct": -2.65,
@@ -173,21 +175,22 @@
"market_val": 39115.0,
"cost_amount": 40178.03,
"exchange_rate": 0.866,
"change_pct": -0.36
"change_pct": -0.34
},
{
"code": "01211",
"name": "比亚迪股份",
"shares": 600,
"avail_shares": 600,
"price": 75.0,
"price": 74.85,
"cost_price": 105.0542,
"pl": -15539.97,
"pl_pct": -28.47,
"currency": "HKD",
"market_val": 39052.45,
"cost_amount": 54592.42,
"exchange_rate": 0.8661
"exchange_rate": 0.8661,
"change_pct": -1.25
},
{
"code": "00700",
@@ -209,7 +212,7 @@
"name": "中芯国际",
"shares": 500,
"avail_shares": 500,
"price": 83.15,
"price": 83.25,
"cost_price": 76.0724,
"pl": 3151.55,
"pl_pct": 9.57,
@@ -217,28 +220,29 @@
"market_val": 36094.72,
"cost_amount": 32943.17,
"exchange_rate": 0.8661,
"change_pct": 6.81
"change_pct": 6.62
},
{
"code": "09868",
"name": "小鹏集团-W",
"shares": 700,
"avail_shares": 700,
"price": 50.2,
"price": 50.1,
"cost_price": 51.3644,
"pl": -675.62,
"pl_pct": -2.17,
"currency": "HKD",
"market_val": 30465.07,
"cost_amount": 31140.69,
"exchange_rate": 0.8661
"exchange_rate": 0.8661,
"change_pct": 1.5
},
{
"code": "600036",
"name": "招商银行",
"shares": 800,
"avail_shares": 800,
"price": 37.06,
"price": 37.05,
"cost_price": 38.1582,
"pl": -846.53,
"pl_pct": -2.77,
@@ -246,14 +250,14 @@
"market_val": 29680.0,
"cost_amount": 30526.53,
"exchange_rate": 0.866,
"change_pct": -0.91
"change_pct": -0.94
},
{
"code": "300548",
"name": "长芯博创",
"shares": 100,
"avail_shares": 100,
"price": 276.12,
"price": 276.79,
"cost_price": 231.46,
"pl": 4766.0,
"pl_pct": 20.59,
@@ -261,14 +265,14 @@
"market_val": 27912.0,
"cost_amount": 23146.0,
"exchange_rate": 0.866,
"change_pct": -3.46
"change_pct": -3.23
},
{
"code": "02318",
"name": "中国平安",
"shares": 500,
"avail_shares": 500,
"price": 52.7,
"price": 52.8,
"cost_price": 54.8199,
"pl": -896.35,
"pl_pct": -3.78,
@@ -276,7 +280,7 @@
"market_val": 22843.39,
"cost_amount": 23739.74,
"exchange_rate": 0.8661,
"change_pct": -1.68
"change_pct": -1.49
},
{
"code": "300035",
@@ -290,14 +294,15 @@
"currency": "CNY",
"market_val": 22442.0,
"cost_amount": 31207.91,
"exchange_rate": 0.866
"exchange_rate": 0.866,
"change_pct": -2.08
},
{
"code": "000700",
"name": "模塑科技",
"shares": 1400,
"avail_shares": 1400,
"price": 14.53,
"price": 14.52,
"cost_price": 14.8336,
"pl": -327.0,
"pl_pct": -1.57,
@@ -305,14 +310,14 @@
"market_val": 20440.0,
"cost_amount": 20767.0,
"exchange_rate": 0.866,
"change_pct": -3.0
"change_pct": -3.07
},
{
"code": "518880",
"name": "黄金ETF华安",
"shares": 2400,
"avail_shares": 2400,
"price": 8.43,
"price": 8.44,
"cost_price": 12.1915,
"pl": -8982.04,
"pl_pct": -30.7,
@@ -320,21 +325,22 @@
"market_val": 20277.6,
"cost_amount": 29259.64,
"exchange_rate": 0.866,
"change_pct": -1.21
"change_pct": -1.16
},
{
"code": "01088",
"name": "中国神华",
"shares": 500,
"avail_shares": 500,
"price": 41.92,
"price": 41.84,
"cost_price": 45.974,
"pl": -1764.27,
"pl_pct": -8.86,
"currency": "HKD",
"market_val": 18144.8,
"cost_amount": 19909.06,
"exchange_rate": 0.8661
"exchange_rate": 0.8661,
"change_pct": -0.52
},
{
"code": "600563",
@@ -355,14 +361,15 @@
"name": "双一科技",
"shares": 400,
"avail_shares": 400,
"price": 22.7,
"price": 22.68,
"cost_price": 27.178,
"pl": -1759.2,
"pl_pct": -16.18,
"currency": "CNY",
"market_val": 9112.0,
"cost_amount": 10871.2,
"exchange_rate": 0.866
"exchange_rate": 0.866,
"change_pct": -3.98
}
],
"cash": 80476,
@@ -370,5 +377,6 @@
"total_pl": -164810.3,
"position_pct": 92.0,
"updated_at": "2026-06-24 11:47",
"source": "/home/hmo/stocks/holding.xls"
"source": "/home/hmo/stocks/holding.xls",
"total_assets": 1010675.93
}
+5 -5
View File
@@ -108,7 +108,7 @@
"date": "2026-06-24",
"high": 88.32,
"low": 82.78,
"close": 82.82
"close": 82.79
}
],
"00700": [
@@ -1284,7 +1284,7 @@
"date": "2026-06-24",
"high": 68.8,
"low": 65.74,
"close": 65.87
"close": 66.01
}
],
"300548": [
@@ -2316,7 +2316,7 @@
"date": "2026-06-24",
"high": 745.2,
"low": 660.01,
"close": 678.5
"close": 679.95
}
],
"688802": [
@@ -2466,7 +2466,7 @@
"date": "2026-06-24",
"high": 5.38,
"low": 4.86,
"close": 5.16
"close": 5.0
}
],
"688630": [
@@ -2610,7 +2610,7 @@
"date": "2026-06-24",
"high": 52.43,
"low": 49.03,
"close": 49.38
"close": 49.39
}
],
"002171": [