@okx_ai/okx-trade-cli 1.3.3 → 1.3.4-beta.2
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 +441 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2300,14 +2300,16 @@ var OKX_INST_TYPES = [
|
|
|
2300
2300
|
function publicRateLimit(key, rps = 20) {
|
|
2301
2301
|
return {
|
|
2302
2302
|
key: `public:${key}`,
|
|
2303
|
-
capacity: rps,
|
|
2303
|
+
capacity: Math.max(1, rps),
|
|
2304
|
+
// capacity >= 1 so the token bucket can fire at least once before refilling
|
|
2304
2305
|
refillPerSecond: rps
|
|
2305
2306
|
};
|
|
2306
2307
|
}
|
|
2307
2308
|
function privateRateLimit(key, rps = 10) {
|
|
2308
2309
|
return {
|
|
2309
2310
|
key: `private:${key}`,
|
|
2310
|
-
capacity: rps,
|
|
2311
|
+
capacity: Math.max(1, rps),
|
|
2312
|
+
// capacity >= 1 so the token bucket can fire at least once before refilling
|
|
2311
2313
|
refillPerSecond: rps
|
|
2312
2314
|
};
|
|
2313
2315
|
}
|
|
@@ -9677,6 +9679,58 @@ function registerMarketFilterTools() {
|
|
|
9677
9679
|
);
|
|
9678
9680
|
return normalizeResponse(response);
|
|
9679
9681
|
}
|
|
9682
|
+
},
|
|
9683
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
9684
|
+
// market_get_pair_spread — /api/v5/aigc/mcp/pair-spread
|
|
9685
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
9686
|
+
{
|
|
9687
|
+
name: "market_get_pair_spread",
|
|
9688
|
+
module: "market",
|
|
9689
|
+
description: "Compute spread statistics between two instruments over a lookback window. Returns absolute and ratio spread (mean / stdDev / median / min / max) plus an optional realtime spread snapshot. Use to size pairs trades, detect mean-reversion setups, or compare cross-listed contracts. Results are cached ~60s per (pair, bar, window) tuple. Read-only, no credentials required.\nDo NOT use to fetch raw candles (use market_get_candles) or single-instrument OI/funding (use market_get_oi_history / market_filter_oi_change).",
|
|
9690
|
+
isWrite: false,
|
|
9691
|
+
inputSchema: {
|
|
9692
|
+
type: "object",
|
|
9693
|
+
properties: {
|
|
9694
|
+
instIdA: {
|
|
9695
|
+
type: "string",
|
|
9696
|
+
description: "First instrument ID, e.g. BTC-USDT-SWAP"
|
|
9697
|
+
},
|
|
9698
|
+
instIdB: {
|
|
9699
|
+
type: "string",
|
|
9700
|
+
description: "Second instrument ID; must differ from instIdA"
|
|
9701
|
+
},
|
|
9702
|
+
bar: {
|
|
9703
|
+
type: "string",
|
|
9704
|
+
enum: ["5m", "15m"],
|
|
9705
|
+
description: "Bar size for the spread series. Default 15m. 1m is not supported."
|
|
9706
|
+
},
|
|
9707
|
+
window: {
|
|
9708
|
+
type: "string",
|
|
9709
|
+
description: "Lookback window. Format <n><unit>, units m/H/D/W (case-sensitive), max 1W. Default 1W."
|
|
9710
|
+
},
|
|
9711
|
+
backtestTime: {
|
|
9712
|
+
type: "number",
|
|
9713
|
+
description: "Anchor timestamp (ms epoch) for backtest mode. When provided, realtime is omitted."
|
|
9714
|
+
}
|
|
9715
|
+
},
|
|
9716
|
+
required: ["instIdA", "instIdB"]
|
|
9717
|
+
},
|
|
9718
|
+
handler: async (rawArgs, context) => {
|
|
9719
|
+
const args = asRecord(rawArgs);
|
|
9720
|
+
const body = compactObject({
|
|
9721
|
+
instIdA: requireString(args, "instIdA"),
|
|
9722
|
+
instIdB: requireString(args, "instIdB"),
|
|
9723
|
+
bar: readString(args, "bar"),
|
|
9724
|
+
window: readString(args, "window"),
|
|
9725
|
+
backtestTime: readNumber(args, "backtestTime")
|
|
9726
|
+
});
|
|
9727
|
+
const response = await context.client.publicPost(
|
|
9728
|
+
"/api/v5/aigc/mcp/pair-spread",
|
|
9729
|
+
body,
|
|
9730
|
+
publicRateLimit("market_get_pair_spread", 5)
|
|
9731
|
+
);
|
|
9732
|
+
return normalizeResponse(response);
|
|
9733
|
+
}
|
|
9680
9734
|
}
|
|
9681
9735
|
];
|
|
9682
9736
|
}
|
|
@@ -9685,6 +9739,219 @@ var NEWS_DETAIL = "/api/v5/orbit/news-detail";
|
|
|
9685
9739
|
var NEWS_DOMAINS = "/api/v5/orbit/news-platform";
|
|
9686
9740
|
var SENTIMENT_QUERY = "/api/v5/orbit/currency-sentiment-query";
|
|
9687
9741
|
var SENTIMENT_RANKING = "/api/v5/orbit/currency-sentiment-ranking";
|
|
9742
|
+
var ECONOMIC_CALENDAR = "/api/v5/public/economic-calendar";
|
|
9743
|
+
var CALENDAR_REGIONS = [
|
|
9744
|
+
"afghanistan",
|
|
9745
|
+
"albania",
|
|
9746
|
+
"algeria",
|
|
9747
|
+
"andorra",
|
|
9748
|
+
"angola",
|
|
9749
|
+
"antigua_and_barbuda",
|
|
9750
|
+
"argentina",
|
|
9751
|
+
"armenia",
|
|
9752
|
+
"aruba",
|
|
9753
|
+
"australia",
|
|
9754
|
+
"austria",
|
|
9755
|
+
"azerbaijan",
|
|
9756
|
+
"bahamas",
|
|
9757
|
+
"bahrain",
|
|
9758
|
+
"bangladesh",
|
|
9759
|
+
"barbados",
|
|
9760
|
+
"belarus",
|
|
9761
|
+
"belgium",
|
|
9762
|
+
"belize",
|
|
9763
|
+
"benin",
|
|
9764
|
+
"bermuda",
|
|
9765
|
+
"bhutan",
|
|
9766
|
+
"bolivia",
|
|
9767
|
+
"bosnia_and_herzegovina",
|
|
9768
|
+
"botswana",
|
|
9769
|
+
"brazil",
|
|
9770
|
+
"brunei",
|
|
9771
|
+
"bulgaria",
|
|
9772
|
+
"burkina_faso",
|
|
9773
|
+
"burundi",
|
|
9774
|
+
"cambodia",
|
|
9775
|
+
"cameroon",
|
|
9776
|
+
"canada",
|
|
9777
|
+
"cape_verde",
|
|
9778
|
+
"cayman_islands",
|
|
9779
|
+
"central_african_republic",
|
|
9780
|
+
"chad",
|
|
9781
|
+
"chile",
|
|
9782
|
+
"china",
|
|
9783
|
+
"colombia",
|
|
9784
|
+
"comoros",
|
|
9785
|
+
"congo",
|
|
9786
|
+
"costa_rica",
|
|
9787
|
+
"croatia",
|
|
9788
|
+
"cuba",
|
|
9789
|
+
"cyprus",
|
|
9790
|
+
"czech_republic",
|
|
9791
|
+
"denmark",
|
|
9792
|
+
"djibouti",
|
|
9793
|
+
"dominica",
|
|
9794
|
+
"dominican_republic",
|
|
9795
|
+
"east_timor",
|
|
9796
|
+
"ecuador",
|
|
9797
|
+
"egypt",
|
|
9798
|
+
"el_salvador",
|
|
9799
|
+
"equatorial_guinea",
|
|
9800
|
+
"eritrea",
|
|
9801
|
+
"estonia",
|
|
9802
|
+
"ethiopia",
|
|
9803
|
+
"euro_area",
|
|
9804
|
+
"european_union",
|
|
9805
|
+
"faroe_islands",
|
|
9806
|
+
"fiji",
|
|
9807
|
+
"finland",
|
|
9808
|
+
"france",
|
|
9809
|
+
"g20",
|
|
9810
|
+
"g7",
|
|
9811
|
+
"gabon",
|
|
9812
|
+
"gambia",
|
|
9813
|
+
"georgia",
|
|
9814
|
+
"germany",
|
|
9815
|
+
"ghana",
|
|
9816
|
+
"greece",
|
|
9817
|
+
"greenland",
|
|
9818
|
+
"grenada",
|
|
9819
|
+
"guatemala",
|
|
9820
|
+
"guinea",
|
|
9821
|
+
"guinea_bissau",
|
|
9822
|
+
"guyana",
|
|
9823
|
+
"haiti",
|
|
9824
|
+
"honduras",
|
|
9825
|
+
"hong_kong",
|
|
9826
|
+
"hungary",
|
|
9827
|
+
"iceland",
|
|
9828
|
+
"imf",
|
|
9829
|
+
"india",
|
|
9830
|
+
"indonesia",
|
|
9831
|
+
"iran",
|
|
9832
|
+
"iraq",
|
|
9833
|
+
"ireland",
|
|
9834
|
+
"isle_of_man",
|
|
9835
|
+
"israel",
|
|
9836
|
+
"italy",
|
|
9837
|
+
"ivory_coast",
|
|
9838
|
+
"jamaica",
|
|
9839
|
+
"japan",
|
|
9840
|
+
"jordan",
|
|
9841
|
+
"kazakhstan",
|
|
9842
|
+
"kenya",
|
|
9843
|
+
"kiribati",
|
|
9844
|
+
"kosovo",
|
|
9845
|
+
"kuwait",
|
|
9846
|
+
"kyrgyzstan",
|
|
9847
|
+
"laos",
|
|
9848
|
+
"latvia",
|
|
9849
|
+
"lebanon",
|
|
9850
|
+
"lesotho",
|
|
9851
|
+
"liberia",
|
|
9852
|
+
"libya",
|
|
9853
|
+
"liechtenstein",
|
|
9854
|
+
"lithuania",
|
|
9855
|
+
"luxembourg",
|
|
9856
|
+
"macau",
|
|
9857
|
+
"macedonia",
|
|
9858
|
+
"madagascar",
|
|
9859
|
+
"malawi",
|
|
9860
|
+
"malaysia",
|
|
9861
|
+
"maldives",
|
|
9862
|
+
"mali",
|
|
9863
|
+
"malta",
|
|
9864
|
+
"mauritania",
|
|
9865
|
+
"mauritius",
|
|
9866
|
+
"mexico",
|
|
9867
|
+
"micronesia",
|
|
9868
|
+
"moldova",
|
|
9869
|
+
"monaco",
|
|
9870
|
+
"mongolia",
|
|
9871
|
+
"montenegro",
|
|
9872
|
+
"morocco",
|
|
9873
|
+
"mozambique",
|
|
9874
|
+
"myanmar",
|
|
9875
|
+
"namibia",
|
|
9876
|
+
"nepal",
|
|
9877
|
+
"netherlands",
|
|
9878
|
+
"new_caledonia",
|
|
9879
|
+
"new_zealand",
|
|
9880
|
+
"nicaragua",
|
|
9881
|
+
"niger",
|
|
9882
|
+
"nigeria",
|
|
9883
|
+
"north_korea",
|
|
9884
|
+
"northern_mariana_islands",
|
|
9885
|
+
"norway",
|
|
9886
|
+
"oman",
|
|
9887
|
+
"opec",
|
|
9888
|
+
"pakistan",
|
|
9889
|
+
"palau",
|
|
9890
|
+
"palestine",
|
|
9891
|
+
"panama",
|
|
9892
|
+
"papua_new_guinea",
|
|
9893
|
+
"paraguay",
|
|
9894
|
+
"peru",
|
|
9895
|
+
"philippines",
|
|
9896
|
+
"poland",
|
|
9897
|
+
"portugal",
|
|
9898
|
+
"puerto_rico",
|
|
9899
|
+
"qatar",
|
|
9900
|
+
"republic_of_the_congo",
|
|
9901
|
+
"romania",
|
|
9902
|
+
"russia",
|
|
9903
|
+
"rwanda",
|
|
9904
|
+
"samoa",
|
|
9905
|
+
"san_marino",
|
|
9906
|
+
"sao_tome_and_principe",
|
|
9907
|
+
"saudi_arabia",
|
|
9908
|
+
"senegal",
|
|
9909
|
+
"serbia",
|
|
9910
|
+
"seychelles",
|
|
9911
|
+
"sierra_leone",
|
|
9912
|
+
"singapore",
|
|
9913
|
+
"slovakia",
|
|
9914
|
+
"slovenia",
|
|
9915
|
+
"solomon_islands",
|
|
9916
|
+
"somalia",
|
|
9917
|
+
"south_africa",
|
|
9918
|
+
"south_korea",
|
|
9919
|
+
"south_sudan",
|
|
9920
|
+
"spain",
|
|
9921
|
+
"sri_lanka",
|
|
9922
|
+
"st_kitts_and_nevis",
|
|
9923
|
+
"st_lucia",
|
|
9924
|
+
"sudan",
|
|
9925
|
+
"suriname",
|
|
9926
|
+
"swaziland",
|
|
9927
|
+
"sweden",
|
|
9928
|
+
"switzerland",
|
|
9929
|
+
"syria",
|
|
9930
|
+
"taiwan",
|
|
9931
|
+
"tajikistan",
|
|
9932
|
+
"tanzania",
|
|
9933
|
+
"thailand",
|
|
9934
|
+
"togo",
|
|
9935
|
+
"tonga",
|
|
9936
|
+
"trinidad_and_tobago",
|
|
9937
|
+
"tunisia",
|
|
9938
|
+
"turkey",
|
|
9939
|
+
"turkmenistan",
|
|
9940
|
+
"uganda",
|
|
9941
|
+
"ukraine",
|
|
9942
|
+
"united_arab_emirates",
|
|
9943
|
+
"united_kingdom",
|
|
9944
|
+
"united_states",
|
|
9945
|
+
"uruguay",
|
|
9946
|
+
"uzbekistan",
|
|
9947
|
+
"vanuatu",
|
|
9948
|
+
"venezuela",
|
|
9949
|
+
"vietnam",
|
|
9950
|
+
"world",
|
|
9951
|
+
"yemen",
|
|
9952
|
+
"zambia",
|
|
9953
|
+
"zimbabwe"
|
|
9954
|
+
];
|
|
9688
9955
|
var NEWS_LANGUAGE = ["en-US", "zh-CN"];
|
|
9689
9956
|
function langHeader(lang) {
|
|
9690
9957
|
if (lang === "zh-CN" || lang === "zh_CN") return { "Accept-Language": "zh-CN" };
|
|
@@ -9982,12 +10249,61 @@ function registerNewsTools() {
|
|
|
9982
10249
|
);
|
|
9983
10250
|
return normalizeResponse(response);
|
|
9984
10251
|
}
|
|
10252
|
+
},
|
|
10253
|
+
// -----------------------------------------------------------------------
|
|
10254
|
+
// Economic calendar
|
|
10255
|
+
// -----------------------------------------------------------------------
|
|
10256
|
+
{
|
|
10257
|
+
name: "news_list_calendar_regions",
|
|
10258
|
+
module: "news",
|
|
10259
|
+
description: "List all valid region values for the economic calendar. Returns a string array of snake_case region codes. Call this when economic-calendar returns empty results to verify the region value, or to help the user pick a valid region. Do NOT use to list news source platforms \u2014 use news_get_domains instead.",
|
|
10260
|
+
isWrite: false,
|
|
10261
|
+
inputSchema: { type: "object", properties: {}, required: [] },
|
|
10262
|
+
handler: async () => ({ data: CALENDAR_REGIONS })
|
|
10263
|
+
},
|
|
10264
|
+
{
|
|
10265
|
+
name: "news_get_economic_calendar",
|
|
10266
|
+
module: "news",
|
|
10267
|
+
description: "Get macro-economic calendar data (GDP, CPI, NFP, interest rate decisions, PMI, etc.). Returns scheduled and released economic events with forecast, previous, and actual values. Use when user asks about economic calendar, macro data, or specific indicators like NFP/CPI/GDP/FOMC. Do NOT use for news articles or sentiment \u2014 use news_get_latest or news_search instead.",
|
|
10268
|
+
isWrite: false,
|
|
10269
|
+
inputSchema: {
|
|
10270
|
+
type: "object",
|
|
10271
|
+
properties: {
|
|
10272
|
+
region: { type: "string", description: "Country/region filter in snake_case (e.g. united_states, euro_area, japan). Invalid values return empty results silently. If empty results, call news_list_calendar_regions to verify the value." },
|
|
10273
|
+
importance: { type: "string", enum: ["1", "2", "3"], description: "Importance level: 1=low, 2=medium, 3=high. Omit for all levels." },
|
|
10274
|
+
before: { type: "string", description: "Lower time bound \u2014 returns events NEWER than this timestamp (reversed semantics). Pair with 'after' for future-event windows. Unix ms." },
|
|
10275
|
+
after: { type: "string", description: "Upper time bound \u2014 returns events OLDER than this timestamp (reversed semantics). Default=now (returns past events). Pair with 'before' for a bounded window. Unix ms." },
|
|
10276
|
+
limit: { type: "number", minimum: 1, maximum: 100, description: "Number of results (default 100, max 100)." }
|
|
10277
|
+
},
|
|
10278
|
+
required: []
|
|
10279
|
+
},
|
|
10280
|
+
handler: async (rawArgs, context) => {
|
|
10281
|
+
const args = asRecord(rawArgs);
|
|
10282
|
+
const rawLimit = readNumber(args, "limit");
|
|
10283
|
+
const limit = rawLimit !== void 0 ? Math.min(rawLimit, 100) : void 0;
|
|
10284
|
+
const response = await context.client.privateGet(
|
|
10285
|
+
ECONOMIC_CALENDAR,
|
|
10286
|
+
compactObject({
|
|
10287
|
+
region: readString(args, "region"),
|
|
10288
|
+
importance: readString(args, "importance"),
|
|
10289
|
+
before: readString(args, "before"),
|
|
10290
|
+
after: readString(args, "after"),
|
|
10291
|
+
limit
|
|
10292
|
+
}),
|
|
10293
|
+
publicRateLimit("news_get_economic_calendar", 0.2)
|
|
10294
|
+
);
|
|
10295
|
+
return normalizeResponse(response);
|
|
10296
|
+
}
|
|
9985
10297
|
}
|
|
9986
10298
|
];
|
|
9987
|
-
const
|
|
9988
|
-
|
|
9989
|
-
const
|
|
9990
|
-
|
|
10299
|
+
const exempt = /* @__PURE__ */ new Set(["news_get_domains", "news_list_calendar_regions"]);
|
|
10300
|
+
const exempted = [];
|
|
10301
|
+
const guarded = [];
|
|
10302
|
+
for (const t of tools) {
|
|
10303
|
+
if (exempt.has(t.name)) exempted.push(t);
|
|
10304
|
+
else guarded.push(t);
|
|
10305
|
+
}
|
|
10306
|
+
return [...guarded.map(withNewsDemoGuard), ...exempted];
|
|
9991
10307
|
}
|
|
9992
10308
|
var NEWS_DEMO_MESSAGE = "News features are not available in demo/simulated trading mode.";
|
|
9993
10309
|
var NEWS_DEMO_SUGGESTION = "Switch to a live profile to use News features.";
|
|
@@ -13487,7 +13803,7 @@ async function cmdDiagnoseMcp(options = {}) {
|
|
|
13487
13803
|
|
|
13488
13804
|
// src/commands/diagnose.ts
|
|
13489
13805
|
var CLI_VERSION = readCliVersion();
|
|
13490
|
-
var GIT_HASH = true ? "
|
|
13806
|
+
var GIT_HASH = true ? "0566db8f" : "dev";
|
|
13491
13807
|
function maskKey2(key) {
|
|
13492
13808
|
if (!key) return "(not set)";
|
|
13493
13809
|
if (key.length <= 8) return "****";
|
|
@@ -14063,6 +14379,11 @@ var CLI_REGISTRY = {
|
|
|
14063
14379
|
toolName: "market_filter_oi_change",
|
|
14064
14380
|
usage: "okx market oi-change --instType <SWAP|FUTURES> [--bar <5m|15m|1H|4H|1D>] [--sortBy <oiUsd|oiDeltaUsd|oiDeltaPct|absOiDeltaPct|volUsd24h|fundingRate|last>] [--sortOrder <asc|desc>] [--limit <1-100>] [--minOiUsd <n>] [--minVolUsd24h <n>] [--minAbsOiDeltaPct <n>]",
|
|
14065
14381
|
description: "Find instruments with largest OI changes over a bar window (accumulation/distribution scanner)"
|
|
14382
|
+
},
|
|
14383
|
+
"pair-spread": {
|
|
14384
|
+
toolName: "market_get_pair_spread",
|
|
14385
|
+
usage: "okx market pair-spread <instIdA> <instIdB> [--bar <5m|15m>] [--window <window>] [--backtest-time <ms>] [--json]",
|
|
14386
|
+
description: "Compute spread statistics (abs + ratio) between two instruments over a lookback window"
|
|
14066
14387
|
}
|
|
14067
14388
|
},
|
|
14068
14389
|
subgroups: {
|
|
@@ -14943,6 +15264,16 @@ var CLI_REGISTRY = {
|
|
|
14943
15264
|
"sentiment-rank": {
|
|
14944
15265
|
toolName: "news_get_sentiment_ranking",
|
|
14945
15266
|
usage: "okx news sentiment-rank [--period 24h] [--sort-by 0] [--limit 20]"
|
|
15267
|
+
},
|
|
15268
|
+
"economic-calendar": {
|
|
15269
|
+
toolName: "news_get_economic_calendar",
|
|
15270
|
+
usage: "okx news economic-calendar [--region <country>] [--importance <1|2|3>] [--before <ms>] [--after <ms>] [--limit <n>]",
|
|
15271
|
+
description: "Get macro-economic calendar data (GDP, CPI, NFP, FOMC, etc.)"
|
|
15272
|
+
},
|
|
15273
|
+
"list-regions": {
|
|
15274
|
+
toolName: "news_list_calendar_regions",
|
|
15275
|
+
usage: "okx news list-regions",
|
|
15276
|
+
description: "List all valid --region values for economic-calendar"
|
|
14946
15277
|
}
|
|
14947
15278
|
}
|
|
14948
15279
|
},
|
|
@@ -15353,6 +15684,49 @@ async function cmdNewsSentimentRank(run, opts) {
|
|
|
15353
15684
|
})
|
|
15354
15685
|
);
|
|
15355
15686
|
}
|
|
15687
|
+
async function cmdNewsEconomicCalendar(run, opts) {
|
|
15688
|
+
if (!opts.json && opts.limit !== void 0 && opts.limit > 100) {
|
|
15689
|
+
errorLine(`Warning: --limit ${opts.limit} exceeds API max 100, capped to 100`);
|
|
15690
|
+
}
|
|
15691
|
+
const result = await run("news_get_economic_calendar", {
|
|
15692
|
+
region: opts.region,
|
|
15693
|
+
importance: opts.importance,
|
|
15694
|
+
before: opts.before,
|
|
15695
|
+
after: opts.after,
|
|
15696
|
+
limit: opts.limit !== void 0 ? Math.min(opts.limit, 100) : void 0
|
|
15697
|
+
});
|
|
15698
|
+
const items = getData(result) ?? [];
|
|
15699
|
+
if (opts.json) return printJson(items);
|
|
15700
|
+
printTable(
|
|
15701
|
+
items.map((e) => {
|
|
15702
|
+
const unit = String(e["unit"] ?? "").trim();
|
|
15703
|
+
const appendUnit = (v) => {
|
|
15704
|
+
const s = String(v ?? "");
|
|
15705
|
+
if (!s || s === "-") return s || "-";
|
|
15706
|
+
if (unit && !s.includes(unit)) return `${s} ${unit}`;
|
|
15707
|
+
return s;
|
|
15708
|
+
};
|
|
15709
|
+
return {
|
|
15710
|
+
time: formatTime(e["date"]),
|
|
15711
|
+
region: e["region"],
|
|
15712
|
+
category: e["category"] || "-",
|
|
15713
|
+
event: String(e["event"] ?? "").slice(0, 50),
|
|
15714
|
+
importance: e["importance"] === "3" ? "HIGH" : e["importance"] === "2" ? "MED" : "LOW",
|
|
15715
|
+
refDate: formatTime(e["refDate"]),
|
|
15716
|
+
forecast: appendUnit(e["forecast"] ?? "-"),
|
|
15717
|
+
previous: appendUnit(e["previous"] ?? "-"),
|
|
15718
|
+
actual: e["actual"] ? appendUnit(e["actual"]) : "(pending)"
|
|
15719
|
+
};
|
|
15720
|
+
})
|
|
15721
|
+
);
|
|
15722
|
+
}
|
|
15723
|
+
async function cmdNewsListCalendarRegions(run, opts) {
|
|
15724
|
+
const result = await run("news_list_calendar_regions", {});
|
|
15725
|
+
const regions = result.data;
|
|
15726
|
+
if (opts.json) return printJson(regions);
|
|
15727
|
+
outputLine(`Valid economic-calendar regions (${regions.length}):`);
|
|
15728
|
+
outputLine(regions.join(", "));
|
|
15729
|
+
}
|
|
15356
15730
|
|
|
15357
15731
|
// src/config/loader.ts
|
|
15358
15732
|
async function loadProfileConfig(opts) {
|
|
@@ -15466,6 +15840,12 @@ function printSubgroupHelp(moduleName, subgroupName) {
|
|
|
15466
15840
|
}
|
|
15467
15841
|
const subgroup = group.subgroups?.[subgroupName];
|
|
15468
15842
|
if (!subgroup) {
|
|
15843
|
+
const cmd = group.commands?.[subgroupName];
|
|
15844
|
+
if (cmd) {
|
|
15845
|
+
const lines2 = ["", ` ${cmd.description}`, ` Usage: ${cmd.usage}`, ""];
|
|
15846
|
+
output(lines2.join(EOL2));
|
|
15847
|
+
return;
|
|
15848
|
+
}
|
|
15469
15849
|
errorLine(`Unknown subgroup: ${moduleName} ${subgroupName}`);
|
|
15470
15850
|
process.exitCode = 1;
|
|
15471
15851
|
return;
|
|
@@ -15708,6 +16088,8 @@ var CLI_OPTIONS = {
|
|
|
15708
16088
|
params: { type: "string" },
|
|
15709
16089
|
list: { type: "boolean", default: false },
|
|
15710
16090
|
"backtest-time": { type: "string" },
|
|
16091
|
+
// pair-spread
|
|
16092
|
+
window: { type: "string" },
|
|
15711
16093
|
// news
|
|
15712
16094
|
coins: { type: "string" },
|
|
15713
16095
|
sentiment: { type: "string" },
|
|
@@ -15718,6 +16100,7 @@ var CLI_OPTIONS = {
|
|
|
15718
16100
|
period: { type: "string" },
|
|
15719
16101
|
points: { type: "string" },
|
|
15720
16102
|
"sort-by": { type: "string" },
|
|
16103
|
+
region: { type: "string" },
|
|
15721
16104
|
// skill marketplace
|
|
15722
16105
|
categories: { type: "string" },
|
|
15723
16106
|
dir: { type: "string" },
|
|
@@ -16230,6 +16613,42 @@ async function cmdMarketOiChangeFilter(run, opts) {
|
|
|
16230
16613
|
}))
|
|
16231
16614
|
);
|
|
16232
16615
|
}
|
|
16616
|
+
async function cmdMarketPairSpread(run, instIdA, instIdB, opts) {
|
|
16617
|
+
const result = await run("market_get_pair_spread", {
|
|
16618
|
+
instIdA,
|
|
16619
|
+
instIdB,
|
|
16620
|
+
bar: opts.bar,
|
|
16621
|
+
window: opts.window,
|
|
16622
|
+
backtestTime: opts.backtestTime
|
|
16623
|
+
});
|
|
16624
|
+
const data = getData2(result);
|
|
16625
|
+
if (opts.json) return printJson(data);
|
|
16626
|
+
const bar = data?.["bar"] ?? "15m";
|
|
16627
|
+
const win = data?.["window"] ?? "1W";
|
|
16628
|
+
const mode = data?.["mode"] ?? "live";
|
|
16629
|
+
outputLine(`${instIdA} / ${instIdB} bar=${bar} window=${win} mode=${mode}`);
|
|
16630
|
+
const rt = data?.["realtime"];
|
|
16631
|
+
if (rt) {
|
|
16632
|
+
outputLine(`realtime lastA=${rt["lastPriceA"]} lastB=${rt["lastPriceB"]} abs=${rt["spreadAbs"]} ratio=${rt["spreadRatio"]}`);
|
|
16633
|
+
}
|
|
16634
|
+
const stats = data?.["statistics"];
|
|
16635
|
+
if (stats) {
|
|
16636
|
+
const abs = stats["absolute"];
|
|
16637
|
+
const ratio = stats["ratio"];
|
|
16638
|
+
const meta = data?.["meta"];
|
|
16639
|
+
outputLine(`samples count=${meta?.["alignedBars"] ?? "?"} start=${stats?.["windowStartTs"] ?? "?"} end=${stats?.["windowEndTs"] ?? "?"}`);
|
|
16640
|
+
printTable([
|
|
16641
|
+
{ stat: "mean", absolute: abs?.["mean"], ratio: ratio?.["mean"] },
|
|
16642
|
+
{ stat: "stdDev", absolute: abs?.["stdDev"], ratio: ratio?.["stdDev"] },
|
|
16643
|
+
{ stat: "median", absolute: abs?.["median"], ratio: ratio?.["median"] },
|
|
16644
|
+
{ stat: "min", absolute: abs?.["min"], ratio: ratio?.["min"] },
|
|
16645
|
+
{ stat: "max", absolute: abs?.["max"], ratio: ratio?.["max"] }
|
|
16646
|
+
]);
|
|
16647
|
+
if (meta) {
|
|
16648
|
+
outputLine(`meta requested=${meta["requestedBars"]} aligned=${meta["alignedBars"]} dropped=${meta["droppedBars"]} truncated=${meta["truncated"]}`);
|
|
16649
|
+
}
|
|
16650
|
+
}
|
|
16651
|
+
}
|
|
16233
16652
|
|
|
16234
16653
|
// src/commands/account.ts
|
|
16235
16654
|
import * as fs7 from "fs";
|
|
@@ -19973,7 +20392,7 @@ async function cmdEventCancel(run, opts) {
|
|
|
19973
20392
|
// src/index.ts
|
|
19974
20393
|
var _require3 = createRequire3(import.meta.url);
|
|
19975
20394
|
var CLI_VERSION2 = _require3("../package.json").version;
|
|
19976
|
-
var GIT_HASH2 = true ? "
|
|
20395
|
+
var GIT_HASH2 = true ? "0566db8f" : "dev";
|
|
19977
20396
|
function handlePilotCommand(action, json, force, binaryPath) {
|
|
19978
20397
|
if (action === "status") return cmdPilotStatus(json, binaryPath);
|
|
19979
20398
|
if (action === "install") return cmdPilotInstall(json, binaryPath);
|
|
@@ -20078,6 +20497,15 @@ function handleMarketFilterCommand(run, action, rest, v, json) {
|
|
|
20078
20497
|
limit,
|
|
20079
20498
|
json
|
|
20080
20499
|
});
|
|
20500
|
+
if (action === "pair-spread") {
|
|
20501
|
+
const backtestTime = v["backtest-time"] !== void 0 ? Number(v["backtest-time"]) : void 0;
|
|
20502
|
+
return cmdMarketPairSpread(run, rest[0], rest[1], {
|
|
20503
|
+
bar: v.bar,
|
|
20504
|
+
window: v.window,
|
|
20505
|
+
backtestTime,
|
|
20506
|
+
json
|
|
20507
|
+
});
|
|
20508
|
+
}
|
|
20081
20509
|
}
|
|
20082
20510
|
function handleIndicatorAction(run, rest, v, json) {
|
|
20083
20511
|
if (rest[0] === "list") return cmdMarketIndicatorList(json);
|
|
@@ -20126,7 +20554,8 @@ function handleMarketCommand(run, action, rest, v, json) {
|
|
|
20126
20554
|
"filter",
|
|
20127
20555
|
"oi-history",
|
|
20128
20556
|
"oi-change",
|
|
20129
|
-
"index-candles"
|
|
20557
|
+
"index-candles",
|
|
20558
|
+
"pair-spread"
|
|
20130
20559
|
]);
|
|
20131
20560
|
}
|
|
20132
20561
|
function handleAccountWriteCommand(run, action, v, json) {
|
|
@@ -21256,7 +21685,9 @@ function handleNewsCommand(run, action, rest, v, json) {
|
|
|
21256
21685
|
const opts = { ...searchOpts, sortBy: sortBy ?? "latest" };
|
|
21257
21686
|
return cmdNewsSearch(run, "", opts);
|
|
21258
21687
|
},
|
|
21259
|
-
"sentiment-rank": () => cmdNewsSentimentRank(run, { period, sortBy, limit, json })
|
|
21688
|
+
"sentiment-rank": () => cmdNewsSentimentRank(run, { period, sortBy, limit, json }),
|
|
21689
|
+
"economic-calendar": () => cmdNewsEconomicCalendar(run, { region: v.region, importance: v.importance, before: v.before, after, limit, json }),
|
|
21690
|
+
"list-regions": () => cmdNewsListCalendarRegions(run, { json })
|
|
21260
21691
|
};
|
|
21261
21692
|
const handler = dispatch[action];
|
|
21262
21693
|
if (handler) return handler();
|