@okx_ai/okx-trade-cli 1.2.5-beta.2 → 1.2.5-beta.4

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 CHANGED
@@ -1104,15 +1104,6 @@ var OkxRestClient = class {
1104
1104
  rateLimit
1105
1105
  });
1106
1106
  }
1107
- async publicPost(path42, body, rateLimit) {
1108
- return this.request({
1109
- method: "POST",
1110
- path: path42,
1111
- auth: "public",
1112
- body,
1113
- rateLimit
1114
- });
1115
- }
1116
1107
  async privatePost(path42, body, rateLimit) {
1117
1108
  return this.request({
1118
1109
  method: "POST",
@@ -2156,32 +2147,41 @@ function registerAlgoTradeTools() {
2156
2147
  {
2157
2148
  name: "swap_cancel_algo_orders",
2158
2149
  module: "swap",
2159
- description: "Cancel one or more pending SWAP/FUTURES algo orders (TP/SL). Accepts a list of {algoId, instId} objects. Private endpoint. Rate limit: 20 req/s per UID.",
2150
+ description: "Cancel one or more pending SWAP/FUTURES algo orders (TP/SL). Accepts a list of {algoId, instId} objects.",
2160
2151
  isWrite: true,
2161
2152
  inputSchema: {
2162
2153
  type: "object",
2163
2154
  properties: {
2164
- instId: {
2165
- type: "string",
2166
- description: "e.g. BTC-USDT-SWAP"
2167
- },
2168
- algoId: {
2169
- type: "string",
2170
- description: "Algo order ID"
2155
+ orders: {
2156
+ type: "array",
2157
+ description: "List of algo orders to cancel. Each item: {algoId, instId}.",
2158
+ items: {
2159
+ type: "object",
2160
+ properties: {
2161
+ algoId: {
2162
+ type: "string",
2163
+ description: "Algo order ID"
2164
+ },
2165
+ instId: {
2166
+ type: "string",
2167
+ description: "e.g. BTC-USDT-SWAP"
2168
+ }
2169
+ },
2170
+ required: ["algoId", "instId"]
2171
+ }
2171
2172
  }
2172
2173
  },
2173
- required: ["instId", "algoId"]
2174
+ required: ["orders"]
2174
2175
  },
2175
2176
  handler: async (rawArgs, context) => {
2176
2177
  const args = asRecord(rawArgs);
2178
+ const orders = args.orders;
2179
+ if (!Array.isArray(orders) || orders.length === 0) {
2180
+ throw new Error("orders must be a non-empty array.");
2181
+ }
2177
2182
  const response = await context.client.privatePost(
2178
2183
  "/api/v5/trade/cancel-algos",
2179
- [
2180
- {
2181
- instId: requireString(args, "instId"),
2182
- algoId: requireString(args, "algoId")
2183
- }
2184
- ],
2184
+ orders,
2185
2185
  privateRateLimit("swap_cancel_algo_orders", 20)
2186
2186
  );
2187
2187
  return normalizeResponse(response);
@@ -2891,13 +2891,7 @@ function registerGridTools() {
2891
2891
  },
2892
2892
  lever: { type: "string", description: "Leverage. Contract only" },
2893
2893
  sz: { type: "string", description: "Margin amount. Contract only" },
2894
- basePos: { type: "boolean", description: "Open base position for contract. Default: true" },
2895
- tpTriggerPx: { type: "string", description: "Take-profit trigger price. Spot + contract" },
2896
- slTriggerPx: { type: "string", description: "Stop-loss trigger price. Spot + contract" },
2897
- algoClOrdId: { type: "string", description: "User-defined algo order ID, 1-32 chars" },
2898
- tradeQuoteCcy: { type: "string", description: "Spot grid only. Quote currency for trading" },
2899
- tpRatio: { type: "string", description: "Contract grid only. TP ratio, e.g. '0.1' = 10%" },
2900
- slRatio: { type: "string", description: "Contract grid only. SL ratio, e.g. '0.1' = 10%" }
2894
+ basePos: { type: "boolean", description: "Open base position for contract. Default: true" }
2901
2895
  },
2902
2896
  required: ["instId", "algoOrdType", "maxPx", "minPx", "gridNum"]
2903
2897
  },
@@ -2911,9 +2905,6 @@ function registerGridTools() {
2911
2905
  minPx: requireString(args, "minPx"),
2912
2906
  gridNum: requireString(args, "gridNum"),
2913
2907
  runType: readString(args, "runType"),
2914
- tpTriggerPx: readString(args, "tpTriggerPx"),
2915
- slTriggerPx: readString(args, "slTriggerPx"),
2916
- algoClOrdId: readString(args, "algoClOrdId"),
2917
2908
  quoteSz: readString(args, "quoteSz"),
2918
2909
  baseSz: readString(args, "baseSz"),
2919
2910
  direction: readString(args, "direction"),
@@ -2921,19 +2912,9 @@ function registerGridTools() {
2921
2912
  sz: readString(args, "sz"),
2922
2913
  tag: context.config.sourceTag
2923
2914
  });
2924
- if (algoOrdType === "grid") {
2925
- const tradeQuoteCcy = readString(args, "tradeQuoteCcy");
2926
- if (tradeQuoteCcy) body.tradeQuoteCcy = tradeQuoteCcy;
2927
- }
2928
2915
  if (algoOrdType === "contract_grid") {
2929
- if (!body.triggerParams) {
2930
- body.triggerParams = [{ triggerAction: "start", triggerStrategy: "instant" }];
2931
- }
2916
+ body.triggerParams = [{ triggerAction: "start", triggerStrategy: "instant" }];
2932
2917
  body.basePos = readBoolean(args, "basePos") ?? true;
2933
- const tpRatio = readString(args, "tpRatio");
2934
- const slRatio = readString(args, "slRatio");
2935
- if (tpRatio) body.tpRatio = tpRatio;
2936
- if (slRatio) body.slRatio = slRatio;
2937
2918
  }
2938
2919
  const response = await context.client.privatePost(
2939
2920
  "/api/v5/tradingBot/grid/order-algo",
@@ -3011,7 +2992,7 @@ function registerDcaTools() {
3011
2992
  {
3012
2993
  name: "dca_create_order",
3013
2994
  module: "bot.dca",
3014
- description: "Create Contract DCA (Martingale) bot. [CAUTION] Real trades. When maxSafetyOrds > 0: also need safetyOrdAmt, pxSteps. When maxSafetyOrds > 1: also need pxStepsMult, volMult.",
2995
+ description: "Create Contract DCA (Martingale) bot. [CAUTION] Real trades. When maxSafetyOrds > 0: also need safetyOrdAmt, pxSteps, pxStepsMult, volMult.",
3015
2996
  isWrite: true,
3016
2997
  inputSchema: {
3017
2998
  type: "object",
@@ -3024,58 +3005,19 @@ function registerDcaTools() {
3024
3005
  tpPct: { type: "string", description: "Take-profit ratio, e.g. '0.03' = 3%" },
3025
3006
  safetyOrdAmt: { type: "string", description: "Safety order amount (USDT). Need when maxSafetyOrds > 0" },
3026
3007
  pxSteps: { type: "string", description: "Price drop % per safety order, e.g. '0.03'. Need when maxSafetyOrds > 0" },
3027
- pxStepsMult: { type: "string", description: "Price step multiplier, e.g. '1.2'. Need when maxSafetyOrds > 1" },
3028
- volMult: { type: "string", description: "Safety order size multiplier, e.g. '1.5'. Need when maxSafetyOrds > 1" },
3008
+ pxStepsMult: { type: "string", description: "Price step multiplier, e.g. '1.2'. Need when maxSafetyOrds > 0" },
3009
+ volMult: { type: "string", description: "Safety order size multiplier, e.g. '1.5'. Need when maxSafetyOrds > 0" },
3029
3010
  slPct: { type: "string", description: "Stop-loss ratio, e.g. '0.05' = 5%" },
3030
3011
  slMode: { type: "string", enum: ["limit", "market"], description: "Stop-loss type. Default: market" },
3031
3012
  allowReinvest: { type: "string", enum: ["true", "false"], description: "Reinvest profit. Default: 'true'" },
3032
3013
  triggerStrategy: { type: "string", enum: ["instant", "price", "rsi"], default: "instant", description: "How bot starts. Default: instant" },
3033
- triggerPx: { type: "string", description: "Required when triggerStrategy='price'" },
3034
- triggerCond: { type: "string", enum: ["cross_up", "cross_down"], description: "RSI trigger condition. Required when triggerStrategy='rsi'" },
3035
- thold: { type: "string", description: "RSI threshold, e.g. '30'. Required when triggerStrategy='rsi'" },
3036
- timePeriod: { type: "string", description: "RSI period. Default: '14'" },
3037
- timeframe: { type: "string", enum: ["3m", "5m", "15m", "30m", "1H", "4H", "1D"], description: "RSI K-line timeframe. Required when triggerStrategy='rsi'" },
3038
- trackingMode: { type: "string", enum: ["sync", "async"], description: "Copy-trading tracking mode" },
3039
- profitSharingRatio: { type: "string", enum: ["0", "0.1", "0.2", "0.3"], description: "Copy-trading profit sharing ratio" }
3014
+ triggerPx: { type: "string", description: "Required when triggerStrategy='price'" }
3040
3015
  },
3041
3016
  required: ["instId", "lever", "direction", "initOrdAmt", "maxSafetyOrds", "tpPct"]
3042
3017
  },
3043
3018
  handler: async (rawArgs, context) => {
3044
3019
  const args = asRecord(rawArgs);
3045
3020
  const instId = requireString(args, "instId");
3046
- const maxSafetyOrds = Number(requireString(args, "maxSafetyOrds"));
3047
- if (maxSafetyOrds > 0) {
3048
- const missing = [];
3049
- if (!readString(args, "safetyOrdAmt")) missing.push("safetyOrdAmt");
3050
- if (!readString(args, "pxSteps")) missing.push("pxSteps");
3051
- if (missing.length > 0) {
3052
- throw new Error(
3053
- `When maxSafetyOrds > 0, the following parameters are required: ${missing.join(", ")}`
3054
- );
3055
- }
3056
- }
3057
- if (maxSafetyOrds > 1) {
3058
- const missing = [];
3059
- if (!readString(args, "pxStepsMult")) missing.push("pxStepsMult");
3060
- if (!readString(args, "volMult")) missing.push("volMult");
3061
- if (missing.length > 0) {
3062
- throw new Error(
3063
- `When maxSafetyOrds > 1, the following parameters are required: ${missing.join(", ")}`
3064
- );
3065
- }
3066
- }
3067
- const slPct = readString(args, "slPct");
3068
- const slMode = readString(args, "slMode");
3069
- if (slPct && !slMode) {
3070
- throw new Error(
3071
- "slMode is required when slPct is set. Use 'market' (market price stop-loss) or 'limit' (limit price stop-loss)."
3072
- );
3073
- }
3074
- if (slMode && !slPct) {
3075
- throw new Error(
3076
- "slPct is required when slMode is set. e.g. '0.05' = 5% stop-loss."
3077
- );
3078
- }
3079
3021
  const triggerStrategy = readString(args, "triggerStrategy") ?? "instant";
3080
3022
  const triggerParam = {
3081
3023
  triggerAction: "start",
@@ -3084,25 +3026,6 @@ function registerDcaTools() {
3084
3026
  if (triggerStrategy === "price") {
3085
3027
  triggerParam["triggerPx"] = requireString(args, "triggerPx");
3086
3028
  }
3087
- if (triggerStrategy === "rsi") {
3088
- const rsiMissing = [];
3089
- const triggerCond = readString(args, "triggerCond");
3090
- const thold = readString(args, "thold");
3091
- const timeframe = readString(args, "timeframe");
3092
- if (!triggerCond) rsiMissing.push("triggerCond");
3093
- if (!thold) rsiMissing.push("thold");
3094
- if (!timeframe) rsiMissing.push("timeframe");
3095
- if (rsiMissing.length > 0) {
3096
- throw new Error(
3097
- `When triggerStrategy='rsi', the following parameters are required: ${rsiMissing.join(", ")}`
3098
- );
3099
- }
3100
- triggerParam["triggerCond"] = triggerCond;
3101
- triggerParam["thold"] = thold;
3102
- triggerParam["timePeriod"] = readString(args, "timePeriod") ?? "14";
3103
- triggerParam["timeframe"] = timeframe;
3104
- }
3105
- const triggerParams = [triggerParam];
3106
3029
  const response = await context.client.privatePost(
3107
3030
  `${BASE}/create`,
3108
3031
  compactObject({
@@ -3120,10 +3043,7 @@ function registerDcaTools() {
3120
3043
  slPct: readString(args, "slPct"),
3121
3044
  slMode: readString(args, "slMode"),
3122
3045
  allowReinvest: readString(args, "allowReinvest"),
3123
- trackingMode: readString(args, "trackingMode"),
3124
- profitSharingRatio: readString(args, "profitSharingRatio"),
3125
- tag: context.config.sourceTag,
3126
- triggerParams
3046
+ triggerParams: [triggerParam]
3127
3047
  }),
3128
3048
  privateRateLimit("dca_create_order", 20)
3129
3049
  );
@@ -3243,8 +3163,6 @@ function registerDcaTools() {
3243
3163
  algoId,
3244
3164
  algoOrdType: "contract_dca",
3245
3165
  cycleId,
3246
- after: readString(args, "after"),
3247
- before: readString(args, "before"),
3248
3166
  limit: readNumber(args, "limit")
3249
3167
  }),
3250
3168
  privateRateLimit("dca_get_sub_orders", 20)
@@ -6482,223 +6400,6 @@ function registerSpotTradeTools() {
6482
6400
  }
6483
6401
  ];
6484
6402
  }
6485
- var BASE2 = "/api/v5/copytrading";
6486
- var LAST_DAYS_30 = "2";
6487
- var INST_TYPE_SWAP = "SWAP";
6488
- var COPY_MODE_SMART = "smart_copy";
6489
- var COPY_MODE_FIXED = "fixed_amount";
6490
- var COPY_MODE_RATIO = "ratio_copy";
6491
- var COPY_INST_ID_TYPE_COPY = "copy";
6492
- var COPY_INST_ID_TYPE_CUSTOM = "custom";
6493
- var COPY_MGN_MODE_COPY = "copy";
6494
- var COPY_MGN_MODE_ISOLATED = "isolated";
6495
- var INST_TYPE_SPOT = "SPOT";
6496
- var SUB_POS_CLOSE_COPY = "copy_close";
6497
- function registerCopyTradeTools() {
6498
- return [
6499
- {
6500
- name: "copytrading_get_lead_traders",
6501
- module: "copytrading",
6502
- description: "Get top lead traders ranking. Public endpoint, no auth required. Use for: \u4EA4\u6613\u5458\u6392\u884C, \u5E26\u5355\u5458\u63A8\u8350, top traders.",
6503
- isWrite: false,
6504
- inputSchema: {
6505
- type: "object",
6506
- properties: {
6507
- instType: { type: "string", enum: ["SWAP", "SPOT"], description: "Instrument type: SPOT for spot copy traders (\u73B0\u8D27\u5E26\u5355\u5458), SWAP for contract copy traders (\u5408\u7EA6\u5E26\u5355\u5458). Defaults to SWAP \u2014 always pass explicitly." },
6508
- sortType: { type: "string", enum: ["overview", "pnl", "aum", "win_ratio", "pnl_ratio", "current_copy_trader_pnl"], description: "Sort by: overview (default), pnl, aum, win_ratio, pnl_ratio, current_copy_trader_pnl" },
6509
- state: { type: "string", enum: ["0", "1"], description: "0=all traders (default), 1=only traders with open slots" },
6510
- minLeadDays: { type: "string", enum: ["1", "2", "3", "4"], description: "Min lead trading days: 1=7d, 2=30d, 3=90d, 4=180d" },
6511
- minAssets: { type: "string", description: "Min trader assets (USDT)" },
6512
- maxAssets: { type: "string", description: "Max trader assets (USDT)" },
6513
- minAum: { type: "string", description: "Min AUM / copy trading scale (USDT)" },
6514
- maxAum: { type: "string", description: "Max AUM / copy trading scale (USDT)" },
6515
- page: { type: "string", description: "Page number for pagination" },
6516
- dataVer: { type: "string", description: "Ranking data version (14-digit, e.g. 20231010182400). Use when paginating to keep consistent results." },
6517
- limit: { type: "number", description: "Max results per page (default 10, max 20)" }
6518
- }
6519
- },
6520
- handler: async (rawArgs, context) => {
6521
- const args = asRecord(rawArgs);
6522
- const response = await context.client.publicGet(
6523
- `${BASE2}/public-lead-traders`,
6524
- compactObject({
6525
- instType: readString(args, "instType") ?? INST_TYPE_SWAP,
6526
- sortType: readString(args, "sortType") ?? "overview",
6527
- state: readString(args, "state"),
6528
- minLeadDays: readString(args, "minLeadDays"),
6529
- minAssets: readString(args, "minAssets"),
6530
- maxAssets: readString(args, "maxAssets"),
6531
- minAum: readString(args, "minAum"),
6532
- maxAum: readString(args, "maxAum"),
6533
- page: readString(args, "page"),
6534
- dataVer: readString(args, "dataVer"),
6535
- limit: String(readNumber(args, "limit") ?? 10)
6536
- })
6537
- );
6538
- const raw = response;
6539
- const dataArr = Array.isArray(raw.data) ? raw.data : [];
6540
- const first = dataArr[0] ?? {};
6541
- return {
6542
- endpoint: response.endpoint,
6543
- requestTime: response.requestTime,
6544
- dataVer: String(first["dataVer"] ?? ""),
6545
- totalPage: String(first["totalPage"] ?? ""),
6546
- data: first["ranks"] ?? []
6547
- };
6548
- }
6549
- },
6550
- {
6551
- name: "copytrading_get_trader_details",
6552
- module: "copytrading",
6553
- description: "Get full profile of a specific lead trader: daily P&L, statistics (win rate, position stats, follower P&L), and preferred trading currencies. All returned together. Public endpoint, no auth required.",
6554
- isWrite: false,
6555
- inputSchema: {
6556
- type: "object",
6557
- properties: {
6558
- uniqueCode: { type: "string", description: "Lead trader unique code (16 chars)" },
6559
- instType: { type: "string", enum: ["SWAP", "SPOT"], description: "Instrument type: SPOT for spot copy traders (\u73B0\u8D27\u5E26\u5355\u5458), SWAP for contract copy traders (\u5408\u7EA6\u5E26\u5355\u5458). Defaults to SWAP \u2014 always pass explicitly." },
6560
- lastDays: { type: "string", enum: ["1", "2", "3", "4"], description: "Time range for pnl and stats: 1=7d 2=30d 3=90d 4=365d (default: 2)" }
6561
- },
6562
- required: ["uniqueCode"]
6563
- },
6564
- handler: async (rawArgs, context) => {
6565
- const args = asRecord(rawArgs);
6566
- const uniqueCode = requireString(args, "uniqueCode");
6567
- const instType = readString(args, "instType") ?? INST_TYPE_SWAP;
6568
- const lastDays = readString(args, "lastDays") ?? LAST_DAYS_30;
6569
- const [pnlRes, statsRes, preferenceRes] = await Promise.all([
6570
- context.client.publicGet(
6571
- `${BASE2}/public-pnl`,
6572
- compactObject({ uniqueCode, instType, lastDays })
6573
- ),
6574
- context.client.publicGet(
6575
- `${BASE2}/public-stats`,
6576
- compactObject({ uniqueCode, instType, lastDays })
6577
- ),
6578
- context.client.publicGet(
6579
- `${BASE2}/public-preference-currency`,
6580
- compactObject({ uniqueCode, instType })
6581
- )
6582
- ]);
6583
- return {
6584
- pnl: normalizeResponse(pnlRes).data,
6585
- stats: normalizeResponse(statsRes).data,
6586
- preference: normalizeResponse(preferenceRes).data
6587
- };
6588
- }
6589
- },
6590
- {
6591
- name: "copytrading_get_my_details",
6592
- module: "copytrading",
6593
- description: "Query the lead traders I am currently copying (cumulative P&L per trader). Private. Rate limit: 5/2s.",
6594
- isWrite: false,
6595
- inputSchema: {
6596
- type: "object",
6597
- properties: {
6598
- instType: { type: "string", enum: ["SWAP", "SPOT"], description: "Instrument type. Must match what was used when following: SPOT for spot copy trades (\u73B0\u8D27\u8DDF\u5355), SWAP for contract copy trades. Defaults to SWAP \u2014 always pass explicitly to query the correct list." }
6599
- }
6600
- },
6601
- handler: async (rawArgs, context) => {
6602
- const args = asRecord(rawArgs);
6603
- const response = await context.client.privateGet(
6604
- `${BASE2}/current-lead-traders`,
6605
- compactObject({ instType: readString(args, "instType") ?? INST_TYPE_SWAP }),
6606
- privateRateLimit("copytrading_get_my_details", 5)
6607
- );
6608
- return normalizeResponse(response);
6609
- }
6610
- },
6611
- {
6612
- name: "copytrading_set_copytrading",
6613
- module: "copytrading",
6614
- description: "Start copy trading a lead trader. copyMode: smart_copy (default), fixed_amount, ratio_copy. [CAUTION] Allocates real funds unless running in demo/simulated mode (x-simulated-trading). Private. Rate limit: 5/2s.",
6615
- isWrite: true,
6616
- inputSchema: {
6617
- type: "object",
6618
- properties: {
6619
- uniqueCode: { type: "string", description: "Lead trader unique code (16 chars)" },
6620
- instType: { type: "string", enum: ["SWAP", "SPOT"], description: "Instrument type. MUST be set explicitly: use SPOT for spot copy trading (\u73B0\u8D27\u8DDF\u5355), SWAP for perpetual/contract copy trading (\u5408\u7EA6\u8DDF\u5355). Defaults to SWAP if omitted \u2014 always pass this field to avoid silently creating the wrong type of copy trade." },
6621
- copyMode: { type: "string", enum: ["smart_copy", "fixed_amount", "ratio_copy"], description: "Copy mode: smart_copy=smart copy, initialAmount+replicationRequired required (default); fixed_amount=fixed USDT per order, copyAmt required; ratio_copy=proportional copy, copyRatio required" },
6622
- copyMgnMode: { type: "string", enum: ["cross", "isolated", "copy"], description: "Margin mode (non-smart_copy only): copy=follow trader (default), isolated, cross. For smart_copy: auto-set by instType (SWAP\u2192copy, SPOT\u2192isolated), user input ignored." },
6623
- copyInstIdType: { type: "string", enum: ["copy", "custom"], description: "copy=follow trader's instruments (default); custom=user-defined (instId required)" },
6624
- instId: { type: "string", description: "Comma-separated instrument IDs, required when copyInstIdType=custom" },
6625
- copyTotalAmt: { type: "string", description: "Max total USDT to allocate for this trader. [REQUIRED when copyMode=fixed_amount or ratio_copy; auto-filled from initialAmount when copyMode=smart_copy]" },
6626
- copyAmt: { type: "string", description: "Fixed USDT per order. [REQUIRED when copyMode=fixed_amount]" },
6627
- copyRatio: { type: "string", description: "Copy ratio (e.g. 0.1 = 10%). [REQUIRED when copyMode=ratio_copy]" },
6628
- initialAmount: { type: "string", description: "Initial investment amount in USDT. [REQUIRED when copyMode=smart_copy; automatically assigned to copyTotalAmt]" },
6629
- replicationRequired: { type: "string", enum: ["0", "1"], description: "Whether to replicate existing positions: 0=no, 1=yes. Only applicable to smart_copy mode." },
6630
- tpRatio: { type: "string", description: "Take-profit ratio per order, e.g. 0.1 = 10%" },
6631
- slRatio: { type: "string", description: "Stop-loss ratio per order, e.g. 0.1 = 10%" },
6632
- subPosCloseType: { type: "string", enum: ["copy_close", "market_close", "manual_close"], description: "How to close sub-positions when you stop copying: copy_close=follow trader (default), market_close=close all immediately, manual_close=keep open" },
6633
- slTotalAmt: { type: "string", description: "Total stop-loss amount (USDT). Auto-stop when net loss reaches this amount" }
6634
- },
6635
- required: ["uniqueCode"]
6636
- },
6637
- handler: async (rawArgs, context) => {
6638
- const args = asRecord(rawArgs);
6639
- const copyMode = readString(args, "copyMode") ?? COPY_MODE_SMART;
6640
- const instType = readString(args, "instType") ?? INST_TYPE_SWAP;
6641
- const copyInstIdType = readString(args, "copyInstIdType") ?? COPY_INST_ID_TYPE_COPY;
6642
- const smartMgnMode = instType === INST_TYPE_SPOT ? COPY_MGN_MODE_ISOLATED : COPY_MGN_MODE_COPY;
6643
- const copyMgnMode = copyMode === COPY_MODE_SMART ? smartMgnMode : readString(args, "copyMgnMode") ?? COPY_MGN_MODE_COPY;
6644
- const initialAmount = copyMode === COPY_MODE_SMART ? requireString(args, "initialAmount") : readString(args, "initialAmount");
6645
- const replicationRequired = copyMode === COPY_MODE_SMART ? requireString(args, "replicationRequired") : void 0;
6646
- const copyTotalAmt = copyMode === COPY_MODE_SMART ? initialAmount : requireString(args, "copyTotalAmt");
6647
- const response = await context.client.privatePost(
6648
- `${BASE2}/first-copy-settings`,
6649
- compactObject({
6650
- instType,
6651
- uniqueCode: requireString(args, "uniqueCode"),
6652
- copyMode,
6653
- copyMgnMode,
6654
- copyInstIdType,
6655
- instId: copyInstIdType === COPY_INST_ID_TYPE_CUSTOM ? requireString(args, "instId") : readString(args, "instId"),
6656
- copyTotalAmt,
6657
- copyAmt: copyMode === COPY_MODE_FIXED ? requireString(args, "copyAmt") : readString(args, "copyAmt"),
6658
- copyRatio: copyMode === COPY_MODE_RATIO ? requireString(args, "copyRatio") : readString(args, "copyRatio"),
6659
- initialAmount: copyMode === COPY_MODE_SMART ? initialAmount : void 0,
6660
- replicationRequired: copyMode === COPY_MODE_SMART ? replicationRequired : void 0,
6661
- tpRatio: readString(args, "tpRatio"),
6662
- slRatio: readString(args, "slRatio"),
6663
- subPosCloseType: readString(args, "subPosCloseType") ?? SUB_POS_CLOSE_COPY,
6664
- slTotalAmt: readString(args, "slTotalAmt"),
6665
- tag: context.config.sourceTag
6666
- }),
6667
- privateRateLimit("copytrading_set_copytrading", 5)
6668
- );
6669
- return normalizeResponse(response);
6670
- }
6671
- },
6672
- {
6673
- name: "copytrading_stop_copy_trader",
6674
- module: "copytrading",
6675
- description: "Stop copy trading a lead trader. [CAUTION] Can close all positions (no effect in demo/simulated mode). Private. Rate limit: 5/2s.",
6676
- isWrite: true,
6677
- inputSchema: {
6678
- type: "object",
6679
- properties: {
6680
- uniqueCode: { type: "string", description: "Lead trader unique code" },
6681
- subPosCloseType: { type: "string", enum: ["copy_close", "market_close", "manual_close"], description: "How to handle positions when stopping: copy_close=follow trader (default), market_close=close all immediately, manual_close=keep open" },
6682
- instType: { type: "string", enum: ["SWAP", "SPOT"], description: "Instrument type. Must match the type used when the copy trade was created: SPOT for spot copy trades, SWAP for contract copy trades. Defaults to SWAP \u2014 always pass explicitly." }
6683
- },
6684
- required: ["uniqueCode"]
6685
- },
6686
- handler: async (rawArgs, context) => {
6687
- const args = asRecord(rawArgs);
6688
- const response = await context.client.privatePost(
6689
- `${BASE2}/stop-copy-trading`,
6690
- compactObject({
6691
- instType: readString(args, "instType") ?? INST_TYPE_SWAP,
6692
- uniqueCode: requireString(args, "uniqueCode"),
6693
- subPosCloseType: readString(args, "subPosCloseType") ?? SUB_POS_CLOSE_COPY
6694
- }),
6695
- privateRateLimit("copytrading_stop_copy_trader", 5)
6696
- );
6697
- return normalizeResponse(response);
6698
- }
6699
- }
6700
- ];
6701
- }
6702
6403
  function registerSwapTradeTools() {
6703
6404
  const common = buildContractTradeTools({
6704
6405
  prefix: "swap",
@@ -6823,9 +6524,7 @@ function allToolSpecs() {
6823
6524
  ...registerAccountTools(),
6824
6525
  ...registerBotTools(),
6825
6526
  ...registerAllEarnTools(),
6826
- ...registerAuditTools(),
6827
- // copytrading: included for CLI use only; not exposed via MCP (module removed from MODULES)
6828
- ...registerCopyTradeTools()
6527
+ ...registerAuditTools()
6829
6528
  ];
6830
6529
  }
6831
6530
  function createToolRunner(client, config) {
@@ -7628,7 +7327,7 @@ async function cmdDiagnoseMcp(options = {}) {
7628
7327
 
7629
7328
  // src/commands/diagnose.ts
7630
7329
  var CLI_VERSION = readCliVersion();
7631
- var GIT_HASH = true ? "da62db2" : "dev";
7330
+ var GIT_HASH = true ? "50eb95e" : "dev";
7632
7331
  function maskKey2(key) {
7633
7332
  if (!key) return "(not set)";
7634
7333
  if (key.length <= 8) return "****";
@@ -8400,7 +8099,7 @@ var HELP_TREE = {
8400
8099
  }
8401
8100
  },
8402
8101
  bot: {
8403
- description: "Trading bot strategies (grid, dca, twap [CLI-only], recurring)",
8102
+ description: "Trading bot strategies (grid, dca)",
8404
8103
  subgroups: {
8405
8104
  grid: {
8406
8105
  description: "Grid trading bot \u2014 create, monitor, and stop grid orders",
@@ -8418,68 +8117,12 @@ var HELP_TREE = {
8418
8117
  description: "List sub-orders of a grid bot (filled or live)"
8419
8118
  },
8420
8119
  create: {
8421
- usage: "okx bot grid create --instId <id> --algoOrdType <grid|contract_grid> --maxPx <px> --minPx <px> --gridNum <n>\n [--runType <1|2>] [--quoteSz <n>] [--baseSz <n>]\n [--direction <long|short|neutral>] [--lever <n>] [--sz <n>] [--basePos] [--no-basePos]\n [--tpTriggerPx <px>] [--slTriggerPx <px>] [--algoClOrdId <id>]\n [--tpRatio <ratio>] [--slRatio <ratio>] [--tradeQuoteCcy <ccy>]",
8120
+ usage: "okx bot grid create --instId <id> --algoOrdType <grid|contract_grid> --maxPx <px> --minPx <px> --gridNum <n>\n [--runType <1|2>] [--quoteSz <n>] [--baseSz <n>]\n [--direction <long|short|neutral>] [--lever <n>] [--sz <n>] [--basePos] [--no-basePos]",
8422
8121
  description: "Create a new grid bot order (contract grid opens base position by default)"
8423
8122
  },
8424
8123
  stop: {
8425
8124
  usage: "okx bot grid stop --algoId <id> --algoOrdType <type> --instId <id> [--stopType <1|2|3|5|6>]",
8426
8125
  description: "Stop a running grid bot order"
8427
- },
8428
- "amend-basic": {
8429
- usage: "okx bot grid amend-basic --algoId <id> --minPx <px> --maxPx <px> --gridNum <n> [--topupAmount <n>]",
8430
- description: "Amend grid bot's price range and grid count"
8431
- },
8432
- "amend-order": {
8433
- usage: "okx bot grid amend-order --algoId <id> --instId <id>\n [--slTriggerPx <px>] [--tpTriggerPx <px>]\n [--tpRatio <ratio>] [--slRatio <ratio>] [--topUpAmt <n>]",
8434
- description: "Amend TP/SL settings of a running grid bot"
8435
- },
8436
- "close-position": {
8437
- usage: "okx bot grid close-position --algoId <id> [--mktClose] [--sz <n>] [--px <price>]",
8438
- description: "Close position of a stopped contract grid bot"
8439
- },
8440
- "cancel-close": {
8441
- usage: "okx bot grid cancel-close --algoId <id> --ordId <id>",
8442
- description: "Cancel a pending close order for contract grid"
8443
- },
8444
- "instant-trigger": {
8445
- usage: "okx bot grid instant-trigger --algoId <id> [--topUpAmt <n>]",
8446
- description: "Immediately trigger a pending-signal grid bot"
8447
- },
8448
- positions: {
8449
- usage: "okx bot grid positions --algoOrdType contract_grid --algoId <id>",
8450
- description: "Get contract grid bot position info"
8451
- },
8452
- "withdraw-income": {
8453
- usage: "okx bot grid withdraw-income --algoId <id>",
8454
- description: "Withdraw profit from a spot grid bot"
8455
- },
8456
- "compute-margin": {
8457
- usage: "okx bot grid compute-margin --algoId <id> --gridType <add|reduce> [--amt <n>]",
8458
- description: "Preview margin adjustment for contract grid"
8459
- },
8460
- "margin-balance": {
8461
- usage: "okx bot grid margin-balance --algoId <id> --gridType <add|reduce> [--amt <n>] [--percent <n>]",
8462
- description: "Adjust margin for contract grid bot"
8463
- },
8464
- "adjust-investment": {
8465
- usage: "okx bot grid adjust-investment --algoId <id> --amt <n> [--allowReinvestProfit <true|false>]",
8466
- description: "Add investment to a running grid bot"
8467
- },
8468
- "ai-param": {
8469
- usage: "okx bot grid ai-param --algoOrdType <grid|contract_grid> --instId <id> [--direction <dir>] [--duration <7D|30D|180D>]",
8470
- description: "Get AI-recommended grid parameters (public, no auth)"
8471
- },
8472
- "min-investment": {
8473
- usage: "okx bot grid min-investment --instId <id> --algoOrdType <type> --gridNum <n>\n --maxPx <px> --minPx <px> --runType <1|2>\n [--direction <dir>] [--lever <n>] [--basePos] [--investmentType <quote|base|dual>]",
8474
- description: "Calculate minimum investment for grid config (public, no auth)"
8475
- },
8476
- "rsi-back-testing": {
8477
- usage: "okx bot grid rsi-back-testing --instId <id> --timeframe <3m|5m|15m|30m|1H|4H|1D>\n --thold <n> --timePeriod <n> [--triggerCond <cond>] [--duration <1M>]",
8478
- description: "RSI signal back testing for grid trigger (public, no auth)"
8479
- },
8480
- "max-quantity": {
8481
- usage: "okx bot grid max-quantity --instId <id> --runType <1|2> --algoOrdType <type>\n --maxPx <px> --minPx <px> [--lever <n>]",
8482
- description: "Get maximum grid quantity for config (public, no auth)"
8483
8126
  }
8484
8127
  }
8485
8128
  },
@@ -8499,112 +8142,17 @@ var HELP_TREE = {
8499
8142
  description: "List cycles or orders within a cycle of a Contract DCA bot"
8500
8143
  },
8501
8144
  create: {
8502
- usage: "okx bot dca create --instId <id> --lever <n> --direction <long|short>\n --initOrdAmt <n> --maxSafetyOrds <n> --tpPct <n>\n [--safetyOrdAmt <n>] [--pxSteps <n>] [--pxStepsMult <n>] [--volMult <n>]\n [--slPct <n>] [--slMode <limit|market>]\n [--allowReinvest <true|false>] [--triggerStrategy <instant|price|rsi>] [--triggerPx <price>]\n [--triggerCond <cross_up|cross_down>] [--thold <n>] [--timePeriod <n>] [--timeframe <3m|5m|15m|30m|1H|4H|1D>]\n [--trackingMode <sync|async>] [--profitSharingRatio <0|0.1|0.2|0.3>]\n Ranges: maxSafetyOrds [0,100]; pxSteps [0.001,0.5] (varies by instrument);\n tpPct: long [0.001,10], short [0.001,0.9999]; slPct must > MPD\n Note: safetyOrdAmt, pxSteps required when maxSafetyOrds > 0; pxStepsMult, volMult required when maxSafetyOrds > 1\n Note: slMode required when slPct is set; triggerCond, thold, timeframe required when triggerStrategy=rsi",
8145
+ usage: "okx bot dca create --instId <id> --lever <n> --direction <long|short>\n --initOrdAmt <n> --maxSafetyOrds <n> --tpPct <n>\n [--safetyOrdAmt <n>] [--pxSteps <n>] [--pxStepsMult <n>] [--volMult <n>]\n [--slPct <n>] [--slMode <limit|market>]\n [--allowReinvest <true|false>] [--triggerStrategy <instant|price|rsi>] [--triggerPx <price>]\n Note: safetyOrdAmt, pxSteps, pxStepsMult, volMult are required when maxSafetyOrds > 0",
8503
8146
  description: "Create a new Contract DCA bot order"
8504
8147
  },
8505
8148
  stop: {
8506
8149
  usage: "okx bot dca stop --algoId <id>",
8507
8150
  description: "Stop a running Contract DCA bot order"
8508
- },
8509
- "margin-add": {
8510
- usage: "okx bot dca margin-add --algoId <id> --amt <n>",
8511
- description: "Add margin to a running DCA bot (CLI-only)"
8512
- },
8513
- "margin-reduce": {
8514
- usage: "okx bot dca margin-reduce --algoId <id> --amt <n>",
8515
- description: "Reduce margin from a running DCA bot (CLI-only)"
8516
- },
8517
- "set-tp": {
8518
- usage: "okx bot dca set-tp --algoId <id> --tpPrice <price>",
8519
- description: "Update take-profit price for a running DCA bot (CLI-only). Long: tpPrice must not be below tpPriceRange; Short: tpPrice must not exceed tpPriceRange. Get tpPriceRange from 'dca orders' (ongoing-list)"
8520
- },
8521
- "set-reinvest": {
8522
- usage: "okx bot dca set-reinvest --algoId <id> --allowReinvest <true|false>",
8523
- description: "Enable or disable reinvestment for a DCA bot (CLI-only)"
8524
- },
8525
- "manual-buy": {
8526
- usage: "okx bot dca manual-buy --algoId <id> --amt <n> --px <price>",
8527
- description: "Manually trigger a buy order within a DCA bot cycle (CLI-only)"
8528
- }
8529
- }
8530
- },
8531
- twap: {
8532
- description: "TWAP (Time-Weighted Average Price) \u2014 split large orders over time intervals",
8533
- commands: {
8534
- orders: {
8535
- usage: "okx bot twap orders [--instId <id>] [--instType <SPOT|SWAP|FUTURES|MARGIN>] [--history] [--state <effective|canceled|order_failed>]",
8536
- description: "List active or historical TWAP algo orders"
8537
- },
8538
- details: {
8539
- usage: "okx bot twap details --algoId <id> | --algoClOrdId <id>",
8540
- description: "Get details of a specific TWAP algo order"
8541
- },
8542
- place: {
8543
- usage: "okx bot twap place --instId <id> --tdMode <cross|isolated|cash> --side <buy|sell>\n --sz <n> --szLimit <n> --pxLimit <px> --timeInterval <sec>\n --pxVar <bps> | --pxSpread <abs>\n [--posSide <long|short|net>] [--algoClOrdId <id>] [--ccy <ccy>] [--tradeQuoteCcy <ccy>]\n [--reduceOnly] [--isTradeBorrowMode]",
8544
- description: "Place a TWAP algo order to split a large order over time"
8545
- },
8546
- cancel: {
8547
- usage: "okx bot twap cancel --instId <id> --algoId <id> | --algoClOrdId <id>",
8548
- description: "Cancel a running TWAP algo order"
8549
- }
8550
- }
8551
- },
8552
- recurring: {
8553
- description: "Spot Recurring Buy (\u5B9A\u6295) \u2014 periodic automatic purchases (CLI-only)",
8554
- commands: {
8555
- orders: {
8556
- usage: "okx bot recurring orders [--algoId <id>] [--history]",
8557
- description: "List active or historical recurring buy orders"
8558
- },
8559
- details: {
8560
- usage: "okx bot recurring details --algoId <id>",
8561
- description: "Get details of a specific recurring buy order"
8562
- },
8563
- "sub-orders": {
8564
- usage: "okx bot recurring sub-orders --algoId <id>",
8565
- description: "List sub-orders (individual buy executions) of a recurring buy"
8566
- },
8567
- create: {
8568
- usage: "okx bot recurring create --stgyName <name> --recurringList '<json>'\n --period <hourly|daily|weekly|monthly> --recurringTime <0-23> --timeZone <n>\n --amt <n> --investmentCcy <ccy> --tdMode <cross|cash>\n [--recurringDay <n>] [--recurringHour <1|4|8|12>] [--tradeQuoteCcy <ccy>] [--algoClOrdId <id>]",
8569
- description: "Create a new recurring buy order"
8570
- },
8571
- amend: {
8572
- usage: "okx bot recurring amend --algoId <id> --stgyName <name>",
8573
- description: "Amend strategy name of a running recurring buy order"
8574
- },
8575
- stop: {
8576
- usage: "okx bot recurring stop --algoId <id>",
8577
- description: "Stop a running recurring buy order"
8578
8151
  }
8579
8152
  }
8580
8153
  }
8581
8154
  }
8582
8155
  },
8583
- "copytrading": {
8584
- description: "Copy trading \u2014 follow lead traders and manage copy positions",
8585
- commands: {
8586
- traders: {
8587
- usage: "okx copytrading traders [--instType <SWAP|SPOT>] [--sortType <overview|pnl|aum|win_ratio|pnl_ratio|current_copy_trader_pnl>]\n [--state <0|1>] [--minLeadDays <1|2|3|4>]\n [--minAssets <n>] [--maxAssets <n>] [--minAum <n>] [--maxAum <n>]\n [--page <n>] [--dataVer <14-digit>] [--limit <n>]",
8588
- description: "List top lead traders by ranking (default instType: SWAP, sortType: overview)"
8589
- },
8590
- status: {
8591
- usage: "okx --profile <name> copytrading status [--instType <SWAP|SPOT>]",
8592
- description: "Get your currently followed lead traders and their cumulative P&L (default instType: SWAP). Requires --profile."
8593
- },
8594
- follow: {
8595
- usage: "okx --profile <name> copytrading follow --uniqueCode <code>\n [--instType <SWAP|SPOT>]\n [--copyMode <smart_copy|fixed_amount|ratio_copy>]\n smart_copy (default): --initialAmount <n> --replicationRequired <0|1>\n fixed_amount: --copyTotalAmt <n> --copyAmt <n>\n ratio_copy: --copyTotalAmt <n> --copyRatio <n>\n [--copyMgnMode <copy|isolated|cross>]\n [--copyInstIdType <copy|custom>] [--instId <id,...>] (instId required when copyInstIdType=custom)\n [--subPosCloseType <copy_close|market_close|manual_close>]\n [--tpRatio <ratio>] [--slRatio <ratio>] [--slTotalAmt <n>]",
8596
- description: "Start following a lead trader (default instType: SWAP). Requires --profile."
8597
- },
8598
- unfollow: {
8599
- usage: "okx --profile <name> copytrading unfollow --uniqueCode <code> [--instType <SWAP|SPOT>] [--subPosCloseType <copy_close|market_close|manual_close>]",
8600
- description: "Stop following a lead trader (default instType: SWAP). Default subPosCloseType: copy_close. Requires --profile."
8601
- },
8602
- "trader-detail": {
8603
- usage: "okx copytrading trader-detail --uniqueCode <code> [--instType <SWAP|SPOT>] [--lastDays <1|2|3|4>]",
8604
- description: "Get stats, daily P&L, and currency preference of a lead trader (default instType: SWAP). lastDays: 1=7d, 2=30d (default), 3=90d, 4=365d"
8605
- }
8606
- }
8607
- },
8608
8156
  config: {
8609
8157
  description: "Manage CLI configuration profiles",
8610
8158
  commands: {
@@ -8817,25 +8365,6 @@ var CLI_OPTIONS = {
8817
8365
  basePos: { type: "boolean", default: true },
8818
8366
  stopType: { type: "string" },
8819
8367
  live: { type: "boolean", default: false },
8820
- // grid create extended
8821
- algoClOrdId: { type: "string" },
8822
- tpRatio: { type: "string" },
8823
- slRatio: { type: "string" },
8824
- tradeQuoteCcy: { type: "string" },
8825
- // grid extended commands
8826
- mktClose: { type: "boolean", default: false },
8827
- topupAmount: { type: "string" },
8828
- topUpAmt: { type: "string" },
8829
- allowReinvestProfit: { type: "string" },
8830
- percent: { type: "string" },
8831
- gridType: { type: "string" },
8832
- investmentType: { type: "string" },
8833
- // rsi back testing / ai param
8834
- timeframe: { type: "string" },
8835
- thold: { type: "string" },
8836
- timePeriod: { type: "string" },
8837
- triggerCond: { type: "string" },
8838
- duration: { type: "string" },
8839
8368
  // market extras
8840
8369
  instType: { type: "string" },
8841
8370
  quoteCcy: { type: "string" },
@@ -8865,19 +8394,7 @@ var CLI_OPTIONS = {
8865
8394
  allowReinvest: { type: "string" },
8866
8395
  triggerStrategy: { type: "string" },
8867
8396
  triggerPx: { type: "string" },
8868
- trackingMode: { type: "string" },
8869
- profitSharingRatio: { type: "string" },
8870
- tpPrice: { type: "string" },
8871
8397
  cycleId: { type: "string" },
8872
- // recurring buy
8873
- stgyName: { type: "string" },
8874
- recurringList: { type: "string" },
8875
- recurringDay: { type: "string" },
8876
- recurringTime: { type: "string" },
8877
- recurringHour: { type: "string" },
8878
- investmentCcy: { type: "string" },
8879
- period: { type: "string" },
8880
- timeZone: { type: "string" },
8881
8398
  // i18n
8882
8399
  lang: { type: "string" },
8883
8400
  // option
@@ -8893,14 +8410,6 @@ var CLI_OPTIONS = {
8893
8410
  tool: { type: "string" },
8894
8411
  // config profile
8895
8412
  force: { type: "boolean", default: false },
8896
- // twap bot
8897
- pxVar: { type: "string" },
8898
- pxSpread: { type: "string" },
8899
- szLimit: { type: "string" },
8900
- pxLimit: { type: "string" },
8901
- timeInterval: { type: "string" },
8902
- tgtCcy: { type: "string" },
8903
- isTradeBorrowMode: { type: "boolean", default: false },
8904
8413
  // onchain-earn
8905
8414
  productId: { type: "string" },
8906
8415
  protocolType: { type: "string" },
@@ -8932,29 +8441,8 @@ var CLI_OPTIONS = {
8932
8441
  // diagnose --cli only: CLI/general checks (explicit alias for default)
8933
8442
  all: { type: "boolean", default: false },
8934
8443
  // diagnose --all: run both CLI and MCP checks
8935
- output: { type: "string" },
8444
+ output: { type: "string" }
8936
8445
  // diagnose --output only: save report to file
8937
- // copytrading
8938
- uniqueCode: { type: "string" },
8939
- lastDays: { type: "string" },
8940
- sortType: { type: "string" },
8941
- minLeadDays: { type: "string" },
8942
- minAssets: { type: "string" },
8943
- maxAssets: { type: "string" },
8944
- minAum: { type: "string" },
8945
- maxAum: { type: "string" },
8946
- page: { type: "string" },
8947
- dataVer: { type: "string" },
8948
- copyMode: { type: "string" },
8949
- copyRatio: { type: "string" },
8950
- copyTotalAmt: { type: "string" },
8951
- copyAmt: { type: "string" },
8952
- copyMgnMode: { type: "string" },
8953
- copyInstIdType: { type: "string" },
8954
- subPosCloseType: { type: "string" },
8955
- initialAmount: { type: "string" },
8956
- replicationRequired: { type: "string" },
8957
- slTotalAmt: { type: "string" }
8958
8446
  };
8959
8447
  function parseCli(argv) {
8960
8448
  const negated = /* @__PURE__ */ new Set();
@@ -11036,10 +10524,10 @@ async function cmdGridDetails(run, opts) {
11036
10524
  minPx: detail["minPx"],
11037
10525
  gridNum: detail["gridNum"],
11038
10526
  runType: detail["runType"] === "1" ? "arithmetic" : "geometric",
11039
- pnl: detail["totalPnl"],
10527
+ pnl: detail["pnl"],
11040
10528
  pnlRatio: detail["pnlRatio"],
11041
- investAmt: detail["investment"],
11042
- totalAnnRate: detail["totalAnnualizedRate"],
10529
+ investAmt: detail["investAmt"],
10530
+ totalAnnRate: detail["totalAnnRate"],
11043
10531
  createdAt: new Date(Number(detail["cTime"])).toLocaleString()
11044
10532
  });
11045
10533
  }
@@ -11081,13 +10569,7 @@ async function cmdGridCreate(run, opts) {
11081
10569
  direction: opts.direction,
11082
10570
  lever: opts.lever,
11083
10571
  sz: opts.sz,
11084
- basePos: opts.basePos,
11085
- tpTriggerPx: opts.tpTriggerPx,
11086
- slTriggerPx: opts.slTriggerPx,
11087
- algoClOrdId: opts.algoClOrdId,
11088
- tpRatio: opts.tpRatio,
11089
- slRatio: opts.slRatio,
11090
- tradeQuoteCcy: opts.tradeQuoteCcy
10572
+ basePos: opts.basePos
11091
10573
  });
11092
10574
  const data = getData7(result);
11093
10575
  if (opts.json) return printJson(data);
@@ -11128,13 +10610,7 @@ async function cmdDcaCreate(run, opts) {
11128
10610
  slMode: opts.slMode,
11129
10611
  allowReinvest: opts.allowReinvest,
11130
10612
  triggerStrategy: opts.triggerStrategy,
11131
- triggerPx: opts.triggerPx,
11132
- triggerCond: opts.triggerCond,
11133
- thold: opts.thold,
11134
- timePeriod: opts.timePeriod,
11135
- timeframe: opts.timeframe,
11136
- trackingMode: opts.trackingMode,
11137
- profitSharingRatio: opts.profitSharingRatio
10613
+ triggerPx: opts.triggerPx
11138
10614
  });
11139
10615
  const data = getData7(result);
11140
10616
  if (opts.json) return printJson(data);
@@ -11230,683 +10706,34 @@ async function cmdDcaSubOrders(run, opts) {
11230
10706
  );
11231
10707
  }
11232
10708
 
11233
- // src/commands/bot-grid-ext.ts
11234
- function getDataArray(result) {
11235
- return result.data ?? [];
11236
- }
11237
- function printWriteResult(data, successMsg) {
11238
- const r = data[0];
11239
- if (!r) {
11240
- process.stdout.write("No response data\n");
11241
- return;
11242
- }
11243
- const sCode = r["sCode"];
11244
- if (sCode !== void 0 && sCode !== "0") {
11245
- process.stdout.write(`Error: [${sCode}] ${r["sMsg"] ?? "Operation failed"}
11246
- `);
11247
- return;
11248
- }
11249
- process.stdout.write(`${successMsg}
11250
- `);
10709
+ // src/commands/onchain-earn.ts
10710
+ function cmdOnchainEarnOffers(run, v) {
10711
+ return run("onchain_earn_get_offers", {
10712
+ productId: v.productId,
10713
+ protocolType: v.protocolType,
10714
+ ccy: v.ccy
10715
+ });
11251
10716
  }
11252
- async function cmdGridAmendBasicParam(client, opts) {
11253
- const response = await client.privatePost(
11254
- "/api/v5/tradingBot/grid/amend-algo-basic-param",
11255
- compactObject({
11256
- algoId: opts.algoId,
11257
- minPx: opts.minPx,
11258
- maxPx: opts.maxPx,
11259
- gridNum: opts.gridNum,
11260
- topupAmount: opts.topupAmount
11261
- }),
11262
- privateRateLimit("grid_amend_basic_param", 20)
11263
- );
11264
- const data = getDataArray(response);
11265
- if (opts.json) return printJson(data);
11266
- printWriteResult(data, `Grid bot amended: ${data[0]?.["algoId"]}`);
11267
- }
11268
- async function cmdGridAmendOrder(client, opts) {
11269
- const response = await client.privatePost(
11270
- "/api/v5/tradingBot/grid/amend-order-algo",
11271
- compactObject({
11272
- algoId: opts.algoId,
11273
- instId: opts.instId,
11274
- slTriggerPx: opts.slTriggerPx,
11275
- tpTriggerPx: opts.tpTriggerPx,
11276
- tpRatio: opts.tpRatio,
11277
- slRatio: opts.slRatio,
11278
- topUpAmt: opts.topUpAmt
11279
- }),
11280
- privateRateLimit("grid_amend_order", 20)
11281
- );
11282
- const data = getDataArray(response);
11283
- if (opts.json) return printJson(data);
11284
- printWriteResult(data, `Grid bot order amended: ${data[0]?.["algoId"]}`);
11285
- }
11286
- async function cmdGridClosePosition(client, opts) {
11287
- const response = await client.privatePost(
11288
- "/api/v5/tradingBot/grid/close-position",
11289
- compactObject({
11290
- algoId: opts.algoId,
11291
- mktClose: opts.mktClose,
11292
- sz: opts.sz,
11293
- px: opts.px
11294
- }),
11295
- privateRateLimit("grid_close_position", 20)
11296
- );
11297
- const data = getDataArray(response);
11298
- if (opts.json) return printJson(data);
11299
- const r = data[0];
11300
- if (opts.mktClose) {
11301
- printWriteResult(data, `Grid position market closed: ${r?.["algoId"]}`);
11302
- } else {
11303
- printWriteResult(data, `Grid close order placed: ${r?.["algoId"]} ordId=${r?.["ordId"]}`);
11304
- }
10717
+ function cmdOnchainEarnPurchase(run, v) {
10718
+ const investData = v.ccy && v.amt ? [{ ccy: v.ccy, amt: v.amt }] : void 0;
10719
+ return run("onchain_earn_purchase", {
10720
+ productId: v.productId,
10721
+ investData,
10722
+ term: v.term,
10723
+ tag: v.tag
10724
+ });
11305
10725
  }
11306
- async function cmdGridCancelCloseOrder(client, opts) {
11307
- const response = await client.privatePost(
11308
- "/api/v5/tradingBot/grid/cancel-close-order",
11309
- { algoId: opts.algoId, ordId: opts.ordId },
11310
- privateRateLimit("grid_cancel_close_order", 20)
11311
- );
11312
- const data = getDataArray(response);
11313
- if (opts.json) return printJson(data);
11314
- printWriteResult(data, `Grid close order cancelled: ${data[0]?.["algoId"]} ordId=${data[0]?.["ordId"]}`);
11315
- }
11316
- async function cmdGridInstantTrigger(client, opts) {
11317
- const response = await client.privatePost(
11318
- "/api/v5/tradingBot/grid/order-instant-trigger",
11319
- compactObject({
11320
- algoId: opts.algoId,
11321
- topUpAmt: opts.topUpAmt
11322
- }),
11323
- privateRateLimit("grid_instant_trigger", 20)
11324
- );
11325
- const data = getDataArray(response);
11326
- if (opts.json) return printJson(data);
11327
- printWriteResult(data, `Grid bot triggered: ${data[0]?.["algoId"]}`);
10726
+ function cmdOnchainEarnRedeem(run, v) {
10727
+ return run("onchain_earn_redeem", {
10728
+ ordId: v.ordId,
10729
+ protocolType: v.protocolType,
10730
+ allowEarlyRedeem: v.allowEarlyRedeem
10731
+ });
11328
10732
  }
11329
- async function cmdGridPositions(client, opts) {
11330
- const response = await client.privateGet(
11331
- "/api/v5/tradingBot/grid/positions",
11332
- { algoOrdType: opts.algoOrdType, algoId: opts.algoId },
11333
- privateRateLimit("grid_positions", 20)
11334
- );
11335
- const data = getDataArray(response);
11336
- if (opts.json) return printJson(data);
11337
- const detail = data[0];
11338
- if (!detail) {
11339
- process.stdout.write("No position data\n");
11340
- return;
11341
- }
11342
- printKv({
11343
- algoId: detail["algoId"],
11344
- instId: detail["instId"],
11345
- pos: detail["pos"],
11346
- avgPx: detail["avgPx"],
11347
- liqPx: detail["liqPx"],
11348
- lever: detail["lever"],
11349
- mgnMode: detail["mgnMode"],
11350
- upl: detail["upl"],
11351
- uplRatio: detail["uplRatio"],
11352
- markPx: detail["markPx"]
11353
- });
11354
- }
11355
- async function cmdGridWithdrawIncome(client, opts) {
11356
- const response = await client.privatePost(
11357
- "/api/v5/tradingBot/grid/withdraw-income",
11358
- { algoId: opts.algoId },
11359
- privateRateLimit("grid_withdraw_income", 20)
11360
- );
11361
- const data = getDataArray(response);
11362
- if (opts.json) return printJson(data);
11363
- const r = data[0];
11364
- process.stdout.write(`Grid income withdrawn: ${r?.["algoId"]} profit=${r?.["profit"]}
11365
- `);
11366
- }
11367
- async function cmdGridComputeMarginBalance(client, opts) {
11368
- const response = await client.privatePost(
11369
- "/api/v5/tradingBot/grid/compute-margin-balance",
11370
- compactObject({
11371
- algoId: opts.algoId,
11372
- type: opts.type,
11373
- amt: opts.amt
11374
- }),
11375
- privateRateLimit("grid_compute_margin_balance", 20)
11376
- );
11377
- const data = getDataArray(response);
11378
- if (opts.json) return printJson(data);
11379
- const detail = data[0];
11380
- if (!detail) {
11381
- process.stdout.write("No data\n");
11382
- return;
11383
- }
11384
- printKv({
11385
- maxAmt: detail["maxAmt"],
11386
- lever: detail["lever"]
11387
- });
11388
- }
11389
- async function cmdGridMarginBalance(client, opts) {
11390
- const response = await client.privatePost(
11391
- "/api/v5/tradingBot/grid/margin-balance",
11392
- compactObject({
11393
- algoId: opts.algoId,
11394
- type: opts.type,
11395
- amt: opts.amt,
11396
- percent: opts.percent
11397
- }),
11398
- privateRateLimit("grid_margin_balance", 20)
11399
- );
11400
- const data = getDataArray(response);
11401
- if (opts.json) return printJson(data);
11402
- printWriteResult(data, `Grid margin adjusted: ${data[0]?.["algoId"]}`);
11403
- }
11404
- async function cmdGridAdjustInvestment(client, opts) {
11405
- const response = await client.privatePost(
11406
- "/api/v5/tradingBot/grid/adjust-investment",
11407
- compactObject({
11408
- algoId: opts.algoId,
11409
- amt: opts.amt,
11410
- allowReinvestProfit: opts.allowReinvestProfit
11411
- }),
11412
- privateRateLimit("grid_adjust_investment", 20)
11413
- );
11414
- const data = getDataArray(response);
11415
- if (opts.json) return printJson(data);
11416
- printWriteResult(data, `Grid investment adjusted: ${data[0]?.["algoId"]}`);
11417
- }
11418
- async function cmdGridAiParam(client, opts) {
11419
- const response = await client.publicGet(
11420
- "/api/v5/tradingBot/grid/ai-param",
11421
- compactObject({
11422
- algoOrdType: opts.algoOrdType,
11423
- instId: opts.instId,
11424
- direction: opts.direction,
11425
- duration: opts.duration
11426
- }),
11427
- publicRateLimit("grid_ai_param", 20)
11428
- );
11429
- const data = getDataArray(response);
11430
- if (opts.json) return printJson(data);
11431
- const detail = data[0];
11432
- if (!detail) {
11433
- process.stdout.write("No AI param data\n");
11434
- return;
11435
- }
11436
- printKv({
11437
- instId: detail["instId"],
11438
- algoOrdType: detail["algoOrdType"],
11439
- duration: detail["duration"],
11440
- gridNum: detail["gridNum"],
11441
- maxPx: detail["maxPx"],
11442
- minPx: detail["minPx"],
11443
- minInvestment: `${detail["minInvestment"]} ${detail["ccy"]}`,
11444
- annualizedRate: detail["annualizedRate"],
11445
- runType: detail["runType"] === "1" ? "arithmetic" : "geometric"
11446
- });
11447
- }
11448
- async function cmdGridMinInvestment(client, opts) {
11449
- const response = await client.publicPost(
11450
- "/api/v5/tradingBot/grid/min-investment",
11451
- compactObject({
11452
- instId: opts.instId,
11453
- algoOrdType: opts.algoOrdType,
11454
- gridNum: opts.gridNum,
11455
- maxPx: opts.maxPx,
11456
- minPx: opts.minPx,
11457
- runType: opts.runType,
11458
- direction: opts.direction,
11459
- lever: opts.lever,
11460
- basePos: opts.basePos,
11461
- investmentType: opts.investmentType
11462
- }),
11463
- publicRateLimit("grid_min_investment", 20)
11464
- );
11465
- const data = getDataArray(response);
11466
- if (opts.json) return printJson(data);
11467
- const detail = data[0];
11468
- if (!detail) {
11469
- process.stdout.write("No data\n");
11470
- return;
11471
- }
11472
- const minData = detail["minInvestmentData"];
11473
- if (minData && minData.length > 0) {
11474
- process.stdout.write("Min Investment:\n");
11475
- for (const item of minData) {
11476
- process.stdout.write(` ${item["amt"]} ${item["ccy"]}
11477
- `);
11478
- }
11479
- }
11480
- process.stdout.write(`Single Amount: ${detail["singleAmt"]}
11481
- `);
11482
- }
11483
- async function cmdGridRsiBackTesting(client, opts) {
11484
- const response = await client.publicGet(
11485
- "/api/v5/tradingBot/public/rsi-back-testing",
11486
- compactObject({
11487
- instId: opts.instId,
11488
- timeframe: opts.timeframe,
11489
- thold: opts.thold,
11490
- timePeriod: opts.timePeriod,
11491
- triggerCond: opts.triggerCond,
11492
- duration: opts.duration
11493
- }),
11494
- publicRateLimit("grid_rsi_back_testing", 20)
11495
- );
11496
- const data = getDataArray(response);
11497
- if (opts.json) return printJson(data);
11498
- const detail = data[0];
11499
- process.stdout.write(`RSI trigger count: ${detail?.["triggerNum"] ?? "N/A"}
11500
- `);
11501
- }
11502
- async function cmdGridMaxQuantity(client, opts) {
11503
- const response = await client.publicGet(
11504
- "/api/v5/tradingBot/grid/grid-quantity",
11505
- compactObject({
11506
- instId: opts.instId,
11507
- runType: opts.runType,
11508
- algoOrdType: opts.algoOrdType,
11509
- maxPx: opts.maxPx,
11510
- minPx: opts.minPx,
11511
- lever: opts.lever
11512
- }),
11513
- publicRateLimit("grid_max_quantity", 5)
11514
- );
11515
- const data = getDataArray(response);
11516
- if (opts.json) return printJson(data);
11517
- const detail = data[0];
11518
- process.stdout.write(`Max grid quantity: ${detail?.["maxGridQty"] ?? "N/A"} (min: 2)
11519
- `);
11520
- }
11521
-
11522
- // src/commands/bot-dca-ext.ts
11523
- var BASE3 = "/api/v5/tradingBot/dca";
11524
- function getDataArray2(result) {
11525
- return result.data ?? [];
11526
- }
11527
- function printWriteResult2(data, successMsg) {
11528
- const r = data[0];
11529
- if (!r) {
11530
- process.stdout.write("No response data\n");
11531
- return;
11532
- }
11533
- const sCode = r["sCode"];
11534
- if (sCode !== void 0 && sCode !== "0") {
11535
- process.stdout.write(`Error: [${sCode}] ${r["sMsg"] ?? "Operation failed"}
11536
- `);
11537
- return;
11538
- }
11539
- process.stdout.write(`${successMsg}
11540
- `);
11541
- }
11542
- async function cmdDcaMarginAdd(client, opts) {
11543
- const response = await client.privatePost(
11544
- `${BASE3}/margin/add`,
11545
- { algoId: opts.algoId, amt: opts.amt },
11546
- privateRateLimit("dca_margin_add", 20)
11547
- );
11548
- const data = getDataArray2(response);
11549
- if (opts.json) return printJson(data);
11550
- printWriteResult2(data, `DCA margin added: ${opts.amt} (algoId: ${opts.algoId})`);
11551
- }
11552
- async function cmdDcaMarginReduce(client, opts) {
11553
- const response = await client.privatePost(
11554
- `${BASE3}/margin/reduce`,
11555
- { algoId: opts.algoId, amt: opts.amt },
11556
- privateRateLimit("dca_margin_reduce", 20)
11557
- );
11558
- const data = getDataArray2(response);
11559
- if (opts.json) return printJson(data);
11560
- printWriteResult2(data, `DCA margin reduced: ${opts.amt} (algoId: ${opts.algoId})`);
11561
- }
11562
- async function cmdDcaSetTakeProfit(client, opts) {
11563
- const response = await client.privatePost(
11564
- `${BASE3}/settings/take-profit`,
11565
- { algoId: opts.algoId, algoOrdType: "contract_dca", tpPrice: opts.tpPrice },
11566
- privateRateLimit("dca_set_take_profit", 20)
11567
- );
11568
- const data = getDataArray2(response);
11569
- if (opts.json) return printJson(data);
11570
- printWriteResult2(data, `DCA take-profit updated: ${opts.tpPrice} (algoId: ${opts.algoId})`);
11571
- }
11572
- async function cmdDcaSetReinvestment(client, opts) {
11573
- const response = await client.privatePost(
11574
- `${BASE3}/settings/reinvestment`,
11575
- { algoId: opts.algoId, algoOrdType: "contract_dca", allowReinvest: opts.allowReinvest },
11576
- privateRateLimit("dca_set_reinvestment", 20)
11577
- );
11578
- const data = getDataArray2(response);
11579
- if (opts.json) return printJson(data);
11580
- const label = opts.allowReinvest === "true" ? "enabled" : "disabled";
11581
- printWriteResult2(data, `DCA reinvestment ${label} (algoId: ${opts.algoId})`);
11582
- }
11583
- async function cmdDcaManualBuy(client, opts) {
11584
- const response = await client.privatePost(
11585
- `${BASE3}/orders/manual-buy`,
11586
- {
11587
- algoId: opts.algoId,
11588
- algoOrdType: "contract_dca",
11589
- amt: opts.amt,
11590
- price: opts.px
11591
- },
11592
- privateRateLimit("dca_manual_buy", 20)
11593
- );
11594
- const data = getDataArray2(response);
11595
- if (opts.json) return printJson(data);
11596
- printWriteResult2(data, `DCA manual buy: ${opts.amt} (algoId: ${opts.algoId})`);
11597
- }
11598
-
11599
- // src/commands/bot-recurring-ext.ts
11600
- var BASE4 = "/api/v5/tradingBot/recurring";
11601
- function getDataArray3(result) {
11602
- return result.data ?? [];
11603
- }
11604
- async function cmdRecurringCreate(client, opts) {
11605
- let parsed;
11606
- try {
11607
- parsed = JSON.parse(opts.recurringList);
11608
- } catch {
11609
- throw new Error(`recurringList must be a valid JSON array, e.g. '[{"ccy":"BTC","ratio":"1"}]'`);
11610
- }
11611
- if (!Array.isArray(parsed) || parsed.length === 0) {
11612
- throw new Error("recurringList must be a non-empty array of {ccy, ratio} objects");
11613
- }
11614
- if (opts.period === "hourly" && !opts.recurringHour) {
11615
- throw new Error("recurringHour is required when period=hourly (valid: 1, 4, 8, 12)");
11616
- }
11617
- const body = compactObject({
11618
- stgyName: opts.stgyName,
11619
- recurringList: parsed,
11620
- period: opts.period,
11621
- recurringDay: opts.recurringDay,
11622
- recurringTime: opts.recurringTime,
11623
- recurringHour: opts.recurringHour,
11624
- timeZone: opts.timeZone,
11625
- amt: opts.amt,
11626
- investmentCcy: opts.investmentCcy,
11627
- tdMode: opts.tdMode,
11628
- tradeQuoteCcy: opts.tradeQuoteCcy,
11629
- algoClOrdId: opts.algoClOrdId,
11630
- tag: DEFAULT_SOURCE_TAG
11631
- });
11632
- const response = await client.privatePost(
11633
- `${BASE4}/order-algo`,
11634
- body,
11635
- privateRateLimit("recurring_create", 20)
11636
- );
11637
- const data = getDataArray3(response);
11638
- if (opts.json) return printJson(data);
11639
- const r = data[0];
11640
- process.stdout.write(
11641
- `Recurring buy created: ${r?.["algoId"]} (${r?.["sCode"] === "0" ? "OK" : r?.["sMsg"]})
11642
- `
11643
- );
11644
- }
11645
- async function cmdRecurringAmend(client, opts) {
11646
- const response = await client.privatePost(
11647
- `${BASE4}/amend-order-algo`,
11648
- { algoId: opts.algoId, stgyName: opts.stgyName },
11649
- privateRateLimit("recurring_amend", 20)
11650
- );
11651
- const data = getDataArray3(response);
11652
- if (opts.json) return printJson(data);
11653
- const r = data[0];
11654
- process.stdout.write(
11655
- `Recurring buy amended: ${r?.["algoId"]} (${r?.["sCode"] === "0" ? "OK" : r?.["sMsg"]})
11656
- `
11657
- );
11658
- }
11659
- async function cmdRecurringStop(client, opts) {
11660
- const response = await client.privatePost(
11661
- `${BASE4}/stop-order-algo`,
11662
- [{ algoId: opts.algoId }],
11663
- privateRateLimit("recurring_stop", 20)
11664
- );
11665
- const data = getDataArray3(response);
11666
- if (opts.json) return printJson(data);
11667
- const r = data[0];
11668
- process.stdout.write(
11669
- `Recurring buy stopped: ${r?.["algoId"]} (${r?.["sCode"] === "0" ? "OK" : r?.["sMsg"]})
11670
- `
11671
- );
11672
- }
11673
- async function cmdRecurringOrders(client, opts) {
11674
- const endpoint = opts.history ? `${BASE4}/orders-algo-history` : `${BASE4}/orders-algo-pending`;
11675
- const params = compactObject({ algoId: opts.algoId });
11676
- const response = await client.privateGet(
11677
- endpoint,
11678
- params,
11679
- privateRateLimit("recurring_orders", 20)
11680
- );
11681
- const orders = getDataArray3(response);
11682
- if (opts.json) return printJson(orders);
11683
- if (!orders.length) {
11684
- process.stdout.write("No recurring buy orders\n");
11685
- return;
11686
- }
11687
- printTable(
11688
- orders.map((o) => ({
11689
- algoId: o["algoId"],
11690
- stgyName: o["stgyName"],
11691
- state: o["state"],
11692
- amt: o["amt"],
11693
- period: o["period"],
11694
- ccy: o["investmentCcy"],
11695
- createdAt: new Date(Number(o["cTime"])).toLocaleString()
11696
- }))
11697
- );
11698
- }
11699
- async function cmdRecurringDetails(client, opts) {
11700
- const response = await client.privateGet(
11701
- `${BASE4}/orders-algo-details`,
11702
- { algoId: opts.algoId },
11703
- privateRateLimit("recurring_details", 20)
11704
- );
11705
- const detail = getDataArray3(response)[0];
11706
- if (!detail) {
11707
- process.stdout.write("Recurring buy not found\n");
11708
- return;
11709
- }
11710
- if (opts.json) return printJson(detail);
11711
- printKv({
11712
- algoId: detail["algoId"],
11713
- stgyName: detail["stgyName"],
11714
- state: detail["state"],
11715
- amt: detail["amt"],
11716
- investmentCcy: detail["investmentCcy"],
11717
- period: detail["period"],
11718
- recurringDay: detail["recurringDay"],
11719
- recurringTime: detail["recurringTime"],
11720
- tdMode: detail["tdMode"],
11721
- totalAmt: detail["totalAmt"],
11722
- totalPnl: detail["totalPnl"],
11723
- createdAt: new Date(Number(detail["cTime"])).toLocaleString()
11724
- });
11725
- }
11726
- async function cmdRecurringSubOrders(client, opts) {
11727
- const response = await client.privateGet(
11728
- `${BASE4}/sub-orders`,
11729
- { algoId: opts.algoId },
11730
- privateRateLimit("recurring_sub_orders", 20)
11731
- );
11732
- const orders = getDataArray3(response);
11733
- if (opts.json) return printJson(orders);
11734
- if (!orders.length) {
11735
- process.stdout.write("No sub-orders\n");
11736
- return;
11737
- }
11738
- printTable(
11739
- orders.map((o) => ({
11740
- ordId: o["ordId"],
11741
- ccy: o["ccy"],
11742
- amt: o["amt"],
11743
- px: o["px"],
11744
- sz: o["sz"],
11745
- state: o["state"],
11746
- ts: o["ts"] ? new Date(Number(o["ts"])).toLocaleString() : ""
11747
- }))
11748
- );
11749
- }
11750
-
11751
- // src/commands/bot-twap-ext.ts
11752
- function getDataArray4(result) {
11753
- return result.data ?? [];
11754
- }
11755
- function printWriteResult3(data, successMsg) {
11756
- const r = data[0];
11757
- if (!r) {
11758
- process.stdout.write("No response data\n");
11759
- return;
11760
- }
11761
- const sCode = r["sCode"];
11762
- if (sCode !== void 0 && sCode !== "0") {
11763
- process.stdout.write(`Error: [${sCode}] ${r["sMsg"] ?? "Operation failed"}
11764
- `);
11765
- return;
11766
- }
11767
- process.stdout.write(`${successMsg}
11768
- `);
11769
- }
11770
- async function cmdTwapPlace(client, opts) {
11771
- const response = await client.privatePost(
11772
- "/api/v5/trade/order-algo",
11773
- compactObject({
11774
- instId: opts.instId,
11775
- tdMode: opts.tdMode,
11776
- side: opts.side,
11777
- ordType: "twap",
11778
- sz: opts.sz,
11779
- szLimit: opts.szLimit,
11780
- pxLimit: opts.pxLimit,
11781
- timeInterval: opts.timeInterval,
11782
- posSide: opts.posSide,
11783
- pxVar: opts.pxVar,
11784
- pxSpread: opts.pxSpread,
11785
- tag: "CLI",
11786
- algoClOrdId: opts.algoClOrdId,
11787
- ccy: opts.ccy,
11788
- tradeQuoteCcy: opts.tradeQuoteCcy,
11789
- reduceOnly: opts.reduceOnly !== void 0 ? String(opts.reduceOnly) : void 0,
11790
- isTradeBorrowMode: opts.isTradeBorrowMode !== void 0 ? String(opts.isTradeBorrowMode) : void 0
11791
- }),
11792
- privateRateLimit("twap_place_order", 20)
11793
- );
11794
- const data = getDataArray4(response);
11795
- if (opts.json) return printJson(data);
11796
- printWriteResult3(data, `TWAP order placed: ${data[0]?.["algoId"]}`);
11797
- }
11798
- async function cmdTwapCancel(client, opts) {
11799
- if (!opts.algoId && !opts.algoClOrdId) {
11800
- throw new Error("Must provide --algoId or --algoClOrdId");
11801
- }
11802
- const response = await client.privatePost(
11803
- "/api/v5/trade/cancel-algos",
11804
- [compactObject({
11805
- algoId: opts.algoId,
11806
- algoClOrdId: opts.algoClOrdId,
11807
- instId: opts.instId
11808
- })],
11809
- privateRateLimit("twap_cancel_order", 20)
11810
- );
11811
- const data = getDataArray4(response);
11812
- if (opts.json) return printJson(data);
11813
- printWriteResult3(data, `TWAP order cancelled: ${data[0]?.["algoId"]}`);
11814
- }
11815
- async function cmdTwapOrders(client, opts) {
11816
- const path5 = opts.history ? "/api/v5/trade/orders-algo-history" : "/api/v5/trade/orders-algo-pending";
11817
- const response = await client.privateGet(
11818
- path5,
11819
- compactObject({
11820
- ordType: "twap",
11821
- instType: opts.instType,
11822
- instId: opts.instId,
11823
- ...opts.history && !opts.state ? { state: "effective" } : {},
11824
- ...opts.history && opts.state ? { state: opts.state } : {}
11825
- }),
11826
- privateRateLimit("twap_get_orders", 20)
11827
- );
11828
- const orders = getDataArray4(response);
11829
- if (opts.json) return printJson(orders);
11830
- if (!orders.length) {
11831
- process.stdout.write("No TWAP orders\n");
11832
- return;
11833
- }
11834
- printTable(
11835
- orders.map((o) => ({
11836
- algoId: o["algoId"],
11837
- instId: o["instId"],
11838
- side: o["side"],
11839
- state: o["state"],
11840
- sz: o["sz"],
11841
- szLimit: o["szLimit"],
11842
- pxLimit: o["pxLimit"],
11843
- timeInterval: o["timeInterval"],
11844
- createdAt: new Date(Number(o["cTime"])).toLocaleString()
11845
- }))
11846
- );
11847
- }
11848
- async function cmdTwapDetails(client, opts) {
11849
- if (!opts.algoId && !opts.algoClOrdId) {
11850
- throw new Error("Must provide --algoId or --algoClOrdId");
11851
- }
11852
- const response = await client.privateGet(
11853
- "/api/v5/trade/order-algo",
11854
- compactObject({
11855
- algoId: opts.algoId,
11856
- algoClOrdId: opts.algoClOrdId
11857
- }),
11858
- privateRateLimit("twap_get_order_details", 20)
11859
- );
11860
- const data = getDataArray4(response);
11861
- const detail = data[0];
11862
- if (!detail) {
11863
- process.stdout.write("TWAP order not found\n");
11864
- return;
11865
- }
11866
- if (opts.json) return printJson(detail);
11867
- printKv({
11868
- algoId: detail["algoId"],
11869
- instId: detail["instId"],
11870
- side: detail["side"],
11871
- state: detail["state"],
11872
- sz: detail["sz"],
11873
- szLimit: detail["szLimit"],
11874
- pxLimit: detail["pxLimit"],
11875
- pxVar: detail["pxVar"],
11876
- pxSpread: detail["pxSpread"],
11877
- timeInterval: detail["timeInterval"],
11878
- createdAt: new Date(Number(detail["cTime"])).toLocaleString()
11879
- });
11880
- }
11881
-
11882
- // src/commands/onchain-earn.ts
11883
- function cmdOnchainEarnOffers(run, v) {
11884
- return run("onchain_earn_get_offers", {
11885
- productId: v.productId,
11886
- protocolType: v.protocolType,
11887
- ccy: v.ccy
11888
- });
11889
- }
11890
- function cmdOnchainEarnPurchase(run, v) {
11891
- const investData = v.ccy && v.amt ? [{ ccy: v.ccy, amt: v.amt }] : void 0;
11892
- return run("onchain_earn_purchase", {
11893
- productId: v.productId,
11894
- investData,
11895
- term: v.term,
11896
- tag: v.tag
11897
- });
11898
- }
11899
- function cmdOnchainEarnRedeem(run, v) {
11900
- return run("onchain_earn_redeem", {
11901
- ordId: v.ordId,
11902
- protocolType: v.protocolType,
11903
- allowEarlyRedeem: v.allowEarlyRedeem
11904
- });
11905
- }
11906
- function cmdOnchainEarnCancel(run, v) {
11907
- return run("onchain_earn_cancel", {
11908
- ordId: v.ordId,
11909
- protocolType: v.protocolType
10733
+ function cmdOnchainEarnCancel(run, v) {
10734
+ return run("onchain_earn_cancel", {
10735
+ ordId: v.ordId,
10736
+ protocolType: v.protocolType
11910
10737
  });
11911
10738
  }
11912
10739
  function cmdOnchainEarnActiveOrders(run, v) {
@@ -12172,135 +10999,10 @@ async function cmdDcdQuoteAndBuy(run, opts) {
12172
10999
  }
12173
11000
  }
12174
11001
 
12175
- // src/commands/copytrading.ts
12176
- function asRaw(result) {
12177
- return result;
12178
- }
12179
- async function cmdCopyTradeTraders(run, opts) {
12180
- const result = await run("copytrading_get_lead_traders", {
12181
- instType: opts.instType,
12182
- sortType: opts.sortType,
12183
- state: opts.state,
12184
- minLeadDays: opts.minLeadDays,
12185
- minAssets: opts.minAssets,
12186
- maxAssets: opts.maxAssets,
12187
- minAum: opts.minAum,
12188
- maxAum: opts.maxAum,
12189
- page: opts.page,
12190
- dataVer: opts.dataVer,
12191
- limit: opts.limit
12192
- });
12193
- const raw = asRaw(result);
12194
- const data = raw["data"] ?? [];
12195
- if (opts.json) return printJson(data);
12196
- printTable(
12197
- (data ?? []).map((t) => ({
12198
- uniqueCode: t["uniqueCode"],
12199
- nickName: t["nickName"],
12200
- pnl: t["pnl"],
12201
- winRatio: t["winRatio"],
12202
- copyTraderNum: t["copyTraderNum"],
12203
- leadDays: t["leadDays"]
12204
- }))
12205
- );
12206
- }
12207
- async function cmdCopyTradeMyStatus(run, opts) {
12208
- const result = await run("copytrading_get_my_details", { instType: opts.instType });
12209
- const raw = result;
12210
- const traders = raw.data ?? [];
12211
- if (opts.json) return printJson(raw);
12212
- if (!traders.length) {
12213
- process.stdout.write("No active copy traders\n");
12214
- return;
12215
- }
12216
- printTable(
12217
- traders.map((t) => ({
12218
- uniqueCode: t["uniqueCode"],
12219
- nickName: t["nickName"],
12220
- copyTotalPnl: t["copyTotalPnl"],
12221
- todayPnl: t["todayPnl"],
12222
- upl: t["upl"],
12223
- margin: t["margin"]
12224
- }))
12225
- );
12226
- }
12227
- async function cmdCopyTradeFollow(run, opts) {
12228
- const result = await run("copytrading_set_copytrading", {
12229
- uniqueCode: opts.uniqueCode,
12230
- copyTotalAmt: opts.copyTotalAmt,
12231
- copyMgnMode: opts.copyMgnMode,
12232
- copyInstIdType: opts.copyInstIdType,
12233
- instId: opts.instId,
12234
- copyMode: opts.copyMode,
12235
- copyAmt: opts.copyAmt,
12236
- copyRatio: opts.copyRatio,
12237
- initialAmount: opts.initialAmount,
12238
- replicationRequired: opts.replicationRequired,
12239
- subPosCloseType: opts.subPosCloseType,
12240
- instType: opts.instType,
12241
- tpRatio: opts.tpRatio,
12242
- slRatio: opts.slRatio,
12243
- slTotalAmt: opts.slTotalAmt
12244
- });
12245
- const data = asRaw(result)["data"];
12246
- if (opts.json) return printJson(data);
12247
- process.stdout.write(`Following trader: ${opts.uniqueCode}
12248
- `);
12249
- }
12250
- async function cmdCopyTradeUnfollow(run, opts) {
12251
- const result = await run("copytrading_stop_copy_trader", {
12252
- uniqueCode: opts.uniqueCode,
12253
- subPosCloseType: opts.subPosCloseType,
12254
- instType: opts.instType
12255
- });
12256
- const data = asRaw(result)["data"];
12257
- if (opts.json) return printJson(data);
12258
- process.stdout.write(`Stopped copying: ${opts.uniqueCode}
12259
- `);
12260
- }
12261
- async function cmdCopyTradeTraderDetail(run, opts) {
12262
- const result = await run("copytrading_get_trader_details", {
12263
- uniqueCode: opts.uniqueCode,
12264
- lastDays: opts.lastDays,
12265
- instType: opts.instType
12266
- });
12267
- const raw = result;
12268
- if (opts.json) return printJson(raw);
12269
- const stats = (raw.stats ?? [])[0];
12270
- if (stats) {
12271
- process.stdout.write([
12272
- `Win Rate: ${stats["winRatio"]}`,
12273
- `Profit Days: ${stats["profitDays"]}`,
12274
- `Loss Days: ${stats["lossDays"]}`,
12275
- `Follower PnL: ${stats["curCopyTraderPnl"]} USDT`,
12276
- `Avg Position: ${stats["avgSubPosNotional"]} USDT`,
12277
- `Invested: ${stats["investAmt"]} USDT`
12278
- ].join("\n") + "\n\n");
12279
- }
12280
- const pnl = raw.pnl ?? [];
12281
- if (pnl.length) {
12282
- process.stdout.write("Daily P&L:\n");
12283
- printTable(pnl.map((d) => ({
12284
- date: new Date(Number(d["beginTs"])).toLocaleDateString(),
12285
- pnl: d["pnl"],
12286
- pnlRatio: d["pnlRatio"]
12287
- })));
12288
- process.stdout.write("\n");
12289
- }
12290
- const preference = raw.preference ?? [];
12291
- if (preference.length) {
12292
- process.stdout.write("Currency Preference:\n");
12293
- printTable(preference.map((d) => ({
12294
- currency: d["ccy"],
12295
- ratio: `${(Number(d["ratio"]) * 100).toFixed(1)}%`
12296
- })));
12297
- }
12298
- }
12299
-
12300
11002
  // src/index.ts
12301
11003
  var _require3 = createRequire3(import.meta.url);
12302
11004
  var CLI_VERSION2 = _require3("../package.json").version;
12303
- var GIT_HASH2 = true ? "da62db2" : "dev";
11005
+ var GIT_HASH2 = true ? "50eb95e" : "dev";
12304
11006
  function handleConfigCommand(action, rest, json, lang, force) {
12305
11007
  if (action === "init") return cmdConfigInit(lang === "zh" ? "zh" : "en");
12306
11008
  if (action === "show") return cmdConfigShow(json);
@@ -12828,7 +11530,7 @@ function handleFuturesCommand(run, action, rest, v, json) {
12828
11530
  if (action === "algo")
12829
11531
  return handleFuturesAlgoCommand(run, rest[0], v, json);
12830
11532
  }
12831
- function handleBotGridCommand(run, client, v, rest, json) {
11533
+ function handleBotGridCommand(run, v, rest, json) {
12832
11534
  const subAction = rest[0];
12833
11535
  if (subAction === "orders")
12834
11536
  return cmdGridOrders(run, {
@@ -12865,12 +11567,6 @@ function handleBotGridCommand(run, client, v, rest, json) {
12865
11567
  lever: v.lever,
12866
11568
  sz: v.sz,
12867
11569
  basePos: v.basePos,
12868
- tpTriggerPx: v.tpTriggerPx,
12869
- slTriggerPx: v.slTriggerPx,
12870
- algoClOrdId: v.algoClOrdId,
12871
- tpRatio: v.tpRatio,
12872
- slRatio: v.slRatio,
12873
- tradeQuoteCcy: v.tradeQuoteCcy,
12874
11570
  json
12875
11571
  });
12876
11572
  if (subAction === "stop")
@@ -12881,123 +11577,8 @@ function handleBotGridCommand(run, client, v, rest, json) {
12881
11577
  stopType: v.stopType,
12882
11578
  json
12883
11579
  });
12884
- if (subAction === "amend-basic")
12885
- return cmdGridAmendBasicParam(client, {
12886
- algoId: v.algoId,
12887
- minPx: v.minPx,
12888
- maxPx: v.maxPx,
12889
- gridNum: v.gridNum,
12890
- topupAmount: v.topupAmount,
12891
- json
12892
- });
12893
- if (subAction === "amend-order")
12894
- return cmdGridAmendOrder(client, {
12895
- algoId: v.algoId,
12896
- instId: v.instId,
12897
- slTriggerPx: v.slTriggerPx,
12898
- tpTriggerPx: v.tpTriggerPx,
12899
- tpRatio: v.tpRatio,
12900
- slRatio: v.slRatio,
12901
- topUpAmt: v.topUpAmt,
12902
- json
12903
- });
12904
- if (subAction === "close-position")
12905
- return cmdGridClosePosition(client, {
12906
- algoId: v.algoId,
12907
- mktClose: v.mktClose ?? false,
12908
- sz: v.sz,
12909
- px: v.px,
12910
- json
12911
- });
12912
- if (subAction === "cancel-close")
12913
- return cmdGridCancelCloseOrder(client, {
12914
- algoId: v.algoId,
12915
- ordId: v.ordId,
12916
- json
12917
- });
12918
- if (subAction === "instant-trigger")
12919
- return cmdGridInstantTrigger(client, {
12920
- algoId: v.algoId,
12921
- topUpAmt: v.topUpAmt,
12922
- json
12923
- });
12924
- if (subAction === "positions")
12925
- return cmdGridPositions(client, {
12926
- algoOrdType: v.algoOrdType,
12927
- algoId: v.algoId,
12928
- json
12929
- });
12930
- if (subAction === "withdraw-income")
12931
- return cmdGridWithdrawIncome(client, {
12932
- algoId: v.algoId,
12933
- json
12934
- });
12935
- if (subAction === "compute-margin")
12936
- return cmdGridComputeMarginBalance(client, {
12937
- algoId: v.algoId,
12938
- type: v.gridType,
12939
- amt: v.amt,
12940
- json
12941
- });
12942
- if (subAction === "margin-balance")
12943
- return cmdGridMarginBalance(client, {
12944
- algoId: v.algoId,
12945
- type: v.gridType,
12946
- amt: v.amt,
12947
- percent: v.percent,
12948
- json
12949
- });
12950
- if (subAction === "adjust-investment")
12951
- return cmdGridAdjustInvestment(client, {
12952
- algoId: v.algoId,
12953
- amt: v.amt,
12954
- allowReinvestProfit: v.allowReinvestProfit,
12955
- json
12956
- });
12957
- if (subAction === "ai-param")
12958
- return cmdGridAiParam(client, {
12959
- algoOrdType: v.algoOrdType,
12960
- instId: v.instId,
12961
- direction: v.direction,
12962
- duration: v.duration,
12963
- json
12964
- });
12965
- if (subAction === "min-investment")
12966
- return cmdGridMinInvestment(client, {
12967
- instId: v.instId,
12968
- algoOrdType: v.algoOrdType,
12969
- gridNum: v.gridNum,
12970
- maxPx: v.maxPx,
12971
- minPx: v.minPx,
12972
- runType: v.runType,
12973
- direction: v.direction,
12974
- lever: v.lever,
12975
- basePos: v.basePos,
12976
- investmentType: v.investmentType,
12977
- json
12978
- });
12979
- if (subAction === "rsi-back-testing")
12980
- return cmdGridRsiBackTesting(client, {
12981
- instId: v.instId,
12982
- timeframe: v.timeframe,
12983
- thold: v.thold,
12984
- timePeriod: v.timePeriod,
12985
- triggerCond: v.triggerCond,
12986
- duration: v.duration,
12987
- json
12988
- });
12989
- if (subAction === "max-quantity")
12990
- return cmdGridMaxQuantity(client, {
12991
- instId: v.instId,
12992
- runType: v.runType,
12993
- algoOrdType: v.algoOrdType,
12994
- maxPx: v.maxPx,
12995
- minPx: v.minPx,
12996
- lever: v.lever,
12997
- json
12998
- });
12999
11580
  }
13000
- function handleBotDcaCommand(run, client, subAction, v, json) {
11581
+ function handleBotDcaCommand(run, subAction, v, json) {
13001
11582
  if (subAction === "orders")
13002
11583
  return cmdDcaOrders(run, { algoId: v.algoId, instId: v.instId, history: v.history ?? false, json });
13003
11584
  if (subAction === "details")
@@ -13021,140 +11602,14 @@ function handleBotDcaCommand(run, client, subAction, v, json) {
13021
11602
  allowReinvest: v.allowReinvest,
13022
11603
  triggerStrategy: v.triggerStrategy,
13023
11604
  triggerPx: v.triggerPx,
13024
- triggerCond: v.triggerCond,
13025
- thold: v.thold,
13026
- timePeriod: v.timePeriod,
13027
- timeframe: v.timeframe,
13028
- trackingMode: v.trackingMode,
13029
- profitSharingRatio: v.profitSharingRatio,
13030
11605
  json
13031
11606
  });
13032
11607
  if (subAction === "stop")
13033
11608
  return cmdDcaStop(run, { algoId: v.algoId, json });
13034
- if (subAction === "margin-add")
13035
- return cmdDcaMarginAdd(client, { algoId: v.algoId, amt: v.amt, json });
13036
- if (subAction === "margin-reduce")
13037
- return cmdDcaMarginReduce(client, { algoId: v.algoId, amt: v.amt, json });
13038
- if (subAction === "set-tp")
13039
- return cmdDcaSetTakeProfit(client, { algoId: v.algoId, tpPrice: v.tpPrice, json });
13040
- if (subAction === "set-reinvest")
13041
- return cmdDcaSetReinvestment(client, { algoId: v.algoId, allowReinvest: v.allowReinvest, json });
13042
- if (subAction === "manual-buy") {
13043
- if (!v.px) throw new Error("--px <price> is required for manual-buy");
13044
- return cmdDcaManualBuy(client, { algoId: v.algoId, amt: v.amt, px: v.px, json });
13045
- }
13046
- }
13047
- function handleBotTwapCommand(client, subAction, v, json) {
13048
- if (subAction === "orders")
13049
- return cmdTwapOrders(client, { history: v.history ?? false, instId: v.instId, instType: v.instType, state: v.state, json });
13050
- if (subAction === "details")
13051
- return cmdTwapDetails(client, { algoId: v.algoId, algoClOrdId: v.algoClOrdId, json });
13052
- if (subAction === "place")
13053
- return cmdTwapPlace(client, {
13054
- instId: v.instId,
13055
- tdMode: v.tdMode,
13056
- side: v.side,
13057
- sz: v.sz,
13058
- szLimit: v.szLimit,
13059
- pxLimit: v.pxLimit,
13060
- timeInterval: v.timeInterval,
13061
- posSide: v.posSide,
13062
- pxVar: v.pxVar,
13063
- pxSpread: v.pxSpread,
13064
- algoClOrdId: v.algoClOrdId,
13065
- ccy: v.ccy,
13066
- tradeQuoteCcy: v.tradeQuoteCcy,
13067
- reduceOnly: v.reduceOnly || void 0,
13068
- isTradeBorrowMode: v.isTradeBorrowMode || void 0,
13069
- json
13070
- });
13071
- if (subAction === "cancel")
13072
- return cmdTwapCancel(client, { instId: v.instId, algoId: v.algoId, algoClOrdId: v.algoClOrdId, json });
13073
11609
  }
13074
- function handleBotRecurringCommand(client, subAction, v, json) {
13075
- if (subAction === "orders")
13076
- return cmdRecurringOrders(client, { algoId: v.algoId, history: v.history ?? false, json });
13077
- if (subAction === "details")
13078
- return cmdRecurringDetails(client, { algoId: v.algoId, json });
13079
- if (subAction === "sub-orders")
13080
- return cmdRecurringSubOrders(client, { algoId: v.algoId, json });
13081
- if (subAction === "create")
13082
- return cmdRecurringCreate(client, {
13083
- stgyName: v.stgyName,
13084
- recurringList: v.recurringList,
13085
- period: v.period,
13086
- recurringDay: v.recurringDay,
13087
- recurringTime: v.recurringTime,
13088
- recurringHour: v.recurringHour,
13089
- timeZone: v.timeZone,
13090
- amt: v.amt,
13091
- investmentCcy: v.investmentCcy,
13092
- tdMode: v.tdMode,
13093
- tradeQuoteCcy: v.tradeQuoteCcy,
13094
- algoClOrdId: v.algoClOrdId,
13095
- json
13096
- });
13097
- if (subAction === "amend")
13098
- return cmdRecurringAmend(client, {
13099
- algoId: v.algoId,
13100
- stgyName: v.stgyName,
13101
- json
13102
- });
13103
- if (subAction === "stop")
13104
- return cmdRecurringStop(client, { algoId: v.algoId, json });
13105
- }
13106
- function handleCopyTradeCommand(run, action, _rest, v, json) {
13107
- const limit = v.limit !== void 0 ? Number(v.limit) : void 0;
13108
- if (action === "traders")
13109
- return cmdCopyTradeTraders(run, {
13110
- instType: v.instType,
13111
- sortType: v.sortType,
13112
- state: v.state,
13113
- minLeadDays: v.minLeadDays,
13114
- minAssets: v.minAssets,
13115
- maxAssets: v.maxAssets,
13116
- minAum: v.minAum,
13117
- maxAum: v.maxAum,
13118
- page: v.page,
13119
- dataVer: v.dataVer,
13120
- limit,
13121
- json
13122
- });
13123
- if (action === "status")
13124
- return cmdCopyTradeMyStatus(run, { instType: v.instType, json });
13125
- if (action === "follow")
13126
- return cmdCopyTradeFollow(run, {
13127
- uniqueCode: v.uniqueCode,
13128
- copyTotalAmt: v.copyTotalAmt,
13129
- copyMgnMode: v.copyMgnMode,
13130
- copyInstIdType: v.copyInstIdType,
13131
- instId: v.instId,
13132
- copyMode: v.copyMode,
13133
- copyAmt: v.copyAmt,
13134
- copyRatio: v.copyRatio,
13135
- initialAmount: v.initialAmount,
13136
- replicationRequired: v.replicationRequired,
13137
- subPosCloseType: v.subPosCloseType,
13138
- instType: v.instType,
13139
- tpRatio: v.tpRatio,
13140
- slRatio: v.slRatio,
13141
- slTotalAmt: v.slTotalAmt,
13142
- json
13143
- });
13144
- if (action === "unfollow")
13145
- return cmdCopyTradeUnfollow(run, { uniqueCode: v.uniqueCode, subPosCloseType: v.subPosCloseType, instType: v.instType, json });
13146
- if (action === "trader-detail")
13147
- return cmdCopyTradeTraderDetail(run, { uniqueCode: v.uniqueCode, lastDays: v.lastDays, instType: v.instType, json });
13148
- process.stderr.write(`Unknown copytrading command: ${action}
13149
- Valid: traders, status, follow, unfollow, trader-detail
13150
- `);
13151
- process.exitCode = 1;
13152
- }
13153
- function handleBotCommand(run, client, action, rest, v, json) {
13154
- if (action === "grid") return handleBotGridCommand(run, client, v, rest, json);
13155
- if (action === "dca") return handleBotDcaCommand(run, client, rest[0], v, json);
13156
- if (action === "twap") return handleBotTwapCommand(client, rest[0], v, json);
13157
- if (action === "recurring") return handleBotRecurringCommand(client, rest[0], v, json);
11610
+ function handleBotCommand(run, action, rest, v, json) {
11611
+ if (action === "grid") return handleBotGridCommand(run, v, rest, json);
11612
+ if (action === "dca") return handleBotDcaCommand(run, rest[0], v, json);
13158
11613
  }
13159
11614
  function handleEarnCommand(run, submodule, rest, v, json) {
13160
11615
  const action = rest[0];
@@ -13302,9 +11757,8 @@ async function main() {
13302
11757
  swap: () => handleSwapCommand(run, action, rest, v, json),
13303
11758
  futures: () => handleFuturesCommand(run, action, rest, v, json),
13304
11759
  option: () => handleOptionCommand(run, action, rest, v, json),
13305
- bot: () => handleBotCommand(run, client, action, rest, v, json),
13306
- earn: () => handleEarnCommand(run, action, rest, v, json),
13307
- copytrading: () => handleCopyTradeCommand(run, action, rest, v, json)
11760
+ bot: () => handleBotCommand(run, action, rest, v, json),
11761
+ earn: () => handleEarnCommand(run, action, rest, v, json)
13308
11762
  };
13309
11763
  const handler = moduleHandlers[module];
13310
11764
  if (handler) return handler();
@@ -13315,8 +11769,6 @@ async function main() {
13315
11769
  main().catch((error) => {
13316
11770
  const payload = toToolErrorPayload(error);
13317
11771
  process.stderr.write(`Error: ${payload.message}
13318
- `);
13319
- if (payload.code) process.stderr.write(`Code: ${payload.code}
13320
11772
  `);
13321
11773
  if (payload.traceId) process.stderr.write(`TraceId: ${payload.traceId}
13322
11774
  `);
@@ -13331,10 +11783,7 @@ export {
13331
11783
  handleBotCommand,
13332
11784
  handleBotDcaCommand,
13333
11785
  handleBotGridCommand,
13334
- handleBotRecurringCommand,
13335
- handleBotTwapCommand,
13336
11786
  handleConfigCommand,
13337
- handleCopyTradeCommand,
13338
11787
  handleEarnCommand,
13339
11788
  handleFuturesAlgoCommand,
13340
11789
  handleFuturesCommand,