@dshtrading/connector-longbridge 0.5.0 → 0.6.1

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 CHANGED
@@ -7,7 +7,7 @@
7
7
  node scripts/new-connector.mjs --slug bybit --title Bybit --market crypto
8
8
  ```
9
9
 
10
- 生成后按 [docs/connector-playbook.md](../../docs/connector-playbook.md) 的填写顺序
10
+ 生成后按 [docs/guides/connector-playbook.md](../../docs/guides/connector-playbook.md) 的填写顺序
11
11
  (src/rest.ts 头部清单 7 项)实现 TODO。每个 TODO 的参照段都在 connector-okx
12
12
  (packages/connector-okx/),它是本仓第一个真实 TradeService 连接器。
13
13
 
package/lib/index.d.ts CHANGED
@@ -27,7 +27,7 @@ declare class LongbridgeMarketDataService extends Service implements MarketDataS
27
27
  }
28
28
  declare class LongbridgeTradeService extends Service implements TradeService {
29
29
  private readonly client;
30
- /** 插件配置(服务缝闸门 P0:dryRun 强制模拟 / liveTrading 总闸门)。 */
30
+ /** 插件配置(服务缝闸门 P0:dryRun 强制模拟 / liveTrading 非权威镜像——实盘授权由 @dshtrading/authority 的人工签署平面裁定)。 */
31
31
  private readonly config;
32
32
  constructor(ctx: Context, options: LongbridgeRestOptions & {
33
33
  config: Config;
package/lib/index.js CHANGED
@@ -1,8 +1,13 @@
1
1
  import { INTERVAL_VOCABULARY, LongbridgeRestClient, TradingServiceError, generateLongbridgeSignature, parseIntervalMs, toLongbridgePeriod, toLongbridgeSymbol as toLongbridgeSymbol$1 } from "./rest.js";
2
+ import { liveTradingEnabled } from "@dshtrading/authority";
2
3
  import { Service } from "@deepseek-ai/cordis";
3
4
  import { defineTool } from "@deepseek-ai/dsh-tools";
4
5
  import Schema from "@deepseek-ai/schemastery";
5
6
  //#region src/index.ts
7
+ /**
8
+ * @dshtrading/connector-longbridge
9
+ * 长桥 (Longbridge) 港股连接器插件(提供 tradingHkMarketData 与 hk_* 工具)。
10
+ */
6
11
  const name = "dsh-trading-hk-connector-longbridge";
7
12
  const Config = Schema.object({
8
13
  enabled: Schema.boolean().default(true).description("是否激活 Longbridge 连接器"),
@@ -39,7 +44,7 @@ var LongbridgeMarketDataService = class extends Service {
39
44
  };
40
45
  var LongbridgeTradeService = class extends Service {
41
46
  client;
42
- /** 插件配置(服务缝闸门 P0:dryRun 强制模拟 / liveTrading 总闸门)。 */
47
+ /** 插件配置(服务缝闸门 P0:dryRun 强制模拟 / liveTrading 非权威镜像——实盘授权由 @dshtrading/authority 的人工签署平面裁定)。 */
43
48
  config;
44
49
  constructor(ctx, options, serviceName = TRADING_HK_TRADE_KEY) {
45
50
  super(ctx, serviceName);
@@ -51,7 +56,7 @@ var LongbridgeTradeService = class extends Service {
51
56
  }
52
57
  async placeOrder(order) {
53
58
  const requestedDryRun = order.dryRun ?? true;
54
- if (!requestedDryRun && !this.config.liveTrading) throw new TradingServiceError("TRADING_LIVE_TRADING_DISABLED", `Longbridge TradeService.placeOrder rejected: the request asks for real execution (dryRun=${String(order.dryRun)}) but liveTrading=false — enable liveTrading explicitly or keep dryRun=true for a simulated fill.`);
59
+ if (!requestedDryRun && !liveTradingEnabled(this.config.liveTrading)) throw new TradingServiceError("TRADING_LIVE_TRADING_DISABLED", `Longbridge TradeService.placeOrder rejected: the request asks for real execution (dryRun=${String(order.dryRun)}) but the signed live-trading authority does not grant real execution (see @dshtrading/authority) — keep dryRun=true for a simulated fill.`);
55
60
  if (requestedDryRun || this.config.dryRun) return {
56
61
  id: `dry-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
57
62
  symbol: order.symbol,
@@ -66,7 +71,7 @@ var LongbridgeTradeService = class extends Service {
66
71
  return this.client.placeOrder(void 0, order);
67
72
  }
68
73
  async cancelOrder(orderId) {
69
- if (!this.config.liveTrading || this.config.dryRun) throw new TradingServiceError("TRADING_LIVE_TRADING_DISABLED", "Longbridge TradeService.cancelOrder rejected at the service seam: cancel is a live action and requires liveTrading=true with dryRun=false.");
74
+ if (!liveTradingEnabled(this.config.liveTrading) || this.config.dryRun) throw new TradingServiceError("TRADING_LIVE_TRADING_DISABLED", "Longbridge TradeService.cancelOrder rejected at the service seam: cancel is a live action and requires a signed live-trading grant (see @dshtrading/authority) with dryRun=false.");
70
75
  return this.client.cancelOrder(void 0, orderId);
71
76
  }
72
77
  async getPositions() {
@@ -220,7 +225,7 @@ function apply(ctx, config) {
220
225
  timestamp: Date.now()
221
226
  });
222
227
  }
223
- if (!config.liveTrading) return JSON.stringify({
228
+ if (!liveTradingEnabled(config.liveTrading)) return JSON.stringify({
224
229
  status: "rejected",
225
230
  code: "TRADING_LIVE_TRADING_DISABLED",
226
231
  message: "Live trading is disabled on Longbridge plugin."
@@ -238,7 +243,7 @@ function apply(ctx, config) {
238
243
  }));
239
244
  register(defineTool({
240
245
  name: "hk_cancel_order",
241
- description: "Cancel a HK stock order on Longbridge by order ID.",
246
+ description: "Cancel a HK stock order on Longbridge by order ID; an already-terminal order is reported as such, not as an error.",
242
247
  parameters: { ordId: {
243
248
  type: "string",
244
249
  required: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dshtrading/connector-longbridge",
3
3
  "description": "【模板】交易所连接器插件脚手架:Longbridge(longbridge)v2 插件骨架 —— 市场数据服务 + 交易服务 + 三态闸门 + BYOK 凭证 ref。生成器:node scripts/new-connector.mjs --slug <exchange>",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "./lib/index.d.ts",
@@ -21,7 +21,8 @@
21
21
  ],
22
22
  "license": "PolyForm-Noncommercial-1.0.0",
23
23
  "dependencies": {
24
- "@dshtrading/api": "^0.5.0"
24
+ "@dshtrading/authority": "^0.6.1",
25
+ "@dshtrading/api": "^0.6.1"
25
26
  },
26
27
  "peerDependencies": {
27
28
  "@deepseek-ai/cordis": ">=4.0.0",