@okx_ai/okx-trade-cli 1.2.8-beta.3 → 1.2.8-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
@@ -1095,13 +1095,14 @@ var OkxRestClient = class {
1095
1095
  rateLimit
1096
1096
  });
1097
1097
  }
1098
- async privateGet(path42, query, rateLimit) {
1098
+ async privateGet(path42, query, rateLimit, extraHeaders) {
1099
1099
  return this.request({
1100
1100
  method: "GET",
1101
1101
  path: path42,
1102
1102
  auth: "private",
1103
1103
  query,
1104
- rateLimit
1104
+ rateLimit,
1105
+ extraHeaders
1105
1106
  });
1106
1107
  }
1107
1108
  async publicPost(path42, body, rateLimit) {
@@ -1213,16 +1214,7 @@ var OkxRestClient = class {
1213
1214
  raw: parsed
1214
1215
  };
1215
1216
  }
1216
- async request(reqConfig) {
1217
- const queryString = buildQueryString(reqConfig.query);
1218
- const requestPath = queryString.length > 0 ? `${reqConfig.path}?${queryString}` : reqConfig.path;
1219
- const url = `${this.config.baseUrl}${requestPath}`;
1220
- const bodyJson = reqConfig.body ? JSON.stringify(reqConfig.body) : "";
1221
- const timestamp = getNow();
1222
- this.logRequest(reqConfig.method, url, reqConfig.auth);
1223
- if (reqConfig.rateLimit) {
1224
- await this.rateLimiter.consume(reqConfig.rateLimit);
1225
- }
1217
+ buildHeaders(reqConfig, requestPath, bodyJson, timestamp) {
1226
1218
  const headers = new Headers({
1227
1219
  "Content-Type": "application/json",
1228
1220
  Accept: "application/json"
@@ -1236,6 +1228,24 @@ var OkxRestClient = class {
1236
1228
  if (this.config.demo) {
1237
1229
  headers.set("x-simulated-trading", "1");
1238
1230
  }
1231
+ if (reqConfig.extraHeaders) {
1232
+ for (const [key, value] of Object.entries(reqConfig.extraHeaders)) {
1233
+ headers.set(key, value);
1234
+ }
1235
+ }
1236
+ return headers;
1237
+ }
1238
+ async request(reqConfig) {
1239
+ const queryString = buildQueryString(reqConfig.query);
1240
+ const requestPath = queryString.length > 0 ? `${reqConfig.path}?${queryString}` : reqConfig.path;
1241
+ const url = `${this.config.baseUrl}${requestPath}`;
1242
+ const bodyJson = reqConfig.body ? JSON.stringify(reqConfig.body) : "";
1243
+ const timestamp = getNow();
1244
+ this.logRequest(reqConfig.method, url, reqConfig.auth);
1245
+ if (reqConfig.rateLimit) {
1246
+ await this.rateLimiter.consume(reqConfig.rateLimit);
1247
+ }
1248
+ const headers = this.buildHeaders(reqConfig, requestPath, bodyJson, timestamp);
1239
1249
  const t0 = Date.now();
1240
1250
  let response;
1241
1251
  try {
@@ -1534,6 +1544,7 @@ var MODULES = [
1534
1544
  "futures",
1535
1545
  "option",
1536
1546
  "account",
1547
+ "news",
1537
1548
  ...EARN_SUB_MODULE_IDS,
1538
1549
  ...BOT_SUB_MODULE_IDS
1539
1550
  ];
@@ -5319,6 +5330,304 @@ function registerMarketTools() {
5319
5330
  }
5320
5331
  ];
5321
5332
  }
5333
+ var NEWS_SEARCH = "/api/v5/orbit/news-search";
5334
+ var NEWS_DETAIL = "/api/v5/orbit/news-detail";
5335
+ var NEWS_DOMAINS = "/api/v5/orbit/news-platform";
5336
+ var SENTIMENT_QUERY = "/api/v5/orbit/currency-sentiment-query";
5337
+ var SENTIMENT_RANKING = "/api/v5/orbit/currency-sentiment-ranking";
5338
+ var NEWS_LANGUAGE = ["en_US", "zh_CN"];
5339
+ function langHeader(lang) {
5340
+ if (lang === "zh_CN" || lang === "en_US") return { "Accept-Language": lang };
5341
+ return void 0;
5342
+ }
5343
+ var NEWS_DETAIL_LVL = ["brief", "summary", "full"];
5344
+ var NEWS_IMPORTANCE = ["high", "medium", "low"];
5345
+ var NEWS_SENTIMENT = ["bullish", "bearish", "neutral"];
5346
+ var NEWS_SORT = ["latest", "relevant"];
5347
+ var SENTIMENT_PERIOD = ["1h", "4h", "24h"];
5348
+ var D_COINS_NEWS = 'Comma-separated uppercase ticker symbols (e.g. "BTC,ETH"). Normalize names/aliases to standard tickers.';
5349
+ var D_COINS_SENTIMENT = 'Comma-separated uppercase ticker symbols, max 20 (e.g. "BTC,ETH"). Normalize names/aliases to standard tickers.';
5350
+ var D_LANGUAGE = "Content language: zh_CN or en_US. Infer from user's message. No server default.";
5351
+ var D_BEGIN = "Start time, Unix epoch milliseconds. Parse relative time if given (e.g. 'yesterday', 'last 7 days').";
5352
+ var D_END = "End time, Unix epoch milliseconds. Parse relative time if given. Omit for no upper bound.";
5353
+ var D_IMPORTANCE = "Importance filter: high (server default), medium, low. Omit unless user wants broader coverage.";
5354
+ var D_LIMIT = "Number of results (default 10, max 50).";
5355
+ function registerNewsTools() {
5356
+ return [
5357
+ // -----------------------------------------------------------------------
5358
+ // News browsing tools
5359
+ // -----------------------------------------------------------------------
5360
+ {
5361
+ name: "news_get_latest",
5362
+ module: "news",
5363
+ description: "Get crypto news sorted by time. Omitting importance still returns only high-importance news (server default). Pass importance='medium' or 'low' explicitly to broaden results. Use when user asks 'what happened recently', 'latest news', 'any big news today', or wants to browse without a keyword.",
5364
+ isWrite: false,
5365
+ inputSchema: {
5366
+ type: "object",
5367
+ properties: {
5368
+ coins: { type: "string", description: D_COINS_NEWS + " Optional." },
5369
+ importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
5370
+ begin: { type: "number", description: D_BEGIN },
5371
+ end: { type: "number", description: D_END },
5372
+ language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE },
5373
+ detailLvl: {
5374
+ type: "string",
5375
+ enum: [...NEWS_DETAIL_LVL],
5376
+ description: "Content level: summary (AI summary, default), full (original text), brief (title only)."
5377
+ },
5378
+ limit: { type: "number", description: D_LIMIT },
5379
+ after: { type: "string", description: "Pagination cursor from previous response nextCursor." }
5380
+ },
5381
+ required: []
5382
+ },
5383
+ handler: async (rawArgs, context) => {
5384
+ const args = asRecord(rawArgs);
5385
+ const response = await context.client.privateGet(
5386
+ NEWS_SEARCH,
5387
+ compactObject({
5388
+ sortBy: "latest",
5389
+ importance: readString(args, "importance"),
5390
+ ccyList: readString(args, "coins"),
5391
+ begin: readNumber(args, "begin"),
5392
+ end: readNumber(args, "end"),
5393
+ detailLvl: readString(args, "detailLvl"),
5394
+ limit: readNumber(args, "limit") ?? 10,
5395
+ cursor: readString(args, "after")
5396
+ }),
5397
+ publicRateLimit("news_get_latest", 20),
5398
+ langHeader(readString(args, "language"))
5399
+ );
5400
+ return normalizeResponse(response);
5401
+ }
5402
+ },
5403
+ {
5404
+ name: "news_get_by_coin",
5405
+ module: "news",
5406
+ description: "Get news for specific coins or tokens. Use when user mentions a coin: 'BTC news', 'any SOL updates'. Supports multiple coins (comma-separated).",
5407
+ isWrite: false,
5408
+ inputSchema: {
5409
+ type: "object",
5410
+ properties: {
5411
+ coins: { type: "string", description: D_COINS_NEWS + " Required." },
5412
+ importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
5413
+ begin: { type: "number", description: D_BEGIN },
5414
+ end: { type: "number", description: D_END },
5415
+ language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE },
5416
+ detailLvl: { type: "string", enum: [...NEWS_DETAIL_LVL] },
5417
+ limit: { type: "number", description: D_LIMIT }
5418
+ },
5419
+ required: ["coins"]
5420
+ },
5421
+ handler: async (rawArgs, context) => {
5422
+ const args = asRecord(rawArgs);
5423
+ const coins = readString(args, "coins");
5424
+ if (!coins) {
5425
+ throw new Error(`Missing required parameter "coins".`);
5426
+ }
5427
+ const response = await context.client.privateGet(
5428
+ NEWS_SEARCH,
5429
+ compactObject({
5430
+ sortBy: "latest",
5431
+ ccyList: coins,
5432
+ importance: readString(args, "importance"),
5433
+ begin: readNumber(args, "begin"),
5434
+ end: readNumber(args, "end"),
5435
+ detailLvl: readString(args, "detailLvl"),
5436
+ limit: readNumber(args, "limit") ?? 10
5437
+ }),
5438
+ publicRateLimit("news_get_by_coin", 20),
5439
+ langHeader(readString(args, "language"))
5440
+ );
5441
+ return normalizeResponse(response);
5442
+ }
5443
+ },
5444
+ {
5445
+ name: "news_search",
5446
+ module: "news",
5447
+ description: "Search crypto news by keyword with optional filters. Use when user provides specific search terms: 'SEC ETF news', 'stablecoin regulation', 'Bitcoin halving'. For coin-only queries prefer news_get_by_coin.",
5448
+ isWrite: false,
5449
+ inputSchema: {
5450
+ type: "object",
5451
+ properties: {
5452
+ keyword: {
5453
+ type: "string",
5454
+ description: "Search keyword(s) extracted from user query (topic/entity). Multiple words are AND-combined. Omit to browse by filters only."
5455
+ },
5456
+ coins: { type: "string", description: D_COINS_NEWS + " Optional." },
5457
+ importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
5458
+ sentiment: {
5459
+ type: "string",
5460
+ enum: [...NEWS_SENTIMENT],
5461
+ description: "Filter by sentiment if mentioned alongside the keyword."
5462
+ },
5463
+ sortBy: {
5464
+ type: "string",
5465
+ enum: [...NEWS_SORT],
5466
+ description: "Sort order: relevant (by relevance, default for keyword search), latest (by time)."
5467
+ },
5468
+ begin: { type: "number", description: D_BEGIN },
5469
+ end: { type: "number", description: D_END },
5470
+ language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE },
5471
+ detailLvl: { type: "string", enum: [...NEWS_DETAIL_LVL] },
5472
+ limit: { type: "number", description: D_LIMIT },
5473
+ after: { type: "string", description: "Pagination cursor from previous response nextCursor." }
5474
+ },
5475
+ required: []
5476
+ },
5477
+ handler: async (rawArgs, context) => {
5478
+ const args = asRecord(rawArgs);
5479
+ const response = await context.client.privateGet(
5480
+ NEWS_SEARCH,
5481
+ compactObject({
5482
+ keyword: readString(args, "keyword") || void 0,
5483
+ sortBy: readString(args, "sortBy") ?? "relevant",
5484
+ importance: readString(args, "importance"),
5485
+ ccyList: readString(args, "coins"),
5486
+ sentiment: readString(args, "sentiment"),
5487
+ begin: readNumber(args, "begin"),
5488
+ end: readNumber(args, "end"),
5489
+ detailLvl: readString(args, "detailLvl"),
5490
+ limit: readNumber(args, "limit") ?? 10,
5491
+ cursor: readString(args, "after")
5492
+ }),
5493
+ publicRateLimit("news_search", 20),
5494
+ langHeader(readString(args, "language"))
5495
+ );
5496
+ return normalizeResponse(response);
5497
+ }
5498
+ },
5499
+ {
5500
+ name: "news_get_detail",
5501
+ module: "news",
5502
+ description: "Get full article content by news ID (returns title + summary + full original text). Use when user says 'show full article', 'read more', or provides a specific news ID from a previous result.",
5503
+ isWrite: false,
5504
+ inputSchema: {
5505
+ type: "object",
5506
+ properties: {
5507
+ id: {
5508
+ type: "string",
5509
+ description: "News article ID from a previous news_get_latest / news_get_by_coin / news_search result. Required."
5510
+ },
5511
+ language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE }
5512
+ },
5513
+ required: ["id"]
5514
+ },
5515
+ handler: async (rawArgs, context) => {
5516
+ const args = asRecord(rawArgs);
5517
+ const id = readString(args, "id");
5518
+ if (!id) {
5519
+ throw new Error(`Missing required parameter "id".`);
5520
+ }
5521
+ const response = await context.client.privateGet(
5522
+ NEWS_DETAIL,
5523
+ { id },
5524
+ publicRateLimit("news_get_detail", 20),
5525
+ langHeader(readString(args, "language"))
5526
+ );
5527
+ return normalizeResponse(response);
5528
+ }
5529
+ },
5530
+ {
5531
+ name: "news_get_domains",
5532
+ module: "news",
5533
+ description: "List available news source domains (e.g. coindesk, cointelegraph). Use when user asks what news sources are available or which platforms are covered.",
5534
+ isWrite: false,
5535
+ inputSchema: {
5536
+ type: "object",
5537
+ properties: {},
5538
+ required: []
5539
+ },
5540
+ handler: async (_rawArgs, context) => {
5541
+ const response = await context.client.privateGet(
5542
+ NEWS_DOMAINS,
5543
+ {},
5544
+ publicRateLimit("news_get_domains", 20)
5545
+ );
5546
+ return normalizeResponse(response);
5547
+ }
5548
+ },
5549
+ // -----------------------------------------------------------------------
5550
+ // Token sentiment tools
5551
+ // -----------------------------------------------------------------------
5552
+ {
5553
+ name: "news_get_coin_sentiment",
5554
+ module: "news",
5555
+ description: "Get sentiment snapshot or time-series trend for coins. Returns bullish/bearish ratios and mention counts. Pass trendPoints for trend data (1h\u219224 points, 4h\u21926, 24h\u21927). Use when user asks about coin sentiment, sentiment trend, or how bullish/bearish a coin is.",
5556
+ isWrite: false,
5557
+ inputSchema: {
5558
+ type: "object",
5559
+ properties: {
5560
+ coins: { type: "string", description: D_COINS_SENTIMENT + " Required." },
5561
+ period: {
5562
+ type: "string",
5563
+ enum: [...SENTIMENT_PERIOD],
5564
+ description: "Aggregation granularity: 1h, 4h, 24h. Snapshot default: 24h. Trend default: 1h."
5565
+ },
5566
+ trendPoints: {
5567
+ type: "number",
5568
+ description: "Trend data points. Pass for time-series trend; omit for snapshot. Guide: 1h\u219224, 4h\u21926, 24h\u21927."
5569
+ }
5570
+ },
5571
+ required: ["coins"]
5572
+ },
5573
+ handler: async (rawArgs, context) => {
5574
+ const args = asRecord(rawArgs);
5575
+ const coins = readString(args, "coins");
5576
+ if (!coins) {
5577
+ throw new Error(`Missing required parameter "coins".`);
5578
+ }
5579
+ const trendPoints = readNumber(args, "trendPoints");
5580
+ const inclTrend = trendPoints !== void 0;
5581
+ const response = await context.client.privateGet(
5582
+ SENTIMENT_QUERY,
5583
+ compactObject({
5584
+ ccy: coins,
5585
+ period: readString(args, "period") ?? (inclTrend ? "1h" : "24h"),
5586
+ ...inclTrend ? { inclTrend: true, limit: trendPoints } : {}
5587
+ }),
5588
+ publicRateLimit("news_get_coin_sentiment", 20)
5589
+ );
5590
+ return normalizeResponse(response);
5591
+ }
5592
+ },
5593
+ {
5594
+ name: "news_get_sentiment_ranking",
5595
+ module: "news",
5596
+ description: "Get coin ranking by social hotness or sentiment direction. Use when user asks which coins are trending, most bullish/bearish coins. Sort by hot (mention count), bullish, or bearish.",
5597
+ isWrite: false,
5598
+ inputSchema: {
5599
+ type: "object",
5600
+ properties: {
5601
+ period: {
5602
+ type: "string",
5603
+ enum: [...SENTIMENT_PERIOD],
5604
+ description: "Aggregation granularity: 1h, 4h, 24h (default)."
5605
+ },
5606
+ sortBy: {
5607
+ type: "string",
5608
+ enum: ["hot", "bullish", "bearish"],
5609
+ description: "Sort: hot=by mentions (default), bullish=most bullish, bearish=most bearish."
5610
+ },
5611
+ limit: { type: "number", description: D_LIMIT }
5612
+ },
5613
+ required: []
5614
+ },
5615
+ handler: async (rawArgs, context) => {
5616
+ const args = asRecord(rawArgs);
5617
+ const response = await context.client.privateGet(
5618
+ SENTIMENT_RANKING,
5619
+ compactObject({
5620
+ period: readString(args, "period") ?? "24h",
5621
+ sortBy: readString(args, "sortBy") ?? "hot",
5622
+ limit: readNumber(args, "limit") ?? 10
5623
+ }),
5624
+ publicRateLimit("news_get_sentiment_ranking", 20)
5625
+ );
5626
+ return normalizeResponse(response);
5627
+ }
5628
+ }
5629
+ ];
5630
+ }
5322
5631
  function registerOptionAlgoTools() {
5323
5632
  return [
5324
5633
  {
@@ -6792,6 +7101,7 @@ function allToolSpecs() {
6792
7101
  ...registerOptionAlgoTools(),
6793
7102
  ...registerAlgoTradeTools(),
6794
7103
  ...registerAccountTools(),
7104
+ ...registerNewsTools(),
6795
7105
  ...registerBotTools(),
6796
7106
  ...registerAllEarnTools(),
6797
7107
  ...registerAuditTools()
@@ -6915,10 +7225,21 @@ function resolveBaseUrl(site, tomlBaseUrl) {
6915
7225
  }
6916
7226
  return rawBaseUrl.replace(/\/+$/, "");
6917
7227
  }
7228
+ function resolveDemo(cli, toml) {
7229
+ if (cli.demo && cli.live) {
7230
+ throw new ConfigError(
7231
+ "--demo and --live are mutually exclusive.",
7232
+ "Use --demo for simulated trading or --live to force live mode, not both."
7233
+ );
7234
+ }
7235
+ if (cli.live === true) return false;
7236
+ if (cli.demo === true) return true;
7237
+ return process.env.OKX_DEMO === "1" || process.env.OKX_DEMO === "true" || (toml.demo ?? false);
7238
+ }
6918
7239
  function loadConfig(cli) {
6919
7240
  const toml = readTomlProfile(cli.profile);
6920
7241
  const creds = loadCredentials(toml);
6921
- const demo = cli.demo || process.env.OKX_DEMO === "1" || process.env.OKX_DEMO === "true" || (toml.demo ?? false);
7242
+ const demo = resolveDemo(cli, toml);
6922
7243
  const site = resolveSite(cli.site, toml.site);
6923
7244
  const baseUrl = resolveBaseUrl(site, toml.base_url);
6924
7245
  const rawTimeout = process.env.OKX_TIMEOUT_MS ? Number(process.env.OKX_TIMEOUT_MS) : toml.timeout_ms ?? 15e3;
@@ -7792,7 +8113,7 @@ async function cmdDiagnoseMcp(options = {}) {
7792
8113
 
7793
8114
  // src/commands/diagnose.ts
7794
8115
  var CLI_VERSION = readCliVersion();
7795
- var GIT_HASH = true ? "43f321d" : "dev";
8116
+ var GIT_HASH = true ? "7b97fe6" : "dev";
7796
8117
  function maskKey2(key) {
7797
8118
  if (!key) return "(not set)";
7798
8119
  if (key.length <= 8) return "****";
@@ -8190,13 +8511,226 @@ async function cmdUpgrade(currentVersion, options, json) {
8190
8511
  }
8191
8512
  }
8192
8513
 
8514
+ // src/commands/news.ts
8515
+ function getData(result) {
8516
+ return result.data;
8517
+ }
8518
+ function formatTime(ts) {
8519
+ if (!ts) return "-";
8520
+ return new Date(Number(ts)).toLocaleString();
8521
+ }
8522
+ async function cmdNewsLatest(run, opts) {
8523
+ const result = await run("news_get_latest", {
8524
+ coins: opts.coins,
8525
+ importance: opts.importance,
8526
+ begin: opts.begin,
8527
+ end: opts.end,
8528
+ language: opts.language,
8529
+ detailLvl: opts.detailLvl,
8530
+ limit: opts.limit,
8531
+ after: opts.after
8532
+ });
8533
+ const raw = getData(result);
8534
+ const pageData = raw?.[0];
8535
+ if (opts.json) return printJson(pageData ?? null);
8536
+ const items = pageData?.["details"] ?? [];
8537
+ printTable(
8538
+ items.map((n) => ({
8539
+ id: n["id"],
8540
+ time: formatTime(n["cTime"] ?? n["createTime"]),
8541
+ platforms: n["platformList"]?.join(",") ?? "-",
8542
+ title: String(n["title"] ?? "").slice(0, 80)
8543
+ }))
8544
+ );
8545
+ const cursor = pageData?.["nextCursor"];
8546
+ if (cursor) outputLine(`[next] --after ${cursor}`);
8547
+ }
8548
+ async function cmdNewsImportant(run, opts) {
8549
+ const result = await run("news_get_latest", {
8550
+ coins: opts.coins,
8551
+ importance: "high",
8552
+ begin: opts.begin,
8553
+ end: opts.end,
8554
+ language: opts.language,
8555
+ detailLvl: opts.detailLvl,
8556
+ limit: opts.limit
8557
+ });
8558
+ const raw = getData(result);
8559
+ const pageData = raw?.[0];
8560
+ if (opts.json) return printJson(pageData ?? null);
8561
+ const items = pageData?.["details"] ?? [];
8562
+ printTable(
8563
+ items.map((n) => ({
8564
+ id: n["id"],
8565
+ time: formatTime(n["cTime"] ?? n["createTime"]),
8566
+ importance: n["importance"] ?? "-",
8567
+ platforms: n["platformList"]?.join(",") ?? "-",
8568
+ title: String(n["title"] ?? "").slice(0, 80)
8569
+ }))
8570
+ );
8571
+ }
8572
+ async function cmdNewsByCoin(run, coins, opts) {
8573
+ const result = await run("news_get_by_coin", {
8574
+ coins,
8575
+ importance: opts.importance,
8576
+ begin: opts.begin,
8577
+ end: opts.end,
8578
+ language: opts.language,
8579
+ detailLvl: opts.detailLvl,
8580
+ limit: opts.limit
8581
+ });
8582
+ const raw = getData(result);
8583
+ const pageData = raw?.[0];
8584
+ if (opts.json) return printJson(pageData ?? null);
8585
+ const items = pageData?.["details"] ?? [];
8586
+ printTable(
8587
+ items.map((n) => ({
8588
+ id: n["id"],
8589
+ time: formatTime(n["cTime"] ?? n["createTime"]),
8590
+ coins: n["ccyList"]?.join(",") ?? "-",
8591
+ platforms: n["platformList"]?.join(",") ?? "-",
8592
+ title: String(n["title"] ?? "").slice(0, 80)
8593
+ }))
8594
+ );
8595
+ }
8596
+ async function cmdNewsSearch(run, keyword, opts) {
8597
+ const result = await run("news_search", {
8598
+ keyword: keyword || void 0,
8599
+ coins: opts.coins,
8600
+ importance: opts.importance,
8601
+ sentiment: opts.sentiment,
8602
+ sortBy: opts.sortBy,
8603
+ begin: opts.begin,
8604
+ end: opts.end,
8605
+ language: opts.language,
8606
+ detailLvl: opts.detailLvl,
8607
+ limit: opts.limit,
8608
+ after: opts.after
8609
+ });
8610
+ const raw = getData(result);
8611
+ const pageData = raw?.[0];
8612
+ if (opts.json) return printJson(pageData ?? null);
8613
+ const items = pageData?.["details"] ?? [];
8614
+ printTable(
8615
+ items.map((n) => ({
8616
+ id: n["id"],
8617
+ time: formatTime(n["cTime"] ?? n["createTime"]),
8618
+ platforms: n["platformList"]?.join(",") ?? "-",
8619
+ title: String(n["title"] ?? "").slice(0, 80)
8620
+ }))
8621
+ );
8622
+ const cursor = pageData?.["nextCursor"];
8623
+ if (cursor) outputLine(`[next] --after ${cursor}`);
8624
+ }
8625
+ async function cmdNewsDetail(run, id, opts) {
8626
+ const result = await run("news_get_detail", { id, language: opts.language });
8627
+ const items = getData(result);
8628
+ if (opts.json) return printJson(items);
8629
+ const article = items?.[0];
8630
+ if (!article) {
8631
+ outputLine("Article not found.");
8632
+ return;
8633
+ }
8634
+ const rawContent = article["content"] ? String(article["content"]) : void 0;
8635
+ const content = rawContent ? rawContent.length > 500 ? rawContent.slice(0, 500) + "... (use --json for full text)" : rawContent : void 0;
8636
+ printKv({
8637
+ id: article["id"],
8638
+ title: article["title"],
8639
+ platforms: article["platformList"]?.join(", ") ?? "-",
8640
+ time: formatTime(article["cTime"] ?? article["createTime"]),
8641
+ sourceUrl: article["sourceUrl"],
8642
+ coins: article["ccyList"]?.join(", ") ?? "-",
8643
+ importance: article["importance"] ?? "-",
8644
+ summary: article["summary"] ?? "(see content)",
8645
+ content
8646
+ });
8647
+ }
8648
+ async function cmdNewsDomains(run, opts) {
8649
+ const result = await run("news_get_domains", {});
8650
+ const raw = getData(result);
8651
+ const items = raw?.[0]?.["platform"] ?? [];
8652
+ if (opts.json) return printJson(items);
8653
+ outputLine("Available news source domains:");
8654
+ (items ?? []).forEach((d) => outputLine(` ${d}`));
8655
+ }
8656
+ async function cmdNewsCoinSentiment(run, coins, opts) {
8657
+ const result = await run("news_get_coin_sentiment", {
8658
+ coins,
8659
+ period: opts.period
8660
+ });
8661
+ const raw = getData(result);
8662
+ if (opts.json) return printJson(raw);
8663
+ const items = raw?.[0]?.["details"] ?? [];
8664
+ printTable(
8665
+ items.map((c) => {
8666
+ const snt = c["sentiment"];
8667
+ return {
8668
+ symbol: c["ccy"],
8669
+ label: snt?.["label"] ?? "-",
8670
+ bullish: snt?.["bullishRatio"] ?? "-",
8671
+ bearish: snt?.["bearishRatio"] ?? "-",
8672
+ mentions: c["mentionCnt"]
8673
+ };
8674
+ })
8675
+ );
8676
+ }
8677
+ async function cmdNewsCoinTrend(run, coin, opts) {
8678
+ const result = await run("news_get_coin_sentiment", {
8679
+ coins: coin,
8680
+ period: opts.period,
8681
+ trendPoints: opts.points
8682
+ });
8683
+ const raw = getData(result);
8684
+ if (opts.json) return printJson(raw);
8685
+ const items = raw?.[0]?.["details"] ?? [];
8686
+ const coinData = items?.[0];
8687
+ if (!coinData) {
8688
+ outputLine("No trend data.");
8689
+ return;
8690
+ }
8691
+ const trend = coinData["trend"] ?? [];
8692
+ outputLine(`Sentiment trend for ${coin} (period: ${opts.period ?? "1h"}):`);
8693
+ printTable(
8694
+ trend.map((t) => ({
8695
+ time: formatTime(t["ts"]),
8696
+ bullish: t["bullishRatio"],
8697
+ bearish: t["bearishRatio"],
8698
+ mentions: t["mentionCnt"]
8699
+ }))
8700
+ );
8701
+ }
8702
+ async function cmdNewsSentimentRank(run, opts) {
8703
+ const result = await run("news_get_sentiment_ranking", {
8704
+ period: opts.period,
8705
+ sortBy: opts.sortBy,
8706
+ limit: opts.limit
8707
+ });
8708
+ const raw = getData(result);
8709
+ if (opts.json) return printJson(raw);
8710
+ const items = raw?.[0]?.["details"] ?? [];
8711
+ printTable(
8712
+ items.map((c, i) => {
8713
+ const snt = c["sentiment"];
8714
+ return {
8715
+ rank: i + 1,
8716
+ symbol: c["ccy"],
8717
+ label: snt?.["label"] ?? "-",
8718
+ bullish: snt?.["bullishRatio"] ?? "-",
8719
+ bearish: snt?.["bearishRatio"] ?? "-",
8720
+ mentions: c["mentionCnt"]
8721
+ };
8722
+ })
8723
+ );
8724
+ }
8725
+
8193
8726
  // src/config/loader.ts
8194
8727
  function loadProfileConfig(opts) {
8195
8728
  return loadConfig({
8196
8729
  profile: opts.profile,
8197
8730
  modules: opts.modules,
8198
8731
  readOnly: opts.readOnly ?? false,
8199
- demo: opts.demo ?? false,
8732
+ demo: opts.demo,
8733
+ live: opts.live,
8200
8734
  site: opts.site,
8201
8735
  userAgent: opts.userAgent,
8202
8736
  sourceTag: opts.sourceTag,
@@ -8791,21 +9325,67 @@ var HELP_TREE = {
8791
9325
  },
8792
9326
  diagnose: {
8793
9327
  description: "Run network / MCP server diagnostics",
8794
- usage: "okx diagnose [--cli | --mcp | --all] [--profile <name>] [--demo] [--output <file>]"
9328
+ usage: "okx diagnose [--cli | --mcp | --all] [--profile <name>] [--demo | --live] [--output <file>]"
8795
9329
  },
8796
9330
  upgrade: {
8797
9331
  description: "Upgrade okx CLI and MCP server to the latest stable version",
8798
9332
  usage: "okx upgrade [--check] [--beta] [--force] [--json]"
9333
+ },
9334
+ news: {
9335
+ description: "Orbit News \u2014 crypto news feed, coin sentiment, and trend analysis",
9336
+ commands: {
9337
+ latest: {
9338
+ usage: "okx news latest [--limit <n>] [--lang <zh_CN|en_US>]",
9339
+ description: "Get latest crypto news"
9340
+ },
9341
+ important: {
9342
+ usage: "okx news important [--limit <n>] [--lang <zh_CN|en_US>]",
9343
+ description: "Get important / high-impact crypto news"
9344
+ },
9345
+ "by-coin": {
9346
+ usage: "okx news by-coin --coins <BTC,ETH,...> [--limit <n>] [--lang <zh_CN|en_US>]",
9347
+ description: "Get news filtered by coin(s)"
9348
+ },
9349
+ "by-sentiment": {
9350
+ usage: "okx news by-sentiment --sentiment <bullish|bearish|neutral> [--limit <n>] [--lang <zh_CN|en_US>]",
9351
+ description: "Get news filtered by sentiment"
9352
+ },
9353
+ search: {
9354
+ usage: "okx news search --keyword <text> [--limit <n>] [--lang <zh_CN|en_US>]",
9355
+ description: "Search news by keyword"
9356
+ },
9357
+ detail: {
9358
+ usage: "okx news detail <articleId> [--lang <zh_CN|en_US>]",
9359
+ description: "Get full article detail by ID"
9360
+ },
9361
+ domains: {
9362
+ usage: "okx news domains",
9363
+ description: "List available news source domains"
9364
+ },
9365
+ "coin-sentiment": {
9366
+ usage: "okx news coin-sentiment --coins <BTC,ETH,...> [--period <1h|24h>]",
9367
+ description: "Get sentiment score for specific coin(s)"
9368
+ },
9369
+ "coin-trend": {
9370
+ usage: "okx news coin-trend <coin> [--period <1h|24h>] [--points <n>]",
9371
+ description: "Get sentiment trend data points for a coin"
9372
+ },
9373
+ "sentiment-rank": {
9374
+ usage: "okx news sentiment-rank [--period <1h|24h>] [--sort-by <hot|bullish|bearish>] [--limit <n>]",
9375
+ description: "Get coin ranking by social hotness or sentiment direction"
9376
+ }
9377
+ }
8799
9378
  }
8800
9379
  };
8801
9380
  function printGlobalHelp() {
8802
9381
  const lines = [
8803
9382
  "",
8804
- `Usage: okx [--profile <name>] [--demo] [--json] <module> <action> [args...]`,
9383
+ `Usage: okx [--profile <name>] [--demo | --live] [--json] <module> <action> [args...]`,
8805
9384
  "",
8806
9385
  "Global Options:",
8807
9386
  ` --profile <name> Use a named profile from ${configFilePath()}`,
8808
9387
  " --demo Use simulated trading (demo) mode",
9388
+ " --live Force live trading mode (overrides profile demo=true; mutually exclusive with --demo)",
8809
9389
  " --json Output raw JSON",
8810
9390
  " --verbose Show detailed network request/response info (stderr)",
8811
9391
  " --version, -v Show version",
@@ -9077,6 +9657,15 @@ var CLI_OPTIONS = {
9077
9657
  params: { type: "string" },
9078
9658
  list: { type: "boolean", default: false },
9079
9659
  "backtest-time": { type: "string" },
9660
+ // news
9661
+ coins: { type: "string" },
9662
+ sentiment: { type: "string" },
9663
+ importance: { type: "string" },
9664
+ keyword: { type: "string" },
9665
+ "detail-lvl": { type: "string" },
9666
+ period: { type: "string" },
9667
+ points: { type: "string" },
9668
+ "sort-by": { type: "string" },
9080
9669
  // diagnostics — cli/mcp/all/output are diagnose-specific; verbose is shared
9081
9670
  verbose: { type: "boolean", default: false },
9082
9671
  mcp: { type: "boolean", default: false },
@@ -9112,12 +9701,12 @@ function parseCli(argv) {
9112
9701
  }
9113
9702
 
9114
9703
  // src/commands/market.ts
9115
- function getData(result) {
9704
+ function getData2(result) {
9116
9705
  return result.data;
9117
9706
  }
9118
9707
  async function cmdMarketInstruments(run, opts) {
9119
9708
  const result = await run("market_get_instruments", { instType: opts.instType, instId: opts.instId });
9120
- const items = getData(result);
9709
+ const items = getData2(result);
9121
9710
  if (opts.json) return printJson(items);
9122
9711
  printTable(
9123
9712
  (items ?? []).slice(0, 50).map((t) => ({
@@ -9132,7 +9721,7 @@ async function cmdMarketInstruments(run, opts) {
9132
9721
  }
9133
9722
  async function cmdMarketFundingRate(run, instId, opts) {
9134
9723
  const result = await run("market_get_funding_rate", { instId, history: opts.history, limit: opts.limit });
9135
- const items = getData(result);
9724
+ const items = getData2(result);
9136
9725
  if (opts.json) return printJson(items);
9137
9726
  if (opts.history) {
9138
9727
  printTable(
@@ -9160,7 +9749,7 @@ async function cmdMarketFundingRate(run, instId, opts) {
9160
9749
  }
9161
9750
  async function cmdMarketMarkPrice(run, opts) {
9162
9751
  const result = await run("market_get_mark_price", { instType: opts.instType, instId: opts.instId });
9163
- const items = getData(result);
9752
+ const items = getData2(result);
9164
9753
  if (opts.json) return printJson(items);
9165
9754
  printTable(
9166
9755
  (items ?? []).map((r) => ({
@@ -9173,7 +9762,7 @@ async function cmdMarketMarkPrice(run, opts) {
9173
9762
  }
9174
9763
  async function cmdMarketTrades(run, instId, opts) {
9175
9764
  const result = await run("market_get_trades", { instId, limit: opts.limit });
9176
- const items = getData(result);
9765
+ const items = getData2(result);
9177
9766
  if (opts.json) return printJson(items);
9178
9767
  printTable(
9179
9768
  (items ?? []).map((t) => ({
@@ -9187,7 +9776,7 @@ async function cmdMarketTrades(run, instId, opts) {
9187
9776
  }
9188
9777
  async function cmdMarketIndexTicker(run, opts) {
9189
9778
  const result = await run("market_get_index_ticker", { instId: opts.instId, quoteCcy: opts.quoteCcy });
9190
- const items = getData(result);
9779
+ const items = getData2(result);
9191
9780
  if (opts.json) return printJson(items);
9192
9781
  printTable(
9193
9782
  (items ?? []).map((t) => ({
@@ -9201,7 +9790,7 @@ async function cmdMarketIndexTicker(run, opts) {
9201
9790
  }
9202
9791
  async function cmdMarketIndexCandles(run, instId, opts) {
9203
9792
  const result = await run("market_get_index_candles", { instId, bar: opts.bar, limit: opts.limit, history: opts.history });
9204
- const candles = getData(result);
9793
+ const candles = getData2(result);
9205
9794
  if (opts.json) return printJson(candles);
9206
9795
  printTable(
9207
9796
  (candles ?? []).map(([ts, o, h, l, c]) => ({
@@ -9215,7 +9804,7 @@ async function cmdMarketIndexCandles(run, instId, opts) {
9215
9804
  }
9216
9805
  async function cmdMarketPriceLimit(run, instId, json) {
9217
9806
  const result = await run("market_get_price_limit", { instId });
9218
- const items = getData(result);
9807
+ const items = getData2(result);
9219
9808
  if (json) return printJson(items);
9220
9809
  const r = items?.[0];
9221
9810
  if (!r) {
@@ -9231,7 +9820,7 @@ async function cmdMarketPriceLimit(run, instId, json) {
9231
9820
  }
9232
9821
  async function cmdMarketOpenInterest(run, opts) {
9233
9822
  const result = await run("market_get_open_interest", { instType: opts.instType, instId: opts.instId });
9234
- const items = getData(result);
9823
+ const items = getData2(result);
9235
9824
  if (opts.json) return printJson(items);
9236
9825
  printTable(
9237
9826
  (items ?? []).map((r) => ({
@@ -9244,7 +9833,7 @@ async function cmdMarketOpenInterest(run, opts) {
9244
9833
  }
9245
9834
  async function cmdMarketTicker(run, instId, json) {
9246
9835
  const result = await run("market_get_ticker", { instId });
9247
- const items = getData(result);
9836
+ const items = getData2(result);
9248
9837
  if (json) return printJson(items);
9249
9838
  if (!items?.length) {
9250
9839
  outputLine("No data");
@@ -9268,7 +9857,7 @@ async function cmdMarketTicker(run, instId, json) {
9268
9857
  }
9269
9858
  async function cmdMarketTickers(run, instType, json) {
9270
9859
  const result = await run("market_get_tickers", { instType });
9271
- const items = getData(result);
9860
+ const items = getData2(result);
9272
9861
  if (json) return printJson(items);
9273
9862
  printTable(
9274
9863
  (items ?? []).map((t) => ({
@@ -9282,7 +9871,7 @@ async function cmdMarketTickers(run, instType, json) {
9282
9871
  }
9283
9872
  async function cmdMarketOrderbook(run, instId, sz, json) {
9284
9873
  const result = await run("market_get_orderbook", { instId, sz });
9285
- const data = getData(result);
9874
+ const data = getData2(result);
9286
9875
  if (json) return printJson(data);
9287
9876
  const book = data[0];
9288
9877
  if (!book) {
@@ -9299,7 +9888,7 @@ async function cmdMarketOrderbook(run, instId, sz, json) {
9299
9888
  }
9300
9889
  async function cmdMarketCandles(run, instId, opts) {
9301
9890
  const result = await run("market_get_candles", { instId, bar: opts.bar, limit: opts.limit, after: opts.after, before: opts.before });
9302
- const candles = getData(result);
9891
+ const candles = getData2(result);
9303
9892
  if (opts.json) return printJson(candles);
9304
9893
  printTable(
9305
9894
  (candles ?? []).map(([ts, o, h, l, c, vol]) => ({
@@ -9323,7 +9912,7 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
9323
9912
  limit: opts.limit,
9324
9913
  backtestTime: opts.backtestTime
9325
9914
  });
9326
- const outerArray = getData(result);
9915
+ const outerArray = getData2(result);
9327
9916
  if (opts.json) return printJson(outerArray);
9328
9917
  if (!outerArray?.length) {
9329
9918
  process.stdout.write("No data\n");
@@ -9362,7 +9951,7 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
9362
9951
  }
9363
9952
  async function cmdMarketStockTokens(run, opts) {
9364
9953
  const result = await run("market_get_stock_tokens", { instType: opts.instType, instId: opts.instId });
9365
- const items = getData(result);
9954
+ const items = getData2(result);
9366
9955
  if (opts.json) return printJson(items);
9367
9956
  printTable(
9368
9957
  (items ?? []).slice(0, 50).map((t) => ({
@@ -9381,12 +9970,12 @@ async function cmdMarketStockTokens(run, opts) {
9381
9970
  import * as fs6 from "fs";
9382
9971
  import * as path4 from "path";
9383
9972
  import * as os5 from "os";
9384
- function getData2(result) {
9973
+ function getData3(result) {
9385
9974
  return result.data;
9386
9975
  }
9387
9976
  async function cmdAccountBalance(run, ccy, json) {
9388
9977
  const result = await run("account_get_balance", { ccy });
9389
- const data = getData2(result);
9978
+ const data = getData3(result);
9390
9979
  if (json) return printJson(data);
9391
9980
  const details = data?.[0]?.["details"] ?? [];
9392
9981
  const rows = details.filter((d) => Number(d["eq"]) > 0).map((d) => ({
@@ -9439,7 +10028,7 @@ async function cmdAccountAssetBalance(run, ccy, json, showValuation) {
9439
10028
  }
9440
10029
  async function cmdAccountPositions(run, opts) {
9441
10030
  const result = await run("account_get_positions", { instType: opts.instType, instId: opts.instId });
9442
- const positions = getData2(result);
10031
+ const positions = getData3(result);
9443
10032
  if (opts.json) return printJson(positions);
9444
10033
  const open = (positions ?? []).filter((p) => Number(p["pos"]) !== 0);
9445
10034
  if (!open.length) {
@@ -9461,7 +10050,7 @@ async function cmdAccountPositions(run, opts) {
9461
10050
  async function cmdAccountBills(run, opts) {
9462
10051
  const toolName = opts.archive ? "account_get_bills_archive" : "account_get_bills";
9463
10052
  const result = await run(toolName, { instType: opts.instType, ccy: opts.ccy, limit: opts.limit });
9464
- const bills = getData2(result);
10053
+ const bills = getData3(result);
9465
10054
  if (opts.json) return printJson(bills);
9466
10055
  printTable(
9467
10056
  (bills ?? []).map((b) => ({
@@ -9477,7 +10066,7 @@ async function cmdAccountBills(run, opts) {
9477
10066
  }
9478
10067
  async function cmdAccountFees(run, opts) {
9479
10068
  const result = await run("account_get_trade_fee", { instType: opts.instType, instId: opts.instId });
9480
- const data = getData2(result);
10069
+ const data = getData3(result);
9481
10070
  if (opts.json) return printJson(data);
9482
10071
  const fee = data?.[0];
9483
10072
  if (!fee) {
@@ -9495,7 +10084,7 @@ async function cmdAccountFees(run, opts) {
9495
10084
  }
9496
10085
  async function cmdAccountConfig(run, json) {
9497
10086
  const result = await run("account_get_config", {});
9498
- const data = getData2(result);
10087
+ const data = getData3(result);
9499
10088
  if (json) return printJson(data);
9500
10089
  const cfg = data?.[0];
9501
10090
  if (!cfg) {
@@ -9514,14 +10103,14 @@ async function cmdAccountConfig(run, json) {
9514
10103
  }
9515
10104
  async function cmdAccountSetPositionMode(run, posMode, json) {
9516
10105
  const result = await run("account_set_position_mode", { posMode });
9517
- const data = getData2(result);
10106
+ const data = getData3(result);
9518
10107
  if (json) return printJson(data);
9519
10108
  const r = data?.[0];
9520
10109
  outputLine(`Position mode set: ${r?.["posMode"]}`);
9521
10110
  }
9522
10111
  async function cmdAccountMaxSize(run, opts) {
9523
10112
  const result = await run("account_get_max_size", { instId: opts.instId, tdMode: opts.tdMode, px: opts.px });
9524
- const data = getData2(result);
10113
+ const data = getData3(result);
9525
10114
  if (opts.json) return printJson(data);
9526
10115
  const r = data?.[0];
9527
10116
  if (!r) {
@@ -9532,7 +10121,7 @@ async function cmdAccountMaxSize(run, opts) {
9532
10121
  }
9533
10122
  async function cmdAccountMaxAvailSize(run, opts) {
9534
10123
  const result = await run("account_get_max_avail_size", { instId: opts.instId, tdMode: opts.tdMode });
9535
- const data = getData2(result);
10124
+ const data = getData3(result);
9536
10125
  if (opts.json) return printJson(data);
9537
10126
  const r = data?.[0];
9538
10127
  if (!r) {
@@ -9543,7 +10132,7 @@ async function cmdAccountMaxAvailSize(run, opts) {
9543
10132
  }
9544
10133
  async function cmdAccountMaxWithdrawal(run, ccy, json) {
9545
10134
  const result = await run("account_get_max_withdrawal", { ccy });
9546
- const data = getData2(result);
10135
+ const data = getData3(result);
9547
10136
  if (json) return printJson(data);
9548
10137
  printTable(
9549
10138
  (data ?? []).map((r) => ({
@@ -9555,7 +10144,7 @@ async function cmdAccountMaxWithdrawal(run, ccy, json) {
9555
10144
  }
9556
10145
  async function cmdAccountPositionsHistory(run, opts) {
9557
10146
  const result = await run("account_get_positions_history", { instType: opts.instType, instId: opts.instId, limit: opts.limit });
9558
- const data = getData2(result);
10147
+ const data = getData3(result);
9559
10148
  if (opts.json) return printJson(data);
9560
10149
  printTable(
9561
10150
  (data ?? []).map((p) => ({
@@ -9577,7 +10166,7 @@ async function cmdAccountTransfer(run, opts) {
9577
10166
  type: opts.transferType,
9578
10167
  subAcct: opts.subAcct
9579
10168
  });
9580
- const data = getData2(result);
10169
+ const data = getData3(result);
9581
10170
  if (opts.json) return printJson(data);
9582
10171
  const r = data?.[0];
9583
10172
  outputLine(`Transfer: ${r?.["transId"]} (${r?.["ccy"]} ${r?.["amt"]})`);
@@ -9637,7 +10226,7 @@ function cmdAccountAudit(opts) {
9637
10226
  }
9638
10227
 
9639
10228
  // src/commands/spot.ts
9640
- function getData3(result) {
10229
+ function getData4(result) {
9641
10230
  return result.data;
9642
10231
  }
9643
10232
  function emitWriteResult(item, label, idKey) {
@@ -9661,7 +10250,7 @@ function emitBatchResults(items) {
9661
10250
  }
9662
10251
  async function cmdSpotOrders(run, opts) {
9663
10252
  const result = await run("spot_get_orders", { instId: opts.instId, status: opts.status });
9664
- const orders = getData3(result);
10253
+ const orders = getData4(result);
9665
10254
  if (opts.json) return printJson(orders);
9666
10255
  printTable(
9667
10256
  (orders ?? []).map((o) => ({
@@ -9690,7 +10279,7 @@ async function cmdSpotPlace(run, opts) {
9690
10279
  slTriggerPx: opts.slTriggerPx,
9691
10280
  slOrdPx: opts.slOrdPx
9692
10281
  });
9693
- const data = getData3(result);
10282
+ const data = getData4(result);
9694
10283
  if (opts.json) return printJson(data);
9695
10284
  emitWriteResult(data?.[0], "Order placed", "ordId");
9696
10285
  }
@@ -9698,7 +10287,7 @@ async function cmdSpotCancel(run, opts) {
9698
10287
  const { instId, ordId, clOrdId, json } = opts;
9699
10288
  if (!ordId && !clOrdId) throw new Error("Either --ordId or --clOrdId is required");
9700
10289
  const result = await run("spot_cancel_order", { instId, ...ordId ? { ordId } : { clOrdId } });
9701
- const data = getData3(result);
10290
+ const data = getData4(result);
9702
10291
  if (json) return printJson(data);
9703
10292
  emitWriteResult(data?.[0], "Cancelled", "ordId");
9704
10293
  }
@@ -9718,7 +10307,7 @@ async function cmdSpotAlgoPlace(run, opts) {
9718
10307
  callbackSpread: opts.callbackSpread,
9719
10308
  activePx: opts.activePx
9720
10309
  });
9721
- const data = getData3(result);
10310
+ const data = getData4(result);
9722
10311
  if (opts.json) return printJson(data);
9723
10312
  emitWriteResult(data?.[0], "Algo order placed", "algoId");
9724
10313
  }
@@ -9732,19 +10321,19 @@ async function cmdSpotAlgoAmend(run, opts) {
9732
10321
  newSlTriggerPx: opts.newSlTriggerPx,
9733
10322
  newSlOrdPx: opts.newSlOrdPx
9734
10323
  });
9735
- const data = getData3(result);
10324
+ const data = getData4(result);
9736
10325
  if (opts.json) return printJson(data);
9737
10326
  emitWriteResult(data?.[0], "Algo order amended", "algoId");
9738
10327
  }
9739
10328
  async function cmdSpotAlgoCancel(run, instId, algoId, json) {
9740
10329
  const result = await run("spot_cancel_algo_order", { instId, algoId });
9741
- const data = getData3(result);
10330
+ const data = getData4(result);
9742
10331
  if (json) return printJson(data);
9743
10332
  emitWriteResult(data?.[0], "Algo order cancelled", "algoId");
9744
10333
  }
9745
10334
  async function cmdSpotGet(run, opts) {
9746
10335
  const result = await run("spot_get_order", { instId: opts.instId, ordId: opts.ordId, clOrdId: opts.clOrdId });
9747
- const data = getData3(result);
10336
+ const data = getData4(result);
9748
10337
  if (opts.json) return printJson(data);
9749
10338
  const o = data?.[0];
9750
10339
  if (!o) {
@@ -9772,7 +10361,7 @@ async function cmdSpotAmend(run, opts) {
9772
10361
  newSz: opts.newSz,
9773
10362
  newPx: opts.newPx
9774
10363
  });
9775
- const data = getData3(result);
10364
+ const data = getData4(result);
9776
10365
  if (opts.json) return printJson(data);
9777
10366
  emitWriteResult(data?.[0], "Order amended", "ordId");
9778
10367
  }
@@ -9782,7 +10371,7 @@ async function cmdSpotAlgoOrders(run, opts) {
9782
10371
  status: opts.status,
9783
10372
  ordType: opts.ordType
9784
10373
  });
9785
- const orders = getData3(result);
10374
+ const orders = getData4(result);
9786
10375
  if (opts.json) return printJson(orders);
9787
10376
  if (!(orders ?? []).length) {
9788
10377
  outputLine("No algo orders");
@@ -9803,7 +10392,7 @@ async function cmdSpotAlgoOrders(run, opts) {
9803
10392
  }
9804
10393
  async function cmdSpotFills(run, opts) {
9805
10394
  const result = await run("spot_get_fills", { instId: opts.instId, ordId: opts.ordId });
9806
- const fills = getData3(result);
10395
+ const fills = getData4(result);
9807
10396
  if (opts.json) return printJson(fills);
9808
10397
  printTable(
9809
10398
  (fills ?? []).map((f) => ({
@@ -9827,7 +10416,7 @@ async function cmdSpotAlgoTrailPlace(run, opts) {
9827
10416
  callbackSpread: opts.callbackSpread,
9828
10417
  activePx: opts.activePx
9829
10418
  });
9830
- const data = getData3(result);
10419
+ const data = getData4(result);
9831
10420
  if (opts.json) return printJson(data);
9832
10421
  emitWriteResult(data?.[0], "Trailing stop placed", "algoId");
9833
10422
  }
@@ -9857,13 +10446,13 @@ async function cmdSpotBatch(run, opts) {
9857
10446
  return;
9858
10447
  }
9859
10448
  const result = await run(tool, tool === "spot_batch_orders" ? { action: opts.action, orders: parsed } : { orders: parsed });
9860
- const data = getData3(result);
10449
+ const data = getData4(result);
9861
10450
  if (opts.json) return printJson(data);
9862
10451
  emitBatchResults(data ?? []);
9863
10452
  }
9864
10453
 
9865
10454
  // src/commands/swap.ts
9866
- function getData4(result) {
10455
+ function getData5(result) {
9867
10456
  return result.data;
9868
10457
  }
9869
10458
  function emitWriteResult2(item, label, idKey) {
@@ -9887,7 +10476,7 @@ function emitBatchResults2(items) {
9887
10476
  }
9888
10477
  async function cmdSwapPositions(run, instId, json) {
9889
10478
  const result = await run("swap_get_positions", { instId });
9890
- const positions = getData4(result);
10479
+ const positions = getData5(result);
9891
10480
  if (json) return printJson(positions);
9892
10481
  const open = (positions ?? []).filter((p) => Number(p["pos"]) !== 0);
9893
10482
  if (!open.length) {
@@ -9908,7 +10497,7 @@ async function cmdSwapPositions(run, instId, json) {
9908
10497
  }
9909
10498
  async function cmdSwapOrders(run, opts) {
9910
10499
  const result = await run("swap_get_orders", { instId: opts.instId, status: opts.status });
9911
- const orders = getData4(result);
10500
+ const orders = getData5(result);
9912
10501
  if (opts.json) return printJson(orders);
9913
10502
  printTable(
9914
10503
  (orders ?? []).map((o) => ({
@@ -9938,7 +10527,7 @@ async function cmdSwapPlace(run, opts) {
9938
10527
  slTriggerPx: opts.slTriggerPx,
9939
10528
  slOrdPx: opts.slOrdPx
9940
10529
  });
9941
- const data = getData4(result);
10530
+ const data = getData5(result);
9942
10531
  if (opts.json) return printJson(data);
9943
10532
  emitWriteResult2(data?.[0], "Order placed", "ordId");
9944
10533
  }
@@ -9946,7 +10535,7 @@ async function cmdSwapCancel(run, opts) {
9946
10535
  const { instId, ordId, clOrdId, json } = opts;
9947
10536
  if (!ordId && !clOrdId) throw new Error("Either --ordId or --clOrdId is required");
9948
10537
  const result = await run("swap_cancel_order", { instId, ...ordId ? { ordId } : { clOrdId } });
9949
- const data = getData4(result);
10538
+ const data = getData5(result);
9950
10539
  if (json) return printJson(data);
9951
10540
  emitWriteResult2(data?.[0], "Cancelled", "ordId");
9952
10541
  }
@@ -9968,7 +10557,7 @@ async function cmdSwapAlgoPlace(run, opts) {
9968
10557
  callbackSpread: opts.callbackSpread,
9969
10558
  activePx: opts.activePx
9970
10559
  });
9971
- const data = getData4(result);
10560
+ const data = getData5(result);
9972
10561
  if (opts.json) return printJson(data);
9973
10562
  emitWriteResult2(data?.[0], "Algo order placed", "algoId");
9974
10563
  }
@@ -9982,7 +10571,7 @@ async function cmdSwapAlgoAmend(run, opts) {
9982
10571
  newSlTriggerPx: opts.newSlTriggerPx,
9983
10572
  newSlOrdPx: opts.newSlOrdPx
9984
10573
  });
9985
- const data = getData4(result);
10574
+ const data = getData5(result);
9986
10575
  if (opts.json) return printJson(data);
9987
10576
  emitWriteResult2(data?.[0], "Algo order amended", "algoId");
9988
10577
  }
@@ -9998,13 +10587,13 @@ async function cmdSwapAlgoTrailPlace(run, opts) {
9998
10587
  posSide: opts.posSide,
9999
10588
  reduceOnly: opts.reduceOnly
10000
10589
  });
10001
- const data = getData4(result);
10590
+ const data = getData5(result);
10002
10591
  if (opts.json) return printJson(data);
10003
10592
  emitWriteResult2(data?.[0], "Trailing stop placed", "algoId");
10004
10593
  }
10005
10594
  async function cmdSwapAlgoCancel(run, instId, algoId, json) {
10006
10595
  const result = await run("swap_cancel_algo_orders", { orders: [{ instId, algoId }] });
10007
- const data = getData4(result);
10596
+ const data = getData5(result);
10008
10597
  if (json) return printJson(data);
10009
10598
  emitWriteResult2(data?.[0], "Algo order cancelled", "algoId");
10010
10599
  }
@@ -10014,7 +10603,7 @@ async function cmdSwapAlgoOrders(run, opts) {
10014
10603
  status: opts.status,
10015
10604
  ordType: opts.ordType
10016
10605
  });
10017
- const orders = getData4(result);
10606
+ const orders = getData5(result);
10018
10607
  if (opts.json) return printJson(orders);
10019
10608
  if (!(orders ?? []).length) {
10020
10609
  outputLine("No algo orders");
@@ -10035,7 +10624,7 @@ async function cmdSwapAlgoOrders(run, opts) {
10035
10624
  }
10036
10625
  async function cmdSwapFills(run, opts) {
10037
10626
  const result = await run("swap_get_fills", { instId: opts.instId, ordId: opts.ordId, archive: opts.archive });
10038
- const fills = getData4(result);
10627
+ const fills = getData5(result);
10039
10628
  if (opts.json) return printJson(fills);
10040
10629
  printTable(
10041
10630
  (fills ?? []).map((f) => ({
@@ -10050,7 +10639,7 @@ async function cmdSwapFills(run, opts) {
10050
10639
  }
10051
10640
  async function cmdSwapGet(run, opts) {
10052
10641
  const result = await run("swap_get_order", { instId: opts.instId, ordId: opts.ordId, clOrdId: opts.clOrdId });
10053
- const data = getData4(result);
10642
+ const data = getData5(result);
10054
10643
  if (opts.json) return printJson(data);
10055
10644
  const o = data?.[0];
10056
10645
  if (!o) {
@@ -10078,14 +10667,14 @@ async function cmdSwapClose(run, opts) {
10078
10667
  posSide: opts.posSide,
10079
10668
  autoCxl: opts.autoCxl
10080
10669
  });
10081
- const data = getData4(result);
10670
+ const data = getData5(result);
10082
10671
  if (opts.json) return printJson(data);
10083
10672
  const r = data?.[0];
10084
10673
  outputLine(`Position closed: ${r?.["instId"]} ${r?.["posSide"] ?? ""}`);
10085
10674
  }
10086
10675
  async function cmdSwapGetLeverage(run, opts) {
10087
10676
  const result = await run("swap_get_leverage", { instId: opts.instId, mgnMode: opts.mgnMode });
10088
- const data = getData4(result);
10677
+ const data = getData5(result);
10089
10678
  if (opts.json) return printJson(data);
10090
10679
  printTable(
10091
10680
  (data ?? []).map((r) => ({
@@ -10104,7 +10693,7 @@ async function cmdSwapAmend(run, opts) {
10104
10693
  newSz: opts.newSz,
10105
10694
  newPx: opts.newPx
10106
10695
  });
10107
- const data = getData4(result);
10696
+ const data = getData5(result);
10108
10697
  if (opts.json) return printJson(data);
10109
10698
  emitWriteResult2(data?.[0], "Order amended", "ordId");
10110
10699
  }
@@ -10115,7 +10704,7 @@ async function cmdSwapSetLeverage(run, opts) {
10115
10704
  mgnMode: opts.mgnMode,
10116
10705
  posSide: opts.posSide
10117
10706
  });
10118
- const data = getData4(result);
10707
+ const data = getData5(result);
10119
10708
  if (opts.json) return printJson(data);
10120
10709
  const r = data?.[0];
10121
10710
  outputLine(`Leverage set: ${r?.["lever"]}x ${r?.["instId"]}`);
@@ -10146,13 +10735,13 @@ async function cmdSwapBatch(run, opts) {
10146
10735
  return;
10147
10736
  }
10148
10737
  const result = await run(tool, tool === "swap_batch_orders" ? { action: opts.action, orders: parsed } : { orders: parsed });
10149
- const data = getData4(result);
10738
+ const data = getData5(result);
10150
10739
  if (opts.json) return printJson(data);
10151
10740
  emitBatchResults2(data ?? []);
10152
10741
  }
10153
10742
 
10154
10743
  // src/commands/futures.ts
10155
- function getData5(result) {
10744
+ function getData6(result) {
10156
10745
  return result.data;
10157
10746
  }
10158
10747
  function emitWriteResult3(item, label, idKey) {
@@ -10176,7 +10765,7 @@ function emitBatchResults3(items) {
10176
10765
  }
10177
10766
  async function cmdFuturesOrders(run, opts) {
10178
10767
  const result = await run("futures_get_orders", { instId: opts.instId, status: opts.status });
10179
- const orders = getData5(result);
10768
+ const orders = getData6(result);
10180
10769
  if (opts.json) return printJson(orders);
10181
10770
  printTable(
10182
10771
  (orders ?? []).map((o) => ({
@@ -10193,7 +10782,7 @@ async function cmdFuturesOrders(run, opts) {
10193
10782
  }
10194
10783
  async function cmdFuturesPositions(run, instId, json) {
10195
10784
  const result = await run("futures_get_positions", { instId });
10196
- const positions = getData5(result);
10785
+ const positions = getData6(result);
10197
10786
  if (json) return printJson(positions);
10198
10787
  const open = (positions ?? []).filter((p) => Number(p["pos"]) !== 0);
10199
10788
  if (!open.length) {
@@ -10213,7 +10802,7 @@ async function cmdFuturesPositions(run, instId, json) {
10213
10802
  }
10214
10803
  async function cmdFuturesFills(run, opts) {
10215
10804
  const result = await run("futures_get_fills", { instId: opts.instId, ordId: opts.ordId, archive: opts.archive });
10216
- const fills = getData5(result);
10805
+ const fills = getData6(result);
10217
10806
  if (opts.json) return printJson(fills);
10218
10807
  printTable(
10219
10808
  (fills ?? []).map((f) => ({
@@ -10242,7 +10831,7 @@ async function cmdFuturesPlace(run, opts) {
10242
10831
  slTriggerPx: opts.slTriggerPx,
10243
10832
  slOrdPx: opts.slOrdPx
10244
10833
  });
10245
- const data = getData5(result);
10834
+ const data = getData6(result);
10246
10835
  if (opts.json) return printJson(data);
10247
10836
  emitWriteResult3(data?.[0], "Order placed", "ordId");
10248
10837
  }
@@ -10250,13 +10839,13 @@ async function cmdFuturesCancel(run, opts) {
10250
10839
  const { instId, ordId, clOrdId, json } = opts;
10251
10840
  if (!ordId && !clOrdId) throw new Error("Either --ordId or --clOrdId is required");
10252
10841
  const result = await run("futures_cancel_order", { instId, ...ordId ? { ordId } : { clOrdId } });
10253
- const data = getData5(result);
10842
+ const data = getData6(result);
10254
10843
  if (json) return printJson(data);
10255
10844
  emitWriteResult3(data?.[0], "Cancelled", "ordId");
10256
10845
  }
10257
10846
  async function cmdFuturesGet(run, opts) {
10258
10847
  const result = await run("futures_get_order", { instId: opts.instId, ordId: opts.ordId });
10259
- const data = getData5(result);
10848
+ const data = getData6(result);
10260
10849
  if (opts.json) return printJson(data);
10261
10850
  const o = data?.[0];
10262
10851
  if (!o) {
@@ -10285,7 +10874,7 @@ async function cmdFuturesAmend(run, opts) {
10285
10874
  newSz: opts.newSz,
10286
10875
  newPx: opts.newPx
10287
10876
  });
10288
- const data = getData5(result);
10877
+ const data = getData6(result);
10289
10878
  if (opts.json) return printJson(data);
10290
10879
  emitWriteResult3(data?.[0], "Order amended", "ordId");
10291
10880
  }
@@ -10296,7 +10885,7 @@ async function cmdFuturesClose(run, opts) {
10296
10885
  posSide: opts.posSide,
10297
10886
  autoCxl: opts.autoCxl
10298
10887
  });
10299
- const data = getData5(result);
10888
+ const data = getData6(result);
10300
10889
  if (opts.json) return printJson(data);
10301
10890
  const r = data?.[0];
10302
10891
  outputLine(`Position closed: ${r?.["instId"]} ${r?.["posSide"] ?? ""}`);
@@ -10308,14 +10897,14 @@ async function cmdFuturesSetLeverage(run, opts) {
10308
10897
  mgnMode: opts.mgnMode,
10309
10898
  posSide: opts.posSide
10310
10899
  });
10311
- const data = getData5(result);
10900
+ const data = getData6(result);
10312
10901
  if (opts.json) return printJson(data);
10313
10902
  const r = data?.[0];
10314
10903
  outputLine(`Leverage set: ${r?.["lever"]}x ${r?.["instId"]}`);
10315
10904
  }
10316
10905
  async function cmdFuturesGetLeverage(run, opts) {
10317
10906
  const result = await run("futures_get_leverage", { instId: opts.instId, mgnMode: opts.mgnMode });
10318
- const data = getData5(result);
10907
+ const data = getData6(result);
10319
10908
  if (opts.json) return printJson(data);
10320
10909
  printTable(
10321
10910
  (data ?? []).map((r) => ({
@@ -10352,7 +10941,7 @@ async function cmdFuturesBatch(run, opts) {
10352
10941
  return;
10353
10942
  }
10354
10943
  const result = await run(tool, { orders: parsed });
10355
- const data = getData5(result);
10944
+ const data = getData6(result);
10356
10945
  if (opts.json) return printJson(data);
10357
10946
  emitBatchResults3(data ?? []);
10358
10947
  }
@@ -10374,7 +10963,7 @@ async function cmdFuturesAlgoPlace(run, opts) {
10374
10963
  callbackSpread: opts.callbackSpread,
10375
10964
  activePx: opts.activePx
10376
10965
  });
10377
- const data = getData5(result);
10966
+ const data = getData6(result);
10378
10967
  if (opts.json) return printJson(data);
10379
10968
  emitWriteResult3(data?.[0], "Algo order placed", "algoId");
10380
10969
  }
@@ -10390,7 +10979,7 @@ async function cmdFuturesAlgoTrailPlace(run, opts) {
10390
10979
  posSide: opts.posSide,
10391
10980
  reduceOnly: opts.reduceOnly
10392
10981
  });
10393
- const data = getData5(result);
10982
+ const data = getData6(result);
10394
10983
  if (opts.json) return printJson(data);
10395
10984
  emitWriteResult3(data?.[0], "Trailing stop placed", "algoId");
10396
10985
  }
@@ -10404,13 +10993,13 @@ async function cmdFuturesAlgoAmend(run, opts) {
10404
10993
  newSlTriggerPx: opts.newSlTriggerPx,
10405
10994
  newSlOrdPx: opts.newSlOrdPx
10406
10995
  });
10407
- const data = getData5(result);
10996
+ const data = getData6(result);
10408
10997
  if (opts.json) return printJson(data);
10409
10998
  emitWriteResult3(data?.[0], "Algo order amended", "algoId");
10410
10999
  }
10411
11000
  async function cmdFuturesAlgoCancel(run, instId, algoId, json) {
10412
11001
  const result = await run("futures_cancel_algo_orders", { orders: [{ instId, algoId }] });
10413
- const data = getData5(result);
11002
+ const data = getData6(result);
10414
11003
  if (json) return printJson(data);
10415
11004
  emitWriteResult3(data?.[0], "Algo order cancelled", "algoId");
10416
11005
  }
@@ -10420,7 +11009,7 @@ async function cmdFuturesAlgoOrders(run, opts) {
10420
11009
  status: opts.status,
10421
11010
  ordType: opts.ordType
10422
11011
  });
10423
- const orders = getData5(result);
11012
+ const orders = getData6(result);
10424
11013
  if (opts.json) return printJson(orders);
10425
11014
  if (!(orders ?? []).length) {
10426
11015
  outputLine("No algo orders");
@@ -10441,7 +11030,7 @@ async function cmdFuturesAlgoOrders(run, opts) {
10441
11030
  }
10442
11031
 
10443
11032
  // src/commands/option.ts
10444
- function getData6(result) {
11033
+ function getData7(result) {
10445
11034
  return result.data;
10446
11035
  }
10447
11036
  function emitWriteResult4(item, label, idKey) {
@@ -10469,7 +11058,7 @@ async function cmdOptionOrders(run, opts) {
10469
11058
  uly: opts.uly,
10470
11059
  status: opts.status
10471
11060
  });
10472
- const orders = getData6(result);
11061
+ const orders = getData7(result);
10473
11062
  if (opts.json) return printJson(orders);
10474
11063
  printTable(
10475
11064
  (orders ?? []).map((o) => ({
@@ -10489,7 +11078,7 @@ async function cmdOptionGet(run, opts) {
10489
11078
  ordId: opts.ordId,
10490
11079
  clOrdId: opts.clOrdId
10491
11080
  });
10492
- const data = getData6(result);
11081
+ const data = getData7(result);
10493
11082
  if (opts.json) return printJson(data);
10494
11083
  const o = data?.[0];
10495
11084
  if (!o) {
@@ -10514,7 +11103,7 @@ async function cmdOptionPositions(run, opts) {
10514
11103
  instId: opts.instId,
10515
11104
  uly: opts.uly
10516
11105
  });
10517
- const positions = getData6(result);
11106
+ const positions = getData7(result);
10518
11107
  if (opts.json) return printJson(positions);
10519
11108
  const open = (positions ?? []).filter((p) => Number(p["pos"]) !== 0);
10520
11109
  if (!open.length) {
@@ -10541,7 +11130,7 @@ async function cmdOptionFills(run, opts) {
10541
11130
  ordId: opts.ordId,
10542
11131
  archive: opts.archive
10543
11132
  });
10544
- const fills = getData6(result);
11133
+ const fills = getData7(result);
10545
11134
  if (opts.json) return printJson(fills);
10546
11135
  printTable(
10547
11136
  (fills ?? []).map((f) => ({
@@ -10559,7 +11148,7 @@ async function cmdOptionInstruments(run, opts) {
10559
11148
  uly: opts.uly,
10560
11149
  expTime: opts.expTime
10561
11150
  });
10562
- const instruments = getData6(result);
11151
+ const instruments = getData7(result);
10563
11152
  if (opts.json) return printJson(instruments);
10564
11153
  printTable(
10565
11154
  (instruments ?? []).map((i) => ({
@@ -10577,7 +11166,7 @@ async function cmdOptionGreeks(run, opts) {
10577
11166
  uly: opts.uly,
10578
11167
  expTime: opts.expTime
10579
11168
  });
10580
- const greeks = getData6(result);
11169
+ const greeks = getData7(result);
10581
11170
  if (opts.json) return printJson(greeks);
10582
11171
  printTable(
10583
11172
  (greeks ?? []).map((g) => ({
@@ -10606,7 +11195,7 @@ async function cmdOptionPlace(run, opts) {
10606
11195
  slTriggerPx: opts.slTriggerPx,
10607
11196
  slOrdPx: opts.slOrdPx
10608
11197
  });
10609
- const data = getData6(result);
11198
+ const data = getData7(result);
10610
11199
  if (opts.json) return printJson(data);
10611
11200
  emitWriteResult4(data?.[0], "Order placed", "ordId");
10612
11201
  }
@@ -10616,7 +11205,7 @@ async function cmdOptionCancel(run, opts) {
10616
11205
  ordId: opts.ordId,
10617
11206
  clOrdId: opts.clOrdId
10618
11207
  });
10619
- const data = getData6(result);
11208
+ const data = getData7(result);
10620
11209
  if (opts.json) return printJson(data);
10621
11210
  emitWriteResult4(data?.[0], "Cancelled", "ordId");
10622
11211
  }
@@ -10628,7 +11217,7 @@ async function cmdOptionAmend(run, opts) {
10628
11217
  newSz: opts.newSz,
10629
11218
  newPx: opts.newPx
10630
11219
  });
10631
- const data = getData6(result);
11220
+ const data = getData7(result);
10632
11221
  if (opts.json) return printJson(data);
10633
11222
  emitWriteResult4(data?.[0], "Amended", "ordId");
10634
11223
  }
@@ -10647,7 +11236,7 @@ async function cmdOptionBatchCancel(run, opts) {
10647
11236
  return;
10648
11237
  }
10649
11238
  const result = await run("option_batch_cancel", { orders: parsed });
10650
- const data = getData6(result);
11239
+ const data = getData7(result);
10651
11240
  if (opts.json) return printJson(data);
10652
11241
  emitBatchResults4(data ?? []);
10653
11242
  }
@@ -10666,7 +11255,7 @@ async function cmdOptionAlgoPlace(run, opts) {
10666
11255
  reduceOnly: opts.reduceOnly,
10667
11256
  clOrdId: opts.clOrdId
10668
11257
  });
10669
- const data = getData6(result);
11258
+ const data = getData7(result);
10670
11259
  if (opts.json) return printJson(data);
10671
11260
  emitWriteResult4(data?.[0], "Algo order placed", "algoId");
10672
11261
  }
@@ -10680,13 +11269,13 @@ async function cmdOptionAlgoAmend(run, opts) {
10680
11269
  newSlTriggerPx: opts.newSlTriggerPx,
10681
11270
  newSlOrdPx: opts.newSlOrdPx
10682
11271
  });
10683
- const data = getData6(result);
11272
+ const data = getData7(result);
10684
11273
  if (opts.json) return printJson(data);
10685
11274
  emitWriteResult4(data?.[0], "Algo order amended", "algoId");
10686
11275
  }
10687
11276
  async function cmdOptionAlgoCancel(run, opts) {
10688
11277
  const result = await run("option_cancel_algo_orders", { orders: [{ instId: opts.instId, algoId: opts.algoId }] });
10689
- const data = getData6(result);
11278
+ const data = getData7(result);
10690
11279
  if (opts.json) return printJson(data);
10691
11280
  emitWriteResult4(data?.[0], "Algo order cancelled", "algoId");
10692
11281
  }
@@ -10696,7 +11285,7 @@ async function cmdOptionAlgoOrders(run, opts) {
10696
11285
  status: opts.status,
10697
11286
  ordType: opts.ordType
10698
11287
  });
10699
- const orders = getData6(result);
11288
+ const orders = getData7(result);
10700
11289
  if (opts.json) return printJson(orders);
10701
11290
  if (!(orders ?? []).length) {
10702
11291
  outputLine("No algo orders");
@@ -11215,7 +11804,7 @@ function emitWriteResult5(item, label, idKey) {
11215
11804
  outputLine(`${label}: ${item?.[idKey]} (OK)`);
11216
11805
  }
11217
11806
  }
11218
- function getData7(result) {
11807
+ function getData8(result) {
11219
11808
  return result.data;
11220
11809
  }
11221
11810
  async function cmdGridOrders(run, opts) {
@@ -11225,7 +11814,7 @@ async function cmdGridOrders(run, opts) {
11225
11814
  algoId: opts.algoId,
11226
11815
  status: opts.status
11227
11816
  });
11228
- const orders = getData7(result) ?? [];
11817
+ const orders = getData8(result) ?? [];
11229
11818
  if (opts.json) return printJson(orders);
11230
11819
  if (!orders.length) {
11231
11820
  outputLine("No grid bots");
@@ -11250,7 +11839,7 @@ async function cmdGridDetails(run, opts) {
11250
11839
  algoOrdType: opts.algoOrdType,
11251
11840
  algoId: opts.algoId
11252
11841
  });
11253
- const detail = (getData7(result) ?? [])[0];
11842
+ const detail = (getData8(result) ?? [])[0];
11254
11843
  if (!detail) {
11255
11844
  outputLine("Bot not found");
11256
11845
  return;
@@ -11278,7 +11867,7 @@ async function cmdGridSubOrders(run, opts) {
11278
11867
  algoId: opts.algoId,
11279
11868
  type: opts.type
11280
11869
  });
11281
- const orders = getData7(result) ?? [];
11870
+ const orders = getData8(result) ?? [];
11282
11871
  if (opts.json) return printJson(orders);
11283
11872
  if (!orders.length) {
11284
11873
  outputLine("No sub-orders");
@@ -11317,7 +11906,7 @@ async function cmdGridCreate(run, opts) {
11317
11906
  slRatio: opts.slRatio,
11318
11907
  algoClOrdId: opts.algoClOrdId
11319
11908
  });
11320
- const data = getData7(result);
11909
+ const data = getData8(result);
11321
11910
  if (opts.json) return printJson(data);
11322
11911
  emitWriteResult5(data?.[0], "Grid bot created", "algoId");
11323
11912
  }
@@ -11328,7 +11917,7 @@ async function cmdGridStop(run, opts) {
11328
11917
  instId: opts.instId,
11329
11918
  stopType: opts.stopType
11330
11919
  });
11331
- const data = getData7(result);
11920
+ const data = getData8(result);
11332
11921
  if (opts.json) return printJson(data);
11333
11922
  emitWriteResult5(data?.[0], "Grid bot stopped", "algoId");
11334
11923
  }
@@ -11358,7 +11947,7 @@ async function cmdDcaCreate(run, opts) {
11358
11947
  reserveFunds: opts.reserveFunds,
11359
11948
  tradeQuoteCcy: opts.tradeQuoteCcy
11360
11949
  });
11361
- const data = getData7(result);
11950
+ const data = getData8(result);
11362
11951
  if (opts.json) return printJson(data);
11363
11952
  emitWriteResult5(data?.[0], "DCA bot created", "algoId");
11364
11953
  }
@@ -11368,7 +11957,7 @@ async function cmdDcaStop(run, opts) {
11368
11957
  algoOrdType: opts.algoOrdType,
11369
11958
  stopType: opts.stopType
11370
11959
  });
11371
- const data = getData7(result);
11960
+ const data = getData8(result);
11372
11961
  if (opts.json) return printJson(data);
11373
11962
  emitWriteResult5(data?.[0], "DCA bot stopped", "algoId");
11374
11963
  }
@@ -11379,7 +11968,7 @@ async function cmdDcaOrders(run, opts) {
11379
11968
  algoId: opts.algoId,
11380
11969
  instId: opts.instId
11381
11970
  });
11382
- const orders = getData7(result) ?? [];
11971
+ const orders = getData8(result) ?? [];
11383
11972
  if (opts.json) return printJson(orders);
11384
11973
  if (!orders.length) {
11385
11974
  outputLine("No DCA bots");
@@ -11402,7 +11991,7 @@ async function cmdDcaDetails(run, opts) {
11402
11991
  algoId: opts.algoId,
11403
11992
  algoOrdType: opts.algoOrdType
11404
11993
  });
11405
- const detail = (getData7(result) ?? [])[0];
11994
+ const detail = (getData8(result) ?? [])[0];
11406
11995
  if (!detail) {
11407
11996
  outputLine("DCA bot not found");
11408
11997
  return;
@@ -11431,7 +12020,7 @@ async function cmdDcaSubOrders(run, opts) {
11431
12020
  algoOrdType: opts.algoOrdType,
11432
12021
  cycleId: opts.cycleId
11433
12022
  });
11434
- const rows = getData7(result) ?? [];
12023
+ const rows = getData8(result) ?? [];
11435
12024
  if (opts.json) return printJson(rows);
11436
12025
  if (!rows.length) {
11437
12026
  outputLine("No sub-orders");
@@ -11763,7 +12352,7 @@ async function cmdDcdQuoteAndBuy(run, opts) {
11763
12352
  // src/index.ts
11764
12353
  var _require3 = createRequire3(import.meta.url);
11765
12354
  var CLI_VERSION2 = _require3("../package.json").version;
11766
- var GIT_HASH2 = true ? "43f321d" : "dev";
12355
+ var GIT_HASH2 = true ? "7b97fe6" : "dev";
11767
12356
  function handleConfigCommand(action, rest, json, lang, force) {
11768
12357
  if (action === "init") return cmdConfigInit(lang === "zh" ? "zh" : "en");
11769
12358
  if (action === "show") return cmdConfigShow(json);
@@ -12522,6 +13111,36 @@ function handleEarnDcdCommand(run, action, v, json) {
12522
13111
  errorLine("Valid: pairs, products, quote-and-buy, redeem-execute, order, orders");
12523
13112
  process.exitCode = 1;
12524
13113
  }
13114
+ function handleNewsCommand(run, action, rest, v, json) {
13115
+ const limit = v.limit !== void 0 ? Number(v.limit) : void 0;
13116
+ const begin = v.begin !== void 0 ? Number(v.begin) : void 0;
13117
+ const end = v.end !== void 0 ? Number(v.end) : void 0;
13118
+ const language = v.lang;
13119
+ const detailLvl = v["detail-lvl"];
13120
+ const after = v.after;
13121
+ const period = v.period;
13122
+ const points = v.points !== void 0 ? Number(v.points) : 24;
13123
+ const sortBy = v["sort-by"];
13124
+ const searchOpts = { coins: v.coins, importance: v.importance, sentiment: v.sentiment, sortBy, begin, end, language, detailLvl, limit, after, json };
13125
+ const listOpts = { coins: v.coins, importance: v.importance, begin, end, language, detailLvl, limit, after, json };
13126
+ const dispatch = {
13127
+ latest: () => cmdNewsLatest(run, listOpts),
13128
+ important: () => cmdNewsImportant(run, { coins: v.coins, begin, end, language, detailLvl, limit, json }),
13129
+ "by-coin": () => cmdNewsByCoin(run, v.coins ?? rest[0], { importance: v.importance, begin, end, language, detailLvl, limit, json }),
13130
+ search: () => cmdNewsSearch(run, v.keyword ?? rest[0], searchOpts),
13131
+ detail: () => cmdNewsDetail(run, rest[0], { language, json }),
13132
+ domains: () => cmdNewsDomains(run, { json }),
13133
+ "coin-sentiment": () => cmdNewsCoinSentiment(run, v.coins ?? rest[0], { period, json }),
13134
+ "coin-trend": () => cmdNewsCoinTrend(run, rest[0], { period, points, json }),
13135
+ "by-sentiment": () => cmdNewsSearch(run, "", { ...searchOpts, sentiment: v.sentiment ?? rest[0], sortBy: sortBy ?? "latest" }),
13136
+ "sentiment-rank": () => cmdNewsSentimentRank(run, { period, sortBy, limit, json })
13137
+ };
13138
+ const handler = dispatch[action];
13139
+ if (handler) return handler();
13140
+ process.stderr.write(`Unknown news command: ${action}
13141
+ `);
13142
+ process.exitCode = 1;
13143
+ }
12525
13144
  function outputResult(result, json) {
12526
13145
  if (json) {
12527
13146
  outputLine(JSON.stringify(result, null, 2));
@@ -12559,12 +13178,12 @@ async function main() {
12559
13178
  if (module === "diagnose") {
12560
13179
  let config2;
12561
13180
  try {
12562
- config2 = loadProfileConfig({ profile: v.profile, demo: v.demo, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
13181
+ config2 = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
12563
13182
  } catch {
12564
13183
  }
12565
13184
  return cmdDiagnose(config2, v.profile ?? "default", { mcp: v.mcp, cli: v.cli, all: v.all, output: v.output });
12566
13185
  }
12567
- const config = loadProfileConfig({ profile: v.profile, demo: v.demo, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
13186
+ const config = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
12568
13187
  const client = new OkxRestClient(config);
12569
13188
  const baseRunner = createToolRunner(client, config);
12570
13189
  const writeToolNames = new Set(allToolSpecs().filter((t) => t.isWrite).map((t) => t.name));
@@ -12582,6 +13201,7 @@ async function main() {
12582
13201
  swap: () => handleSwapCommand(run, action, rest, v, json),
12583
13202
  futures: () => handleFuturesCommand(run, action, rest, v, json),
12584
13203
  option: () => handleOptionCommand(run, action, rest, v, json),
13204
+ news: () => handleNewsCommand(run, action, rest, v, json),
12585
13205
  bot: () => handleBotCommand(run, action, rest, v, json),
12586
13206
  earn: () => handleEarnCommand(run, action, rest, v, json)
12587
13207
  };
@@ -12610,6 +13230,7 @@ export {
12610
13230
  handleMarketCommand,
12611
13231
  handleMarketDataCommand,
12612
13232
  handleMarketPublicCommand,
13233
+ handleNewsCommand,
12613
13234
  handleOptionAlgoCommand,
12614
13235
  handleOptionCommand,
12615
13236
  handleSetupCommand,