@okx_ai/okx-trade-cli 1.2.3 → 1.2.4-beta.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/dist/index.js +443 -416
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/scripts/postinstall.js +20 -0
package/dist/index.js
CHANGED
|
@@ -2391,7 +2391,7 @@ function registerGridTools() {
|
|
|
2391
2391
|
algoOrdType: {
|
|
2392
2392
|
type: "string",
|
|
2393
2393
|
enum: ["grid", "contract_grid", "moon_grid"],
|
|
2394
|
-
description: "grid=Spot, contract_grid=Contract, moon_grid=Moon"
|
|
2394
|
+
description: "Grid bot type. grid=Spot, contract_grid=Contract, moon_grid=Moon. Must match the bot's actual type when filtering by algoId."
|
|
2395
2395
|
},
|
|
2396
2396
|
status: {
|
|
2397
2397
|
type: "string",
|
|
@@ -2403,7 +2403,8 @@ function registerGridTools() {
|
|
|
2403
2403
|
description: "e.g. BTC-USDT"
|
|
2404
2404
|
},
|
|
2405
2405
|
algoId: {
|
|
2406
|
-
type: "string"
|
|
2406
|
+
type: "string",
|
|
2407
|
+
description: "Grid bot algo order ID (returned by grid_create_order or grid_get_orders). This is NOT a normal trade order ID."
|
|
2407
2408
|
},
|
|
2408
2409
|
after: {
|
|
2409
2410
|
type: "string",
|
|
@@ -2451,10 +2452,11 @@ function registerGridTools() {
|
|
|
2451
2452
|
algoOrdType: {
|
|
2452
2453
|
type: "string",
|
|
2453
2454
|
enum: ["grid", "contract_grid", "moon_grid"],
|
|
2454
|
-
description: "grid=Spot, contract_grid=Contract, moon_grid=Moon"
|
|
2455
|
+
description: "Must match the bot's actual type (use the algoOrdType value returned by grid_get_orders). grid=Spot, contract_grid=Contract, moon_grid=Moon."
|
|
2455
2456
|
},
|
|
2456
2457
|
algoId: {
|
|
2457
|
-
type: "string"
|
|
2458
|
+
type: "string",
|
|
2459
|
+
description: "Grid bot algo order ID (returned by grid_create_order or grid_get_orders). This is NOT a normal trade order ID."
|
|
2458
2460
|
}
|
|
2459
2461
|
},
|
|
2460
2462
|
required: ["algoOrdType", "algoId"]
|
|
@@ -2483,10 +2485,11 @@ function registerGridTools() {
|
|
|
2483
2485
|
algoOrdType: {
|
|
2484
2486
|
type: "string",
|
|
2485
2487
|
enum: ["grid", "contract_grid", "moon_grid"],
|
|
2486
|
-
description: "grid=Spot, contract_grid=Contract, moon_grid=Moon"
|
|
2488
|
+
description: "Must match the bot's actual type (use the algoOrdType value returned by grid_get_orders). grid=Spot, contract_grid=Contract, moon_grid=Moon."
|
|
2487
2489
|
},
|
|
2488
2490
|
algoId: {
|
|
2489
|
-
type: "string"
|
|
2491
|
+
type: "string",
|
|
2492
|
+
description: "Grid bot algo order ID (returned by grid_create_order or grid_get_orders). This is NOT a normal trade order ID."
|
|
2490
2493
|
},
|
|
2491
2494
|
type: {
|
|
2492
2495
|
type: "string",
|
|
@@ -2494,7 +2497,8 @@ function registerGridTools() {
|
|
|
2494
2497
|
description: "filled=executed trades (default); live=pending orders"
|
|
2495
2498
|
},
|
|
2496
2499
|
groupId: {
|
|
2497
|
-
type: "string"
|
|
2500
|
+
type: "string",
|
|
2501
|
+
description: "Group ID \u2014 a buy-sell pair shares the same groupId. Use to filter a specific grid level."
|
|
2498
2502
|
},
|
|
2499
2503
|
after: {
|
|
2500
2504
|
type: "string",
|
|
@@ -2629,12 +2633,13 @@ function registerGridTools() {
|
|
|
2629
2633
|
type: "object",
|
|
2630
2634
|
properties: {
|
|
2631
2635
|
algoId: {
|
|
2632
|
-
type: "string"
|
|
2636
|
+
type: "string",
|
|
2637
|
+
description: "Grid bot algo order ID (returned by grid_create_order or grid_get_orders). This is NOT a normal trade order ID."
|
|
2633
2638
|
},
|
|
2634
2639
|
algoOrdType: {
|
|
2635
2640
|
type: "string",
|
|
2636
2641
|
enum: ["grid", "contract_grid", "moon_grid"],
|
|
2637
|
-
description: "grid=Spot, contract_grid=Contract, moon_grid=Moon"
|
|
2642
|
+
description: "Must match the bot's actual type (use the algoOrdType value returned by grid_get_orders). grid=Spot, contract_grid=Contract, moon_grid=Moon."
|
|
2638
2643
|
},
|
|
2639
2644
|
instId: {
|
|
2640
2645
|
type: "string",
|
|
@@ -2766,7 +2771,10 @@ function registerDcaTools() {
|
|
|
2766
2771
|
inputSchema: {
|
|
2767
2772
|
type: "object",
|
|
2768
2773
|
properties: {
|
|
2769
|
-
algoId: {
|
|
2774
|
+
algoId: {
|
|
2775
|
+
type: "string",
|
|
2776
|
+
description: "DCA bot algo order ID (returned by dca_create_order or dca_get_orders). This is NOT a normal trade order ID."
|
|
2777
|
+
}
|
|
2770
2778
|
},
|
|
2771
2779
|
required: ["algoId"]
|
|
2772
2780
|
},
|
|
@@ -2794,7 +2802,10 @@ function registerDcaTools() {
|
|
|
2794
2802
|
enum: ["active", "history"],
|
|
2795
2803
|
description: "active=running (default); history=stopped"
|
|
2796
2804
|
},
|
|
2797
|
-
algoId: {
|
|
2805
|
+
algoId: {
|
|
2806
|
+
type: "string",
|
|
2807
|
+
description: "DCA bot algo order ID (returned by dca_create_order or dca_get_orders). This is NOT a normal trade order ID."
|
|
2808
|
+
},
|
|
2798
2809
|
instId: { type: "string", description: "Filter by instrument, e.g. BTC-USDT-SWAP (optional)" },
|
|
2799
2810
|
after: { type: "string", description: "Pagination: before this algo ID" },
|
|
2800
2811
|
before: { type: "string", description: "Pagination: after this algo ID" },
|
|
@@ -2829,7 +2840,10 @@ function registerDcaTools() {
|
|
|
2829
2840
|
inputSchema: {
|
|
2830
2841
|
type: "object",
|
|
2831
2842
|
properties: {
|
|
2832
|
-
algoId: {
|
|
2843
|
+
algoId: {
|
|
2844
|
+
type: "string",
|
|
2845
|
+
description: "DCA bot algo order ID (returned by dca_create_order or dca_get_orders). This is NOT a normal trade order ID."
|
|
2846
|
+
}
|
|
2833
2847
|
},
|
|
2834
2848
|
required: ["algoId"]
|
|
2835
2849
|
},
|
|
@@ -2852,7 +2866,10 @@ function registerDcaTools() {
|
|
|
2852
2866
|
inputSchema: {
|
|
2853
2867
|
type: "object",
|
|
2854
2868
|
properties: {
|
|
2855
|
-
algoId: {
|
|
2869
|
+
algoId: {
|
|
2870
|
+
type: "string",
|
|
2871
|
+
description: "DCA bot algo order ID (returned by dca_create_order or dca_get_orders). This is NOT a normal trade order ID."
|
|
2872
|
+
},
|
|
2856
2873
|
cycleId: { type: "string", description: "Omit to list all cycles; provide to get orders within a cycle" },
|
|
2857
2874
|
after: { type: "string", description: "Pagination cursor \u2014 applies to cycle-list mode only (when cycleId is omitted)" },
|
|
2858
2875
|
before: { type: "string", description: "Pagination cursor \u2014 applies to cycle-list mode only (when cycleId is omitted)" },
|
|
@@ -3139,639 +3156,645 @@ function registerEarnTools() {
|
|
|
3139
3156
|
}
|
|
3140
3157
|
];
|
|
3141
3158
|
}
|
|
3142
|
-
|
|
3143
|
-
function normalize5(response) {
|
|
3144
|
-
return {
|
|
3145
|
-
endpoint: response.endpoint,
|
|
3146
|
-
requestTime: response.requestTime,
|
|
3147
|
-
data: response.data
|
|
3148
|
-
};
|
|
3149
|
-
}
|
|
3150
|
-
function registerFuturesTools() {
|
|
3159
|
+
function registerOnchainEarnTools() {
|
|
3151
3160
|
return [
|
|
3161
|
+
// -------------------------------------------------------------------------
|
|
3162
|
+
// Get Offers
|
|
3163
|
+
// -------------------------------------------------------------------------
|
|
3152
3164
|
{
|
|
3153
|
-
name: "
|
|
3154
|
-
module: "
|
|
3155
|
-
description: "
|
|
3156
|
-
isWrite:
|
|
3165
|
+
name: "onchain_earn_get_offers",
|
|
3166
|
+
module: "earn.onchain",
|
|
3167
|
+
description: "Get available on-chain earn (staking/DeFi) offers. Returns investment products with APY, terms, and limits. Private endpoint. Rate limit: 3 req/s.",
|
|
3168
|
+
isWrite: false,
|
|
3157
3169
|
inputSchema: {
|
|
3158
3170
|
type: "object",
|
|
3159
3171
|
properties: {
|
|
3160
|
-
|
|
3161
|
-
type: "string",
|
|
3162
|
-
description: "e.g. BTC-USDT-240329"
|
|
3163
|
-
},
|
|
3164
|
-
tdMode: {
|
|
3165
|
-
type: "string",
|
|
3166
|
-
enum: ["cross", "isolated"],
|
|
3167
|
-
description: "cross|isolated margin"
|
|
3168
|
-
},
|
|
3169
|
-
side: {
|
|
3170
|
-
type: "string",
|
|
3171
|
-
enum: ["buy", "sell"],
|
|
3172
|
-
description: "one-way: buy=open long, sell=open short (use reduceOnly=true to close); hedge: combined with posSide"
|
|
3173
|
-
},
|
|
3174
|
-
posSide: {
|
|
3175
|
-
type: "string",
|
|
3176
|
-
enum: ["long", "short", "net"],
|
|
3177
|
-
description: "net=one-way mode (default); long/short=hedge mode only"
|
|
3178
|
-
},
|
|
3179
|
-
ordType: {
|
|
3180
|
-
type: "string",
|
|
3181
|
-
enum: ["market", "limit", "post_only", "fok", "ioc"],
|
|
3182
|
-
description: "market(no px)|limit(px req)|post_only(maker)|fok(all-or-cancel)|ioc(partial fill)"
|
|
3183
|
-
},
|
|
3184
|
-
sz: {
|
|
3185
|
-
type: "string",
|
|
3186
|
-
description: "Number of contracts (NOT USDT amount). Use market_get_instruments to get ctVal for conversion."
|
|
3187
|
-
},
|
|
3188
|
-
px: {
|
|
3189
|
-
type: "string",
|
|
3190
|
-
description: "Required for limit/post_only/fok/ioc"
|
|
3191
|
-
},
|
|
3192
|
-
reduceOnly: {
|
|
3193
|
-
type: "boolean",
|
|
3194
|
-
description: "Close/reduce only, no new position (one-way mode)"
|
|
3195
|
-
},
|
|
3196
|
-
clOrdId: {
|
|
3197
|
-
type: "string",
|
|
3198
|
-
description: "Client order ID (max 32 chars)"
|
|
3199
|
-
},
|
|
3200
|
-
tpTriggerPx: {
|
|
3201
|
-
type: "string",
|
|
3202
|
-
description: "TP trigger price; places TP at tpOrdPx"
|
|
3203
|
-
},
|
|
3204
|
-
tpOrdPx: {
|
|
3172
|
+
productId: {
|
|
3205
3173
|
type: "string",
|
|
3206
|
-
description: "
|
|
3174
|
+
description: "Specific product ID to query. Omit for all offers."
|
|
3207
3175
|
},
|
|
3208
|
-
|
|
3176
|
+
protocolType: {
|
|
3209
3177
|
type: "string",
|
|
3210
|
-
description: "
|
|
3178
|
+
description: "Protocol type filter: staking, defi. Omit for all types."
|
|
3211
3179
|
},
|
|
3212
|
-
|
|
3180
|
+
ccy: {
|
|
3213
3181
|
type: "string",
|
|
3214
|
-
description: "
|
|
3182
|
+
description: "Currency filter, e.g. ETH. Omit for all currencies."
|
|
3215
3183
|
}
|
|
3216
|
-
}
|
|
3217
|
-
required: ["instId", "tdMode", "side", "ordType", "sz"]
|
|
3184
|
+
}
|
|
3218
3185
|
},
|
|
3219
3186
|
handler: async (rawArgs, context) => {
|
|
3220
3187
|
const args = asRecord(rawArgs);
|
|
3221
|
-
const
|
|
3222
|
-
|
|
3223
|
-
const tpOrdPx = readString(args, "tpOrdPx");
|
|
3224
|
-
const slTriggerPx = readString(args, "slTriggerPx");
|
|
3225
|
-
const slOrdPx = readString(args, "slOrdPx");
|
|
3226
|
-
const algoEntry = compactObject({ tpTriggerPx, tpOrdPx, slTriggerPx, slOrdPx });
|
|
3227
|
-
const attachAlgoOrds = Object.keys(algoEntry).length > 0 ? [algoEntry] : void 0;
|
|
3228
|
-
const response = await context.client.privatePost(
|
|
3229
|
-
"/api/v5/trade/order",
|
|
3188
|
+
const response = await context.client.privateGet(
|
|
3189
|
+
"/api/v5/finance/staking-defi/offers",
|
|
3230
3190
|
compactObject({
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
posSide: readString(args, "posSide"),
|
|
3235
|
-
ordType: requireString(args, "ordType"),
|
|
3236
|
-
sz: requireString(args, "sz"),
|
|
3237
|
-
px: readString(args, "px"),
|
|
3238
|
-
reduceOnly: typeof reduceOnly === "boolean" ? String(reduceOnly) : void 0,
|
|
3239
|
-
clOrdId: readString(args, "clOrdId"),
|
|
3240
|
-
tag: context.config.sourceTag,
|
|
3241
|
-
attachAlgoOrds
|
|
3191
|
+
productId: readString(args, "productId"),
|
|
3192
|
+
protocolType: readString(args, "protocolType"),
|
|
3193
|
+
ccy: readString(args, "ccy")
|
|
3242
3194
|
}),
|
|
3243
|
-
privateRateLimit("
|
|
3195
|
+
privateRateLimit("onchain_earn_get_offers", 3)
|
|
3244
3196
|
);
|
|
3245
|
-
return
|
|
3197
|
+
return normalizeResponse(response);
|
|
3246
3198
|
}
|
|
3247
3199
|
},
|
|
3200
|
+
// -------------------------------------------------------------------------
|
|
3201
|
+
// Purchase
|
|
3202
|
+
// -------------------------------------------------------------------------
|
|
3248
3203
|
{
|
|
3249
|
-
name: "
|
|
3250
|
-
module: "
|
|
3251
|
-
description: "
|
|
3204
|
+
name: "onchain_earn_purchase",
|
|
3205
|
+
module: "earn.onchain",
|
|
3206
|
+
description: "Purchase on-chain earn (staking/DeFi) product. [CAUTION] Moves real funds into staking/DeFi product. Not supported in demo/simulated trading mode. Private endpoint. Rate limit: 2 req/s.",
|
|
3252
3207
|
isWrite: true,
|
|
3253
3208
|
inputSchema: {
|
|
3254
3209
|
type: "object",
|
|
3255
3210
|
properties: {
|
|
3256
|
-
|
|
3211
|
+
productId: {
|
|
3257
3212
|
type: "string",
|
|
3258
|
-
description: "
|
|
3213
|
+
description: "Product ID to purchase"
|
|
3259
3214
|
},
|
|
3260
|
-
|
|
3261
|
-
type: "
|
|
3215
|
+
investData: {
|
|
3216
|
+
type: "array",
|
|
3217
|
+
description: "Investment data array: [{ccy, amt}]. Each item specifies currency and amount.",
|
|
3218
|
+
items: {
|
|
3219
|
+
type: "object",
|
|
3220
|
+
properties: {
|
|
3221
|
+
ccy: { type: "string", description: "Currency, e.g. ETH" },
|
|
3222
|
+
amt: { type: "string", description: "Amount to invest" }
|
|
3223
|
+
},
|
|
3224
|
+
required: ["ccy", "amt"]
|
|
3225
|
+
}
|
|
3262
3226
|
},
|
|
3263
|
-
|
|
3227
|
+
term: {
|
|
3264
3228
|
type: "string",
|
|
3265
|
-
description: "
|
|
3229
|
+
description: "Investment term in days. Required for fixed-term products."
|
|
3230
|
+
},
|
|
3231
|
+
tag: {
|
|
3232
|
+
type: "string",
|
|
3233
|
+
description: "Order tag for tracking (optional)."
|
|
3266
3234
|
}
|
|
3267
3235
|
},
|
|
3268
|
-
required: ["
|
|
3236
|
+
required: ["productId", "investData"]
|
|
3269
3237
|
},
|
|
3270
3238
|
handler: async (rawArgs, context) => {
|
|
3239
|
+
assertNotDemo(context.config, "onchain_earn_purchase");
|
|
3271
3240
|
const args = asRecord(rawArgs);
|
|
3272
3241
|
const response = await context.client.privatePost(
|
|
3273
|
-
"/api/v5/
|
|
3242
|
+
"/api/v5/finance/staking-defi/purchase",
|
|
3274
3243
|
compactObject({
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3244
|
+
productId: requireString(args, "productId"),
|
|
3245
|
+
investData: args.investData,
|
|
3246
|
+
term: readString(args, "term"),
|
|
3247
|
+
tag: readString(args, "tag")
|
|
3278
3248
|
}),
|
|
3279
|
-
privateRateLimit("
|
|
3249
|
+
privateRateLimit("onchain_earn_purchase", 2)
|
|
3280
3250
|
);
|
|
3281
|
-
return
|
|
3251
|
+
return normalizeResponse(response);
|
|
3282
3252
|
}
|
|
3283
3253
|
},
|
|
3254
|
+
// -------------------------------------------------------------------------
|
|
3255
|
+
// Redeem
|
|
3256
|
+
// -------------------------------------------------------------------------
|
|
3284
3257
|
{
|
|
3285
|
-
name: "
|
|
3286
|
-
module: "
|
|
3287
|
-
description: "
|
|
3288
|
-
isWrite:
|
|
3258
|
+
name: "onchain_earn_redeem",
|
|
3259
|
+
module: "earn.onchain",
|
|
3260
|
+
description: "Redeem on-chain earn (staking/DeFi) investment. [CAUTION] Withdraws funds from staking/DeFi product. Some products may have lock periods. Not supported in demo mode. Private endpoint. Rate limit: 2 req/s.",
|
|
3261
|
+
isWrite: true,
|
|
3289
3262
|
inputSchema: {
|
|
3290
3263
|
type: "object",
|
|
3291
3264
|
properties: {
|
|
3292
|
-
instId: {
|
|
3293
|
-
type: "string",
|
|
3294
|
-
description: "e.g. BTC-USDT-240329"
|
|
3295
|
-
},
|
|
3296
3265
|
ordId: {
|
|
3297
3266
|
type: "string",
|
|
3298
|
-
description: "
|
|
3267
|
+
description: "Order ID to redeem"
|
|
3299
3268
|
},
|
|
3300
|
-
|
|
3269
|
+
protocolType: {
|
|
3301
3270
|
type: "string",
|
|
3302
|
-
description: "
|
|
3271
|
+
description: "Protocol type: staking, defi"
|
|
3272
|
+
},
|
|
3273
|
+
allowEarlyRedeem: {
|
|
3274
|
+
type: "boolean",
|
|
3275
|
+
description: "Allow early redemption for fixed-term products (may incur penalties). Default false."
|
|
3303
3276
|
}
|
|
3304
3277
|
},
|
|
3305
|
-
required: ["
|
|
3278
|
+
required: ["ordId", "protocolType"]
|
|
3306
3279
|
},
|
|
3307
3280
|
handler: async (rawArgs, context) => {
|
|
3281
|
+
assertNotDemo(context.config, "onchain_earn_redeem");
|
|
3308
3282
|
const args = asRecord(rawArgs);
|
|
3309
|
-
const response = await context.client.
|
|
3310
|
-
"/api/v5/
|
|
3283
|
+
const response = await context.client.privatePost(
|
|
3284
|
+
"/api/v5/finance/staking-defi/redeem",
|
|
3311
3285
|
compactObject({
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3286
|
+
ordId: requireString(args, "ordId"),
|
|
3287
|
+
protocolType: requireString(args, "protocolType"),
|
|
3288
|
+
allowEarlyRedeem: readBoolean(args, "allowEarlyRedeem")
|
|
3315
3289
|
}),
|
|
3316
|
-
privateRateLimit("
|
|
3290
|
+
privateRateLimit("onchain_earn_redeem", 2)
|
|
3317
3291
|
);
|
|
3318
|
-
return
|
|
3292
|
+
return normalizeResponse(response);
|
|
3319
3293
|
}
|
|
3320
3294
|
},
|
|
3295
|
+
// -------------------------------------------------------------------------
|
|
3296
|
+
// Cancel
|
|
3297
|
+
// -------------------------------------------------------------------------
|
|
3321
3298
|
{
|
|
3322
|
-
name: "
|
|
3323
|
-
module: "
|
|
3324
|
-
description: "
|
|
3325
|
-
isWrite:
|
|
3299
|
+
name: "onchain_earn_cancel",
|
|
3300
|
+
module: "earn.onchain",
|
|
3301
|
+
description: "Cancel pending on-chain earn purchase. [CAUTION] Cancels a pending investment order. Not supported in demo mode. Private endpoint. Rate limit: 2 req/s.",
|
|
3302
|
+
isWrite: true,
|
|
3326
3303
|
inputSchema: {
|
|
3327
3304
|
type: "object",
|
|
3328
3305
|
properties: {
|
|
3329
|
-
|
|
3306
|
+
ordId: {
|
|
3330
3307
|
type: "string",
|
|
3331
|
-
|
|
3332
|
-
description: "open=active, history=7d, archive=3mo"
|
|
3308
|
+
description: "Order ID to cancel"
|
|
3333
3309
|
},
|
|
3334
|
-
|
|
3310
|
+
protocolType: {
|
|
3335
3311
|
type: "string",
|
|
3336
|
-
|
|
3337
|
-
|
|
3312
|
+
description: "Protocol type: staking, defi"
|
|
3313
|
+
}
|
|
3314
|
+
},
|
|
3315
|
+
required: ["ordId", "protocolType"]
|
|
3316
|
+
},
|
|
3317
|
+
handler: async (rawArgs, context) => {
|
|
3318
|
+
assertNotDemo(context.config, "onchain_earn_cancel");
|
|
3319
|
+
const args = asRecord(rawArgs);
|
|
3320
|
+
const response = await context.client.privatePost(
|
|
3321
|
+
"/api/v5/finance/staking-defi/cancel",
|
|
3322
|
+
{
|
|
3323
|
+
ordId: requireString(args, "ordId"),
|
|
3324
|
+
protocolType: requireString(args, "protocolType")
|
|
3338
3325
|
},
|
|
3339
|
-
|
|
3340
|
-
type: "string",
|
|
3341
|
-
description: "e.g. BTC-USDT-240329"
|
|
3342
|
-
},
|
|
3343
|
-
ordType: {
|
|
3344
|
-
type: "string",
|
|
3345
|
-
description: "Order type filter"
|
|
3346
|
-
},
|
|
3347
|
-
state: {
|
|
3348
|
-
type: "string",
|
|
3349
|
-
description: "canceled|filled"
|
|
3350
|
-
},
|
|
3351
|
-
after: {
|
|
3352
|
-
type: "string",
|
|
3353
|
-
description: "Pagination: before this order ID"
|
|
3354
|
-
},
|
|
3355
|
-
before: {
|
|
3356
|
-
type: "string",
|
|
3357
|
-
description: "Pagination: after this order ID"
|
|
3358
|
-
},
|
|
3359
|
-
begin: {
|
|
3360
|
-
type: "string",
|
|
3361
|
-
description: "Start time (ms)"
|
|
3362
|
-
},
|
|
3363
|
-
end: {
|
|
3364
|
-
type: "string",
|
|
3365
|
-
description: "End time (ms)"
|
|
3366
|
-
},
|
|
3367
|
-
limit: {
|
|
3368
|
-
type: "number",
|
|
3369
|
-
description: "Max results (default 100)"
|
|
3370
|
-
}
|
|
3371
|
-
}
|
|
3372
|
-
},
|
|
3373
|
-
handler: async (rawArgs, context) => {
|
|
3374
|
-
const args = asRecord(rawArgs);
|
|
3375
|
-
const status = readString(args, "status") ?? "open";
|
|
3376
|
-
const instType = readString(args, "instType") ?? "FUTURES";
|
|
3377
|
-
assertEnum(instType, "instType", FUTURES_INST_TYPES);
|
|
3378
|
-
const path4 = status === "archive" ? "/api/v5/trade/orders-history-archive" : status === "history" ? "/api/v5/trade/orders-history" : "/api/v5/trade/orders-pending";
|
|
3379
|
-
const response = await context.client.privateGet(
|
|
3380
|
-
path4,
|
|
3381
|
-
compactObject({
|
|
3382
|
-
instType,
|
|
3383
|
-
instId: readString(args, "instId"),
|
|
3384
|
-
ordType: readString(args, "ordType"),
|
|
3385
|
-
state: readString(args, "state"),
|
|
3386
|
-
after: readString(args, "after"),
|
|
3387
|
-
before: readString(args, "before"),
|
|
3388
|
-
begin: readString(args, "begin"),
|
|
3389
|
-
end: readString(args, "end"),
|
|
3390
|
-
limit: readNumber(args, "limit")
|
|
3391
|
-
}),
|
|
3392
|
-
privateRateLimit("futures_get_orders", 20)
|
|
3326
|
+
privateRateLimit("onchain_earn_cancel", 2)
|
|
3393
3327
|
);
|
|
3394
|
-
return
|
|
3328
|
+
return normalizeResponse(response);
|
|
3395
3329
|
}
|
|
3396
3330
|
},
|
|
3331
|
+
// -------------------------------------------------------------------------
|
|
3332
|
+
// Get Active Orders
|
|
3333
|
+
// -------------------------------------------------------------------------
|
|
3397
3334
|
{
|
|
3398
|
-
name: "
|
|
3399
|
-
module: "
|
|
3400
|
-
description: "Get
|
|
3335
|
+
name: "onchain_earn_get_active_orders",
|
|
3336
|
+
module: "earn.onchain",
|
|
3337
|
+
description: "Get active on-chain earn orders. Returns current staking/DeFi investments. Private endpoint. Rate limit: 3 req/s.",
|
|
3401
3338
|
isWrite: false,
|
|
3402
3339
|
inputSchema: {
|
|
3403
3340
|
type: "object",
|
|
3404
3341
|
properties: {
|
|
3405
|
-
|
|
3342
|
+
productId: {
|
|
3406
3343
|
type: "string",
|
|
3407
|
-
|
|
3408
|
-
description: "FUTURES (default) or SWAP"
|
|
3344
|
+
description: "Filter by product ID. Omit for all."
|
|
3409
3345
|
},
|
|
3410
|
-
|
|
3346
|
+
protocolType: {
|
|
3411
3347
|
type: "string",
|
|
3412
|
-
description: "
|
|
3348
|
+
description: "Filter by protocol type: staking, defi. Omit for all."
|
|
3413
3349
|
},
|
|
3414
|
-
|
|
3415
|
-
type: "string"
|
|
3350
|
+
ccy: {
|
|
3351
|
+
type: "string",
|
|
3352
|
+
description: "Filter by currency, e.g. ETH. Omit for all."
|
|
3353
|
+
},
|
|
3354
|
+
state: {
|
|
3355
|
+
type: "string",
|
|
3356
|
+
description: "Filter by state: 8 (pending), 13 (cancelling), 9 (onchain), 1 (earning), 2 (redeeming). Omit for all."
|
|
3416
3357
|
}
|
|
3417
3358
|
}
|
|
3418
3359
|
},
|
|
3419
3360
|
handler: async (rawArgs, context) => {
|
|
3420
3361
|
const args = asRecord(rawArgs);
|
|
3421
|
-
const instType = readString(args, "instType") ?? "FUTURES";
|
|
3422
|
-
assertEnum(instType, "instType", FUTURES_INST_TYPES);
|
|
3423
3362
|
const response = await context.client.privateGet(
|
|
3424
|
-
"/api/v5/
|
|
3363
|
+
"/api/v5/finance/staking-defi/orders-active",
|
|
3425
3364
|
compactObject({
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3365
|
+
productId: readString(args, "productId"),
|
|
3366
|
+
protocolType: readString(args, "protocolType"),
|
|
3367
|
+
ccy: readString(args, "ccy"),
|
|
3368
|
+
state: readString(args, "state")
|
|
3429
3369
|
}),
|
|
3430
|
-
privateRateLimit("
|
|
3370
|
+
privateRateLimit("onchain_earn_get_active_orders", 3)
|
|
3431
3371
|
);
|
|
3432
|
-
return
|
|
3372
|
+
return normalizeResponse(response);
|
|
3433
3373
|
}
|
|
3434
3374
|
},
|
|
3375
|
+
// -------------------------------------------------------------------------
|
|
3376
|
+
// Get Order History
|
|
3377
|
+
// -------------------------------------------------------------------------
|
|
3435
3378
|
{
|
|
3436
|
-
name: "
|
|
3437
|
-
module: "
|
|
3438
|
-
description: "Get
|
|
3379
|
+
name: "onchain_earn_get_order_history",
|
|
3380
|
+
module: "earn.onchain",
|
|
3381
|
+
description: "Get on-chain earn order history. Returns past staking/DeFi investments including redeemed orders. Private endpoint. Rate limit: 3 req/s.",
|
|
3439
3382
|
isWrite: false,
|
|
3440
3383
|
inputSchema: {
|
|
3441
3384
|
type: "object",
|
|
3442
3385
|
properties: {
|
|
3443
|
-
|
|
3444
|
-
type: "boolean",
|
|
3445
|
-
description: "true=up to 3 months; false=last 3 days (default)"
|
|
3446
|
-
},
|
|
3447
|
-
instType: {
|
|
3386
|
+
productId: {
|
|
3448
3387
|
type: "string",
|
|
3449
|
-
|
|
3450
|
-
description: "FUTURES (default) or SWAP"
|
|
3388
|
+
description: "Filter by product ID. Omit for all."
|
|
3451
3389
|
},
|
|
3452
|
-
|
|
3390
|
+
protocolType: {
|
|
3453
3391
|
type: "string",
|
|
3454
|
-
description: "
|
|
3392
|
+
description: "Filter by protocol type: staking, defi. Omit for all."
|
|
3455
3393
|
},
|
|
3456
|
-
|
|
3394
|
+
ccy: {
|
|
3457
3395
|
type: "string",
|
|
3458
|
-
description: "
|
|
3396
|
+
description: "Filter by currency, e.g. ETH. Omit for all."
|
|
3459
3397
|
},
|
|
3460
3398
|
after: {
|
|
3461
3399
|
type: "string",
|
|
3462
|
-
description: "Pagination: before this
|
|
3400
|
+
description: "Pagination: return results before this order ID"
|
|
3463
3401
|
},
|
|
3464
3402
|
before: {
|
|
3465
3403
|
type: "string",
|
|
3466
|
-
description: "Pagination: after this
|
|
3467
|
-
},
|
|
3468
|
-
begin: {
|
|
3469
|
-
type: "string",
|
|
3470
|
-
description: "Start time (ms)"
|
|
3471
|
-
},
|
|
3472
|
-
end: {
|
|
3473
|
-
type: "string",
|
|
3474
|
-
description: "End time (ms)"
|
|
3404
|
+
description: "Pagination: return results after this order ID"
|
|
3475
3405
|
},
|
|
3476
3406
|
limit: {
|
|
3477
|
-
type: "
|
|
3478
|
-
description: "Max results (default 100
|
|
3407
|
+
type: "string",
|
|
3408
|
+
description: "Max results to return (default 100, max 100)"
|
|
3479
3409
|
}
|
|
3480
3410
|
}
|
|
3481
3411
|
},
|
|
3482
3412
|
handler: async (rawArgs, context) => {
|
|
3483
3413
|
const args = asRecord(rawArgs);
|
|
3484
|
-
const archive = readBoolean(args, "archive") ?? false;
|
|
3485
|
-
const instType = readString(args, "instType") ?? "FUTURES";
|
|
3486
|
-
assertEnum(instType, "instType", FUTURES_INST_TYPES);
|
|
3487
|
-
const path4 = archive ? "/api/v5/trade/fills-history" : "/api/v5/trade/fills";
|
|
3488
3414
|
const response = await context.client.privateGet(
|
|
3489
|
-
|
|
3415
|
+
"/api/v5/finance/staking-defi/orders-history",
|
|
3490
3416
|
compactObject({
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3417
|
+
productId: readString(args, "productId"),
|
|
3418
|
+
protocolType: readString(args, "protocolType"),
|
|
3419
|
+
ccy: readString(args, "ccy"),
|
|
3494
3420
|
after: readString(args, "after"),
|
|
3495
3421
|
before: readString(args, "before"),
|
|
3496
|
-
|
|
3497
|
-
end: readString(args, "end"),
|
|
3498
|
-
limit: readNumber(args, "limit") ?? (archive ? 20 : void 0)
|
|
3422
|
+
limit: readString(args, "limit")
|
|
3499
3423
|
}),
|
|
3500
|
-
privateRateLimit("
|
|
3424
|
+
privateRateLimit("onchain_earn_get_order_history", 3)
|
|
3501
3425
|
);
|
|
3502
|
-
return
|
|
3426
|
+
return normalizeResponse(response);
|
|
3503
3427
|
}
|
|
3504
3428
|
}
|
|
3505
3429
|
];
|
|
3506
3430
|
}
|
|
3507
|
-
function
|
|
3431
|
+
function registerAllEarnTools() {
|
|
3432
|
+
return [
|
|
3433
|
+
...registerEarnTools(),
|
|
3434
|
+
...registerOnchainEarnTools()
|
|
3435
|
+
];
|
|
3436
|
+
}
|
|
3437
|
+
var FUTURES_INST_TYPES = ["FUTURES", "SWAP"];
|
|
3438
|
+
function normalize5(response) {
|
|
3439
|
+
return {
|
|
3440
|
+
endpoint: response.endpoint,
|
|
3441
|
+
requestTime: response.requestTime,
|
|
3442
|
+
data: response.data
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
function registerFuturesTools() {
|
|
3508
3446
|
return [
|
|
3509
|
-
// -------------------------------------------------------------------------
|
|
3510
|
-
// Get Offers
|
|
3511
|
-
// -------------------------------------------------------------------------
|
|
3512
3447
|
{
|
|
3513
|
-
name: "
|
|
3514
|
-
module: "
|
|
3515
|
-
description: "
|
|
3516
|
-
isWrite:
|
|
3448
|
+
name: "futures_place_order",
|
|
3449
|
+
module: "futures",
|
|
3450
|
+
description: "Place a FUTURES delivery contract order (e.g. instId: BTC-USDT-240329). Optionally attach TP/SL via tpTriggerPx/slTriggerPx. [CAUTION] Executes real trades. Private endpoint. Rate limit: 60 req/s.",
|
|
3451
|
+
isWrite: true,
|
|
3517
3452
|
inputSchema: {
|
|
3518
3453
|
type: "object",
|
|
3519
3454
|
properties: {
|
|
3520
|
-
|
|
3455
|
+
instId: {
|
|
3521
3456
|
type: "string",
|
|
3522
|
-
description: "
|
|
3457
|
+
description: "e.g. BTC-USDT-240329"
|
|
3523
3458
|
},
|
|
3524
|
-
|
|
3459
|
+
tdMode: {
|
|
3525
3460
|
type: "string",
|
|
3526
|
-
|
|
3461
|
+
enum: ["cross", "isolated"],
|
|
3462
|
+
description: "cross|isolated margin"
|
|
3527
3463
|
},
|
|
3528
|
-
|
|
3464
|
+
side: {
|
|
3529
3465
|
type: "string",
|
|
3530
|
-
|
|
3466
|
+
enum: ["buy", "sell"],
|
|
3467
|
+
description: "one-way: buy=open long, sell=open short (use reduceOnly=true to close); hedge: combined with posSide"
|
|
3468
|
+
},
|
|
3469
|
+
posSide: {
|
|
3470
|
+
type: "string",
|
|
3471
|
+
enum: ["long", "short", "net"],
|
|
3472
|
+
description: "net=one-way mode (default); long/short=hedge mode only"
|
|
3473
|
+
},
|
|
3474
|
+
ordType: {
|
|
3475
|
+
type: "string",
|
|
3476
|
+
enum: ["market", "limit", "post_only", "fok", "ioc"],
|
|
3477
|
+
description: "market(no px)|limit(px req)|post_only(maker)|fok(all-or-cancel)|ioc(partial fill)"
|
|
3478
|
+
},
|
|
3479
|
+
sz: {
|
|
3480
|
+
type: "string",
|
|
3481
|
+
description: "Number of contracts (NOT USDT amount). Use market_get_instruments to get ctVal for conversion."
|
|
3482
|
+
},
|
|
3483
|
+
px: {
|
|
3484
|
+
type: "string",
|
|
3485
|
+
description: "Required for limit/post_only/fok/ioc"
|
|
3486
|
+
},
|
|
3487
|
+
reduceOnly: {
|
|
3488
|
+
type: "boolean",
|
|
3489
|
+
description: "Close/reduce only, no new position (one-way mode)"
|
|
3490
|
+
},
|
|
3491
|
+
clOrdId: {
|
|
3492
|
+
type: "string",
|
|
3493
|
+
description: "Client order ID (max 32 chars)"
|
|
3494
|
+
},
|
|
3495
|
+
tpTriggerPx: {
|
|
3496
|
+
type: "string",
|
|
3497
|
+
description: "TP trigger price; places TP at tpOrdPx"
|
|
3498
|
+
},
|
|
3499
|
+
tpOrdPx: {
|
|
3500
|
+
type: "string",
|
|
3501
|
+
description: "TP order price; -1=market"
|
|
3502
|
+
},
|
|
3503
|
+
slTriggerPx: {
|
|
3504
|
+
type: "string",
|
|
3505
|
+
description: "SL trigger price; places SL at slOrdPx"
|
|
3506
|
+
},
|
|
3507
|
+
slOrdPx: {
|
|
3508
|
+
type: "string",
|
|
3509
|
+
description: "SL order price; -1=market"
|
|
3531
3510
|
}
|
|
3532
|
-
}
|
|
3511
|
+
},
|
|
3512
|
+
required: ["instId", "tdMode", "side", "ordType", "sz"]
|
|
3533
3513
|
},
|
|
3534
3514
|
handler: async (rawArgs, context) => {
|
|
3535
3515
|
const args = asRecord(rawArgs);
|
|
3536
|
-
const
|
|
3537
|
-
|
|
3516
|
+
const reduceOnly = args.reduceOnly;
|
|
3517
|
+
const tpTriggerPx = readString(args, "tpTriggerPx");
|
|
3518
|
+
const tpOrdPx = readString(args, "tpOrdPx");
|
|
3519
|
+
const slTriggerPx = readString(args, "slTriggerPx");
|
|
3520
|
+
const slOrdPx = readString(args, "slOrdPx");
|
|
3521
|
+
const algoEntry = compactObject({ tpTriggerPx, tpOrdPx, slTriggerPx, slOrdPx });
|
|
3522
|
+
const attachAlgoOrds = Object.keys(algoEntry).length > 0 ? [algoEntry] : void 0;
|
|
3523
|
+
const response = await context.client.privatePost(
|
|
3524
|
+
"/api/v5/trade/order",
|
|
3538
3525
|
compactObject({
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3526
|
+
instId: requireString(args, "instId"),
|
|
3527
|
+
tdMode: requireString(args, "tdMode"),
|
|
3528
|
+
side: requireString(args, "side"),
|
|
3529
|
+
posSide: readString(args, "posSide"),
|
|
3530
|
+
ordType: requireString(args, "ordType"),
|
|
3531
|
+
sz: requireString(args, "sz"),
|
|
3532
|
+
px: readString(args, "px"),
|
|
3533
|
+
reduceOnly: typeof reduceOnly === "boolean" ? String(reduceOnly) : void 0,
|
|
3534
|
+
clOrdId: readString(args, "clOrdId"),
|
|
3535
|
+
tag: context.config.sourceTag,
|
|
3536
|
+
attachAlgoOrds
|
|
3542
3537
|
}),
|
|
3543
|
-
privateRateLimit("
|
|
3538
|
+
privateRateLimit("futures_place_order", 60)
|
|
3544
3539
|
);
|
|
3545
|
-
return
|
|
3540
|
+
return normalize5(response);
|
|
3546
3541
|
}
|
|
3547
3542
|
},
|
|
3548
|
-
// -------------------------------------------------------------------------
|
|
3549
|
-
// Purchase
|
|
3550
|
-
// -------------------------------------------------------------------------
|
|
3551
3543
|
{
|
|
3552
|
-
name: "
|
|
3553
|
-
module: "
|
|
3554
|
-
description: "
|
|
3544
|
+
name: "futures_cancel_order",
|
|
3545
|
+
module: "futures",
|
|
3546
|
+
description: "Cancel an unfilled FUTURES delivery order. Private endpoint. Rate limit: 60 req/s.",
|
|
3555
3547
|
isWrite: true,
|
|
3556
3548
|
inputSchema: {
|
|
3557
3549
|
type: "object",
|
|
3558
3550
|
properties: {
|
|
3559
|
-
|
|
3551
|
+
instId: {
|
|
3560
3552
|
type: "string",
|
|
3561
|
-
description: "
|
|
3562
|
-
},
|
|
3563
|
-
investData: {
|
|
3564
|
-
type: "array",
|
|
3565
|
-
description: "Investment data array: [{ccy, amt}]. Each item specifies currency and amount.",
|
|
3566
|
-
items: {
|
|
3567
|
-
type: "object",
|
|
3568
|
-
properties: {
|
|
3569
|
-
ccy: { type: "string", description: "Currency, e.g. ETH" },
|
|
3570
|
-
amt: { type: "string", description: "Amount to invest" }
|
|
3571
|
-
},
|
|
3572
|
-
required: ["ccy", "amt"]
|
|
3573
|
-
}
|
|
3553
|
+
description: "e.g. BTC-USDT-240329"
|
|
3574
3554
|
},
|
|
3575
|
-
|
|
3576
|
-
type: "string"
|
|
3577
|
-
description: "Investment term in days. Required for fixed-term products."
|
|
3555
|
+
ordId: {
|
|
3556
|
+
type: "string"
|
|
3578
3557
|
},
|
|
3579
|
-
|
|
3558
|
+
clOrdId: {
|
|
3580
3559
|
type: "string",
|
|
3581
|
-
description: "
|
|
3560
|
+
description: "Client order ID"
|
|
3582
3561
|
}
|
|
3583
3562
|
},
|
|
3584
|
-
required: ["
|
|
3563
|
+
required: ["instId"]
|
|
3585
3564
|
},
|
|
3586
3565
|
handler: async (rawArgs, context) => {
|
|
3587
|
-
assertNotDemo(context.config, "onchain_earn_purchase");
|
|
3588
3566
|
const args = asRecord(rawArgs);
|
|
3589
3567
|
const response = await context.client.privatePost(
|
|
3590
|
-
"/api/v5/
|
|
3568
|
+
"/api/v5/trade/cancel-order",
|
|
3591
3569
|
compactObject({
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
tag: readString(args, "tag")
|
|
3570
|
+
instId: requireString(args, "instId"),
|
|
3571
|
+
ordId: readString(args, "ordId"),
|
|
3572
|
+
clOrdId: readString(args, "clOrdId")
|
|
3596
3573
|
}),
|
|
3597
|
-
privateRateLimit("
|
|
3574
|
+
privateRateLimit("futures_cancel_order", 60)
|
|
3598
3575
|
);
|
|
3599
|
-
return
|
|
3576
|
+
return normalize5(response);
|
|
3600
3577
|
}
|
|
3601
3578
|
},
|
|
3602
|
-
// -------------------------------------------------------------------------
|
|
3603
|
-
// Redeem
|
|
3604
|
-
// -------------------------------------------------------------------------
|
|
3605
3579
|
{
|
|
3606
|
-
name: "
|
|
3607
|
-
module: "
|
|
3608
|
-
description: "
|
|
3609
|
-
isWrite:
|
|
3580
|
+
name: "futures_get_order",
|
|
3581
|
+
module: "futures",
|
|
3582
|
+
description: "Get details of a single FUTURES delivery order by ordId or clOrdId. Private endpoint. Rate limit: 60 req/s.",
|
|
3583
|
+
isWrite: false,
|
|
3610
3584
|
inputSchema: {
|
|
3611
3585
|
type: "object",
|
|
3612
3586
|
properties: {
|
|
3613
|
-
|
|
3587
|
+
instId: {
|
|
3614
3588
|
type: "string",
|
|
3615
|
-
description: "
|
|
3589
|
+
description: "e.g. BTC-USDT-240329"
|
|
3616
3590
|
},
|
|
3617
|
-
|
|
3591
|
+
ordId: {
|
|
3618
3592
|
type: "string",
|
|
3619
|
-
description: "
|
|
3593
|
+
description: "Provide ordId or clOrdId"
|
|
3620
3594
|
},
|
|
3621
|
-
|
|
3622
|
-
type: "
|
|
3623
|
-
description: "
|
|
3595
|
+
clOrdId: {
|
|
3596
|
+
type: "string",
|
|
3597
|
+
description: "Provide ordId or clOrdId"
|
|
3624
3598
|
}
|
|
3625
3599
|
},
|
|
3626
|
-
required: ["
|
|
3600
|
+
required: ["instId"]
|
|
3627
3601
|
},
|
|
3628
3602
|
handler: async (rawArgs, context) => {
|
|
3629
|
-
assertNotDemo(context.config, "onchain_earn_redeem");
|
|
3630
3603
|
const args = asRecord(rawArgs);
|
|
3631
|
-
const response = await context.client.
|
|
3632
|
-
"/api/v5/
|
|
3604
|
+
const response = await context.client.privateGet(
|
|
3605
|
+
"/api/v5/trade/order",
|
|
3633
3606
|
compactObject({
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3607
|
+
instId: requireString(args, "instId"),
|
|
3608
|
+
ordId: readString(args, "ordId"),
|
|
3609
|
+
clOrdId: readString(args, "clOrdId")
|
|
3637
3610
|
}),
|
|
3638
|
-
privateRateLimit("
|
|
3611
|
+
privateRateLimit("futures_get_order", 60)
|
|
3639
3612
|
);
|
|
3640
|
-
return
|
|
3613
|
+
return normalize5(response);
|
|
3641
3614
|
}
|
|
3642
3615
|
},
|
|
3643
|
-
// -------------------------------------------------------------------------
|
|
3644
|
-
// Cancel
|
|
3645
|
-
// -------------------------------------------------------------------------
|
|
3646
3616
|
{
|
|
3647
|
-
name: "
|
|
3648
|
-
module: "
|
|
3649
|
-
description: "
|
|
3650
|
-
isWrite:
|
|
3617
|
+
name: "futures_get_orders",
|
|
3618
|
+
module: "futures",
|
|
3619
|
+
description: "Query FUTURES open orders, history (last 7 days), or archive (up to 3 months). Private. Rate limit: 20 req/s.",
|
|
3620
|
+
isWrite: false,
|
|
3651
3621
|
inputSchema: {
|
|
3652
3622
|
type: "object",
|
|
3653
3623
|
properties: {
|
|
3654
|
-
|
|
3624
|
+
status: {
|
|
3655
3625
|
type: "string",
|
|
3656
|
-
|
|
3626
|
+
enum: ["open", "history", "archive"],
|
|
3627
|
+
description: "open=active, history=7d, archive=3mo"
|
|
3657
3628
|
},
|
|
3658
|
-
|
|
3629
|
+
instType: {
|
|
3659
3630
|
type: "string",
|
|
3660
|
-
|
|
3631
|
+
enum: [...FUTURES_INST_TYPES],
|
|
3632
|
+
description: "FUTURES (default) or SWAP"
|
|
3633
|
+
},
|
|
3634
|
+
instId: {
|
|
3635
|
+
type: "string",
|
|
3636
|
+
description: "e.g. BTC-USDT-240329"
|
|
3637
|
+
},
|
|
3638
|
+
ordType: {
|
|
3639
|
+
type: "string",
|
|
3640
|
+
description: "Order type filter"
|
|
3641
|
+
},
|
|
3642
|
+
state: {
|
|
3643
|
+
type: "string",
|
|
3644
|
+
description: "canceled|filled"
|
|
3645
|
+
},
|
|
3646
|
+
after: {
|
|
3647
|
+
type: "string",
|
|
3648
|
+
description: "Pagination: before this order ID"
|
|
3649
|
+
},
|
|
3650
|
+
before: {
|
|
3651
|
+
type: "string",
|
|
3652
|
+
description: "Pagination: after this order ID"
|
|
3653
|
+
},
|
|
3654
|
+
begin: {
|
|
3655
|
+
type: "string",
|
|
3656
|
+
description: "Start time (ms)"
|
|
3657
|
+
},
|
|
3658
|
+
end: {
|
|
3659
|
+
type: "string",
|
|
3660
|
+
description: "End time (ms)"
|
|
3661
|
+
},
|
|
3662
|
+
limit: {
|
|
3663
|
+
type: "number",
|
|
3664
|
+
description: "Max results (default 100)"
|
|
3661
3665
|
}
|
|
3662
|
-
}
|
|
3663
|
-
required: ["ordId", "protocolType"]
|
|
3666
|
+
}
|
|
3664
3667
|
},
|
|
3665
3668
|
handler: async (rawArgs, context) => {
|
|
3666
|
-
assertNotDemo(context.config, "onchain_earn_cancel");
|
|
3667
3669
|
const args = asRecord(rawArgs);
|
|
3668
|
-
const
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3670
|
+
const status = readString(args, "status") ?? "open";
|
|
3671
|
+
const instType = readString(args, "instType") ?? "FUTURES";
|
|
3672
|
+
assertEnum(instType, "instType", FUTURES_INST_TYPES);
|
|
3673
|
+
const path4 = status === "archive" ? "/api/v5/trade/orders-history-archive" : status === "history" ? "/api/v5/trade/orders-history" : "/api/v5/trade/orders-pending";
|
|
3674
|
+
const response = await context.client.privateGet(
|
|
3675
|
+
path4,
|
|
3676
|
+
compactObject({
|
|
3677
|
+
instType,
|
|
3678
|
+
instId: readString(args, "instId"),
|
|
3679
|
+
ordType: readString(args, "ordType"),
|
|
3680
|
+
state: readString(args, "state"),
|
|
3681
|
+
after: readString(args, "after"),
|
|
3682
|
+
before: readString(args, "before"),
|
|
3683
|
+
begin: readString(args, "begin"),
|
|
3684
|
+
end: readString(args, "end"),
|
|
3685
|
+
limit: readNumber(args, "limit")
|
|
3686
|
+
}),
|
|
3687
|
+
privateRateLimit("futures_get_orders", 20)
|
|
3675
3688
|
);
|
|
3676
|
-
return
|
|
3689
|
+
return normalize5(response);
|
|
3677
3690
|
}
|
|
3678
3691
|
},
|
|
3679
|
-
// -------------------------------------------------------------------------
|
|
3680
|
-
// Get Active Orders
|
|
3681
|
-
// -------------------------------------------------------------------------
|
|
3682
3692
|
{
|
|
3683
|
-
name: "
|
|
3684
|
-
module: "
|
|
3685
|
-
description: "Get
|
|
3693
|
+
name: "futures_get_positions",
|
|
3694
|
+
module: "futures",
|
|
3695
|
+
description: "Get current FUTURES delivery contract positions. Private endpoint. Rate limit: 10 req/s.",
|
|
3686
3696
|
isWrite: false,
|
|
3687
3697
|
inputSchema: {
|
|
3688
3698
|
type: "object",
|
|
3689
3699
|
properties: {
|
|
3690
|
-
|
|
3691
|
-
type: "string",
|
|
3692
|
-
description: "Filter by product ID. Omit for all."
|
|
3693
|
-
},
|
|
3694
|
-
protocolType: {
|
|
3700
|
+
instType: {
|
|
3695
3701
|
type: "string",
|
|
3696
|
-
|
|
3702
|
+
enum: [...FUTURES_INST_TYPES],
|
|
3703
|
+
description: "FUTURES (default) or SWAP"
|
|
3697
3704
|
},
|
|
3698
|
-
|
|
3705
|
+
instId: {
|
|
3699
3706
|
type: "string",
|
|
3700
|
-
description: "
|
|
3707
|
+
description: "e.g. BTC-USDT-240329"
|
|
3701
3708
|
},
|
|
3702
|
-
|
|
3703
|
-
type: "string"
|
|
3704
|
-
description: "Filter by state: 8 (pending), 13 (cancelling), 9 (onchain), 1 (earning), 2 (redeeming). Omit for all."
|
|
3709
|
+
posId: {
|
|
3710
|
+
type: "string"
|
|
3705
3711
|
}
|
|
3706
3712
|
}
|
|
3707
3713
|
},
|
|
3708
3714
|
handler: async (rawArgs, context) => {
|
|
3709
3715
|
const args = asRecord(rawArgs);
|
|
3716
|
+
const instType = readString(args, "instType") ?? "FUTURES";
|
|
3717
|
+
assertEnum(instType, "instType", FUTURES_INST_TYPES);
|
|
3710
3718
|
const response = await context.client.privateGet(
|
|
3711
|
-
"/api/v5/
|
|
3719
|
+
"/api/v5/account/positions",
|
|
3712
3720
|
compactObject({
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
state: readString(args, "state")
|
|
3721
|
+
instType,
|
|
3722
|
+
instId: readString(args, "instId"),
|
|
3723
|
+
posId: readString(args, "posId")
|
|
3717
3724
|
}),
|
|
3718
|
-
privateRateLimit("
|
|
3725
|
+
privateRateLimit("futures_get_positions", 10)
|
|
3719
3726
|
);
|
|
3720
|
-
return
|
|
3727
|
+
return normalize5(response);
|
|
3721
3728
|
}
|
|
3722
3729
|
},
|
|
3723
|
-
// -------------------------------------------------------------------------
|
|
3724
|
-
// Get Order History
|
|
3725
|
-
// -------------------------------------------------------------------------
|
|
3726
3730
|
{
|
|
3727
|
-
name: "
|
|
3728
|
-
module: "
|
|
3729
|
-
description: "Get
|
|
3731
|
+
name: "futures_get_fills",
|
|
3732
|
+
module: "futures",
|
|
3733
|
+
description: "Get FUTURES fill details. archive=false: last 3 days. archive=true: up to 3 months. Private. Rate limit: 20 req/s.",
|
|
3730
3734
|
isWrite: false,
|
|
3731
3735
|
inputSchema: {
|
|
3732
3736
|
type: "object",
|
|
3733
3737
|
properties: {
|
|
3734
|
-
|
|
3738
|
+
archive: {
|
|
3739
|
+
type: "boolean",
|
|
3740
|
+
description: "true=up to 3 months; false=last 3 days (default)"
|
|
3741
|
+
},
|
|
3742
|
+
instType: {
|
|
3735
3743
|
type: "string",
|
|
3736
|
-
|
|
3744
|
+
enum: [...FUTURES_INST_TYPES],
|
|
3745
|
+
description: "FUTURES (default) or SWAP"
|
|
3737
3746
|
},
|
|
3738
|
-
|
|
3747
|
+
instId: {
|
|
3739
3748
|
type: "string",
|
|
3740
|
-
description: "
|
|
3749
|
+
description: "Instrument ID filter"
|
|
3741
3750
|
},
|
|
3742
|
-
|
|
3751
|
+
ordId: {
|
|
3743
3752
|
type: "string",
|
|
3744
|
-
description: "
|
|
3753
|
+
description: "Order ID filter"
|
|
3745
3754
|
},
|
|
3746
3755
|
after: {
|
|
3747
3756
|
type: "string",
|
|
3748
|
-
description: "Pagination:
|
|
3757
|
+
description: "Pagination: before this bill ID"
|
|
3749
3758
|
},
|
|
3750
3759
|
before: {
|
|
3751
3760
|
type: "string",
|
|
3752
|
-
description: "Pagination:
|
|
3761
|
+
description: "Pagination: after this bill ID"
|
|
3753
3762
|
},
|
|
3754
|
-
|
|
3763
|
+
begin: {
|
|
3755
3764
|
type: "string",
|
|
3756
|
-
description: "
|
|
3765
|
+
description: "Start time (ms)"
|
|
3766
|
+
},
|
|
3767
|
+
end: {
|
|
3768
|
+
type: "string",
|
|
3769
|
+
description: "End time (ms)"
|
|
3770
|
+
},
|
|
3771
|
+
limit: {
|
|
3772
|
+
type: "number",
|
|
3773
|
+
description: "Max results (default 100 or 20 for archive)"
|
|
3757
3774
|
}
|
|
3758
3775
|
}
|
|
3759
3776
|
},
|
|
3760
3777
|
handler: async (rawArgs, context) => {
|
|
3761
3778
|
const args = asRecord(rawArgs);
|
|
3779
|
+
const archive = readBoolean(args, "archive") ?? false;
|
|
3780
|
+
const instType = readString(args, "instType") ?? "FUTURES";
|
|
3781
|
+
assertEnum(instType, "instType", FUTURES_INST_TYPES);
|
|
3782
|
+
const path4 = archive ? "/api/v5/trade/fills-history" : "/api/v5/trade/fills";
|
|
3762
3783
|
const response = await context.client.privateGet(
|
|
3763
|
-
|
|
3784
|
+
path4,
|
|
3764
3785
|
compactObject({
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3786
|
+
instType,
|
|
3787
|
+
instId: readString(args, "instId"),
|
|
3788
|
+
ordId: readString(args, "ordId"),
|
|
3768
3789
|
after: readString(args, "after"),
|
|
3769
3790
|
before: readString(args, "before"),
|
|
3770
|
-
|
|
3791
|
+
begin: readString(args, "begin"),
|
|
3792
|
+
end: readString(args, "end"),
|
|
3793
|
+
limit: readNumber(args, "limit") ?? (archive ? 20 : void 0)
|
|
3771
3794
|
}),
|
|
3772
|
-
privateRateLimit("
|
|
3795
|
+
privateRateLimit("futures_get_fills", 20)
|
|
3773
3796
|
);
|
|
3774
|
-
return
|
|
3797
|
+
return normalize5(response);
|
|
3775
3798
|
}
|
|
3776
3799
|
}
|
|
3777
3800
|
];
|
|
@@ -4772,17 +4795,20 @@ function registerSpotTradeTools() {
|
|
|
4772
4795
|
description: "e.g. BTC-USDT"
|
|
4773
4796
|
},
|
|
4774
4797
|
ordId: {
|
|
4775
|
-
type: "string"
|
|
4798
|
+
type: "string",
|
|
4799
|
+
description: "Order ID"
|
|
4776
4800
|
},
|
|
4777
4801
|
clOrdId: {
|
|
4778
4802
|
type: "string",
|
|
4779
4803
|
description: "Client order ID"
|
|
4780
4804
|
},
|
|
4781
4805
|
newSz: {
|
|
4782
|
-
type: "string"
|
|
4806
|
+
type: "string",
|
|
4807
|
+
description: "New order size in base currency (e.g. BTC amount)"
|
|
4783
4808
|
},
|
|
4784
4809
|
newPx: {
|
|
4785
|
-
type: "string"
|
|
4810
|
+
type: "string",
|
|
4811
|
+
description: "New order price"
|
|
4786
4812
|
},
|
|
4787
4813
|
newClOrdId: {
|
|
4788
4814
|
type: "string",
|
|
@@ -4957,7 +4983,7 @@ function registerSpotTradeTools() {
|
|
|
4957
4983
|
properties: {
|
|
4958
4984
|
instId: { type: "string", description: "e.g. BTC-USDT" },
|
|
4959
4985
|
algoId: { type: "string", description: "Algo order ID" },
|
|
4960
|
-
newSz: { type: "string" },
|
|
4986
|
+
newSz: { type: "string", description: "New order size in base currency (e.g. BTC amount)" },
|
|
4961
4987
|
newTpTriggerPx: { type: "string", description: "New TP trigger price" },
|
|
4962
4988
|
newTpOrdPx: { type: "string", description: "New TP order price; -1=market" },
|
|
4963
4989
|
newSlTriggerPx: { type: "string", description: "New SL trigger price" },
|
|
@@ -5980,8 +6006,7 @@ function allToolSpecs() {
|
|
|
5980
6006
|
...registerAlgoTradeTools(),
|
|
5981
6007
|
...registerAccountTools(),
|
|
5982
6008
|
...registerBotTools(),
|
|
5983
|
-
...
|
|
5984
|
-
...registerOnchainEarnTools(),
|
|
6009
|
+
...registerAllEarnTools(),
|
|
5985
6010
|
...registerAuditTools()
|
|
5986
6011
|
];
|
|
5987
6012
|
}
|
|
@@ -6355,7 +6380,7 @@ function readCliVersion() {
|
|
|
6355
6380
|
return "0.0.0";
|
|
6356
6381
|
}
|
|
6357
6382
|
var CLI_VERSION = readCliVersion();
|
|
6358
|
-
var GIT_HASH = true ? "
|
|
6383
|
+
var GIT_HASH = true ? "ecce5a7" : "dev";
|
|
6359
6384
|
var Report = class {
|
|
6360
6385
|
lines = [];
|
|
6361
6386
|
add(key, value) {
|
|
@@ -7103,7 +7128,7 @@ var HELP_TREE = {
|
|
|
7103
7128
|
description: "Contract DCA (Martingale) bot \u2014 leveraged recurring buys on futures/swaps",
|
|
7104
7129
|
commands: {
|
|
7105
7130
|
orders: {
|
|
7106
|
-
usage: "okx bot dca orders [--history]",
|
|
7131
|
+
usage: "okx bot dca orders [--algoId <id>] [--instId <id>] [--history]",
|
|
7107
7132
|
description: "List active or historical Contract DCA bot orders"
|
|
7108
7133
|
},
|
|
7109
7134
|
details: {
|
|
@@ -9278,7 +9303,9 @@ async function cmdDcaStop(run, opts) {
|
|
|
9278
9303
|
}
|
|
9279
9304
|
async function cmdDcaOrders(run, opts) {
|
|
9280
9305
|
const result = await run("dca_get_orders", {
|
|
9281
|
-
status: opts.history ? "history" : "active"
|
|
9306
|
+
status: opts.history ? "history" : "active",
|
|
9307
|
+
algoId: opts.algoId,
|
|
9308
|
+
instId: opts.instId
|
|
9282
9309
|
});
|
|
9283
9310
|
const orders = getData7(result) ?? [];
|
|
9284
9311
|
if (opts.json) return printJson(orders);
|
|
@@ -9397,7 +9424,7 @@ function cmdOnchainEarnOrderHistory(run, v) {
|
|
|
9397
9424
|
// src/index.ts
|
|
9398
9425
|
var _require2 = createRequire2(import.meta.url);
|
|
9399
9426
|
var CLI_VERSION2 = _require2("../package.json").version;
|
|
9400
|
-
var GIT_HASH2 = true ? "
|
|
9427
|
+
var GIT_HASH2 = true ? "ecce5a7" : "dev";
|
|
9401
9428
|
function handleConfigCommand(action, rest, json, lang, force) {
|
|
9402
9429
|
if (action === "init") return cmdConfigInit(lang === "zh" ? "zh" : "en");
|
|
9403
9430
|
if (action === "show") return cmdConfigShow(json);
|
|
@@ -9828,7 +9855,7 @@ function handleBotGridCommand(run, v, rest, json) {
|
|
|
9828
9855
|
}
|
|
9829
9856
|
function handleBotDcaCommand(run, subAction, v, json) {
|
|
9830
9857
|
if (subAction === "orders")
|
|
9831
|
-
return cmdDcaOrders(run, { history: v.history ?? false, json });
|
|
9858
|
+
return cmdDcaOrders(run, { algoId: v.algoId, instId: v.instId, history: v.history ?? false, json });
|
|
9832
9859
|
if (subAction === "details")
|
|
9833
9860
|
return cmdDcaDetails(run, { algoId: v.algoId, json });
|
|
9834
9861
|
if (subAction === "sub-orders")
|