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

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
@@ -2300,14 +2300,16 @@ var OKX_INST_TYPES = [
2300
2300
  function publicRateLimit(key, rps = 20) {
2301
2301
  return {
2302
2302
  key: `public:${key}`,
2303
- capacity: rps,
2303
+ capacity: Math.max(1, rps),
2304
+ // capacity >= 1 so the token bucket can fire at least once before refilling
2304
2305
  refillPerSecond: rps
2305
2306
  };
2306
2307
  }
2307
2308
  function privateRateLimit(key, rps = 10) {
2308
2309
  return {
2309
2310
  key: `private:${key}`,
2310
- capacity: rps,
2311
+ capacity: Math.max(1, rps),
2312
+ // capacity >= 1 so the token bucket can fire at least once before refilling
2311
2313
  refillPerSecond: rps
2312
2314
  };
2313
2315
  }
@@ -9685,6 +9687,219 @@ var NEWS_DETAIL = "/api/v5/orbit/news-detail";
9685
9687
  var NEWS_DOMAINS = "/api/v5/orbit/news-platform";
9686
9688
  var SENTIMENT_QUERY = "/api/v5/orbit/currency-sentiment-query";
9687
9689
  var SENTIMENT_RANKING = "/api/v5/orbit/currency-sentiment-ranking";
9690
+ var ECONOMIC_CALENDAR = "/api/v5/public/economic-calendar";
9691
+ var CALENDAR_REGIONS = [
9692
+ "afghanistan",
9693
+ "albania",
9694
+ "algeria",
9695
+ "andorra",
9696
+ "angola",
9697
+ "antigua_and_barbuda",
9698
+ "argentina",
9699
+ "armenia",
9700
+ "aruba",
9701
+ "australia",
9702
+ "austria",
9703
+ "azerbaijan",
9704
+ "bahamas",
9705
+ "bahrain",
9706
+ "bangladesh",
9707
+ "barbados",
9708
+ "belarus",
9709
+ "belgium",
9710
+ "belize",
9711
+ "benin",
9712
+ "bermuda",
9713
+ "bhutan",
9714
+ "bolivia",
9715
+ "bosnia_and_herzegovina",
9716
+ "botswana",
9717
+ "brazil",
9718
+ "brunei",
9719
+ "bulgaria",
9720
+ "burkina_faso",
9721
+ "burundi",
9722
+ "cambodia",
9723
+ "cameroon",
9724
+ "canada",
9725
+ "cape_verde",
9726
+ "cayman_islands",
9727
+ "central_african_republic",
9728
+ "chad",
9729
+ "chile",
9730
+ "china",
9731
+ "colombia",
9732
+ "comoros",
9733
+ "congo",
9734
+ "costa_rica",
9735
+ "croatia",
9736
+ "cuba",
9737
+ "cyprus",
9738
+ "czech_republic",
9739
+ "denmark",
9740
+ "djibouti",
9741
+ "dominica",
9742
+ "dominican_republic",
9743
+ "east_timor",
9744
+ "ecuador",
9745
+ "egypt",
9746
+ "el_salvador",
9747
+ "equatorial_guinea",
9748
+ "eritrea",
9749
+ "estonia",
9750
+ "ethiopia",
9751
+ "euro_area",
9752
+ "european_union",
9753
+ "faroe_islands",
9754
+ "fiji",
9755
+ "finland",
9756
+ "france",
9757
+ "g20",
9758
+ "g7",
9759
+ "gabon",
9760
+ "gambia",
9761
+ "georgia",
9762
+ "germany",
9763
+ "ghana",
9764
+ "greece",
9765
+ "greenland",
9766
+ "grenada",
9767
+ "guatemala",
9768
+ "guinea",
9769
+ "guinea_bissau",
9770
+ "guyana",
9771
+ "haiti",
9772
+ "honduras",
9773
+ "hong_kong",
9774
+ "hungary",
9775
+ "iceland",
9776
+ "imf",
9777
+ "india",
9778
+ "indonesia",
9779
+ "iran",
9780
+ "iraq",
9781
+ "ireland",
9782
+ "isle_of_man",
9783
+ "israel",
9784
+ "italy",
9785
+ "ivory_coast",
9786
+ "jamaica",
9787
+ "japan",
9788
+ "jordan",
9789
+ "kazakhstan",
9790
+ "kenya",
9791
+ "kiribati",
9792
+ "kosovo",
9793
+ "kuwait",
9794
+ "kyrgyzstan",
9795
+ "laos",
9796
+ "latvia",
9797
+ "lebanon",
9798
+ "lesotho",
9799
+ "liberia",
9800
+ "libya",
9801
+ "liechtenstein",
9802
+ "lithuania",
9803
+ "luxembourg",
9804
+ "macau",
9805
+ "macedonia",
9806
+ "madagascar",
9807
+ "malawi",
9808
+ "malaysia",
9809
+ "maldives",
9810
+ "mali",
9811
+ "malta",
9812
+ "mauritania",
9813
+ "mauritius",
9814
+ "mexico",
9815
+ "micronesia",
9816
+ "moldova",
9817
+ "monaco",
9818
+ "mongolia",
9819
+ "montenegro",
9820
+ "morocco",
9821
+ "mozambique",
9822
+ "myanmar",
9823
+ "namibia",
9824
+ "nepal",
9825
+ "netherlands",
9826
+ "new_caledonia",
9827
+ "new_zealand",
9828
+ "nicaragua",
9829
+ "niger",
9830
+ "nigeria",
9831
+ "north_korea",
9832
+ "northern_mariana_islands",
9833
+ "norway",
9834
+ "oman",
9835
+ "opec",
9836
+ "pakistan",
9837
+ "palau",
9838
+ "palestine",
9839
+ "panama",
9840
+ "papua_new_guinea",
9841
+ "paraguay",
9842
+ "peru",
9843
+ "philippines",
9844
+ "poland",
9845
+ "portugal",
9846
+ "puerto_rico",
9847
+ "qatar",
9848
+ "republic_of_the_congo",
9849
+ "romania",
9850
+ "russia",
9851
+ "rwanda",
9852
+ "samoa",
9853
+ "san_marino",
9854
+ "sao_tome_and_principe",
9855
+ "saudi_arabia",
9856
+ "senegal",
9857
+ "serbia",
9858
+ "seychelles",
9859
+ "sierra_leone",
9860
+ "singapore",
9861
+ "slovakia",
9862
+ "slovenia",
9863
+ "solomon_islands",
9864
+ "somalia",
9865
+ "south_africa",
9866
+ "south_korea",
9867
+ "south_sudan",
9868
+ "spain",
9869
+ "sri_lanka",
9870
+ "st_kitts_and_nevis",
9871
+ "st_lucia",
9872
+ "sudan",
9873
+ "suriname",
9874
+ "swaziland",
9875
+ "sweden",
9876
+ "switzerland",
9877
+ "syria",
9878
+ "taiwan",
9879
+ "tajikistan",
9880
+ "tanzania",
9881
+ "thailand",
9882
+ "togo",
9883
+ "tonga",
9884
+ "trinidad_and_tobago",
9885
+ "tunisia",
9886
+ "turkey",
9887
+ "turkmenistan",
9888
+ "uganda",
9889
+ "ukraine",
9890
+ "united_arab_emirates",
9891
+ "united_kingdom",
9892
+ "united_states",
9893
+ "uruguay",
9894
+ "uzbekistan",
9895
+ "vanuatu",
9896
+ "venezuela",
9897
+ "vietnam",
9898
+ "world",
9899
+ "yemen",
9900
+ "zambia",
9901
+ "zimbabwe"
9902
+ ];
9688
9903
  var NEWS_LANGUAGE = ["en-US", "zh-CN"];
9689
9904
  function langHeader(lang) {
9690
9905
  if (lang === "zh-CN" || lang === "zh_CN") return { "Accept-Language": "zh-CN" };
@@ -9982,12 +10197,61 @@ function registerNewsTools() {
9982
10197
  );
9983
10198
  return normalizeResponse(response);
9984
10199
  }
10200
+ },
10201
+ // -----------------------------------------------------------------------
10202
+ // Economic calendar
10203
+ // -----------------------------------------------------------------------
10204
+ {
10205
+ name: "news_list_calendar_regions",
10206
+ module: "news",
10207
+ description: "List all valid region values for the economic calendar. Returns a string array of snake_case region codes. Call this when economic-calendar returns empty results to verify the region value, or to help the user pick a valid region. Do NOT use to list news source platforms \u2014 use news_get_domains instead.",
10208
+ isWrite: false,
10209
+ inputSchema: { type: "object", properties: {}, required: [] },
10210
+ handler: async () => ({ data: CALENDAR_REGIONS })
10211
+ },
10212
+ {
10213
+ name: "news_get_economic_calendar",
10214
+ module: "news",
10215
+ description: "Get macro-economic calendar data (GDP, CPI, NFP, interest rate decisions, PMI, etc.). Returns scheduled and released economic events with forecast, previous, and actual values. Use when user asks about economic calendar, macro data, or specific indicators like NFP/CPI/GDP/FOMC. Do NOT use for news articles or sentiment \u2014 use news_get_latest or news_search instead.",
10216
+ isWrite: false,
10217
+ inputSchema: {
10218
+ type: "object",
10219
+ properties: {
10220
+ region: { type: "string", description: "Country/region filter in snake_case (e.g. united_states, euro_area, japan). Invalid values return empty results silently. If empty results, call news_list_calendar_regions to verify the value." },
10221
+ importance: { type: "string", enum: ["1", "2", "3"], description: "Importance level: 1=low, 2=medium, 3=high. Omit for all levels." },
10222
+ before: { type: "string", description: "Lower time bound \u2014 returns events NEWER than this timestamp (reversed semantics). Pair with 'after' for future-event windows. Unix ms." },
10223
+ after: { type: "string", description: "Upper time bound \u2014 returns events OLDER than this timestamp (reversed semantics). Default=now (returns past events). Pair with 'before' for a bounded window. Unix ms." },
10224
+ limit: { type: "number", minimum: 1, maximum: 100, description: "Number of results (default 100, max 100)." }
10225
+ },
10226
+ required: []
10227
+ },
10228
+ handler: async (rawArgs, context) => {
10229
+ const args = asRecord(rawArgs);
10230
+ const rawLimit = readNumber(args, "limit");
10231
+ const limit = rawLimit !== void 0 ? Math.min(rawLimit, 100) : void 0;
10232
+ const response = await context.client.privateGet(
10233
+ ECONOMIC_CALENDAR,
10234
+ compactObject({
10235
+ region: readString(args, "region"),
10236
+ importance: readString(args, "importance"),
10237
+ before: readString(args, "before"),
10238
+ after: readString(args, "after"),
10239
+ limit
10240
+ }),
10241
+ publicRateLimit("news_get_economic_calendar", 0.2)
10242
+ );
10243
+ return normalizeResponse(response);
10244
+ }
9985
10245
  }
