@weaxs/openclaw-stock-analysis 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +197 -0
- package/openclaw.plugin.json +9 -1
- package/package.json +5 -2
- package/schemas/market_review_schema.json +176 -0
- package/scripts/sync-version.sh +55 -0
- package/templates/_macros.j2 +90 -0
- package/templates/market_review/full.md.j2 +103 -0
- package/templates/stock_analysis/brief.md.j2 +28 -0
- package/templates/stock_analysis/full.md.j2 +108 -0
- package/tools/alert_rules.py +238 -0
- package/tools/backtest.py +115 -0
- package/tools/capabilities.py +101 -0
- package/tools/diagnostics.py +135 -0
- package/tools/import_parser.py +259 -0
- package/tools/position_context.py +156 -0
- package/tools/report_renderer.py +111 -0
- package/tools/requirements.txt +2 -0
- package/tools/stock_data.py +8 -2
- package/tools/watchlist_context.py +180 -0
package/index.ts
CHANGED
|
@@ -757,5 +757,202 @@ export default definePluginEntry({
|
|
|
757
757
|
return asText(out);
|
|
758
758
|
},
|
|
759
759
|
});
|
|
760
|
+
|
|
761
|
+
// --- Diagnostics & Capabilities ---
|
|
762
|
+
|
|
763
|
+
api.registerTool({
|
|
764
|
+
name: "diagnose_data_sources",
|
|
765
|
+
description:
|
|
766
|
+
"数据源诊断 — 检查当前环境可用的数据 provider(akshare/tushare/yfinance/finnhub/longbridge/alphavantage),输出每个市场的可用链路、缺失 env、warnings",
|
|
767
|
+
parameters: Type.Object({
|
|
768
|
+
market: Type.Optional(
|
|
769
|
+
Type.Union(
|
|
770
|
+
[
|
|
771
|
+
Type.Literal("A"),
|
|
772
|
+
Type.Literal("HK"),
|
|
773
|
+
Type.Literal("US"),
|
|
774
|
+
Type.Literal("all"),
|
|
775
|
+
],
|
|
776
|
+
{ description: "市场,默认 all" }
|
|
777
|
+
)
|
|
778
|
+
),
|
|
779
|
+
}),
|
|
780
|
+
async execute(_id, params) {
|
|
781
|
+
const out = await runPy("diagnostics.py", [
|
|
782
|
+
"check",
|
|
783
|
+
"--market",
|
|
784
|
+
params.market ?? "all",
|
|
785
|
+
]);
|
|
786
|
+
return asText(out);
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
api.registerTool({
|
|
791
|
+
name: "get_market_capabilities",
|
|
792
|
+
description:
|
|
793
|
+
"市场能力边界 — 返回指定市场支持/不支持的工具列表,避免 agent 对港股调 get_chip_distribution 或对美股调 get_capital_flow 后编造数据",
|
|
794
|
+
parameters: Type.Object({
|
|
795
|
+
market: Type.Optional(
|
|
796
|
+
Type.Union(
|
|
797
|
+
[Type.Literal("A"), Type.Literal("HK"), Type.Literal("US")],
|
|
798
|
+
{ description: "市场代码" }
|
|
799
|
+
)
|
|
800
|
+
),
|
|
801
|
+
symbol: Type.Optional(
|
|
802
|
+
Type.String({ description: "股票代码(自动识别市场,与 market 二选一)" })
|
|
803
|
+
),
|
|
804
|
+
}),
|
|
805
|
+
async execute(_id, params) {
|
|
806
|
+
const args = params.symbol
|
|
807
|
+
? ["get", "--symbol", params.symbol]
|
|
808
|
+
: ["get", "--market", params.market ?? "A"];
|
|
809
|
+
const out = await runPy("capabilities.py", args);
|
|
810
|
+
return asText(out);
|
|
811
|
+
},
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
// --- Report Rendering ---
|
|
815
|
+
|
|
816
|
+
api.registerTool({
|
|
817
|
+
name: "render_stock_report",
|
|
818
|
+
description:
|
|
819
|
+
"股票分析报告渲染 — 将结构化 JSON(符合 schemas/report_schema.json)通过 j2 模板渲染为 Markdown。template: brief|full。仅渲染,不保存不推送",
|
|
820
|
+
parameters: Type.Object({
|
|
821
|
+
report: Type.Object({}, { additionalProperties: true, description: "结构化股票报告" }),
|
|
822
|
+
template: Type.Optional(
|
|
823
|
+
Type.Union([Type.Literal("brief"), Type.Literal("full")], {
|
|
824
|
+
description: "模板类型,默认 full",
|
|
825
|
+
})
|
|
826
|
+
),
|
|
827
|
+
}),
|
|
828
|
+
async execute(_id, params) {
|
|
829
|
+
const b64 = Buffer.from(JSON.stringify(params.report), "utf-8").toString("base64");
|
|
830
|
+
const out = await runPy("report_renderer.py", [
|
|
831
|
+
"stock",
|
|
832
|
+
"--template",
|
|
833
|
+
params.template ?? "full",
|
|
834
|
+
"--input-b64",
|
|
835
|
+
b64,
|
|
836
|
+
]);
|
|
837
|
+
return asText(out);
|
|
838
|
+
},
|
|
839
|
+
});
|
|
840
|
+
|
|
841
|
+
api.registerTool({
|
|
842
|
+
name: "render_market_report",
|
|
843
|
+
description:
|
|
844
|
+
"大盘复盘报告渲染 — 将结构化 JSON(符合 schemas/market_review_schema.json)通过 j2 模板渲染为 Markdown",
|
|
845
|
+
parameters: Type.Object({
|
|
846
|
+
report: Type.Object({}, { additionalProperties: true, description: "结构化市场复盘" }),
|
|
847
|
+
template: Type.Optional(
|
|
848
|
+
Type.Union([Type.Literal("full")], { description: "模板类型,默认 full" })
|
|
849
|
+
),
|
|
850
|
+
}),
|
|
851
|
+
async execute(_id, params) {
|
|
852
|
+
const b64 = Buffer.from(JSON.stringify(params.report), "utf-8").toString("base64");
|
|
853
|
+
const out = await runPy("report_renderer.py", [
|
|
854
|
+
"market",
|
|
855
|
+
"--template",
|
|
856
|
+
params.template ?? "full",
|
|
857
|
+
"--input-b64",
|
|
858
|
+
b64,
|
|
859
|
+
]);
|
|
860
|
+
return asText(out);
|
|
861
|
+
},
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
// --- Watchlist / Position / Alert Context ---
|
|
865
|
+
|
|
866
|
+
api.registerTool({
|
|
867
|
+
name: "build_watchlist_context",
|
|
868
|
+
description:
|
|
869
|
+
"自选股上下文包 — 对多只股票输出评分/趋势/异常/风险/建议 next_tools 的 agent 友好摘要。宿主 agent 决定如何写日报或深入分析",
|
|
870
|
+
parameters: Type.Object({
|
|
871
|
+
symbols: Type.String({ description: "逗号分隔的股票代码列表" }),
|
|
872
|
+
include_market_review: Type.Optional(
|
|
873
|
+
Type.Boolean({ description: "是否附带各市场复盘,默认 false" })
|
|
874
|
+
),
|
|
875
|
+
workers: Type.Optional(Type.Number({ description: "并发数,默认 3" })),
|
|
876
|
+
}),
|
|
877
|
+
async execute(_id, params) {
|
|
878
|
+
const args = [
|
|
879
|
+
"build",
|
|
880
|
+
params.symbols,
|
|
881
|
+
"--workers",
|
|
882
|
+
String(params.workers ?? 3),
|
|
883
|
+
];
|
|
884
|
+
if (params.include_market_review) args.push("--include-market-review");
|
|
885
|
+
const out = await runPy("watchlist_context.py", args);
|
|
886
|
+
return asText(out);
|
|
887
|
+
},
|
|
888
|
+
});
|
|
889
|
+
|
|
890
|
+
api.registerTool({
|
|
891
|
+
name: "analyze_position_context",
|
|
892
|
+
description:
|
|
893
|
+
"持仓上下文分析 — 输入成本/仓位/止损止盈,结合现价和技术位输出浮盈亏、离止损距离、风险级别、操作建议。无状态、不存账户",
|
|
894
|
+
parameters: Type.Object({
|
|
895
|
+
symbol: Type.String({ description: "股票代码" }),
|
|
896
|
+
cost: Type.Number({ description: "成本价" }),
|
|
897
|
+
quantity: Type.Number({ description: "持仓数量" }),
|
|
898
|
+
stop_loss: Type.Optional(Type.Number({ description: "止损价" })),
|
|
899
|
+
take_profit: Type.Optional(Type.Number({ description: "止盈价" })),
|
|
900
|
+
}),
|
|
901
|
+
async execute(_id, params) {
|
|
902
|
+
const args = [
|
|
903
|
+
"analyze",
|
|
904
|
+
params.symbol,
|
|
905
|
+
"--cost",
|
|
906
|
+
String(params.cost),
|
|
907
|
+
"--quantity",
|
|
908
|
+
String(params.quantity),
|
|
909
|
+
];
|
|
910
|
+
if (params.stop_loss !== undefined) {
|
|
911
|
+
args.push("--stop-loss", String(params.stop_loss));
|
|
912
|
+
}
|
|
913
|
+
if (params.take_profit !== undefined) {
|
|
914
|
+
args.push("--take-profit", String(params.take_profit));
|
|
915
|
+
}
|
|
916
|
+
const out = await runPy("position_context.py", args);
|
|
917
|
+
return asText(out);
|
|
918
|
+
},
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
api.registerTool({
|
|
922
|
+
name: "check_alert_rules",
|
|
923
|
+
description:
|
|
924
|
+
"无状态告警规则检查 — 传入规则数组,返回当前是否触发。规则类型:price_below/price_above/change_pct_above/change_pct_below/volume_ratio_above/anomaly/risk_veto/risk_level_at_least。不做调度不存历史",
|
|
925
|
+
parameters: Type.Object({
|
|
926
|
+
symbol: Type.String({ description: "股票代码" }),
|
|
927
|
+
rules: Type.Array(
|
|
928
|
+
Type.Object({}, { additionalProperties: true }),
|
|
929
|
+
{ description: "规则列表,每项 { type, value }" }
|
|
930
|
+
),
|
|
931
|
+
}),
|
|
932
|
+
async execute(_id, params) {
|
|
933
|
+
const b64 = Buffer.from(JSON.stringify(params.rules), "utf-8").toString("base64");
|
|
934
|
+
const out = await runPy("alert_rules.py", [
|
|
935
|
+
"check",
|
|
936
|
+
params.symbol,
|
|
937
|
+
"--rules-b64",
|
|
938
|
+
b64,
|
|
939
|
+
]);
|
|
940
|
+
return asText(out);
|
|
941
|
+
},
|
|
942
|
+
});
|
|
943
|
+
|
|
944
|
+
api.registerTool({
|
|
945
|
+
name: "parse_stock_list",
|
|
946
|
+
description:
|
|
947
|
+
"自选股/文本导入解析 — 从自然语言、CSV、Markdown 表格提取股票,自动识别 A 股 6 位代码、港股 xxxxx.HK、美股 ticker,并调用 name_resolver 处理中文股票名",
|
|
948
|
+
parameters: Type.Object({
|
|
949
|
+
text: Type.String({ description: "待解析的文本" }),
|
|
950
|
+
}),
|
|
951
|
+
async execute(_id, params) {
|
|
952
|
+
const b64 = Buffer.from(String(params.text), "utf-8").toString("base64");
|
|
953
|
+
const out = await runPy("import_parser.py", ["parse", "--text-b64", b64]);
|
|
954
|
+
return asText(out);
|
|
955
|
+
},
|
|
956
|
+
});
|
|
760
957
|
},
|
|
761
958
|
});
|
package/openclaw.plugin.json
CHANGED
|
@@ -34,7 +34,15 @@
|
|
|
34
34
|
"detect_market_regime",
|
|
35
35
|
"get_market_review",
|
|
36
36
|
"run_watchlist_analysis",
|
|
37
|
-
"detect_anomaly"
|
|
37
|
+
"detect_anomaly",
|
|
38
|
+
"diagnose_data_sources",
|
|
39
|
+
"get_market_capabilities",
|
|
40
|
+
"render_stock_report",
|
|
41
|
+
"render_market_report",
|
|
42
|
+
"build_watchlist_context",
|
|
43
|
+
"analyze_position_context",
|
|
44
|
+
"check_alert_rules",
|
|
45
|
+
"parse_stock_list"
|
|
38
46
|
]
|
|
39
47
|
},
|
|
40
48
|
"activation": {
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weaxs/openclaw-stock-analysis",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "OpenClaw plugin for stock analysis, screening, and strategy backtesting across A/HK/US markets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.ts",
|
|
7
7
|
"openclaw": {
|
|
8
|
-
"extensions": [
|
|
8
|
+
"extensions": [
|
|
9
|
+
"./index.ts"
|
|
10
|
+
],
|
|
9
11
|
"compat": {
|
|
10
12
|
"pluginApi": ">=2026.3.24-beta.2",
|
|
11
13
|
"minGatewayVersion": "2026.3.24-beta.2"
|
|
@@ -25,6 +27,7 @@
|
|
|
25
27
|
"tools/",
|
|
26
28
|
"skills/",
|
|
27
29
|
"schemas/",
|
|
30
|
+
"templates/",
|
|
28
31
|
"strategies/",
|
|
29
32
|
"scripts/"
|
|
30
33
|
],
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "MarketReviewReport",
|
|
4
|
+
"description": "结构化大盘复盘报告格式",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"market": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"enum": ["A", "HK", "US"],
|
|
10
|
+
"description": "市场代码"
|
|
11
|
+
},
|
|
12
|
+
"market_cn": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "市场中文名(A 股 / 港股 / 美股)"
|
|
15
|
+
},
|
|
16
|
+
"review_date": { "type": "string", "format": "date" },
|
|
17
|
+
"temperature": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"description": "市场温度(来自 market_review.review)",
|
|
20
|
+
"properties": {
|
|
21
|
+
"score": { "type": "number", "minimum": 0, "maximum": 100 },
|
|
22
|
+
"level": { "type": "string", "enum": ["constructive", "neutral", "weak"] },
|
|
23
|
+
"signal": { "type": "string", "enum": ["green", "yellow", "red"] }
|
|
24
|
+
},
|
|
25
|
+
"required": ["score", "signal"]
|
|
26
|
+
},
|
|
27
|
+
"strategy_stance": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"enum": ["offensive", "balanced", "defensive"],
|
|
30
|
+
"description": "建议策略姿态"
|
|
31
|
+
},
|
|
32
|
+
"regime": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"description": "市场阶段(来自 detect_market_regime)",
|
|
35
|
+
"properties": {
|
|
36
|
+
"regime": { "type": "string" },
|
|
37
|
+
"regime_cn": { "type": "string" },
|
|
38
|
+
"confidence": { "type": "number" },
|
|
39
|
+
"recommended_skills": { "type": "array", "items": { "type": "string" } }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"overview": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"description": "盘面总览",
|
|
45
|
+
"properties": {
|
|
46
|
+
"headline": { "type": "string", "description": "一句话总览" },
|
|
47
|
+
"indices": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"items": {
|
|
50
|
+
"type": "object",
|
|
51
|
+
"properties": {
|
|
52
|
+
"name": { "type": "string" },
|
|
53
|
+
"code": { "type": "string" },
|
|
54
|
+
"price": { "type": "number" },
|
|
55
|
+
"change_pct": { "type": "number" },
|
|
56
|
+
"volume": { "type": ["number", "string"] }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"breadth": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"description": "涨跌家数(仅 A 股)",
|
|
63
|
+
"properties": {
|
|
64
|
+
"up_count": { "type": "integer" },
|
|
65
|
+
"down_count": { "type": "integer" },
|
|
66
|
+
"limit_up_count": { "type": "integer" },
|
|
67
|
+
"limit_down_count": { "type": "integer" },
|
|
68
|
+
"turnover": { "type": ["number", "string"] },
|
|
69
|
+
"turnover_change": { "type": "string", "description": "放量 / 缩量 / 持平" }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"index_structure": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"description": "指数结构与分化",
|
|
77
|
+
"properties": {
|
|
78
|
+
"large_vs_small": { "type": "string", "description": "大盘 vs 中小盘表现差异" },
|
|
79
|
+
"blue_chip_vs_theme": { "type": "string", "description": "权重股 vs 题材股分化" },
|
|
80
|
+
"position_assessment": { "type": "string", "description": "指数位置(突破 / 回落 / 震荡)" }
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"sectors": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"description": "板块主线(仅 A 股有完整数据)",
|
|
86
|
+
"properties": {
|
|
87
|
+
"leading": {
|
|
88
|
+
"type": "array",
|
|
89
|
+
"items": {
|
|
90
|
+
"type": "object",
|
|
91
|
+
"properties": {
|
|
92
|
+
"name": { "type": "string" },
|
|
93
|
+
"change_pct": { "type": "number" },
|
|
94
|
+
"logic": { "type": "string", "description": "上涨逻辑(政策 / 业绩 / 事件)" }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"lagging": {
|
|
99
|
+
"type": "array",
|
|
100
|
+
"items": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"properties": {
|
|
103
|
+
"name": { "type": "string" },
|
|
104
|
+
"change_pct": { "type": "number" },
|
|
105
|
+
"reason": { "type": "string" }
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"main_storylines": {
|
|
110
|
+
"type": "array",
|
|
111
|
+
"items": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"properties": {
|
|
114
|
+
"theme": { "type": "string" },
|
|
115
|
+
"stage": { "type": "string", "description": "首日 / 加速 / 高潮 / 退潮" },
|
|
116
|
+
"sustainability": { "type": "string", "enum": ["high", "medium", "low"] }
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"capital_emotion": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"description": "资金与情绪",
|
|
125
|
+
"properties": {
|
|
126
|
+
"turnover_level": { "type": "string", "description": "成交额历史分位" },
|
|
127
|
+
"limit_ratio": { "type": "string", "description": "涨停 / 跌停比情绪解读" },
|
|
128
|
+
"money_effect": { "type": "string", "description": "赚钱效应判断" },
|
|
129
|
+
"consecutive_limit_height": { "type": "integer", "description": "连板高度(仅 A 股)" }
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"catalysts": {
|
|
133
|
+
"type": "array",
|
|
134
|
+
"description": "消息催化",
|
|
135
|
+
"items": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"properties": {
|
|
138
|
+
"title": { "type": "string" },
|
|
139
|
+
"category": { "type": "string", "description": "政策 / 业绩 / 事件 / 国际 / 其他" },
|
|
140
|
+
"impact": { "type": "string", "description": "对市场的影响路径" },
|
|
141
|
+
"direction": { "type": "string", "enum": ["positive", "negative", "neutral"] }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"tomorrow_strategy": {
|
|
146
|
+
"type": "object",
|
|
147
|
+
"description": "明日策略",
|
|
148
|
+
"properties": {
|
|
149
|
+
"stance": { "type": "string", "enum": ["offensive", "balanced", "defensive"] },
|
|
150
|
+
"position_advice": { "type": "string", "description": "建议仓位区间" },
|
|
151
|
+
"focus_sectors": { "type": "array", "items": { "type": "string" } },
|
|
152
|
+
"avoid": { "type": "array", "items": { "type": "string" } },
|
|
153
|
+
"key_levels": {
|
|
154
|
+
"type": "object",
|
|
155
|
+
"properties": {
|
|
156
|
+
"support": { "type": ["number", "string"] },
|
|
157
|
+
"resistance": { "type": ["number", "string"] }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"risks": {
|
|
163
|
+
"type": "array",
|
|
164
|
+
"description": "风险提示",
|
|
165
|
+
"items": {
|
|
166
|
+
"type": "object",
|
|
167
|
+
"properties": {
|
|
168
|
+
"level": { "type": "string", "enum": ["high", "medium", "low"] },
|
|
169
|
+
"category": { "type": "string", "description": "系统性 / 板块 / 个股 / 外围" },
|
|
170
|
+
"description": { "type": "string" }
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"required": ["market", "review_date", "temperature", "strategy_stance"]
|
|
176
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Sync all manifest version fields to the version derived from the current
|
|
3
|
+
# git tag ($GITHUB_REF_NAME on GitHub Actions, e.g. "v0.1.5" → "0.1.5").
|
|
4
|
+
#
|
|
5
|
+
# Called by .github/workflows/publish.yml before each publish step. Changes
|
|
6
|
+
# are in-CI only — never committed back to the repo.
|
|
7
|
+
#
|
|
8
|
+
# Manifests updated:
|
|
9
|
+
# - pyproject.toml (PyPI package version)
|
|
10
|
+
# - package.json (npm root package)
|
|
11
|
+
# - package-lock.json (kept in lockstep so `npm publish` doesn't warn)
|
|
12
|
+
# - openclaw/package.json (OpenClaw npm package version)
|
|
13
|
+
#
|
|
14
|
+
# Idempotent: running twice with the same tag is a no-op.
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
|
|
17
|
+
TAG="${1:-${GITHUB_REF_NAME:-}}"
|
|
18
|
+
if [[ -z "$TAG" ]]; then
|
|
19
|
+
echo "usage: $0 <tag> (or set GITHUB_REF_NAME)" >&2
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
22
|
+
VERSION="${TAG#v}"
|
|
23
|
+
|
|
24
|
+
# Basic shape check — semver-ish, e.g. 0.1.5 or 1.2.3-rc.1
|
|
25
|
+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9.]+)?$ ]]; then
|
|
26
|
+
echo "sync-version: unexpected tag shape '$TAG' → version '$VERSION'" >&2
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
echo "sync-version: setting version to $VERSION (from tag $TAG)"
|
|
31
|
+
|
|
32
|
+
# pyproject.toml — the only `version = "..."` at file scope
|
|
33
|
+
python3 - "$VERSION" <<'PY'
|
|
34
|
+
import re, sys, pathlib
|
|
35
|
+
version = sys.argv[1]
|
|
36
|
+
p = pathlib.Path("pyproject.toml")
|
|
37
|
+
text = p.read_text()
|
|
38
|
+
new, n = re.subn(r'^version = "[^"]+"', f'version = "{version}"', text, count=1, flags=re.M)
|
|
39
|
+
if n != 1:
|
|
40
|
+
sys.exit(f"pyproject.toml: expected one version = line, got {n}")
|
|
41
|
+
p.write_text(new)
|
|
42
|
+
print(f" pyproject.toml: {n} substitution(s)")
|
|
43
|
+
PY
|
|
44
|
+
|
|
45
|
+
# npm root and openclaw sub-package
|
|
46
|
+
# `npm version` refuses in a workspace unless we bypass with --no-git-tag-version
|
|
47
|
+
# --allow-same-version keeps it idempotent when the tag already matches.
|
|
48
|
+
for dir in "." "openclaw"; do
|
|
49
|
+
if [[ -f "$dir/package.json" ]]; then
|
|
50
|
+
(cd "$dir" && npm version "$VERSION" --no-git-tag-version --allow-same-version) >/dev/null
|
|
51
|
+
echo " $dir/package.json: bumped"
|
|
52
|
+
fi
|
|
53
|
+
done
|
|
54
|
+
|
|
55
|
+
echo "sync-version: done"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{# Shared Jinja2 macros for stock-analysis-plugin report templates. #}
|
|
2
|
+
|
|
3
|
+
{% macro decision_emoji(decision) -%}
|
|
4
|
+
{%- if decision == 'strong_buy' -%}🟢🟢
|
|
5
|
+
{%- elif decision == 'buy' -%}🟢
|
|
6
|
+
{%- elif decision == 'hold' -%}⚪
|
|
7
|
+
{%- elif decision == 'sell' -%}🟡
|
|
8
|
+
{%- elif decision == 'strong_sell' -%}🔴
|
|
9
|
+
{%- else -%}❔
|
|
10
|
+
{%- endif -%}
|
|
11
|
+
{%- endmacro %}
|
|
12
|
+
|
|
13
|
+
{% macro decision_label(decision) -%}
|
|
14
|
+
{%- if decision == 'strong_buy' -%}强烈买入
|
|
15
|
+
{%- elif decision == 'buy' -%}买入
|
|
16
|
+
{%- elif decision == 'hold' -%}观望
|
|
17
|
+
{%- elif decision == 'sell' -%}卖出
|
|
18
|
+
{%- elif decision == 'strong_sell' -%}强烈卖出
|
|
19
|
+
{%- else -%}-
|
|
20
|
+
{%- endif -%}
|
|
21
|
+
{%- endmacro %}
|
|
22
|
+
|
|
23
|
+
{% macro confidence_label(c) -%}
|
|
24
|
+
{%- if c == 'high' -%}高
|
|
25
|
+
{%- elif c == 'medium' -%}中
|
|
26
|
+
{%- elif c == 'low' -%}低
|
|
27
|
+
{%- else -%}-
|
|
28
|
+
{%- endif -%}
|
|
29
|
+
{%- endmacro %}
|
|
30
|
+
|
|
31
|
+
{% macro signal_emoji(signal) -%}
|
|
32
|
+
{%- if signal == 'green' -%}🟢
|
|
33
|
+
{%- elif signal == 'yellow' -%}🟡
|
|
34
|
+
{%- elif signal == 'red' -%}🔴
|
|
35
|
+
{%- else -%}⚪
|
|
36
|
+
{%- endif -%}
|
|
37
|
+
{%- endmacro %}
|
|
38
|
+
|
|
39
|
+
{% macro signal_label(signal) -%}
|
|
40
|
+
{%- if signal == 'green' -%}绿灯(进攻)
|
|
41
|
+
{%- elif signal == 'yellow' -%}黄灯(均衡)
|
|
42
|
+
{%- elif signal == 'red' -%}红灯(防守)
|
|
43
|
+
{%- else -%}-
|
|
44
|
+
{%- endif -%}
|
|
45
|
+
{%- endmacro %}
|
|
46
|
+
|
|
47
|
+
{% macro stance_label(stance) -%}
|
|
48
|
+
{%- if stance == 'offensive' -%}进攻
|
|
49
|
+
{%- elif stance == 'balanced' -%}均衡
|
|
50
|
+
{%- elif stance == 'defensive' -%}防守
|
|
51
|
+
{%- else -%}-
|
|
52
|
+
{%- endif -%}
|
|
53
|
+
{%- endmacro %}
|
|
54
|
+
|
|
55
|
+
{% macro risk_emoji(level) -%}
|
|
56
|
+
{%- if level == 'high' -%}🔴
|
|
57
|
+
{%- elif level == 'medium' -%}🟡
|
|
58
|
+
{%- elif level == 'low' -%}🟢
|
|
59
|
+
{%- else -%}⚪
|
|
60
|
+
{%- endif -%}
|
|
61
|
+
{%- endmacro %}
|
|
62
|
+
|
|
63
|
+
{% macro change_pct(v) -%}
|
|
64
|
+
{%- if v is none or v is not number -%}-
|
|
65
|
+
{%- elif v > 0 -%}+{{ '%.2f'|format(v) }}%
|
|
66
|
+
{%- else -%}{{ '%.2f'|format(v) }}%
|
|
67
|
+
{%- endif -%}
|
|
68
|
+
{%- endmacro %}
|
|
69
|
+
|
|
70
|
+
{% macro fmt_num(v, digits=2) -%}
|
|
71
|
+
{%- if v is none -%}-
|
|
72
|
+
{%- elif v is number -%}{{ ('%%.%df' % digits)|format(v) }}
|
|
73
|
+
{%- else -%}{{ v }}
|
|
74
|
+
{%- endif -%}
|
|
75
|
+
{%- endmacro %}
|
|
76
|
+
|
|
77
|
+
{% macro market_cn(m) -%}
|
|
78
|
+
{%- if m == 'A' -%}A 股
|
|
79
|
+
{%- elif m == 'HK' -%}港股
|
|
80
|
+
{%- elif m == 'US' -%}美股
|
|
81
|
+
{%- else -%}{{ m }}
|
|
82
|
+
{%- endif -%}
|
|
83
|
+
{%- endmacro %}
|
|
84
|
+
|
|
85
|
+
{% macro direction_emoji(d) -%}
|
|
86
|
+
{%- if d == 'positive' -%}✅
|
|
87
|
+
{%- elif d == 'negative' -%}⚠️
|
|
88
|
+
{%- else -%}ℹ️
|
|
89
|
+
{%- endif -%}
|
|
90
|
+
{%- endmacro %}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{%- import '_macros.j2' as m -%}
|
|
2
|
+
# {{ m.market_cn(market) }}大盘复盘 · {{ review_date }}
|
|
3
|
+
|
|
4
|
+
{% set t = temperature or {} -%}
|
|
5
|
+
**温度:** {{ m.signal_emoji(t.signal) }} {{ m.fmt_num(t.score, 1) }}/100 | **信号灯:** {{ m.signal_label(t.signal) }} | **策略姿态:** {{ m.stance_label(strategy_stance) }}
|
|
6
|
+
|
|
7
|
+
{% if regime and (regime.regime_cn or regime.regime) -%}
|
|
8
|
+
> **市场阶段:** {{ regime.regime_cn or regime.regime }}{% if regime.confidence is not none %}(置信度 {{ m.fmt_num(regime.confidence) }}){% endif %}{% if regime.recommended_skills %} | **推荐策略:** {{ regime.recommended_skills | join('、') }}{% endif %}
|
|
9
|
+
{%- endif %}
|
|
10
|
+
|
|
11
|
+
## 1. 盘面总览
|
|
12
|
+
|
|
13
|
+
{% set ov = overview or {} -%}
|
|
14
|
+
{% if ov.headline -%}
|
|
15
|
+
{{ ov.headline }}
|
|
16
|
+
|
|
17
|
+
{% endif -%}
|
|
18
|
+
{% if ov.indices -%}
|
|
19
|
+
| 指数 | 现值 | 涨跌幅 | 成交量 |
|
|
20
|
+
|------|------|--------|--------|
|
|
21
|
+
{% for idx in ov.indices -%}
|
|
22
|
+
| {{ idx.name }}{% if idx.code %}({{ idx.code }}){% endif %} | {{ m.fmt_num(idx.price) }} | {{ m.change_pct(idx.change_pct) }} | {{ idx.volume or '-' }} |
|
|
23
|
+
{% endfor %}
|
|
24
|
+
{%- endif %}
|
|
25
|
+
|
|
26
|
+
{% set br = ov.breadth or {} -%}
|
|
27
|
+
{% if br and (br.up_count is not none or br.limit_up_count is not none) -%}
|
|
28
|
+
- **涨跌家数:** 🟢 {{ br.up_count or 0 }} 上涨 | 🔴 {{ br.down_count or 0 }} 下跌
|
|
29
|
+
- **涨跌停:** 🚀 {{ br.limit_up_count or 0 }} 涨停 | 💧 {{ br.limit_down_count or 0 }} 跌停
|
|
30
|
+
{% if br.turnover %}- **成交额:** {{ br.turnover }}{% if br.turnover_change %}({{ br.turnover_change }}){% endif %}
|
|
31
|
+
{% endif -%}
|
|
32
|
+
{%- endif %}
|
|
33
|
+
|
|
34
|
+
{% if index_structure -%}
|
|
35
|
+
## 2. 指数结构
|
|
36
|
+
|
|
37
|
+
{% if index_structure.large_vs_small %}- **大小盘分化:** {{ index_structure.large_vs_small }}
|
|
38
|
+
{% endif %}{% if index_structure.blue_chip_vs_theme %}- **权重 vs 题材:** {{ index_structure.blue_chip_vs_theme }}
|
|
39
|
+
{% endif %}{% if index_structure.position_assessment %}- **指数位置:** {{ index_structure.position_assessment }}
|
|
40
|
+
{% endif %}
|
|
41
|
+
{%- endif %}
|
|
42
|
+
|
|
43
|
+
{% if sectors -%}
|
|
44
|
+
## 3. 板块主线
|
|
45
|
+
|
|
46
|
+
{% if sectors.leading -%}
|
|
47
|
+
**领涨板块:**
|
|
48
|
+
{% for s in sectors.leading %}- 🟢 {{ s.name }} {{ m.change_pct(s.change_pct) }}{% if s.logic %} — {{ s.logic }}{% endif %}
|
|
49
|
+
{% endfor %}
|
|
50
|
+
{%- endif %}
|
|
51
|
+
|
|
52
|
+
{% if sectors.lagging -%}
|
|
53
|
+
**领跌板块:**
|
|
54
|
+
{% for s in sectors.lagging %}- 🔴 {{ s.name }} {{ m.change_pct(s.change_pct) }}{% if s.reason %} — {{ s.reason }}{% endif %}
|
|
55
|
+
{% endfor %}
|
|
56
|
+
{%- endif %}
|
|
57
|
+
|
|
58
|
+
{% if sectors.main_storylines -%}
|
|
59
|
+
**主线判断:**
|
|
60
|
+
{% for line in sectors.main_storylines %}- **{{ line.theme }}** | 阶段:{{ line.stage or '-' }}{% if line.sustainability %} | 持续性:{{ line.sustainability }}{% endif %}
|
|
61
|
+
{% endfor %}
|
|
62
|
+
{%- endif %}
|
|
63
|
+
{%- endif %}
|
|
64
|
+
|
|
65
|
+
{% if capital_emotion -%}
|
|
66
|
+
## 4. 资金与情绪
|
|
67
|
+
|
|
68
|
+
{% if capital_emotion.turnover_level %}- **成交分位:** {{ capital_emotion.turnover_level }}
|
|
69
|
+
{% endif %}{% if capital_emotion.limit_ratio %}- **涨跌停比:** {{ capital_emotion.limit_ratio }}
|
|
70
|
+
{% endif %}{% if capital_emotion.money_effect %}- **赚钱效应:** {{ capital_emotion.money_effect }}
|
|
71
|
+
{% endif %}{% if capital_emotion.consecutive_limit_height is not none %}- **连板高度:** {{ capital_emotion.consecutive_limit_height }} 板
|
|
72
|
+
{% endif %}
|
|
73
|
+
{%- endif %}
|
|
74
|
+
|
|
75
|
+
{% if catalysts -%}
|
|
76
|
+
## 5. 消息催化
|
|
77
|
+
|
|
78
|
+
{% for c in catalysts %}- {{ m.direction_emoji(c.direction) }} **[{{ c.category or '-' }}] {{ c.title }}**{% if c.impact %} — {{ c.impact }}{% endif %}
|
|
79
|
+
{% endfor %}
|
|
80
|
+
{%- endif %}
|
|
81
|
+
|
|
82
|
+
{% if tomorrow_strategy -%}
|
|
83
|
+
## 6. 明日策略
|
|
84
|
+
|
|
85
|
+
{% set ts = tomorrow_strategy -%}
|
|
86
|
+
- **策略姿态:** {{ m.stance_label(ts.stance) }}
|
|
87
|
+
{% if ts.position_advice %}- **建议仓位:** {{ ts.position_advice }}
|
|
88
|
+
{% endif %}{% if ts.focus_sectors %}- **关注方向:** {{ ts.focus_sectors | join('、') }}
|
|
89
|
+
{% endif %}{% if ts.avoid %}- **规避方向:** {{ ts.avoid | join('、') }}
|
|
90
|
+
{% endif %}{% if ts.key_levels and (ts.key_levels.support or ts.key_levels.resistance) -%}
|
|
91
|
+
- **关键点位:** 支撑 {{ ts.key_levels.support or '-' }} | 压力 {{ ts.key_levels.resistance or '-' }}
|
|
92
|
+
{%- endif %}
|
|
93
|
+
{%- endif %}
|
|
94
|
+
|
|
95
|
+
{% if risks -%}
|
|
96
|
+
## 7. 风险提示
|
|
97
|
+
|
|
98
|
+
{% for r in risks %}- {{ m.risk_emoji(r.level) }} **[{{ r.category or '风险' }}]** {{ r.description }}
|
|
99
|
+
{% endfor %}
|
|
100
|
+
{%- endif %}
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
*本报告由 stock-analysis-plugin 渲染,仅供参考,不构成投资建议。*
|