@okx_ai/okx-trade-cli 1.3.4-beta.1 → 1.3.4-beta.2

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
@@ -9679,6 +9679,58 @@ function registerMarketFilterTools() {
9679
9679
  );
9680
9680
  return normalizeResponse(response);
9681
9681
  }
9682
+ },
9683
+ // ─────────────────────────────────────────────────────────────────────────
9684
+ // market_get_pair_spread — /api/v5/aigc/mcp/pair-spread
9685
+ // ─────────────────────────────────────────────────────────────────────────
9686
+ {
9687
+ name: "market_get_pair_spread",
9688
+ module: "market",
9689
+ description: "Compute spread statistics between two instruments over a lookback window. Returns absolute and ratio spread (mean / stdDev / median / min / max) plus an optional realtime spread snapshot. Use to size pairs trades, detect mean-reversion setups, or compare cross-listed contracts. Results are cached ~60s per (pair, bar, window) tuple. Read-only, no credentials required.\nDo NOT use to fetch raw candles (use market_get_candles) or single-instrument OI/funding (use market_get_oi_history / market_filter_oi_change).",
9690
+ isWrite: false,
9691
+ inputSchema: {
9692
+ type: "object",
9693
+ properties: {
9694
+ instIdA: {
9695
+ type: "string",
9696
+ description: "First instrument ID, e.g. BTC-USDT-SWAP"
9697
+ },
9698
+ instIdB: {
9699
+ type: "string",
9700
+ description: "Second instrument ID; must differ from instIdA"
9701
+ },
9702
+ bar: {
9703
+ type: "string",
9704
+ enum: ["5m", "15m"],
9705
+ description: "Bar size for the spread series. Default 15m. 1m is not supported."
9706
+ },
9707
+ window: {
9708
+ type: "string",
9709
+ description: "Lookback window. Format <n><unit>, units m/H/D/W (case-sensitive), max 1W. Default 1W."
9710
+ },
9711
+ backtestTime: {
9712
+ type: "number",
9713
+ description: "Anchor timestamp (ms epoch) for backtest mode. When provided, realtime is omitted."
9714
+ }
9715
+ },
9716
+ required: ["instIdA", "instIdB"]
9717
+ },
9718
+ handler: async (rawArgs, context) => {
9719
+ const args = asRecord(rawArgs);
9720
+ const body = compactObject({
9721
+ instIdA: requireString(args, "instIdA"),
9722
+ instIdB: requireString(args, "instIdB"),
9723
+ bar: readString(args, "bar"),
9724
+ window: readString(args, "window"),
9725
+ backtestTime: readNumber(args, "backtestTime")
9726
+ });
9727
+ const response = await context.client.publicPost(
9728
+ "/api/v5/aigc/mcp/pair-spread",
9729
+ body,
9730
+ publicRateLimit("market_get_pair_spread", 5)
9731
+ );
9732
+ return normalizeResponse(response);
9733
+ }
9682
9734
  }
9683
9735
  ];
9684
9736
  }
@@ -13751,7 +13803,7 @@ async function cmdDiagnoseMcp(options = {}) {
13751
13803
 
13752
13804
  // src/commands/diagnose.ts
13753
13805
  var CLI_VERSION = readCliVersion();
13754
- var GIT_HASH = true ? "cd99d487" : "dev";
13806
+ var GIT_HASH = true ? "0566db8f" : "dev";
13755
13807
  function maskKey2(key) {
13756
13808
  if (!key) return "(not set)";
13757
13809
  if (key.length <= 8) return "****";
@@ -14327,6 +14379,11 @@ var CLI_REGISTRY = {
14327
14379
  toolName: "market_filter_oi_change",
14328
14380
  usage: "okx market oi-change --instType <SWAP|FUTURES> [--bar <5m|15m|1H|4H|1D>] [--sortBy <oiUsd|oiDeltaUsd|oiDeltaPct|absOiDeltaPct|volUsd24h|fundingRate|last>] [--sortOrder <asc|desc>] [--limit <1-100>] [--minOiUsd <n>] [--minVolUsd24h <n>] [--minAbsOiDeltaPct <n>]",
14329
14381
  description: "Find instruments with largest OI changes over a bar window (accumulation/distribution scanner)"
14382
+ },
14383
+ "pair-spread": {
14384
+ toolName: "market_get_pair_spread",
14385
+ usage: "okx market pair-spread <instIdA> <instIdB> [--bar <5m|15m>] [--window <window>] [--backtest-time <ms>] [--json]",
14386
+ description: "Compute spread statistics (abs + ratio) between two instruments over a lookback window"
14330
14387
  }
14331
14388
  },
14332
14389
  subgroups: {
@@ -16031,6 +16088,8 @@ var CLI_OPTIONS = {
16031
16088
  params: { type: "string" },
16032
16089
  list: { type: "boolean", default: false },
16033
16090
  "backtest-time": { type: "string" },
16091
+ // pair-spread
16092
+ window: { type: "string" },
16034
16093
  // news
16035
16094
  coins: { type: "string" },
16036
16095
  sentiment: { type: "string" },
@@ -16554,6 +16613,42 @@ async function cmdMarketOiChangeFilter(run, opts) {
16554
16613
  }))
16555
16614
  );
