@okx_ai/okx-trade-cli 1.3.2-beta.3 → 1.3.2-beta.5
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 +197 -92
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1926,6 +1926,23 @@ function privateRateLimit(key, rps = 10) {
|
|
|
1926
1926
|
refillPerSecond: rps
|
|
1927
1927
|
};
|
|
1928
1928
|
}
|
|
1929
|
+
var CURSOR_PROPS = {
|
|
1930
|
+
after: { type: "string", description: "Cursor: return older records" },
|
|
1931
|
+
before: { type: "string", description: "Cursor: return newer records" }
|
|
1932
|
+
};
|
|
1933
|
+
var TIME_RANGE_PROPS = {
|
|
1934
|
+
begin: { type: "string", description: "Start time (ms)" },
|
|
1935
|
+
end: { type: "string", description: "End time (ms)" }
|
|
1936
|
+
};
|
|
1937
|
+
function readPaginationParams(args, readStr, readNum) {
|
|
1938
|
+
return {
|
|
1939
|
+
after: readStr(args, "after"),
|
|
1940
|
+
before: readStr(args, "before"),
|
|
1941
|
+
begin: readStr(args, "begin"),
|
|
1942
|
+
end: readStr(args, "end"),
|
|
1943
|
+
limit: readNum(args, "limit")
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1929
1946
|
function assertNotDemo(config, endpoint) {
|
|
1930
1947
|
if (config.demo) {
|
|
1931
1948
|
throw new ConfigError(
|
|
@@ -2184,6 +2201,8 @@ function registerIndicatorTools() {
|
|
|
2184
2201
|
];
|
|
2185
2202
|
}
|
|
2186
2203
|
var DEFAULT_SOURCE_TAG = "MCP";
|
|
2204
|
+
var TOKEN_REGEX = /^[A-Z2-7]{12}$/;
|
|
2205
|
+
var TAG_JOIN = "";
|
|
2187
2206
|
var OKX_SITES = {
|
|
2188
2207
|
global: {
|
|
2189
2208
|
label: "Global",
|
|
@@ -3141,7 +3160,8 @@ function registerAlgoTradeTools() {
|
|
|
3141
3160
|
callBackSpread: readString(args, "callbackSpread"),
|
|
3142
3161
|
activePx: readString(args, "activePx"),
|
|
3143
3162
|
reduceOnly: typeof reduceOnly === "boolean" ? String(reduceOnly) : void 0,
|
|
3144
|
-
clOrdId: readString(args, "clOrdId")
|
|
3163
|
+
clOrdId: readString(args, "clOrdId"),
|
|
3164
|
+
tag: context.config.sourceTag
|
|
3145
3165
|
}),
|
|
3146
3166
|
privateRateLimit("swap_place_move_stop_order", 20)
|
|
3147
3167
|
);
|
|
@@ -3486,7 +3506,8 @@ function registerFuturesAlgoTools() {
|
|
|
3486
3506
|
callBackSpread: readString(args, "callbackSpread"),
|
|
3487
3507
|
activePx: readString(args, "activePx"),
|
|
3488
3508
|
reduceOnly: typeof reduceOnly === "boolean" ? String(reduceOnly) : void 0,
|
|
3489
|
-
clOrdId: readString(args, "clOrdId")
|
|
3509
|
+
clOrdId: readString(args, "clOrdId"),
|
|
3510
|
+
tag: context.config.sourceTag
|
|
3490
3511
|
}),
|
|
3491
3512
|
privateRateLimit("futures_place_move_stop_order", 20)
|
|
3492
3513
|
);
|
|
@@ -6341,37 +6362,45 @@ function registerEventContractTools() {
|
|
|
6341
6362
|
{
|
|
6342
6363
|
name: "event_get_orders",
|
|
6343
6364
|
module: "event",
|
|
6344
|
-
description: "Query event contract orders
|
|
6365
|
+
description: "Query event contract orders (open, 7d history, or 3-month archive). outcome pre-translated (YES/NO/UP/DOWN). Do NOT use for trade executions \u2014 use event_get_fills for fill records and settlement outcomes.",
|
|
6345
6366
|
isWrite: false,
|
|
6346
6367
|
inputSchema: {
|
|
6347
6368
|
type: "object",
|
|
6348
6369
|
properties: {
|
|
6349
|
-
|
|
6370
|
+
status: {
|
|
6350
6371
|
type: "string",
|
|
6351
|
-
|
|
6372
|
+
enum: ["open", "history", "archive"],
|
|
6373
|
+
description: "open=active, history=7d (default), archive=3mo"
|
|
6352
6374
|
},
|
|
6353
|
-
|
|
6375
|
+
instId: {
|
|
6354
6376
|
type: "string",
|
|
6355
|
-
description: "
|
|
6377
|
+
description: "Event contract instrument ID"
|
|
6356
6378
|
},
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6379
|
+
ordType: { type: "string", description: "Order type filter" },
|
|
6380
|
+
state: { type: "string", description: "canceled|filled (only for history/archive)" },
|
|
6381
|
+
...CURSOR_PROPS,
|
|
6382
|
+
...TIME_RANGE_PROPS,
|
|
6383
|
+
limit: { type: "number", description: "Max results (default 100)" }
|
|
6361
6384
|
}
|
|
6362
6385
|
},
|
|
6363
6386
|
handler: async (rawArgs, context) => {
|
|
6364
6387
|
const args = asRecord(rawArgs);
|
|
6365
|
-
const
|
|
6366
|
-
const
|
|
6367
|
-
|
|
6388
|
+
const status = readString(args, "status") ?? "history";
|
|
6389
|
+
const endpointMap = {
|
|
6390
|
+
open: "/api/v5/trade/orders-pending",
|
|
6391
|
+
archive: "/api/v5/trade/orders-history-archive"
|
|
6392
|
+
};
|
|
6393
|
+
const endpoint = endpointMap[status] ?? "/api/v5/trade/orders-history";
|
|
6394
|
+
const params = compactObject({
|
|
6395
|
+
instType: "EVENTS",
|
|
6396
|
+
instId: readString(args, "instId"),
|
|
6397
|
+
ordType: readString(args, "ordType"),
|
|
6398
|
+
state: readString(args, "state"),
|
|
6399
|
+
...readPaginationParams(args, readString, readNumber)
|
|
6400
|
+
});
|
|
6368
6401
|
const response = await context.client.privateGet(
|
|
6369
6402
|
endpoint,
|
|
6370
|
-
|
|
6371
|
-
instType: "EVENTS",
|
|
6372
|
-
instId: readString(args, "instId"),
|
|
6373
|
-
limit: readNumber(args, "limit")
|
|
6374
|
-
}),
|
|
6403
|
+
params,
|
|
6375
6404
|
privateRateLimit("event_get_orders", 20)
|
|
6376
6405
|
);
|
|
6377
6406
|
const base = normalizeResponse(response);
|
|
@@ -6385,41 +6414,51 @@ function registerEventContractTools() {
|
|
|
6385
6414
|
stateLabel: mapOrderState(String(item["state"] ?? ""))
|
|
6386
6415
|
};
|
|
6387
6416
|
}) : base["data"];
|
|
6388
|
-
return { ...base, data };
|
|
6417
|
+
return { ...base, data, requestParams: params };
|
|
6389
6418
|
}
|
|
6390
6419
|
},
|
|
6391
6420
|
{
|
|
6392
6421
|
name: "event_get_fills",
|
|
6393
6422
|
module: "event",
|
|
6394
|
-
description: "Get event contract fill history. outcome pre-translated (YES/NO/UP/DOWN). Each record includes a 'type' field: 'fill' (
|
|
6423
|
+
description: "Get event contract fill history (trade executions and settlement payouts). archive=true for up to 3mo, false (default) for last 3d. outcome pre-translated (YES/NO/UP/DOWN). Each record includes a 'type' field: 'fill' (opening trade) or 'settlement' (expiry payout with settlementResult win/loss and pnl). Do NOT use for order status \u2014 use event_get_orders instead.",
|
|
6395
6424
|
isWrite: false,
|
|
6396
6425
|
inputSchema: {
|
|
6397
6426
|
type: "object",
|
|
6398
6427
|
properties: {
|
|
6428
|
+
archive: {
|
|
6429
|
+
type: "boolean",
|
|
6430
|
+
description: "true=up to 3mo, false=3d (default)"
|
|
6431
|
+
},
|
|
6399
6432
|
instId: {
|
|
6400
6433
|
type: "string",
|
|
6401
6434
|
description: "Event contract instrument ID"
|
|
6402
6435
|
},
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
}
|
|
6436
|
+
ordId: { type: "string", description: "Order ID filter" },
|
|
6437
|
+
...CURSOR_PROPS,
|
|
6438
|
+
...TIME_RANGE_PROPS,
|
|
6439
|
+
limit: { type: "number", description: "Max results (default 100 or 20 for archive)" }
|
|
6407
6440
|
}
|
|
6408
6441
|
},
|
|
6409
6442
|
handler: async (rawArgs, context) => {
|
|
6410
6443
|
const args = asRecord(rawArgs);
|
|
6444
|
+
const archive = readBoolean(args, "archive") ?? false;
|
|
6445
|
+
const path42 = archive ? "/api/v5/trade/fills-history" : "/api/v5/trade/fills";
|
|
6446
|
+
const paging = readPaginationParams(args, readString, readNumber);
|
|
6447
|
+
const params = compactObject({
|
|
6448
|
+
instType: "EVENTS",
|
|
6449
|
+
instId: readString(args, "instId"),
|
|
6450
|
+
ordId: readString(args, "ordId"),
|
|
6451
|
+
...paging,
|
|
6452
|
+
limit: paging.limit ?? (archive ? 20 : void 0)
|
|
6453
|
+
});
|
|
6411
6454
|
const response = await context.client.privateGet(
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
instType: "EVENTS",
|
|
6415
|
-
instId: readString(args, "instId"),
|
|
6416
|
-
limit: readNumber(args, "limit")
|
|
6417
|
-
}),
|
|
6455
|
+
path42,
|
|
6456
|
+
params,
|
|
6418
6457
|
privateRateLimit("event_get_fills", 20)
|
|
6419
6458
|
);
|
|
6420
6459
|
const base = normalizeResponse(response);
|
|
6421
6460
|
const data = Array.isArray(base["data"]) ? base["data"].map(enrichFill) : base["data"];
|
|
6422
|
-
return { ...base, data };
|
|
6461
|
+
return { ...base, data, requestParams: params };
|
|
6423
6462
|
}
|
|
6424
6463
|
},
|
|
6425
6464
|
// -----------------------------------------------------------------------
|
|
@@ -6503,7 +6542,7 @@ function registerEventContractTools() {
|
|
|
6503
6542
|
{
|
|
6504
6543
|
name: "event_amend_order",
|
|
6505
6544
|
module: "event",
|
|
6506
|
-
description: "Amend a pending event contract order (change price or size). [CAUTION] Modifies a real order. Before amending, call event_get_orders(
|
|
6545
|
+
description: "Amend a pending event contract order (change price or size). [CAUTION] Modifies a real order. Before amending, call event_get_orders(status=open) to obtain the ordId and confirm the order is still pending. Only limit/post_only orders can be amended.",
|
|
6507
6546
|
isWrite: true,
|
|
6508
6547
|
inputSchema: {
|
|
6509
6548
|
type: "object",
|
|
@@ -6534,7 +6573,7 @@ function registerEventContractTools() {
|
|
|
6534
6573
|
{
|
|
6535
6574
|
name: "event_cancel_order",
|
|
6536
6575
|
module: "event",
|
|
6537
|
-
description: "Cancel a pending event contract order. [CAUTION] Cancels a real order. Before cancelling, call event_get_orders(
|
|
6576
|
+
description: "Cancel a pending event contract order. [CAUTION] Cancels a real order. Before cancelling, call event_get_orders(status=open) to obtain the ordId and confirm the order is still pending. instId must be the full event contract instrument ID (e.g. BTC-ABOVE-DAILY-260224-1600-69700), NOT a spot trading pair.",
|
|
6538
6577
|
isWrite: true,
|
|
6539
6578
|
inputSchema: {
|
|
6540
6579
|
type: "object",
|
|
@@ -6582,27 +6621,27 @@ var PATH_SIGNAL_HISTORY = "/api/v5/journal/smartmoney/signal-history";
|
|
|
6582
6621
|
var SIGNAL_POOL_FILTER_PROPS = {
|
|
6583
6622
|
sortType: {
|
|
6584
6623
|
type: "string",
|
|
6585
|
-
description: "pnl
|
|
6624
|
+
description: "Pool ranking: pnl|pnlRatio (default pnl)"
|
|
6586
6625
|
},
|
|
6587
6626
|
period: {
|
|
6588
6627
|
type: "string",
|
|
6589
|
-
description: "3|7|30|90
|
|
6628
|
+
description: "Win-rate window days: 3|7|30|90 (default 90). Not snapshot range."
|
|
6590
6629
|
},
|
|
6591
6630
|
pnl: {
|
|
6592
6631
|
type: "string",
|
|
6593
|
-
description: "PNL_ANY|PNL_TOP50|PNL_TOP20|PNL_TOP5"
|
|
6632
|
+
description: "Top N% by PnL: PNL_ANY|PNL_TOP50|PNL_TOP20|PNL_TOP5 (default PNL_ANY)"
|
|
6594
6633
|
},
|
|
6595
6634
|
winRatio: {
|
|
6596
6635
|
type: "string",
|
|
6597
|
-
description: "WR_ANY|WR_GE_50|WR_GE_80"
|
|
6636
|
+
description: "Min win-rate: WR_ANY|WR_GE_50|WR_GE_80 (default WR_ANY)"
|
|
6598
6637
|
},
|
|
6599
6638
|
maxRetreat: {
|
|
6600
6639
|
type: "string",
|
|
6601
|
-
description: "MR_ANY|MR_LE_20|MR_LE_50"
|
|
6640
|
+
description: "Max drawdown: MR_ANY|MR_LE_20|MR_LE_50 (default MR_ANY)"
|
|
6602
6641
|
},
|
|
6603
6642
|
asset: {
|
|
6604
6643
|
type: "string",
|
|
6605
|
-
description: "AUM_ANY|AUM_TOP50|AUM_TOP20|AUM_TOP5"
|
|
6644
|
+
description: "Top N% by AUM: AUM_ANY|AUM_TOP50|AUM_TOP20|AUM_TOP5 (default AUM_ANY)"
|
|
6606
6645
|
}
|
|
6607
6646
|
};
|
|
6608
6647
|
var LEADERBOARD_POOL_FILTER_PROPS = {
|
|
@@ -6654,39 +6693,39 @@ function registerSmartmoneyTools() {
|
|
|
6654
6693
|
{
|
|
6655
6694
|
name: "smartmoney_get_overview",
|
|
6656
6695
|
module: "smartmoney",
|
|
6657
|
-
description: "Multi-currency smart money overview ranked by most-watched
|
|
6696
|
+
description: "Multi-currency smart money overview, ranked by tradersWithPosition DESC (most-watched first). Requires either ts (recommended, Date.now()) or dataVersion (yyyyMMddHHmm UTC) \u2014 at least one must be set; ts wins when both are sent. For single-currency signal with entry prices and trend, use smartmoney_get_signal.",
|
|
6658
6697
|
isWrite: false,
|
|
6659
6698
|
inputSchema: {
|
|
6660
6699
|
type: "object",
|
|
6661
6700
|
properties: {
|
|
6662
|
-
|
|
6701
|
+
ts: {
|
|
6663
6702
|
type: "string",
|
|
6664
|
-
description: "
|
|
6703
|
+
description: "Recommended. Timestamp ms \u2014 use Date.now() for latest."
|
|
6665
6704
|
},
|
|
6666
|
-
|
|
6705
|
+
dataVersion: {
|
|
6667
6706
|
type: "string",
|
|
6668
|
-
description: "
|
|
6707
|
+
description: "Alternative. yyyyMMddHHmm UTC for prior snapshot. If both sent, ts wins."
|
|
6669
6708
|
},
|
|
6670
6709
|
instType: {
|
|
6671
6710
|
type: "string",
|
|
6672
|
-
description: "SPOT|MARGIN|FUTURES|SWAP|OPTION"
|
|
6711
|
+
description: "SPOT|MARGIN|FUTURES|SWAP|OPTION (default SWAP)"
|
|
6673
6712
|
},
|
|
6674
6713
|
...SIGNAL_POOL_FILTER_PROPS,
|
|
6675
6714
|
lmtNum: {
|
|
6676
6715
|
type: "string",
|
|
6677
|
-
description: "Trader pool size 1-500"
|
|
6716
|
+
description: "Trader pool size 1-500 (default 100)"
|
|
6678
6717
|
},
|
|
6679
6718
|
instCcyList: {
|
|
6680
6719
|
type: "string",
|
|
6681
|
-
description: "Comma-separated e.g. BTC,ETH,SOL"
|
|
6720
|
+
description: "Comma-separated currency codes e.g. BTC,ETH,SOL (prefix-matched against instId)"
|
|
6682
6721
|
},
|
|
6683
6722
|
instCcy: {
|
|
6684
6723
|
type: "string",
|
|
6685
|
-
description: "Single currency e.g. BTC"
|
|
6724
|
+
description: "Single currency e.g. BTC; alias for instCcyList (instCcyList wins if both set)"
|
|
6686
6725
|
},
|
|
6687
6726
|
topInstruments: {
|
|
6688
6727
|
type: "string",
|
|
6689
|
-
description: "Top N instruments 1-100"
|
|
6728
|
+
description: "Top N instruments 1-100 (default 20)"
|
|
6690
6729
|
}
|
|
6691
6730
|
}
|
|
6692
6731
|
},
|
|
@@ -6718,35 +6757,35 @@ function registerSmartmoneyTools() {
|
|
|
6718
6757
|
{
|
|
6719
6758
|
name: "smartmoney_get_signal",
|
|
6720
6759
|
module: "smartmoney",
|
|
6721
|
-
description: "Single-currency consensus signal: long/short ratio, entry prices, trend, capital flow. Requires instId or instCcy.
|
|
6760
|
+
description: "Single-currency consensus signal: long/short ratio, entry prices, trend, capital flow. Requires either instId (e.g. BTC-USDT-SWAP, recommended) or instCcy (SPOT/SWAP only) \u2014 instId wins when both are sent. Requires either ts (recommended, Date.now()) or dataVersion (yyyyMMddHHmm UTC) \u2014 at least one must be set; ts wins when both are sent. For multi-currency overview, use smartmoney_get_overview. For timeline, use smartmoney_get_signal_history.",
|
|
6722
6761
|
isWrite: false,
|
|
6723
6762
|
inputSchema: {
|
|
6724
6763
|
type: "object",
|
|
6725
6764
|
properties: {
|
|
6726
6765
|
instId: {
|
|
6727
6766
|
type: "string",
|
|
6728
|
-
description: "e.g. BTC-USDT-SWAP
|
|
6767
|
+
description: "Recommended. e.g. BTC-USDT-SWAP"
|
|
6729
6768
|
},
|
|
6730
6769
|
instCcy: {
|
|
6731
6770
|
type: "string",
|
|
6732
|
-
description: "e.g. BTC
|
|
6771
|
+
description: "e.g. BTC (SPOT/SWAP only); instId takes precedence if both set"
|
|
6733
6772
|
},
|
|
6734
|
-
|
|
6773
|
+
ts: {
|
|
6735
6774
|
type: "string",
|
|
6736
|
-
description: "
|
|
6775
|
+
description: "Recommended. Timestamp ms \u2014 use Date.now() for latest."
|
|
6737
6776
|
},
|
|
6738
|
-
|
|
6777
|
+
dataVersion: {
|
|
6739
6778
|
type: "string",
|
|
6740
|
-
description: "
|
|
6779
|
+
description: "Alternative. yyyyMMddHHmm UTC for prior snapshot. If both sent, ts wins."
|
|
6741
6780
|
},
|
|
6742
6781
|
...SIGNAL_POOL_FILTER_PROPS,
|
|
6743
6782
|
lmtNum: {
|
|
6744
6783
|
type: "string",
|
|
6745
|
-
description: "Trader pool size 1-500"
|
|
6784
|
+
description: "Trader pool size 1-500 (default 100)"
|
|
6746
6785
|
},
|
|
6747
6786
|
authorIds: {
|
|
6748
6787
|
type: "string",
|
|
6749
|
-
description: "Comma-separated user IDs e.g. 1001,1002"
|
|
6788
|
+
description: "Comma-separated user IDs e.g. 1001,1002 \u2014 restricts the trader pool to these IDs only (precise filter)"
|
|
6750
6789
|
}
|
|
6751
6790
|
}
|
|
6752
6791
|
},
|
|
@@ -6782,7 +6821,7 @@ function registerSmartmoneyTools() {
|
|
|
6782
6821
|
{
|
|
6783
6822
|
name: "smartmoney_get_signal_history",
|
|
6784
6823
|
module: "smartmoney",
|
|
6785
|
-
description: "Signal history timeline sorted by ts DESC for trend analysis. Requires instId.
|
|
6824
|
+
description: "Signal history timeline sorted by ts DESC for trend analysis. Requires instId. Requires either ts (recommended, Date.now()) or dataVersion (yyyyMMddHHmm UTC) \u2014 at least one must be set; ts wins when both are sent. For current snapshot, use smartmoney_get_signal.",
|
|
6786
6825
|
isWrite: false,
|
|
6787
6826
|
inputSchema: {
|
|
6788
6827
|
type: "object",
|
|
@@ -6791,13 +6830,13 @@ function registerSmartmoneyTools() {
|
|
|
6791
6830
|
type: "string",
|
|
6792
6831
|
description: "e.g. BTC-USDT-SWAP"
|
|
6793
6832
|
},
|
|
6794
|
-
|
|
6833
|
+
ts: {
|
|
6795
6834
|
type: "string",
|
|
6796
|
-
description: "
|
|
6835
|
+
description: "Recommended. Timestamp ms \u2014 use Date.now() for latest."
|
|
6797
6836
|
},
|
|
6798
|
-
|
|
6837
|
+
dataVersion: {
|
|
6799
6838
|
type: "string",
|
|
6800
|
-
description: "
|
|
6839
|
+
description: "Alternative. yyyyMMddHHmm UTC for prior snapshot. If both sent, ts wins."
|
|
6801
6840
|
},
|
|
6802
6841
|
granularity: {
|
|
6803
6842
|
type: "string",
|
|
@@ -10406,6 +10445,30 @@ function resolveBaseUrl(site, tomlBaseUrl) {
|
|
|
10406
10445
|
}
|
|
10407
10446
|
return rawBaseUrl.replace(/\/+$/, "");
|
|
10408
10447
|
}
|
|
10448
|
+
function resolveSourceTag(cli, defaultTag, opts = {}) {
|
|
10449
|
+
const readEnv = opts.readEnv !== false;
|
|
10450
|
+
const cliSkill = cli.skill?.trim();
|
|
10451
|
+
if (cliSkill) {
|
|
10452
|
+
if (isValidToken(cliSkill)) return composeTag(defaultTag, cliSkill);
|
|
10453
|
+
console.warn("--skill value format invalid (expected 12-char Base32), ignoring");
|
|
10454
|
+
}
|
|
10455
|
+
if (readEnv) {
|
|
10456
|
+
const envToken = process.env.OKX_SKILL_TOKEN?.trim();
|
|
10457
|
+
if (envToken) {
|
|
10458
|
+
if (isValidToken(envToken)) return composeTag(defaultTag, envToken);
|
|
10459
|
+
console.warn("OKX_SKILL_TOKEN format invalid, ignoring");
|
|
10460
|
+
}
|
|
10461
|
+
}
|
|
10462
|
+
const sourceTag = cli.sourceTag?.trim();
|
|
10463
|
+
if (sourceTag) return sourceTag;
|
|
10464
|
+
return defaultTag;
|
|
10465
|
+
}
|
|
10466
|
+
function composeTag(defaultTag, token) {
|
|
10467
|
+
return `${defaultTag}${TAG_JOIN}${token}`;
|
|
10468
|
+
}
|
|
10469
|
+
function isValidToken(s) {
|
|
10470
|
+
return TOKEN_REGEX.test(s);
|
|
10471
|
+
}
|
|
10409
10472
|
function resolveDemo(cli, toml) {
|
|
10410
10473
|
if (cli.demo && cli.live) {
|
|
10411
10474
|
throw new ConfigError(
|
|
@@ -10417,7 +10480,7 @@ function resolveDemo(cli, toml) {
|
|
|
10417
10480
|
if (cli.demo === true) return true;
|
|
10418
10481
|
return process.env.OKX_DEMO === "1" || process.env.OKX_DEMO === "true" || (toml.demo ?? false);
|
|
10419
10482
|
}
|
|
10420
|
-
function loadConfig(cli) {
|
|
10483
|
+
function loadConfig(cli, opts = {}) {
|
|
10421
10484
|
const toml = readTomlProfile(cli.profile);
|
|
10422
10485
|
const creds = loadCredentials(toml);
|
|
10423
10486
|
const demo = resolveDemo(cli, toml);
|
|
@@ -10437,6 +10500,7 @@ function loadConfig(cli) {
|
|
|
10437
10500
|
"proxy_url must start with http:// or https://. SOCKS proxies are not supported."
|
|
10438
10501
|
);
|
|
10439
10502
|
}
|
|
10503
|
+
const defaultTag = opts.entryPrefix ?? DEFAULT_SOURCE_TAG;
|
|
10440
10504
|
return {
|
|
10441
10505
|
...creds,
|
|
10442
10506
|
baseUrl,
|
|
@@ -10446,7 +10510,9 @@ function loadConfig(cli) {
|
|
|
10446
10510
|
demo,
|
|
10447
10511
|
site,
|
|
10448
10512
|
userAgent: cli.userAgent,
|
|
10449
|
-
sourceTag:
|
|
10513
|
+
// sourceTag resolution: --skill > OKX_SKILL_TOKEN > --source-tag > defaultTag
|
|
10514
|
+
// MCP entry passes { readEnv: false } to honour the "MCP path not attributed" contract.
|
|
10515
|
+
sourceTag: resolveSourceTag(cli, defaultTag, { readEnv: opts.readEnv }),
|
|
10450
10516
|
proxyUrl: rawProxyUrl || void 0,
|
|
10451
10517
|
verbose: cli.verbose ?? false
|
|
10452
10518
|
};
|
|
@@ -11646,7 +11712,7 @@ async function cmdDiagnoseMcp(options = {}) {
|
|
|
11646
11712
|
|
|
11647
11713
|
// src/commands/diagnose.ts
|
|
11648
11714
|
var CLI_VERSION = readCliVersion();
|
|
11649
|
-
var GIT_HASH = true ? "
|
|
11715
|
+
var GIT_HASH = true ? "7acf49fb" : "dev";
|
|
11650
11716
|
function maskKey2(key) {
|
|
11651
11717
|
if (!key) return "(not set)";
|
|
11652
11718
|
if (key.length <= 8) return "****";
|
|
@@ -12938,12 +13004,12 @@ var CLI_REGISTRY = {
|
|
|
12938
13004
|
},
|
|
12939
13005
|
orders: {
|
|
12940
13006
|
toolName: "event_get_orders",
|
|
12941
|
-
usage: "okx event orders [--instId <id>] [--state
|
|
13007
|
+
usage: "okx event orders [--status <open|history|archive>] [--instId <id>] [--ordType <type>] [--state <canceled|filled>] [--after <id>] [--before <id>] [--begin <ms>] [--end <ms>] [--limit <n>] [--json]",
|
|
12942
13008
|
description: "Query event contract orders"
|
|
12943
13009
|
},
|
|
12944
13010
|
fills: {
|
|
12945
13011
|
toolName: "event_get_fills",
|
|
12946
|
-
usage: "okx event fills [--instId <id>] [--limit <n>] [--json]",
|
|
13012
|
+
usage: "okx event fills [--archive] [--instId <id>] [--ordId <id>] [--after <id>] [--before <id>] [--begin <ms>] [--end <ms>] [--limit <n>] [--json]",
|
|
12947
13013
|
description: "Get event contract fill history"
|
|
12948
13014
|
}
|
|
12949
13015
|
}
|
|
@@ -12954,18 +13020,18 @@ var CLI_REGISTRY = {
|
|
|
12954
13020
|
commands: {
|
|
12955
13021
|
overview: {
|
|
12956
13022
|
toolName: "smartmoney_get_overview",
|
|
12957
|
-
usage: "okx smartmoney overview [--
|
|
12958
|
-
description: "Multi-currency smart money overview
|
|
13023
|
+
usage: "okx smartmoney overview [--ts <ms> | --dataVersion <ver>] [--instType <SWAP|SPOT>] [--sortType <pnl|pnlRatio>] [--period <3|7|30|90>] [--pnl <tier>] [--winRatio <tier>] [--maxRetreat <tier>] [--asset <tier>] [--lmtNum <n>] [--instCcyList <ccys>] [--instCcy <ccy>] [--topInstruments <n>] [--json]",
|
|
13024
|
+
description: "Multi-currency smart money overview ranked by tradersWithPosition DESC (requires --ts or --dataVersion; --ts takes precedence)"
|
|
12959
13025
|
},
|
|
12960
13026
|
signal: {
|
|
12961
13027
|
toolName: "smartmoney_get_signal",
|
|
12962
|
-
usage: "okx smartmoney signal [--instId <id>] [--instCcy <ccy>] [--
|
|
12963
|
-
description: "Single-currency aggregated consensus signal"
|
|
13028
|
+
usage: "okx smartmoney signal [--instId <id>] [--instCcy <ccy>] [--ts <ms> | --dataVersion <ver>] [--sortType <pnl|pnlRatio>] [--period <3|7|30|90>] [--pnl <tier>] [--winRatio <tier>] [--maxRetreat <tier>] [--asset <tier>] [--lmtNum <n>] [--authorIds <ids>] [--json]",
|
|
13029
|
+
description: "Single-currency aggregated consensus signal (requires --instId or --instCcy, and --ts or --dataVersion; --instId / --ts take precedence)"
|
|
12964
13030
|
},
|
|
12965
13031
|
"signal-history": {
|
|
12966
13032
|
toolName: "smartmoney_get_signal_history",
|
|
12967
|
-
usage: "okx smartmoney signal-history --instId <id> [--
|
|
12968
|
-
description: "Signal history timeline
|
|
13033
|
+
usage: "okx smartmoney signal-history --instId <id> [--ts <ms> | --dataVersion <ver>] [--granularity <1h|1d>] [--limit <n>] [--sortType <pnl|pnlRatio>] [--period <3|7|30|90>] [--pnl <tier>] [--winRatio <tier>] [--maxRetreat <tier>] [--asset <tier>] [--json]",
|
|
13034
|
+
description: "Signal history timeline sorted by ts DESC (requires --instId and --ts/--dataVersion)"
|
|
12969
13035
|
},
|
|
12970
13036
|
traders: {
|
|
12971
13037
|
toolName: "smartmoney_get_traders",
|
|
@@ -13490,17 +13556,21 @@ async function cmdNewsSentimentRank(run, opts) {
|
|
|
13490
13556
|
|
|
13491
13557
|
// src/config/loader.ts
|
|
13492
13558
|
function loadProfileConfig(opts) {
|
|
13493
|
-
return loadConfig(
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13559
|
+
return loadConfig(
|
|
13560
|
+
{
|
|
13561
|
+
profile: opts.profile,
|
|
13562
|
+
modules: opts.modules,
|
|
13563
|
+
readOnly: opts.readOnly ?? false,
|
|
13564
|
+
demo: opts.demo,
|
|
13565
|
+
live: opts.live,
|
|
13566
|
+
site: opts.site,
|
|
13567
|
+
userAgent: opts.userAgent,
|
|
13568
|
+
sourceTag: opts.sourceTag,
|
|
13569
|
+
skill: opts.skill,
|
|
13570
|
+
verbose: opts.verbose
|
|
13571
|
+
},
|
|
13572
|
+
{ entryPrefix: opts.entryPrefix, readEnv: opts.readEnv }
|
|
13573
|
+
);
|
|
13504
13574
|
}
|
|
13505
13575
|
|
|
13506
13576
|
// src/help.ts
|
|
@@ -13509,12 +13579,13 @@ var HELP_TREE = generateHelpTree();
|
|
|
13509
13579
|
function printGlobalHelp() {
|
|
13510
13580
|
const lines = [
|
|
13511
13581
|
"",
|
|
13512
|
-
`Usage: okx [--profile <name>] [--demo | --live] [--json] <module> <action> [args...]`,
|
|
13582
|
+
`Usage: okx [--profile <name>] [--demo | --live] [--skill <token>] [--json] <module> <action> [args...]`,
|
|
13513
13583
|
"",
|
|
13514
13584
|
"Global Options:",
|
|
13515
13585
|
` --profile <name> Use a named profile from ${configFilePath()}`,
|
|
13516
13586
|
" --demo Use simulated trading (demo) mode",
|
|
13517
13587
|
" --live Force live trading mode (overrides profile demo=true; mutually exclusive with --demo)",
|
|
13588
|
+
" --skill <token> OKX skill token for order tagging (from SKILL.md)",
|
|
13518
13589
|
" --json Output raw JSON",
|
|
13519
13590
|
" --env With --json, wrap output as {env, profile, data}",
|
|
13520
13591
|
" --verbose Show detailed network request/response info (stderr)",
|
|
@@ -13647,6 +13718,7 @@ import { parseArgs } from "util";
|
|
|
13647
13718
|
var CLI_OPTIONS = {
|
|
13648
13719
|
profile: { type: "string" },
|
|
13649
13720
|
demo: { type: "boolean", default: false },
|
|
13721
|
+
skill: { type: "string" },
|
|
13650
13722
|
json: { type: "boolean", default: false },
|
|
13651
13723
|
env: { type: "boolean", default: false },
|
|
13652
13724
|
help: { type: "boolean", default: false },
|
|
@@ -17627,8 +17699,14 @@ async function cmdEventMarkets(run, opts) {
|
|
|
17627
17699
|
}
|
|
17628
17700
|
async function cmdEventOrders(run, opts) {
|
|
17629
17701
|
const result = await run("event_get_orders", {
|
|
17702
|
+
status: opts.status,
|
|
17630
17703
|
instId: opts.instId,
|
|
17704
|
+
ordType: opts.ordType,
|
|
17631
17705
|
state: opts.state,
|
|
17706
|
+
after: opts.after,
|
|
17707
|
+
before: opts.before,
|
|
17708
|
+
begin: opts.begin,
|
|
17709
|
+
end: opts.end,
|
|
17632
17710
|
limit: opts.limit
|
|
17633
17711
|
});
|
|
17634
17712
|
const data = getData9(result);
|
|
@@ -17647,7 +17725,13 @@ async function cmdEventOrders(run, opts) {
|
|
|
17647
17725
|
}
|
|
17648
17726
|
async function cmdEventFills(run, opts) {
|
|
17649
17727
|
const result = await run("event_get_fills", {
|
|
17728
|
+
archive: opts.archive,
|
|
17650
17729
|
instId: opts.instId,
|
|
17730
|
+
ordId: opts.ordId,
|
|
17731
|
+
after: opts.after,
|
|
17732
|
+
before: opts.before,
|
|
17733
|
+
begin: opts.begin,
|
|
17734
|
+
end: opts.end,
|
|
17651
17735
|
limit: opts.limit
|
|
17652
17736
|
});
|
|
17653
17737
|
const data = getData9(result);
|
|
@@ -17836,7 +17920,7 @@ async function cmdEventCancel(run, opts) {
|
|
|
17836
17920
|
// src/index.ts
|
|
17837
17921
|
var _require3 = createRequire3(import.meta.url);
|
|
17838
17922
|
var CLI_VERSION2 = _require3("../package.json").version;
|
|
17839
|
-
var GIT_HASH2 = true ? "
|
|
17923
|
+
var GIT_HASH2 = true ? "7acf49fb" : "dev";
|
|
17840
17924
|
function handlePilotCommand(action, json, force, binaryPath) {
|
|
17841
17925
|
if (action === "status") return cmdPilotStatus(json, binaryPath);
|
|
17842
17926
|
if (action === "install") return cmdPilotInstall(json, binaryPath);
|
|
@@ -18959,8 +19043,29 @@ function handleEventCommand(run, action, rest, v, json) {
|
|
|
18959
19043
|
}),
|
|
18960
19044
|
amend: () => cmdEventAmend(run, { instId: v.instId ?? rest[0], ordId: v.ordId ?? rest[1], px: v.px, sz: v.sz, json }),
|
|
18961
19045
|
cancel: () => cmdEventCancel(run, { instId: v.instId ?? rest[0], ordId: v.ordId ?? rest[1], json }),
|
|
18962
|
-
orders: () => cmdEventOrders(run, {
|
|
18963
|
-
|
|
19046
|
+
orders: () => cmdEventOrders(run, {
|
|
19047
|
+
status: v.status,
|
|
19048
|
+
instId: v.instId,
|
|
19049
|
+
ordType: v.ordType,
|
|
19050
|
+
state: v.state,
|
|
19051
|
+
after: v.after,
|
|
19052
|
+
before: v.before,
|
|
19053
|
+
begin: v.begin,
|
|
19054
|
+
end: v.end,
|
|
19055
|
+
limit,
|
|
19056
|
+
json
|
|
19057
|
+
}),
|
|
19058
|
+
fills: () => cmdEventFills(run, {
|
|
19059
|
+
archive: v.archive ?? false,
|
|
19060
|
+
instId: v.instId,
|
|
19061
|
+
ordId: v.ordId,
|
|
19062
|
+
after: v.after,
|
|
19063
|
+
before: v.before,
|
|
19064
|
+
begin: v.begin,
|
|
19065
|
+
end: v.end,
|
|
19066
|
+
limit,
|
|
19067
|
+
json
|
|
19068
|
+
})
|
|
18964
19069
|
};
|
|
18965
19070
|
const handler = handlers[action];
|
|
18966
19071
|
if (handler) return handler();
|
|
@@ -19005,7 +19110,7 @@ function wrapRunnerWithLogger(baseRunner, logger, verbose = false) {
|
|
|
19005
19110
|
async function runDiagnose(v) {
|
|
19006
19111
|
let config;
|
|
19007
19112
|
try {
|
|
19008
|
-
config = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
|
|
19113
|
+
config = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI", skill: v.skill, entryPrefix: "CLI" });
|
|
19009
19114
|
} catch {
|
|
19010
19115
|
}
|
|
19011
19116
|
return cmdDiagnose(config, v.profile ?? "default", { mcp: v.mcp, cli: v.cli, all: v.all, output: v.output });
|
|
@@ -19060,7 +19165,7 @@ async function main() {
|
|
|
19060
19165
|
const json = v.json ?? false;
|
|
19061
19166
|
const mgmt = routeManagementCommand(module, action, rest, json, v);
|
|
19062
19167
|
if (mgmt !== void 0) return mgmt === true ? void 0 : mgmt;
|
|
19063
|
-
const config = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
|
|
19168
|
+
const config = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI", skill: v.skill, entryPrefix: "CLI" });
|
|
19064
19169
|
setEnvContext({ demo: config.demo, profile: v.profile ?? "default" });
|
|
19065
19170
|
setJsonEnvEnabled(v.env ?? false);
|
|
19066
19171
|
const client = new OkxRestClient(config);
|