dsh-hyperliquid 0.5.1 → 0.5.2

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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.2 — 2026-10-17
4
+
5
+ - 新增投影(TradingView 的扇形:起点、未来点、估计价格,标注涨跌幅)与幽灵 K 线(逐点点击设想路径,双击或 Enter 结束;从首点到末点每个 K 线周期一根,收盘跟随路径;每根高低差取其实体与「路径起点前 20 根真实 K 线平均高低差 × 0.6–1.4 的固定抖动」中的较大者,最多 2000 根。TradingView 未公开其生成算法,这是近似实现)。共 74 种。
6
+ - 查证 TradingView 帮助页后记录:内部叉子线的官方描述与改良 Schiff 相同、固定江恩方格没有说明文档,两者未做;锚定文本与表格仍未做。
7
+
3
8
  ## 0.5.1 — 2026-10-17
4
9
 
5
10
  - 再补 6 种 TradingView 画线(共 72 种):荧光笔(拖动绘制的半透明粗线)、路径(逐点点击,双击或 Enter 结束,末端带箭头)、折线、图钉(带说明)、斐波那契螺旋(每四分之一圈放大 1.618 倍)、K 线形态(把源区间的 K 线按首根开盘价对齐复制到指定位置)。
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 的分组提供 72 种工具(菜单顶部可搜索)——线条:趋势线、射线、延长线、信息线(涨跌 / 根数 / 时长 / 角度)、趋势角度、水平线、水平射线、十字线、垂直线;通道:平行通道、安德鲁叉子线、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 线的形状到别处)。点击过程中实时预览,Esc 取消,按住 Shift 把方向约束为水平或 45°;磁吸可选关 / 弱 / 强,吸附到 K 线开高低收。
61
+ - **画线工具**:工具栏「画线」菜单按 TradingView 的分组提供 74 种工具(菜单顶部可搜索)——线条:趋势线、射线、延长线、信息线(涨跌 / 根数 / 时长 / 角度)、趋势角度、水平线、水平射线、十字线、垂直线;通道:平行通道、安德鲁叉子线、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 线)。点击过程中实时预览,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` | 在会话图表上添加、修改(几何 / 颜色 / 线宽 / 线型 / 锁定 / 隐藏)或删除画线(72 种,含固定范围成交量分布、斐波那契、江恩、叉子线、回归、艾略特与谐波形态、标注与多空头寸;可设置同步到所有会话与价格提醒)和均线(SMA / EMA / SMMA / WMA,可选平滑);`action=view` 切换图表周期并显示 / 隐藏 RSI、MACD 等副图指标 |
112
+ | `hyper_chart` | 在会话图表上添加、修改(几何 / 颜色 / 线宽 / 线型 / 锁定 / 隐藏)或删除画线(74 种,含固定范围成交量分布、斐波那契、江恩、叉子线、回归、艾略特与谐波形态、标注与多空头寸;可设置同步到所有会话与价格提醒)和均线(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
@@ -974,6 +974,12 @@ body:has(.dhl-divider.dragging) * { cursor: col-resize !important; }
974
974
  .dhl-drawing .dhl-pin-glyph { fill: currentColor; fill-opacity: .25; stroke: currentColor; stroke-width: 2; }
975
975
  .dhl-drawing .dhl-bars-copy { fill: none; stroke: currentColor; stroke-width: 1.3; opacity: .8; }
976
976
  .dhl-drawing-hit .dhl-bars-copy, .dhl-drawing-hit .dhl-pin-glyph { pointer-events: stroke; }
977
+
978
+ /* 0.5.2: projection sector, ghost feed candles. */
979
+ .dhl-drawing path.dhl-sector { fill: currentColor; fill-opacity: var(--dhl-fill-opacity, .1); stroke: currentColor; stroke-width: var(--dhl-line-width, 1.4); }
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
+ .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
+ .dhl-drawing-hit .dhl-ghost path, .dhl-drawing-hit .dhl-sector { pointer-events: all; }
977
983
  `;