16556
16615
  }
16616
+ async function cmdMarketPairSpread(run, instIdA, instIdB, opts) {
16617
+ const result = await run("market_get_pair_spread", {
16618
+ instIdA,
16619
+ instIdB,
16620
+ bar: opts.bar,
16621
+ window: opts.window,
16622
+ backtestTime: opts.backtestTime
16623
+ });
16624
+ const data = getData2(result);
16625
+ if (opts.json) return printJson(data);
16626
+ const bar = data?.["bar"] ?? "15m";
16627
+ const win = data?.["window"] ?? "1W";
16628
+ const mode = data?.["mode"] ?? "live";
16629
+ outputLine(`${instIdA} / ${instIdB} bar=${bar} window=${win} mode=${mode}`);
16630
+ const rt = data?.["realtime"];
16631
+ if (rt) {
16632
+ outputLine(`realtime lastA=${rt["lastPriceA"]} lastB=${rt["lastPriceB"]} abs=${rt["spreadAbs"]} ratio=${rt["spreadRatio"]}`);
16633
+ }
16634
+ const stats = data?.["statistics"];
16635
+ if (stats) {
16636
+ const abs = stats["absolute"];
16637
+ const ratio = stats["ratio"];
16638
+ const meta = data?.["meta"];
16639
+ outputLine(`samples count=${meta?.["alignedBars"] ?? "?"} start=${stats?.["windowStartTs"] ?? "?"} end=${stats?.["windowEndTs"] ?? "?"}`);
16640
+ printTable([
16641
+ { stat: "mean", absolute: abs?.["mean"], ratio: ratio?.["mean"] },
16642
+ { stat: "stdDev", absolute: abs?.["stdDev"], ratio: ratio?.["stdDev"] },
16643
+ { stat: "median", absolute: abs?.["median"], ratio: ratio?.["median"] },
16644
+ { stat: "min", absolute: abs?.["min"], ratio: ratio?.["min"] },
16645
+ { stat: "max", absolute: abs?.["max"], ratio: ratio?.["max"] }
16646
+ ]);
16647
+ if (meta) {
16648
+ outputLine(`meta requested=${meta["requestedBars"]} aligned=${meta["alignedBars"]} dropped=${meta["droppedBars"]} truncated=${meta["truncated"]}`);
16649
+ }
16650
+ }
16651
+ }
16557
16652
 
16558
16653
  // src/commands/account.ts
16559
16654
  import * as fs7 from "fs";
@@ -20297,7 +20392,7 @@ async function cmdEventCancel(run, opts) {
20297
20392
  // src/index.ts
20298
20393
  var _require3 = createRequire3(import.meta.url);
20299
20394
  var CLI_VERSION2 = _require3("../package.json").version;
20300
- var GIT_HASH2 = true ? "cd99d487" : "dev";
20395
+ var GIT_HASH2 = true ? "0566db8f" : "dev";
20301
20396
  function handlePilotCommand(action, json, force, binaryPath) {
20302
20397
  if (action === "status") return cmdPilotStatus(json, binaryPath);
20303
20398
  if (action === "install") return cmdPilotInstall(json, binaryPath);
@@ -20402,6 +20497,15 @@ function handleMarketFilterCommand(run, action, rest, v, json) {
20402
20497
  limit,
20403
20498
  json
20404
20499
  });
20500
+ if (action === "pair-spread") {
20501
+ const backtestTime = v["backtest-time"] !== void 0 ? Number(v["backtest-time"]) : void 0;
20502
+ return cmdMarketPairSpread(run, rest[0], rest[1], {
20503
+ bar: v.bar,
20504
+ window: v.window,
20505
+ backtestTime,
20506
+ json
20507
+ });
20508
+ }
20405
20509
  }
20406
20510
  function handleIndicatorAction(run, rest, v, json) {
20407
20511
  if (rest[0] === "list") return cmdMarketIndicatorList(json);
@@ -20450,7 +20554,8 @@ function handleMarketCommand(run, action, rest, v, json) {
20450
20554
  "filter",
20451
20555
  "oi-history",
20452
20556
  "oi-change",
20453
- "index-candles"
20557
+ "index-candles",
20558
+ "pair-spread"
20454
20559
  ]);
20455
20560
  }
20456
20561
  function handleAccountWriteCommand(run, action, v, json) {