toobit-trade-cli 1.0.2 → 1.0.3
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/dist/index.js +39 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -290,7 +290,7 @@ var ToobitRestClient = class {
|
|
|
290
290
|
const responseCode = parsed.code;
|
|
291
291
|
const responseMsg = parsed.msg || void 0;
|
|
292
292
|
const endpoint = `${config.method} ${config.path}`;
|
|
293
|
-
const hasBusinessCode = responseCode !== void 0 && responseCode !== 0;
|
|
293
|
+
const hasBusinessCode = responseCode !== void 0 && responseCode !== 0 && responseCode !== 200;
|
|
294
294
|
if (hasBusinessCode) {
|
|
295
295
|
const codeStr = String(responseCode);
|
|
296
296
|
const message = responseMsg || "Toobit API request failed.";
|
|
@@ -469,24 +469,26 @@ function registerAccountTools() {
|
|
|
469
469
|
inputSchema: {
|
|
470
470
|
type: "object",
|
|
471
471
|
properties: {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
472
|
+
fromUid: { type: "number", description: "From user ID" },
|
|
473
|
+
toUid: { type: "number", description: "To user ID" },
|
|
474
|
+
fromAccountType: { type: "string", enum: ["MAIN", "FUTURES", "COPY_TRADING"], description: "MAIN=spot, FUTURES=contract, COPY_TRADING=copy trading" },
|
|
475
|
+
toAccountType: { type: "string", enum: ["MAIN", "FUTURES", "COPY_TRADING"], description: "MAIN=spot, FUTURES=contract, COPY_TRADING=copy trading" },
|
|
476
|
+
asset: { type: "string", description: "Asset name, e.g. USDT" },
|
|
477
|
+
quantity: { type: "string", description: "Transfer quantity" }
|
|
477
478
|
},
|
|
478
|
-
required: ["
|
|
479
|
+
required: ["fromUid", "toUid", "fromAccountType", "toAccountType", "asset", "quantity"]
|
|
479
480
|
},
|
|
480
481
|
handler: async (rawArgs, context) => {
|
|
481
482
|
const args = asRecord(rawArgs);
|
|
482
483
|
const response = await context.client.privatePost(
|
|
483
484
|
"/api/v1/subAccount/transfer",
|
|
484
485
|
compactObject({
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
486
|
+
fromUid: readNumber(args, "fromUid"),
|
|
487
|
+
toUid: readNumber(args, "toUid"),
|
|
488
|
+
fromAccountType: requireString(args, "fromAccountType"),
|
|
489
|
+
toAccountType: requireString(args, "toAccountType"),
|
|
490
|
+
asset: requireString(args, "asset"),
|
|
491
|
+
quantity: requireString(args, "quantity")
|
|
490
492
|
}),
|
|
491
493
|
privateRateLimit("account_sub_transfer", 5)
|
|
492
494
|
);
|
|
@@ -581,18 +583,18 @@ function registerAccountTools() {
|
|
|
581
583
|
inputSchema: {
|
|
582
584
|
type: "object",
|
|
583
585
|
properties: {
|
|
584
|
-
|
|
585
|
-
chainType: { type: "string" }
|
|
586
|
+
coin: { type: "string", description: "Asset name, e.g. USDT" },
|
|
587
|
+
chainType: { type: "string", description: "Chain type, e.g. ERC20, TRC20, OMNI" }
|
|
586
588
|
},
|
|
587
|
-
required: ["
|
|
589
|
+
required: ["coin", "chainType"]
|
|
588
590
|
},
|
|
589
591
|
handler: async (rawArgs, context) => {
|
|
590
592
|
const args = asRecord(rawArgs);
|
|
591
593
|
const response = await context.client.privateGet(
|
|
592
594
|
"/api/v1/account/deposit/address",
|
|
593
595
|
compactObject({
|
|
594
|
-
|
|
595
|
-
chainType:
|
|
596
|
+
coin: requireString(args, "coin"),
|
|
597
|
+
chainType: requireString(args, "chainType")
|
|
596
598
|
}),
|
|
597
599
|
privateRateLimit("account_get_deposit_address", 20)
|
|
598
600
|
);
|
|
@@ -675,38 +677,45 @@ function registerFuturesTools() {
|
|
|
675
677
|
{
|
|
676
678
|
name: "futures_place_order",
|
|
677
679
|
module: "futures",
|
|
678
|
-
description: "Place a USDT-M futures order. [CAUTION] Executes real trades. Private endpoint. Rate limit: 20 req/s.",
|
|
680
|
+
description: "Place a USDT-M futures order. For market orders, set orderType to MARKET \u2014 the handler automatically converts to type=LIMIT + priceType=MARKET as required by Toobit API. [CAUTION] Executes real trades. Private endpoint. Rate limit: 20 req/s.",
|
|
679
681
|
isWrite: true,
|
|
680
682
|
inputSchema: {
|
|
681
683
|
type: "object",
|
|
682
684
|
properties: {
|
|
683
|
-
symbol: { type: "string", description: "e.g.
|
|
685
|
+
symbol: { type: "string", description: "Futures contract symbol, e.g. BTC-SWAP-USDT" },
|
|
684
686
|
side: { type: "string", enum: ["BUY_OPEN", "SELL_OPEN", "BUY_CLOSE", "SELL_CLOSE"] },
|
|
685
|
-
orderType: { type: "string", enum: ["LIMIT", "MARKET"], description: "
|
|
687
|
+
orderType: { type: "string", enum: ["LIMIT", "MARKET", "STOP"], description: "LIMIT=limit order, MARKET=market order (auto-converted), STOP=conditional order" },
|
|
686
688
|
quantity: { type: "string", description: "Order quantity (contracts)" },
|
|
687
|
-
price: { type: "string", description: "Required for LIMIT" },
|
|
689
|
+
price: { type: "string", description: "Required for LIMIT orders with priceType=INPUT" },
|
|
688
690
|
leverage: { type: "string", description: "Leverage, e.g. 10" },
|
|
689
|
-
|
|
690
|
-
priceType: { type: "string", enum: ["INPUT", "OPPONENT", "QUEUE", "OVER", "MARKET"], description: "Price type
|
|
691
|
-
|
|
692
|
-
timeInForce: { type: "string", enum: ["GTC", "IOC", "FOK"
|
|
691
|
+
newClientOrderId: { type: "string", description: "Unique client order ID. Auto-generated if omitted." },
|
|
692
|
+
priceType: { type: "string", enum: ["INPUT", "OPPONENT", "QUEUE", "OVER", "MARKET"], description: "Price type. INPUT=specified price, MARKET=market price" },
|
|
693
|
+
stopPrice: { type: "string", description: "Trigger price for STOP orders" },
|
|
694
|
+
timeInForce: { type: "string", enum: ["GTC", "IOC", "FOK"] }
|
|
693
695
|
},
|
|
694
696
|
required: ["symbol", "side", "orderType", "quantity"]
|
|
695
697
|
},
|
|
696
698
|
handler: async (rawArgs, context) => {
|
|
697
699
|
const args = asRecord(rawArgs);
|
|
700
|
+
let orderType = requireString(args, "orderType");
|
|
701
|
+
let priceType = readString(args, "priceType");
|
|
702
|
+
if (orderType === "MARKET") {
|
|
703
|
+
orderType = "LIMIT";
|
|
704
|
+
priceType = "MARKET";
|
|
705
|
+
}
|
|
706
|
+
const clientId = readString(args, "newClientOrderId") ?? `mcp_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
698
707
|
const response = await context.client.privatePost(
|
|
699
708
|
"/api/v1/futures/order",
|
|
700
709
|
compactObject({
|
|
701
710
|
symbol: requireString(args, "symbol"),
|
|
702
711
|
side: requireString(args, "side"),
|
|
703
|
-
|
|
712
|
+
type: orderType,
|
|
704
713
|
quantity: requireString(args, "quantity"),
|
|
705
714
|
price: readString(args, "price"),
|
|
706
715
|
leverage: readString(args, "leverage"),
|
|
707
|
-
|
|
708
|
-
priceType
|
|
709
|
-
|
|
716
|
+
newClientOrderId: clientId,
|
|
717
|
+
priceType,
|
|
718
|
+
stopPrice: readString(args, "stopPrice"),
|
|
710
719
|
timeInForce: readString(args, "timeInForce")
|
|
711
720
|
}),
|
|
712
721
|
privateRateLimit("futures_place_order", 20)
|
|
@@ -1037,7 +1046,7 @@ function registerFuturesTools() {
|
|
|
1037
1046
|
type: "object",
|
|
1038
1047
|
properties: {
|
|
1039
1048
|
symbol: { type: "string", description: "e.g. BTCUSDT" },
|
|
1040
|
-
marginType: { type: "string", enum: ["
|
|
1049
|
+
marginType: { type: "string", enum: ["CROSS", "ISOLATED"], description: "CROSS=cross margin, ISOLATED=isolated margin" }
|
|
1041
1050
|
},
|
|
1042
1051
|
required: ["symbol", "marginType"]
|
|
1043
1052
|
},
|