@v587d/capital-generation 2.31.8 → 2.32.1

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +11 -7
  3. package/automation/package.json +1 -1
  4. package/chart-ui/package.json +1 -1
  5. package/config/package.json +1 -1
  6. package/lib/analysis/artifact.d.ts +35 -0
  7. package/lib/analysis/artifact.js +250 -0
  8. package/lib/analysis/registry.d.ts +16 -2
  9. package/lib/analysis/registry.js +133 -23
  10. package/lib/analysis/runtime.d.ts +46 -19
  11. package/lib/analysis/runtime.js +485 -116
  12. package/lib/analysis/schemas.d.ts +46 -0
  13. package/lib/analysis/schemas.js +260 -7
  14. package/lib/analysis/snapshot.d.ts +10 -3
  15. package/lib/analysis/snapshot.js +298 -46
  16. package/lib/analysis/storage.d.ts +29 -1
  17. package/lib/analysis/storage.js +39 -6
  18. package/lib/analysis/tools.js +270 -29
  19. package/lib/analysis/types.d.ts +257 -3
  20. package/lib/analysis/types.js +31 -1
  21. package/lib/analysis/validation.d.ts +37 -1
  22. package/lib/analysis/validation.js +315 -1
  23. package/lib/chart/tool.js +1 -0
  24. package/lib/data-collector/store.d.ts +7 -1
  25. package/lib/data-collector/store.js +14 -0
  26. package/lib/python-runtime/child-env.d.ts +4 -2
  27. package/lib/python-runtime/child-env.js +21 -14
  28. package/lib/python-runtime/manager.d.ts +8 -0
  29. package/lib/python-runtime/manager.js +30 -14
  30. package/lib/sources/ftshare-rest.js +1 -1
  31. package/lib/sources/tencent-http.js +210 -53
  32. package/lib/web-retriever/local-fetch.d.ts +1 -1
  33. package/lib/web-retriever/local-fetch.js +1 -1
  34. package/lib/web-retriever/wind-client.d.ts +1 -1
  35. package/lib/web-retriever/wind-client.js +1 -1
  36. package/package.json +2 -1
  37. package/plugin-page/README.en.md +1 -1
  38. package/plugin-page/README.zh.md +1 -1
  39. package/preset/capital-generation/agent.patch.yml +1 -1
  40. package/preset/capital-generation/skills/capital-analysis-evidence/SKILL.md +15 -2
  41. package/preset/capital-generation/skills/capital-analysis-synthesis/SKILL.md +54 -9
  42. package/preset/capital-generation/skills/capital-analysis-validation/SKILL.md +41 -7
  43. package/preset/capital-generation/skills/capital-equity-research/SKILL.md +1 -1
  44. package/preset/capital-generation/skills/capital-event-impact/SKILL.md +20 -1
  45. package/preset/capital-generation/skills/capital-orchestration/SKILL.md +1 -1
  46. package/preset/capital-generation/skills/capital-senior-analysis/SKILL.md +38 -8
  47. package/python/analysis/lib/__init__.py +9 -0
  48. package/python/analysis/lib/errors.py +12 -0
  49. package/python/analysis/lib/eventstudy.py +164 -0
  50. package/python/analysis/lib/frames.py +95 -0
  51. package/python/analysis/lib/gaps.py +54 -0
  52. package/python/analysis/lib/jsonio.py +61 -0
  53. package/python/analysis/lib/metrics.py +147 -0
  54. package/python/analysis/lib/pit.py +84 -0
  55. package/python/analysis/lib/prices.py +140 -0
  56. package/python/analysis/lib/timeaxis.py +142 -0
  57. package/python/analysis/lib/version.py +3 -0
  58. package/python/analysis/modules/comps_valuation/module.py +26 -59
  59. package/python/analysis/modules/earnings_bridge/module.py +20 -77
  60. package/python/analysis/modules/event_study/LICENSE +21 -0
  61. package/python/analysis/modules/event_study/module.json +217 -0
  62. package/python/analysis/modules/event_study/module.py +979 -0
  63. package/python/analysis/modules/financial_quality/module.py +25 -88
  64. package/python/analysis/modules/hello/module.py +4 -0
  65. package/python/analysis/modules/kline_quality/module.py +26 -132
  66. package/python/analysis/modules/portfolio_stress/module.py +27 -112
  67. package/python/analysis/modules/returns_risk/module.json +108 -25
  68. package/python/analysis/modules/returns_risk/module.py +68 -227
  69. package/python/analysis/modules/scenario_sensitivity/module.py +11 -44
  70. package/python/analysis/modules/simple_backtest/module.json +244 -36
  71. package/python/analysis/modules/simple_backtest/module.py +1146 -459
  72. package/python/analysis/modules/statement_integrity/module.py +35 -87
  73. package/python/analysis/modules/technical_indicators/module.py +33 -152
  74. package/python/analysis/modules/valuation_sensitivity/module.py +30 -61
  75. package/python/worker.py +5 -0
  76. package/watchlist/package.json +1 -1
