@okx_ai/okx-trade-cli 1.2.9 → 1.3.0-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/LICENSE +21 -0
- package/dist/index.js +181 -29
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/scripts/postinstall-download.js +152 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OKX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -1503,14 +1503,137 @@ var INDICATOR_BARS = [
|
|
|
1503
1503
|
"1Wutc"
|
|
1504
1504
|
];
|
|
1505
1505
|
var INDICATOR_CODE_OVERRIDES = {
|
|
1506
|
+
// Aliases
|
|
1507
|
+
"boll": "BB",
|
|
1508
|
+
// server supports BB not BOLL
|
|
1509
|
+
// Names where default rule produces underscores but backend uses no separator
|
|
1506
1510
|
"rainbow": "BTCRAINBOW",
|
|
1507
|
-
|
|
1511
|
+
// default: RAINBOW
|
|
1508
1512
|
"stoch-rsi": "STOCHRSI",
|
|
1509
|
-
|
|
1510
|
-
"
|
|
1511
|
-
//
|
|
1512
|
-
"
|
|
1513
|
+
// default: STOCH_RSI
|
|
1514
|
+
"bull-engulf": "BULLENGULF",
|
|
1515
|
+
// default: BULL_ENGULF
|
|
1516
|
+
"bear-engulf": "BEARENGULF",
|
|
1517
|
+
// default: BEAR_ENGULF
|
|
1518
|
+
"bull-harami": "BULLHARAMI",
|
|
1519
|
+
// default: BULL_HARAMI
|
|
1520
|
+
"bear-harami": "BEARHARAMI",
|
|
1521
|
+
// default: BEAR_HARAMI
|
|
1522
|
+
"bull-harami-cross": "BULLHARAMICROSS",
|
|
1523
|
+
// default: BULL_HARAMI_CROSS
|
|
1524
|
+
"bear-harami-cross": "BEARHARAMICROSS",
|
|
1525
|
+
// default: BEAR_HARAMI_CROSS
|
|
1526
|
+
"three-soldiers": "THREESOLDIERS",
|
|
1527
|
+
// default: THREE_SOLDIERS
|
|
1528
|
+
"three-crows": "THREECROWS",
|
|
1529
|
+
// default: THREE_CROWS
|
|
1530
|
+
"hanging-man": "HANGINGMAN",
|
|
1531
|
+
// default: HANGING_MAN
|
|
1532
|
+
"inverted-hammer": "INVERTEDH",
|
|
1533
|
+
// default: INVERTED_HAMMER (backend uses INVERTEDH)
|
|
1534
|
+
"shooting-star": "SHOOTINGSTAR",
|
|
1535
|
+
// default: SHOOTING_STAR
|
|
1536
|
+
"nvi-pvi": "NVIPVI",
|
|
1537
|
+
// default: NVI_PVI
|
|
1538
|
+
"top-long-short": "TOPLONGSHORT"
|
|
1539
|
+
// default: TOP_LONG_SHORT
|
|
1540
|
+
// Note: range-filter → RANGE_FILTER is correct via the default rule; no override needed.
|
|
1513
1541
|
};
|
|
1542
|
+
var KNOWN_INDICATORS = [
|
|
1543
|
+
// Moving Averages
|
|
1544
|
+
{ name: "ma", description: "Simple Moving Average" },
|
|
1545
|
+
{ name: "ema", description: "Exponential Moving Average" },
|
|
1546
|
+
{ name: "wma", description: "Weighted Moving Average" },
|
|
1547
|
+
{ name: "dema", description: "Double Exponential Moving Average" },
|
|
1548
|
+
{ name: "tema", description: "Triple Exponential Moving Average" },
|
|
1549
|
+
{ name: "zlema", description: "Zero-Lag Exponential Moving Average" },
|
|
1550
|
+
{ name: "hma", description: "Hull Moving Average" },
|
|
1551
|
+
{ name: "kama", description: "Kaufman Adaptive Moving Average" },
|
|
1552
|
+
// Trend
|
|
1553
|
+
{ name: "macd", description: "MACD" },
|
|
1554
|
+
{ name: "sar", description: "Parabolic SAR" },
|
|
1555
|
+
{ name: "adx", description: "Average Directional Index" },
|
|
1556
|
+
{ name: "aroon", description: "Aroon Indicator" },
|
|
1557
|
+
{ name: "cci", description: "Commodity Channel Index" },
|
|
1558
|
+
{ name: "dpo", description: "Detrended Price Oscillator" },
|
|
1559
|
+
{ name: "envelope", description: "Envelope" },
|
|
1560
|
+
{ name: "halftrend", description: "HalfTrend" },
|
|
1561
|
+
{ name: "alphatrend", description: "AlphaTrend" },
|
|
1562
|
+
// Momentum
|
|
1563
|
+
{ name: "rsi", description: "Relative Strength Index" },
|
|
1564
|
+
{ name: "stoch-rsi", description: "Stochastic RSI" },
|
|
1565
|
+
{ name: "stoch", description: "Stochastic Oscillator" },
|
|
1566
|
+
{ name: "roc", description: "Rate of Change" },
|
|
1567
|
+
{ name: "mom", description: "Momentum" },
|
|
1568
|
+
{ name: "ppo", description: "Price Percentage Oscillator" },
|
|
1569
|
+
{ name: "trix", description: "TRIX" },
|
|
1570
|
+
{ name: "ao", description: "Awesome Oscillator" },
|
|
1571
|
+
{ name: "uo", description: "Ultimate Oscillator" },
|
|
1572
|
+
{ name: "wr", description: "Williams %R" },
|
|
1573
|
+
// Volatility
|
|
1574
|
+
{ name: "bb", description: "Bollinger Bands" },
|
|
1575
|
+
{ name: "boll", description: "Bollinger Bands (alias for bb)" },
|
|
1576
|
+
{ name: "bbwidth", description: "Bollinger Band Width" },
|
|
1577
|
+
{ name: "bbpct", description: "Bollinger Band %B" },
|
|
1578
|
+
{ name: "atr", description: "Average True Range" },
|
|
1579
|
+
{ name: "keltner", description: "Keltner Channel" },
|
|
1580
|
+
{ name: "donchian", description: "Donchian Channel" },
|
|
1581
|
+
{ name: "hv", description: "Historical Volatility" },
|
|
1582
|
+
{ name: "stddev", description: "Standard Deviation" },
|
|
1583
|
+
// Volume
|
|
1584
|
+
{ name: "obv", description: "On-Balance Volume" },
|
|
1585
|
+
{ name: "vwap", description: "Volume Weighted Average Price" },
|
|
1586
|
+
{ name: "mvwap", description: "Moving VWAP" },
|
|
1587
|
+
{ name: "cmf", description: "Chaikin Money Flow" },
|
|
1588
|
+
{ name: "mfi", description: "Money Flow Index" },
|
|
1589
|
+
{ name: "ad", description: "Accumulation/Distribution" },
|
|
1590
|
+
// Statistical
|
|
1591
|
+
{ name: "lr", description: "Linear Regression" },
|
|
1592
|
+
{ name: "slope", description: "Linear Regression Slope" },
|
|
1593
|
+
{ name: "angle", description: "Linear Regression Angle" },
|
|
1594
|
+
{ name: "variance", description: "Variance" },
|
|
1595
|
+
{ name: "meandev", description: "Mean Deviation" },
|
|
1596
|
+
{ name: "sigma", description: "Sigma" },
|
|
1597
|
+
{ name: "stderr", description: "Standard Error" },
|
|
1598
|
+
// Custom
|
|
1599
|
+
{ name: "kdj", description: "KDJ Stochastic Oscillator" },
|
|
1600
|
+
{ name: "supertrend", description: "Supertrend" },
|
|
1601
|
+
// Ichimoku
|
|
1602
|
+
{ name: "tenkan", description: "Ichimoku Tenkan-sen (Conversion Line)" },
|
|
1603
|
+
{ name: "kijun", description: "Ichimoku Kijun-sen (Base Line)" },
|
|
1604
|
+
{ name: "senkoa", description: "Ichimoku Senkou Span A (Leading Span A)" },
|
|
1605
|
+
{ name: "senkob", description: "Ichimoku Senkou Span B (Leading Span B)" },
|
|
1606
|
+
{ name: "chikou", description: "Ichimoku Chikou Span (Lagging Span)" },
|
|
1607
|
+
// Candlestick Patterns
|
|
1608
|
+
{ name: "doji", description: "Doji candlestick pattern" },
|
|
1609
|
+
{ name: "bull-engulf", description: "Bullish Engulfing pattern" },
|
|
1610
|
+
{ name: "bear-engulf", description: "Bearish Engulfing pattern" },
|
|
1611
|
+
{ name: "bull-harami", description: "Bullish Harami pattern" },
|
|
1612
|
+
{ name: "bear-harami", description: "Bearish Harami pattern" },
|
|
1613
|
+
{ name: "bull-harami-cross", description: "Bullish Harami Cross pattern" },
|
|
1614
|
+
{ name: "bear-harami-cross", description: "Bearish Harami Cross pattern" },
|
|
1615
|
+
{ name: "three-soldiers", description: "Three White Soldiers pattern" },
|
|
1616
|
+
{ name: "three-crows", description: "Three Black Crows pattern" },
|
|
1617
|
+
{ name: "hanging-man", description: "Hanging Man pattern" },
|
|
1618
|
+
{ name: "inverted-hammer", description: "Inverted Hammer pattern" },
|
|
1619
|
+
{ name: "shooting-star", description: "Shooting Star pattern" },
|
|
1620
|
+
// Bitcoin On-Chain
|
|
1621
|
+
{ name: "ahr999", description: "AHR999 Bitcoin accumulation index" },
|
|
1622
|
+
{ name: "rainbow", description: "Bitcoin Rainbow Chart" },
|
|
1623
|
+
// Other
|
|
1624
|
+
{ name: "fisher", description: "Fisher Transform" },
|
|
1625
|
+
{ name: "nvi-pvi", description: "Negative/Positive Volume Index (returns both)" },
|
|
1626
|
+
{ name: "pmax", description: "PMAX" },
|
|
1627
|
+
{ name: "qqe", description: "QQE Mod" },
|
|
1628
|
+
{ name: "tdi", description: "Traders Dynamic Index" },
|
|
1629
|
+
{ name: "waddah", description: "Waddah Attar Explosion" },
|
|
1630
|
+
{ name: "range-filter", description: "Range Filter" },
|
|
1631
|
+
{ name: "cho", description: "Chande Momentum Oscillator" },
|
|
1632
|
+
{ name: "tr", description: "True Range" },
|
|
1633
|
+
{ name: "tp", description: "Typical Price" },
|
|
1634
|
+
{ name: "mp", description: "Median Price" },
|
|
1635
|
+
{ name: "top-long-short", description: "Top Trader Long/Short Ratio (timeframe-independent)" }
|
|
1636
|
+
];
|
|
1514
1637
|
function resolveIndicatorCode(name) {
|
|
1515
1638
|
const lower = name.toLowerCase();
|
|
1516
1639
|
return INDICATOR_CODE_OVERRIDES[lower] ?? name.toUpperCase().replace(/-/g, "_");
|
|
@@ -1537,7 +1660,7 @@ function registerIndicatorTools() {
|
|
|
1537
1660
|
},
|
|
1538
1661
|
indicator: {
|
|
1539
1662
|
type: "string",
|
|
1540
|
-
description: "Indicator name (case-insensitive).
|
|
1663
|
+
description: "Indicator name (case-insensitive). Call market_list_indicators to see all supported names."
|
|
1541
1664
|
},
|
|
1542
1665
|
bar: {
|
|
1543
1666
|
type: "string",
|
|
@@ -1594,6 +1717,14 @@ function registerIndicatorTools() {
|
|
|
1594
1717
|
);
|
|
1595
1718
|
return normalizeResponse(response);
|
|
1596
1719
|
}
|
|
1720
|
+
},
|
|
1721
|
+
{
|
|
1722
|
+
name: "market_list_indicators",
|
|
1723
|
+
module: "market",
|
|
1724
|
+
description: "List all supported technical indicator names and descriptions. Call this before market_get_indicator to discover valid indicator names. No credentials required.",
|
|
1725
|
+
isWrite: false,
|
|
1726
|
+
inputSchema: { type: "object", properties: {} },
|
|
1727
|
+
handler: async () => ({ data: KNOWN_INDICATORS })
|
|
1597
1728
|
}
|
|
1598
1729
|
];
|
|
1599
1730
|
}
|
|
@@ -7770,6 +7901,10 @@ var activeOutput = stdioOutput;
|
|
|
7770
7901
|
function setOutput(impl) {
|
|
7771
7902
|
activeOutput = impl;
|
|
7772
7903
|
}
|
|
7904
|
+
var envContext = null;
|
|
7905
|
+
function setEnvContext(ctx) {
|
|
7906
|
+
envContext = ctx;
|
|
7907
|
+
}
|
|
7773
7908
|
function output(message) {
|
|
7774
7909
|
activeOutput.out(message);
|
|
7775
7910
|
}
|
|
@@ -7783,9 +7918,18 @@ function errorLine(message) {
|
|
|
7783
7918
|
activeOutput.err(message + EOL);
|
|
7784
7919
|
}
|
|
7785
7920
|
function printJson(data) {
|
|
7786
|
-
|
|
7921
|
+
const payload = envContext ? {
|
|
7922
|
+
env: envContext.demo ? "demo" : "live",
|
|
7923
|
+
profile: envContext.profile,
|
|
7924
|
+
data
|
|
7925
|
+
} : data;
|
|
7926
|
+
activeOutput.out(JSON.stringify(payload, null, 2) + EOL);
|
|
7787
7927
|
}
|
|
7788
7928
|
function printTable(rows) {
|
|
7929
|
+
if (envContext) {
|
|
7930
|
+
const envLabel = envContext.demo ? "demo (simulated trading)" : "live";
|
|
7931
|
+
activeOutput.out(`Environment: ${envLabel}` + EOL + EOL);
|
|
7932
|
+
}
|
|
7789
7933
|
if (rows.length === 0) {
|
|
7790
7934
|
activeOutput.out("(no data)" + EOL);
|
|
7791
7935
|
return;
|
|
@@ -8364,7 +8508,7 @@ async function cmdDiagnoseMcp(options = {}) {
|
|
|
8364
8508
|
|
|
8365
8509
|
// src/commands/diagnose.ts
|
|
8366
8510
|
var CLI_VERSION = readCliVersion();
|
|
8367
|
-
var GIT_HASH = true ? "
|
|
8511
|
+
var GIT_HASH = true ? "ab11ece" : "dev";
|
|
8368
8512
|
function maskKey2(key) {
|
|
8369
8513
|
if (!key) return "(not set)";
|
|
8370
8514
|
if (key.length <= 8) return "****";
|
|
@@ -9896,6 +10040,10 @@ async function cmdMarketCandles(run, instId, opts) {
|
|
|
9896
10040
|
}))
|
|
9897
10041
|
);
|
|
9898
10042
|
}
|
|
10043
|
+
function cmdMarketIndicatorList(json) {
|
|
10044
|
+
if (json) return printJson(KNOWN_INDICATORS);
|
|
10045
|
+
printTable(KNOWN_INDICATORS.map(({ name, description }) => ({ name, description })));
|
|
10046
|
+
}
|
|
9899
10047
|
async function cmdMarketIndicator(run, indicator, instId, opts) {
|
|
9900
10048
|
const params = opts.params ? opts.params.split(",").map((p) => Number(p.trim())).filter((n) => !Number.isNaN(n)) : void 0;
|
|
9901
10049
|
const result = await run("market_get_indicator", {
|
|
@@ -12568,7 +12716,7 @@ function printSkillInstallResult(meta, json) {
|
|
|
12568
12716
|
// src/index.ts
|
|
12569
12717
|
var _require3 = createRequire3(import.meta.url);
|
|
12570
12718
|
var CLI_VERSION2 = _require3("../package.json").version;
|
|
12571
|
-
var GIT_HASH2 = true ? "
|
|
12719
|
+
var GIT_HASH2 = true ? "ab11ece" : "dev";
|
|
12572
12720
|
function handleConfigCommand(action, rest, json, lang, force) {
|
|
12573
12721
|
if (action === "init") return cmdConfigInit(lang === "zh" ? "zh" : "en");
|
|
12574
12722
|
if (action === "show") return cmdConfigShow(json);
|
|
@@ -12618,18 +12766,20 @@ function handleMarketPublicCommand(run, action, rest, v, json) {
|
|
|
12618
12766
|
instId: v.instId,
|
|
12619
12767
|
json
|
|
12620
12768
|
});
|
|
12621
|
-
if (action === "indicator")
|
|
12622
|
-
|
|
12623
|
-
|
|
12624
|
-
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
|
|
12628
|
-
|
|
12629
|
-
|
|
12630
|
-
|
|
12631
|
-
|
|
12632
|
-
|
|
12769
|
+
if (action === "indicator") return handleIndicatorAction(run, rest, v, json);
|
|
12770
|
+
}
|
|
12771
|
+
function handleIndicatorAction(run, rest, v, json) {
|
|
12772
|
+
if (rest[0] === "list") return cmdMarketIndicatorList(json);
|
|
12773
|
+
const limit = v.limit !== void 0 ? Number(v.limit) : void 0;
|
|
12774
|
+
const backtestTime = v["backtest-time"] !== void 0 ? Number(v["backtest-time"]) : void 0;
|
|
12775
|
+
return cmdMarketIndicator(run, rest[0], rest[1], {
|
|
12776
|
+
bar: v.bar,
|
|
12777
|
+
params: v.params,
|
|
12778
|
+
list: v.list,
|
|
12779
|
+
limit,
|
|
12780
|
+
backtestTime,
|
|
12781
|
+
json
|
|
12782
|
+
});
|
|
12633
12783
|
}
|
|
12634
12784
|
function handleMarketDataCommand(run, action, rest, v, json) {
|
|
12635
12785
|
const limit = v.limit !== void 0 ? Number(v.limit) : void 0;
|
|
@@ -13384,6 +13534,14 @@ function printHelpForLevel(positionals) {
|
|
|
13384
13534
|
else if (!subgroup) printHelp(module);
|
|
13385
13535
|
else printHelp(module, subgroup);
|
|
13386
13536
|
}
|
|
13537
|
+
async function runDiagnose(v) {
|
|
13538
|
+
let config;
|
|
13539
|
+
try {
|
|
13540
|
+
config = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
|
|
13541
|
+
} catch {
|
|
13542
|
+
}
|
|
13543
|
+
return cmdDiagnose(config, v.profile ?? "default", { mcp: v.mcp, cli: v.cli, all: v.all, output: v.output });
|
|
13544
|
+
}
|
|
13387
13545
|
async function main() {
|
|
13388
13546
|
setOutput({
|
|
13389
13547
|
out: (m) => process.stdout.write(m),
|
|
@@ -13405,15 +13563,9 @@ async function main() {
|
|
|
13405
13563
|
if (module === "config") return handleConfigCommand(action, rest, json, v.lang, v.force);
|
|
13406
13564
|
if (module === "setup") return handleSetupCommand(v);
|
|
13407
13565
|
if (module === "upgrade") return cmdUpgrade(CLI_VERSION2, { beta: v.beta, check: v.check, force: v.force }, json);
|
|
13408
|
-
if (module === "diagnose")
|
|
13409
|
-
let config2;
|
|
13410
|
-
try {
|
|
13411
|
-
config2 = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
|
|
13412
|
-
} catch {
|
|
13413
|
-
}
|
|
13414
|
-
return cmdDiagnose(config2, v.profile ?? "default", { mcp: v.mcp, cli: v.cli, all: v.all, output: v.output });
|
|
13415
|
-
}
|
|
13566
|
+
if (module === "diagnose") return runDiagnose(v);
|
|
13416
13567
|
const config = loadProfileConfig({ profile: v.profile, demo: v.demo, live: v.live, verbose: v.verbose, userAgent: `okx-trade-cli/${CLI_VERSION2}`, sourceTag: "CLI" });
|
|
13568
|
+
setEnvContext({ demo: config.demo, profile: v.profile ?? "default" });
|
|
13417
13569
|
const client = new OkxRestClient(config);
|
|
13418
13570
|
const baseRunner = createToolRunner(client, config);
|
|
13419
13571
|
const writeToolNames = new Set(allToolSpecs().filter((t) => t.isWrite).map((t) => t.name));
|