9986
10246
  ];
9987
- const domainsIdx = tools.findIndex((t) => t.name === "news_get_domains");
9988
- if (domainsIdx === -1) throw new Error("news_get_domains not found in tools list");
9989
- const [domainsTool] = tools.splice(domainsIdx, 1);
9990
- return [...tools.map(withNewsDemoGuard), domainsTool];
10247
+ const exempt = /* @__PURE__ */ new Set(["news_get_domains", "news_list_calendar_regions"]);
10248
+ const exempted = [];
10249
+ const guarded = [];
10250
+ for (const t of tools) {
10251
+ if (exempt.has(t.name)) exempted.push(t);
10252
+ else guarded.push(t);
10253
+ }
10254
+ return [...guarded.map(withNewsDemoGuard), ...exempted];
9991
10255
  }
9992
10256
  var NEWS_DEMO_MESSAGE = "News features are not available in demo/simulated trading mode.";
9993
10257
  var NEWS_DEMO_SUGGESTION = "Switch to a live profile to use News features.";
@@ -13487,7 +13751,7 @@ async function cmdDiagnoseMcp(options = {}) {
13487
13751
 
13488
13752
  // src/commands/diagnose.ts
13489
13753
  var CLI_VERSION = readCliVersion();
13490
- var GIT_HASH = true ? "3247f9a2" : "dev";
13754
+ var GIT_HASH = true ? "cd99d487" : "dev";
13491
13755
  function maskKey2(key) {
13492
13756
  if (!key) return "(not set)";
13493
13757
  if (key.length <= 8) return "****";
@@ -14943,6 +15207,16 @@ var CLI_REGISTRY = {
14943
15207
  "sentiment-rank": {
14944
15208
  toolName: "news_get_sentiment_ranking",
14945
15209
  usage: "okx news sentiment-rank [--period 24h] [--sort-by 0] [--limit 20]"
15210
+ },
15211
+ "economic-calendar": {
15212
+ toolName: "news_get_economic_calendar",
15213
+ usage: "okx news economic-calendar [--region <country>] [--importance <1|2|3>] [--before <ms>] [--after <ms>] [--limit <n>]",
15214
+ description: "Get macro-economic calendar data (GDP, CPI, NFP, FOMC, etc.)"
15215
+ },
15216
+ "list-regions": {
15217
+ toolName: "news_list_calendar_regions",
15218
+ usage: "okx news list-regions",
15219
+ description: "List all valid --region values for economic-calendar"
14946
15220
  }
14947
15221
  }
14948
15222
  },
@@ -15353,6 +15627,49 @@ async function cmdNewsSentimentRank(run, opts) {
15353
15627
  })