978
984
 
979
985
  // src/client/locale.ts
@@ -17750,10 +17756,13 @@ var DRAWING_POINTS = {
17750
17756
  polyline: 0,
17751
17757
  pin: 1,
17752
17758
  fibspiral: 2,
17753
- barspattern: 3
17759
+ barspattern: 3,
17760
+ // Projection (TradingView's sector: origin, a future point, an estimated price); ghost feed is drawn like a path.
17761
+ projection: 3,
17762
+ ghostfeed: 0
17754
17763
  };
17755
17764
  var FREEHAND_KINDS = ["brush", "highlighter"];
17756
- var MULTI_KINDS = ["path", "polyline"];
17765
+ var MULTI_KINDS = ["path", "polyline", "ghostfeed"];
17757
17766
  var PATH_MAX = 50;
17758
17767
  var ICON_NAMES = ["flag", "star", "up", "down", "warning", "check", "cross", "fire", "target", "bell", "pin", "clock", "dollar", "shield", "bolt", "heart", "question", "info"];
17759
17768
  var STICKERS = {
@@ -17852,6 +17861,8 @@ function drawingGeometry(kind, request, now = Date.now()) {
17852
17861
  if (["trend", "ray", "extended", "channel", "fibchannel", "gannfan", "regression", "fibtime", "infoline", "trendangle", "flatchannel", "disjoint", "fibfan", "fibtrendtime", "cycles", "sine", "forecast"].includes(kind) && points2[0].time === points2[1].time) throw new Error("\u524D\u4E24\u4E2A\u70B9\u7684\u65F6\u95F4\u4E0D\u80FD\u76F8\u540C");
17853
17862
  if ((kind === "cycles" || kind === "sine" || kind === "fibtrendtime") && points2[1].time < points2[0].time) throw new Error("\u7B2C\u4E8C\u4E2A\u70B9\u5FC5\u987B\u665A\u4E8E\u7B2C\u4E00\u4E2A\u70B9");
17854
17863
  if (kind === "barspattern" && points2[1].time <= points2[0].time) throw new Error("K \u7EBF\u5F62\u6001\u7684\u6E90\u533A\u95F4\u7EC8\u70B9\u5FC5\u987B\u665A\u4E8E\u8D77\u70B9");
17864
+ if (kind === "projection" && points2[1].time <= points2[0].time) throw new Error("\u6295\u5F71\u7684\u7B2C\u4E8C\u4E2A\u70B9\u5FC5\u987B\u5728\u8D77\u70B9\u4E4B\u540E\uFF08\u672A\u6765\u65B9\u5411\uFF09");
17865
+ if (kind === "ghostfeed" && points2.some((point2, index) => index > 0 && point2.time <= points2[index - 1].time)) throw new Error("\u5E7D\u7075 K \u7EBF\u7684\u70B9\u5FC5\u987B\u6309\u65F6\u95F4\u4ECE\u5DE6\u5230\u53F3");
17855
17866
  if (kind === "vprofile") {
17856
17867
  if (points2[0].time === points2[1].time) throw new Error("\u6210\u4EA4\u91CF\u5206\u5E03\u9700\u8981\u4E00\u4E2A\u65F6\u95F4\u533A\u95F4");
17857
17868
  if (points2[1].time < points2[0].time) points2.reverse();
@@ -17938,6 +17949,8 @@ var DRAWING_TOOLS = [
17938
17949
  { group: "measure", kind: "forecast", zh: "\u9884\u6D4B", en: "Forecast", hintZh: "\u70B9\u51FB\u8D77\u70B9\uFF0C\u518D\u70B9\u51FB\u9884\u6D4B\u76EE\u6807\uFF0C\u663E\u793A\u6DA8\u8DCC\u4E0E\u65F6\u957F", hintEn: "Click the source, then the target; shows change and time", icon: "M3 17 10 12M10 12l11-7M17 5h4v4M10 12v.01" },
17939
17950
  { group: "measure", kind: "avwap", zh: "\u951A\u5B9A VWAP", en: "Anchored VWAP", hintZh: "\u5355\u51FB\u951A\u5B9A\u7684 K \u7EBF\uFF0C\u4ECE\u8BE5\u5904\u7D2F\u8BA1\u5230\u6700\u65B0 K \u7EBF", hintEn: "Click the anchor bar; accumulates to the latest bar", icon: "M4 4v16M4 16c4-1 6-6 10-7s5 2 6 0" },
17940
17951
  { group: "measure", kind: "avprofile", zh: "\u951A\u5B9A\u6210\u4EA4\u91CF\u5206\u5E03", en: "Anchored volume profile", hintZh: "\u5355\u51FB\u951A\u5B9A\u7684 K \u7EBF\uFF0C\u7EDF\u8BA1\u4ECE\u8BE5\u5904\u5230\u6700\u65B0\u7684\u6210\u4EA4\u91CF\u5206\u5E03", hintEn: "Click the anchor bar; volume by price up to the latest bar", icon: "M4 3v18M4 6h7M4 10h12M4 14h9M4 18h5" },
17952
+ { group: "measure", kind: "projection", zh: "\u6295\u5F71", en: "Projection", hintZh: "\u70B9\u51FB\u8D77\u70B9\u3001\u672A\u6765\u65B9\u5411\u70B9\uFF0C\u518D\u70B9\u51FB\u4F30\u8BA1\u4EF7\u683C\uFF0C\u753B\u51FA\u6247\u5F62\u5E76\u6807\u6CE8\u6DA8\u8DCC\u5E45", hintEn: "Click the origin, a future point, then the estimated price; draws a sector with the change", icon: "M4 18 20 10M4 18l14-12M4 18M16 6a10 10 0 0 1 4 4" },
17953
+ { group: "measure", kind: "ghostfeed", zh: "\u5E7D\u7075 K \u7EBF", en: "Ghost feed", hintZh: "\u9010\u70B9\u70B9\u51FB\u8BBE\u60F3\u7684\u4EF7\u683C\u8DEF\u5F84\uFF0C\u53CC\u51FB\u6216\u6309 Enter \u7ED3\u675F\uFF0C\u6CBF\u8DEF\u5F84\u751F\u6210\u5047\u60F3 K \u7EBF", hintEn: "Click the imagined price path; double-click or Enter to finish; candles follow it", icon: "M5 8v8M4 10h2M10 5v10M9 7h2M15 9v9M14 11h2M20 6v8M19 8h2" },
17941
17954
  { group: "measure", kind: "barspattern", zh: "K \u7EBF\u5F62\u6001", en: "Bars pattern", hintZh: "\u70B9\u51FB\u6E90\u533A\u95F4\u8D77\u70B9\u548C\u7EC8\u70B9\uFF0C\u518D\u70B9\u51FB\u7C98\u8D34\u4F4D\u7F6E\uFF0C\u590D\u5236\u8FD9\u6BB5 K \u7EBF\u7684\u5F62\u72B6", hintEn: "Click the source range start and end, then where to paste its shape", icon: "M6 5v14M4 8h2M6 15h2M12 3v12M10 6h2M12 12h2M18 8v12M16 10h2M18 17h2" },
17942
17955
  { group: "measure", kind: "long", zh: "\u591A\u5934\u5934\u5BF8", en: "Long position", hintZh: "\u70B9\u51FB\u5165\u573A\u4EF7\uFF0C\u518D\u70B9\u51FB\u6B62\u635F\u4EF7\uFF08\u6B62\u76C8\u9ED8\u8BA4 2R\uFF0C\u53EF\u62D6\u52A8\uFF09", hintEn: "Click entry, then stop (target defaults to 2R)", icon: "M4 4h16v8H4zM4 12h16v8H4zM4 12h16" },
17943
17956
  { group: "measure", kind: "short", zh: "\u7A7A\u5934\u5934\u5BF8", en: "Short position", hintZh: "\u70B9\u51FB\u5165\u573A\u4EF7\uFF0C\u518D\u70B9\u51FB\u6B62\u635F\u4EF7\uFF08\u6B62\u76C8\u9ED8\u8BA4 2R\uFF0C\u53EF\u62D6\u52A8\uFF09", hintEn: "Click entry, then stop (target defaults to 2R)", icon: "M4 4h16v8H4zM4 12h16v8H4zM4 12h16" }
@@ -18005,6 +18018,7 @@ function drawingLabel(kind, points2, price) {
18005
18018
  const when = new Date(first.time).toLocaleString(tr("zh-CN", "en-US"), { month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hour12: false });
18006
18019
  return `${name} ${when}`;
18007
18020
  }
18021
+ var GHOST_MAX = 2e3;
18008
18022
  function clipLine(a, b, w, h, from, to = Infinity) {
18009
18023
  const dx = b.x - a.x, dy = b.y - a.y;
18010
18024
  let t0 = from, t1 = to;
@@ -18247,6 +18261,51 @@ var DrawingShape = React7.memo(function DrawingShape2({ kind, points: points2, l
18247
18261
  body = /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("polyline", { className: "dhl-pattern", points: pts.join(" ") }), /* @__PURE__ */ React7.createElement("line", { className: "dhl-drawing-mid", x1: p[0].x, y1: p[0].y, x2: p[1].x, y2: p[1].y }));
18248
18262
  break;
18249
18263
  }
18264
+ case "projection": {
18265
+ if (!p[1]) break;
18266
+ if (!p[2]) {
18267
+ body = /* @__PURE__ */ React7.createElement("line", { x1: p[0].x, y1: p[0].y, x2: p[1].x, y2: p[1].y });
18268
+ break;
18269
+ }
18270
+ const r = Math.hypot(p[1].x - p[0].x, p[1].y - p[0].y);
18271
+ const a1 = Math.atan2(p[1].y - p[0].y, p[1].x - p[0].x), a2 = Math.atan2(p[2].y - p[0].y, p[2].x - p[0].x);
18272
+ const span = Math.atan2(Math.sin(a2 - a1), Math.cos(a2 - a1));
18273
+ const s1 = { x: p[0].x + r * Math.cos(a1), y: p[0].y + r * Math.sin(a1) }, s2 = { x: p[0].x + r * Math.cos(a1 + span), y: p[0].y + r * Math.sin(a1 + span) };
18274
+ const change = points2[0].price > 0 ? (points2[2].price - points2[0].price) / points2[0].price * 100 : 0;
18275
+ body = /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("path", { className: "dhl-drawing-fill dhl-sector", d: `M${p[0].x} ${p[0].y}L${s1.x} ${s1.y}A${r} ${r} 0 0 ${span > 0 ? 1 : 0} ${s2.x} ${s2.y}Z` }), /* @__PURE__ */ React7.createElement("line", { className: "dhl-drawing-mid", x1: p[0].x, y1: p[0].y, x2: p[2].x, y2: p[2].y }), text(p[2].x + 6, p[2].y - 4, `${fmtPrice(points2[2].price)} (${change >= 0 ? "+" : ""}${change.toFixed(2)}%)`));
18276
+ break;
18277
+ }
18278
+ case "ghostfeed": {
18279
+ if (p.length < 2) break;
18280
+ const barMs = view.barMs ?? 0;
18281
+ if (!barMs) {
18282
+ body = /* @__PURE__ */ React7.createElement("polyline", { className: "dhl-drawing-mid", points: p.map((point) => `${point.x},${point.y}`).join(" ") });
18283
+ break;
18284
+ }
18285
+ const before = view.candles?.(points2[0].time - 20 * barMs, points2[0].time - 1) ?? [];
18286
+ const avgHL = before.length ? before.reduce((sum, bar) => sum + bar.high - bar.low, 0) / before.length : 0;
18287
+ const w0 = view.project(points2[0].time + barMs, points2[0].price)?.x, half = w0 != null ? Math.max(1, (w0 - p[0].x) * 0.35) : 2;
18288
+ const last = points2[points2.length - 1];
18289
+ let up = "", down = "", prev = points2[0].price, k2 = 0, seg = 1;
18290
+ for (let t2 = points2[0].time + barMs; t2 <= last.time + 1 && k2 < GHOST_MAX; t2 += barMs) {
18291
+ while (seg < points2.length - 1 && t2 > points2[seg].time) seg += 1;
18292
+ const a = points2[seg - 1], b = points2[seg];
18293
+ const close = a.price + (b.price - a.price) * Math.min(1, (t2 - a.time) / (b.time - a.time));
18294
+ k2 += 1;
18295
+ const jitter = 0.6 + 0.8 * Math.abs(Math.sin(k2 * 12.9898) * 43758.5453 % 1);
18296
+ const bodyLow = Math.min(prev, close), bodyHigh = Math.max(prev, close);
18297
+ const extra = Math.max(0, avgHL * jitter - (bodyHigh - bodyLow)) / 2;
18298
+ const o = view.project(t2, prev), c = view.project(t2, close), hi = view.project(t2, bodyHigh + extra), lo = view.project(t2, bodyLow - extra);
18299
+ if (o && c && hi && lo) {
18300
+ const path = `M${o.x.toFixed(1)} ${hi.y.toFixed(1)}V${lo.y.toFixed(1)}M${(o.x - half).toFixed(1)} ${Math.min(o.y, c.y).toFixed(1)}h${(2 * half).toFixed(1)}v${Math.max(1, Math.abs(c.y - o.y)).toFixed(1)}h${(-2 * half).toFixed(1)}z`;
18301
+ if (close >= prev) up += path;
18302
+ else down += path;
18303
+ }
18304
+ prev = close;
18305
+ }
18306
+ body = /* @__PURE__ */ React7.createElement("g", { className: "dhl-ghost", "data-candles": k2 }, /* @__PURE__ */ React7.createElement("path", { className: "dhl-ghost-up", d: up }), /* @__PURE__ */ React7.createElement("path", { className: "dhl-ghost-down", d: down }), /* @__PURE__ */ React7.createElement("polyline", { className: "dhl-drawing-mid", points: p.map((point) => `${point.x},${point.y}`).join(" ") }));
18307
+ break;
18308
+ }
18250
18309
  case "barspattern": {
18251
18310
  if (!p[1]) break;
18252
18311
  const [from, to] = points2[0].time <= points2[1].time ? [points2[0], points2[1]] : [points2[1], points2[0]];
@@ -19057,6 +19116,19 @@ function completePreview(kind, points2) {
19057
19116
  if ((kind === "long" || kind === "short") && points2.length === 2) return completePoints(kind, points2) ?? points2.slice(0, 1);
19058
19117
  return points2;
19059
19118
  }
19119
+ function candlesIn(candles, from, to) {
19120
+ const first = (time) => {
19121
+ let lo = 0, hi = candles.length;
19122
+ while (lo < hi) {
19123
+ const mid = lo + hi >> 1;
19124
+ if (candles[mid].t < time) lo = mid + 1;
19125
+ else hi = mid;
19126
+ }
19127
+ return lo;
19128
+ };
19129
+ const end = to >= Number.MAX_SAFE_INTEGER ? candles.length : first(to + 1);
19130
+ return candles.slice(first(from), end);
19131
+ }
19060
19132
  function barAt(candles, time) {
19061
19133
  const t2 = Math.floor(time / 1e3);
19062
19134
  let lo = 0, hi = candles.length - 1;
@@ -19077,6 +19149,7 @@ function chartData(points2) {
19077
19149
  }
19078
19150
  var TOOLBAR_CLEARANCE = 84;
19079
19151
  var FINITE_KINDS = /* @__PURE__ */ new Set([
19152
+ "ghostfeed",
19080
19153
  "highlighter",
19081
19154
  "path",
19082
19155
  "polyline",
@@ -19963,8 +20036,8 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
19963
20036
  width: Math.max(0, box.clientWidth - chartApi.chart.priceScale("right").width()),
19964
20037
  height: chartApi.chart.panes()[0]?.getHeight() ?? box.clientHeight,
19965
20038
  bars: (from, to) => timeline.toLogical(to) - timeline.toLogical(from),
19966
- closes: (from, to) => candlesRef.current.filter((candle) => candle.t >= from && candle.t <= to).map((candle) => ({ time: candle.t, price: candle.c })),
19967
- candles: (from, to) => candlesRef.current.filter((candle) => candle.t >= from && candle.t <= to).map((candle) => ({ time: candle.t, open: candle.o, high: candle.h, low: candle.l, close: candle.c, volume: candle.v })),
20039
+ closes: (from, to) => candlesIn(candlesRef.current, from, to).map((candle) => ({ time: candle.t, price: candle.c })),
20040
+ candles: (from, to) => candlesIn(candlesRef.current, from, to).map((candle) => ({ time: candle.t, open: candle.o, high: candle.h, low: candle.l, close: candle.c, volume: candle.v })),
19968
20041
  profile: (from, to, options) => cachedProfile(candlesRef.current, from, to, options),
19969
20042
  firstTime: candlesRef.current[0]?.t,
19970
20043
  barMs: candlesRef.current.length > 1 ? candlesRef.current[1].t - candlesRef.current[0].t : void 0
@@ -20354,7 +20427,7 @@ function CandleChart({ candles, marks, indicators, expanded, resetToken, drawMod
20354
20427
  points: shown,
20355
20428
  view,
20356
20429
  text: mark.label,
20357
- dataVersion: mark.kind === "vprofile" || mark.kind === "regression" || mark.kind === "avwap" || mark.kind === "avprofile" || mark.kind === "barspattern" ? candles : void 0,
20430
+ dataVersion: mark.kind === "vprofile" || mark.kind === "regression" || mark.kind === "avwap" || mark.kind === "avprofile" || mark.kind === "barspattern" || mark.kind === "ghostfeed" ? candles : void 0,
20358
20431
  className: `dhl-drawing ${roleClass(mark)}${mark.kind === "level" ? " is-level" : ""}${selected ? " selected" : ""}${mark.locked || drawingsLocked ? " locked" : ""}`,
20359
20432
  label: mark.source === "user" || mark.kind === "level" ? void 0 : mark.label,
20360
20433
  anchors: selected,
@@ -1,4 +1,4 @@
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'
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'
2
2
  export type LineStyleName = 'solid' | 'dashed' | 'dotted'
3
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 }
4
4
  export declare const DRAWING_POINTS: Record<DrawingKind, number>
@@ -32,11 +32,13 @@ export const DRAWING_POINTS = {
32
32
  avwap: 1, avprofile: 1, forecast: 2,
33
33
  // Freehand highlighter (0 = variable, like brush); path / polyline take clicks until a double-click or Enter.
34
34
  highlighter: 0, path: 0, polyline: 0, pin: 1, fibspiral: 2, barspattern: 3,
35
+ // Projection (TradingView's sector: origin, a future point, an estimated price); ghost feed is drawn like a path.
36
+ projection: 3, ghostfeed: 0,
35
37
  }
36
38
  /** Freehand kinds drawn by dragging. */
37
39
  export const FREEHAND_KINDS = ['brush', 'highlighter']
38
40
  /** Kinds drawn click by click until a double-click or Enter. */
39
- export const MULTI_KINDS = ['path', 'polyline']
41
+ export const MULTI_KINDS = ['path', 'polyline', 'ghostfeed']
40
42
  export const PATH_MAX = 50
41
43
  /** Icon stickers (the drawing's label holds the icon name). */
42
44
  export const ICON_NAMES = ['flag', 'star', 'up', 'down', 'warning', 'check', 'cross', 'fire', 'target', 'bell', 'pin', 'clock', 'dollar', 'shield', 'bolt', 'heart', 'question', 'info']
@@ -179,6 +181,8 @@ export function drawingGeometry(kind, request, now = Date.now()) {
179
181
  if (['trend', 'ray', 'extended', 'channel', 'fibchannel', 'gannfan', 'regression', 'fibtime', 'infoline', 'trendangle', 'flatchannel', 'disjoint', 'fibfan', 'fibtrendtime', 'cycles', 'sine', 'forecast'].includes(kind) && points[0].time === points[1].time) throw new Error('前两个点的时间不能相同')
180
182
  if ((kind === 'cycles' || kind === 'sine' || kind === 'fibtrendtime') && points[1].time < points[0].time) throw new Error('第二个点必须晚于第一个点')
181
183
  if (kind === 'barspattern' && points[1].time <= points[0].time) throw new Error('K 线形态的源区间终点必须晚于起点')
184
+ if (kind === 'projection' && points[1].time <= points[0].time) throw new Error('投影的第二个点必须在起点之后(未来方向)')
185
+ if (kind === 'ghostfeed' && points.some((point, index) => index > 0 && point.time <= points[index - 1].time)) throw new Error('幽灵 K 线的点必须按时间从左到右')
182
186
  if (kind === 'vprofile') {
183
187
  if (points[0].time === points[1].time) throw new Error('成交量分布需要一个时间区间')
184
188
  // Only the time range matters, so either drawing direction is fine.
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 = { highlighter: '荧光笔', path: '路径', polyline: '折线', pin: '图钉', fibspiral: '斐波那契螺旋', barspattern: 'K 线形态', flatchannel: '平顶/平底通道', disjoint: '分离通道', fibfan: '斐波那契速度阻力扇', fibcircles: '斐波那契圆', fibarcs: '斐波那契弧', fibwedge: '斐波那契楔形', fibtrendtime: '基于趋势的斐波那契时间',
15
+ const DRAWING_NAMES = { 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' ? '2-50' : '2-500')}`).join(' ')}。long/short=[入场,止损,止盈];${TEXT_KINDS.join('/')} 的文字放 label;avwap/avprofile 的唯一锚点是起算 K 线;barspattern=[源区间起点, 源区间终点, 粘贴位置(首根开盘价对齐此价)]`, items: { type: 'object', properties: { time: { type: 'number', description: 'K 线时间 epoch ms' }, price: { type: 'number' } }, required: ['time', 'price'] } },
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=[源区间起点, 源区间终点, 粘贴位置(首根开盘价对齐此价)]`, 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' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-hyperliquid",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
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
- - 72 种画线(趋势线、水平线/射线、通道、斐波那契回撤/扩展/通道(可自定义层级 `levels`)、江恩、叉子线、回归趋势、**固定范围成交量分布 vprofile**(返回 POC / VAH / VAL)、艾略特浪与谐波形态、多空头寸、文字和图标、**锚定 VWAP avwap**(单点锚定,算到最新 K 线)、**锚定成交量分布 avprofile**、预测、便签 / 路标等;各类型点数见 `hyper_chart` 的 points 说明),用 `hyper_chart`。已有画线用 `update` 修改,不必删了重画。
61
+ - 74 种画线(趋势线、水平线/射线、通道、斐波那契回撤/扩展/通道(可自定义层级 `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` 让画线同步到该币种的所有会话。