@okx_ai/okx-trade-cli 1.3.7 → 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 +67 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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).
|
|
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",
|
|
@@ -14441,7 +14491,7 @@ async function cmdDiagnoseMcp(options = {}) {
|
|
|
14441
14491
|
|
|
14442
14492
|
// src/commands/diagnose.ts
|
|
14443
14493
|
var CLI_VERSION = readCliVersion();
|
|
14444
|
-
var GIT_HASH = true ? "
|
|
14494
|
+
var GIT_HASH = true ? "52f6524c" : "dev";
|
|
14445
14495
|
function maskKey2(key) {
|
|
14446
14496
|
if (!key) return "(not set)";
|
|
14447
14497
|
if (key.length <= 8) return "****";
|
|
@@ -16848,6 +16898,7 @@ function parseCli(argv) {
|
|
|
16848
16898
|
}
|
|
16849
16899
|
|
|
16850
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).";
|
|
16851
16902
|
function getData2(result) {
|
|
16852
16903
|
return result.data;
|
|
16853
16904
|
}
|
|
@@ -17054,11 +17105,13 @@ function cmdMarketIndicatorList(json) {
|
|
|
17054
17105
|
}
|
|
17055
17106
|
async function cmdMarketIndicator(run, indicator, instId, opts) {
|
|
17056
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);
|
|
17057
17110
|
const result = await run("market_get_indicator", {
|
|
17058
17111
|
instId,
|
|
17059
17112
|
indicator,
|
|
17060
17113
|
bar: opts.bar,
|
|
17061
|
-
params:
|
|
17114
|
+
params: effectiveParams,
|
|
17062
17115
|
returnList: opts.list ?? false,
|
|
17063
17116
|
limit: opts.limit,
|
|
17064
17117
|
backtestTime: opts.backtestTime
|
|
@@ -17066,7 +17119,7 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
|
|
|
17066
17119
|
const outerArray = getData2(result);
|
|
17067
17120
|
if (opts.json) return printJson(outerArray);
|
|
17068
17121
|
if (!outerArray?.length) {
|
|
17069
|
-
|
|
17122
|
+
outputLine("No data");
|
|
17070
17123
|
return;
|
|
17071
17124
|
}
|
|
17072
17125
|
const apiCode = resolveIndicatorCode(indicator);
|
|
@@ -17075,16 +17128,18 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
|
|
|
17075
17128
|
const instData = innerArray?.[0];
|
|
17076
17129
|
const timeframes = instData?.["timeframes"];
|
|
17077
17130
|
if (!timeframes) {
|
|
17078
|
-
|
|
17131
|
+
output(JSON.stringify(outerArray, null, 2) + "\n");
|
|
17079
17132
|
return;
|
|
17080
17133
|
}
|
|
17134
|
+
let printed = false;
|
|
17081
17135
|
for (const [tf, tfData] of Object.entries(timeframes)) {
|
|
17082
17136
|
const indicators = tfData?.["indicators"];
|
|
17083
17137
|
const values = indicators?.[apiCode];
|
|
17084
17138
|
if (!values?.length) continue;
|
|
17085
|
-
|
|
17139
|
+
printed = true;
|
|
17140
|
+
output(`${instId} | ${apiCode} | ${tf}
|
|
17086
17141
|
`);
|
|
17087
|
-
|
|
17142
|
+
output("-".repeat(40) + "\n");
|
|
17088
17143
|
if (opts.list) {
|
|
17089
17144
|
const tableRows = values.map((entry) => ({
|
|
17090
17145
|
ts: new Date(Number(entry["ts"])).toLocaleString(),
|
|
@@ -17099,6 +17154,7 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
|
|
|
17099
17154
|
});
|
|
17100
17155
|
}
|
|
17101
17156
|
}
|
|
17157
|
+
if (!printed) outputLine(NO_INDICATOR_VALUES_HINT);
|
|
17102
17158
|
}
|
|
17103
17159
|
async function cmdMarketInstrumentsByCategory(run, opts) {
|
|
17104
17160
|
const result = await run("market_get_instruments_by_category", {
|
|
@@ -17172,8 +17228,9 @@ async function cmdMarketFilter(run, opts) {
|
|
|
17172
17228
|
sortOrder: opts.sortOrder,
|
|
17173
17229
|
limit: opts.limit
|
|
17174
17230
|
});
|
|
17175
|
-
const
|
|
17176
|
-
if (opts.json) return printJson(
|
|
17231
|
+
const raw = getData2(result);
|
|
17232
|
+
if (opts.json) return printJson(raw);
|
|
17233
|
+
const data = Array.isArray(raw) ? raw[0] : raw;
|
|
17177
17234
|
const rows = data?.["rows"] ?? [];
|
|
17178
17235
|
const total = data?.["total"] ?? rows.length;
|
|
17179
17236
|
outputLine(`Total: ${total}`);
|
|
@@ -21148,7 +21205,7 @@ async function cmdEventCancel(run, opts) {
|
|
|
21148
21205
|
// src/index.ts
|
|
21149
21206
|
var _require3 = createRequire3(import.meta.url);
|
|
21150
21207
|
var CLI_VERSION2 = _require3("../package.json").version;
|
|
21151
|
-
var GIT_HASH2 = true ? "
|
|
21208
|
+
var GIT_HASH2 = true ? "52f6524c" : "dev";
|
|
21152
21209
|
function handlePilotCommand(action, json, force, binaryPath) {
|
|
21153
21210
|
if (action === "status") return cmdPilotStatus(json, binaryPath);
|
|
21154
21211
|
if (action === "install") return cmdPilotInstall(json, binaryPath);
|