15354
15628
  );
15355
15629
  }
15630
+ async function cmdNewsEconomicCalendar(run, opts) {
15631
+ if (!opts.json && opts.limit !== void 0 && opts.limit > 100) {
15632
+ errorLine(`Warning: --limit ${opts.limit} exceeds API max 100, capped to 100`);
15633
+ }
15634
+ const result = await run("news_get_economic_calendar", {
15635
+ region: opts.region,
15636
+ importance: opts.importance,
15637
+ before: opts.before,
15638
+ after: opts.after,
15639
+ limit: opts.limit !== void 0 ? Math.min(opts.limit, 100) : void 0
15640
+ });
15641
+ const items = getData(result) ?? [];
15642
+ if (opts.json) return printJson(items);
15643
+ printTable(
15644
+ items.map((e) => {
15645
+ const unit = String(e["unit"] ?? "").trim();
15646
+ const appendUnit = (v) => {
15647
+ const s = String(v ?? "");
15648
+ if (!s || s === "-") return s || "-";
15649
+ if (unit && !s.includes(unit)) return `${s} ${unit}`;
15650
+ return s;
15651
+ };
15652
+ return {
15653
+ time: formatTime(e["date"]),
15654
+ region: e["region"],
15655
+ category: e["category"] || "-",
15656
+ event: String(e["event"] ?? "").slice(0, 50),
15657
+ importance: e["importance"] === "3" ? "HIGH" : e["importance"] === "2" ? "MED" : "LOW",
15658
+ refDate: formatTime(e["refDate"]),
15659
+ forecast: appendUnit(e["forecast"] ?? "-"),
15660
+ previous: appendUnit(e["previous"] ?? "-"),
15661
+ actual: e["actual"] ? appendUnit(e["actual"]) : "(pending)"
15662
+ };
15663
+ })
15664
+ );
15665
+ }
15666
+ async function cmdNewsListCalendarRegions(run, opts) {
15667
+ const result = await run("news_list_calendar_regions", {});
15668
+ const regions = result.data;
15669
+ if (opts.json) return printJson(regions);
15670
+ outputLine(`Valid economic-calendar regions (${regions.length}):`);
15671
+ outputLine(regions.join(", "));
15672
+ }
15356
15673
 