@@ -11,6 +11,12 @@ this module only produces reproducible multiples plus the input values behind ea
11
11
  """
12
12
  from __future__ import annotations
13
13
 
14
+ from lib import frames as _frames
15
+ from lib import gaps as gapvocab
16
+ from lib.errors import AnalysisInputError
17
+ from lib.frames import columns_of as _columns_of, number as _number
18
+ from lib.jsonio import plain as _plain, round_metric as _round
19
+
14
20
  MODULE_ID = "comps_valuation"
15
21
  MODULE_VERSION = "1.0.0"
16
22
  OUTPUT_NAME = "comps"
@@ -42,59 +48,12 @@ MULTIPLES = (
42
48
  )
43
49
 
44
50
 
45
- class AnalysisInputError(Exception):
46
- """The input cannot be used at all; the host maps `analysis_code` to the stable protocol code."""
47
-
48
- analysis_code = "analysis_input_invalid"
49
-
50
-
51
- def _round(value):
52
- rounded = round(float(value), 6)
53
- return 0.0 if rounded == 0 else rounded
54
-
55
-
56
- def _plain(value):
57
- return int(value) if isinstance(value, float) and value.is_integer() else value
58
-
59
-
60
- def _number(row, name):
61
- if row is None:
62
- return None
63
- value = row.get(name)
64
- if isinstance(value, bool) or not isinstance(value, (int, float)):
65
- return None
66
- number = float(value)
67
- if number != number or number in (float("inf"), float("-inf")):
68
- return None
69
- return number
70
-
71
-
72
- def _columns_of(view):
73
- columns = view.get("columns") or []
74
- names = {item.get("name") for item in columns if isinstance(item, dict)}
75
- for row in (view.get("rows") or [])[:1]:
76
- if isinstance(row, dict):
77
- names |= set(row)
78
- return names
79
-
80
-
81
- def _read_datasets(request, context):
82
- items = (request.get("inputs") or {}).get("datasets") or []
83
- if not items:
84
- raise AnalysisInputError("快照里没有任何 Dataset:comps_valuation 需要同行同期的 peers 横截面")
85
- views = {}
86
- for item in items:
87
- dataset_id = (item or {}).get("dataset_id")
88
- if not isinstance(dataset_id, str) or not dataset_id:
89
- raise AnalysisInputError("request.inputs.datasets 里有缺失 dataset_id 的条目")
90
- views[dataset_id] = context.read_dataset(dataset_id)
91
- for dataset_id, view in views.items():
92
- if view.get("shape") != "rows":
93
- raise AnalysisInputError(
94
- f"Dataset {dataset_id} 是 {view.get('shape')} 型:comps_valuation 只吃表格数据,"
95
- "文档型输入请先走 profile 或证据"
96
- )
97
- return views
51
+ def _read_views(request, context):
52
+ return _frames.read_views(
53
+ request, context,
54
+ module_id=MODULE_ID,
55
+ empty_message="快照里没有任何 Dataset:comps_valuation 需要同行同期的 peers 横截面",
56
+ )
98
57
 
99
58
 
100
59
  def _select_datasets(views, params):
@@ -232,7 +191,7 @@ def _summary(peer_medians, subject_values, subject_premiums, excluded, gaps, sub
232
191
 
233
192
  def analyze(request: dict, context) -> dict:
234
193
  params = request.get("params") or {}
235
- views = _read_datasets(request, context)
194
+ views = _read_views(request, context)
236
195
  peers_id, subject_id = _select_datasets(views, params)
237
196
  methodology = [f"peers = {peers_id}" + (f";subject = {subject_id}" if subject_id else ";未提供 subject")]
238
197
  limitations = list(LIMITATIONS)
@@ -260,7 +219,9 @@ def analyze(request: dict, context) -> dict:
260
219
  label = str(ticker) if ticker is not None else f"row_{index + 1}"
261
220
  values, inputs = _multiples_of(row)
262
221
  if not values:
263
- gaps.append(f"{label} 没有可计算的倍数(market_cap / net_profit 或对应分母缺失或不可用)")
222
+ gaps.append(gapvocab.field_missing(
223
+ f"{label} 没有可计算的倍数(market_cap / net_profit 或对应分母缺失或不可用)"
224
+ ))
264
225
  for code, _, numerator, denominator in MULTIPLES:
265
226
  if code in values:
266
227
  peer_values[code].append(values[code])
@@ -277,7 +238,9 @@ def analyze(request: dict, context) -> dict:
277
238
  for code, label, _, _ in MULTIPLES:
278
239
  values = peer_values[code]
279
240
  if not values:
280
- gaps.append(f"{label} 未计算:peers 表没有可用的 {_multiple_name(code)} 样本(缺列、分母 ≤ 0 或全被剔除)")
241
+ gaps.append(gapvocab.field_missing(
242
+ f"{label} 未计算:peers 表没有可用的 {_multiple_name(code)} 样本(缺列、分母 ≤ 0 或全被剔除)"
243
+ ))
281
244
  metrics[f"{code}_count"] = 0
282
245
  continue
283
246
  median = _round(_median(values))
@@ -295,7 +258,9 @@ def analyze(request: dict, context) -> dict:
295
258
  raise AnalysisInputError(f"subject Dataset 必须只有一行(当前 {len(subject_rows)} 行):横截面口径一次只比一只标的")
296
259
  subject_values, subject_inputs = _multiples_of(subject_rows[0])
297
260
  if not subject_values:
298
- gaps.append("subject 没有可计算的倍数:缺 market_cap / net_profit 或分母不可用")
261
+ gaps.append(gapvocab.field_missing(
262
+ "subject 没有可计算的倍数:缺 market_cap / net_profit 或分母不可用"
263
+ ))
299
264
  for code, label, _, _ in MULTIPLES:
300
265
  if code in subject_values:
301
266
  metrics[f"{code}_subject"] = _round(subject_values[code])
@@ -305,7 +270,9 @@ def analyze(request: dict, context) -> dict:
305
270
  metrics[f"{code}_premium"] = premium
306
271
  methodology.append(f"{label}:标的 {_ratio_text(subject_values[code])},较中位数 {premium * 100:+.2f}%")
307
272
  else:
308
- gaps.append(f"{label} 的相对位置未计算:peers 侧没有可用中位数")
273
+ gaps.append(gapvocab.field_missing(
274
+ f"{label} 的相对位置未计算:peers 侧没有可用中位数"
275
+ ))
309
276
  methodology.append("subject 倍数:" + "、".join(f"{label} {_ratio_text(subject_values[code])}" for code, label, _, _ in MULTIPLES if code in subject_values))
310
277
  subject_payload = {
311
278
  "ticker": str(subject_rows[0].get(ticker_column)) if ticker_column and subject_rows[0].get(ticker_column) is not None else "subject",
@@ -328,7 +295,7 @@ def analyze(request: dict, context) -> dict:
328
295
  limitations.append("剔除的样本:" + "、".join(f"{label} {count} 家" for label, count in excluded.items()))
329
296
 
330
297
  payload = {
331
- "protocol": "capital.analysis/v1",
298
+ "protocol": "capital.analysis/v2",
332
299
  "module_id": MODULE_ID,
333
300
  "module_version": MODULE_VERSION,
334
301
  "analysis_id": request.get("analysis_id"),
@@ -17,7 +17,12 @@ this module only produces reproducible effects plus the input values behind each
17
17
  """
