dsh-hyperliquid 0.5.2 → 0.5.4
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/CHANGELOG.md +11 -0
- package/README.md +2 -2
- package/client.js +176 -14
- package/lib/chart-drawings.d.ts +3 -2
- package/lib/chart-drawings.js +16 -2
- package/lib/remote.js +1 -1
- package/lib/tools.js +6 -3
- package/package.json +1 -1
- package/skills/hyperliquid-trading/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.4 — 2026-10-17
|
|
4
|
+
|
|
5
|
+
- 新增固定江恩方格(共 77 种),几何按 TradingView Charting Library 的 GannfixedLineToolOverrides 默认值:始终正方形、5×5 单位网格(6 条等分线)、弧线位于 (1,0)(1,1)(1.5,0)(2,0)(2,1)(3,0)(3,1)(4,0)(4,1)(5,0)(5,1) 单位(超出方格的不画)、默认显示 2×1 / 1×1 / 1×2 扇线。
|
|
6
|
+
- 内部叉子线仍未做:帮助页描述与改良 Schiff 相同,开发者文档里只是叉子线的样式之一,没有单独的几何定义。
|
|
7
|
+
|
|
8
|
+
## 0.5.3 — 2026-10-17
|
|
9
|
+
|
|
10
|
+
- 新增锚定文本(按 TradingView 说明固定在屏幕位置,平移图表时不动,可拖动换位置)与表格(| 分隔单元格、; 或换行分隔行;工具条可固定到屏幕或取消固定,取消时贴回所在位置的时间与价格)。共 76 种。固定在屏幕上的画线不参与多选拖动;agent 用 `screenX/screenY` 固定、`unpin: true` 取消固定。
|
|
11
|
+
- 修复:指针停在画线上时,触控板滑动和滚轮缩放被画线的命中层截走,图表不响应;现在转发给下方的图表。
|
|
12
|
+
- 冒烟:锚定文本、表格固定 / 取消固定,每次平移都有「图表确实平移了」的对照检查;触控板阶段加「指针在画线上滑动仍平移」。
|
|
13
|
+
|
|
3
14
|
## 0.5.2 — 2026-10-17
|
|
4
15
|
|
|
5
16
|
- 新增投影(TradingView 的扇形:起点、未来点、估计价格,标注涨跌幅)与幽灵 K 线(逐点点击设想路径,双击或 Enter 结束;从首点到末点每个 K 线周期一根,收盘跟随路径;每根高低差取其实体与「路径起点前 20 根真实 K 线平均高低差 × 0.6–1.4 的固定抖动」中的较大者,最多 2000 根。TradingView 未公开其生成算法,这是近似实现)。共 74 种。
|
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ dsh plugin --profile web add dsh-web3
|
|
|
58
58
|
- **钱包与收益**:点击顶栏钱包查看地址、余额、权益和收益。实盘收益曲线来自 Hyperliquid 官方 portfolio 数据;模拟盘显示本地已实现与未实现收益。
|
|
59
59
|
- **K 线**:支持交易所官方的 14 个周期,以及成交量、SMA20、MA60、EMA20/50、布林带、RSI、MACD、ATR14 与 UTC 日内 VWAP。图表类型可切换蜡烛、美国线、折线、面积和平均 K 线,并随会话保存;平均 K 线仅改变显示,点位引用仍使用原始 OHLC。向左拖动会自动加载更早的 K 线,最多可追溯到交易所提供的最近 5000 根。可以画水平线、趋势线,画线有实时预览和趋势线端点。手动画线与会话中 `hyper_chart` 添加的标注按会话和币种保存,在该币种的所有周期展示;agent 添加或删除后,打开的图表通常在下一次宿主事件轮询(约 1 秒)更新。明确点击 K 线、成交量柱或指标线,会在输入框里插入一个引用标签(如 `BTC 15m 10-15 13:45 · C 81397`);拖动图表不会引用。发送时标签展开为该点的完整 OHLC、量能与指标数据;点击标签可回到图上的那根 K 线。 「指标」菜单还可叠加最多 8 条可配置均线:SMA / EMA / SMMA(平滑均线,即 TradingView 的 RMA)/ WMA,周期 1–500,价格源可选 close / open / high / low / hl2 / hlc3 / ohlc4,并可再套一层平滑(虚线),算法与 TradingView Pine 一致;图例实时显示数值,agent 也能用 `hyper_chart` 把均线画到图上。
|
|
60
60
|
- **导航与导出**:图表下方可查看最近 1/5/30 天、适应已加载全部数据、跳转到本地时间指定的日期,或回到最新行情;历史不足会自动补取,并在到达数据边界时提示。导出菜单可保存含画线和指标的 PNG,或导出已加载原始 OHLCV 的 CSV(UTC 时间)。指标图例与成交量跟随十字光标;VWAP 使用 UTC 每日重置的 HLC3 成交量加权价格,首日历史不全时不展示该日不完整结果。
|
|
61
|
-
- **画线工具**:工具栏「画线」菜单按 TradingView 的分组提供
|
|
61
|
+
- **画线工具**:工具栏「画线」菜单按 TradingView 的分组提供 77 种工具(菜单顶部可搜索)——线条:趋势线、射线、延长线、信息线(涨跌 / 根数 / 时长 / 角度)、趋势角度、水平线、水平射线、十字线、垂直线;通道:平行通道、安德鲁叉子线、Schiff 与改良 Schiff 叉子线、回归趋势(收盘价最小二乘 ±2σ)、固定范围成交量分布(按价格统计区间成交量,标出 POC 与价值区 VAH / VAL,可调行数与价值区比例;斐波那契回撤、扩展和通道可在浮动工具条自定义层级;由 K 线估算,区间早于已加载历史时自动补加载并提示);斐波那契与江恩:斐波那契回撤、趋势斐波那契扩展、斐波那契通道、斐波那契时间周期、江恩箱、江恩方格、江恩扇形;形态:艾略特推动浪(0-5)与调整浪(A-B-C)、XABCD 谐波与 ABCD(自动标注斐波那契比值)、头肩形态(含颈线);形状:矩形、圆形、三角形、画笔;标注:文本、标注气泡、价格标签、箭头、图标;测量与头寸:价格区间、日期区间、日期与价格区间、多头 / 空头头寸(止盈默认 2R,显示 R:R);0.5.0 新增:平顶 / 平底通道、分离通道、斐波那契速度阻力扇 / 圆 / 弧 / 楔形 / 基于趋势的时间、Cypher、三驱、三角形态、艾略特三角浪与双重 / 三重组合、周期线、正弦线、椭圆、旋转矩形、弧线、曲线、便签、价格便签、路标、预测、锚定 VWAP、锚定成交量分布;0.5.1 新增:荧光笔、路径(逐点点击,双击或 Enter 结束)、折线、图钉、斐波那契螺旋、K 线形态(复制一段 K 线的形状到别处);0.5.2 新增:投影(扇形)、幽灵 K 线(沿设想路径生成假想 K 线);0.5.3 新增:锚定文本(固定在屏幕上)、表格(| 分隔单元格,; 分隔行,可固定到屏幕);0.5.4 新增:固定江恩方格。点击过程中实时预览,Esc 取消,按住 Shift 把方向约束为水平或 45°;磁吸可选关 / 弱 / 强,吸附到 K 线开高低收。
|
|
62
62
|
- **编辑与管理画线**:点选后拖动锚点改形状、拖动线身整体移动;浮动工具条可通过齿轮精确编辑锚点时间、价格和名称,改颜色、线宽、线型,复制,设为该工具的默认样式(之后新画的同类线自动套用),锁定或删除。按住 Shift 或 Ctrl/Cmd 点击可多选,多选后整组拖动、改色、隐藏、锁定或删除(一步撤销)。快捷键:Alt+T 趋势线、Alt+H 水平线、Alt+J 水平射线、Alt+V 垂直线、Alt+C 十字线、Alt+F 斐波那契回撤、Alt+Shift+R 矩形;画线时按住 Ctrl/Cmd 临时反转磁吸,吸附点显示提示圈;Esc 逐层退出(取消当前拖动或工具 → 取消选择 → 退出放大图表)。Delete 删除,Ctrl/Cmd+C、V 复制粘贴,Ctrl/Cmd+Z 撤销、Shift+Ctrl/Cmd+Z 重做(新建、修改、删除和批量删除都可撤销)。图表下方的画线列表可逐条定位、显示 / 隐藏、锁定或删除;菜单里还有连续绘制、锁定所有画线和删除所有画线。点击菜单中的星标可收藏最多 12 个工具,图表上方显示常用画线快捷栏;收藏保存在当前浏览器。画线锚定在时间与价格上,平移、缩放、切换刻度和加载历史时始终贴合 K 线,也可延伸到最新 K 线右侧的空白区域;画线按会话和币种保存,切换会话随之切换,重启后保留,agent 用 `hyper_chart` 新增或修改的画线会实时出现在打开的图表上。
|
|
63
63
|
- **同步、提醒与贴图**:浮动工具条可把画线「同步到所有会话」(该币种的每个交易会话都显示同一条线,任一会话可修改,重启后保留),水平线、水平射线、趋势线、射线和延长线可开启「价格提醒」——宿主持续监控中价,穿越画线时交易台弹出提醒,提醒触发一次后自动关闭,可再次开启。图标工具附贴图库:18 个内置图标、交易 / 表情 / 符号三类约 60 个贴纸,也可输入或粘贴任意一个 emoji 作为贴纸。每张图(会话 + 币种,跨周期合计)最多 100 条画线。
|
|
64
64
|
- **成交与决策原因**:每笔成交在图上的成交价位置打点(买绿卖红),有 AI 决策原因的点带圆环;点击查看方向、数量、价格、时间和当时的决策原因,「显示 → 成交原因」可把原因标签直接显示在图上。「回到决策会话分析」会切换到做出这笔决策的交易会话,并把成交与原因作为复盘引用放进输入框。
|
|
@@ -109,7 +109,7 @@ dsh plugin --profile web add dsh-web3
|
|
|
109
109
|
|---|---|
|
|
110
110
|
| `hyper_context` | 一次读取当前会话的币对、盘口、K 线、账户权益、仓位与风险限额 |
|
|
111
111
|
| `hyper_market` | 行情:overview / book / candles / trades / catalog / indicators(SMA、EMA、RSI、MACD、布林带、ATR、Stochastic、ADX/DMI、OBV、支撑阻力,以及图上均线或指定均线的最新值) |
|
|
112
|
-
| `hyper_chart` | 在会话图表上添加、修改(几何 / 颜色 / 线宽 / 线型 / 锁定 / 隐藏)或删除画线(
|
|
112
|
+
| `hyper_chart` | 在会话图表上添加、修改(几何 / 颜色 / 线宽 / 线型 / 锁定 / 隐藏)或删除画线(77 种,含固定范围成交量分布、斐波那契、江恩、叉子线、回归、艾略特与谐波形态、标注与多空头寸;可设置同步到所有会话与价格提醒)和均线(SMA / EMA / SMMA / WMA,可选平滑);`action=view` 切换图表周期并显示 / 隐藏 RSI、MACD 等副图指标 |
|
|
113
113
|
| `hyper_account` | 账户:state / orders / fills / orderStatus(支持 oid、cloid)/ review(窗口证据、成本及订单核对) |
|
|
114
114
|
| `hyper_decide` | 实盘预检:提交交易意图与依据,返回 30 秒内有效的一次性 `decisionId` |
|
|
115
115
|
| `hyper_order` | place / cancel / leverage;实盘下单必须带匹配的 `decisionId`,可附带止盈止损(目前仅测试网) |
|
package/client.js
CHANGED
|
@@ -980,6 +980,14 @@ body:has(.dhl-divider.dragging) * { cursor: col-resize !important; }
|
|
|
980
980
|
.dhl-drawing .dhl-ghost-up { fill: color-mix(in srgb, var(--dsw-alias-state-success-primary) 45%, transparent); stroke: var(--dsw-alias-state-success-primary); stroke-width: 1; opacity: .7; }
|
|
981
981
|
.dhl-drawing .dhl-ghost-down { fill: color-mix(in srgb, var(--dsw-alias-state-error-primary) 45%, transparent); stroke: var(--dsw-alias-state-error-primary); stroke-width: 1; opacity: .7; }
|
|
982
982
|
.dhl-drawing-hit .dhl-ghost path, .dhl-drawing-hit .dhl-sector { pointer-events: all; }
|
|
983
|
+
|
|
984
|
+
/* 0.5.3: tables and screen-pinned annotations. */
|
|
985
|
+
.dhl-drawing .dhl-table-rule { stroke: currentColor; stroke-width: 1; opacity: .35; }
|
|
986
|
+
.dhl-drawing .dhl-table-head { font-weight: 650; }
|
|
987
|
+
.dhl-drawing-hit .dhl-table-box { pointer-events: all; }
|
|
988
|
+
|
|
989
|
+
/* 0.5.4: Gann square fixed grid. */
|
|
990
|
+
.dhl-drawing .dhl-gann-grid { stroke: currentColor; stroke-width: 1; opacity: .35; }
|
|
983
991
|
`;
|
|
984
992
|
|
|
985
993
|
// src/client/locale.ts
|
|
@@ -17759,8 +17767,14 @@ var DRAWING_POINTS = {
|
|
|
17759
17767
|
barspattern: 3,
|
|
17760
17768
|
// Projection (TradingView's sector: origin, a future point, an estimated price); ghost feed is drawn like a path.
|
|
17761
17769
|
projection: 3,
|
|
17762
|
-
ghostfeed: 0
|
|
17770
|
+
ghostfeed: 0,
|
|
17771
|
+
// Screen-anchored text (TradingView's anchored text) and a table (cells split by |, rows by ; or a new line).
|
|
17772
|
+
anchoredtext: 1,
|
|
17773
|
+
table: 1,
|
|
17774
|
+
// Gann square fixed: always square on screen, 5×5 units (TradingView Charting Library defaults).
|
|
17775
|
+
gannfixed: 2
|
|
17763
17776
|
};
|
|
17777
|
+
var SCREEN_KINDS = ["anchoredtext", "table"];
|
|
17764
17778
|
var FREEHAND_KINDS = ["brush", "highlighter"];
|
|
17765
17779
|
var MULTI_KINDS = ["path", "polyline", "ghostfeed"];
|
|
17766
17780
|
var PATH_MAX = 50;
|
|
@@ -17775,7 +17789,7 @@ function isSingleEmoji(value) {
|
|
|
17775
17789
|
if (typeof value !== "string" || !value || value.length > 32 || !/\p{Extended_Pictographic}|\p{Regional_Indicator}/u.test(value)) return false;
|
|
17776
17790
|
return [...new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(value)].length === 1;
|
|
17777
17791
|
}
|
|
17778
|
-
var FONT_KINDS = ["text", "callout", "note", "pricenote", "signpost"];
|
|
17792
|
+
var FONT_KINDS = ["text", "callout", "note", "pricenote", "signpost", "anchoredtext", "table"];
|
|
17779
17793
|
var FILL_KINDS = ["rect", "circle", "triangle", "channel", "fib", "regression", "gannbox", "pricerange", "daterange", "measure", "flatchannel", "disjoint", "ellipse", "rotrect"];
|
|
17780
17794
|
var FIB_LEVEL_KINDS = ["fib", "fibext", "fibchannel"];
|
|
17781
17795
|
function volumeProfile(bars, { rows = 48, valueArea = 0.7 } = {}) {
|
|
@@ -17822,7 +17836,7 @@ var GANN_BOX_LEVELS = [0, 0.25, 0.382, 0.5, 0.618, 0.75, 1];
|
|
|
17822
17836
|
var ALERT_KINDS = ["level", "hray", "trend", "ray", "extended"];
|
|
17823
17837
|
var BRUSH_MIN = 2;
|
|
17824
17838
|
var BRUSH_MAX = 500;
|
|
17825
|
-
var TEXT_KINDS = ["text", "callout", "note", "pricenote", "signpost", "pin"];
|
|
17839
|
+
var TEXT_KINDS = ["text", "callout", "note", "pricenote", "signpost", "pin", "anchoredtext", "table"];
|
|
17826
17840
|
var DRAWING_CLICKS = { ...Object.fromEntries(Object.entries(DRAWING_POINTS)), long: 2, short: 2 };
|
|
17827
17841
|
var DRAWING_KINDS = Object.keys(DRAWING_POINTS);
|
|
17828
17842
|
var FIB_LEVELS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1];
|
|
@@ -17909,6 +17923,7 @@ var DRAWING_TOOLS = [
|
|
|
17909
17923
|
{ group: "fib", kind: "fibspiral", zh: "\u6590\u6CE2\u90A3\u5951\u87BA\u65CB", en: "Fib spiral", hintZh: "\u70B9\u51FB\u4E2D\u5FC3\uFF0C\u518D\u70B9\u51FB\u786E\u5B9A\u8D77\u59CB\u534A\u5F84\u4E0E\u65B9\u5411\uFF08\u6BCF\u56DB\u5206\u4E4B\u4E00\u5708\u653E\u5927 1.618 \u500D\uFF09", hintEn: "Click the center, then the starting radius (grows 1.618\xD7 per quarter turn)", icon: "M12 12a2 2 0 1 1 2-2c0 3-3 5-6 4s-5-5-3-8 7-5 10-3 5 7 3 11" },
|
|
17910
17924
|
{ group: "fib", kind: "gannbox", zh: "\u6C5F\u6069\u7BB1", en: "Gann box", hintZh: "\u70B9\u51FB\u4E24\u4E2A\u5BF9\u89D2\uFF0C\u6309 0.25/0.382/0.5/0.618/0.75 \u5206\u5272", hintEn: "Click two corners; divided at Gann levels", icon: "M4 4h16v16H4zM4 12h16M12 4v16M4 4l16 16" },
|
|
17911
17925
|
{ group: "fib", kind: "gannsquare", zh: "\u6C5F\u6069\u65B9\u683C", en: "Gann square", hintZh: "\u70B9\u51FB\u4E24\u4E2A\u5BF9\u89D2\uFF0C\u753B\u56DB\u5206\u7F51\u683C\u3001\u5BF9\u89D2\u7EBF\u4E0E\u6247\u7EBF", hintEn: "Click two corners; quarters, diagonals and fans", icon: "M4 4h16v16H4zM4 4l16 16M20 4 4 20M4 12h16M12 4v16" },
|
|
17926
|
+
{ group: "fib", kind: "gannfixed", zh: "\u56FA\u5B9A\u6C5F\u6069\u65B9\u683C", en: "Gann square fixed", hintZh: "\u70B9\u51FB\u539F\u70B9\uFF0C\u518D\u70B9\u51FB\u786E\u5B9A\u5927\u5C0F\uFF1B\u59CB\u7EC8\u4E3A\u6B63\u65B9\u5F62\uFF0C5\xD75 \u7F51\u683C\u3001\u5F27\u7EBF\u4E0E 2\xD71/1\xD71/1\xD72 \u6247\u7EBF", hintEn: "Click the origin, then the size; always square, 5\xD75 grid, arcs and 2\xD71/1\xD71/1\xD72 fans", icon: "M4 4h16v16H4zM4 20a16 16 0 0 1 16-16M4 20 20 4M4 20l16-8M4 20 12 4" },
|
|
17912
17927
|
{ group: "fib", kind: "gannfan", zh: "\u6C5F\u6069\u6247\u5F62", en: "Gann fan", hintZh: "\u70B9\u51FB\u539F\u70B9\uFF0C\u518D\u70B9\u51FB\u786E\u5B9A 1\xD71 \u7EBF", hintEn: "Click the origin, then a point on the 1\xD71 line", icon: "M3 21 21 3M3 21 21 12M3 21 12 3M3 21h18" },
|
|
17913
17928
|
{ group: "patterns", kind: "elliott", zh: "\u827E\u7565\u7279\u63A8\u52A8\u6D6A", en: "Elliott impulse wave", hintZh: "\u4F9D\u6B21\u70B9\u51FB 0\u30011\u30012\u30013\u30014\u30015 \u516D\u4E2A\u70B9", hintEn: "Click points 0 through 5", icon: "M2 18 6 10l3 4 5-10 3 6 5-6" },
|
|
17914
17929
|
{ group: "patterns", kind: "elliottabc", zh: "\u827E\u7565\u7279\u8C03\u6574\u6D6A", en: "Elliott correction wave", hintZh: "\u4F9D\u6B21\u70B9\u51FB 0\u3001A\u3001B\u3001C \u56DB\u4E2A\u70B9", hintEn: "Click 0, A, B, C", icon: "M3 6l6 10 5-6 7 10" },
|
|
@@ -17939,6 +17954,8 @@ var DRAWING_TOOLS = [
|
|
|
17939
17954
|
{ group: "annotation", kind: "note", zh: "\u4FBF\u7B7E", en: "Note", hintZh: "\u5355\u51FB\u4F4D\u7F6E\u540E\u8F93\u5165\u4FBF\u7B7E\u5185\u5BB9", hintEn: "Click a spot, then type the note", icon: "M5 4h14v11l-5 5H5zM14 20v-5h5" },
|
|
17940
17955
|
{ group: "annotation", kind: "pricenote", zh: "\u4EF7\u683C\u4FBF\u7B7E", en: "Price note", hintZh: "\u70B9\u51FB\u8981\u6807\u6CE8\u7684\u4EF7\u683C\uFF0C\u518D\u70B9\u51FB\u4FBF\u7B7E\u4F4D\u7F6E\uFF0C\u7136\u540E\u8F93\u5165\u6587\u5B57", hintEn: "Click the price, then the note position, then type", icon: "M3 16h6M9 16l4-6h8v8h-8z" },
|
|
17941
17956
|
{ group: "annotation", kind: "signpost", zh: "\u8DEF\u6807", en: "Signpost", hintZh: "\u5355\u51FB K \u7EBF\u4F4D\u7F6E\u540E\u8F93\u5165\u8DEF\u6807\u6587\u5B57", hintEn: "Click a bar, then type the signpost text", icon: "M8 21V4M8 4h11l-2 3 2 3H8" },
|
|
17957
|
+
{ group: "annotation", kind: "anchoredtext", zh: "\u951A\u5B9A\u6587\u672C", en: "Anchored text", hintZh: "\u5355\u51FB\u4F4D\u7F6E\u540E\u8F93\u5165\u6587\u5B57\uFF1B\u56FA\u5B9A\u5728\u5C4F\u5E55\u4E0A\uFF0C\u5E73\u79FB\u56FE\u8868\u65F6\u4E0D\u52A8", hintEn: "Click a spot, then type; pinned to the screen while the chart scrolls", icon: "M5 6h14M12 6v13M9 19h6M18 15l3 3-3 3" },
|
|
17958
|
+
{ group: "annotation", kind: "table", zh: "\u8868\u683C", en: "Table", hintZh: "\u5355\u51FB\u4F4D\u7F6E\u540E\u8F93\u5165\u5185\u5BB9\uFF1A| \u5206\u9694\u5355\u5143\u683C\uFF0C; \u5206\u9694\u884C\uFF1B\u53EF\u5728\u5DE5\u5177\u6761\u56FA\u5B9A\u5230\u5C4F\u5E55", hintEn: "Click, then type: | between cells, ; between rows; pin it from the toolbar", icon: "M4 5h16v14H4zM4 10h16M4 15h16M10 5v14" },
|
|
17942
17959
|
{ group: "annotation", kind: "pin", zh: "\u56FE\u9489", en: "Pin", hintZh: "\u5355\u51FB\u4F4D\u7F6E\u540E\u8F93\u5165\u8BF4\u660E\uFF0C\u56FE\u4E0A\u663E\u793A\u56FE\u9489\u548C\u8BF4\u660E", hintEn: "Click a spot, then type; shows a pin with its note", icon: "M12 21s-6-5.6-6-10a6 6 0 0 1 12 0c0 4.4-6 10-6 10zM12 8.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5z" },
|
|
17943
17960
|
{ group: "annotation", kind: "pricelabel", zh: "\u4EF7\u683C\u6807\u7B7E", en: "Price label", hintZh: "\u5355\u51FB\u5728\u8BE5\u4EF7\u683C\u5904\u653E\u7F6E\u6807\u7B7E", hintEn: "Click to tag a price", icon: "M3 12l5-6h13v12H8z" },
|
|
17944
17961
|
{ group: "annotation", kind: "icon", zh: "\u56FE\u6807", en: "Icon", hintZh: "\u5355\u51FB\u4F4D\u7F6E\u540E\u9009\u62E9\u56FE\u6807", hintEn: "Click a spot, then pick an icon", icon: "M12 3l2.6 5.6 6 .7-4.5 4.1 1.2 6L12 16.6 6.7 19.4l1.2-6L3.4 9.3l6-.7z" },
|
|
@@ -18091,6 +18108,9 @@ function regressionFit(bars) {
|
|
|
18091
18108
|
const variance = bars.reduce((sum, bar, i) => sum + (bar.price - (intercept + slope * i)) ** 2, 0) / n2;
|
|
18092
18109
|
return { slope, intercept, sigma: Math.sqrt(variance) };
|
|
18093
18110
|
}
|
|
18111
|
+
function tableRows(value) {
|
|
18112
|
+
return value.split(/[;\n]/).map((row) => row.split("|").map((cell) => cell.trim())).filter((row) => row.some(Boolean)).slice(0, 12).map((row) => row.slice(0, 8));
|
|
18113
|
+
}
|
|
18094
18114
|
function wave(p, labels, text) {
|
|
18095
18115
|
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("polyline", { className: "dhl-pattern", points: p.map((point) => `${point.x},${point.y}`).join(" ") }), p.map((point, index) => {
|
|
18096
18116
|
const up = index === 0 ? p[1] ? p[1].y > point.y : true : point.y < p[index - 1].y;
|
|
@@ -18103,11 +18123,12 @@ function guide(a, b, value, key3, text) {
|
|
|
18103
18123
|
}
|
|
18104
18124
|
var BADGE_PATHS = { alert: "M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0", shared: "M4 9h13l-3-3M20 15H7l3 3" };
|
|
18105
18125
|
var DASH = { solid: void 0, dashed: "7 5", dotted: "1.5 4" };
|
|
18106
|
-
var DrawingShape = React7.memo(function DrawingShape2({ kind, points: points2, label, text: textValue, className, view, anchors = false, interactive = false, color, lineWidth, lineStyle, id, alert, shared, rows, valueArea, levels, fontSize, bold, italic, fillOpacity, extendLeft, extendRight }) {
|
|
18126
|
+
var DrawingShape = React7.memo(function DrawingShape2({ kind, points: points2, label, text: textValue, className, view, anchors = false, interactive = false, color, lineWidth, lineStyle, id, alert, shared, rows, valueArea, levels, fontSize, bold, italic, fillOpacity, extendLeft, extendRight, screenX, screenY }) {
|
|
18107
18127
|
const k = (fontSize ?? 12) / 12;
|
|
18108
18128
|
const badges = [...alert ? ["alert"] : [], ...shared ? ["shared"] : []];
|
|
18109
18129
|
const { width: w, height: h } = view;
|
|
18110
|
-
const
|
|
18130
|
+
const pinned = screenX != null && screenY != null;
|
|
18131
|
+
const px = pinned ? [{ x: screenX * w, y: screenY * h }] : points2.map((point) => view.project(point.time, point.price));
|
|
18111
18132
|
if (!px.length || px.some((point) => point == null)) return null;
|
|
18112
18133
|
const p = px;
|
|
18113
18134
|
const text = (x, y, value, anchor = "start", cls = "dhl-drawing-text") => /* @__PURE__ */ React7.createElement("text", { className: cls, x, y, textAnchor: anchor }, value);
|
|
@@ -18239,6 +18260,28 @@ var DrawingShape = React7.memo(function DrawingShape2({ kind, points: points2, l
|
|
|
18239
18260
|
body = /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("polyline", { className: "dhl-pattern", points: p.map((point) => `${point.x},${point.y}`).join(" ") }), kind === "path" ? /* @__PURE__ */ React7.createElement("polygon", { className: "dhl-arrow-head", points: arrowHead(p[p.length - 2], p[p.length - 1]) }) : null);
|
|
18240
18261
|
break;
|
|
18241
18262
|
}
|
|
18263
|
+
case "anchoredtext": {
|
|
18264
|
+
const value = textValue || label || tr("\u951A\u5B9A\u6587\u672C", "Anchored text");
|
|
18265
|
+
const lines = wrapText(value, 300);
|
|
18266
|
+
const width = (14 + Math.max(...lines.map(textWidth))) * k;
|
|
18267
|
+
body = /* @__PURE__ */ React7.createElement("g", { className: pinned ? "dhl-anchored" : void 0 }, /* @__PURE__ */ React7.createElement("rect", { className: "dhl-text-box", x: p[0].x, y: p[0].y - 20 * k, width, height: (8 + lines.length * 16) * k, rx: "4" }), lines.map((line, index) => /* @__PURE__ */ React7.createElement(React7.Fragment, { key: index }, text(p[0].x + 7 * k, p[0].y + (-4 + index * 16) * k, line, "start", "dhl-drawing-text dhl-text-value"))));
|
|
18268
|
+
handles = [p[0]];
|
|
18269
|
+
break;
|
|
18270
|
+
}
|
|
18271
|
+
case "table": {
|
|
18272
|
+
const rows2 = tableRows(textValue || label || "");
|
|
18273
|
+
if (!rows2.length) break;
|
|
18274
|
+
const cols = Math.max(...rows2.map((row) => row.length));
|
|
18275
|
+
const widths = Array.from({ length: cols }, (_, c) => (16 + Math.max(...rows2.map((row) => textWidth(row[c] ?? "")))) * k);
|
|
18276
|
+
const rowH = 22 * k, x0 = p[0].x, y0 = p[0].y;
|
|
18277
|
+
const total = widths.reduce((sum, value) => sum + value, 0);
|
|
18278
|
+
body = /* @__PURE__ */ React7.createElement("g", { className: "dhl-table", "data-rows": rows2.length, "data-cols": cols }, /* @__PURE__ */ React7.createElement("rect", { className: "dhl-text-box dhl-table-box", x: x0, y: y0, width: total, height: rows2.length * rowH, rx: "3" }), rows2.map((_, r) => r > 0 ? /* @__PURE__ */ React7.createElement("line", { key: `r${r}`, className: "dhl-table-rule", x1: x0, x2: x0 + total, y1: y0 + r * rowH, y2: y0 + r * rowH }) : null), widths.slice(0, -1).map((_, c) => {
|
|
18279
|
+
const x = x0 + widths.slice(0, c + 1).reduce((sum, value) => sum + value, 0);
|
|
18280
|
+
return /* @__PURE__ */ React7.createElement("line", { key: `c${c}`, className: "dhl-table-rule", x1: x, x2: x, y1: y0, y2: y0 + rows2.length * rowH });
|
|
18281
|
+
}), rows2.flatMap((row, r) => row.map((cell, c) => /* @__PURE__ */ React7.createElement(React7.Fragment, { key: `${r}-${c}` }, text(x0 + widths.slice(0, c).reduce((sum, value) => sum + value, 0) + 8 * k, y0 + r * rowH + 15 * k, cell, "start", r === 0 ? "dhl-drawing-text dhl-text-value dhl-table-head" : "dhl-drawing-text dhl-text-value")))));
|
|
18282
|
+
handles = [p[0]];
|
|
18283
|
+
break;
|
|
18284
|
+
}
|
|
18242
18285
|
case "pin": {
|
|
18243
18286
|
const value = textValue || label || tr("\u56FE\u9489", "Pin");
|
|
18244
18287
|
const lines = wrapText(value, 220);
|
|
@@ -18421,6 +18464,27 @@ var DrawingShape = React7.memo(function DrawingShape2({ kind, points: points2, l
|
|
|
18421
18464
|
body = /* @__PURE__ */ React7.createElement(React7.Fragment, null, p[4] ? /* @__PURE__ */ React7.createElement("polygon", { className: "dhl-drawing-fill", points: `${p[2].x},${p[2].y} ${p[3].x},${p[3].y} ${p[4].x},${p[4].y}` }) : null, wave(p, names, text), neck ? /* @__PURE__ */ React7.createElement("line", { className: "dhl-neckline", x1: neck[0].x, y1: neck[0].y, x2: neck[1].x, y2: neck[1].y }) : null);
|
|
18422
18465
|
break;
|
|
18423
18466
|
}
|
|
18467
|
+
case "gannfixed": {
|
|
18468
|
+
if (!p[1]) break;
|
|
18469
|
+
const side2 = Math.max(Math.abs(p[1].x - p[0].x), Math.abs(p[1].y - p[0].y));
|
|
18470
|
+
if (side2 < 4) break;
|
|
18471
|
+
const sx = p[1].x >= p[0].x ? 1 : -1, sy = p[1].y >= p[0].y ? 1 : -1, unit = side2 / 5;
|
|
18472
|
+
const at = (ux, uy) => ({ x: p[0].x + sx * ux * unit, y: p[0].y + sy * uy * unit });
|
|
18473
|
+
const far = at(5, 5);
|
|
18474
|
+
const arcs = [[1, 0], [1, 1], [1.5, 0], [2, 0], [2, 1], [3, 0], [3, 1], [4, 0], [4, 1], [5, 0], [5, 1]];
|
|
18475
|
+
const sweep = sx * sy > 0 ? 1 : 0;
|
|
18476
|
+
body = /* @__PURE__ */ React7.createElement("g", { className: "dhl-gann-fixed" }, /* @__PURE__ */ React7.createElement("rect", { className: "dhl-drawing-mid", x: Math.min(p[0].x, far.x), y: Math.min(p[0].y, far.y), width: side2, height: side2, fill: "none" }), [0, 1, 2, 3, 4, 5].map((n2) => /* @__PURE__ */ React7.createElement("g", { key: `l${n2}` }, /* @__PURE__ */ React7.createElement("line", { className: "dhl-gann-grid", x1: at(n2, 0).x, y1: at(n2, 0).y, x2: at(n2, 5).x, y2: at(n2, 5).y }), /* @__PURE__ */ React7.createElement("line", { className: "dhl-gann-grid", x1: at(0, n2).x, y1: at(0, n2).y, x2: at(5, n2).x, y2: at(5, n2).y }))), arcs.map(([ux, uy]) => {
|
|
18477
|
+
const r = Math.hypot(ux, uy) * unit;
|
|
18478
|
+
if (r > side2 * 1.0001) return null;
|
|
18479
|
+
const start = at(Math.hypot(ux, uy), 0), end = at(0, Math.hypot(ux, uy));
|
|
18480
|
+
return /* @__PURE__ */ React7.createElement("path", { key: `a${ux}-${uy}`, className: "dhl-fib-ring", d: `M${start.x} ${start.y}A${r} ${r} 0 0 ${sweep} ${end.x} ${end.y}` });
|
|
18481
|
+
}), [[2, 1], [1, 1], [1, 2]].map(([ux, uy]) => {
|
|
18482
|
+
const end = ux >= uy ? at(5, 5 * uy / ux) : at(5 * ux / uy, 5);
|
|
18483
|
+
return /* @__PURE__ */ React7.createElement("g", { key: `f${ux}x${uy}` }, /* @__PURE__ */ React7.createElement("line", { className: ux === uy ? "dhl-fib-key" : void 0, x1: p[0].x, y1: p[0].y, x2: end.x, y2: end.y }), text(end.x + sx * 3, end.y, `${ux}\xD7${uy}`, sx > 0 ? "start" : "end"));
|
|
18484
|
+
}));
|
|
18485
|
+
handles = [p[0], far];
|
|
18486
|
+
break;
|
|
18487
|
+
}
|
|
18424
18488
|
case "gannbox":
|
|
18425
18489
|
case "gannsquare": {
|
|
18426
18490
|
if (!p[1]) break;
|
|
@@ -18766,7 +18830,7 @@ function saveStyleTemplate(kind, style) {
|
|
|
18766
18830
|
// src/client/components/draw-toolbar.tsx
|
|
18767
18831
|
var DRAW_COLORS = ["#4c82d8", "#2fd3a0", "#ef5f6c", "#e2a943", "#9b86db", "#26b5c8", "#8a8f98"];
|
|
18768
18832
|
var STYLES = [["solid", "\u5B9E\u7EBF", "Solid"], ["dashed", "\u865A\u7EBF", "Dashed"], ["dotted", "\u70B9\u7EBF", "Dotted"]];
|
|
18769
|
-
function DrawToolbar({ mark, globallyLocked, onEdit, onRemove, onClose, onClone, onCoordinates, placement = "top" }) {
|
|
18833
|
+
function DrawToolbar({ mark, globallyLocked, onEdit, onRemove, onClose, onClone, onCoordinates, placement = "top", onTogglePin }) {
|
|
18770
18834
|
const [savedDefault, setSavedDefault] = React8.useState(false);
|
|
18771
18835
|
React8.useEffect(() => {
|
|
18772
18836
|
setSavedDefault(false);
|
|
@@ -18867,7 +18931,19 @@ function DrawToolbar({ mark, globallyLocked, onEdit, onRemove, onClose, onClone,
|
|
|
18867
18931
|
},
|
|
18868
18932
|
onBlur: applyLevels
|
|
18869
18933
|
}
|
|
18870
|
-
)) : null, mark.kind === "vprofile" ? /* @__PURE__ */ React8.createElement("span", { className: "dhl-draw-toolbar-group", role: "group", "aria-label": tr("\u6210\u4EA4\u91CF\u5206\u5E03\u8BBE\u7F6E", "Volume profile settings") }, /* @__PURE__ */ React8.createElement(Select, { "aria-label": tr("\u4EF7\u683C\u884C\u6570", "Rows"), title: tr("\u4EF7\u683C\u884C\u6570", "Rows"), value: String(mark.rows ?? 48), disabled: locked, onChange: (event) => onEdit({ rows: Number(event.target.value) }) }, [24, 48, 96, 150].map((value) => /* @__PURE__ */ React8.createElement("option", { key: value, value }, tr(`${value} \u884C`, `${value} rows`)))), /* @__PURE__ */ React8.createElement(Select, { "aria-label": tr("\u4EF7\u503C\u533A\u6BD4\u4F8B", "Value area"), title: tr("\u4EF7\u503C\u533A\u6210\u4EA4\u91CF\u5360\u6BD4", "Value area volume"), value: String(mark.valueArea ?? 0.7), disabled: locked, onChange: (event) => onEdit({ valueArea: Number(event.target.value) }) }, [0.68, 0.7, 0.8].map((value) => /* @__PURE__ */ React8.createElement("option", { key: value, value }, `VA ${Math.round(value * 100)}%`)))) : null, /* @__PURE__ */ React8.createElement("span", { className: "dhl-draw-toolbar-group" }, /* @__PURE__ */ React8.createElement(
|
|
18934
|
+
)) : null, mark.kind === "vprofile" ? /* @__PURE__ */ React8.createElement("span", { className: "dhl-draw-toolbar-group", role: "group", "aria-label": tr("\u6210\u4EA4\u91CF\u5206\u5E03\u8BBE\u7F6E", "Volume profile settings") }, /* @__PURE__ */ React8.createElement(Select, { "aria-label": tr("\u4EF7\u683C\u884C\u6570", "Rows"), title: tr("\u4EF7\u683C\u884C\u6570", "Rows"), value: String(mark.rows ?? 48), disabled: locked, onChange: (event) => onEdit({ rows: Number(event.target.value) }) }, [24, 48, 96, 150].map((value) => /* @__PURE__ */ React8.createElement("option", { key: value, value }, tr(`${value} \u884C`, `${value} rows`)))), /* @__PURE__ */ React8.createElement(Select, { "aria-label": tr("\u4EF7\u503C\u533A\u6BD4\u4F8B", "Value area"), title: tr("\u4EF7\u503C\u533A\u6210\u4EA4\u91CF\u5360\u6BD4", "Value area volume"), value: String(mark.valueArea ?? 0.7), disabled: locked, onChange: (event) => onEdit({ valueArea: Number(event.target.value) }) }, [0.68, 0.7, 0.8].map((value) => /* @__PURE__ */ React8.createElement("option", { key: value, value }, `VA ${Math.round(value * 100)}%`)))) : null, /* @__PURE__ */ React8.createElement("span", { className: "dhl-draw-toolbar-group" }, onTogglePin ? /* @__PURE__ */ React8.createElement(
|
|
18935
|
+
"button",
|
|
18936
|
+
{
|
|
18937
|
+
type: "button",
|
|
18938
|
+
className: mark.screenX != null ? "on" : "",
|
|
18939
|
+
"aria-pressed": mark.screenX != null,
|
|
18940
|
+
disabled: locked,
|
|
18941
|
+
"aria-label": mark.screenX != null ? tr("\u53D6\u6D88\u56FA\u5B9A\u5230\u5C4F\u5E55", "Unpin from the screen") : tr("\u56FA\u5B9A\u5230\u5C4F\u5E55", "Pin to the screen"),
|
|
18942
|
+
title: mark.screenX != null ? tr("\u53D6\u6D88\u56FA\u5B9A\uFF1A\u56DE\u5230\u56FE\u4E0A\u5F53\u524D\u4F4D\u7F6E\u5BF9\u5E94\u7684\u65F6\u95F4\u548C\u4EF7\u683C", "Unpin: attach to the time and price under it") : tr("\u56FA\u5B9A\u5728\u5C4F\u5E55\u5F53\u524D\u4F4D\u7F6E\uFF0C\u5E73\u79FB\u56FE\u8868\u65F6\u4E0D\u52A8", "Pin to this spot on screen while the chart scrolls"),
|
|
18943
|
+
onClick: onTogglePin
|
|
18944
|
+
},
|
|
18945
|
+
/* @__PURE__ */ React8.createElement("svg", { viewBox: "0 0 24 24", width: "15", height: "15", fill: "none", stroke: "currentColor", strokeWidth: "1.8", "aria-hidden": "true" }, /* @__PURE__ */ React8.createElement("path", { d: "M9 4h6l-1 6 3 3H7l3-3zM12 13v7" }))
|
|
18946
|
+
) : null, /* @__PURE__ */ React8.createElement(
|
|
18871
18947
|
"button",
|
|
18872
18948
|
{
|
|
18873
18949
|
type: "button",
|
|
@@ -19481,6 +19557,11 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
19481
19557
|
onDrawRef.current({ kind: "level", price: point.price });
|
|
19482
19558
|
return;
|
|
19483
19559
|
}
|
|
19560
|
+
if (mode === "anchoredtext") {
|
|
19561
|
+
const v = viewRef.current, at = v?.project(point.time, point.price);
|
|
19562
|
+
onDrawRef.current({ kind: "anchoredtext", points: [point], ...v && at && v.width && v.height ? { screenX: Math.min(1, Math.max(0, at.x / v.width)), screenY: Math.min(1, Math.max(0, at.y / v.height)) } : {} });
|
|
19563
|
+
return;
|
|
19564
|
+
}
|
|
19484
19565
|
if (isMultiKind(mode)) {
|
|
19485
19566
|
const now = performance.now(), here = { x: event.clientX, y: event.clientY };
|
|
19486
19567
|
const near = (other, within = Infinity) => Boolean(other && now - other.at < within && Math.hypot(here.x - other.x, here.y - other.y) <= 6);
|
|
@@ -19567,6 +19648,31 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
19567
19648
|
box.addEventListener("pointerdown", scaleDown, { passive: true });
|
|
19568
19649
|
box.addEventListener("pointermove", scaleDrag, { passive: true });
|
|
19569
19650
|
box.addEventListener("wheel", refreshOverlay, { passive: true });
|
|
19651
|
+
const forwardWheel = (event) => {
|
|
19652
|
+
const target = event.target;
|
|
19653
|
+
if (!target?.closest?.(".dhl-chart-drawing-overlay")) return;
|
|
19654
|
+
const canvas = document.elementsFromPoint(event.clientX, event.clientY).find((element) => element instanceof HTMLCanvasElement && box.contains(element));
|
|
19655
|
+
if (!canvas) return;
|
|
19656
|
+
event.preventDefault();
|
|
19657
|
+
event.stopPropagation();
|
|
19658
|
+
canvas.dispatchEvent(new WheelEvent("wheel", {
|
|
19659
|
+
deltaX: event.deltaX,
|
|
19660
|
+
deltaY: event.deltaY,
|
|
19661
|
+
deltaZ: event.deltaZ,
|
|
19662
|
+
deltaMode: event.deltaMode,
|
|
19663
|
+
clientX: event.clientX,
|
|
19664
|
+
clientY: event.clientY,
|
|
19665
|
+
screenX: event.screenX,
|
|
19666
|
+
screenY: event.screenY,
|
|
19667
|
+
ctrlKey: event.ctrlKey,
|
|
19668
|
+
metaKey: event.metaKey,
|
|
19669
|
+
shiftKey: event.shiftKey,
|
|
19670
|
+
altKey: event.altKey,
|
|
19671
|
+
bubbles: true,
|
|
19672
|
+
cancelable: true
|
|
19673
|
+
}));
|
|
19674
|
+
};
|
|
19675
|
+
box.addEventListener("wheel", forwardWheel, { capture: true, passive: false });
|
|
19570
19676
|
box.addEventListener("dblclick", refreshOverlay);
|
|
19571
19677
|
const sizeObserver = new ResizeObserver(refreshOverlay);
|
|
19572
19678
|
sizeObserver.observe(box);
|
|
@@ -19621,6 +19727,7 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
19621
19727
|
endCanvasGesture();
|
|
19622
19728
|
box.removeEventListener("pointerdown", scaleDown);
|
|
19623
19729
|
box.removeEventListener("wheel", refreshOverlay);
|
|
19730
|
+
box.removeEventListener("wheel", forwardWheel, { capture: true });
|
|
19624
19731
|
box.removeEventListener("dblclick", refreshOverlay);
|
|
19625
19732
|
sizeObserver.disconnect();
|
|
19626
19733
|
if (viewportFrame) cancelAnimationFrame(viewportFrame);
|
|
@@ -20043,6 +20150,20 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
20043
20150
|
barMs: candlesRef.current.length > 1 ? candlesRef.current[1].t - candlesRef.current[0].t : void 0
|
|
20044
20151
|
};
|
|
20045
20152
|
}, [viewportVersion, timeline, themeVersion, expanded, indicators, priceScale]);
|
|
20153
|
+
const viewRef = React10.useRef(view);
|
|
20154
|
+
viewRef.current = view;
|
|
20155
|
+
const pinPatch = (mark) => {
|
|
20156
|
+
const v = viewRef.current, api = refs.current;
|
|
20157
|
+
if (!v || !api || !v.width || !v.height) return null;
|
|
20158
|
+
if (mark.screenX != null && mark.screenY != null) {
|
|
20159
|
+
const logical = api.chart.timeScale().coordinateToLogical(mark.screenX * v.width);
|
|
20160
|
+
const price = Number(api.candles.coordinateToPrice(mark.screenY * v.height));
|
|
20161
|
+
if (logical == null || !Number.isFinite(price) || price <= 0) return { screenX: null, screenY: null };
|
|
20162
|
+
return { screenX: null, screenY: null, points: [{ time: timelineRef.current.toTime(Number(logical)), price }] };
|
|
20163
|
+
}
|
|
20164
|
+
const at = v.project(markPoints(mark)[0].time, markPoints(mark)[0].price);
|
|
20165
|
+
return at ? { screenX: Math.min(1, Math.max(0, at.x / v.width)), screenY: Math.min(1, Math.max(0, at.y / v.height)) } : null;
|
|
20166
|
+
};
|
|
20046
20167
|
React10.useEffect(() => {
|
|
20047
20168
|
if (selectedId && !markById.has(selectedId)) setSelectedId(null);
|
|
20048
20169
|
}, [markById, selectedId]);
|
|
@@ -20117,6 +20238,7 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
20117
20238
|
const abortGesture = React10.useRef(null);
|
|
20118
20239
|
React10.useEffect(() => () => abortGesture.current?.(), []);
|
|
20119
20240
|
const [brushPoints, setBrushPoints] = React10.useState([]);
|
|
20241
|
+
const [screenDraft, setScreenDraft] = React10.useState(null);
|
|
20120
20242
|
const beginBrush = (event, freehandKind) => {
|
|
20121
20243
|
const snap = snapRef.current;
|
|
20122
20244
|
const first = snap?.(event.nativeEvent, void 0, false);
|
|
@@ -20253,7 +20375,7 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
20253
20375
|
const startGroup = snapGroup(event.nativeEvent, void 0, false);
|
|
20254
20376
|
if (!startGroup) return;
|
|
20255
20377
|
const line2 = timelineRef.current, startLogical2 = line2.toLogical(startGroup.time);
|
|
20256
|
-
const originals = new Map(groupRef.current.map((member) => markByIdRef.current.get(member)).filter((item) => Boolean(item) && !item.locked).map((item) => [item.id, item]));
|
|
20378
|
+
const originals = new Map(groupRef.current.map((member) => markByIdRef.current.get(member)).filter((item) => Boolean(item) && !item.locked && item.screenX == null).map((item) => [item.id, item]));
|
|
20257
20379
|
const origin2 = { x: event.clientX, y: event.clientY };
|
|
20258
20380
|
let moved2 = false, frame2 = 0, latest2 = null;
|
|
20259
20381
|
const compute2 = (ev) => {
|
|
@@ -20314,6 +20436,39 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
20314
20436
|
setSelectedId(id);
|
|
20315
20437
|
const snap = snapRef.current;
|
|
20316
20438
|
if (mark.locked || lockedRef.current || !snap) return;
|
|
20439
|
+
if (mark.screenX != null && mark.screenY != null) {
|
|
20440
|
+
const v = viewRef.current;
|
|
20441
|
+
if (!v || !v.width || !v.height) return;
|
|
20442
|
+
event.preventDefault();
|
|
20443
|
+
event.stopPropagation();
|
|
20444
|
+
const origin2 = { x: event.clientX, y: event.clientY }, sx = mark.screenX, sy = mark.screenY;
|
|
20445
|
+
let latest2 = null;
|
|
20446
|
+
const move2 = (ev) => {
|
|
20447
|
+
latest2 = { id, x: Math.min(1, Math.max(0, sx + (ev.clientX - origin2.x) / v.width)), y: Math.min(1, Math.max(0, sy + (ev.clientY - origin2.y) / v.height)) };
|
|
20448
|
+
setScreenDraft(latest2);
|
|
20449
|
+
};
|
|
20450
|
+
const detach2 = () => {
|
|
20451
|
+
window.removeEventListener("pointermove", move2);
|
|
20452
|
+
window.removeEventListener("pointerup", up2);
|
|
20453
|
+
window.removeEventListener("pointercancel", cancel2);
|
|
20454
|
+
abortGesture.current = null;
|
|
20455
|
+
};
|
|
20456
|
+
const cancel2 = () => {
|
|
20457
|
+
detach2();
|
|
20458
|
+
setScreenDraft(null);
|
|
20459
|
+
};
|
|
20460
|
+
const up2 = (ev) => {
|
|
20461
|
+
detach2();
|
|
20462
|
+
if (latest2 && Math.hypot(ev.clientX - origin2.x, ev.clientY - origin2.y) >= 3) onEditRef.current(id, { screenX: latest2.x, screenY: latest2.y });
|
|
20463
|
+
setScreenDraft(null);
|
|
20464
|
+
};
|
|
20465
|
+
abortGesture.current?.();
|
|
20466
|
+
abortGesture.current = cancel2;
|
|
20467
|
+
window.addEventListener("pointermove", move2);
|
|
20468
|
+
window.addEventListener("pointerup", up2);
|
|
20469
|
+
window.addEventListener("pointercancel", cancel2);
|
|
20470
|
+
return;
|
|
20471
|
+
}
|
|
20317
20472
|
const anchorAttr = target.getAttribute("data-anchor");
|
|
20318
20473
|
const anchor = anchorAttr == null ? null : Number(anchorAttr);
|
|
20319
20474
|
const startPoint = snap(event.nativeEvent, void 0, false);
|
|
@@ -20413,6 +20568,7 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
20413
20568
|
const paneCount = ["rsi14", "macd", "atr14", "stochastic", "adx", "obv"].filter((id) => indicators.has(id)).length;
|
|
20414
20569
|
return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement("div", { className: "dhl-chartbox", ref: boxRef, style: { height: expanded && !compact ? void 0 : (compact ? 310 : CHART_HEIGHT) + paneCount * (compact ? 65 : 125) } }, view ? /* @__PURE__ */ React10.createElement("svg", { className: "dhl-chart-drawing-overlay" + (drawMode ? " drawing" : "") + (drawMode && FREEHAND_KINDS.includes(drawMode) ? " brushing" : ""), "aria-hidden": "true", onPointerDown: beginDrag }, /* @__PURE__ */ React10.createElement("defs", null, /* @__PURE__ */ React10.createElement("clipPath", { id: clipId.current }, /* @__PURE__ */ React10.createElement("rect", { x: "0", y: "0", width: view.width, height: view.height })), /* @__PURE__ */ React10.createElement("marker", { id: `${clipId.current}-arrow`, viewBox: "0 0 10 10", refX: "8", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse" }, /* @__PURE__ */ React10.createElement("path", { d: "M0 0 10 5 0 10z", fill: "currentColor" }))), /* @__PURE__ */ React10.createElement("g", { clipPath: `url(#${clipId.current})` }, shapes.map(({ mark, points: points2 }) => {
|
|
20415
20570
|
const live = draft?.id === mark.id ? draft.points : groupDraft?.get(mark.id) ?? points2;
|
|
20571
|
+
const screen = screenDraft?.id === mark.id ? screenDraft : mark.screenX != null && mark.screenY != null ? { x: mark.screenX, y: mark.screenY } : null;
|
|
20416
20572
|
const shown = mark.kind === "level" ? [{ time: lastTime, price: live[0].price }] : live;
|
|
20417
20573
|
const selected = selectedId === mark.id || group.includes(mark.id);
|
|
20418
20574
|
if (interval && mark.visibleIntervals?.length && !mark.visibleIntervals.includes(interval)) return null;
|
|
@@ -20445,7 +20601,9 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
20445
20601
|
italic: mark.italic,
|
|
20446
20602
|
fillOpacity: mark.fillOpacity,
|
|
20447
20603
|
extendLeft: mark.extendLeft,
|
|
20448
|
-
extendRight: mark.extendRight
|
|
20604
|
+
extendRight: mark.extendRight,
|
|
20605
|
+
screenX: screen?.x,
|
|
20606
|
+
screenY: screen?.y
|
|
20449
20607
|
}
|
|
20450
20608
|
);
|
|
20451
20609
|
}), /* @__PURE__ */ React10.createElement("g", { className: "dhl-fills" }, fills.map((event) => {
|
|
@@ -20489,6 +20647,10 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
20489
20647
|
mark: selectedMark,
|
|
20490
20648
|
globallyLocked: drawingsLocked,
|
|
20491
20649
|
placement: toolbarPlacement(selectedMark),
|
|
20650
|
+
onTogglePin: SCREEN_KINDS.includes(selectedMark.kind) ? () => {
|
|
20651
|
+
const patch = pinPatch(selectedMark);
|
|
20652
|
+
if (patch) onEditMark(selectedMark.id, patch);
|
|
20653
|
+
} : void 0,
|
|
20492
20654
|
onCoordinates: () => setEditingId(selectedMark.id),
|
|
20493
20655
|
onEdit: (patch) => onEditMark(selectedMark.id, patch),
|
|
20494
20656
|
onClone: () => onCloneMark(cloneOf(selectedMark)),
|
|
@@ -20522,7 +20684,7 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
|
|
|
20522
20684
|
var React11 = __toESM(require("react"), 1);
|
|
20523
20685
|
var HISTORY_LIMIT = 100;
|
|
20524
20686
|
var GEOMETRY = ["price", "fromTime", "fromPrice", "toTime", "toPrice", "points"];
|
|
20525
|
-
var STYLE = ["color", "lineWidth", "lineStyle", "locked", "hidden", "shared", "alert", "rows", "valueArea", "levels", "visibleIntervals", "fontSize", "fillOpacity", "bold", "italic", "extendLeft", "extendRight"];
|
|
20687
|
+
var STYLE = ["color", "lineWidth", "lineStyle", "locked", "hidden", "shared", "alert", "rows", "valueArea", "levels", "visibleIntervals", "fontSize", "fillOpacity", "bold", "italic", "extendLeft", "extendRight", "screenX", "screenY"];
|
|
20526
20688
|
var FLAGS = /* @__PURE__ */ new Set(["locked", "hidden", "shared", "alert"]);
|
|
20527
20689
|
function recreateRequest(mark) {
|
|
20528
20690
|
const out = { kind: mark.kind, label: mark.label, role: mark.role, coin: mark.coin, interval: mark.interval };
|
|
@@ -21902,7 +22064,7 @@ function DeskColumn({ onCollapse }) {
|
|
|
21902
22064
|
if (!stayRef.current) setDrawMode(null);
|
|
21903
22065
|
if ((isTextKind(mark2.kind) || mark2.kind === "icon") && "points" in mark2) {
|
|
21904
22066
|
setTextValue("");
|
|
21905
|
-
setTextAt({ kind: mark2.kind, points: mark2.points });
|
|
22067
|
+
setTextAt({ kind: mark2.kind, points: mark2.points, screenX: mark2.screenX, screenY: mark2.screenY });
|
|
21906
22068
|
return;
|
|
21907
22069
|
}
|
|
21908
22070
|
void save(mark2, mark2.kind === "level" ? drawingLabel("level", [], mark2.price) : mark2.kind === "trend" ? drawingLabel("trend", [{ time: mark2.fromTime, price: mark2.fromPrice }]) : drawingLabel(mark2.kind, mark2.points));
|
|
@@ -22053,11 +22215,11 @@ function DeskColumn({ onCollapse }) {
|
|
|
22053
22215
|
{
|
|
22054
22216
|
open: Boolean(textAt),
|
|
22055
22217
|
onClose: () => setTextAt(null),
|
|
22056
|
-
title: textAt?.kind === "icon" ? tr("\u9009\u62E9\u56FE\u6807", "Pick an icon") : textAt?.kind === "callout" ? tr("\u6DFB\u52A0\u6807\u6CE8", "Add callout") : tr("\u6DFB\u52A0\u6587\u672C", "Add text"),
|
|
22218
|
+
title: textAt?.kind === "icon" ? tr("\u9009\u62E9\u56FE\u6807", "Pick an icon") : textAt?.kind === "callout" ? tr("\u6DFB\u52A0\u6807\u6CE8", "Add callout") : textAt?.kind === "table" ? tr("\u6DFB\u52A0\u8868\u683C\uFF08| \u5206\u9694\u5355\u5143\u683C\uFF0C; \u5206\u9694\u884C\uFF09", "Add table (| between cells, ; between rows)") : tr("\u6DFB\u52A0\u6587\u672C", "Add text"),
|
|
22057
22219
|
closeLabel: tr("\u5173\u95ED", "Close"),
|
|
22058
22220
|
className: "dhl-rename-modal",
|
|
22059
22221
|
footer: /* @__PURE__ */ React26.createElement(React26.Fragment, null, /* @__PURE__ */ React26.createElement(import_dsh_client_ui_primitives6.Button, { variant: "outline", onClick: () => setTextAt(null) }, tr("\u53D6\u6D88", "Cancel")), /* @__PURE__ */ React26.createElement(import_dsh_client_ui_primitives6.Button, { variant: "primary", disabled: !textValue.trim(), onClick: () => {
|
|
22060
|
-
if (textAt && textValue.trim()) void save({ kind: textAt.kind, points: textAt.points }, textValue.trim());
|
|
22222
|
+
if (textAt && textValue.trim()) void save({ kind: textAt.kind, points: textAt.points, ...textAt.screenX != null ? { screenX: textAt.screenX, screenY: textAt.screenY } : {} }, textValue.trim());
|
|
22061
22223
|
setTextAt(null);
|
|
22062
22224
|
} }, tr("\u6DFB\u52A0", "Add")))
|
|
22063
22225
|
},
|
|
@@ -22077,7 +22239,7 @@ function DeskColumn({ onCollapse }) {
|
|
|
22077
22239
|
onKeyDown: (event) => {
|
|
22078
22240
|
if (event.key === "Enter" && textAt && textValue.trim()) {
|
|
22079
22241
|
event.preventDefault();
|
|
22080
|
-
void save({ kind: textAt.kind, points: textAt.points }, textValue.trim());
|
|
22242
|
+
void save({ kind: textAt.kind, points: textAt.points, ...textAt.screenX != null ? { screenX: textAt.screenX, screenY: textAt.screenY } : {} }, textValue.trim());
|
|
22081
22243
|
setTextAt(null);
|
|
22082
22244
|
}
|
|
22083
22245
|
}
|
package/lib/chart-drawings.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type DrawingKind = 'level' | 'hray' | 'vline' | 'text' | 'trend' | 'ray' | 'extended' | 'fib' | 'rect' | 'measure' | 'channel' | 'long' | 'short' | 'fibext' | 'fibchannel' | 'fibtime' | 'gannfan' | 'pitchfork' | 'regression' | 'vprofile' | 'arrow' | 'callout' | 'circle' | 'triangle' | 'brush' | 'crossline' | 'pricelabel' | 'infoline' | 'trendangle' | 'pricerange' | 'daterange' | 'elliott' | 'elliottabc' | 'xabcd' | 'abcd' | 'headshoulders' | 'gannbox' | 'gannsquare' | 'schiff' | 'modschiff' | 'icon' | 'flatchannel' | 'disjoint' | 'fibfan' | 'fibcircles' | 'fibarcs' | 'fibwedge' | 'fibtrendtime' | 'cypher' | 'threedrives' | 'tripattern' | 'elliotttri' | 'elliottwxy' | 'elliottwxyxz' | 'cycles' | 'sine' | 'ellipse' | 'rotrect' | 'arc' | 'curve' | 'note' | 'pricenote' | 'signpost' | 'avwap' | 'avprofile' | 'forecast' | 'highlighter' | 'path' | 'polyline' | 'pin' | 'fibspiral' | 'barspattern' | 'projection' | 'ghostfeed'
|
|
1
|
+
export type DrawingKind = 'level' | 'hray' | 'vline' | 'text' | 'trend' | 'ray' | 'extended' | 'fib' | 'rect' | 'measure' | 'channel' | 'long' | 'short' | 'fibext' | 'fibchannel' | 'fibtime' | 'gannfan' | 'pitchfork' | 'regression' | 'vprofile' | 'arrow' | 'callout' | 'circle' | 'triangle' | 'brush' | 'crossline' | 'pricelabel' | 'infoline' | 'trendangle' | 'pricerange' | 'daterange' | 'elliott' | 'elliottabc' | 'xabcd' | 'abcd' | 'headshoulders' | 'gannbox' | 'gannsquare' | 'schiff' | 'modschiff' | 'icon' | 'flatchannel' | 'disjoint' | 'fibfan' | 'fibcircles' | 'fibarcs' | 'fibwedge' | 'fibtrendtime' | 'cypher' | 'threedrives' | 'tripattern' | 'elliotttri' | 'elliottwxy' | 'elliottwxyxz' | 'cycles' | 'sine' | 'ellipse' | 'rotrect' | 'arc' | 'curve' | 'note' | 'pricenote' | 'signpost' | 'avwap' | 'avprofile' | 'forecast' | 'highlighter' | 'path' | 'polyline' | 'pin' | 'fibspiral' | 'barspattern' | 'projection' | 'ghostfeed' | 'anchoredtext' | 'table' | 'gannfixed'
|
|
2
2
|
export type LineStyleName = 'solid' | 'dashed' | 'dotted'
|
|
3
|
-
export interface DrawingStyle { visibleIntervals?: string[]; fontSize?: number; bold?: boolean; italic?: boolean; extendLeft?: boolean; extendRight?: boolean; fillOpacity?: number; levels?: number[]; rows?: number; valueArea?: number; color?: string; lineWidth?: number; lineStyle?: LineStyleName; locked?: boolean; hidden?: boolean; shared?: boolean; alert?: boolean }
|
|
3
|
+
export interface DrawingStyle { visibleIntervals?: string[]; fontSize?: number; bold?: boolean; italic?: boolean; extendLeft?: boolean; extendRight?: boolean; screenX?: number; screenY?: number; fillOpacity?: number; levels?: number[]; rows?: number; valueArea?: number; color?: string; lineWidth?: number; lineStyle?: LineStyleName; locked?: boolean; hidden?: boolean; shared?: boolean; alert?: boolean }
|
|
4
4
|
export declare const DRAWING_POINTS: Record<DrawingKind, number>
|
|
5
5
|
export declare const DRAWING_KINDS: DrawingKind[]
|
|
6
6
|
export declare const DRAWING_CLICKS: Record<DrawingKind, number>
|
|
@@ -32,3 +32,4 @@ export declare const FILL_KINDS: DrawingKind[]
|
|
|
32
32
|
export declare const FREEHAND_KINDS: DrawingKind[]
|
|
33
33
|
export declare const MULTI_KINDS: DrawingKind[]
|
|
34
34
|
export declare const PATH_MAX: number
|
|
35
|
+
export declare const SCREEN_KINDS: DrawingKind[]
|
package/lib/chart-drawings.js
CHANGED
|
@@ -34,7 +34,13 @@ export const DRAWING_POINTS = {
|
|
|
34
34
|
highlighter: 0, path: 0, polyline: 0, pin: 1, fibspiral: 2, barspattern: 3,
|
|
35
35
|
// Projection (TradingView's sector: origin, a future point, an estimated price); ghost feed is drawn like a path.
|
|
36
36
|
projection: 3, ghostfeed: 0,
|
|
37
|
+
// Screen-anchored text (TradingView's anchored text) and a table (cells split by |, rows by ; or a new line).
|
|
38
|
+
anchoredtext: 1, table: 1,
|
|
39
|
+
// Gann square fixed: always square on screen, 5×5 units (TradingView Charting Library defaults).
|
|
40
|
+
gannfixed: 2,
|
|
37
41
|
}
|
|
42
|
+
/** Kinds that can be pinned to a screen position (screenX / screenY, 0-1 of the plot). */
|
|
43
|
+
export const SCREEN_KINDS = ['anchoredtext', 'table']
|
|
38
44
|
/** Freehand kinds drawn by dragging. */
|
|
39
45
|
export const FREEHAND_KINDS = ['brush', 'highlighter']
|
|
40
46
|
/** Kinds drawn click by click until a double-click or Enter. */
|
|
@@ -71,7 +77,7 @@ export function isSingleEmoji(value) {
|
|
|
71
77
|
/** Chart intervals a drawing can be limited to (same set as the desk). */
|
|
72
78
|
export const INTERVALS = ['1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '8h', '12h', '1d', '3d', '1w', '1M']
|
|
73
79
|
/** Text drawings whose font size can be set. */
|
|
74
|
-
export const FONT_KINDS = ['text', 'callout', 'note', 'pricenote', 'signpost']
|
|
80
|
+
export const FONT_KINDS = ['text', 'callout', 'note', 'pricenote', 'signpost', 'anchoredtext', 'table']
|
|
75
81
|
/** Drawings with a background fill whose opacity can be set. */
|
|
76
82
|
export const FILL_KINDS = ['rect', 'circle', 'triangle', 'channel', 'fib', 'regression', 'gannbox', 'pricerange', 'daterange', 'measure', 'flatchannel', 'disjoint', 'ellipse', 'rotrect']
|
|
77
83
|
/** Fibonacci drawings whose levels can be customised. */
|
|
@@ -131,7 +137,7 @@ export function linePriceAt(mark, time) {
|
|
|
131
137
|
export const BRUSH_MIN = 2
|
|
132
138
|
export const BRUSH_MAX = 500
|
|
133
139
|
/** Kinds whose label is free text shown on the chart (up to 200 characters). */
|
|
134
|
-
export const TEXT_KINDS = ['text', 'callout', 'note', 'pricenote', 'signpost', 'pin']
|
|
140
|
+
export const TEXT_KINDS = ['text', 'callout', 'note', 'pricenote', 'signpost', 'pin', 'anchoredtext', 'table']
|
|
135
141
|
/** Clicks that create a drawing when they differ from its stored anchor count. */
|
|
136
142
|
export const DRAWING_CLICKS = { ...Object.fromEntries(Object.entries(DRAWING_POINTS)), long: 2, short: 2 }
|
|
137
143
|
export const DRAWING_KINDS = Object.keys(DRAWING_POINTS)
|
|
@@ -229,6 +235,14 @@ export function drawingStyle(request) {
|
|
|
229
235
|
if (!Number.isInteger(size) || size < 10 || size > 32) throw new Error('字号必须为 10-32 的整数')
|
|
230
236
|
style.fontSize = size
|
|
231
237
|
}
|
|
238
|
+
// Pinned to the screen: both fractions together, or null (via update) to unpin.
|
|
239
|
+
if (request?.screenX != null || request?.screenY != null) {
|
|
240
|
+
if (request?.kind != null && !SCREEN_KINDS.includes(request.kind)) throw new Error(`screenX/screenY 只适用于 ${SCREEN_KINDS.join('/')}`)
|
|
241
|
+
// Both must be real numbers (Number(null) would read as 0); unpinning passes both as null.
|
|
242
|
+
const x = request.screenX == null ? NaN : Number(request.screenX), y = request.screenY == null ? NaN : Number(request.screenY)
|
|
243
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || x < 0 || x > 1 || y < 0 || y > 1) throw new Error('screenX/screenY 必须同时提供,且在 0-1 之间(图表宽高的比例)')
|
|
244
|
+
style.screenX = x; style.screenY = y
|
|
245
|
+
}
|
|
232
246
|
for (const flag of ['extendLeft', 'extendRight']) {
|
|
233
247
|
if (request?.[flag] == null) continue
|
|
234
248
|
if (request?.kind != null && request.kind !== 'trend') throw new Error(`${flag} 只适用于 trend`)
|
package/lib/remote.js
CHANGED
|
@@ -575,7 +575,7 @@ export class HyperRemote extends TypertRemoteService {
|
|
|
575
575
|
const fields = { ...drawingStyle({ ...patch, kind: current.kind }) }
|
|
576
576
|
if (patch?.alert === true) fields.alertTriggeredAt = undefined
|
|
577
577
|
// null clears a style back to its default (undo of a first restyle relies on this).
|
|
578
|
-
for (const key of ['color', 'lineWidth', 'lineStyle', 'rows', 'valueArea', 'levels', 'visibleIntervals', 'fontSize', 'fillOpacity', 'bold', 'italic', 'extendLeft', 'extendRight']) if (key in patch && patch[key] === null) fields[key] = undefined
|
|
578
|
+
for (const key of ['color', 'lineWidth', 'lineStyle', 'rows', 'valueArea', 'levels', 'visibleIntervals', 'fontSize', 'fillOpacity', 'bold', 'italic', 'extendLeft', 'extendRight', 'screenX', 'screenY']) if (key in patch && patch[key] === null) fields[key] = undefined
|
|
579
579
|
if (geometryKeys.some((key) => key in patch)) Object.assign(fields, drawingGeometry(current.kind, merged))
|
|
580
580
|
if ('label' in patch) {
|
|
581
581
|
const label = String(patch.label ?? '').trim()
|
package/lib/tools.js
CHANGED
|
@@ -12,7 +12,7 @@ import { INDICATOR_IDS, computeStudies, normalizeIndicatorSettings, studyDefinit
|
|
|
12
12
|
import { reviewLedger } from './review.js'
|
|
13
13
|
import { DRAWING_KINDS, DRAWING_POINTS, TEXT_KINDS, drawingStyle, volumeProfile } from './chart-drawings.js'
|
|
14
14
|
|
|
15
|
-
const DRAWING_NAMES = { projection: '投影', ghostfeed: '幽灵 K 线', highlighter: '荧光笔', path: '路径', polyline: '折线', pin: '图钉', fibspiral: '斐波那契螺旋', barspattern: 'K 线形态', flatchannel: '平顶/平底通道', disjoint: '分离通道', fibfan: '斐波那契速度阻力扇', fibcircles: '斐波那契圆', fibarcs: '斐波那契弧', fibwedge: '斐波那契楔形', fibtrendtime: '基于趋势的斐波那契时间',
|
|
15
|
+
const DRAWING_NAMES = { gannfixed: '固定江恩方格', anchoredtext: '锚定文本', table: '表格', projection: '投影', ghostfeed: '幽灵 K 线', highlighter: '荧光笔', path: '路径', polyline: '折线', pin: '图钉', fibspiral: '斐波那契螺旋', barspattern: 'K 线形态', flatchannel: '平顶/平底通道', disjoint: '分离通道', fibfan: '斐波那契速度阻力扇', fibcircles: '斐波那契圆', fibarcs: '斐波那契弧', fibwedge: '斐波那契楔形', fibtrendtime: '基于趋势的斐波那契时间',
|
|
16
16
|
cypher: 'Cypher 形态', threedrives: '三驱形态', tripattern: '三角形态', elliotttri: '艾略特三角浪', elliottwxy: '艾略特双重组合', elliottwxyxz: '艾略特三重组合', cycles: '周期线', sine: '正弦线',
|
|
17
17
|
ellipse: '椭圆', rotrect: '旋转矩形', arc: '弧线', curve: '曲线', note: '便签', pricenote: '价格便签', signpost: '路标', avwap: '锚定 VWAP', avprofile: '锚定成交量分布', forecast: '预测', vprofile: '固定范围成交量分布', level: '水平线', hray: '水平射线', vline: '垂直线', text: '文本', trend: '趋势线', ray: '射线', extended: '延长线', channel: '平行通道', fib: '斐波那契回撤', rect: '矩形', measure: '价格区间', long: '多头头寸', short: '空头头寸', fibext: '斐波那契扩展', fibchannel: '斐波那契通道', fibtime: '斐波那契时间周期', gannfan: '江恩扇形', pitchfork: '安德鲁叉子线', regression: '回归趋势', arrow: '箭头', callout: '标注气泡', circle: '圆形', triangle: '三角形', brush: '画笔', crossline: '十字线', pricelabel: '价格标签', infoline: '信息线', trendangle: '趋势角度', pricerange: '价格区间', daterange: '日期区间', elliott: '艾略特推动浪', elliottabc: '艾略特调整浪', xabcd: 'XABCD 谐波', abcd: 'ABCD 形态', headshoulders: '头肩形态', gannbox: '江恩箱', gannsquare: '江恩方格', schiff: 'Schiff 叉子线', modschiff: '改良 Schiff 叉子线', icon: '图标' }
|
|
18
18
|
import { canonicalMarketCoin } from './market-symbol.js'
|
|
@@ -246,7 +246,7 @@ function buildTools(remote) {
|
|
|
246
246
|
coin: { type: 'string', description: '默认会话绑定币对' },
|
|
247
247
|
interval: { type: 'string', description: '默认当前交易台周期' },
|
|
248
248
|
kind: { type: 'string', enum: [...DRAWING_KINDS, 'ma'], description: 'add 必填:画线类型或 ma 均线' },
|
|
249
|
-
points: { type: 'array', description: `除 level(price)、trend(fromTime…toPrice)外各类型的锚点,按点击顺序。点数:${Object.entries(DRAWING_POINTS).filter(([kind]) => kind !== 'level' && kind !== 'trend').map(([kind, n]) => `${kind}=${n || (kind === 'path' || kind === 'polyline' || kind === 'ghostfeed' ? '2-50' : '2-500')}`).join(' ')}。long/short=[入场,止损,止盈];${TEXT_KINDS.join('/')} 的文字放 label;avwap/avprofile 的唯一锚点是起算 K 线;barspattern=[源区间起点, 源区间终点, 粘贴位置(首根开盘价对齐此价)]
|
|
249
|
+
points: { type: 'array', description: `除 level(price)、trend(fromTime…toPrice)外各类型的锚点,按点击顺序。点数:${Object.entries(DRAWING_POINTS).filter(([kind]) => kind !== 'level' && kind !== 'trend').map(([kind, n]) => `${kind}=${n || (kind === 'path' || kind === 'polyline' || kind === 'ghostfeed' ? '2-50' : '2-500')}`).join(' ')}。long/short=[入场,止损,止盈];${TEXT_KINDS.join('/')} 的文字放 label;avwap/avprofile 的唯一锚点是起算 K 线;barspattern=[源区间起点, 源区间终点, 粘贴位置(首根开盘价对齐此价)];table 的 label 用 | 分隔单元格、; 或换行分隔行`, items: { type: 'object', properties: { time: { type: 'number', description: 'K 线时间 epoch ms' }, price: { type: 'number' } }, required: ['time', 'price'] } },
|
|
250
250
|
maType: { type: 'string', enum: MA_KINDS, description: 'kind=ma:均线类型;smma 即平滑均线(RMA)' },
|
|
251
251
|
period: { type: 'number', description: 'kind=ma:周期,1-500 的整数' },
|
|
252
252
|
source: { type: 'string', enum: MA_SOURCES, description: 'kind=ma:价格源,默认 close' },
|
|
@@ -256,6 +256,8 @@ function buildTools(remote) {
|
|
|
256
256
|
lineWidth: { type: 'number', description: '画线线宽 1-4' },
|
|
257
257
|
visibleIntervals: { type: 'array', items: { type: 'string' }, description: '只在这些周期显示(如 ["4h","1d"]);省略=所有周期' },
|
|
258
258
|
fontSize: { type: 'number', description: 'kind=text/callout:字号 10-32' },
|
|
259
|
+
screenX: { type: 'number', description: 'kind=anchoredtext/table:固定在屏幕的横向位置 0-1(与 screenY 同时给)' }, screenY: { type: 'number', description: '固定在屏幕的纵向位置 0-1' },
|
|
260
|
+
unpin: { type: 'boolean', description: 'action=update:true 取消固定到屏幕,画线回到它保存的 points 时间与价格' },
|
|
259
261
|
extendLeft: { type: 'boolean', description: 'kind=trend:向左延长' }, extendRight: { type: 'boolean', description: 'kind=trend:向右延长' },
|
|
260
262
|
bold: { type: 'boolean', description: 'kind=text/callout:粗体' }, italic: { type: 'boolean', description: 'kind=text/callout:斜体' },
|
|
261
263
|
fillOpacity: { type: 'number', description: '矩形/圆/三角形/通道/斐波那契/区间等的背景填充透明度 0-0.6(0=无填充)' },
|
|
@@ -313,7 +315,8 @@ function buildTools(remote) {
|
|
|
313
315
|
return { text: `已移除均线:${maLabel(removed)}(${removed.id})`, line: removed }
|
|
314
316
|
}
|
|
315
317
|
if (args?.action === 'update') {
|
|
316
|
-
const patch = Object.fromEntries(['points', 'price', 'fromTime', 'fromPrice', 'toTime', 'toPrice', 'label', 'color', 'lineWidth', 'lineStyle', 'locked', 'hidden', 'shared', 'alert', 'rows', 'valueArea', 'levels', 'visibleIntervals', 'fontSize', 'fillOpacity', 'bold', 'italic', 'extendLeft', 'extendRight'].filter((key) => args?.[key] != null).map((key) => [key, args[key]]))
|
|
318
|
+
const patch = Object.fromEntries(['points', 'price', 'fromTime', 'fromPrice', 'toTime', 'toPrice', 'label', 'color', 'lineWidth', 'lineStyle', 'locked', 'hidden', 'shared', 'alert', 'rows', 'valueArea', 'levels', 'visibleIntervals', 'fontSize', 'fillOpacity', 'bold', 'italic', 'extendLeft', 'extendRight', 'screenX', 'screenY'].filter((key) => args?.[key] != null).map((key) => [key, args[key]]))
|
|
319
|
+
if (args?.unpin === true) { patch.screenX = null; patch.screenY = null }
|
|
317
320
|
const mark = remote.editChartMark(args?.id, patch, sessionId)
|
|
318
321
|
return { text: `已更新${DRAWING_NAMES[mark.kind] ?? mark.kind}:${mark.label}(${mark.id})`, mark }
|
|
319
322
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hyperliquid",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Hyperliquid trading desk for the DeepSeek Harness (dsh) - market workspace, native agent conversation and guarded live / paper trading over the Hyperliquid API.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|
|
@@ -58,7 +58,7 @@ description: 作为用户的交易副手,在 DSH 交易会话中用 Hyperliqui
|
|
|
58
58
|
- 提交后一律用 `hyper_account orderStatus / orders / state` 对账。回执超时或未知时,先查状态再决定,绝不直接重下。
|
|
59
59
|
|
|
60
60
|
### 图表与提醒
|
|
61
|
-
-
|
|
61
|
+
- 77 种画线(趋势线、水平线/射线、通道、斐波那契回撤/扩展/通道(可自定义层级 `levels`)、江恩、叉子线、回归趋势、**固定范围成交量分布 vprofile**(返回 POC / VAH / VAL)、艾略特浪与谐波形态、多空头寸、文字和图标、**锚定 VWAP avwap**(单点锚定,算到最新 K 线)、**锚定成交量分布 avprofile**、预测、便签 / 路标等;各类型点数见 `hyper_chart` 的 points 说明),用 `hyper_chart`。已有画线用 `update` 修改,不必删了重画。
|
|
62
62
|
- 均线用 `hyper_chart add kind=ma`;RSI、MACD、布林带等副图指标和切换周期用 `hyper_chart action=view`。**不要自己算均线再拼线段**。
|
|
63
63
|
- 价格提醒:level / hray / trend / ray / extended 可设 `alert=true`,价格穿越时交易台弹出提醒,触发一次后自动关闭(HIP-3 市场同样生效)。同时你会收到一条以「[交易台事件]」开头的消息(同一会话 5 分钟内最多一次,多个提醒会合并)。它是自动通知,**不是用户授权**:复核后简短告诉用户发生了什么、建议怎么做,不要据此直接下单、改限额或划转。
|
|
64
64
|
- `shared=true` 让画线同步到该币种的所有会话。
|