@weaxs/dsh-stock-analysis 0.2.9 → 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 +16 -3
- package/dist/client.js +88 -0
- package/dist/index.js +860 -126
- 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/scripts/profile-offline.py +127 -0
- package/scripts/profile-workflows.py +87 -0
- package/skills/growth-quality/SKILL.md +2 -0
- package/skills/stock-analysis/SKILL.md +14 -3
- package/skills/stock-analysis/references/stateless-analysis.md +16 -2
- package/skills/stock-screener/SKILL.md +4 -0
- package/skills/strategy-backtest/SKILL.md +8 -3
- package/tools/_cache.py +93 -21
- package/tools/_subproc.py +43 -8
- package/tools/alert_rules.py +63 -14
- package/tools/anomaly_detect.py +11 -6
- package/tools/backtest.py +225 -70
- package/tools/capabilities.py +1 -0
- package/tools/gather.py +63 -8
- package/tools/market_regime.py +26 -15
- package/tools/market_review.py +2 -2
- package/tools/name_resolver.py +16 -14
- package/tools/position_context.py +5 -2
- package/tools/requirements.txt +4 -4
- package/tools/risk_screening.py +40 -15
- package/tools/screener.py +44 -18
- package/tools/search_intel.py +95 -33
- package/tools/sec_holders.py +27 -25
- package/tools/signal_tracker.py +106 -54
- package/tools/stateless_analysis.py +600 -33
- package/tools/stock_data.py +366 -50
- package/tools/technical.py +42 -40
- package/tools/tiaa_disclosures.py +263 -0
- package/tools/trading_calendar.py +26 -21
- package/tools/value_data.py +6 -2
- package/tools/watchlist.py +24 -15
- package/tools/watchlist_context.py +63 -49
|
@@ -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
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Offline baseline: python scripts/profile-offline.py > baseline.json.
|
|
3
|
+
|
|
4
|
+
CLI --help includes interpreter/import/argparse cost, never provider latency.
|
|
5
|
+
Synthetic compute timings exclude imports; this is not a production throughput test.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import cProfile
|
|
9
|
+
import json
|
|
10
|
+
import platform
|
|
11
|
+
import pstats
|
|
12
|
+
import statistics
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
import tempfile
|
|
16
|
+
import time
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
20
|
+
sys.path.insert(0, str(ROOT / "tools"))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def measure(operation, repeats=5):
|
|
24
|
+
samples = []
|
|
25
|
+
for _ in range(repeats):
|
|
26
|
+
start = time.perf_counter()
|
|
27
|
+
operation()
|
|
28
|
+
samples.append(round((time.perf_counter() - start) * 1000, 3))
|
|
29
|
+
return {"median_ms": statistics.median(samples), "samples_ms": samples}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def main():
|
|
33
|
+
cli = {}
|
|
34
|
+
for path in sorted((ROOT / "tools").glob("*.py")):
|
|
35
|
+
if '__name__ == "__main__"' not in path.read_text():
|
|
36
|
+
continue
|
|
37
|
+
|
|
38
|
+
def help_call(path=path):
|
|
39
|
+
subprocess.run(
|
|
40
|
+
[sys.executable, str(path), "--help"],
|
|
41
|
+
stdout=subprocess.DEVNULL,
|
|
42
|
+
stderr=subprocess.PIPE,
|
|
43
|
+
timeout=15,
|
|
44
|
+
check=True,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
cli[path.name] = measure(help_call, 3)
|
|
48
|
+
|
|
49
|
+
import _cache
|
|
50
|
+
import numpy as np
|
|
51
|
+
import pandas as pd
|
|
52
|
+
from backtest import load_strategy, simulate
|
|
53
|
+
from stateless_analysis import portfolio
|
|
54
|
+
from technical import analyze_records
|
|
55
|
+
|
|
56
|
+
def bars(count):
|
|
57
|
+
rng = np.random.default_rng(68)
|
|
58
|
+
close = 100 * np.exp(np.cumsum(rng.normal(0.0002, 0.01, count)))
|
|
59
|
+
return pd.DataFrame(
|
|
60
|
+
{
|
|
61
|
+
"date": pd.bdate_range("2000-01-03", periods=count).strftime("%Y-%m-%d"),
|
|
62
|
+
"open": close,
|
|
63
|
+
"close": close,
|
|
64
|
+
"high": close * 1.01,
|
|
65
|
+
"low": close * 0.99,
|
|
66
|
+
"volume": rng.integers(100000, 1000000, count),
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
compute = {}
|
|
71
|
+
strategy = load_strategy(str(ROOT / "strategies/examples/ma_crossover.yaml"))
|
|
72
|
+
for count in (120, 2500):
|
|
73
|
+
frame = bars(count)
|
|
74
|
+
records = frame.to_dict("records")
|
|
75
|
+
assert "error" not in analyze_records("TEST", records)
|
|
76
|
+
compute[f"technical_{count}"] = measure(lambda records=records: analyze_records("TEST", records))
|
|
77
|
+
compute[f"backtest_{count}"] = measure(lambda frame=frame: simulate(frame, strategy, 100000, "TEST"))
|
|
78
|
+
for count in (10, 50, 100):
|
|
79
|
+
histories = []
|
|
80
|
+
for i in range(count):
|
|
81
|
+
records = bars(250).to_dict("records")
|
|
82
|
+
histories.append({"symbol": f"S{i}", "prices": [{"date": r["date"], "close": r["close"]} for r in records]})
|
|
83
|
+
payload = {
|
|
84
|
+
"base_currency": "USD",
|
|
85
|
+
"cash": 0,
|
|
86
|
+
"positions": [{"symbol": f"S{i}", "quantity": 1, "price": 100, "currency": "USD"} for i in range(count)],
|
|
87
|
+
"histories": histories,
|
|
88
|
+
}
|
|
89
|
+
result = portfolio(payload)
|
|
90
|
+
assert len(result["correlations"]) == count * (count - 1) // 2
|
|
91
|
+
compute[f"portfolio_{count}_assets_250_dates"] = measure(lambda payload=payload: portfolio(payload), 3)
|
|
92
|
+
profiler = cProfile.Profile()
|
|
93
|
+
profiler.runcall(simulate, frame, strategy, 100000, "TEST")
|
|
94
|
+
stats = pstats.Stats(profiler)
|
|
95
|
+
hotspots = [
|
|
96
|
+
{"function": f"{Path(file).name}:{line}:{name}", "calls": values[1], "cumulative_s": round(values[3], 4)}
|
|
97
|
+
for (file, line, name), values in sorted(stats.stats.items(), key=lambda item: item[1][3], reverse=True)[:12]
|
|
98
|
+
]
|
|
99
|
+
original_dir = _cache.CACHE_DIR
|
|
100
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
101
|
+
try:
|
|
102
|
+
_cache.CACHE_DIR = Path(directory)
|
|
103
|
+
payload = [{"symbol": str(i), "value": i} for i in range(10000)]
|
|
104
|
+
_cache.cached("profile", 60, lambda: payload)
|
|
105
|
+
|
|
106
|
+
def unexpected_fetch():
|
|
107
|
+
raise AssertionError("warm cache missed")
|
|
108
|
+
|
|
109
|
+
compute["cache_read_10000_rows"] = measure(lambda: _cache.cached("profile", 60, unexpected_fetch))
|
|
110
|
+
finally:
|
|
111
|
+
_cache.CACHE_DIR = original_dir
|
|
112
|
+
print(
|
|
113
|
+
json.dumps(
|
|
114
|
+
{
|
|
115
|
+
"python": platform.python_version(),
|
|
116
|
+
"platform": platform.platform(),
|
|
117
|
+
"cli": cli,
|
|
118
|
+
"compute": compute,
|
|
119
|
+
"backtest_hotspots": hotspots,
|
|
120
|
+
},
|
|
121
|
+
indent=2,
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if __name__ == "__main__":
|
|
127
|
+
main()
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Offline workflow baseline with counted, fixed-latency CLI substitutes.
|
|
3
|
+
|
|
4
|
+
Run with the repo venv (pytest/pandas/numpy installed):
|
|
5
|
+
python scripts/profile-workflows.py [checkout-root]
|
|
6
|
+
This measures orchestration only, not provider throughput. Reuses the test OHLCV fixture.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import importlib.util
|
|
10
|
+
import json
|
|
11
|
+
import sys
|
|
12
|
+
import threading
|
|
13
|
+
import time
|
|
14
|
+
from collections import Counter
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
root = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(__file__).resolve().parents[1]
|
|
18
|
+
sys.path.insert(0, str(root / "tools"))
|
|
19
|
+
import anomaly_detect # noqa: E402
|
|
20
|
+
import gather # noqa: E402
|
|
21
|
+
import risk_screening # noqa: E402
|
|
22
|
+
import technical # noqa: E402
|
|
23
|
+
import watchlist_context # noqa: E402
|
|
24
|
+
|
|
25
|
+
spec = importlib.util.spec_from_file_location("perf_fixtures", root / "tests/conftest.py")
|
|
26
|
+
fixtures = importlib.util.module_from_spec(spec)
|
|
27
|
+
spec.loader.exec_module(fixtures)
|
|
28
|
+
bars = fixtures.make_kline_data.__wrapped__()(120, "volatile")
|
|
29
|
+
for row in bars:
|
|
30
|
+
row["date"] = row["date"].strftime("%Y-%m-%d")
|
|
31
|
+
calls = Counter()
|
|
32
|
+
lock = threading.Lock()
|
|
33
|
+
active = peak = 0
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def invoke(script, args, **kwargs):
|
|
37
|
+
global active, peak
|
|
38
|
+
if script == "risk_screening.py" and args[0] == "screen":
|
|
39
|
+
return risk_screening.screen_risk(args[1])
|
|
40
|
+
if script == "technical.py":
|
|
41
|
+
rows = invoke("stock_data.py", ["kline", args[1], "--count", "120"])
|
|
42
|
+
return technical.analyze_records(args[1], rows)
|
|
43
|
+
if script == "anomaly_detect.py":
|
|
44
|
+
return anomaly_detect.detect_anomalies(args[1])
|
|
45
|
+
key = script + ":" + args[0]
|
|
46
|
+
with lock:
|
|
47
|
+
calls[key] += 1
|
|
48
|
+
active += 1
|
|
49
|
+
peak = max(peak, active)
|
|
50
|
+
time.sleep(0.01)
|
|
51
|
+
with lock:
|
|
52
|
+
active -= 1
|
|
53
|
+
if args[0] == "kline":
|
|
54
|
+
n = int(args[args.index("--count") + 1]) if "--count" in args else 120
|
|
55
|
+
return bars[-n:]
|
|
56
|
+
if args[0] == "quote":
|
|
57
|
+
return {"price": 10, "pe": 15, "pb": 2}
|
|
58
|
+
if args[0] == "lockup":
|
|
59
|
+
return {"upcoming_30d": [], "flags": [], "available": True}
|
|
60
|
+
if args[0] == "capital_flow":
|
|
61
|
+
return []
|
|
62
|
+
if script == "market_regime.py":
|
|
63
|
+
return {"market": args[1]}
|
|
64
|
+
return []
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
gather._run = lambda script, args, **kw: json.dumps(invoke(script, args, **kw))
|
|
68
|
+
risk_screening._run_tool = invoke
|
|
69
|
+
anomaly_detect._run_tool = invoke
|
|
70
|
+
anomaly_detect.fetch_kline = lambda symbol, period, count: invoke(
|
|
71
|
+
"stock_data.py", ["kline", symbol, "--count", str(count)]
|
|
72
|
+
)
|
|
73
|
+
watchlist_context._run_json = invoke
|
|
74
|
+
start = time.perf_counter()
|
|
75
|
+
result = watchlist_context.build_context(["600519", "000001", "000002"], workers=3)
|
|
76
|
+
assert result["summary"]["success"] == 3
|
|
77
|
+
print(
|
|
78
|
+
json.dumps(
|
|
79
|
+
{
|
|
80
|
+
"seconds": time.perf_counter() - start,
|
|
81
|
+
"calls": dict(calls),
|
|
82
|
+
"total_calls": sum(calls.values()),
|
|
83
|
+
"peak_leaf_calls": peak,
|
|
84
|
+
"summary": result["summary"],
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
)
|
|
@@ -28,6 +28,8 @@ gather 工具返回:
|
|
|
28
28
|
|
|
29
29
|
需要财务趋势时调用 `get_financials(symbol, annual=true, periods=10)`。港股配置 `LIXINGER_TOKEN` 后优先理杏仁非金融公司财报,按真实 `report_type` 判断年报,保留实际财年末、披露日期、币种;历史 ROE/毛利率/净利率为百分数,顶层 `roe/profit_margin` 延续小数比例。读取 `available_periods/warnings`,缺期不补造。有效 Yahoo 顶层快照与历史行分开读:`currency` 为快照财报币种、`market_cap_currency` 为市值币种,历史币种在 `periods` 每行,`snapshot_source` 标记快照来源;null 不用历史值补成跨期或跨币种数字;顶层 `report_date` 未知时读取 `periods` 的历史日期,不当作当前快照报告期。
|
|
30
30
|
|
|
31
|
+
Yahoo 顶层快照单位以 `snapshot_units` 为准:`roe/profit_margin/dividend_yield=ratio`,`debt_to_equity=percent`,例如 150 表示 150%,不是 150 倍;`pe=trailing`,不与 dynamic PE 直接比较。
|
|
32
|
+
|
|
31
33
|
`financials` 通常只是单期摘要。多期趋势、经营现金流、应收账款或同业估值未返回时,把对应维度标为“数据不足”,不推断趋势、不计分。
|
|
32
34
|
|
|
33
35
|
## 分析框架(4 步法)
|