18
18
  from __future__ import annotations
19
19
 
20
- from datetime import datetime, timezone
20
+ from lib import frames as _frames
21
+ from lib import gaps as gapvocab
22
+ from lib.errors import AnalysisInputError
23
+ from lib.frames import columns_of as _columns_of, number as _number
24
+ from lib.jsonio import round_metric as _round
25
+ from lib.timeaxis import iso_date as _iso_date
21
26
 
22
27
  MODULE_ID = "earnings_bridge"
23
28
  MODULE_VERSION = "1.0.0"
@@ -41,22 +46,6 @@ LIMITATIONS = [
41
46
 
42
47
  SIGNATURE = ("operating_income", "net_profit")
43
48
  PERIOD_KEYS = ("period_end_ms", "period")
44
- ROUND = 6
45
-
46
-
47
- class AnalysisInputError(Exception):
48
- """The input cannot be used at all; the host maps `analysis_code` to the stable protocol code."""
49
-
50
- analysis_code = "analysis_input_invalid"
51
-
52
-
53
- def _round(value):
54
- rounded = round(float(value), ROUND)
55
- return 0.0 if rounded == 0 else rounded
56
-
57
-
58
- def _plain(value):
59
- return int(value) if isinstance(value, float) and value.is_integer() else value
60
49
 
61
50
 
62
51
  def _amount(value):
@@ -69,44 +58,12 @@ def _amount(value):
69
58
  return _round(value)
70
59
 
71
60
 
72
- def _number(row, name):
73
- if row is None:
74
- return None
75
- value = row.get(name)
76
- if isinstance(value, bool) or not isinstance(value, (int, float)):
77
- return None
78
- number = float(value)
79
- if number != number or number in (float("inf"), float("-inf")):
80
- return None
81
- return number
82
-
83
-
84
- def _columns_of(view):
85
- columns = view.get("columns") or []
86
- names = {item.get("name") for item in columns if isinstance(item, dict)}
87
- for row in (view.get("rows") or [])[:1]:
88
- if isinstance(row, dict):
89
- names |= set(row)
90
- return names
91
-
92
-
93
- def _read_datasets(request, context):
94
- items = (request.get("inputs") or {}).get("datasets") or []
95
- if not items:
96
- raise AnalysisInputError("快照里没有任何 Dataset:earnings_bridge 需要一份利润表序列")
97
- views = {}
98
- for item in items:
99
- dataset_id = (item or {}).get("dataset_id")
100
- if not isinstance(dataset_id, str) or not dataset_id:
101
- raise AnalysisInputError("request.inputs.datasets 里有缺失 dataset_id 的条目")
102
- views[dataset_id] = context.read_dataset(dataset_id)
103
- for dataset_id, view in views.items():
104
- if view.get("shape") != "rows":
105
- raise AnalysisInputError(
106
- f"Dataset {dataset_id} 是 {view.get('shape')} 型:earnings_bridge 只吃表格数据,"
107
- "文档型输入请先走 profile 或证据"
108
- )
109
- return views
61
+ def _read_views(request, context):
62
+ return _frames.read_views(
63
+ request, context,
64
+ module_id=MODULE_ID,
65
+ empty_message="快照里没有任何 Dataset:earnings_bridge 需要一份利润表序列",
66
+ )
110
67
 
111
68
 
112
69
  def _select_dataset(views, params):
@@ -142,21 +99,7 @@ def _join_key(view):
142
99
 
143
100
 
144
101
  def _index_rows(view, column):
145
- indexed = {}
146
- for row in view.get("rows") or []:
147
- if not isinstance(row, dict):
148
- raise AnalysisInputError("利润表的数据行不是对象:无法计算")
149
- key = row.get(column)
150
- if isinstance(key, bool) or not isinstance(key, (int, float, str)) or key == "":
151
- raise AnalysisInputError(f"利润表的 {column} 列有空值:无法对齐报告期")
152
- if key in indexed:
153
- raise AnalysisInputError(f"利润表在报告期 {key} 出现多行:无法判断用哪一行(请先去重)")
154
- indexed[key] = row
155
- return indexed
156
-
157
-
158
- def _iso_date(ms):
159
- return datetime.fromtimestamp(float(ms) / 1000, tz=timezone.utc).strftime("%Y-%m-%d")
102
+ return _frames.index_rows(view, column, "利润表")
160
103
 
161
104
 
162
105
  def _label(rows, key, key_column):
@@ -292,7 +235,7 @@ def _summary(current_label, previous_label, nets, revenue_bridge, tax_bridge, ga
292
235
 
293
236
  def analyze(request: dict, context) -> dict:
294
237
  params = request.get("params") or {}
295
- views = _read_datasets(request, context)
238
+ views = _read_views(request, context)
296
239
  dataset_id = _select_dataset(views, params)
297
240
  view = views[dataset_id]
298
241
  methodology = [f"利润表 = {dataset_id}"]
@@ -313,13 +256,13 @@ def analyze(request: dict, context) -> dict:
313
256
  methodology.append(f"报告期键 {key_column};本期 {current_label}")
314
257
 
315
258
  if not previous_keys:
316
- gaps.append(f"没有早于 {current_label} 的报告期:两期归因无法计算")
259
+ gaps.append(gapvocab.period_conflict(f"没有早于 {current_label} 的报告期:两期归因无法计算"))
317
260
  current = rows[current_key]
318
261
  nets = (_number(current, "net_profit"), _number(current, "net_profit"), 0.0)
319
262
  status = "blocked"
320
263
  metrics = {"net_profit_current": _amount(nets[1])}
321
264
  payload = {
322
- "protocol": "capital.analysis/v1",
265
+ "protocol": "capital.analysis/v2",
323
266
  "module_id": MODULE_ID,
324
267
  "module_version": MODULE_VERSION,
325
268
  "analysis_id": request.get("analysis_id"),
@@ -357,7 +300,7 @@ def analyze(request: dict, context) -> dict:
357
300
  net_cur = _number(current, "net_profit")
358
301
  metrics = {}
359
302
  if net_prev is None or net_cur is None:
360
- gaps.append("两期净利润有空值(或非数字):差额无法计算")
303
+ gaps.append(gapvocab.field_missing("两期净利润有空值(或非数字):差额无法计算"))
361
304
  status = "blocked"
362
305
  nets = (None, None, None)
363
306
  else:
@@ -376,7 +319,7 @@ def analyze(request: dict, context) -> dict:
376
319
  revenue_bridge, revenue_gap = _revenue_bridge(previous, current)
377
320
  tax_bridge, tax_gap = _tax_bridge(previous, current)
378
321
  if revenue_gap:
379
- gaps.append(f"收入/净利率分解未执行:{revenue_gap}")
322
+ gaps.append(gapvocab.field_missing(f"收入/净利率分解未执行:{revenue_gap}"))
380
323
  else:
381
324
  metrics.update({
382
325
  "revenue_previous": revenue_bridge["revenue_previous"],
@@ -394,7 +337,7 @@ def analyze(request: dict, context) -> dict:
394
337
  f"三项合计与差额的残差 {revenue_bridge['bridge_residual']}"
395
338
  )
396
339
  if tax_gap:
397
- gaps.append(f"税前/税率分解未执行:{tax_gap}")
340
+ gaps.append(gapvocab.field_missing(f"税前/税率分解未执行:{tax_gap}"))
398
341
  else:
399
342
  metrics.update({
400
343
  "profit_total_previous": tax_bridge["profit_total_previous"],
@@ -422,7 +365,7 @@ def analyze(request: dict, context) -> dict:
422
365
  limitations.append("交互项不是误差项:它同时含两个因子的变化,报告时不要并入收入或净利率")
423
366
 
424
367
  payload = {
425
- "protocol": "capital.analysis/v1",
368
+ "protocol": "capital.analysis/v2",
426
369
  "module_id": MODULE_ID,
427
370
  "module_version": MODULE_VERSION,
428
371
  "analysis_id": request.get("analysis_id"),
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 v587d
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,217 @@
1
+ {
2
+ "id": "event_study",
3
+ "version": "1.0.0",
4
+ "entrypoint": "module.py",
5
+ "runtime": "python",
6
+ "description": "事件研究:按证据条目的发布时间对齐事件日,用调用方指定的基准行情算事件窗异常收益(market_adjusted 取基准同日收益作预期,market_model 用事件前估计窗 OLS 拟合 alpha/beta),输出逐事件对齐/AR/CAR 明细、样本量与因果边界;只描述历史价格相对基准的表现,不证明因果、不预测、不评级",
7
+ "roles": [
8
+ "senior_analyst"
9
+ ],
10
+ "capabilities": [
11
+ "dataset.read",
12
+ "evidence.read"
13
+ ],
14
+ "required_fields": [
15
+ "inputs.evidence"
16
+ ],
17
+ "input_schema": {
18
+ "type": "object",
19
+ "properties": {
20
+ "price_dataset_id": {
21
+ "type": "string",
22
+ "maxLength": 128,
23
+ "description": "标的行情 Dataset id;只有一份像日线价格序列时可省略"
24
+ },
25
+ "price_column": {
26
+ "type": "string",
27
+ "maxLength": 64,
28
+ "description": "价格列名;省略优先 adj_close(复权)再 close / close_price / price / nav"
29
+ },
30
+ "time_column": {
31
+ "type": "string",
32
+ "maxLength": 64,
33
+ "description": "时间列名;省略优先用 time_coverage 列,再按 trade_date_ms / date 等识别"
34
+ },
35
+ "timezone": {
36
+ "type": "string",
37
+ "maxLength": 64,
38
+ "description": "IANA 时区:解析事件发布时间与数值时间轴的日历日,默认 Asia/Shanghai"
39
+ },
40
+ "price_basis": {
41
+ "type": "string",
42
+ "enum": [
43
+ "auto",
44
+ "adjusted",
45
+ "unadjusted"
46
+ ],
47
+ "description": "价格复权口径;auto 按列名推断(adj_close 视为复权),显式值覆盖推断"
48
+ },
49
+ "benchmark_dataset_id": {
50
+ "type": "string",
51
+ "maxLength": 128,
52
+ "description": "基准行情 Dataset(时间列 + 价格列);必需,缺省时 blocked 并点名缺少的输入"
53
+ },
54
+ "benchmark_price_column": {
55
+ "type": "string",
56
+ "maxLength": 64,
57
+ "description": "基准价格列名;省略优先 adj_close 再 close / close_price / price / nav"
58
+ },
59
+ "benchmark_time_column": {
60
+ "type": "string",
61
+ "maxLength": 64,
62
+ "description": "基准 Dataset 的时间列名;省略自动识别"
63
+ },
64
+ "calendar_dataset_id": {
65
+ "type": "string",
66
+ "maxLength": 128,
67
+ "description": "交易日历 Dataset(日期列);省略时以价格序列日期代替并记缺口"
68
+ },
69
+ "event_window_before": {
70
+ "type": "integer",
71
+ "minimum": 0,
72
+ "maximum": 20,
73
+ "description": "事件窗前段交易日数,默认 1:AR 序列覆盖 −before..+after"
74
+ },
75
+ "event_window_after": {
76
+ "type": "integer",
77
+ "minimum": 1,
78
+ "maximum": 20,
79
+ "description": "事件窗后段交易日数,默认 5:CAR = ΣAR(0..+after)"
80
+ },
81
+ "estimation_window": {
82
+ "type": "integer",
83
+ "minimum": 5,
84
+ "maximum": 250,
85
+ "description": "估计窗交易日数,默认 120;只 market_model 用,仍写进事实块"
86
+ },
87
+ "benchmark_model": {
88
+ "type": "string",
89
+ "enum": [
90
+ "market_adjusted",
91
+ "market_model"
92
+ ],
93
+ "description": "预期收益模型:market_adjusted 取基准同日收益;market_model 用估计窗 OLS 拟合 alpha/beta"
94
+ },
95
+ "min_estimation_observations": {
96
+ "type": "integer",
97
+ "minimum": 2,
98
+ "maximum": 250,
99
+ "description": "market_model 最少有效配对观测数,默认 60;不足则排除该事件"
100
+ },
101
+ "market_open": {
102
+ "type": "string",
103
+ "maxLength": 5,
104
+ "description": "交易时段起点 HH:MM,默认 09:30;早于它的发布时间算盘前"
105
+ },
106
+ "market_close": {
107
+ "type": "string",
108
+ "maxLength": 5,
109
+ "description": "交易时段终点 HH:MM,默认 15:00;不早于它的发布时间算盘后"
110
+ },
111
+ "evidence_ids": {
112
+ "type": "array",
113
+ "items": {
114
+ "type": "string"
115
+ },
116
+ "maxItems": 20,
117
+ "description": "指定参与研究的事件证据 source_id;省略表示快照里的全部证据"
118
+ }
119
+ },
120
+ "required": [],
121
+ "additionalProperties": false
122
+ },
123
+ "output_schema": {
124
+ "type": "object",
125
+ "properties": {
126
+ "status": {
127
+ "type": "string",
128
+ "enum": [
129
+ "completed",
130
+ "partial",
131
+ "blocked",
132
+ "failed"
133
+ ]
134
+ },
135
+ "summary": {
136
+ "type": "string"
137
+ },
138
+ "metrics": {
139
+ "type": "object"
140
+ },
141
+ "claims": {
142
+ "type": "array"
143
+ },
144
+ "assumptions": {
145
+ "type": "array"
146
+ },
147
+ "methodology_log": {
148
+ "type": "array"
149
+ },
150
+ "sensitivity": {
151
+ "type": "object"
152
+ },
153
+ "limitations": {
154
+ "type": "array"
155
+ },
156
+ "data_gaps": {
157
+ "type": "array"
158
+ },
159
+ "outputs": {
160
+ "type": "array"
161
+ },
162
+ "event_study": {
163
+ "type": "object"
164
+ }
165
+ },
166
+ "required": [
167
+ "status",
168
+ "summary",
169
+ "metrics",
170
+ "claims",
171
+ "assumptions",
172
+ "methodology_log",
173
+ "sensitivity",
174
+ "limitations",
175
+ "data_gaps",
176
+ "outputs",
177
+ "event_study"
178
+ ],
179
+ "additionalProperties": false
180
+ },
181
+ "assumptions": [
182
+ "事件时间取自证据条目的 published_at:盘前与盘中按当日对齐,盘后顺延到下一交易日,只有日期时按严格晚于该日期的第一个交易日对齐(保守)",
183
+ "日收益只在相邻交易日且有相邻 bar 时计算:停牌、缺 bar 或坏行处不拼接收益,事件窗需要该日收益时该事件排除",
184
+ "market_adjusted 用基准同日收益作预期收益(不拟合 beta);market_model 用事件前估计窗的 OLS 拟合 alpha/beta,估计窗与事件窗不重叠",
185
+ "CAR 为事件日及之后 event_window_after 个交易日异常收益之和;pre_event_car 为事件日之前 event_window_before 个交易日异常收益之和;数字按 6 位小数舍入",
186
+ "没有交易日历 Dataset 时用价格序列日期代替交易日并记缺口:无法区分停牌与节假日",
187
+ "基准由调用方指定(benchmark_dataset_id):缺基准时模块不虚构基准,直接 blocked 并点名缺少的输入",
188
+ "结果只描述历史价格相对基准的表现;统计关联不等于因果影响,也不构成评级或收益预测"
189
+ ],
190
+ "applicability": [
191
+ "需要至少一条带 published_at 的证据条目作为事件来源;事件时间须能解析成日期或日期时间",
192
+ "需要标的行情 Dataset(时间列 + 价格列)与基准行情 Dataset(benchmark_dataset_id);日频及更低频价格序列均可",
193
+ "适用于公告/财报/政策等有明确发布时间的单标的日频事件研究:盘前、盘中、盘后与只有日期的发布时间按固定规则对齐",
194
+ "支持 market_adjusted 与 market_model 两种预期收益模型;market_model 需要事件前有足够估计窗(默认 120 个交易日、最少 60 个有效配对)",
195
+ "不适用于分钟级事件反应、多标的组合事件、事件日密集重叠的短期事件研究,也不用于证明因果关系"
196
+ ],
197
+ "limits": {
198
+ "timeout_ms": 30000,
199
+ "max_input_rows": 200000,
200
+ "max_output_bytes": 1048576,
201
+ "max_log_bytes": 65536
202
+ },
203
+ "provenance": {
204
+ "source_type": "original",
205
+ "license": "MIT"
206
+ },
207
+ "display_name": "事件研究",
208
+ "temporal_aware": true,
209
+ "limitations": [
210
+ "日频 bar 无法区分盘中路径:盘中事件只能用收盘收益近似,无法估计事件时点前后的分钟级反应",
211
+ "只支持单标的、单窗口、单基准模型:没有多窗口/多基准/多因子对照,也没有做多重检验校正",
212
+ "事件样本少时统计量不稳定:1 个事件只有描述性意义,事件日聚集时 CAR 之间不独立",
213
+ "估计窗、事件窗与基准的选择会影响结果:模块按调用方参数计算,不做参数寻优,也不宣称窗口最优",
214
+ "停牌与缺 bar 会让收益无法对齐:这类事件会被排除,样本可能因此向数据完整的事件倾斜",
215
+ "未建模交易成本、涨跌停与流动性约束:异常收益是价格层面的统计,不等于可实现的策略收益"
216
+ ]
217
+ }