@dshtrading/connector-tencent 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +2 -2
- package/lib/index.js +27 -4
- package/package.json +3 -2
package/lib/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ interface Config {
|
|
|
15
15
|
market: MarketOption;
|
|
16
16
|
/** 交易安全闸门(铁律 #3):true 时下单类工具强制 dry-run。 */
|
|
17
17
|
dryRun: boolean;
|
|
18
|
-
/**
|
|
18
|
+
/** 实盘镜像:默认 false。它是非权威镜像——只能收紧、永不能授予;实盘授权由 @dshtrading/authority 的人工签署平面裁定 [S4]。 */
|
|
19
19
|
liveTrading: boolean;
|
|
20
20
|
}
|
|
21
21
|
declare const Config: Schema<Config>;
|
|
@@ -76,7 +76,7 @@ declare function buildDryRunReceipt(market: MarketOption, args: PlaceOrderArgs,
|
|
|
76
76
|
interface PlaceOrderToolDeps {
|
|
77
77
|
/** 行情服务(dry-run 回执的市价参照),按接口取用,不直连 HTTP。 */
|
|
78
78
|
readonly marketData: Pick<MarketDataService, 'getTicker'>;
|
|
79
|
-
/** 插件配置(market 分流 + dryRun 强制模拟 / liveTrading
|
|
79
|
+
/** 插件配置(market 分流 + dryRun 强制模拟 / liveTrading 非权威镜像——实盘授权由 @dshtrading/authority 人工签署平面裁定)。 */
|
|
80
80
|
readonly config: Config;
|
|
81
81
|
}
|
|
82
82
|
/**
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { INTERVAL_VOCABULARY, TencentRestClient, TradingServiceError, klineDateToEpochMs, minuteKlineTimeToEpochMs, normalizeCnSymbol, normalizeHkSymbol, normalizeSymbol, parseCnOrderbook, toCanonicalTencentSymbol, wallTimeToEpochMs } 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
|
|
6
7
|
/**
|
|
8
|
+
* 腾讯行情连接器插件(dsh-trading cn+hk 双市场切片):**单包双市场**——这是手册
|
|
9
|
+
* (docs/replication.md §1-§4「一市场一连接器包」)之外的**多实例新模式**:
|
|
10
|
+
*
|
|
11
|
+
* - 同一个插件包(插件名 `dsh-trading-tencent`,export const name)被挂载两次,
|
|
12
|
+
* preset 行用**不同行 id**(`dsh-trading-cn-connector` / `dsh-trading-hk-connector`)
|
|
13
|
+
* 指向**同一 bare 包名**(`@dshtrading/connector-tencent`),以 `config.market`
|
|
14
|
+
* 分流 cn/hk(行 id 即命名空间——不同 id 即两个独立实例,互不整行替换);
|
|
15
|
+
* - provide 服务键按实例分流:cn → `tradingCnMarketData`,hk → `tradingHkMarketData`
|
|
16
|
+
* (api 包 Context 模块增强统一声明两个键);
|
|
17
|
+
* - 工具按市场注册:market=cn 挂 `cn_get_ticker/cn_get_klines/cn_place_order`,
|
|
18
|
+
* market=hk 挂 `hk_` 同名三件。工具前缀落在 base 闸门模式
|
|
19
|
+
* `/^(?:crypto|us|cn|hk)_(?:place|cancel)_order$/` 内,闸门接线与 crypto/us 同构。
|
|
20
|
+
*
|
|
21
|
+
* 下单三段闸门语义照抄 crypto/us 切片(README 铁律 #3 / S4 修订);审批不在工具内做。
|
|
22
|
+
* 腾讯本身无交易 API——live 路径恒为 TRADING_NOT_IMPLEMENTED(券商 API 是后续任务)。
|
|
23
|
+
*
|
|
24
|
+
* 合规(README 铁律 #5):腾讯公共行情端点,无 key、无官方授权;个人使用边界自负
|
|
25
|
+
* (详见 src/rest.ts 头注与 README 数据源节)。
|
|
26
|
+
*
|
|
27
|
+
* @module @dshtrading/connector-tencent
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
7
30
|
* Cordis 插件名:`dsh-trading-*` 命名空间(TEMPLATES §8)。**两个 preset 实例共享此
|
|
8
31
|
* 插件名**——实例区分靠 preset 行 id(dsh-trading-cn-connector / dsh-trading-hk-connector)
|
|
9
32
|
* 与 config.market,不再依赖插件名后缀(单包双市场与 crypto/us 的「一市场一插件名」不同)。
|
|
@@ -61,10 +84,10 @@ var TencentMarketDataService = class extends Service {
|
|
|
61
84
|
};
|
|
62
85
|
function evaluateOrderGate(config, args) {
|
|
63
86
|
const requestedDryRun = args.dryRun ?? true;
|
|
64
|
-
if (!requestedDryRun && !config.liveTrading) return {
|
|
87
|
+
if (!requestedDryRun && !liveTradingEnabled(config.liveTrading)) return {
|
|
65
88
|
action: "reject",
|
|
66
89
|
code: "TRADING_LIVE_TRADING_DISABLED",
|
|
67
|
-
message: `${config.market}_place_order rejected: the call requests real execution (dryRun=${String(args.dryRun)}) but live trading is disabled (
|
|
90
|
+
message: `${config.market}_place_order rejected: the call requests real execution (dryRun=${String(args.dryRun)}) but live trading is disabled (no signed live-trading grant from the authority plane). Ask the operator to sign a live-trading grant (packages/authority/bin/sign-live-trading.mjs) after confirmation, or keep dryRun=true for a simulated fill.`
|
|
68
91
|
};
|
|
69
92
|
if (requestedDryRun || config.dryRun) return { action: "simulate" };
|
|
70
93
|
return { action: "live" };
|
|
@@ -133,7 +156,7 @@ function createPlaceOrderTool(deps) {
|
|
|
133
156
|
const market = deps.config.market;
|
|
134
157
|
return defineTool({
|
|
135
158
|
name: `${market}_place_order`,
|
|
136
|
-
description: `Place a ${market === "hk" ? "Hong Kong" : "China A-share"} stock order, or simulate one. dryRun defaults to true and returns a DRY-RUN simulated fill receipt referencing the latest Tencent public quote. Real execution (dryRun=false) requires the
|
|
159
|
+
description: `Place a ${market === "hk" ? "Hong Kong" : "China A-share"} stock order, or simulate one. dryRun defaults to true and returns a DRY-RUN simulated fill receipt referencing the latest Tencent public quote. Real execution (dryRun=false) requires the signed live-trading grant plus user approval, and is not implemented yet in this slice (Tencent has no trading API).`,
|
|
137
160
|
parameters: {
|
|
138
161
|
symbol: {
|
|
139
162
|
type: "string",
|
|
@@ -163,7 +186,7 @@ function createPlaceOrderTool(deps) {
|
|
|
163
186
|
},
|
|
164
187
|
dryRun: {
|
|
165
188
|
type: "boolean",
|
|
166
|
-
description: "true (default) = simulate only and return a DRY-RUN receipt; false = request real execution (gated by
|
|
189
|
+
description: "true (default) = simulate only and return a DRY-RUN receipt; false = request real execution (gated by the signed live-trading authority and user approval)",
|
|
167
190
|
default: true
|
|
168
191
|
}
|
|
169
192
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dshtrading/connector-tencent",
|
|
3
3
|
"description": "CN + HK dual-market connector plugin for dsh-trading: public market data from Tencent quote/kline endpoints implementing the @dshtrading/api contracts (single package, per-instance market split; no key, no official authorization — personal use boundary at your own discretion)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
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/
|
|
24
|
+
"@dshtrading/authority": "^0.6.0",
|
|
25
|
+
"@dshtrading/api": "^0.6.0"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"@deepseek-ai/cordis": ">=4.0.0",
|