15357
15674
  // src/config/loader.ts
15358
15675
  async function loadProfileConfig(opts) {
@@ -15466,6 +15783,12 @@ function printSubgroupHelp(moduleName, subgroupName) {
15466
15783
  }
15467
15784
  const subgroup = group.subgroups?.[subgroupName];
15468
15785
  if (!subgroup) {
15786
+ const cmd = group.commands?.[subgroupName];
15787
+ if (cmd) {
15788
+ const lines2 = ["", ` ${cmd.description}`, ` Usage: ${cmd.usage}`, ""];
15789
+ output(lines2.join(EOL2));
15790
+ return;
15791
+ }
15469
15792
  errorLine(`Unknown subgroup: ${moduleName} ${subgroupName}`);
15470
15793
  process.exitCode = 1;
15471
15794
  return;
@@ -15718,6 +16041,7 @@ var CLI_OPTIONS = {
15718
16041
  period: { type: "string" },
15719
16042
  points: { type: "string" },
15720
16043
  "sort-by": { type: "string" },
16044
+ region: { type: "string" },
15721
16045
  // skill marketplace
15722
16046
  categories: { type: "string" },
15723
16047
  dir: { type: "string" },
@@ -19973,7 +20297,7 @@ async function cmdEventCancel(run, opts) {
19973
20297
  // src/index.ts
19974
20298
  var _require3 = createRequire3(import.meta.url);
19975
20299
  var CLI_VERSION2 = _require3("../package.json").version;
19976
- var GIT_HASH2 = true ? "3247f9a2" : "dev";
20300
+ var GIT_HASH2 = true ? "cd99d487" : "dev";
19977
20301
  function handlePilotCommand(action, json, force, binaryPath) {
19978
20302
  if (action === "status") return cmdPilotStatus(json, binaryPath);
19979
20303
  if (action === "install") return cmdPilotInstall(json, binaryPath);
@@ -21256,7 +21580,9 @@ function handleNewsCommand(run, action, rest, v, json) {
21256
21580
  const opts = { ...searchOpts, sortBy: sortBy ?? "latest" };
21257
21581
  return cmdNewsSearch(run, "", opts);
21258
21582
  },
21259
- "sentiment-rank": () => cmdNewsSentimentRank(run, { period, sortBy, limit, json })
21583
+ "sentiment-rank": () => cmdNewsSentimentRank(run, { period, sortBy, limit, json }),
21584
+ "economic-calendar": () => cmdNewsEconomicCalendar(run, { region: v.region, importance: v.importance, before: v.before, after, limit, json }),
21585
+ "list-regions": () => cmdNewsListCalendarRegions(run, { json })
21260
21586
  };
21261
21587
  const handler = dispatch[action];
21262
21588
  if (handler) return handler();