@dshtrading/connector-tiger 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 +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +9 -4
- package/package.json +3 -2
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 TigerMarketDataService extends Service implements MarketDataServic
|
|
|
27
27
|
}
|
|
28
28
|
declare class TigerTradeService 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: TigerRestOptions & {
|
|
33
33
|
config: Config;
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { INTERVAL_VOCABULARY, TigerRestClient, TradingServiceError, generateTigerSignature, toTigerSymbol as toTigerSymbol$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-tiger
|
|
9
|
+
* 老虎证券 (Tiger Trade) 港美股连接器插件。
|
|
10
|
+
*/
|
|
6
11
|
const name = "dsh-trading-hk-connector-tiger";
|
|
7
12
|
const Config = Schema.object({
|
|
8
13
|
enabled: Schema.boolean().default(true).description("是否激活 Tiger 连接器"),
|
|
@@ -39,7 +44,7 @@ var TigerMarketDataService = class extends Service {
|
|
|
39
44
|
};
|
|
40
45
|
var TigerTradeService = 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 TigerTradeService = 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", `Tiger TradeService.placeOrder rejected: the request asks for real execution (dryRun=${String(order.dryRun)}) but
|
|
59
|
+
if (!requestedDryRun && !liveTradingEnabled(this.config.liveTrading)) throw new TradingServiceError("TRADING_LIVE_TRADING_DISABLED", `Tiger 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 TigerTradeService = 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", "Tiger TradeService.cancelOrder rejected at the service seam: cancel is a live action and requires
|
|
74
|
+
if (!liveTradingEnabled(this.config.liveTrading) || this.config.dryRun) throw new TradingServiceError("TRADING_LIVE_TRADING_DISABLED", "Tiger 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() {
|
|
@@ -218,7 +223,7 @@ function apply(ctx, config) {
|
|
|
218
223
|
timestamp: Date.now()
|
|
219
224
|
});
|
|
220
225
|
}
|
|
221
|
-
if (!config.liveTrading) return JSON.stringify({
|
|
226
|
+
if (!liveTradingEnabled(config.liveTrading)) return JSON.stringify({
|
|
222
227
|
status: "rejected",
|
|
223
228
|
code: "TRADING_LIVE_TRADING_DISABLED",
|
|
224
229
|
message: "Live trading is disabled on Tiger plugin."
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dshtrading/connector-tiger",
|
|
3
3
|
"description": "【模板】交易所连接器插件脚手架:Tiger(tiger)v2 插件骨架 —— 市场数据服务 + 交易服务 + 三态闸门 + BYOK 凭证 ref。生成器:node scripts/new-connector.mjs --slug <exchange>",
|
|
4
|
-
"version": "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/
|
|
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",
|