@weaxs/dsh-stock-analysis 0.2.10 → 0.2.11
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/README.md +14 -3
- package/dist/client.js +88 -0
- package/dist/index.js +625 -110
- package/dist/web/app.js +871 -0
- package/dist/web/index.html +87 -0
- package/dist/web/style.css +292 -0
- package/package.json +13 -3
- package/skills/stock-analysis/SKILL.md +4 -1
- package/tools/alert_rules.py +63 -14
- package/tools/name_resolver.py +16 -14
- package/tools/requirements.txt +2 -2
- package/tools/search_intel.py +2 -2
- package/tools/signal_tracker.py +6 -5
- package/tools/stock_data.py +255 -24
- package/tools/tiaa_disclosures.py +263 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
7
|
+
<meta name="description" content="在 DeepSeek Harness 中查看自选股与六市场指数。">
|
|
8
|
+
<title>股票仪表盘</title>
|
|
9
|
+
<link rel="stylesheet" href="./style.css">
|
|
10
|
+
<script src="./app.js" defer></script>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div class="app">
|
|
14
|
+
<header class="bar">
|
|
15
|
+
<div class="bar-title">
|
|
16
|
+
<h1>自选</h1>
|
|
17
|
+
<span id="watch-count" class="count">0</span>
|
|
18
|
+
</div>
|
|
19
|
+
<p id="status" class="status" role="status" aria-live="polite">正在连接行情服务…</p>
|
|
20
|
+
<div class="bar-actions">
|
|
21
|
+
<button id="refresh" class="btn ghost" type="button" title="立即刷新全部行情">
|
|
22
|
+
<svg class="refresh-icon" viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6v5h-5"/><path d="M18.4 15a7 7 0 1 1-.8-7.8L20 9"/></svg>
|
|
23
|
+
<span>刷新</span>
|
|
24
|
+
</button>
|
|
25
|
+
<button id="add-toggle" class="btn primary" type="button" aria-expanded="false" aria-controls="add-form">
|
|
26
|
+
<svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M10 4v12M4 10h12"/></svg>
|
|
27
|
+
<span>添加</span>
|
|
28
|
+
</button>
|
|
29
|
+
</div>
|
|
30
|
+
</header>
|
|
31
|
+
|
|
32
|
+
<form id="add-form" class="add" hidden>
|
|
33
|
+
<label class="sr-only" for="symbol-input">股票代码,多个用逗号分隔</label>
|
|
34
|
+
<input id="symbol-input" type="text" placeholder="600519, 00700.HK, AAPL, 7203.T" autocomplete="off" spellcheck="false" maxlength="512" required>
|
|
35
|
+
<button class="btn primary" type="submit">加入自选</button>
|
|
36
|
+
<button id="add-cancel" class="btn ghost" type="button">取消</button>
|
|
37
|
+
<p class="add-hint">A 股填 6 位代码;港股 .HK、日股 .T、韩股 .KS/.KQ、台股 .TW,美股直接填代码。最多 30 只。</p>
|
|
38
|
+
<p id="add-message" class="add-message" role="status" aria-live="polite"></p>
|
|
39
|
+
</form>
|
|
40
|
+
|
|
41
|
+
<section id="ribbon-wrap" class="ribbon" aria-label="主要指数">
|
|
42
|
+
<div id="ribbon" class="ribbon-track"></div>
|
|
43
|
+
<button class="ribbon-nav prev" type="button" data-step="-1" aria-label="查看前面的指数" hidden>
|
|
44
|
+
<svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12.5 4.5L7 10l5.5 5.5"/></svg>
|
|
45
|
+
</button>
|
|
46
|
+
<button class="ribbon-nav next" type="button" data-step="1" aria-label="查看更多市场指数" hidden>
|
|
47
|
+
<svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M7.5 4.5L13 10l-5.5 5.5"/></svg>
|
|
48
|
+
</button>
|
|
49
|
+
</section>
|
|
50
|
+
<div id="pulse" class="pulse" aria-label="A 股市场宽度"></div>
|
|
51
|
+
|
|
52
|
+
<section class="watch" aria-labelledby="watch-heading">
|
|
53
|
+
<h2 id="watch-heading" class="sr-only">自选股行情</h2>
|
|
54
|
+
<div id="filters" class="filters" role="toolbar" aria-label="按市场筛选" hidden></div>
|
|
55
|
+
<div id="watch-error" class="notice" role="alert" hidden></div>
|
|
56
|
+
<div class="table-wrap">
|
|
57
|
+
<table class="quotes">
|
|
58
|
+
<thead>
|
|
59
|
+
<tr>
|
|
60
|
+
<th scope="col" class="c-name"><button type="button" data-sort="order">名称</button></th>
|
|
61
|
+
<th scope="col" class="c-num"><button type="button" data-sort="price">最新</button></th>
|
|
62
|
+
<th scope="col" class="c-num"><button type="button" data-sort="change_pct">涨跌幅</button></th>
|
|
63
|
+
<th scope="col" class="c-num c-change"><button type="button" data-sort="change">涨跌额</button></th>
|
|
64
|
+
<th scope="col" class="c-range">今日区间</th>
|
|
65
|
+
<th scope="col" class="c-num c-amount"><button type="button" data-sort="turnover">成交额</button></th>
|
|
66
|
+
<th scope="col" class="c-trend"><button type="button" data-sort="trend">30 日</button></th>
|
|
67
|
+
<th scope="col" class="c-act"><span class="sr-only">操作</span></th>
|
|
68
|
+
</tr>
|
|
69
|
+
</thead>
|
|
70
|
+
<tbody id="rows"></tbody>
|
|
71
|
+
</table>
|
|
72
|
+
</div>
|
|
73
|
+
</section>
|
|
74
|
+
|
|
75
|
+
<section class="market" aria-labelledby="market-heading">
|
|
76
|
+
<div class="market-head">
|
|
77
|
+
<h2 id="market-heading">市场</h2>
|
|
78
|
+
<div id="market-tabs" class="tabs" role="tablist" aria-label="切换市场"></div>
|
|
79
|
+
</div>
|
|
80
|
+
<div id="market-body" class="market-body" role="tabpanel" aria-labelledby="market-heading"></div>
|
|
81
|
+
</section>
|
|
82
|
+
|
|
83
|
+
<footer class="foot">报价可能延迟,悬停名称可查看来源与报价时间。交易时段内有页面打开时约每 30 秒更新一次,后台每 5 分钟预热;30 日走势为最近 30 个有效交易日收盘价。</footer>
|
|
84
|
+
</div>
|
|
85
|
+
<div id="tip" class="tip" role="tooltip" hidden></div>
|
|
86
|
+
</body>
|
|
87
|
+
</html>
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
color-scheme: light;
|
|
3
|
+
--bg: #f6f7f9;
|
|
4
|
+
--surface: #ffffff;
|
|
5
|
+
--surface-subtle: #f1f3f6;
|
|
6
|
+
--text: #1d2129;
|
|
7
|
+
--muted: #646c78;
|
|
8
|
+
--border: #e3e6eb;
|
|
9
|
+
--accent: #3159d9;
|
|
10
|
+
--on-accent: #ffffff;
|
|
11
|
+
--up: #d63340;
|
|
12
|
+
--down: #0a7f4b;
|
|
13
|
+
--up-fill: #d63340;
|
|
14
|
+
--down-fill: #0a7f4b;
|
|
15
|
+
--up-tint: rgba(214, 51, 64, .14);
|
|
16
|
+
--down-tint: rgba(10, 127, 75, .14);
|
|
17
|
+
--warn: #8a5a00;
|
|
18
|
+
--shadow: 0 6px 20px -8px rgba(20, 24, 32, .28);
|
|
19
|
+
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
|
|
20
|
+
font-synthesis: none;
|
|
21
|
+
-webkit-font-smoothing: antialiased;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:root[data-theme="dark"] {
|
|
25
|
+
color-scheme: dark;
|
|
26
|
+
--bg: #111317;
|
|
27
|
+
--surface: #181b20;
|
|
28
|
+
--surface-subtle: #20242a;
|
|
29
|
+
--text: #e9edf2;
|
|
30
|
+
--muted: #9aa3ae;
|
|
31
|
+
--border: #2c3138;
|
|
32
|
+
--accent: #8ea6ff;
|
|
33
|
+
--on-accent: #10173a;
|
|
34
|
+
--up: #ff6b72;
|
|
35
|
+
--down: #3ccf8e;
|
|
36
|
+
--up-fill: #c8323b;
|
|
37
|
+
--down-fill: #0d7a48;
|
|
38
|
+
--up-tint: rgba(255, 107, 114, .16);
|
|
39
|
+
--down-tint: rgba(60, 207, 142, .16);
|
|
40
|
+
--warn: #e8bd6a;
|
|
41
|
+
--shadow: 0 8px 24px -8px rgba(0, 0, 0, .6);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (prefers-color-scheme: dark) {
|
|
45
|
+
:root:not([data-theme="light"]) {
|
|
46
|
+
color-scheme: dark;
|
|
47
|
+
--bg: #111317;
|
|
48
|
+
--surface: #181b20;
|
|
49
|
+
--surface-subtle: #20242a;
|
|
50
|
+
--text: #e9edf2;
|
|
51
|
+
--muted: #9aa3ae;
|
|
52
|
+
--border: #2c3138;
|
|
53
|
+
--accent: #8ea6ff;
|
|
54
|
+
--on-accent: #10173a;
|
|
55
|
+
--up: #ff6b72;
|
|
56
|
+
--down: #3ccf8e;
|
|
57
|
+
--up-fill: #c8323b;
|
|
58
|
+
--down-fill: #0d7a48;
|
|
59
|
+
--up-tint: rgba(255, 107, 114, .16);
|
|
60
|
+
--down-tint: rgba(60, 207, 142, .16);
|
|
61
|
+
--warn: #e8bd6a;
|
|
62
|
+
--shadow: 0 8px 24px -8px rgba(0, 0, 0, .6);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
* { box-sizing: border-box; }
|
|
67
|
+
html { background: var(--bg); scrollbar-color: var(--border) transparent; scrollbar-width: thin; }
|
|
68
|
+
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.45; }
|
|
69
|
+
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--text); }
|
|
70
|
+
::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
71
|
+
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
|
|
72
|
+
::-webkit-scrollbar-track { background: transparent; }
|
|
73
|
+
button, input { font: inherit; color: inherit; }
|
|
74
|
+
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
|
|
75
|
+
button:disabled { cursor: default; opacity: .55; }
|
|
76
|
+
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
|
|
77
|
+
[hidden] { display: none !important; }
|
|
78
|
+
h1, h2, p { margin: 0; }
|
|
79
|
+
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
|
|
80
|
+
.num { font-variant-numeric: tabular-nums; }
|
|
81
|
+
.up { color: var(--up); }
|
|
82
|
+
.down { color: var(--down); }
|
|
83
|
+
.flat { color: var(--muted); }
|
|
84
|
+
|
|
85
|
+
.app { width: min(100%, 1280px); margin: 0 auto; padding: 16px 20px 20px; }
|
|
86
|
+
|
|
87
|
+
/* ---------- top bar ---------- */
|
|
88
|
+
.bar { display: flex; align-items: center; gap: 14px; min-height: 34px; }
|
|
89
|
+
.bar-title { display: flex; align-items: baseline; gap: 8px; }
|
|
90
|
+
h1 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
|
|
91
|
+
.count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
92
|
+
.status { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
93
|
+
.status .live { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 1px; box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); animation: live 2.4s cubic-bezier(.16, 1, .3, 1) infinite; }
|
|
94
|
+
.status .warn { color: var(--warn); }
|
|
95
|
+
@keyframes live { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
|
|
96
|
+
.bar-actions { display: flex; gap: 8px; }
|
|
97
|
+
.btn { height: 30px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border-radius: 7px; border: 1px solid transparent; font-size: 12.5px; font-weight: 600; white-space: nowrap; transition: background-color .16s ease, border-color .16s ease, opacity .16s ease; }
|
|
98
|
+
.btn.primary { background: var(--accent); color: var(--on-accent); }
|
|
99
|
+
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
|
|
100
|
+
.btn.ghost { background: var(--surface); border-color: var(--border); }
|
|
101
|
+
.btn.ghost:hover:not(:disabled) { background: var(--surface-subtle); }
|
|
102
|
+
.btn:active:not(:disabled) { transform: translateY(1px); }
|
|
103
|
+
.busy .refresh-icon { animation: spin .9s linear infinite; }
|
|
104
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
105
|
+
|
|
106
|
+
.add { display: grid; grid-template-columns: minmax(0, 420px) auto auto 1fr; align-items: center; gap: 8px; margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
|
|
107
|
+
.add input { height: 32px; min-width: 0; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-subtle); caret-color: var(--accent); }
|
|
108
|
+
.add input::placeholder { color: var(--muted); opacity: 1; }
|
|
109
|
+
.add input:focus { border-color: var(--accent); outline: none; }
|
|
110
|
+
.add-hint, .add-message { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
|
|
111
|
+
.add-message:empty { display: none; }
|
|
112
|
+
.add-message.error { color: var(--up); }
|
|
113
|
+
|
|
114
|
+
/* ---------- index ribbon ---------- */
|
|
115
|
+
.ribbon { position: relative; margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
|
|
116
|
+
.ribbon.more-right .ribbon-track { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 72px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 72px), transparent); }
|
|
117
|
+
.ribbon.more-left .ribbon-track { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 72px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 72px), transparent); }
|
|
118
|
+
.ribbon.more-left.more-right .ribbon-track { -webkit-mask-image: linear-gradient(to right, transparent, #000 72px, #000 calc(100% - 72px), transparent); mask-image: linear-gradient(to right, transparent, #000 72px, #000 calc(100% - 72px), transparent); }
|
|
119
|
+
.ribbon-nav { position: absolute; top: 50%; width: 28px; height: 28px; margin-top: -14px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text); box-shadow: var(--shadow); transition: background-color .16s ease; }
|
|
120
|
+
.ribbon-nav:hover { background: var(--surface-subtle); }
|
|
121
|
+
.ribbon-nav.prev { left: 8px; }
|
|
122
|
+
.ribbon-nav.next { right: 8px; }
|
|
123
|
+
.ribbon-track { display: flex; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
|
|
124
|
+
.ribbon-track::-webkit-scrollbar { display: none; }
|
|
125
|
+
.rgroup { flex: 0 0 auto; display: flex; flex-direction: column; scroll-snap-align: start; }
|
|
126
|
+
.rgroup + .rgroup { border-left: 1px solid var(--border); }
|
|
127
|
+
.rgroup-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px 0; color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
|
|
128
|
+
.rgroup-head .phase { font-weight: 500; }
|
|
129
|
+
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); flex: none; }
|
|
130
|
+
.dot.on { background: var(--accent); }
|
|
131
|
+
.rgroup-tiles { display: flex; }
|
|
132
|
+
.tile { width: 140px; display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 1px 6px; padding: 4px 12px 9px; border: 0; border-radius: 0; background: transparent; text-align: left; transition: background-color .16s ease; }
|
|
133
|
+
.tile:hover { background: var(--surface-subtle); }
|
|
134
|
+
.tile-name { grid-column: 1 / -1; color: var(--text); font-size: 12px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
135
|
+
.tile-price { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
|
|
136
|
+
.tile-pct { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
137
|
+
.tile .spark { grid-column: 1 / -1; margin-top: 3px; }
|
|
138
|
+
|
|
139
|
+
.pulse { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; min-height: 36px; padding: 8px 2px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
140
|
+
.pulse strong { color: var(--text); font-weight: 600; }
|
|
141
|
+
.pulse .label { color: var(--text); font-weight: 600; }
|
|
142
|
+
.breadth { display: inline-flex; align-items: center; gap: 8px; }
|
|
143
|
+
.breadth-bar { display: flex; width: 180px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-subtle); }
|
|
144
|
+
.breadth-bar span { display: block; height: 100%; }
|
|
145
|
+
.breadth-bar .u { background: var(--up); }
|
|
146
|
+
.breadth-bar .f { background: var(--border); }
|
|
147
|
+
.breadth-bar .d { background: var(--down); }
|
|
148
|
+
|
|
149
|
+
/* ---------- watchlist table ---------- */
|
|
150
|
+
.watch { margin-top: 2px; }
|
|
151
|
+
.filters { display: flex; gap: 6px; margin-bottom: 8px; overflow-x: auto; }
|
|
152
|
+
.chip { height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 550; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
|
153
|
+
.chip:hover { color: var(--text); }
|
|
154
|
+
.chip[aria-pressed="true"] { border-color: transparent; background: var(--text); color: var(--bg); }
|
|
155
|
+
.notice { margin-bottom: 8px; padding: 8px 12px; border-radius: 8px; background: var(--up-tint); color: var(--up); font-size: 12px; }
|
|
156
|
+
.table-wrap { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow-x: auto; }
|
|
157
|
+
table { width: 100%; border-collapse: collapse; }
|
|
158
|
+
.quotes th { padding: 0 12px; height: 34px; color: var(--muted); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
|
|
159
|
+
.quotes th button { padding: 0; border: 0; background: none; color: inherit; font-weight: inherit; }
|
|
160
|
+
.quotes th button:hover { color: var(--text); }
|
|
161
|
+
.quotes th[aria-sort] button { color: var(--text); font-weight: 600; }
|
|
162
|
+
.quotes th[aria-sort="descending"] button::after { content: " ↓"; }
|
|
163
|
+
.quotes th[aria-sort="ascending"] button::after { content: " ↑"; }
|
|
164
|
+
.quotes td { height: 56px; padding: 6px 12px; border-top: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
|
|
165
|
+
.quotes tbody tr:first-child td { border-top: 0; }
|
|
166
|
+
.quotes tbody tr { transition: background-color .16s ease; }
|
|
167
|
+
.quotes tbody tr:hover { background: color-mix(in srgb, var(--surface-subtle) 70%, transparent); }
|
|
168
|
+
.c-num { text-align: right !important; }
|
|
169
|
+
.c-name { width: 230px; min-width: 180px; }
|
|
170
|
+
.quotes th.c-num { width: 100px; }
|
|
171
|
+
.quotes th.c-change { width: 84px; }
|
|
172
|
+
.quotes th.c-amount { width: 96px; }
|
|
173
|
+
.quotes th.c-range { width: 136px; }
|
|
174
|
+
.name { display: block; max-width: 22em; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
|
|
175
|
+
.meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 11px; }
|
|
176
|
+
.code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11px; }
|
|
177
|
+
.tag { padding: 0 4px; border-radius: 3px; background: var(--surface-subtle); font-size: 10.5px; line-height: 16px; }
|
|
178
|
+
.stale { color: var(--warn); }
|
|
179
|
+
.price { font-size: 15px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; border-radius: 5px; }
|
|
180
|
+
.price.flash-up { animation: flash-up 1.4s cubic-bezier(.16, 1, .3, 1); }
|
|
181
|
+
.price.flash-down { animation: flash-down 1.4s cubic-bezier(.16, 1, .3, 1); }
|
|
182
|
+
@keyframes flash-up { from { background: var(--up-tint); box-shadow: 0 0 0 4px var(--up-tint); } to { background: transparent; box-shadow: 0 0 0 4px transparent; } }
|
|
183
|
+
@keyframes flash-down { from { background: var(--down-tint); box-shadow: 0 0 0 4px var(--down-tint); } to { background: transparent; box-shadow: 0 0 0 4px transparent; } }
|
|
184
|
+
.pill { display: inline-block; min-width: 70px; padding: 4px 8px; border-radius: 6px; font-size: 13px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; color: #fff; }
|
|
185
|
+
.pill.up { background: var(--up-fill); color: #fff; }
|
|
186
|
+
.pill.down { background: var(--down-fill); color: #fff; }
|
|
187
|
+
.pill.flat { background: var(--surface-subtle); color: var(--muted); }
|
|
188
|
+
.change, .amount { font-size: 13px; font-variant-numeric: tabular-nums; }
|
|
189
|
+
.amount { color: var(--muted); }
|
|
190
|
+
.range { width: 112px; }
|
|
191
|
+
.range-track { position: relative; height: 4px; border-radius: 2px; background: var(--surface-subtle); }
|
|
192
|
+
.range-prev { position: absolute; top: -3px; width: 1px; height: 10px; background: var(--muted); opacity: .6; }
|
|
193
|
+
.range-mark { position: absolute; top: -4px; width: 3px; height: 12px; margin-left: -1.5px; border-radius: 2px; background: currentColor; }
|
|
194
|
+
.range-label { margin-top: 5px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
|
|
195
|
+
.c-trend { padding-left: 20px !important; }
|
|
196
|
+
.trend-cell { display: flex; align-items: center; gap: 8px; }
|
|
197
|
+
.trend-pct { min-width: 52px; font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
|
|
198
|
+
.c-act { width: 40px; padding-left: 0 !important; }
|
|
199
|
+
.remove { width: 26px; height: 26px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); opacity: 0; transition: opacity .16s ease, background-color .16s ease, color .16s ease; }
|
|
200
|
+
tr:hover .remove, .remove:focus-visible { opacity: 1; }
|
|
201
|
+
.remove:hover { background: var(--up-tint); color: var(--up); }
|
|
202
|
+
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
|
|
203
|
+
.empty strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 14px; }
|
|
204
|
+
.empty .btn { margin-top: 12px; }
|
|
205
|
+
|
|
206
|
+
/* ---------- sparkline ---------- */
|
|
207
|
+
.spark { display: block; overflow: visible; touch-action: none; }
|
|
208
|
+
.spark .line { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
|
|
209
|
+
.spark .area { fill: currentColor; opacity: .09; }
|
|
210
|
+
.spark .base { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: .55; }
|
|
211
|
+
.spark .end { fill: currentColor; }
|
|
212
|
+
.spark .guide { stroke: var(--muted); stroke-width: 1; opacity: .7; }
|
|
213
|
+
.spark .hover-dot { fill: var(--surface); stroke: currentColor; stroke-width: 1.5; }
|
|
214
|
+
.sk { display: inline-block; height: 10px; border-radius: 4px; background: var(--surface-subtle); animation: pulse 1.6s ease-in-out infinite; vertical-align: middle; }
|
|
215
|
+
@keyframes pulse { 50% { opacity: .45; } }
|
|
216
|
+
|
|
217
|
+
/* ---------- market detail ---------- */
|
|
218
|
+
.market { margin-top: 22px; }
|
|
219
|
+
.market-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
|
|
220
|
+
.market-head h2 { font-size: 14px; font-weight: 650; white-space: nowrap; }
|
|
221
|
+
.tabs { display: flex; min-width: 0; gap: 2px; padding: 2px; border-radius: 8px; background: var(--surface-subtle); overflow-x: auto; }
|
|
222
|
+
.tab { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 550; white-space: nowrap; }
|
|
223
|
+
.tab:hover { color: var(--text); }
|
|
224
|
+
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
|
|
225
|
+
.market-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; }
|
|
226
|
+
.panel { min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
|
|
227
|
+
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 14px 4px; }
|
|
228
|
+
.panel-head h3 { margin: 0; font-size: 13px; font-weight: 650; }
|
|
229
|
+
.panel-head span { color: var(--muted); font-size: 11.5px; }
|
|
230
|
+
.idx td { height: 44px; padding: 4px 14px; border-top: 1px solid var(--border); white-space: nowrap; }
|
|
231
|
+
.idx tr:first-child td { border-top: 0; }
|
|
232
|
+
.idx .iname { font-weight: 600; }
|
|
233
|
+
.idx .icode { display: block; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 10.5px; }
|
|
234
|
+
.idx .iprice { text-align: right; font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
|
|
235
|
+
.idx .ipct { text-align: right; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
236
|
+
.idx .ispark { width: 110px; }
|
|
237
|
+
.side { display: grid; gap: 14px; }
|
|
238
|
+
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 8px 14px 14px; border-radius: 8px; overflow: hidden; background: var(--border); }
|
|
239
|
+
.stats div { padding: 8px 10px; background: var(--surface); }
|
|
240
|
+
.stats dt { color: var(--muted); font-size: 11px; }
|
|
241
|
+
.stats dd { margin: 2px 0 0; font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
|
|
242
|
+
.breadth-wide { padding: 6px 14px 0; }
|
|
243
|
+
.breadth-wide .breadth-bar { width: 100%; height: 8px; border-radius: 4px; }
|
|
244
|
+
.breadth-legend { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
245
|
+
.sectors { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; padding: 4px 14px 12px; }
|
|
246
|
+
.sectors h4 { margin: 6px 0 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
|
|
247
|
+
.sector { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 8px; padding: 5px 0; }
|
|
248
|
+
.sector-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
249
|
+
.sector-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
250
|
+
.sector-bar { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: var(--surface-subtle); overflow: hidden; }
|
|
251
|
+
.sector-bar span { display: block; height: 100%; background: currentColor; opacity: .75; }
|
|
252
|
+
.sector-lead { grid-column: 1 / -1; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
253
|
+
.session { padding: 6px 14px 14px; color: var(--muted); font-size: 12px; }
|
|
254
|
+
.session dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 6px 0 10px; }
|
|
255
|
+
.session dt { color: var(--muted); }
|
|
256
|
+
.session dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }
|
|
257
|
+
.panel-note { padding: 14px; color: var(--muted); font-size: 12px; }
|
|
258
|
+
.foot { margin-top: 16px; color: var(--muted); font-size: 11px; max-width: 110ch; }
|
|
259
|
+
|
|
260
|
+
.tip { position: fixed; z-index: 10; padding: 6px 9px; border-radius: 7px; background: var(--text); color: var(--bg); font-size: 11.5px; line-height: 1.45; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
|
|
261
|
+
.tip b { font-weight: 650; }
|
|
262
|
+
|
|
263
|
+
@media (max-width: 980px) {
|
|
264
|
+
.c-change, .c-amount { display: none; }
|
|
265
|
+
.market-body { grid-template-columns: minmax(0, 1fr); }
|
|
266
|
+
}
|
|
267
|
+
@media (max-width: 720px) {
|
|
268
|
+
.app { padding: 12px; }
|
|
269
|
+
.bar { flex-wrap: wrap; }
|
|
270
|
+
.status { order: 3; flex-basis: 100%; }
|
|
271
|
+
.bar-actions { margin-left: auto; }
|
|
272
|
+
.bar-actions .btn span { display: none; }
|
|
273
|
+
.c-range { display: none; }
|
|
274
|
+
.c-trend { width: 120px; }
|
|
275
|
+
.trend-pct { display: none; }
|
|
276
|
+
.c-name { width: auto; }
|
|
277
|
+
.name { max-width: 9em; }
|
|
278
|
+
.pill { min-width: 62px; }
|
|
279
|
+
.remove { opacity: 1; }
|
|
280
|
+
.add { grid-template-columns: 1fr auto; }
|
|
281
|
+
.add #add-cancel { display: none; }
|
|
282
|
+
.breadth-bar { width: 120px; }
|
|
283
|
+
.sectors { grid-template-columns: 1fr; }
|
|
284
|
+
}
|
|
285
|
+
@media (max-width: 520px) {
|
|
286
|
+
.c-trend, .idx .ispark { display: none; }
|
|
287
|
+
.idx td { padding: 4px 10px; }
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@media (prefers-reduced-motion: reduce) {
|
|
291
|
+
*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
|
|
292
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weaxs/dsh-stock-analysis",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "DeepSeek Harness (dsh) plugin for stock analysis, screening, and strategy backtesting across A/HK/US/JP/KR/TW markets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./dist/index.js",
|
|
9
|
+
"./client": "./dist/client.js",
|
|
9
10
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
10
11
|
"./research-role": "./dist/research-role.js",
|
|
11
12
|
"./research.patch.yml": "./research.patch.yml",
|
|
@@ -14,6 +15,15 @@
|
|
|
14
15
|
"dsh": {
|
|
15
16
|
"bundle": {
|
|
16
17
|
"patch": "./cordis.patch.yml"
|
|
18
|
+
},
|
|
19
|
+
"client": {
|
|
20
|
+
"platform": "web",
|
|
21
|
+
"immediately": true,
|
|
22
|
+
"inject": [
|
|
23
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
24
|
+
"@deepseek-ai/dsh-client-ui-sidebar",
|
|
25
|
+
"@deepseek-ai/dsh-client-ui-theme"
|
|
26
|
+
]
|
|
17
27
|
}
|
|
18
28
|
},
|
|
19
29
|
"scripts": {
|
|
@@ -51,7 +61,7 @@
|
|
|
51
61
|
"license": "MIT",
|
|
52
62
|
"peerDependencies": {
|
|
53
63
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
54
|
-
"@deepseek-ai/dsh-skill": "^0.0.1-rc.1 || ^0.1.7-rc.1 || ^0.2.0-rc.2 || ^0.2.1-rc.2",
|
|
55
|
-
"@deepseek-ai/dsh-tools": "^0.0.1-rc.1 || ^0.1.7-rc.1 || ^0.2.0-rc.2 || ^0.2.1-rc.2"
|
|
64
|
+
"@deepseek-ai/dsh-skill": "^0.0.1-rc.1 || ^0.1.7-rc.1 || ^0.2.0-rc.2 || ^0.2.1-rc.2 || ^0.2.2-rc.1",
|
|
65
|
+
"@deepseek-ai/dsh-tools": "^0.0.1-rc.1 || ^0.1.7-rc.1 || ^0.2.0-rc.2 || ^0.2.1-rc.2 || ^0.2.2-rc.1"
|
|
56
66
|
}
|
|
57
67
|
}
|
|
@@ -29,6 +29,7 @@ description: 综合股票分析:联合技术、基本面、资金、消息和
|
|
|
29
29
|
|------|---------|
|
|
30
30
|
| 个股买卖时机 | `get_technical_analysis` → `get_market_capabilities` → 当前市场支持的资金/风险工具 → `detect_market_regime`。A股可加 `get_capital_flow`(summary) 和 `screen_risk`;其他市场不得用缺失的资金或风险数据。veto_buy=true 则不入场;大盘下跌时个股看多信号降级为轻仓试错或等待;HOLD/WAIT 给出可观察触发条件 |
|
|
31
31
|
| 个股状态速览 | `get_quote` + `get_technical_analysis` |
|
|
32
|
+
| 场外公募基金净值 | `get_fund_quote`(6 位基金代码,如 018147) |
|
|
32
33
|
| 异动归因 | `detect_anomaly` + `get_news` |
|
|
33
34
|
| 大盘择时 | `detect_market_regime`;A 股可补充 `get_market_stats` |
|
|
34
35
|
|
|
@@ -46,6 +47,8 @@ python3 scripts/gather.py <symbol>
|
|
|
46
47
|
|
|
47
48
|
解读实时行情前先调 `get_trading_phase` 确认该市场当前盘中阶段(盘前/早盘/午间休市/午盘/交易中/盘后/休市),避免把休市时的静态快照当作盘中信号解读。
|
|
48
49
|
|
|
50
|
+
场外公募基金净值查询使用 `get_fund_quote(symbol="018147")`,不要当作股票实时报价。`nav` 是 `nav_date` 对应的已披露日终净值而非实时价;`accumulated_nav` 为累计净值,`change_pct` 为日涨跌幅。`estimated_nav` 是估算值且可能为 `null`,缺失时不得编造或当作实时成交价;QDII 净值可能滞后 1-2 交易日,须披露实际 `nav_date`。`TIAAxxxxxx` 使用 `get_quote` 获取投顾组合识别与无统一净值提示,不推算组合净值。`advisor_code/advisor_org` 按 TIAA 前三位机构段与资本市场标准网基金投顾业务编码表进行 best-effort 映射,来源和抓取时间随结果返回;投顾机构不等于主理人,查不到时保留 null。`official_disclosures` 目前仅对确认属于有知有行的 `TIAA001001/TIAA001002/TIAA001004` 提供,其他 TIAA 组合不得套用该站文章;有搜索配置时可返回 `disclosure_status=search_partial` 和 `public_search_results`,其中每项均为 `verification=unverified_search_result`,只能作为待核实线索,否则为 `unsupported_provider`。官方披露含发布日期、摘要、正文摘录和 URL;`disclosures_partial=true` 时必须视为不完整历史披露,不能当作实时业绩或完整成分基金清单。示例账户收益不等于用户收益,引用基金代码时必须保留对应文章日期和链接。
|
|
51
|
+
|
|
49
52
|
港股 `get_quote` 自动按 yfinance → 腾讯 → finnhub → longbridge 容灾,腾讯无需 API key,使用 `r_hk` 实时报价通道(`hk` 通道延迟约 15 分钟)。腾讯港股成交量为股,成交额及市值为港元;PB、换手率、量比为 null 时按缺失处理。该备用源只覆盖报价,K 线仍走原链路。
|
|
50
53
|
|
|
51
54
|
### 第二步:综合研判
|
|
@@ -88,7 +91,7 @@ python3 scripts/gather.py <symbol>
|
|
|
88
91
|
- 行情:`get_quote.price`、`get_quote.data_as_of`。
|
|
89
92
|
- 财务:`get_financials.report_date`、`get_financials.roe`,以及历史 `periods` 中实际返回的 `report_date`、`roe`,路径含数字下标。
|
|
90
93
|
- 回测:`run_backtest.metrics.total_trades`、`run_backtest.metrics.win_rate`。
|
|
91
|
-
每项保留原始 value,并按第 2 项填写 source/as_of;正文中的数字及其他证据的 as_of
|
|
94
|
+
每项保留原始 value,并按第 2 项填写 source/as_of;正文中的数字及其他证据的 as_of 元数据不替代独立引用。漏项先补齐再提交。报价过期时保留原始价格与时间作为历史证据;结论与风险说明均以报价的 data_as_of 为行情覆盖截止点,明确该时点至分析日及之后的行情变动未知,等待新报价后再制定当前数值交易计划。
|
|
92
95
|
4. 调用 `render_stock_report`:快速问答用 `brief`,完整研判用 `full`。
|
|
93
96
|
5. 输出渲染后的 Markdown;只在用户要求机器可读数据时附加结构化 JSON。
|
|
94
97
|
|
package/tools/alert_rules.py
CHANGED
|
@@ -140,28 +140,77 @@ def check_rules(symbol: str, rules: list[dict]) -> dict:
|
|
|
140
140
|
needs_anom = any(r.get("type") == "anomaly" for r in rules)
|
|
141
141
|
needs_risk = any(r.get("type") in ("risk_veto", "risk_level_at_least") for r in rules)
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
jobs
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
needs_quote = (
|
|
144
|
+
needs_anom
|
|
145
|
+
or needs_risk
|
|
146
|
+
or any(r.get("type") in ("price_below", "price_above", "change_pct_above", "change_pct_below") for r in rules)
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
# Share one market snapshot while retaining 60-bar alerts and 120-bar risk analysis.
|
|
150
|
+
with ThreadPoolExecutor(max_workers=4) as pool:
|
|
151
|
+
jobs = {}
|
|
152
|
+
if needs_quote:
|
|
153
|
+
quote_job = pool.submit(_run_json, "stock_data.py", ["quote", symbol])
|
|
154
|
+
jobs["quote"] = quote_job
|
|
155
|
+
if needs_tech or needs_anom or needs_risk:
|
|
156
|
+
from technical import analyze_records
|
|
157
|
+
|
|
158
|
+
kline_job = pool.submit(
|
|
159
|
+
_run_json,
|
|
160
|
+
"stock_data.py",
|
|
161
|
+
["kline", symbol, "--period", "daily", "--count", "120" if needs_risk else "60"],
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
def analyze(count):
|
|
165
|
+
records = kline_job.result()
|
|
166
|
+
try:
|
|
167
|
+
return analyze_records(symbol, records[-count:] if isinstance(records, list) else records)
|
|
168
|
+
except Exception as exc:
|
|
169
|
+
return {"error": f"Technical analysis failed ({type(exc).__name__})"}
|
|
170
|
+
|
|
171
|
+
if needs_risk:
|
|
172
|
+
from risk_screening import screen_risk
|
|
173
|
+
|
|
174
|
+
technical_job = pool.submit(analyze, 120)
|
|
175
|
+
|
|
176
|
+
def collect_risk():
|
|
177
|
+
try:
|
|
178
|
+
return screen_risk(
|
|
179
|
+
symbol, inputs={"quote": quote_job, "technical": technical_job}, run=_run_json
|
|
180
|
+
)
|
|
181
|
+
except Exception as exc:
|
|
182
|
+
return {"error": f"Risk analysis failed ({type(exc).__name__})"}
|
|
183
|
+
|
|
184
|
+
jobs["risk"] = pool.submit(collect_risk)
|
|
185
|
+
if needs_tech:
|
|
186
|
+
jobs["tech"] = pool.submit(analyze, 60)
|
|
187
|
+
if needs_anom:
|
|
188
|
+
from anomaly_detect import detect_anomalies
|
|
189
|
+
|
|
190
|
+
def anomalies():
|
|
191
|
+
records = kline_job.result()
|
|
192
|
+
try:
|
|
193
|
+
return detect_anomalies(
|
|
194
|
+
symbol,
|
|
195
|
+
records=records[-60:] if isinstance(records, list) else records,
|
|
196
|
+
quote=quote_job.result(),
|
|
197
|
+
run=_run_json,
|
|
198
|
+
)
|
|
199
|
+
except Exception as exc:
|
|
200
|
+
return {"error": f"Anomaly analysis failed ({type(exc).__name__})"}
|
|
201
|
+
|
|
202
|
+
jobs["anom"] = pool.submit(anomalies)
|
|
203
|
+
fetched = {key: future.result() for key, future in jobs.items()}
|
|
155
204
|
fetched = {
|
|
156
205
|
key: value if isinstance(value, dict) and "error" not in value else None for key, value in fetched.items()
|
|
157
206
|
}
|
|
158
|
-
quote = fetched
|
|
207
|
+
quote = fetched.get("quote") or {}
|
|
159
208
|
tech = fetched.get("tech")
|
|
160
209
|
anom = fetched.get("anom")
|
|
161
210
|
risk = fetched.get("risk")
|
|
162
211
|
|
|
163
212
|
warnings = []
|
|
164
|
-
if not quote or quote.get("price") is None:
|
|
213
|
+
if needs_quote and (not quote or quote.get("price") is None):
|
|
165
214
|
warnings.append("quote fetch failed or missing price — price/change rules cannot fire")
|
|
166
215
|
if needs_tech and not tech:
|
|
167
216
|
warnings.append("technical analysis fetch failed — volume_ratio rules cannot fire")
|
package/tools/name_resolver.py
CHANGED
|
@@ -9,30 +9,32 @@ from pathlib import Path
|
|
|
9
9
|
|
|
10
10
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
11
11
|
|
|
12
|
+
from _cache import DAY, cached # noqa: E402
|
|
12
13
|
from _subproc import utf8_stdio # noqa: E402
|
|
13
14
|
from stock_data import _akshare_retry # noqa: E402
|
|
14
15
|
|
|
15
|
-
_STOCK_MAP_CACHE = None
|
|
16
|
-
|
|
17
16
|
|
|
18
17
|
def _load_stock_map() -> list[dict]:
|
|
19
|
-
|
|
20
|
-
if _STOCK_MAP_CACHE is not None:
|
|
21
|
-
return _STOCK_MAP_CACHE
|
|
22
|
-
try:
|
|
18
|
+
def fetch():
|
|
23
19
|
import akshare as ak
|
|
24
20
|
|
|
25
21
|
df = _akshare_retry(ak.stock_zh_a_spot_em)
|
|
26
22
|
records = []
|
|
27
|
-
for
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
for row in df.to_dict("records"):
|
|
24
|
+
code, name = str(row["代码"]), row["名称"]
|
|
25
|
+
if (
|
|
26
|
+
len(code) != 6
|
|
27
|
+
or not code.isascii()
|
|
28
|
+
or not code.isdigit()
|
|
29
|
+
or not isinstance(name, str)
|
|
30
|
+
or not name.strip()
|
|
31
|
+
):
|
|
32
|
+
raise ValueError("Stock name map contains invalid codes or names")
|
|
33
|
+
records.append({"code": code, "name": name})
|
|
35
34
|
return records
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
return cached("stock-name-map:v1", DAY, fetch)
|
|
36
38
|
except Exception as e:
|
|
37
39
|
raise RuntimeError(f"Failed to load stock list: {e}") from e
|
|
38
40
|
|
package/tools/requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
akshare>=1.
|
|
1
|
+
akshare>=1.20.24; python_version >= "3.11"
|
|
2
2
|
akshare>=1.14.0; python_version < "3.11"
|
|
3
3
|
yfinance>=0.2.36
|
|
4
4
|
pandas>=2.0.0
|
|
@@ -7,7 +7,7 @@ pyyaml>=6.0
|
|
|
7
7
|
pypinyin>=0.50.0
|
|
8
8
|
requests>=2.33.0
|
|
9
9
|
exchange-calendars>=4.5.0
|
|
10
|
-
newspaper4k>=0.9.
|
|
10
|
+
newspaper4k>=0.9.6.1
|
|
11
11
|
efinance>=0.5.0
|
|
12
12
|
baostock>=0.8.8
|
|
13
13
|
pytdx>=1.72
|
package/tools/search_intel.py
CHANGED
|
@@ -228,13 +228,13 @@ def _searxng_search(query: str, max_results: int = 5) -> list[dict]:
|
|
|
228
228
|
return []
|
|
229
229
|
|
|
230
230
|
|
|
231
|
-
def search_news(query: str, max_results: int = 10) -> dict:
|
|
231
|
+
def search_news(query: str, max_results: int = 10, budget_seconds: int = 45) -> dict:
|
|
232
232
|
results = []
|
|
233
233
|
engines_tried = []
|
|
234
234
|
engines_available = []
|
|
235
235
|
engines_errors = {}
|
|
236
236
|
|
|
237
|
-
with _search_budget(
|
|
237
|
+
with _search_budget(budget_seconds) as state:
|
|
238
238
|
for name, fn in [
|
|
239
239
|
("tavily", _tavily_search),
|
|
240
240
|
("brave", _brave_search),
|
package/tools/signal_tracker.py
CHANGED
|
@@ -136,11 +136,12 @@ def _save_records(store: Path, records: list):
|
|
|
136
136
|
def _append_record(store: Path, record: dict):
|
|
137
137
|
"""Append one complete JSON line; caller holds the store lock."""
|
|
138
138
|
payload = (json.dumps(record, ensure_ascii=False, default=str, allow_nan=False) + "\n").encode("utf-8")
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
previous = store.read_bytes() if store.exists() else b""
|
|
140
|
+
# Publish only complete records; a failed append must not leave a corrupt tail.
|
|
141
|
+
with atomic_write(store, binary=True) as stream:
|
|
142
|
+
stream.write(previous)
|
|
143
|
+
if previous and not previous.endswith(b"\n"):
|
|
144
|
+
stream.write(b"\n")
|
|
144
145
|
stream.write(payload)
|
|
145
146
|
|
|
146
147
|
|