@okx_ai/okx-trade-cli 1.2.9-beta.2 → 1.2.9

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
@@ -4432,7 +4432,7 @@ function registerDcdTools() {
4432
4432
  {
4433
4433
  name: "dcd_get_products",
4434
4434
  module: "earn.dcd",
4435
- description: "Get DCD products with yield and quota info.",
4435
+ description: "Get DCD products with yield and quota info. Yields in response are decimal fractions, not percentages.",
4436
4436
  isWrite: false,
4437
4437
  inputSchema: {
4438
4438
  type: "object",
@@ -4486,7 +4486,7 @@ function registerDcdTools() {
4486
4486
  {
4487
4487
  name: "dcd_get_orders",
4488
4488
  module: "earn.dcd",
4489
- description: "Get DCD order history.",
4489
+ description: "Get DCD order history. Yields in response are decimal fractions, not percentages.",
4490
4490
  isWrite: false,
4491
4491
  inputSchema: {
4492
4492
  type: "object",
@@ -4530,7 +4530,7 @@ function registerDcdTools() {
4530
4530
  {
4531
4531
  name: "dcd_subscribe",
4532
4532
  module: "earn.dcd",
4533
- description: "Subscribe to a DCD product: get quote and execute atomically. Confirm product, amount, and currency with user before calling. Optional minAnnualizedYield (percent) rejects the order if quote yield falls below threshold. Returns order result with quote snapshot (annualizedYield, absYield).",
4533
+ description: "Subscribe to a DCD product: get quote and execute atomically. Confirm product, amount, and currency with user before calling. Optional minAnnualizedYield rejects the order if quote yield falls below threshold. Returns order result with quote snapshot (minAnnualizedYield is in percent; response yields are decimal fractions).",
4534
4534
  isWrite: true,
4535
4535
  inputSchema: {
4536
4536
  type: "object",
@@ -4569,13 +4569,23 @@ function registerDcdTools() {
4569
4569
  });
4570
4570
  }
4571
4571
  if (minAnnualizedYield !== void 0) {
4572
- const actualYield = parseFloat(quote["annualizedYield"]);
4573
- if (!isNaN(actualYield) && actualYield < minAnnualizedYield) {
4572
+ const rawYield = parseFloat(quote["annualizedYield"]);
4573
+ if (isNaN(rawYield)) {
4574
4574
  throw new OkxApiError(
4575
- `Quote yield ${actualYield}% is below the minimum threshold of ${minAnnualizedYield}%.`,
4575
+ "Quote returned non-numeric annualizedYield, cannot verify minimum yield threshold.",
4576
+ {
4577
+ code: "INVALID_YIELD_VALUE",
4578
+ suggestion: "Order not placed. The quote did not include a valid annualizedYield. Retry or pick a different product."
4579
+ }
4580
+ );
4581
+ }
4582
+ const actualYieldPct = rawYield * 100;
4583
+ if (actualYieldPct < minAnnualizedYield) {
4584
+ throw new OkxApiError(
4585
+ `Quote yield ${actualYieldPct.toFixed(2)}% is below the minimum threshold of ${minAnnualizedYield}%.`,
4576
4586
  {
4577
4587
  code: "YIELD_BELOW_MIN",
4578
- suggestion: `Order not placed. Actual: ${actualYield}%, required: >= ${minAnnualizedYield}%. Try a different product or lower your minimum yield.`
4588
+ suggestion: `Order not placed. Actual: ${actualYieldPct.toFixed(2)}%, required: >= ${minAnnualizedYield}%. Try a different product or lower your minimum yield.`
4579
4589
  }
4580
4590
  );
4581
4591
  }
@@ -6147,7 +6157,12 @@ function registerOptionTools() {
6147
6157
  },
6148
6158
  sz: {
6149
6159
  type: "string",
6150
- description: "Contracts count (NOT USDT). Use market_get_instruments for ctVal."
6160
+ description: "Contracts count by default. Set tgtCcy=quote_ccy to use USDT amount instead."
6161
+ },
6162
+ tgtCcy: {
6163
+ type: "string",
6164
+ enum: ["base_ccy", "quote_ccy"],
6165
+ description: "Size unit. base_ccy(default): sz in contracts, quote_ccy: sz in USDT (auto-converted to contracts)"
6151
6166
  },
6152
6167
  px: {
6153
6168
  type: "string",
@@ -6184,6 +6199,13 @@ function registerOptionTools() {
6184
6199
  const args = asRecord(rawArgs);
6185
6200
  const reduceOnly = args.reduceOnly;
6186
6201
  const attachAlgoOrds = buildAttachAlgoOrds(args);
6202
+ const resolved = await resolveQuoteCcySz(
6203
+ requireString(args, "instId"),
6204
+ requireString(args, "sz"),
6205
+ readString(args, "tgtCcy"),
6206
+ "OPTION",
6207
+ context.client
6208
+ );
6187
6209
  const response = await context.client.privatePost(
6188
6210
  "/api/v5/trade/order",
6189
6211
  compactObject({
@@ -6191,7 +6213,8 @@ function registerOptionTools() {
6191
6213
  tdMode: requireString(args, "tdMode"),
6192
6214
  side: requireString(args, "side"),
6193
6215
  ordType: requireString(args, "ordType"),
6194
- sz: requireString(args, "sz"),
6216
+ sz: resolved.sz,
6217
+ tgtCcy: resolved.tgtCcy,
6195
6218
  px: readString(args, "px"),
6196
6219
  reduceOnly: typeof reduceOnly === "boolean" ? String(reduceOnly) : void 0,
6197
6220
  clOrdId: readString(args, "clOrdId"),
@@ -8341,7 +8364,7 @@ async function cmdDiagnoseMcp(options = {}) {
8341
8364
 
8342
8365
  // src/commands/diagnose.ts
8343
8366
  var CLI_VERSION = readCliVersion();
8344
- var GIT_HASH = true ? "5f833a2" : "dev";
8367
+ var GIT_HASH = true ? "f1f0625" : "dev";
8345
8368
  function maskKey2(key) {
8346
8369
  if (!key) return "(not set)";
8347
8370
  if (key.length <= 8) return "****";
@@ -11190,6 +11213,7 @@ async function cmdOptionPlace(run, opts) {
11190
11213
  side: opts.side,
11191
11214
  ordType: opts.ordType,
11192
11215
  sz: opts.sz,
11216
+ tgtCcy: opts.tgtCcy,
11193
11217
  px: opts.px,
11194
11218
  reduceOnly: opts.reduceOnly,
11195
11219
  clOrdId: opts.clOrdId,
@@ -12236,7 +12260,7 @@ async function cmdDcdRedeemExecute(run, opts) {
12236
12260
  ordId: r["ordId"],
12237
12261
  state: r["state"],
12238
12262
  redeemSz: q["redeemSz"] ? `${parseFloat(q["redeemSz"]).toFixed(8)} ${q["redeemCcy"]}` : "\u2014",
12239
- termRate: q["termRate"] ? `${q["termRate"]}%` : "\u2014"
12263
+ termRate: q["termRate"] ? `${(parseFloat(q["termRate"]) * 100).toFixed(2)}%` : "\u2014"
12240
12264
  });
12241
12265
  }
12242
12266
  async function cmdDcdOrderState(run, opts) {
@@ -12289,7 +12313,7 @@ async function cmdDcdOrders(run, opts) {
12289
12313
  quoteCcy: r["quoteCcy"],
12290
12314
  strike: r["strike"],
12291
12315
  notionalSz: r["notionalSz"],
12292
- annualizedYield: r["annualizedYield"],
12316
+ annualizedYield: r["annualizedYield"] ? `${(parseFloat(r["annualizedYield"]) * 100).toFixed(2)}%` : "\u2014",
12293
12317
  yieldSz: r["yieldSz"],
12294
12318
  settleTime: r["settleTime"] ? new Date(Number(r["settleTime"])).toLocaleDateString() : "",
12295
12319
  // scheduled settlement time
@@ -12329,7 +12353,7 @@ async function cmdDcdQuoteAndBuy(run, opts) {
12329
12353
  outputLine("Quote:");
12330
12354
  printKv({
12331
12355
  quoteId: q["quoteId"],
12332
- annualizedYield: q["annualizedYield"] ? `${q["annualizedYield"]}%` : "\u2014",
12356
+ annualizedYield: q["annualizedYield"] ? `${(parseFloat(q["annualizedYield"]) * 100).toFixed(2)}%` : "\u2014",
12333
12357
  absYield: q["absYield"],
12334
12358
  notionalSz: q["notionalSz"],
12335
12359
  notionalCcy: q["notionalCcy"]
@@ -12544,7 +12568,7 @@ function printSkillInstallResult(meta, json) {
12544
12568
  // src/index.ts
12545
12569
  var _require3 = createRequire3(import.meta.url);
12546
12570
  var CLI_VERSION2 = _require3("../package.json").version;
12547
- var GIT_HASH2 = true ? "5f833a2" : "dev";
12571
+ var GIT_HASH2 = true ? "f1f0625" : "dev";
12548
12572
  function handleConfigCommand(action, rest, json, lang, force) {
12549
12573
  if (action === "init") return cmdConfigInit(lang === "zh" ? "zh" : "en");
12550
12574
  if (action === "show") return cmdConfigShow(json);
@@ -12951,6 +12975,7 @@ function handleOptionCommand(run, action, rest, v, json) {
12951
12975
  side: v.side,
12952
12976
  ordType: v.ordType,
12953
12977
  sz: v.sz,
12978
+ tgtCcy: v.tgtCcy,
12954
12979
  px: v.px,
12955
12980
  reduceOnly: v.reduceOnly,
12956
12981
  clOrdId: v.clOrdId,