@dsh-ft/dsh-fft-paper-trading 0.8.0 → 0.9.0
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 +5 -5
- package/README.zh.md +5 -5
- package/lib/client.js +185 -58
- package/lib/data/trading-calendar-port.js +1 -1
- package/lib/data/unavailable-futures-market-data.js +1 -1
- package/lib/index.js +2 -2
- package/lib/service/data-source.js +3 -3
- package/package.json +4 -4
- package/src/client/parts/10-core.js +12 -12
- package/src/client/parts/20-styles.js +48 -0
- package/src/client/parts/30-atoms.js +69 -0
- package/src/client/parts/50-futures.js +18 -13
- package/src/client/parts/60-shell.js +37 -32
- package/src/data/trading-calendar-port.ts +1 -1
- package/src/data/unavailable-futures-market-data.ts +1 -1
- package/src/index.ts +2 -2
- package/src/service/data-source.ts +3 -3
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Open an A-share / commodity futures account in DeepSeek Harness without opening
|
|
|
30
30
|
- **Build positions in bulk by weight**: import a `code,weight` CSV, set a budget, and buy up to 20 symbols in one batch; check shares, fees and remaining cash before submitting the whole batch.
|
|
31
31
|
- **Reviews that reconcile**: equity curve, maximum drawdown, fill statistics, end-of-day report and cash flows, with returns already excluding deposits and withdrawals.
|
|
32
32
|
- **Run several strategies apart, compare them together**: create accounts from the header picker, rename or archive them at will (an archived account stops trading but keeps its ledger, and can be restored), and keep a free-form notes page per account (auto-saved, out of reach of the model); the comparison tab overlays every account’s equity curve normalised to 100, ranked by return, with drawdown and fill counts.
|
|
33
|
-
- **Practice without an API key**: the free tier quotes at the latest daily close; configure an
|
|
33
|
+
- **Practice without an API key**: the free tier quotes at the latest daily close; configure an FtShare key to switch to real-time quotes.
|
|
34
34
|
- **The ledger stays local**: the event ledger is a file on this machine and is restored automatically after a DSH restart; the account is backed up before a reset.
|
|
35
35
|
|
|
36
36
|
## Install
|
|
@@ -39,10 +39,10 @@ Open an A-share / commodity futures account in DeepSeek Harness without opening
|
|
|
39
39
|
dsh plugin add @dsh-ft/dsh-fft-paper-trading
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
Requires DSH `>= 0.2.0-rc.2`. The plugin ships
|
|
42
|
+
Requires DSH `>= 0.2.0-rc.2`. The plugin ships FtShare quotes, the trading calendar and the K-line view, so no separate data plugin is needed.
|
|
43
43
|
|
|
44
44
|
- The full K-line view needs Python 3.10+ on this machine and prepares its runtime over the network on first launch; a failed preparation does not affect ordering, positions or review.
|
|
45
|
-
- **Do not** install it alongside `@dsh-ft/dsh-fft-bundle` or any other entry package that ships the
|
|
45
|
+
- **Do not** install it alongside `@dsh-ft/dsh-fft-bundle` or any other entry package that ships the FtShare data service: the data service row would be duplicated, and the related entries in the plugin manager could no longer be toggled separately.
|
|
46
46
|
|
|
47
47
|
## Get started in three steps
|
|
48
48
|
|
|
@@ -58,12 +58,12 @@ In the conversation, you can simply say:
|
|
|
58
58
|
|
|
59
59
|
## Market data and API keys
|
|
60
60
|
|
|
61
|
-
Market data comes from
|
|
61
|
+
Market data comes from FtShare in two tiers:
|
|
62
62
|
|
|
63
63
|
- **API key configured**: real-time quotes.
|
|
64
64
|
- **No API key**: the free tier. Quotes use the latest close — during the session that is the previous trading day's close — and minute bars and the real-time endpoints are unavailable. The anonymous quota is limited: once it runs out, quotes pause. You can keep trading with a hand-entered reference price, and quotes resume automatically when the quota recovers (about 24 hours, rolling).
|
|
65
65
|
|
|
66
|
-
Configure the API key in DSH under “Settings → Financial Terminal”; request one at [the
|
|
66
|
+
Configure the API key in DSH under “Settings → Financial Terminal”; request one at [the FtShare website](https://ftai.chat/ftshare?utm_source=dsh-fft&utm_medium=AI&utm_campaign=dsh).
|
|
67
67
|
|
|
68
68
|
The panel header shows the data-source state (live / free / unavailable / invalid); when quotes are unavailable it says why and offers “Get API key” or “Retry”. When the trading calendar degrades to “Monday to Friday”, the panel flags it (holidays then count as trading days, and T+1, pending-order expiry and settlement are estimated on business days).
|
|
69
69
|
|
package/README.zh.md
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
- **按权重批量建仓**:导入「代码,权重」CSV,填一个预算,一次买入最多 20 只;先看股数、费用、剩余现金,再整批提交。
|
|
31
31
|
- **复盘能对账**:权益曲线、最大回撤、成交统计、日终报告、资金流水,收益已剔除出入金。
|
|
32
32
|
- **多个策略分开记、放在一起比**:账户下拉里新建账户、随时改名或归档(归档后不再交易,数据保留、可随时恢复);每个账户有自己的「笔记」页,想写多少写多少(自动保存,模型读写不到);「对比」页把各账户净值曲线归一化到 100 叠加,按收益排序,也能看回撤与成交。
|
|
33
|
-
- **没配 API Key 也能练**:免费档按日 K 收盘价报价,配置
|
|
33
|
+
- **没配 API Key 也能练**:免费档按日 K 收盘价报价,配置 FtShare Key 后切换实时行情。
|
|
34
34
|
- **账本在本地**:事件账本落在本机文件,重启 DSH 自动恢复;重置账户前自动备份。
|
|
35
35
|
|
|
36
36
|
## 安装
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
dsh plugin add @dsh-ft/dsh-fft-paper-trading
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
需要 DSH `>= 0.2.0-rc.2`。安装后自带
|
|
42
|
+
需要 DSH `>= 0.2.0-rc.2`。安装后自带 FtShare 行情、交易日历与 K 线视图,不需要再单独安装数据插件。
|
|
43
43
|
|
|
44
44
|
- 完整 K 线视图依赖本机 Python 3.10+,首次启动会联网准备运行环境;准备失败不影响下单、持仓和复盘。
|
|
45
|
-
- **不要**与 `@dsh-ft/dsh-fft-bundle` 或其他自带
|
|
45
|
+
- **不要**与 `@dsh-ft/dsh-fft-bundle` 或其他自带 FtShare 数据服务的入口包同时安装:数据服务行会重复,插件管理器里相关项将无法单独开关。
|
|
46
46
|
|
|
47
47
|
## 上手三步
|
|
48
48
|
|
|
@@ -58,12 +58,12 @@ dsh plugin add @dsh-ft/dsh-fft-paper-trading
|
|
|
58
58
|
|
|
59
59
|
## 行情与 API Key
|
|
60
60
|
|
|
61
|
-
行情来自
|
|
61
|
+
行情来自 FtShare,分两档:
|
|
62
62
|
|
|
63
63
|
- **已配置 API Key**:实时行情。
|
|
64
64
|
- **未配置 API Key**:免费档,报价取最近一个收盘价(盘中等于上一交易日收盘),分钟线与实时接口不可用;匿名额度有限,用尽后行情暂停,可用手填参考价继续交易,额度恢复后自动恢复(滚动约 24 小时)。
|
|
65
65
|
|
|
66
|
-
API Key 在 DSH「设置 → 金融终端」中配置,申请地址:[
|
|
66
|
+
API Key 在 DSH「设置 → 金融终端」中配置,申请地址:[FtShare 官网](https://ftai.chat/ftshare?utm_source=dsh-fft&utm_medium=AI&utm_campaign=dsh)。
|
|
67
67
|
|
|
68
68
|
面板顶栏会显示数据源状态(正常 / 免费 / 无 / 无效);行情不可用时会说明原因并给出「获取 API Key」或「重试」入口。交易日历降级为「周一至周五」时面板会标注(此时节假日会被当作交易日,T+1、挂单过期与结算按工作日估算)。
|
|
69
69
|
|
package/lib/client.js
CHANGED
|
@@ -12,7 +12,7 @@ window.__ModuleLoader__.load({
|
|
|
12
12
|
|
|
13
13
|
const ROUTE = '/api/ft-paper-trading'
|
|
14
14
|
/** Release number stamped into the Feedback link title at build time. */
|
|
15
|
-
const PAPER_VERSION = '0.
|
|
15
|
+
const PAPER_VERSION = '0.9.0'
|
|
16
16
|
/** Public repository; the panel links out and collects nothing itself. */
|
|
17
17
|
const ISSUE_NEW = 'https://github.com/gigaflw/dsh-fft-paper-trading/issues/new'
|
|
18
18
|
/**
|
|
@@ -126,11 +126,11 @@ window.__ModuleLoader__.load({
|
|
|
126
126
|
* tick, so the label has to say which one it is.
|
|
127
127
|
*/
|
|
128
128
|
const quoteSourceText = quote => {
|
|
129
|
-
if (!quote || !quote.source) return '
|
|
129
|
+
if (!quote || !quote.source) return 'FtShare'
|
|
130
130
|
if (quote.source === 'manual') return '参考价'
|
|
131
131
|
// Provenance, not tier: a keyed account can also end up on the daily close.
|
|
132
132
|
if (quote.source === 'daily-bar') return '日K收盘'
|
|
133
|
-
return '
|
|
133
|
+
return 'FtShare 实时'
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
136
|
* Quote line time. Same-day data shows the clock only; a daily-close quote
|
|
@@ -158,13 +158,13 @@ window.__ModuleLoader__.load({
|
|
|
158
158
|
* title carries the consequence (realtime vs daily-close pricing).
|
|
159
159
|
*/
|
|
160
160
|
const DATA_SOURCE_STATE = {
|
|
161
|
-
configured: { text: '数据源正常', title: '
|
|
161
|
+
configured: { text: '数据源正常', title: 'FtShare API Key 已配置,可看实时行情' },
|
|
162
162
|
free: {
|
|
163
|
-
text: '
|
|
164
|
-
title: '未配置
|
|
163
|
+
text: '免费档',
|
|
164
|
+
title: '未配置 FtShare Key:免费档报价取日K收盘,可手填参考价交易',
|
|
165
165
|
},
|
|
166
|
-
none: { text: '无数据源', title: '未安装
|
|
167
|
-
invalid: { text: '数据源无效', title: '
|
|
166
|
+
none: { text: '无数据源', title: '未安装 FtShare 数据服务,行情不可用;可手填参考价交易' },
|
|
167
|
+
invalid: { text: '数据源无效', title: 'FtShare Key 无法使用;请在「设置」中检查,可手填参考价交易' },
|
|
168
168
|
}
|
|
169
169
|
/** Badge suffix per recorded failure, so the header cannot read 正常 while quotes fail. */
|
|
170
170
|
const DATA_PROBLEM_STATE = {
|
|
@@ -200,7 +200,7 @@ window.__ModuleLoader__.load({
|
|
|
200
200
|
return {
|
|
201
201
|
id: 'no-service', tone: 'info',
|
|
202
202
|
title: '行情数据服务未安装',
|
|
203
|
-
detail: '现在只能用参考价交易;安装
|
|
203
|
+
detail: '现在只能用参考价交易;安装 FtShare 数据服务后自动恢复。',
|
|
204
204
|
actions: [],
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -209,7 +209,7 @@ window.__ModuleLoader__.load({
|
|
|
209
209
|
// Quotes still work on the free tier (last daily close), so the banner
|
|
210
210
|
// cannot say 行情未启用; what a key adds is the realtime feed.
|
|
211
211
|
title: '免费档:报价取日K收盘',
|
|
212
|
-
detail:
|
|
212
|
+
detail: `实时行情需 FtShare Key,申请后 → ${KEY_SETTINGS} 填入。`,
|
|
213
213
|
actions: [],
|
|
214
214
|
}
|
|
215
215
|
const problem = status.problem
|
|
@@ -220,7 +220,7 @@ window.__ModuleLoader__.load({
|
|
|
220
220
|
id: 'quota', tone: 'warn',
|
|
221
221
|
// 匿名档是「最近 24 小时 500 次」的滚动额度,不是一个自然日。
|
|
222
222
|
title: '免费额度已用尽',
|
|
223
|
-
detail:
|
|
223
|
+
detail: `点右上「申请 FtShare Key」,申请后到 ${KEY_SETTINGS} 填入;或等约 24 小时额度恢复。`,
|
|
224
224
|
actions: ['retry'],
|
|
225
225
|
}
|
|
226
226
|
case 'plan-denied':
|
|
@@ -241,7 +241,7 @@ window.__ModuleLoader__.load({
|
|
|
241
241
|
? noKeyBanner
|
|
242
242
|
: {
|
|
243
243
|
id: 'invalid-key', tone: 'error',
|
|
244
|
-
title: '
|
|
244
|
+
title: 'FtShare 数据源无法使用',
|
|
245
245
|
detail: `在 ${KEY_SETTINGS} 检查 API Key。`,
|
|
246
246
|
actions: ['retry'],
|
|
247
247
|
}
|
|
@@ -265,7 +265,7 @@ window.__ModuleLoader__.load({
|
|
|
265
265
|
if (status.state === 'invalid') {
|
|
266
266
|
return {
|
|
267
267
|
id: 'invalid-key', tone: 'error',
|
|
268
|
-
title: '
|
|
268
|
+
title: 'FtShare 数据源无法使用',
|
|
269
269
|
detail: `${status.message === undefined || status.message === '' ? 'Key 未通过验证' : status.message}。在 ${KEY_SETTINGS} 检查 API Key。`,
|
|
270
270
|
actions: [],
|
|
271
271
|
}
|
|
@@ -574,6 +574,54 @@ window.__ModuleLoader__.load({
|
|
|
574
574
|
padding-bottom:8px; border-bottom:0.5px solid var(--dsw-alias-border-l2, rgba(45,49,66,.12)); }
|
|
575
575
|
.pt-title { font-size:16px; font-weight:500; letter-spacing:-.01em; margin:0; }
|
|
576
576
|
.pt-sub { color:var(--dsw-alias-label-secondary, #49525f); font-size:12px; margin-top:2px; }
|
|
577
|
+
/* The header's right column stacks the brand entry above the account
|
|
578
|
+
controls. The entry is the only outbound marketing link in the panel,
|
|
579
|
+
so it stays a quiet outline until hovered: its blue-violet gradient and
|
|
580
|
+
the slogan appear only under the pointer (or keyboard focus). */
|
|
581
|
+
.pt-head-right { display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
|
|
582
|
+
/* The data-source state is page context, not an action: it shares the
|
|
583
|
+
top line with the brand entry, so the row below stays pure controls. */
|
|
584
|
+
.pt-topline { display:flex; align-items:center; gap:12px; flex-wrap:wrap; justify-content:flex-end; }
|
|
585
|
+
.pt-brand-pill { position:relative; display:inline-flex; align-items:center; gap:7px; flex:0 0 auto;
|
|
586
|
+
max-width:100%; padding:4px 12px 4px 9px; border-radius:999px; overflow:hidden;
|
|
587
|
+
border:0.5px solid var(--dsw-alias-border-l2, rgba(45,49,66,.18));
|
|
588
|
+
background:transparent; color:var(--dsw-alias-label-secondary, #49525f);
|
|
589
|
+
font-size:12px; font-weight:500; line-height:normal; text-decoration:none;
|
|
590
|
+
transition:color .24s ease, border-color .24s ease, box-shadow .24s ease; }
|
|
591
|
+
.pt-brand-pill::before { content:""; position:absolute; inset:0; z-index:0; opacity:0;
|
|
592
|
+
background:linear-gradient(120deg, #3b6bff 0%, #6a5cff 50%, #9a5cff 100%);
|
|
593
|
+
transition:opacity .24s ease; }
|
|
594
|
+
.pt-brand-pill:hover, .pt-brand-pill:focus-visible { color:#ffffff; border-color:transparent;
|
|
595
|
+
box-shadow:0 2px 14px -4px rgba(88,92,255,.55); outline:none; }
|
|
596
|
+
.pt-brand-pill:hover::before, .pt-brand-pill:focus-visible::before { opacity:1; }
|
|
597
|
+
.pt-brand-mark { width:16px; height:16px; flex:0 0 auto; position:relative; z-index:1;
|
|
598
|
+
opacity:.78; transition:filter .24s ease, opacity .24s ease; }
|
|
599
|
+
.pt-brand-pill:hover .pt-brand-mark, .pt-brand-pill:focus-visible .pt-brand-mark {
|
|
600
|
+
filter:brightness(0) invert(1); opacity:.95; }
|
|
601
|
+
/* One grid cell for both labels keeps the pill from resizing as the copy
|
|
602
|
+
flips; the taller line is 18px, which also clips the sliding label. */
|
|
603
|
+
.pt-brand-swap { display:inline-grid; position:relative; z-index:1; overflow:hidden;
|
|
604
|
+
height:18px; align-items:center; }
|
|
605
|
+
.pt-brand-swap > span { grid-area:1/1; white-space:nowrap;
|
|
606
|
+
transition:transform .34s cubic-bezier(.22,.61,.36,1), opacity .18s ease; }
|
|
607
|
+
.pt-brand-idle { transform:translateY(0); }
|
|
608
|
+
.pt-brand-hover { transform:translateY(100%); }
|
|
609
|
+
.pt-brand-pill:hover .pt-brand-idle, .pt-brand-pill:focus-visible .pt-brand-idle {
|
|
610
|
+
transform:translateY(-100%); opacity:0; }
|
|
611
|
+
.pt-brand-pill:hover .pt-brand-hover, .pt-brand-pill:focus-visible .pt-brand-hover {
|
|
612
|
+
transform:translateY(0); }
|
|
613
|
+
.pt-brand-arrow { width:11px; height:11px; flex:0 0 auto; position:relative; z-index:1;
|
|
614
|
+
transition:transform .24s ease; }
|
|
615
|
+
.pt-brand-pill:hover .pt-brand-arrow, .pt-brand-pill:focus-visible .pt-brand-arrow {
|
|
616
|
+
transform:translate(1px, -1px); }
|
|
617
|
+
@media (prefers-reduced-motion: reduce) {
|
|
618
|
+
.pt-brand-swap > span { transform:none !important; transition:opacity .01ms linear; }
|
|
619
|
+
.pt-brand-idle { opacity:1; }
|
|
620
|
+
.pt-brand-hover { opacity:0; }
|
|
621
|
+
.pt-brand-pill:hover .pt-brand-idle, .pt-brand-pill:focus-visible .pt-brand-idle { opacity:0; }
|
|
622
|
+
.pt-brand-pill:hover .pt-brand-hover, .pt-brand-pill:focus-visible .pt-brand-hover { opacity:1; }
|
|
623
|
+
.pt-brand-arrow, .pt-brand-mark, .pt-brand-pill, .pt-brand-pill::before { transition-duration:.01ms; }
|
|
624
|
+
}
|
|
577
625
|
/* The badge has no padding of its own and inherits the 1.5 line-height,
|
|
578
626
|
while a button keeps the UA's smaller normal line-height; bottom
|
|
579
627
|
alignment would lift the badge text away from the button labels. Sit on
|
|
@@ -891,6 +939,75 @@ window.__ModuleLoader__.load({
|
|
|
891
939
|
return h('label', { className: span ? 'pt-field pt-span-2' : 'pt-field' }, h('span', null, label), children)
|
|
892
940
|
}
|
|
893
941
|
|
|
942
|
+
/**
|
|
943
|
+
* FTShare brand entry in the header's top-right corner.
|
|
944
|
+
*
|
|
945
|
+
* One link carries three surfaces: the mark, a label that flips from the
|
|
946
|
+
* CTA copy to the brand slogan on hover, and the arrow. The idle state is a
|
|
947
|
+
* plain outline on purpose — this is a marketing entry, not a trading
|
|
948
|
+
* control, so it must not read as a filled accent until the pointer is on
|
|
949
|
+
* it. `aria-label` pins the accessible name to the CTA copy: the visible
|
|
950
|
+
* label changes, and a screen reader must not announce the slogan instead.
|
|
951
|
+
*/
|
|
952
|
+
const BRAND_LANDING_URL = 'https://ftai.chat/ftshare?utm_source=dsh-fft&utm_medium=AI&utm_campaign=dsh'
|
|
953
|
+
const BRAND_IDLE_COPY = '即刻体验 FtShare'
|
|
954
|
+
const BRAND_APPLY_COPY = '申请 FtShare Key'
|
|
955
|
+
const BRAND_HOVER_COPY = '有智能的金融数据'
|
|
956
|
+
/** States where the entry is the place to get a key, so the label says so. */
|
|
957
|
+
const BRAND_APPLY_STATES = new Set(['free', 'invalid'])
|
|
958
|
+
|
|
959
|
+
/** FTShare mark; the mask keeps the glyphs inside the rounded tile. */
|
|
960
|
+
function BrandMark() {
|
|
961
|
+
return h('svg', {
|
|
962
|
+
className: 'pt-brand-mark', viewBox: '0 0 24.0702 24', 'aria-hidden': 'true', focusable: 'false',
|
|
963
|
+
},
|
|
964
|
+
h('defs', null,
|
|
965
|
+
h('mask', { id: 'pt-brand-mark-tile', maskUnits: 'userSpaceOnUse', x: 0, y: 0, width: 25, height: 24 },
|
|
966
|
+
h('path', {
|
|
967
|
+
d: 'M19.1579 0H4.91228C2.1993 0 0 2.19289 0 4.89796V19.102C0 21.8071 2.1993 24 4.91228 24H19.1579C21.8709 24 24.0702 21.8071 24.0702 19.102V4.89796C24.0702 2.19289 21.8709 0 19.1579 0Z',
|
|
968
|
+
fill: '#fff',
|
|
969
|
+
}))),
|
|
970
|
+
h('g', { mask: 'url(#pt-brand-mark-tile)' },
|
|
971
|
+
h('path', {
|
|
972
|
+
d: 'M23.5789 0H0.491228C0.21993 0 0 0.219289 0 0.489796V4.40816C0 4.67868 0.21993 4.89796 0.491228 4.89796H23.5789C23.8503 4.89796 24.0702 4.67868 24.0702 4.40816V0.489796C24.0702 0.219289 23.8503 0 23.5789 0Z',
|
|
973
|
+
fill: '#0000FF',
|
|
974
|
+
}),
|
|
975
|
+
h('path', {
|
|
976
|
+
d: 'M24.0702 9.3338C24.0702 8.88801 23.5215 8.67399 23.2182 9.00147L15.5094 17.3232C15.417 17.423 15.2871 17.48 15.1509 17.4806L10.3653 17.5029C10.2291 17.5035 10.0992 17.5606 10.0068 17.6604L4.89504 23.1779C4.6044 23.4916 4.82754 24 5.25587 24H23.579C23.8503 24 24.0702 23.7807 24.0702 23.5102V9.3338Z',
|
|
977
|
+
fill: '#95B6F5',
|
|
978
|
+
}),
|
|
979
|
+
h('path', {
|
|
980
|
+
d: 'M18.8157 8.08163C19.2438 8.08163 19.4671 8.58965 19.1769 8.90346L14.4398 14.0256C14.3468 14.1261 14.2158 14.1833 14.0786 14.1833H9.29548C9.15831 14.1833 9.02737 14.2405 8.93438 14.3411L0.852325 23.0785C0.54909 23.4064 0 23.1925 0 22.7465V8.57143C0 8.30092 0.21993 8.08163 0.491228 8.08163H18.8157Z',
|
|
981
|
+
fill: '#0000FF',
|
|
982
|
+
})),
|
|
983
|
+
)
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Header brand entry: mark + label that flips to the slogan on hover.
|
|
988
|
+
*
|
|
989
|
+
* The idle label follows the data-source state: while no key is configured
|
|
990
|
+
* (or the stored one is unusable) the entry is the way to get one, so it
|
|
991
|
+
* reads 申请 FtShare Key; otherwise it stays the brand CTA. Both labels
|
|
992
|
+
* share one grid cell, so the wider slogan fixes the width either way.
|
|
993
|
+
*/
|
|
994
|
+
function BrandPill({ state }) {
|
|
995
|
+
const idle = BRAND_APPLY_STATES.has(state) ? BRAND_APPLY_COPY : BRAND_IDLE_COPY
|
|
996
|
+
return h('a', {
|
|
997
|
+
className: 'pt-brand-pill', href: BRAND_LANDING_URL, target: '_blank',
|
|
998
|
+
rel: 'noopener noreferrer', 'aria-label': idle,
|
|
999
|
+
},
|
|
1000
|
+
h(BrandMark),
|
|
1001
|
+
h('span', { className: 'pt-brand-swap', 'aria-hidden': 'true' },
|
|
1002
|
+
h('span', { className: 'pt-brand-idle' }, idle),
|
|
1003
|
+
h('span', { className: 'pt-brand-hover' }, BRAND_HOVER_COPY)),
|
|
1004
|
+
h('svg', {
|
|
1005
|
+
className: 'pt-brand-arrow', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor',
|
|
1006
|
+
strokeWidth: 2.2, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': 'true',
|
|
1007
|
+
}, h('path', { d: 'M7 17 17 7M7 7h10v10' })),
|
|
1008
|
+
)
|
|
1009
|
+
}
|
|
1010
|
+
|
|
894
1011
|
/**
|
|
895
1012
|
* Header badge for the data source. `null` until the host has answered, so
|
|
896
1013
|
* the header never flashes a guess; a status `message` (failed validation,
|
|
@@ -3234,19 +3351,24 @@ window.__ModuleLoader__.load({
|
|
|
3234
3351
|
status !== null && status !== undefined ? calendarNote(status.calendar) : null,
|
|
3235
3352
|
),
|
|
3236
3353
|
),
|
|
3237
|
-
h('div', { className: 'pt-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3354
|
+
h('div', { className: 'pt-head-right' },
|
|
3355
|
+
h('div', { className: 'pt-topline' },
|
|
3356
|
+
h(DataSourceBadge, { status: dataSource }),
|
|
3357
|
+
h(BrandPill, { state: dataSource?.state }),
|
|
3358
|
+
),
|
|
3359
|
+
h('div', { className: 'pt-row' },
|
|
3360
|
+
accountSwitch,
|
|
3361
|
+
h('button', { className: 'pt-btn', onClick: refreshAll, disabled: busy }, '刷新'),
|
|
3362
|
+
h('button', {
|
|
3363
|
+
className: 'pt-btn', 'data-active': cashOpen, disabled: busy,
|
|
3364
|
+
onClick: () => {
|
|
3365
|
+
setError(null)
|
|
3366
|
+
setCashOpen(value => !value)
|
|
3367
|
+
},
|
|
3368
|
+
}, '资金'),
|
|
3369
|
+
h('button', { className: 'pt-btn pt-btn-danger', onClick: reset, disabled: busy }, '重置'),
|
|
3370
|
+
h(FeedbackLink),
|
|
3371
|
+
),
|
|
3250
3372
|
),
|
|
3251
3373
|
),
|
|
3252
3374
|
h(DataBanner, { status: dataSource, onRetry: refreshAll }),
|
|
@@ -4201,38 +4323,43 @@ window.__ModuleLoader__.load({
|
|
|
4201
4323
|
session !== null && session !== undefined ? calendarNote(session.calendar) : null,
|
|
4202
4324
|
),
|
|
4203
4325
|
),
|
|
4204
|
-
h('div', { className: 'pt-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4326
|
+
h('div', { className: 'pt-head-right' },
|
|
4327
|
+
h('div', { className: 'pt-topline' },
|
|
4328
|
+
h(DataSourceBadge, { status: dataSource }),
|
|
4329
|
+
h(BrandPill, { state: dataSource?.state }),
|
|
4330
|
+
),
|
|
4331
|
+
h('div', { className: 'pt-row' },
|
|
4332
|
+
accountSwitch,
|
|
4333
|
+
h(AccountPicker, {
|
|
4334
|
+
accounts: stockAccounts,
|
|
4335
|
+
archived,
|
|
4336
|
+
current: currentAccount,
|
|
4337
|
+
onRestoreArchived: restoreArchived,
|
|
4338
|
+
busy,
|
|
4339
|
+
onSelect: id => setCurrentAccountId(id),
|
|
4340
|
+
onCreate: () => setAccountEditor('create'),
|
|
4341
|
+
onAction: runAccountAction,
|
|
4342
|
+
}),
|
|
4343
|
+
h('button', { className: 'pt-btn', onClick: refreshAll, disabled: busy }, '刷新'),
|
|
4344
|
+
h('button', {
|
|
4345
|
+
className: 'pt-btn', 'data-active': cashOpen, disabled: busy,
|
|
4346
|
+
onClick: () => {
|
|
4347
|
+
setError(null)
|
|
4348
|
+
setCashOpen(value => !value)
|
|
4349
|
+
setResetOpen(false)
|
|
4350
|
+
},
|
|
4351
|
+
}, '资金'),
|
|
4352
|
+
h('button', {
|
|
4353
|
+
className: 'pt-btn pt-btn-danger', 'data-active': resetOpen, disabled: busy,
|
|
4354
|
+
onClick: () => {
|
|
4355
|
+
setError(null)
|
|
4356
|
+
setResetOpen(value => !value)
|
|
4357
|
+
setResetCash(String(account.initialCash))
|
|
4358
|
+
setCashOpen(false)
|
|
4359
|
+
},
|
|
4360
|
+
}, '重置'),
|
|
4361
|
+
h(FeedbackLink),
|
|
4362
|
+
),
|
|
4236
4363
|
),
|
|
4237
4364
|
),
|
|
4238
4365
|
h(DataBanner, { status: dataSource, onRetry: refreshAll }),
|
|
@@ -6,7 +6,7 @@ export class WeekdayTradingCalendar {
|
|
|
6
6
|
/**
|
|
7
7
|
* @param reason - why the weekday approximation is in use, shown in the UI.
|
|
8
8
|
*/
|
|
9
|
-
constructor(reason = '未接入
|
|
9
|
+
constructor(reason = '未接入 FtShare 交易日历') {
|
|
10
10
|
this.status = { source: 'fallback', reason };
|
|
11
11
|
}
|
|
12
12
|
async isTradingDay(date) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* every call reports `failed` with one readable reason instead of throwing.
|
|
4
4
|
*/
|
|
5
5
|
export class UnavailableFuturesMarketData {
|
|
6
|
-
notice = '期货行情不可用:未连接
|
|
6
|
+
notice = '期货行情不可用:未连接 FtShare 或当前套餐无权限';
|
|
7
7
|
fail() {
|
|
8
8
|
return Promise.resolve({ state: 'failed', notice: this.notice });
|
|
9
9
|
}
|
package/lib/index.js
CHANGED
|
@@ -91,7 +91,7 @@ export function apply(ctx, options = {}) {
|
|
|
91
91
|
// FTShare adapter can appear (or disappear) later without rebuilding the
|
|
92
92
|
// services, the route or the tools.
|
|
93
93
|
let market = options.marketData ?? new UnavailableMarketData();
|
|
94
|
-
let calendar = new WeekdayTradingCalendar('未安装
|
|
94
|
+
let calendar = new WeekdayTradingCalendar('未安装 FtShare 数据服务,按工作日估算');
|
|
95
95
|
const data = {
|
|
96
96
|
quotes: symbols => market.quotes(symbols),
|
|
97
97
|
dailyBars: (symbol, limit) => market.dailyBars(symbol, limit),
|
|
@@ -267,7 +267,7 @@ export function apply(ctx, options = {}) {
|
|
|
267
267
|
if (market === adapter)
|
|
268
268
|
market = new UnavailableMarketData();
|
|
269
269
|
if (calendar === calendarAdapter)
|
|
270
|
-
calendar = new WeekdayTradingCalendar('未安装
|
|
270
|
+
calendar = new WeekdayTradingCalendar('未安装 FtShare 数据服务,按工作日估算');
|
|
271
271
|
if (futuresMarket === futuresAdapter)
|
|
272
272
|
futuresMarket = new UnavailableFuturesMarketData();
|
|
273
273
|
cached.clear();
|
|
@@ -34,13 +34,13 @@ export async function probeDataSource(input) {
|
|
|
34
34
|
return { state: 'none' };
|
|
35
35
|
const describe = input.settings?.apiKey?.describe;
|
|
36
36
|
if (typeof describe !== 'function') {
|
|
37
|
-
return { state: 'invalid', message: '无法读取
|
|
37
|
+
return { state: 'invalid', message: '无法读取 FtShare Key 状态' };
|
|
38
38
|
}
|
|
39
39
|
let status;
|
|
40
40
|
try {
|
|
41
41
|
const described = asRecord(await describe());
|
|
42
42
|
if (described === undefined) {
|
|
43
|
-
status = { state: 'invalid', message: '无法读取
|
|
43
|
+
status = { state: 'invalid', message: '无法读取 FtShare Key 状态' };
|
|
44
44
|
}
|
|
45
45
|
else if (described.configured !== true) {
|
|
46
46
|
status = { state: 'free' };
|
|
@@ -61,7 +61,7 @@ export async function probeDataSource(input) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
catch {
|
|
64
|
-
status = { state: 'invalid', message: '无法读取
|
|
64
|
+
status = { state: 'invalid', message: '无法读取 FtShare Key 状态' };
|
|
65
65
|
}
|
|
66
66
|
return status;
|
|
67
67
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-ft/dsh-fft-paper-trading",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A-share and commodity futures paper trading for DeepSeek Harness: local ledger, batch orders, review, and
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "A-share and commodity futures paper trading for DeepSeek Harness: local ledger, batch orders, review, and FtShare quotes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"package.json"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@dsh-ft/dsh-fft-settings": "^0.7.
|
|
53
|
-
"@dsh-ft/dsh-fft-ftshare": "^0.4.
|
|
52
|
+
"@dsh-ft/dsh-fft-settings": "^0.7.3",
|
|
53
|
+
"@dsh-ft/dsh-fft-ftshare": "^0.4.4",
|
|
54
54
|
"@ftshare-lab/dsh-kline": ">=0.6.11"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
@@ -116,11 +116,11 @@
|
|
|
116
116
|
* tick, so the label has to say which one it is.
|
|
117
117
|
*/
|
|
118
118
|
const quoteSourceText = quote => {
|
|
119
|
-
if (!quote || !quote.source) return '
|
|
119
|
+
if (!quote || !quote.source) return 'FtShare'
|
|
120
120
|
if (quote.source === 'manual') return '参考价'
|
|
121
121
|
// Provenance, not tier: a keyed account can also end up on the daily close.
|
|
122
122
|
if (quote.source === 'daily-bar') return '日K收盘'
|
|
123
|
-
return '
|
|
123
|
+
return 'FtShare 实时'
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Quote line time. Same-day data shows the clock only; a daily-close quote
|
|
@@ -148,13 +148,13 @@
|
|
|
148
148
|
* title carries the consequence (realtime vs daily-close pricing).
|
|
149
149
|
*/
|
|
150
150
|
const DATA_SOURCE_STATE = {
|
|
151
|
-
configured: { text: '数据源正常', title: '
|
|
151
|
+
configured: { text: '数据源正常', title: 'FtShare API Key 已配置,可看实时行情' },
|
|
152
152
|
free: {
|
|
153
|
-
text: '
|
|
154
|
-
title: '未配置
|
|
153
|
+
text: '免费档',
|
|
154
|
+
title: '未配置 FtShare Key:免费档报价取日K收盘,可手填参考价交易',
|
|
155
155
|
},
|
|
156
|
-
none: { text: '无数据源', title: '未安装
|
|
157
|
-
invalid: { text: '数据源无效', title: '
|
|
156
|
+
none: { text: '无数据源', title: '未安装 FtShare 数据服务,行情不可用;可手填参考价交易' },
|
|
157
|
+
invalid: { text: '数据源无效', title: 'FtShare Key 无法使用;请在「设置」中检查,可手填参考价交易' },
|
|
158
158
|
}
|
|
159
159
|
/** Badge suffix per recorded failure, so the header cannot read 正常 while quotes fail. */
|
|
160
160
|
const DATA_PROBLEM_STATE = {
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
return {
|
|
191
191
|
id: 'no-service', tone: 'info',
|
|
192
192
|
title: '行情数据服务未安装',
|
|
193
|
-
detail: '现在只能用参考价交易;安装
|
|
193
|
+
detail: '现在只能用参考价交易;安装 FtShare 数据服务后自动恢复。',
|
|
194
194
|
actions: [],
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
// Quotes still work on the free tier (last daily close), so the banner
|
|
200
200
|
// cannot say 行情未启用; what a key adds is the realtime feed.
|
|
201
201
|
title: '免费档:报价取日K收盘',
|
|
202
|
-
detail:
|
|
202
|
+
detail: `实时行情需 FtShare Key,申请后 → ${KEY_SETTINGS} 填入。`,
|
|
203
203
|
actions: [],
|
|
204
204
|
}
|
|
205
205
|
const problem = status.problem
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
id: 'quota', tone: 'warn',
|
|
211
211
|
// 匿名档是「最近 24 小时 500 次」的滚动额度,不是一个自然日。
|
|
212
212
|
title: '免费额度已用尽',
|
|
213
|
-
detail:
|
|
213
|
+
detail: `点右上「申请 FtShare Key」,申请后到 ${KEY_SETTINGS} 填入;或等约 24 小时额度恢复。`,
|
|
214
214
|
actions: ['retry'],
|
|
215
215
|
}
|
|
216
216
|
case 'plan-denied':
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
? noKeyBanner
|
|
232
232
|
: {
|
|
233
233
|
id: 'invalid-key', tone: 'error',
|
|
234
|
-
title: '
|
|
234
|
+
title: 'FtShare 数据源无法使用',
|
|
235
235
|
detail: `在 ${KEY_SETTINGS} 检查 API Key。`,
|
|
236
236
|
actions: ['retry'],
|
|
237
237
|
}
|
|
@@ -255,7 +255,7 @@
|
|
|
255
255
|
if (status.state === 'invalid') {
|
|
256
256
|
return {
|
|
257
257
|
id: 'invalid-key', tone: 'error',
|
|
258
|
-
title: '
|
|
258
|
+
title: 'FtShare 数据源无法使用',
|
|
259
259
|
detail: `${status.message === undefined || status.message === '' ? 'Key 未通过验证' : status.message}。在 ${KEY_SETTINGS} 检查 API Key。`,
|
|
260
260
|
actions: [],
|
|
261
261
|
}
|
|
@@ -27,6 +27,54 @@
|
|
|
27
27
|
padding-bottom:8px; border-bottom:0.5px solid var(--dsw-alias-border-l2, rgba(45,49,66,.12)); }
|
|
28
28
|
.pt-title { font-size:16px; font-weight:500; letter-spacing:-.01em; margin:0; }
|
|
29
29
|
.pt-sub { color:var(--dsw-alias-label-secondary, #49525f); font-size:12px; margin-top:2px; }
|
|
30
|
+
/* The header's right column stacks the brand entry above the account
|
|
31
|
+
controls. The entry is the only outbound marketing link in the panel,
|
|
32
|
+
so it stays a quiet outline until hovered: its blue-violet gradient and
|
|
33
|
+
the slogan appear only under the pointer (or keyboard focus). */
|
|
34
|
+
.pt-head-right { display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
|
|
35
|
+
/* The data-source state is page context, not an action: it shares the
|
|
36
|
+
top line with the brand entry, so the row below stays pure controls. */
|
|
37
|
+
.pt-topline { display:flex; align-items:center; gap:12px; flex-wrap:wrap; justify-content:flex-end; }
|
|
38
|
+
.pt-brand-pill { position:relative; display:inline-flex; align-items:center; gap:7px; flex:0 0 auto;
|
|
39
|
+
max-width:100%; padding:4px 12px 4px 9px; border-radius:999px; overflow:hidden;
|
|
40
|
+
border:0.5px solid var(--dsw-alias-border-l2, rgba(45,49,66,.18));
|
|
41
|
+
background:transparent; color:var(--dsw-alias-label-secondary, #49525f);
|
|
42
|
+
font-size:12px; font-weight:500; line-height:normal; text-decoration:none;
|
|
43
|
+
transition:color .24s ease, border-color .24s ease, box-shadow .24s ease; }
|
|
44
|
+
.pt-brand-pill::before { content:""; position:absolute; inset:0; z-index:0; opacity:0;
|
|
45
|
+
background:linear-gradient(120deg, #3b6bff 0%, #6a5cff 50%, #9a5cff 100%);
|
|
46
|
+
transition:opacity .24s ease; }
|
|
47
|
+
.pt-brand-pill:hover, .pt-brand-pill:focus-visible { color:#ffffff; border-color:transparent;
|
|
48
|
+
box-shadow:0 2px 14px -4px rgba(88,92,255,.55); outline:none; }
|
|
49
|
+
.pt-brand-pill:hover::before, .pt-brand-pill:focus-visible::before { opacity:1; }
|
|
50
|
+
.pt-brand-mark { width:16px; height:16px; flex:0 0 auto; position:relative; z-index:1;
|
|
51
|
+
opacity:.78; transition:filter .24s ease, opacity .24s ease; }
|
|
52
|
+
.pt-brand-pill:hover .pt-brand-mark, .pt-brand-pill:focus-visible .pt-brand-mark {
|
|
53
|
+
filter:brightness(0) invert(1); opacity:.95; }
|
|
54
|
+
/* One grid cell for both labels keeps the pill from resizing as the copy
|
|
55
|
+
flips; the taller line is 18px, which also clips the sliding label. */
|
|
56
|
+
.pt-brand-swap { display:inline-grid; position:relative; z-index:1; overflow:hidden;
|
|
57
|
+
height:18px; align-items:center; }
|
|
58
|
+
.pt-brand-swap > span { grid-area:1/1; white-space:nowrap;
|
|
59
|
+
transition:transform .34s cubic-bezier(.22,.61,.36,1), opacity .18s ease; }
|
|
60
|
+
.pt-brand-idle { transform:translateY(0); }
|
|
61
|
+
.pt-brand-hover { transform:translateY(100%); }
|
|
62
|
+
.pt-brand-pill:hover .pt-brand-idle, .pt-brand-pill:focus-visible .pt-brand-idle {
|
|
63
|
+
transform:translateY(-100%); opacity:0; }
|
|
64
|
+
.pt-brand-pill:hover .pt-brand-hover, .pt-brand-pill:focus-visible .pt-brand-hover {
|
|
65
|
+
transform:translateY(0); }
|
|
66
|
+
.pt-brand-arrow { width:11px; height:11px; flex:0 0 auto; position:relative; z-index:1;
|
|
67
|
+
transition:transform .24s ease; }
|
|
68
|
+
.pt-brand-pill:hover .pt-brand-arrow, .pt-brand-pill:focus-visible .pt-brand-arrow {
|
|
69
|
+
transform:translate(1px, -1px); }
|
|
70
|
+
@media (prefers-reduced-motion: reduce) {
|
|
71
|
+
.pt-brand-swap > span { transform:none !important; transition:opacity .01ms linear; }
|
|
72
|
+
.pt-brand-idle { opacity:1; }
|
|
73
|
+
.pt-brand-hover { opacity:0; }
|
|
74
|
+
.pt-brand-pill:hover .pt-brand-idle, .pt-brand-pill:focus-visible .pt-brand-idle { opacity:0; }
|
|
75
|
+
.pt-brand-pill:hover .pt-brand-hover, .pt-brand-pill:focus-visible .pt-brand-hover { opacity:1; }
|
|
76
|
+
.pt-brand-arrow, .pt-brand-mark, .pt-brand-pill, .pt-brand-pill::before { transition-duration:.01ms; }
|
|
77
|
+
}
|
|
30
78
|
/* The badge has no padding of its own and inherits the 1.5 line-height,
|
|
31
79
|
while a button keeps the UA's smaller normal line-height; bottom
|
|
32
80
|
alignment would lift the badge text away from the button labels. Sit on
|
|
@@ -6,6 +6,75 @@
|
|
|
6
6
|
return h('label', { className: span ? 'pt-field pt-span-2' : 'pt-field' }, h('span', null, label), children)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* FTShare brand entry in the header's top-right corner.
|
|
11
|
+
*
|
|
12
|
+
* One link carries three surfaces: the mark, a label that flips from the
|
|
13
|
+
* CTA copy to the brand slogan on hover, and the arrow. The idle state is a
|
|
14
|
+
* plain outline on purpose — this is a marketing entry, not a trading
|
|
15
|
+
* control, so it must not read as a filled accent until the pointer is on
|
|
16
|
+
* it. `aria-label` pins the accessible name to the CTA copy: the visible
|
|
17
|
+
* label changes, and a screen reader must not announce the slogan instead.
|
|
18
|
+
*/
|
|
19
|
+
const BRAND_LANDING_URL = 'https://ftai.chat/ftshare?utm_source=dsh-fft&utm_medium=AI&utm_campaign=dsh'
|
|
20
|
+
const BRAND_IDLE_COPY = '即刻体验 FtShare'
|
|
21
|
+
const BRAND_APPLY_COPY = '申请 FtShare Key'
|
|
22
|
+
const BRAND_HOVER_COPY = '有智能的金融数据'
|
|
23
|
+
/** States where the entry is the place to get a key, so the label says so. */
|
|
24
|
+
const BRAND_APPLY_STATES = new Set(['free', 'invalid'])
|
|
25
|
+
|
|
26
|
+
/** FTShare mark; the mask keeps the glyphs inside the rounded tile. */
|
|
27
|
+
function BrandMark() {
|
|
28
|
+
return h('svg', {
|
|
29
|
+
className: 'pt-brand-mark', viewBox: '0 0 24.0702 24', 'aria-hidden': 'true', focusable: 'false',
|
|
30
|
+
},
|
|
31
|
+
h('defs', null,
|
|
32
|
+
h('mask', { id: 'pt-brand-mark-tile', maskUnits: 'userSpaceOnUse', x: 0, y: 0, width: 25, height: 24 },
|
|
33
|
+
h('path', {
|
|
34
|
+
d: 'M19.1579 0H4.91228C2.1993 0 0 2.19289 0 4.89796V19.102C0 21.8071 2.1993 24 4.91228 24H19.1579C21.8709 24 24.0702 21.8071 24.0702 19.102V4.89796C24.0702 2.19289 21.8709 0 19.1579 0Z',
|
|
35
|
+
fill: '#fff',
|
|
36
|
+
}))),
|
|
37
|
+
h('g', { mask: 'url(#pt-brand-mark-tile)' },
|
|
38
|
+
h('path', {
|
|
39
|
+
d: 'M23.5789 0H0.491228C0.21993 0 0 0.219289 0 0.489796V4.40816C0 4.67868 0.21993 4.89796 0.491228 4.89796H23.5789C23.8503 4.89796 24.0702 4.67868 24.0702 4.40816V0.489796C24.0702 0.219289 23.8503 0 23.5789 0Z',
|
|
40
|
+
fill: '#0000FF',
|
|
41
|
+
}),
|
|
42
|
+
h('path', {
|
|
43
|
+
d: 'M24.0702 9.3338C24.0702 8.88801 23.5215 8.67399 23.2182 9.00147L15.5094 17.3232C15.417 17.423 15.2871 17.48 15.1509 17.4806L10.3653 17.5029C10.2291 17.5035 10.0992 17.5606 10.0068 17.6604L4.89504 23.1779C4.6044 23.4916 4.82754 24 5.25587 24H23.579C23.8503 24 24.0702 23.7807 24.0702 23.5102V9.3338Z',
|
|
44
|
+
fill: '#95B6F5',
|
|
45
|
+
}),
|
|
46
|
+
h('path', {
|
|
47
|
+
d: 'M18.8157 8.08163C19.2438 8.08163 19.4671 8.58965 19.1769 8.90346L14.4398 14.0256C14.3468 14.1261 14.2158 14.1833 14.0786 14.1833H9.29548C9.15831 14.1833 9.02737 14.2405 8.93438 14.3411L0.852325 23.0785C0.54909 23.4064 0 23.1925 0 22.7465V8.57143C0 8.30092 0.21993 8.08163 0.491228 8.08163H18.8157Z',
|
|
48
|
+
fill: '#0000FF',
|
|
49
|
+
})),
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Header brand entry: mark + label that flips to the slogan on hover.
|
|
55
|
+
*
|
|
56
|
+
* The idle label follows the data-source state: while no key is configured
|
|
57
|
+
* (or the stored one is unusable) the entry is the way to get one, so it
|
|
58
|
+
* reads 申请 FtShare Key; otherwise it stays the brand CTA. Both labels
|
|
59
|
+
* share one grid cell, so the wider slogan fixes the width either way.
|
|
60
|
+
*/
|
|
61
|
+
function BrandPill({ state }) {
|
|
62
|
+
const idle = BRAND_APPLY_STATES.has(state) ? BRAND_APPLY_COPY : BRAND_IDLE_COPY
|
|
63
|
+
return h('a', {
|
|
64
|
+
className: 'pt-brand-pill', href: BRAND_LANDING_URL, target: '_blank',
|
|
65
|
+
rel: 'noopener noreferrer', 'aria-label': idle,
|
|
66
|
+
},
|
|
67
|
+
h(BrandMark),
|
|
68
|
+
h('span', { className: 'pt-brand-swap', 'aria-hidden': 'true' },
|
|
69
|
+
h('span', { className: 'pt-brand-idle' }, idle),
|
|
70
|
+
h('span', { className: 'pt-brand-hover' }, BRAND_HOVER_COPY)),
|
|
71
|
+
h('svg', {
|
|
72
|
+
className: 'pt-brand-arrow', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor',
|
|
73
|
+
strokeWidth: 2.2, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': 'true',
|
|
74
|
+
}, h('path', { d: 'M7 17 17 7M7 7h10v10' })),
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
9
78
|
/**
|
|
10
79
|
* Header badge for the data source. `null` until the host has answered, so
|
|
11
80
|
* the header never flashes a guess; a status `message` (failed validation,
|
|
@@ -486,19 +486,24 @@
|
|
|
486
486
|
status !== null && status !== undefined ? calendarNote(status.calendar) : null,
|
|
487
487
|
),
|
|
488
488
|
),
|
|
489
|
-
h('div', { className: 'pt-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
489
|
+
h('div', { className: 'pt-head-right' },
|
|
490
|
+
h('div', { className: 'pt-topline' },
|
|
491
|
+
h(DataSourceBadge, { status: dataSource }),
|
|
492
|
+
h(BrandPill, { state: dataSource?.state }),
|
|
493
|
+
),
|
|
494
|
+
h('div', { className: 'pt-row' },
|
|
495
|
+
accountSwitch,
|
|
496
|
+
h('button', { className: 'pt-btn', onClick: refreshAll, disabled: busy }, '刷新'),
|
|
497
|
+
h('button', {
|
|
498
|
+
className: 'pt-btn', 'data-active': cashOpen, disabled: busy,
|
|
499
|
+
onClick: () => {
|
|
500
|
+
setError(null)
|
|
501
|
+
setCashOpen(value => !value)
|
|
502
|
+
},
|
|
503
|
+
}, '资金'),
|
|
504
|
+
h('button', { className: 'pt-btn pt-btn-danger', onClick: reset, disabled: busy }, '重置'),
|
|
505
|
+
h(FeedbackLink),
|
|
506
|
+
),
|
|
502
507
|
),
|
|
503
508
|
),
|
|
504
509
|
h(DataBanner, { status: dataSource, onRetry: refreshAll }),
|
|
@@ -540,38 +540,43 @@
|
|
|
540
540
|
session !== null && session !== undefined ? calendarNote(session.calendar) : null,
|
|
541
541
|
),
|
|
542
542
|
),
|
|
543
|
-
h('div', { className: 'pt-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
543
|
+
h('div', { className: 'pt-head-right' },
|
|
544
|
+
h('div', { className: 'pt-topline' },
|
|
545
|
+
h(DataSourceBadge, { status: dataSource }),
|
|
546
|
+
h(BrandPill, { state: dataSource?.state }),
|
|
547
|
+
),
|
|
548
|
+
h('div', { className: 'pt-row' },
|
|
549
|
+
accountSwitch,
|
|
550
|
+
h(AccountPicker, {
|
|
551
|
+
accounts: stockAccounts,
|
|
552
|
+
archived,
|
|
553
|
+
current: currentAccount,
|
|
554
|
+
onRestoreArchived: restoreArchived,
|
|
555
|
+
busy,
|
|
556
|
+
onSelect: id => setCurrentAccountId(id),
|
|
557
|
+
onCreate: () => setAccountEditor('create'),
|
|
558
|
+
onAction: runAccountAction,
|
|
559
|
+
}),
|
|
560
|
+
h('button', { className: 'pt-btn', onClick: refreshAll, disabled: busy }, '刷新'),
|
|
561
|
+
h('button', {
|
|
562
|
+
className: 'pt-btn', 'data-active': cashOpen, disabled: busy,
|
|
563
|
+
onClick: () => {
|
|
564
|
+
setError(null)
|
|
565
|
+
setCashOpen(value => !value)
|
|
566
|
+
setResetOpen(false)
|
|
567
|
+
},
|
|
568
|
+
}, '资金'),
|
|
569
|
+
h('button', {
|
|
570
|
+
className: 'pt-btn pt-btn-danger', 'data-active': resetOpen, disabled: busy,
|
|
571
|
+
onClick: () => {
|
|
572
|
+
setError(null)
|
|
573
|
+
setResetOpen(value => !value)
|
|
574
|
+
setResetCash(String(account.initialCash))
|
|
575
|
+
setCashOpen(false)
|
|
576
|
+
},
|
|
577
|
+
}, '重置'),
|
|
578
|
+
h(FeedbackLink),
|
|
579
|
+
),
|
|
575
580
|
),
|
|
576
581
|
),
|
|
577
582
|
h(DataBanner, { status: dataSource, onRetry: refreshAll }),
|
|
@@ -20,7 +20,7 @@ export class WeekdayTradingCalendar implements TradingCalendarPort {
|
|
|
20
20
|
/**
|
|
21
21
|
* @param reason - why the weekday approximation is in use, shown in the UI.
|
|
22
22
|
*/
|
|
23
|
-
constructor(reason = '未接入
|
|
23
|
+
constructor(reason = '未接入 FtShare 交易日历') {
|
|
24
24
|
this.status = { source: 'fallback', reason }
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
* every call reports `failed` with one readable reason instead of throwing.
|
|
14
14
|
*/
|
|
15
15
|
export class UnavailableFuturesMarketData implements FuturesMarketDataPort {
|
|
16
|
-
private readonly notice = '期货行情不可用:未连接
|
|
16
|
+
private readonly notice = '期货行情不可用:未连接 FtShare 或当前套餐无权限'
|
|
17
17
|
|
|
18
18
|
private fail<T>(): Promise<FuturesDataResult<T>> {
|
|
19
19
|
return Promise.resolve({ state: 'failed', notice: this.notice })
|
package/src/index.ts
CHANGED
|
@@ -113,7 +113,7 @@ export function apply(ctx: Context, options: ApplyOptions = {}): void {
|
|
|
113
113
|
// FTShare adapter can appear (or disappear) later without rebuilding the
|
|
114
114
|
// services, the route or the tools.
|
|
115
115
|
let market: MarketDataPort = options.marketData ?? new UnavailableMarketData()
|
|
116
|
-
let calendar: TradingCalendarPort = new WeekdayTradingCalendar('未安装
|
|
116
|
+
let calendar: TradingCalendarPort = new WeekdayTradingCalendar('未安装 FtShare 数据服务,按工作日估算')
|
|
117
117
|
const data: MarketDataPort = {
|
|
118
118
|
quotes: symbols => market.quotes(symbols),
|
|
119
119
|
dailyBars: (symbol, limit) => market.dailyBars(symbol, limit),
|
|
@@ -299,7 +299,7 @@ export function apply(ctx: Context, options: ApplyOptions = {}): void {
|
|
|
299
299
|
scope.effect(
|
|
300
300
|
() => () => {
|
|
301
301
|
if (market === adapter) market = new UnavailableMarketData()
|
|
302
|
-
if (calendar === calendarAdapter) calendar = new WeekdayTradingCalendar('未安装
|
|
302
|
+
if (calendar === calendarAdapter) calendar = new WeekdayTradingCalendar('未安装 FtShare 数据服务,按工作日估算')
|
|
303
303
|
if (futuresMarket === futuresAdapter) futuresMarket = new UnavailableFuturesMarketData()
|
|
304
304
|
cached.clear()
|
|
305
305
|
dataService = false
|
|
@@ -57,13 +57,13 @@ export async function probeDataSource(input: DataSourceProbeInput): Promise<Data
|
|
|
57
57
|
if (!input.dataService) return { state: 'none' }
|
|
58
58
|
const describe = input.settings?.apiKey?.describe
|
|
59
59
|
if (typeof describe !== 'function') {
|
|
60
|
-
return { state: 'invalid', message: '无法读取
|
|
60
|
+
return { state: 'invalid', message: '无法读取 FtShare Key 状态' }
|
|
61
61
|
}
|
|
62
62
|
let status: DataSourceStatus
|
|
63
63
|
try {
|
|
64
64
|
const described = asRecord(await describe())
|
|
65
65
|
if (described === undefined) {
|
|
66
|
-
status = { state: 'invalid', message: '无法读取
|
|
66
|
+
status = { state: 'invalid', message: '无法读取 FtShare Key 状态' }
|
|
67
67
|
} else if (described.configured !== true) {
|
|
68
68
|
status = { state: 'free' }
|
|
69
69
|
} else {
|
|
@@ -79,7 +79,7 @@ export async function probeDataSource(input: DataSourceProbeInput): Promise<Data
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
} catch {
|
|
82
|
-
status = { state: 'invalid', message: '无法读取
|
|
82
|
+
status = { state: 'invalid', message: '无法读取 FtShare Key 状态' }
|
|
83
83
|
}
|
|
84
84
|
return status
|
|
85
85
|
}
|