@okx_ai/okx-trade-cli 1.2.3-beta.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OKX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  import { createRequire as createRequire2 } from "module";
5
5
 
6
6
  // ../core/dist/index.js
7
+ import { ProxyAgent } from "undici";
7
8
  import { createHmac } from "crypto";
8
9
  import fs from "fs";
9
10
  import path from "path";
@@ -1063,9 +1064,13 @@ function vlog(message) {
1063
1064
  var OkxRestClient = class {
1064
1065
  config;
1065
1066
  rateLimiter;
1067
+ dispatcher;
1066
1068
  constructor(config) {
1067
1069
  this.config = config;
1068
1070
  this.rateLimiter = new RateLimiter(3e4, config.verbose);
1071
+ if (config.proxyUrl) {
1072
+ this.dispatcher = new ProxyAgent(config.proxyUrl);
1073
+ }
1069
1074
  }
1070
1075
  logRequest(method, url, auth) {
1071
1076
  if (!this.config.verbose) return;
@@ -1225,12 +1230,16 @@ var OkxRestClient = class {
1225
1230
  const t0 = Date.now();
1226
1231
  let response;
1227
1232
  try {
1228
- response = await fetch(url, {
1233
+ const fetchOptions = {
1229
1234
  method: reqConfig.method,
1230
1235
  headers,
1231
1236
  body: reqConfig.method === "POST" ? bodyJson : void 0,
1232
1237
  signal: AbortSignal.timeout(this.config.timeoutMs)
1233
- });
1238
+ };
1239
+ if (this.dispatcher) {
1240
+ fetchOptions.dispatcher = this.dispatcher;
1241
+ }
1242
+ response = await fetch(url, fetchOptions);
1234
1243
  } catch (error) {
1235
1244
  if (this.config.verbose) {
1236
1245
  const elapsed2 = Date.now() - t0;
@@ -1982,7 +1991,7 @@ function registerAlgoTradeTools() {
1982
1991
  },
1983
1992
  sz: {
1984
1993
  type: "string",
1985
- description: "Contracts to close"
1994
+ description: "Number of contracts to close (NOT USDT amount). Use market_get_instruments to get ctVal for conversion."
1986
1995
  },
1987
1996
  tpTriggerPx: {
1988
1997
  type: "string",
@@ -2077,7 +2086,7 @@ function registerAlgoTradeTools() {
2077
2086
  },
2078
2087
  sz: {
2079
2088
  type: "string",
2080
- description: "Contracts"
2089
+ description: "Number of contracts (NOT USDT amount). Use market_get_instruments to get ctVal for conversion."
2081
2090
  },
2082
2091
  callbackRatio: {
2083
2092
  type: "string",
@@ -3174,7 +3183,7 @@ function registerFuturesTools() {
3174
3183
  },
3175
3184
  sz: {
3176
3185
  type: "string",
3177
- description: "Contracts"
3186
+ description: "Number of contracts (NOT USDT amount). Use market_get_instruments to get ctVal for conversion."
3178
3187
  },
3179
3188
  px: {
3180
3189
  type: "string",
@@ -4284,7 +4293,7 @@ function registerOptionTools() {
4284
4293
  },
4285
4294
  sz: {
4286
4295
  type: "string",
4287
- description: "Number of contracts"
4296
+ description: "Number of contracts (NOT USDT amount). Use market_get_instruments to get ctVal for conversion."
4288
4297
  },
4289
4298
  px: {
4290
4299
  type: "string",
@@ -4391,7 +4400,7 @@ function registerOptionTools() {
4391
4400
  instId: { type: "string", description: "e.g. BTC-USD-241227-50000-C" },
4392
4401
  ordId: { type: "string" },
4393
4402
  clOrdId: { type: "string" },
4394
- newSz: { type: "string", description: "New quantity (contracts)" },
4403
+ newSz: { type: "string", description: "New number of contracts (NOT USDT amount)" },
4395
4404
  newPx: { type: "string", description: "New price" }
4396
4405
  },
4397
4406
  required: ["instId"]
@@ -5353,7 +5362,7 @@ function registerSwapTradeTools() {
5353
5362
  },
5354
5363
  sz: {
5355
5364
  type: "string",
5356
- description: "Contracts (e.g. '1'; BTC-USDT-SWAP: 1ct=0.01 BTC)"
5365
+ description: "Number of contracts (NOT USDT amount). Use market_get_instruments to get ctVal for conversion."
5357
5366
  },
5358
5367
  px: {
5359
5368
  type: "string",
@@ -5618,7 +5627,7 @@ function registerSwapTradeTools() {
5618
5627
  properties: {
5619
5628
  instId: { type: "string", description: "e.g. BTC-USDT-SWAP" },
5620
5629
  algoId: { type: "string", description: "Algo order ID" },
5621
- newSz: { type: "string", description: "New quantity (contracts)" },
5630
+ newSz: { type: "string", description: "New number of contracts (NOT USDT amount)" },
5622
5631
  newTpTriggerPx: { type: "string", description: "New TP trigger price" },
5623
5632
  newTpOrdPx: { type: "string", description: "New TP order price; -1=market" },
5624
5633
  newSlTriggerPx: { type: "string", description: "New SL trigger price" },
@@ -6095,6 +6104,13 @@ function loadConfig(cli) {
6095
6104
  "Set OKX_TIMEOUT_MS as a positive integer in milliseconds."
6096
6105
  );
6097
6106
  }
6107
+ const rawProxyUrl = toml.proxy_url?.trim();
6108
+ if (rawProxyUrl && !rawProxyUrl.startsWith("http://") && !rawProxyUrl.startsWith("https://")) {
6109
+ throw new ConfigError(
6110
+ `Invalid proxy URL "${rawProxyUrl}".`,
6111
+ "proxy_url must start with http:// or https://. SOCKS proxies are not supported."
6112
+ );
6113
+ }
6098
6114
  return {
6099
6115
  ...creds,
6100
6116
  baseUrl,
@@ -6105,6 +6121,7 @@ function loadConfig(cli) {
6105
6121
  site,
6106
6122
  userAgent: cli.userAgent,
6107
6123
  sourceTag: cli.sourceTag ?? DEFAULT_SOURCE_TAG,
6124
+ proxyUrl: rawProxyUrl || void 0,
6108
6125
  verbose: cli.verbose ?? false
6109
6126
  };
6110
6127
  }
@@ -6338,7 +6355,7 @@ function readCliVersion() {
6338
6355
  return "0.0.0";
6339
6356
  }
6340
6357
  var CLI_VERSION = readCliVersion();
6341
- var GIT_HASH = true ? "7777cc2" : "dev";
6358
+ var GIT_HASH = true ? "4427916" : "dev";
6342
6359
  var Report = class {
6343
6360
  lines = [];
6344
6361
  add(key, value) {
@@ -9380,7 +9397,7 @@ function cmdOnchainEarnOrderHistory(run, v) {
9380
9397
  // src/index.ts
9381
9398
  var _require2 = createRequire2(import.meta.url);
9382
9399
  var CLI_VERSION2 = _require2("../package.json").version;
9383
- var GIT_HASH2 = true ? "7777cc2" : "dev";
9400
+ var GIT_HASH2 = true ? "4427916" : "dev";
9384
9401
  function handleConfigCommand(action, rest, json, lang, force) {
9385
9402
  if (action === "init") return cmdConfigInit(lang === "zh" ? "zh" : "en");
9386
9403
  if (action === "show") return cmdConfigShow(json);