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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2506,6 +2506,56 @@ function resolveIndicatorCode(name) {
2506
2506
  const lower = name.toLowerCase();
2507
2507
  return INDICATOR_CODE_OVERRIDES[lower] ?? name.toUpperCase().replace(/-/g, "_");
2508
2508
  }
2509
+ var DEFAULT_INDICATOR_PARAMS = {
2510
+ // Moving Averages — PRD example default is [14]
2511
+ ma: [14],
2512
+ ema: [14],
2513
+ wma: [14],
2514
+ dema: [14],
2515
+ tema: [14],
2516
+ zlema: [14],
2517
+ hma: [14],
2518
+ kama: [14],
2519
+ // Trend
2520
+ macd: [12, 26, 9],
2521
+ adx: [14],
2522
+ aroon: [14],
2523
+ cci: [20],
2524
+ dpo: [20],
2525
+ // Momentum
2526
+ rsi: [14],
2527
+ "stoch-rsi": [14],
2528
+ stoch: [14, 3, 3],
2529
+ roc: [12],
2530
+ mom: [10],
2531
+ ppo: [12, 26, 9],
2532
+ trix: [15],
2533
+ uo: [7, 14, 28],
2534
+ wr: [14],
2535
+ // Volatility
2536
+ bb: [20, 2],
2537
+ bbwidth: [20, 2],
2538
+ bbpct: [20, 2],
2539
+ atr: [14],
2540
+ keltner: [20, 2],
2541
+ donchian: [20],
2542
+ hv: [20],
2543
+ stddev: [20],
2544
+ // Volume
2545
+ mvwap: [20],
2546
+ cmf: [20],
2547
+ mfi: [14],
2548
+ // Custom
2549
+ kdj: [9, 3, 3],
2550
+ supertrend: [10, 3]
2551
+ };
2552
+ function getDefaultIndicatorParams(name) {
2553
+ const lower = name.toLowerCase();
2554
+ const direct = DEFAULT_INDICATOR_PARAMS[lower];
2555
+ if (direct !== void 0) return direct;
2556
+ const code = resolveIndicatorCode(lower);
2557
+ return DEFAULT_INDICATOR_PARAMS[code.toLowerCase()];
2558
+ }
2509
2559
  function validateIndicatorName(name) {
2510
2560
  const lower = name.toLowerCase();
2511
2561
  if (VALID_INDICATOR_NAMES.has(lower)) return;
@@ -2549,7 +2599,7 @@ function registerIndicatorTools() {
2549
2599
  params: {
2550
2600
  type: "array",
2551
2601
  items: { type: "number" },
2552
- description: "Indicator-specific parameters as a number array. Examples: MA/EMA [14] (period), MACD [12,26,9] (fast,slow,signal), BB [20,2] (period,stdDev), RSI [14] (period). Omit to use server defaults."
2602
+ description: "Indicator-specific parameters as a number array. Examples: MA/EMA [14] (period), MACD [12,26,9] (fast,slow,signal), BB [20,2] (period,stdDev), RSI [14] (period). For period-based indicators a parameter is required; the CLI applies a sensible default when omitted."
2553
2603
  },
2554
2604
  returnList: {
2555
2605
  type: "boolean",
@@ -2650,7 +2700,6 @@ var MODULES = [
2650
2700
  "event",
2651
2701
  "news",
2652
2702
  "smartmoney",
2653
- "outcomes",
2654
2703
  ...EARN_SUB_MODULE_IDS,
2655
2704
  ...BOT_SUB_MODULE_IDS,
2656
2705
  "skills"
@@ -2674,7 +2723,6 @@ var MODULE_DESCRIPTIONS = {
2674
2723
  "bot.dca": "DCA (Martingale) bot - spot or contract recurring buys",
2675
2724
  news: "Crypto news, sentiment analysis, and coin trend tracking",
2676
2725
  smartmoney: "Smart money signals - trader leaderboard, consensus signals, and position analysis",
2677
- outcomes: "Prediction markets - binary YES/NO event contracts (browse, search, CLOB, account)",
2678
2726
  skills: SKILLS_MARKETPLACE_DESC,
2679
2727
  earn: "Earn products - Simple Earn, On-chain Earn, DCD, Flash Earn, and Auto-Earn",
2680
2728
  bot: "Trading bot strategies (grid, dca)",
@@ -8654,706 +8702,6 @@ function registerSmartmoneyTools() {
8654
8702
  ];
8655
8703
  return tools;
8656
8704
  }
8657
- function toNum(v) {
8658
- if (v === void 0 || v === null || v === "") return void 0;
8659
- const n = Number(v);
8660
- return Number.isFinite(n) ? n : void 0;
8661
- }
8662
- function decimalPlaces(v) {
8663
- if (v === void 0 || v === null || v === "") return 0;
8664
- const s = String(v);
8665
- const dot = s.indexOf(".");
8666
- return dot < 0 ? 0 : s.length - dot - 1;
8667
- }
8668
- function fmtFixed(n, places) {
8669
- return n.toFixed(places);
8670
- }
8671
- function deriveTickerView(ticker, outcome) {
8672
- const bidNum = toNum(ticker.bidPx);
8673
- const askNum = toNum(ticker.askPx);
8674
- const lastStr = ticker.last !== void 0 ? String(ticker.last) : void 0;
8675
- const bidPlaces = decimalPlaces(ticker.bidPx);
8676
- const askPlaces = decimalPlaces(ticker.askPx);
8677
- const maxPlaces = Math.max(bidPlaces, askPlaces);
8678
- const bidStr = bidNum !== void 0 ? fmtFixed(bidNum, bidPlaces) : void 0;
8679
- const askStr = askNum !== void 0 ? fmtFixed(askNum, askPlaces) : void 0;
8680
- const view = { last: lastStr, bidPx: bidStr, askPx: askStr };
8681
- if (bidNum !== void 0 && askNum !== void 0) {
8682
- view.midpoint = fmtFixed((bidNum + askNum) / 2, maxPlaces);
8683
- view.spread = fmtFixed(askNum - bidNum, maxPlaces);
8684
- }
8685
- if (outcome !== void 0 && askNum !== void 0) {
8686
- const outcomeLower = outcome.toLowerCase();
8687
- if (outcomeLower === "yes") {
8688
- view.derivedPrice = fmtFixed(askNum, askPlaces);
8689
- } else if (outcomeLower === "no") {
8690
- view.derivedPrice = fmtFixed(1 - askNum, askPlaces);
8691
- }
8692
- }
8693
- return view;
8694
- }
8695
- var PATH_EVENTS = "/api/v5/predictions/events";
8696
- var PATH_EVENTS_SEARCH = "/api/v5/predictions/events/search";
8697
- var PATH_MARKETS = "/api/v5/predictions/markets";
8698
- var PATH_BALANCE = "/api/v5/predictions/balance";
8699
- var PATH_ORDERS = "/api/v5/predictions/orders";
8700
- var PATH_POSITIONS = "/api/v5/predictions/positions";
8701
- var PATH_TRADES = "/api/v5/predictions/trades";
8702
- var PATH_TICKER = "/api/v5/market/ticker";
8703
- var PATH_CANDLES = "/api/v5/market/candles";
8704
- var PATH_PM_BOOKS = "/api/v5/market/pm-books";
8705
- var OUTCOMES_RPS = 10;
8706
- function requireString2(args, key, label) {
8707
- const v = readString(args, key);
8708
- if (!v) throw new Error(`${label} is required`);
8709
- return v;
8710
- }
8711
- function pathSegment(id) {
8712
- return encodeURIComponent(id);
8713
- }
8714
- async function runBatchQuery(ids, fn) {
8715
- if (ids.length === 0) {
8716
- throw new Error("At least one ID is required");
8717
- }
8718
- const results = await Promise.allSettled(ids.map((id) => fn(id)));
8719
- return results.map((result, i) => {
8720
- const id = ids[i];
8721
- if (result.status === "fulfilled") {
8722
- return { id, data: result.value };
8723
- }
8724
- const errMsg = result.reason instanceof Error ? result.reason.message : String(result.reason);
8725
- return { id, error: errMsg };
8726
- });
8727
- }
8728
- function registerOutcomesTools() {
8729
- const tools = [
8730
- /* ================================================================ */
8731
- /* DATA MODULE (7) */
8732
- /* ================================================================ */
8733
- /* D1. List events */
8734
- {
8735
- name: "outcomes_get_events",
8736
- title: "List Prediction Events",
8737
- module: "outcomes",
8738
- description: "List available prediction (binary outcomes) events on OKX, optionally filtered by status, category, tag, league, sort, or cursor. Use when: discovering events to trade on. Default limit 20. See also: `outcomes_get_trending_events` (no args, server-chosen trending events), `outcomes_search_events` (keyword search).",
8739
- isWrite: false,
8740
- inputSchema: {
8741
- type: "object",
8742
- properties: {
8743
- status: { type: "string", description: "Filter by event status, e.g. `active` | `closed` | `settled`." },
8744
- category: { type: "string", description: "Event category, e.g. `crypto` | `sports` | `politics`." },
8745
- tag: { type: "string", description: "Event tag for further classification." },
8746
- league: { type: "string", description: "League / competition name for sports events." },
8747
- sort: { type: "string", description: "Sort key, e.g. `trending` | `newest`." },
8748
- cursor: { type: "string", description: "Pagination cursor from previous response." },
8749
- limit: { type: "integer", minimum: 1, maximum: 100, default: 20, description: "Max results (default 20)." }
8750
- }
8751
- },
8752
- handler: async (rawArgs, context) => {
8753
- const args = asRecord(rawArgs);
8754
- const response = await context.client.privateGet(
8755
- PATH_EVENTS,
8756
- compactObject({
8757
- status: readString(args, "status"),
8758
- category: readString(args, "category"),
8759
- tag: readString(args, "tag"),
8760
- league: readString(args, "league"),
8761
- sort: readString(args, "sort"),
8762
- cursor: readString(args, "cursor"),
8763
- limit: readNumber(args, "limit") ?? 20
8764
- }),
8765
- privateRateLimit("outcomes_get_events", OUTCOMES_RPS)
8766
- );
8767
- return normalizeResponse(response);
8768
- }
8769
- },
8770
- /* D2. Get event detail */
8771
- {
8772
- name: "outcomes_get_event_detail",
8773
- title: "Get Prediction Event Detail",
8774
- module: "outcomes",
8775
- description: "Get full detail of a single prediction event by its ID, including description, resolution criteria, and linked markets. Use when: inspecting a specific event before trading.",
8776
- isWrite: false,
8777
- inputSchema: {
8778
- type: "object",
8779
- properties: {
8780
- id: { type: "string", description: "Event ID, e.g. from `outcomes_get_events` results." }
8781
- },
8782
- required: ["id"]
8783
- },
8784
- handler: async (rawArgs, context) => {
8785
- const args = asRecord(rawArgs);
8786
- const id = requireString2(args, "id", "Event ID");
8787
- const response = await context.client.privateGet(
8788
- `${PATH_EVENTS}/${pathSegment(id)}`,
8789
- {},
8790
- privateRateLimit("outcomes_get_event_detail", OUTCOMES_RPS)
8791
- );
8792
- return normalizeResponse(response);
8793
- }
8794
- },
8795
- /* D3. Get event markets */
8796
- {
8797
- name: "outcomes_get_event_markets",
8798
- title: "Get Markets for a Prediction Event",
8799
- module: "outcomes",
8800
- description: "Get all tradable markets for a prediction event. Each market corresponds to a binary outcome (YES/NO). Use when: listing which outcomes are available to trade for an event. See also: `outcomes_get_market_detail` (single market by market ID).",
8801
- isWrite: false,
8802
- inputSchema: {
8803
- type: "object",
8804
- properties: {
8805
- id: { type: "string", description: "Event ID." }
8806
- },
8807
- required: ["id"]
8808
- },
8809
- handler: async (rawArgs, context) => {
8810
- const args = asRecord(rawArgs);
8811
- const id = requireString2(args, "id", "Event ID");
8812
- const response = await context.client.privateGet(
8813
- `${PATH_EVENTS}/${pathSegment(id)}/markets`,
8814
- {},
8815
- privateRateLimit("outcomes_get_event_markets", OUTCOMES_RPS)
8816
- );
8817
- return normalizeResponse(response);
8818
- }
8819
- },
8820
- /* D4. Get market detail */
8821
- {
8822
- name: "outcomes_get_market_detail",
8823
- title: "Get Prediction Market Detail",
8824
- module: "outcomes",
8825
- description: "Get full detail of a single prediction market by its market ID (e.g. current probability, settlement info, linked event). Use when: inspecting a specific binary market before placing an order.",
8826
- isWrite: false,
8827
- inputSchema: {
8828
- type: "object",
8829
- properties: {
8830
- id: { type: "string", description: "Market ID." }
8831
- },
8832
- required: ["id"]
8833
- },
8834
- handler: async (rawArgs, context) => {
8835
- const args = asRecord(rawArgs);
8836
- const id = requireString2(args, "id", "Market ID");
8837
- const response = await context.client.privateGet(
8838
- `${PATH_MARKETS}/${pathSegment(id)}`,
8839
- {},
8840
- privateRateLimit("outcomes_get_market_detail", OUTCOMES_RPS)
8841
- );
8842
- return normalizeResponse(response);
8843
- }
8844
- },
8845
- /* D5. Trending events (alias of events, server defaults sort) */
8846
- {
8847
- name: "outcomes_get_trending_events",
8848
- title: "Get Trending Prediction Events",
8849
- module: "outcomes",
8850
- description: "Get trending prediction events \u2014 server-selected, most-active events. Equivalent to `outcomes_get_events` with no sort parameter; the server applies its trending algorithm. Use when: user asks for 'what's hot / trending' in predictions. See also: `outcomes_get_events` (full filter support).",
8851
- isWrite: false,
8852
- inputSchema: {
8853
- type: "object",
8854
- properties: {
8855
- cursor: { type: "string", description: "Pagination cursor." },
8856
- limit: { type: "integer", minimum: 1, maximum: 100, default: 20, description: "Max results (default 20)." }
8857
- }
8858
- },
8859
- handler: async (rawArgs, context) => {
8860
- const args = asRecord(rawArgs);
8861
- const response = await context.client.privateGet(
8862
- PATH_EVENTS,
8863
- compactObject({
8864
- cursor: readString(args, "cursor"),
8865
- limit: readNumber(args, "limit") ?? 20
8866
- }),
8867
- privateRateLimit("outcomes_get_trending_events", OUTCOMES_RPS)
8868
- );
8869
- return normalizeResponse(response);
8870
- }
8871
- },
8872
- /* D6. Get ticker */
8873
- {
8874
- name: "outcomes_get_ticker",
8875
- title: "Get Prediction Asset Ticker",
8876
- module: "outcomes",
8877
- description: "Get the current ticker (last traded price, best bid/ask, volume) for a prediction market asset ID. Use when: checking the latest price for a prediction market instrument. Returns the full raw ticker \u2014 use `outcomes_get_market_price` for outcome-derived pricing.",
8878
- isWrite: false,
8879
- inputSchema: {
8880
- type: "object",
8881
- properties: {
8882
- assetId: { type: "string", description: "Prediction asset instrument ID, e.g. `BTC-USD-PRED`." }
8883
- },
8884
- required: ["assetId"]
8885
- },
8886
- handler: async (rawArgs, context) => {
8887
- const args = asRecord(rawArgs);
8888
- const assetId = readString(args, "assetId") ?? "";
8889
- const response = await context.client.privateGet(
8890
- PATH_TICKER,
8891
- { instId: assetId },
8892
- privateRateLimit("outcomes_get_ticker", OUTCOMES_RPS)
8893
- );
8894
- return normalizeResponse(response);
8895
- }
8896
- },
8897
- /* D7. Get candles */
8898
- {
8899
- name: "outcomes_get_candles",
8900
- title: "Get Prediction Asset Candles",
8901
- module: "outcomes",
8902
- description: "Get OHLCV candlestick data for a prediction asset. OKX pagination convention: `after` returns candles with timestamp BEFORE the cursor; `before` returns candles AFTER. Use when: charting or analysing price history of a prediction market instrument.",
8903
- isWrite: false,
8904
- inputSchema: {
8905
- type: "object",
8906
- properties: {
8907
- assetId: { type: "string", description: "Prediction asset instrument ID." },
8908
- bar: { type: "string", enum: ["1m", "5m", "15m", "30m", "1H", "4H", "1D"], description: "Candlestick bar size (default `1m`)." },
8909
- after: { type: "string", description: "Pagination cursor \u2014 returns candles with ts BEFORE this value." },
8910
- before: { type: "string", description: "Pagination cursor \u2014 returns candles with ts AFTER this value." },
8911
- limit: { type: "integer", minimum: 1, maximum: 300, default: 100, description: "Max candles (default 100)." }
8912
- },
8913
- required: ["assetId"]
8914
- },
8915
- handler: async (rawArgs, context) => {
8916
- const args = asRecord(rawArgs);
8917
- const assetId = readString(args, "assetId") ?? "";
8918
- const response = await context.client.privateGet(
8919
- PATH_CANDLES,
8920
- compactObject({
8921
- instId: assetId,
8922
- bar: readString(args, "bar"),
8923
- after: readString(args, "after"),
8924
- before: readString(args, "before"),
8925
- limit: readNumber(args, "limit") ?? 100
8926
- }),
8927
- privateRateLimit("outcomes_get_candles", OUTCOMES_RPS)
8928
- );
8929
- return normalizeResponse(response);
8930
- }
8931
- },
8932
- /* ================================================================ */
8933
- /* SEARCH MODULE (1) */
8934
- /* ================================================================ */
8935
- /* S1. Search events */
8936
- {
8937
- name: "outcomes_search_events",
8938
- title: "Search Prediction Events",
8939
- module: "outcomes",
8940
- description: "Search prediction events by keyword. Returns events matching the keyword in title, description, or tags. Use when: user asks about a specific topic (e.g. 'Will BTC hit 100k?', 'US election'). See also: `outcomes_get_events` (full browse), `outcomes_get_trending_events` (trending).",
8941
- isWrite: false,
8942
- inputSchema: {
8943
- type: "object",
8944
- properties: {
8945
- keyword: { type: "string", description: "Search keyword." },
8946
- cursor: { type: "string", description: "Pagination cursor." },
8947
- limit: { type: "integer", minimum: 1, maximum: 100, default: 20, description: "Max results (default 20)." }
8948
- },
8949
- required: ["keyword"]
8950
- },
8951
- handler: async (rawArgs, context) => {
8952
- const args = asRecord(rawArgs);
8953
- const response = await context.client.privateGet(
8954
- PATH_EVENTS_SEARCH,
8955
- compactObject({
8956
- keyword: readString(args, "keyword"),
8957
- cursor: readString(args, "cursor"),
8958
- limit: readNumber(args, "limit") ?? 20
8959
- }),
8960
- privateRateLimit("outcomes_search_events", OUTCOMES_RPS)
8961
- );
8962
- return normalizeResponse(response);
8963
- }
8964
- },
8965
- /* ================================================================ */
8966
- /* CLOB MODULE (8) */
8967
- /* 6 of these call /api/v5/market/ticker with client-side derive. */
8968
- /* 2 (book/books) call /api/v5/market/pm-books. */
8969
- /* ================================================================ */
8970
- /* C1. Market price (single) */
8971
- {
8972
- name: "outcomes_get_market_price",
8973
- title: "Get Prediction Market Price",
8974
- module: "outcomes",
8975
- description: "Get the derived trading price for a binary prediction market outcome (YES or NO side). Internally fetches the ticker and derives the best-ask for the specified outcome. Use `outcome=yes` for YES side, `outcome=no` for NO side. See also: `outcomes_get_market_prices` (batch), `outcomes_get_market_midpoint` (mid price).",
8976
- isWrite: false,
8977
- inputSchema: {
8978
- type: "object",
8979
- properties: {
8980
- mktId: { type: "string", description: "Market instrument ID." },
8981
- outcome: { type: "string", enum: ["yes", "no"], description: "Which outcome side: `yes` or `no`." }
8982
- },
8983
- required: ["mktId"]
8984
- },
8985
- handler: async (rawArgs, context) => {
8986
- const args = asRecord(rawArgs);
8987
- const mktId = readString(args, "mktId") ?? "";
8988
- const outcome = readString(args, "outcome");
8989
- const response = await context.client.privateGet(
8990
- PATH_TICKER,
8991
- { instId: mktId },
8992
- privateRateLimit("outcomes_get_market_price", OUTCOMES_RPS)
8993
- );
8994
- const normalized = normalizeResponse(response);
8995
- const ticker = Array.isArray(normalized.data) && normalized.data.length > 0 ? normalized.data[0] : {};
8996
- const view = deriveTickerView(ticker, outcome);
8997
- return { ...normalized, data: { ...ticker, ...view } };
8998
- }
8999
- },
9000
- /* C2. Market prices (batch) */
9001
- {
9002
- name: "outcomes_get_market_prices",
9003
- title: "Get Prediction Market Prices (Batch)",
9004
- module: "outcomes",
9005
- description: "Get derived trading prices for multiple prediction market IDs in parallel. Per-row error isolation: if any single market fails, only that row has an `error` field; the rest succeed normally. See also: `outcomes_get_market_price` (single market), `outcomes_get_market_midpoints` (batch midpoints).",
9006
- isWrite: false,
9007
- inputSchema: {
9008
- type: "object",
9009
- properties: {
9010
- ids: { type: "array", items: { type: "string" }, description: "List of market instrument IDs." },
9011
- outcome: { type: "string", enum: ["yes", "no"], description: "Outcome side for price derivation." }
9012
- },
9013
- required: ["ids"]
9014
- },
9015
- handler: async (rawArgs, context) => {
9016
- const args = asRecord(rawArgs);
9017
- const ids = Array.isArray(args["ids"]) ? args["ids"] : [];
9018
- const outcome = readString(args, "outcome");
9019
- const rows = await runBatchQuery(ids, async (id) => {
9020
- const response = await context.client.privateGet(
9021
- PATH_TICKER,
9022
- { instId: id },
9023
- privateRateLimit("outcomes_get_market_prices", OUTCOMES_RPS)
9024
- );
9025
- const normalized = normalizeResponse(response);
9026
- const ticker = Array.isArray(normalized.data) && normalized.data.length > 0 ? normalized.data[0] : {};
9027
- return { ...ticker, ...deriveTickerView(ticker, outcome) };
9028
- });
9029
- return {
9030
- endpoint: PATH_TICKER,
9031
- requestTime: (/* @__PURE__ */ new Date()).toISOString(),
9032
- data: rows
9033
- };
9034
- }
9035
- },
9036
- /* C3. Market midpoint (single) */
9037
- {
9038
- name: "outcomes_get_market_midpoint",
9039
- title: "Get Prediction Market Midpoint",
9040
- module: "outcomes",
9041
- description: "Get the midpoint price for a prediction market: (bidPx + askPx) / 2. Use when: estimating the fair mid-market price. See also: `outcomes_get_market_midpoints` (batch), `outcomes_get_market_spread` (bid-ask spread).",
9042
- isWrite: false,
9043
- inputSchema: {
9044
- type: "object",
9045
- properties: {
9046
- mktId: { type: "string", description: "Market instrument ID." }
9047
- },
9048
- required: ["mktId"]
9049
- },
9050
- handler: async (rawArgs, context) => {
9051
- const args = asRecord(rawArgs);
9052
- const mktId = readString(args, "mktId") ?? "";
9053
- const response = await context.client.privateGet(
9054
- PATH_TICKER,
9055
- { instId: mktId },
9056
- privateRateLimit("outcomes_get_market_midpoint", OUTCOMES_RPS)
9057
- );
9058
- const normalized = normalizeResponse(response);
9059
- const ticker = Array.isArray(normalized.data) && normalized.data.length > 0 ? normalized.data[0] : {};
9060
- const view = deriveTickerView(ticker, void 0);
9061
- return { ...normalized, data: { ...ticker, ...view } };
9062
- }
9063
- },
9064
- /* C4. Market midpoints (batch) */
9065
- {
9066
- name: "outcomes_get_market_midpoints",
9067
- title: "Get Prediction Market Midpoints (Batch)",
9068
- module: "outcomes",
9069
- description: "Get midpoint prices for multiple prediction markets in parallel. Per-row error isolation. See also: `outcomes_get_market_midpoint` (single), `outcomes_get_market_spreads` (batch spreads).",
9070
- isWrite: false,
9071
- inputSchema: {
9072
- type: "object",
9073
- properties: {
9074
- ids: { type: "array", items: { type: "string" }, description: "List of market instrument IDs." }
9075
- },
9076
- required: ["ids"]
9077
- },
9078
- handler: async (rawArgs, context) => {
9079
- const args = asRecord(rawArgs);
9080
- const ids = Array.isArray(args["ids"]) ? args["ids"] : [];
9081
- const rows = await runBatchQuery(ids, async (id) => {
9082
- const response = await context.client.privateGet(
9083
- PATH_TICKER,
9084
- { instId: id },
9085
- privateRateLimit("outcomes_get_market_midpoints", OUTCOMES_RPS)
9086
- );
9087
- const normalized = normalizeResponse(response);
9088
- const ticker = Array.isArray(normalized.data) && normalized.data.length > 0 ? normalized.data[0] : {};
9089
- return { ...ticker, ...deriveTickerView(ticker, void 0) };
9090
- });
9091
- return {
9092
- endpoint: PATH_TICKER,
9093
- requestTime: (/* @__PURE__ */ new Date()).toISOString(),
9094
- data: rows
9095
- };
9096
- }
9097
- },
9098
- /* C5. Market spread (single) */
9099
- {
9100
- name: "outcomes_get_market_spread",
9101
- title: "Get Prediction Market Spread",
9102
- module: "outcomes",
9103
- description: "Get the bid-ask spread for a prediction market: askPx - bidPx. Use when: assessing liquidity or trading cost. See also: `outcomes_get_market_spreads` (batch), `outcomes_get_market_midpoint` (midpoint price).",
9104
- isWrite: false,
9105
- inputSchema: {
9106
- type: "object",
9107
- properties: {
9108
- mktId: { type: "string", description: "Market instrument ID." }
9109
- },
9110
- required: ["mktId"]
9111
- },
9112
- handler: async (rawArgs, context) => {
9113
- const args = asRecord(rawArgs);
9114
- const mktId = readString(args, "mktId") ?? "";
9115
- const response = await context.client.privateGet(
9116
- PATH_TICKER,
9117
- { instId: mktId },
9118
- privateRateLimit("outcomes_get_market_spread", OUTCOMES_RPS)
9119
- );
9120
- const normalized = normalizeResponse(response);
9121
- const ticker = Array.isArray(normalized.data) && normalized.data.length > 0 ? normalized.data[0] : {};
9122
- const view = deriveTickerView(ticker, void 0);
9123
- return { ...normalized, data: { ...ticker, ...view } };
9124
- }
9125
- },
9126
- /* C6. Market spreads (batch) */
9127
- {
9128
- name: "outcomes_get_market_spreads",
9129
- title: "Get Prediction Market Spreads (Batch)",
9130
- module: "outcomes",
9131
- description: "Get bid-ask spreads for multiple prediction markets in parallel. Per-row error isolation. See also: `outcomes_get_market_spread` (single), `outcomes_get_market_midpoints` (batch midpoints).",
9132
- isWrite: false,
9133
- inputSchema: {
9134
- type: "object",
9135
- properties: {
9136
- ids: { type: "array", items: { type: "string" }, description: "List of market instrument IDs." }
9137
- },
9138
- required: ["ids"]
9139
- },
9140
- handler: async (rawArgs, context) => {
9141
- const args = asRecord(rawArgs);
9142
- const ids = Array.isArray(args["ids"]) ? args["ids"] : [];
9143
- const rows = await runBatchQuery(ids, async (id) => {
9144
- const response = await context.client.privateGet(
9145
- PATH_TICKER,
9146
- { instId: id },
9147
- privateRateLimit("outcomes_get_market_spreads", OUTCOMES_RPS)
9148
- );
9149
- const normalized = normalizeResponse(response);
9150
- const ticker = Array.isArray(normalized.data) && normalized.data.length > 0 ? normalized.data[0] : {};
9151
- return { ...ticker, ...deriveTickerView(ticker, void 0) };
9152
- });
9153
- return {
9154
- endpoint: PATH_TICKER,
9155
- requestTime: (/* @__PURE__ */ new Date()).toISOString(),
9156
- data: rows
9157
- };
9158
- }
9159
- },
9160
- /* C7. Order book (single) */
9161
- {
9162
- name: "outcomes_get_order_book",
9163
- title: "Get Prediction Market Order Book",
9164
- module: "outcomes",
9165
- description: "Get the CLOB order book (bids and asks) for a prediction market. Use when: examining market depth before a limit order. See also: `outcomes_get_order_books` (batch).",
9166
- isWrite: false,
9167
- inputSchema: {
9168
- type: "object",
9169
- properties: {
9170
- mktId: { type: "string", description: "Market instrument ID." },
9171
- sz: { type: "integer", minimum: 1, maximum: 400, description: "Order book depth (levels to return)." }
9172
- },
9173
- required: ["mktId"]
9174
- },
9175
- handler: async (rawArgs, context) => {
9176
- const args = asRecord(rawArgs);
9177
- const mktId = readString(args, "mktId") ?? "";
9178
- const sz = readNumber(args, "sz");
9179
- const response = await context.client.privateGet(
9180
- PATH_PM_BOOKS,
9181
- compactObject({ instId: mktId, sz }),
9182
- privateRateLimit("outcomes_get_order_book", OUTCOMES_RPS)
9183
- );
9184
- return normalizeResponse(response);
9185
- }
9186
- },
9187
- /* C8. Order books (batch) */
9188
- {
9189
- name: "outcomes_get_order_books",
9190
- title: "Get Prediction Market Order Books (Batch)",
9191
- module: "outcomes",
9192
- description: "Get CLOB order books for multiple prediction markets in parallel. Per-row error isolation. See also: `outcomes_get_order_book` (single).",
9193
- isWrite: false,
9194
- inputSchema: {
9195
- type: "object",
9196
- properties: {
9197
- ids: { type: "array", items: { type: "string" }, description: "List of market instrument IDs." },
9198
- sz: { type: "integer", minimum: 1, maximum: 400, description: "Order book depth per market." }
9199
- },
9200
- required: ["ids"]
9201
- },
9202
- handler: async (rawArgs, context) => {
9203
- const args = asRecord(rawArgs);
9204
- const ids = Array.isArray(args["ids"]) ? args["ids"] : [];
9205
- const sz = readNumber(args, "sz");
9206
- const rows = await runBatchQuery(ids, async (id) => {
9207
- const response = await context.client.privateGet(
9208
- PATH_PM_BOOKS,
9209
- compactObject({ instId: id, sz }),
9210
- privateRateLimit("outcomes_get_order_books", OUTCOMES_RPS)
9211
- );
9212
- const normalized = normalizeResponse(response);
9213
- return Array.isArray(normalized.data) && normalized.data.length > 0 ? normalized.data[0] : normalized.data;
9214
- });
9215
- return {
9216
- endpoint: PATH_PM_BOOKS,
9217
- requestTime: (/* @__PURE__ */ new Date()).toISOString(),
9218
- data: rows
9219
- };
9220
- }
9221
- },
9222
- /* ================================================================ */
9223
- /* ACCOUNT MODULE (5) */
9224
- /* ================================================================ */
9225
- /* A1. Account balance */
9226
- {
9227
- name: "outcomes_get_account_balance",
9228
- title: "Get Predictions Account Balance",
9229
- module: "outcomes",
9230
- description: "Get the balance of the user's predictions account (collateral available for trading binary outcomes). Use when: checking how much is available to bet on prediction markets.",
9231
- isWrite: false,
9232
- inputSchema: { type: "object", properties: {} },
9233
- handler: async (_rawArgs, context) => {
9234
- const response = await context.client.privateGet(
9235
- PATH_BALANCE,
9236
- {},
9237
- privateRateLimit("outcomes_get_account_balance", OUTCOMES_RPS)
9238
- );
9239
- return normalizeResponse(response);
9240
- }
9241
- },
9242
- /* A2. Order detail */
9243
- {
9244
- name: "outcomes_get_order_detail",
9245
- title: "Get Prediction Order Detail",
9246
- module: "outcomes",
9247
- description: "Get full detail of a single prediction order by order ID (status, fill info, timestamps). Use when: checking whether a specific order was filled. Also reachable via `okx outcomes clob order {ID}` (CLI alias).",
9248
- isWrite: false,
9249
- inputSchema: {
9250
- type: "object",
9251
- properties: {
9252
- id: { type: "string", description: "Order ID." }
9253
- },
9254
- required: ["id"]
9255
- },
9256
- handler: async (rawArgs, context) => {
9257
- const args = asRecord(rawArgs);
9258
- const id = requireString2(args, "id", "Order ID");
9259
- const response = await context.client.privateGet(
9260
- `${PATH_ORDERS}/${pathSegment(id)}`,
9261
- {},
9262
- privateRateLimit("outcomes_get_order_detail", OUTCOMES_RPS)
9263
- );
9264
- return normalizeResponse(response);
9265
- }
9266
- },
9267
- /* A3. Account orders */
9268
- {
9269
- name: "outcomes_get_account_orders",
9270
- title: "List Prediction Account Orders",
9271
- module: "outcomes",
9272
- description: "List the user's prediction orders, optionally filtered by status (`open` | `closed`, default `open`) and paginated. Use when: reviewing pending or historical orders. Also reachable via `okx outcomes clob orders` (CLI alias).",
9273
- isWrite: false,
9274
- inputSchema: {
9275
- type: "object",
9276
- properties: {
9277
- status: { type: "string", enum: ["open", "closed"], default: "open", description: "Order status filter (default `open`)." },
9278
- cursor: { type: "string", description: "Pagination cursor." },
9279
- limit: { type: "integer", minimum: 1, maximum: 100, default: 20, description: "Max results (default 20)." }
9280
- }
9281
- },
9282
- handler: async (rawArgs, context) => {
9283
- const args = asRecord(rawArgs);
9284
- const response = await context.client.privateGet(
9285
- PATH_ORDERS,
9286
- compactObject({
9287
- status: readString(args, "status") ?? "open",
9288
- cursor: readString(args, "cursor"),
9289
- limit: readNumber(args, "limit") ?? 20
9290
- }),
9291
- privateRateLimit("outcomes_get_account_orders", OUTCOMES_RPS)
9292
- );
9293
- return normalizeResponse(response);
9294
- }
9295
- },
9296
- /* A4. Account positions */
9297
- {
9298
- name: "outcomes_get_account_positions",
9299
- title: "List Prediction Account Positions",
9300
- module: "outcomes",
9301
- description: "List the user's prediction positions, optionally filtered by status (`open` | `closed`, default `open`), market ID, or limit. The MCP schema enum enforces valid status values at the boundary; server-side mapping of unknown values to `open` is a defensive fallback only. Use when: checking which prediction markets the user currently holds positions in.",
9302
- isWrite: false,
9303
- inputSchema: {
9304
- type: "object",
9305
- properties: {
9306
- status: { type: "string", enum: ["open", "closed"], default: "open", description: "Position status filter (default `open`)." },
9307
- market: { type: "string", description: "Optional market instrument ID to filter by." },
9308
- cursor: { type: "string", description: "Pagination cursor." },
9309
- limit: { type: "integer", minimum: 1, maximum: 100, default: 20, description: "Max results (default 20)." }
9310
- }
9311
- },
9312
- handler: async (rawArgs, context) => {
9313
- const args = asRecord(rawArgs);
9314
- const response = await context.client.privateGet(
9315
- PATH_POSITIONS,
9316
- compactObject({
9317
- status: readString(args, "status") ?? "open",
9318
- market: readString(args, "market"),
9319
- cursor: readString(args, "cursor"),
9320
- limit: readNumber(args, "limit") ?? 20
9321
- }),
9322
- privateRateLimit("outcomes_get_account_positions", OUTCOMES_RPS)
9323
- );
9324
- return normalizeResponse(response);
9325
- }
9326
- },
9327
- /* A5. Account trades */
9328
- {
9329
- name: "outcomes_get_account_trades",
9330
- title: "List Prediction Account Trades",
9331
- module: "outcomes",
9332
- description: "List the user's prediction trade fills (executed trades), paginated. Use when: reviewing trading history on prediction markets. Also reachable via `okx outcomes clob trades` (CLI alias).",
9333
- isWrite: false,
9334
- inputSchema: {
9335
- type: "object",
9336
- properties: {
9337
- cursor: { type: "string", description: "Pagination cursor." },
9338
- limit: { type: "integer", minimum: 1, maximum: 100, default: 20, description: "Max results (default 20)." }
9339
- }
9340
- },
9341
- handler: async (rawArgs, context) => {
9342
- const args = asRecord(rawArgs);
9343
- const response = await context.client.privateGet(
9344
- PATH_TRADES,
9345
- compactObject({
9346
- cursor: readString(args, "cursor"),
9347
- limit: readNumber(args, "limit") ?? 20
9348
- }),
9349
- privateRateLimit("outcomes_get_account_trades", OUTCOMES_RPS)
9350
- );
9351
- return normalizeResponse(response);
9352
- }
9353
- }
9354
- ];
9355
- return tools;
9356
- }
9357
8705
  function buildContractTradeTools(cfg) {
9358
8706
  const { prefix, module, label, instTypes, instIdExample, titleLabel } = cfg;
9359
8707
  const [defaultType, otherType] = instTypes;
@@ -13144,7 +12492,6 @@ function allToolSpecs() {
13144
12492
  ...registerBotTools(),
13145
12493
  ...registerAllEarnTools(),
13146
12494
  ...registerSmartmoneyTools(),
13147
- ...registerOutcomesTools(),
13148
12495
  ...registerAuditTools(),
13149
12496
  ...registerSkillsTools()
13150
12497
  ];
@@ -15144,7 +14491,7 @@ async function cmdDiagnoseMcp(options = {}) {
15144
14491
 
15145
14492
  // src/commands/diagnose.ts
15146
14493
  var CLI_VERSION = readCliVersion();
15147
- var GIT_HASH = true ? "740ac6f1" : "dev";
14494
+ var GIT_HASH = true ? "52f6524c" : "dev";
15148
14495
  function maskKey2(key) {
15149
14496
  if (!key) return "(not set)";
15150
14497
  if (key.length <= 8) return "****";
@@ -16512,152 +15859,6 @@ var CLI_REGISTRY = {
16512
15859
  }
16513
15860
  }
16514
15861
  },
16515
- // ── outcomes ────────────────────────────────────────────────────────────────
16516
- outcomes: {
16517
- description: "Prediction markets - binary YES/NO event contracts (browse, search, CLOB, account)",
16518
- subgroups: {
16519
- data: {
16520
- description: "Browse and query prediction market events and markets",
16521
- commands: {
16522
- events: {
16523
- toolName: "outcomes_get_events",
16524
- usage: "okx outcomes data events [--status <status>] [--category <cat>] [--tag <tag>] [--league <lg>] [--sortBy <sort>] [--after <cursor>] [--limit <n>] [--json]",
16525
- description: "List prediction market events"
16526
- },
16527
- event: {
16528
- toolName: "outcomes_get_event_detail",
16529
- usage: "okx outcomes data event <id> [--json]",
16530
- description: "Get details of a specific prediction market event"
16531
- },
16532
- "event-markets": {
16533
- toolName: "outcomes_get_event_markets",
16534
- usage: "okx outcomes data event-markets <id> [--json]",
16535
- description: "Get markets for a prediction market event"
16536
- },
16537
- market: {
16538
- toolName: "outcomes_get_market_detail",
16539
- usage: "okx outcomes data market <id> [--json]",
16540
- description: "Get details of a specific prediction market"
16541
- },
16542
- trending: {
16543
- toolName: "outcomes_get_trending_events",
16544
- usage: "okx outcomes data trending [--after <cursor>] [--limit <n>] [--json]",
16545
- description: "Get trending prediction market events"
16546
- },
16547
- ticker: {
16548
- toolName: "outcomes_get_ticker",
16549
- usage: "okx outcomes data ticker <assetId> [--json]",
16550
- description: "Get ticker for a prediction market asset"
16551
- },
16552
- candles: {
16553
- toolName: "outcomes_get_candles",
16554
- usage: "okx outcomes data candles <assetId> [--bar <bar>] [--after <ts>] [--before <ts>] [--limit <n>] [--json]",
16555
- description: "Get candlestick data for a prediction market asset"
16556
- }
16557
- }
16558
- },
16559
- search: {
16560
- description: "Search prediction market events",
16561
- commands: {
16562
- "<keyword>": {
16563
- toolName: "outcomes_search_events",
16564
- usage: "okx outcomes search <keyword> [--after <cursor>] [--limit <n>] [--json]",
16565
- description: "Search prediction market events by keyword"
16566
- }
16567
- }
16568
- },
16569
- clob: {
16570
- description: "CLOB price, order book, and account actions",
16571
- commands: {
16572
- price: {
16573
- toolName: "outcomes_get_market_price",
16574
- usage: "okx outcomes clob price <mktId> [--outcome <yes|no>] [--json]",
16575
- description: "Get price for a market (optionally for a specific outcome)"
16576
- },
16577
- prices: {
16578
- toolName: "outcomes_get_market_prices",
16579
- usage: "okx outcomes clob prices <id1,id2,...> [--outcome <yes|no>] [--json]",
16580
- description: "Get prices for multiple markets (batch)"
16581
- },
16582
- midpoint: {
16583
- toolName: "outcomes_get_market_midpoint",
16584
- usage: "okx outcomes clob midpoint <mktId> [--json]",
16585
- description: "Get midpoint price for a market"
16586
- },
16587
- midpoints: {
16588
- toolName: "outcomes_get_market_midpoints",
16589
- usage: "okx outcomes clob midpoints <id1,id2,...> [--json]",
16590
- description: "Get midpoint prices for multiple markets (batch)"
16591
- },
16592
- spread: {
16593
- toolName: "outcomes_get_market_spread",
16594
- usage: "okx outcomes clob spread <mktId> [--json]",
16595
- description: "Get bid-ask spread for a market"
16596
- },
16597
- spreads: {
16598
- toolName: "outcomes_get_market_spreads",
16599
- usage: "okx outcomes clob spreads <id1,id2,...> [--json]",
16600
- description: "Get bid-ask spreads for multiple markets (batch)"
16601
- },
16602
- book: {
16603
- toolName: "outcomes_get_order_book",
16604
- usage: "okx outcomes clob book <mktId> [--sz <depth>] [--json]",
16605
- description: "Get order book for a prediction market"
16606
- },
16607
- books: {
16608
- toolName: "outcomes_get_order_books",
16609
- usage: "okx outcomes clob books <id1,id2,...> [--sz <depth>] [--json]",
16610
- description: "Get order books for multiple markets (batch)"
16611
- },
16612
- order: {
16613
- toolName: "outcomes_get_order_detail",
16614
- usage: "okx outcomes clob order <id> [--json]",
16615
- description: "Get details of a specific prediction market order (alias for account order)"
16616
- },
16617
- orders: {
16618
- toolName: "outcomes_get_account_orders",
16619
- usage: "okx outcomes clob orders [--status <open|closed>] [--after <cursor>] [--limit <n>] [--json]",
16620
- description: "List prediction market orders (alias for account orders)"
16621
- },
16622
- trades: {
16623
- toolName: "outcomes_get_account_trades",
16624
- usage: "okx outcomes clob trades [--after <cursor>] [--limit <n>] [--json]",
16625
- description: "List prediction market trades (alias for account trades)"
16626
- }
16627
- }
16628
- },
16629
- account: {
16630
- description: "Prediction market account balance, orders, positions, and trades",
16631
- commands: {
16632
- balance: {
16633
- toolName: "outcomes_get_account_balance",
16634
- usage: "okx outcomes account balance [--json]",
16635
- description: "Get prediction market account balance"
16636
- },
16637
- order: {
16638
- toolName: "outcomes_get_order_detail",
16639
- usage: "okx outcomes account order <id> [--json]",
16640
- description: "Get details of a specific prediction market order"
16641
- },
16642
- orders: {
16643
- toolName: "outcomes_get_account_orders",
16644
- usage: "okx outcomes account orders [--status <open|closed>] [--after <cursor>] [--limit <n>] [--json]",
16645
- description: "List prediction market orders"
16646
- },
16647
- positions: {
16648
- toolName: "outcomes_get_account_positions",
16649
- usage: "okx outcomes account positions [--status <open|closed>] [--instId <mktId>] [--after <cursor>] [--limit <n>] [--json]",
16650
- description: "List prediction market positions"
16651
- },
16652
- trades: {
16653
- toolName: "outcomes_get_account_trades",
16654
- usage: "okx outcomes account trades [--after <cursor>] [--limit <n>] [--json]",
16655
- description: "List prediction market account trades"
16656
- }
16657
- }
16658
- }
16659
- }
16660
- },
16661
15862
  // ── config ─────────────────────────────────────────────────────────────────
16662
15863
  config: {
16663
15864
  description: "Manage CLI configuration profiles",
@@ -17626,9 +16827,6 @@ var CLI_OPTIONS = {
17626
16827
  settleCcy: { type: "string" },
17627
16828
  ts: { type: "string" },
17628
16829
  minAbsOiDeltaPct: { type: "string" },
17629
- // outcomes module
17630
- category: { type: "string" },
17631
- league: { type: "string" },
17632
16830
  // diagnostics - cli/mcp/all/output are diagnose-specific; verbose is shared
17633
16831
  verbose: { type: "boolean", default: false },
17634
16832
  mcp: { type: "boolean", default: false },
@@ -17700,6 +16898,7 @@ function parseCli(argv) {
17700
16898
  }
17701
16899
 
17702
16900
  // src/commands/market.ts
16901
+ var NO_INDICATOR_VALUES_HINT = "No indicator values returned. This indicator may require a period \u2014 try --params (e.g. --params 14).";
17703
16902
  function getData2(result) {
17704
16903
  return result.data;
17705
16904
  }
@@ -17906,11 +17105,13 @@ function cmdMarketIndicatorList(json) {
17906
17105
  }
17907
17106
  async function cmdMarketIndicator(run, indicator, instId, opts) {
17908
17107
  const params = opts.params ? opts.params.split(",").map((p) => Number(p.trim())).filter((n) => !Number.isNaN(n)) : void 0;
17108
+ const explicit = params && params.length > 0 ? params : void 0;
17109
+ const effectiveParams = explicit ?? getDefaultIndicatorParams(indicator);
17909
17110
  const result = await run("market_get_indicator", {
17910
17111
  instId,
17911
17112
  indicator,
17912
17113
  bar: opts.bar,
17913
- params: params && params.length > 0 ? params : void 0,
17114
+ params: effectiveParams,
17914
17115
  returnList: opts.list ?? false,
17915
17116
  limit: opts.limit,
17916
17117
  backtestTime: opts.backtestTime
@@ -17918,7 +17119,7 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
17918
17119
  const outerArray = getData2(result);
17919
17120
  if (opts.json) return printJson(outerArray);
17920
17121
  if (!outerArray?.length) {
17921
- process.stdout.write("No data\n");
17122
+ outputLine("No data");
17922
17123
  return;
17923
17124
  }
17924
17125
  const apiCode = resolveIndicatorCode(indicator);
@@ -17927,16 +17128,18 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
17927
17128
  const instData = innerArray?.[0];
17928
17129
  const timeframes = instData?.["timeframes"];
17929
17130
  if (!timeframes) {
17930
- process.stdout.write(JSON.stringify(outerArray, null, 2) + "\n");
17131
+ output(JSON.stringify(outerArray, null, 2) + "\n");
17931
17132
  return;
17932
17133
  }
17134
+ let printed = false;
17933
17135
  for (const [tf, tfData] of Object.entries(timeframes)) {
17934
17136
  const indicators = tfData?.["indicators"];
17935
17137
  const values = indicators?.[apiCode];
17936
17138
  if (!values?.length) continue;
17937
- process.stdout.write(`${instId} | ${apiCode} | ${tf}
17139
+ printed = true;
17140
+ output(`${instId} | ${apiCode} | ${tf}
17938
17141
  `);
17939
- process.stdout.write("-".repeat(40) + "\n");
17142
+ output("-".repeat(40) + "\n");
17940
17143
  if (opts.list) {
17941
17144
  const tableRows = values.map((entry) => ({
17942
17145
  ts: new Date(Number(entry["ts"])).toLocaleString(),
@@ -17951,6 +17154,7 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
17951
17154
  });
17952
17155
  }
17953
17156
  }
17157
+ if (!printed) outputLine(NO_INDICATOR_VALUES_HINT);
17954
17158
  }
17955
17159
  async function cmdMarketInstrumentsByCategory(run, opts) {
17956
17160
  const result = await run("market_get_instruments_by_category", {
@@ -18024,8 +17228,9 @@ async function cmdMarketFilter(run, opts) {
18024
17228
  sortOrder: opts.sortOrder,
18025
17229
  limit: opts.limit
18026
17230
  });
18027
- const data = getData2(result);
18028
- if (opts.json) return printJson(data);
17231
+ const raw = getData2(result);
17232
+ if (opts.json) return printJson(raw);
17233
+ const data = Array.isArray(raw) ? raw[0] : raw;
18029
17234
  const rows = data?.["rows"] ?? [];
18030
17235
  const total = data?.["total"] ?? rows.length;
18031
17236
  outputLine(`Total: ${total}`);
@@ -21997,186 +21202,10 @@ async function cmdEventCancel(run, opts) {
21997
21202
  `);
21998
21203
  }
21999
21204
 
22000
- // src/commands/outcomes.ts
22001
- function getData10(result) {
22002
- return result.data;
22003
- }
22004
- async function cmdOutcomesEvents(run, opts) {
22005
- const result = await run("outcomes_get_events", {
22006
- status: opts.status,
22007
- category: opts.category,
22008
- tag: opts.tag,
22009
- league: opts.league,
22010
- sort: opts.sort,
22011
- cursor: opts.cursor,
22012
- limit: opts.limit
22013
- });
22014
- const data = getData10(result);
22015
- if (opts.json) return printJson(data);
22016
- printTable(Array.isArray(data) ? data : []);
22017
- }
22018
- async function cmdOutcomesEventDetail(run, id, opts) {
22019
- const result = await run("outcomes_get_event_detail", { id });
22020
- const data = getData10(result);
22021
- if (opts.json) return printJson(data);
22022
- printTable(Array.isArray(data) ? data : [data]);
22023
- }
22024
- async function cmdOutcomesEventMarkets(run, id, opts) {
22025
- const result = await run("outcomes_get_event_markets", { id });
22026
- const data = getData10(result);
22027
- if (opts.json) return printJson(data);
22028
- printTable(Array.isArray(data) ? data : []);
22029
- }
22030
- async function cmdOutcomesMarketDetail(run, id, opts) {
22031
- const result = await run("outcomes_get_market_detail", { id });
22032
- const data = getData10(result);
22033
- if (opts.json) return printJson(data);
22034
- printTable(Array.isArray(data) ? data : [data]);
22035
- }
22036
- async function cmdOutcomesTrending(run, opts) {
22037
- const result = await run("outcomes_get_trending_events", {
22038
- cursor: opts.cursor,
22039
- limit: opts.limit
22040
- });
22041
- const data = getData10(result);
22042
- if (opts.json) return printJson(data);
22043
- printTable(Array.isArray(data) ? data : []);
22044
- }
22045
- async function cmdOutcomesTicker(run, assetId, opts) {
22046
- const result = await run("outcomes_get_ticker", { assetId });
22047
- const data = getData10(result);
22048
- if (opts.json) return printJson(data);
22049
- printTable(Array.isArray(data) ? data : [data]);
22050
- }
22051
- async function cmdOutcomesCandles(run, assetId, opts) {
22052
- const result = await run("outcomes_get_candles", {
22053
- assetId,
22054
- bar: opts.bar,
22055
- after: opts.after,
22056
- before: opts.before,
22057
- limit: opts.limit
22058
- });
22059
- const data = getData10(result);
22060
- if (opts.json) return printJson(data);
22061
- printTable(Array.isArray(data) ? data : []);
22062
- }
22063
- async function cmdOutcomesSearch(run, keyword, opts) {
22064
- const result = await run("outcomes_search_events", {
22065
- keyword,
22066
- cursor: opts.cursor,
22067
- limit: opts.limit
22068
- });
22069
- const data = getData10(result);
22070
- if (opts.json) return printJson(data);
22071
- printTable(Array.isArray(data) ? data : []);
22072
- }
22073
- async function cmdOutcomesClobPrice(run, mktId, opts) {
22074
- const result = await run("outcomes_get_market_price", {
22075
- mktId,
22076
- outcome: opts.outcome
22077
- });
22078
- const data = getData10(result);
22079
- if (opts.json) return printJson(data);
22080
- printTable(data ? [data] : []);
22081
- }
22082
- async function cmdOutcomesClobPrices(run, ids, opts) {
22083
- const result = await run("outcomes_get_market_prices", {
22084
- ids,
22085
- outcome: opts.outcome
22086
- });
22087
- const data = getData10(result);
22088
- if (opts.json) return printJson(data);
22089
- printTable(Array.isArray(data) ? data : []);
22090
- }
22091
- async function cmdOutcomesClobMidpoint(run, mktId, opts) {
22092
- const result = await run("outcomes_get_market_midpoint", { mktId });
22093
- const data = getData10(result);
22094
- if (opts.json) return printJson(data);
22095
- printTable(data ? [data] : []);
22096
- }
22097
- async function cmdOutcomesClobMidpoints(run, ids, opts) {
22098
- const result = await run("outcomes_get_market_midpoints", { ids });
22099
- const data = getData10(result);
22100
- if (opts.json) return printJson(data);
22101
- printTable(Array.isArray(data) ? data : []);
22102
- }
22103
- async function cmdOutcomesClobSpread(run, mktId, opts) {
22104
- const result = await run("outcomes_get_market_spread", { mktId });
22105
- const data = getData10(result);
22106
- if (opts.json) return printJson(data);
22107
- printTable(data ? [data] : []);
22108
- }
22109
- async function cmdOutcomesClobSpreads(run, ids, opts) {
22110
- const result = await run("outcomes_get_market_spreads", { ids });
22111
- const data = getData10(result);
22112
- if (opts.json) return printJson(data);
22113
- printTable(Array.isArray(data) ? data : []);
22114
- }
22115
- async function cmdOutcomesClobBook(run, mktId, opts) {
22116
- const result = await run("outcomes_get_order_book", {
22117
- mktId,
22118
- sz: opts.sz
22119
- });
22120
- const data = getData10(result);
22121
- if (opts.json) return printJson(data);
22122
- printTable(Array.isArray(data) ? data : [data]);
22123
- }
22124
- async function cmdOutcomesClobBooks(run, ids, opts) {
22125
- const result = await run("outcomes_get_order_books", {
22126
- ids,
22127
- sz: opts.sz
22128
- });
22129
- const data = getData10(result);
22130
- if (opts.json) return printJson(data);
22131
- printTable(Array.isArray(data) ? data : []);
22132
- }
22133
- async function cmdOutcomesAccountBalance(run, opts) {
22134
- const result = await run("outcomes_get_account_balance", {});
22135
- const data = getData10(result);
22136
- if (opts.json) return printJson(data);
22137
- printTable(Array.isArray(data) ? data : [data]);
22138
- }
22139
- async function cmdOutcomesAccountOrderDetail(run, id, opts) {
22140
- const result = await run("outcomes_get_order_detail", { id });
22141
- const data = getData10(result);
22142
- if (opts.json) return printJson(data);
22143
- printTable(Array.isArray(data) ? data : [data]);
22144
- }
22145
- async function cmdOutcomesAccountOrders(run, opts) {
22146
- const result = await run("outcomes_get_account_orders", {
22147
- status: opts.status,
22148
- cursor: opts.cursor,
22149
- limit: opts.limit
22150
- });
22151
- const data = getData10(result);
22152
- if (opts.json) return printJson(data);
22153
- printTable(Array.isArray(data) ? data : []);
22154
- }
22155
- async function cmdOutcomesAccountPositions(run, opts) {
22156
- const result = await run("outcomes_get_account_positions", {
22157
- status: opts.status,
22158
- market: opts.market,
22159
- cursor: opts.cursor,
22160
- limit: opts.limit
22161
- });
22162
- const data = getData10(result);
22163
- if (opts.json) return printJson(data);
22164
- printTable(Array.isArray(data) ? data : []);
22165
- }
22166
- async function cmdOutcomesAccountTrades(run, opts) {
22167
- const result = await run("outcomes_get_account_trades", {
22168
- cursor: opts.cursor,
22169
- limit: opts.limit
22170
- });
22171
- const data = getData10(result);
22172
- if (opts.json) return printJson(data);
22173
- printTable(Array.isArray(data) ? data : []);
22174
- }
22175
-
22176
21205
  // src/index.ts
22177
21206
  var _require3 = createRequire3(import.meta.url);
22178
21207
  var CLI_VERSION2 = _require3("../package.json").version;
22179
- var GIT_HASH2 = true ? "740ac6f1" : "dev";
21208
+ var GIT_HASH2 = true ? "52f6524c" : "dev";
22180
21209
  function handlePilotCommand(action, json, force, binaryPath) {
22181
21210
  if (action === "status") return cmdPilotStatus(json, binaryPath);
22182
21211
  if (action === "install") return cmdPilotInstall(json, binaryPath);
@@ -23570,102 +22599,6 @@ function handleEventCommand(run, action, rest, v, json) {
23570
22599
  `);
23571
22600
  process.exitCode = 1;
23572
22601
  }
23573
- function handleOutcomesCommand(run, module, rest, v, json) {
23574
- const sub = rest[0];
23575
- const subRest = rest.slice(1);
23576
- const limit = v.limit !== void 0 ? Number(v.limit) : void 0;
23577
- if (module === "data") {
23578
- if (sub === "events")
23579
- return cmdOutcomesEvents(run, {
23580
- status: v.status,
23581
- category: v.category,
23582
- tag: v.tag,
23583
- league: v.league,
23584
- sort: v.sortBy,
23585
- cursor: v.after,
23586
- limit,
23587
- json
23588
- });
23589
- if (sub === "event")
23590
- return cmdOutcomesEventDetail(run, subRest[0] ?? "", { json });
23591
- if (sub === "event-markets")
23592
- return cmdOutcomesEventMarkets(run, subRest[0] ?? "", { json });
23593
- if (sub === "market")
23594
- return cmdOutcomesMarketDetail(run, subRest[0] ?? "", { json });
23595
- if (sub === "trending")
23596
- return cmdOutcomesTrending(run, { cursor: v.after, limit, json });
23597
- if (sub === "ticker")
23598
- return cmdOutcomesTicker(run, subRest[0] ?? "", { json });
23599
- if (sub === "candles")
23600
- return cmdOutcomesCandles(run, subRest[0] ?? "", {
23601
- bar: v.bar,
23602
- after: v.after,
23603
- before: v.before,
23604
- limit,
23605
- json
23606
- });
23607
- errorLine(`Unknown outcomes data command: ${sub ?? "(none)"}`);
23608
- errorLine("Valid: events, event, event-markets, market, trending, ticker, candles");
23609
- process.exitCode = 1;
23610
- return;
23611
- }
23612
- if (module === "search") {
23613
- const keyword = sub ?? "";
23614
- return cmdOutcomesSearch(run, keyword, { cursor: v.after, limit, json });
23615
- }
23616
- if (module === "clob") {
23617
- const mktId = subRest[0] ?? "";
23618
- const parseIds = (raw) => raw.split(",").map((s) => s.trim()).filter(Boolean);
23619
- if (sub === "price")
23620
- return cmdOutcomesClobPrice(run, mktId, { outcome: v.outcome, json });
23621
- if (sub === "prices")
23622
- return cmdOutcomesClobPrices(run, parseIds(subRest[0] ?? ""), { outcome: v.outcome, json });
23623
- if (sub === "midpoint")
23624
- return cmdOutcomesClobMidpoint(run, mktId, { json });
23625
- if (sub === "midpoints")
23626
- return cmdOutcomesClobMidpoints(run, parseIds(subRest[0] ?? ""), { json });
23627
- if (sub === "spread")
23628
- return cmdOutcomesClobSpread(run, mktId, { json });
23629
- if (sub === "spreads")
23630
- return cmdOutcomesClobSpreads(run, parseIds(subRest[0] ?? ""), { json });
23631
- if (sub === "book")
23632
- return cmdOutcomesClobBook(run, mktId, { sz: v.sz !== void 0 ? Number(v.sz) : void 0, json });
23633
- if (sub === "books")
23634
- return cmdOutcomesClobBooks(run, parseIds(subRest[0] ?? ""), { sz: v.sz !== void 0 ? Number(v.sz) : void 0, json });
23635
- if (sub === "order")
23636
- return cmdOutcomesAccountOrderDetail(run, subRest[0] ?? "", { json });
23637
- if (sub === "orders")
23638
- return cmdOutcomesAccountOrders(run, { status: v.status, cursor: v.after, limit, json });
23639
- if (sub === "trades")
23640
- return cmdOutcomesAccountTrades(run, { cursor: v.after, limit, json });
23641
- errorLine(`Unknown outcomes clob command: ${sub ?? "(none)"}`);
23642
- errorLine("Valid: price, prices, midpoint, midpoints, spread, spreads, book, books, order, orders, trades");
23643
- process.exitCode = 1;
23644
- return;
23645
- }
23646
- if (module === "account") {
23647
- if (sub === "balance")
23648
- return cmdOutcomesAccountBalance(run, { json });
23649
- if (sub === "order")
23650
- return cmdOutcomesAccountOrderDetail(run, subRest[0] ?? "", { json });
23651
- if (sub === "orders")
23652
- return cmdOutcomesAccountOrders(run, { status: v.status, cursor: v.after, limit, json });
23653
- if (sub === "positions")
23654
- return cmdOutcomesAccountPositions(run, { status: v.status, market: v.instId, cursor: v.after, limit, json });
23655
- if (sub === "trades")
23656
- return cmdOutcomesAccountTrades(run, { cursor: v.after, limit, json });
23657
- errorLine(`Unknown outcomes account command: ${sub ?? "(none)"}`);
23658
- errorLine("Valid: balance, order, orders, positions, trades");
23659
- process.exitCode = 1;
23660
- return;
23661
- }
23662
- if (module === "wallet") {
23663
- throw new Error("Coming in Phase 2");
23664
- }
23665
- errorLine(`Unknown outcomes module: ${module}`);
23666
- errorLine("Valid: data, search, clob, account, wallet");
23667
- process.exitCode = 1;
23668
- }
23669
22602
  function outputResult(result, json) {
23670
22603
  if (json) {
23671
22604
  outputLine(JSON.stringify(result, null, 2));
@@ -23778,7 +22711,6 @@ async function main() {
23778
22711
  bot: () => handleBotCommand(run, action, rest, v, json),
23779
22712
  earn: () => handleEarnCommand(run, action, rest, v, json),
23780
22713
  smartmoney: () => handleSmartmoneyCommand(run, action, rest, v, json),
23781
- outcomes: () => handleOutcomesCommand(run, action, rest, v, json),
23782
22714
  skill: () => handleSkillCommand(run, action, rest, v, json, config)
23783
22715
  };
23784
22716
  const handler = moduleHandlers[module];
@@ -23812,7 +22744,6 @@ export {
23812
22744
  handleNewsCommand,
23813
22745
  handleOptionAlgoCommand,
23814
22746
  handleOptionCommand,
23815
- handleOutcomesCommand,
23816
22747
  handlePilotCommand,
23817
22748
  handleSetupCommand,
23818
22749
  handleSkillCommand,