@okx_ai/okx-trade-cli 1.2.8-beta.5 → 1.2.8-beta.7
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 +111 -728
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1106,14 +1106,13 @@ var OkxRestClient = class _OkxRestClient {
|
|
|
1106
1106
|
rateLimit
|
|
1107
1107
|
});
|
|
1108
1108
|
}
|
|
1109
|
-
async privateGet(path42, query, rateLimit
|
|
1109
|
+
async privateGet(path42, query, rateLimit) {
|
|
1110
1110
|
return this.request({
|
|
1111
1111
|
method: "GET",
|
|
1112
1112
|
path: path42,
|
|
1113
1113
|
auth: "private",
|
|
1114
1114
|
query,
|
|
1115
|
-
rateLimit
|
|
1116
|
-
extraHeaders
|
|
1115
|
+
rateLimit
|
|
1117
1116
|
});
|
|
1118
1117
|
}
|
|
1119
1118
|
async publicPost(path42, body, rateLimit) {
|
|
@@ -1321,11 +1320,6 @@ var OkxRestClient = class _OkxRestClient {
|
|
|
1321
1320
|
if (this.config.demo) {
|
|
1322
1321
|
headers.set("x-simulated-trading", "1");
|
|
1323
1322
|
}
|
|
1324
|
-
if (reqConfig.extraHeaders) {
|
|
1325
|
-
for (const [key, value] of Object.entries(reqConfig.extraHeaders)) {
|
|
1326
|
-
headers.set(key, value);
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
1323
|
return headers;
|
|
1330
1324
|
}
|
|
1331
1325
|
// ---------------------------------------------------------------------------
|
|
@@ -1640,7 +1634,6 @@ var MODULES = [
|
|
|
1640
1634
|
"futures",
|
|
1641
1635
|
"option",
|
|
1642
1636
|
"account",
|
|
1643
|
-
"news",
|
|
1644
1637
|
...EARN_SUB_MODULE_IDS,
|
|
1645
1638
|
...BOT_SUB_MODULE_IDS,
|
|
1646
1639
|
"skills"
|
|
@@ -1986,7 +1979,7 @@ function registerAccountTools() {
|
|
|
1986
1979
|
{
|
|
1987
1980
|
name: "account_get_config",
|
|
1988
1981
|
module: "account",
|
|
1989
|
-
description: "Get account configuration: position mode (net vs hedge), account level, auto-loan settings, etc.",
|
|
1982
|
+
description: "Get account configuration: position mode (net vs hedge), account level, auto-loan settings, etc. Note: `settleCcy` is the current settlement currency for USDS-margined contracts. `settleCcyList` is the list of available settlement currencies to choose from. These fields only apply to USDS-margined contracts and can be ignored for standard USDT/coin-margined trading.",
|
|
1990
1983
|
isWrite: false,
|
|
1991
1984
|
inputSchema: {
|
|
1992
1985
|
type: "object",
|
|
@@ -1998,16 +1991,7 @@ function registerAccountTools() {
|
|
|
1998
1991
|
{},
|
|
1999
1992
|
privateRateLimit("account_get_config", 5)
|
|
2000
1993
|
);
|
|
2001
|
-
|
|
2002
|
-
if (Array.isArray(result.data)) {
|
|
2003
|
-
return {
|
|
2004
|
-
...result,
|
|
2005
|
-
data: result.data.map(
|
|
2006
|
-
({ settleCcy, settleCcyList, ...rest }) => rest
|
|
2007
|
-
)
|
|
2008
|
-
};
|
|
2009
|
-
}
|
|
2010
|
-
return result;
|
|
1994
|
+
return normalizeResponse(response);
|
|
2011
1995
|
}
|
|
2012
1996
|
},
|
|
2013
1997
|
{
|
|
@@ -4694,7 +4678,7 @@ function buildContractTradeTools(cfg) {
|
|
|
4694
4678
|
{
|
|
4695
4679
|
name: n("place_order"),
|
|
4696
4680
|
module,
|
|
4697
|
-
description: `Place ${label} order. Attach TP/SL via tpTriggerPx/slTriggerPx. [CAUTION] Executes real trades.`,
|
|
4681
|
+
description: `Place ${label} order. Attach TP/SL via tpTriggerPx/slTriggerPx. Before placing, use market_get_instruments to get ctVal (contract face value) \u2014 do NOT assume contract sizes. [CAUTION] Executes real trades.`,
|
|
4698
4682
|
isWrite: true,
|
|
4699
4683
|
inputSchema: {
|
|
4700
4684
|
type: "object",
|
|
@@ -4722,7 +4706,7 @@ function buildContractTradeTools(cfg) {
|
|
|
4722
4706
|
},
|
|
4723
4707
|
sz: {
|
|
4724
4708
|
type: "string",
|
|
4725
|
-
description: "
|
|
4709
|
+
description: "Number of contracts. Each contract = ctVal units (e.g. 0.1 ETH for ETH-USDT-SWAP). Query market_get_instruments for exact ctVal. Set tgtCcy=quote_ccy to specify sz in USDT instead."
|
|
4726
4710
|
},
|
|
4727
4711
|
tgtCcy: {
|
|
4728
4712
|
type: "string",
|
|
@@ -5779,304 +5763,6 @@ function registerMarketTools() {
|
|
|
5779
5763
|
}
|
|
5780
5764
|
];
|
|
5781
5765
|
}
|
|
5782
|
-
var NEWS_SEARCH = "/api/v5/orbit/news-search";
|
|
5783
|
-
var NEWS_DETAIL = "/api/v5/orbit/news-detail";
|
|
5784
|
-
var NEWS_DOMAINS = "/api/v5/orbit/news-platform";
|
|
5785
|
-
var SENTIMENT_QUERY = "/api/v5/orbit/currency-sentiment-query";
|
|
5786
|
-
var SENTIMENT_RANKING = "/api/v5/orbit/currency-sentiment-ranking";
|
|
5787
|
-
var NEWS_LANGUAGE = ["en_US", "zh_CN"];
|
|
5788
|
-
function langHeader(lang) {
|
|
5789
|
-
if (lang === "zh_CN" || lang === "en_US") return { "Accept-Language": lang };
|
|
5790
|
-
return void 0;
|
|
5791
|
-
}
|
|
5792
|
-
var NEWS_DETAIL_LVL = ["brief", "summary", "full"];
|
|
5793
|
-
var NEWS_IMPORTANCE = ["high", "medium", "low"];
|
|
5794
|
-
var NEWS_SENTIMENT = ["bullish", "bearish", "neutral"];
|
|
5795
|
-
var NEWS_SORT = ["latest", "relevant"];
|
|
5796
|
-
var SENTIMENT_PERIOD = ["1h", "4h", "24h"];
|
|
5797
|
-
var D_COINS_NEWS = 'Comma-separated uppercase ticker symbols (e.g. "BTC,ETH"). Normalize names/aliases to standard tickers.';
|
|
5798
|
-
var D_COINS_SENTIMENT = 'Comma-separated uppercase ticker symbols, max 20 (e.g. "BTC,ETH"). Normalize names/aliases to standard tickers.';
|
|
5799
|
-
var D_LANGUAGE = "Content language: zh_CN or en_US. Infer from user's message. No server default.";
|
|
5800
|
-
var D_BEGIN = "Start time, Unix epoch milliseconds. Parse relative time if given (e.g. 'yesterday', 'last 7 days').";
|
|
5801
|
-
var D_END = "End time, Unix epoch milliseconds. Parse relative time if given. Omit for no upper bound.";
|
|
5802
|
-
var D_IMPORTANCE = "Importance filter: high (server default), medium, low. Omit unless user wants broader coverage.";
|
|
5803
|
-
var D_LIMIT = "Number of results (default 10, max 50).";
|
|
5804
|
-
function registerNewsTools() {
|
|
5805
|
-
return [
|
|
5806
|
-
// -----------------------------------------------------------------------
|
|
5807
|
-
// News browsing tools
|
|
5808
|
-
// -----------------------------------------------------------------------
|
|
5809
|
-
{
|
|
5810
|
-
name: "news_get_latest",
|
|
5811
|
-
module: "news",
|
|
5812
|
-
description: "Get crypto news sorted by time. Omitting importance still returns only high-importance news (server default). Pass importance='medium' or 'low' explicitly to broaden results. Use when user asks 'what happened recently', 'latest news', 'any big news today', or wants to browse without a keyword.",
|
|
5813
|
-
isWrite: false,
|
|
5814
|
-
inputSchema: {
|
|
5815
|
-
type: "object",
|
|
5816
|
-
properties: {
|
|
5817
|
-
coins: { type: "string", description: D_COINS_NEWS + " Optional." },
|
|
5818
|
-
importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
|
|
5819
|
-
begin: { type: "number", description: D_BEGIN },
|
|
5820
|
-
end: { type: "number", description: D_END },
|
|
5821
|
-
language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE },
|
|
5822
|
-
detailLvl: {
|
|
5823
|
-
type: "string",
|
|
5824
|
-
enum: [...NEWS_DETAIL_LVL],
|
|
5825
|
-
description: "Content level: summary (AI summary, default), full (original text), brief (title only)."
|
|
5826
|
-
},
|
|
5827
|
-
limit: { type: "number", description: D_LIMIT },
|
|
5828
|
-
after: { type: "string", description: "Pagination cursor from previous response nextCursor." }
|
|
5829
|
-
},
|
|
5830
|
-
required: []
|
|
5831
|
-
},
|
|
5832
|
-
handler: async (rawArgs, context) => {
|
|
5833
|
-
const args = asRecord(rawArgs);
|
|
5834
|
-
const response = await context.client.privateGet(
|
|
5835
|
-
NEWS_SEARCH,
|
|
5836
|
-
compactObject({
|
|
5837
|
-
sortBy: "latest",
|
|
5838
|
-
importance: readString(args, "importance"),
|
|
5839
|
-
ccyList: readString(args, "coins"),
|
|
5840
|
-
begin: readNumber(args, "begin"),
|
|
5841
|
-
end: readNumber(args, "end"),
|
|
5842
|
-
detailLvl: readString(args, "detailLvl"),
|
|
5843
|
-
limit: readNumber(args, "limit") ?? 10,
|
|
5844
|
-
cursor: readString(args, "after")
|
|
5845
|
-
}),
|
|
5846
|
-
publicRateLimit("news_get_latest", 20),
|
|
5847
|
-
langHeader(readString(args, "language"))
|
|
5848
|
-
);
|
|
5849
|
-
return normalizeResponse(response);
|
|
5850
|
-
}
|
|
5851
|
-
},
|
|
5852
|
-
{
|
|
5853
|
-
name: "news_get_by_coin",
|
|
5854
|
-
module: "news",
|
|
5855
|
-
description: "Get news for specific coins or tokens. Use when user mentions a coin: 'BTC news', 'any SOL updates'. Supports multiple coins (comma-separated).",
|
|
5856
|
-
isWrite: false,
|
|
5857
|
-
inputSchema: {
|
|
5858
|
-
type: "object",
|
|
5859
|
-
properties: {
|
|
5860
|
-
coins: { type: "string", description: D_COINS_NEWS + " Required." },
|
|
5861
|
-
importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
|
|
5862
|
-
begin: { type: "number", description: D_BEGIN },
|
|
5863
|
-
end: { type: "number", description: D_END },
|
|
5864
|
-
language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE },
|
|
5865
|
-
detailLvl: { type: "string", enum: [...NEWS_DETAIL_LVL] },
|
|
5866
|
-
limit: { type: "number", description: D_LIMIT }
|
|
5867
|
-
},
|
|
5868
|
-
required: ["coins"]
|
|
5869
|
-
},
|
|
5870
|
-
handler: async (rawArgs, context) => {
|
|
5871
|
-
const args = asRecord(rawArgs);
|
|
5872
|
-
const coins = readString(args, "coins");
|
|
5873
|
-
if (!coins) {
|
|
5874
|
-
throw new Error(`Missing required parameter "coins".`);
|
|
5875
|
-
}
|
|
5876
|
-
const response = await context.client.privateGet(
|
|
5877
|
-
NEWS_SEARCH,
|
|
5878
|
-
compactObject({
|
|
5879
|
-
sortBy: "latest",
|
|
5880
|
-
ccyList: coins,
|
|
5881
|
-
importance: readString(args, "importance"),
|
|
5882
|
-
begin: readNumber(args, "begin"),
|
|
5883
|
-
end: readNumber(args, "end"),
|
|
5884
|
-
detailLvl: readString(args, "detailLvl"),
|
|
5885
|
-
limit: readNumber(args, "limit") ?? 10
|
|
5886
|
-
}),
|
|
5887
|
-
publicRateLimit("news_get_by_coin", 20),
|
|
5888
|
-
langHeader(readString(args, "language"))
|
|
5889
|
-
);
|
|
5890
|
-
return normalizeResponse(response);
|
|
5891
|
-
}
|
|
5892
|
-
},
|
|
5893
|
-
{
|
|
5894
|
-
name: "news_search",
|
|
5895
|
-
module: "news",
|
|
5896
|
-
description: "Search crypto news by keyword with optional filters. Use when user provides specific search terms: 'SEC ETF news', 'stablecoin regulation', 'Bitcoin halving'. For coin-only queries prefer news_get_by_coin.",
|
|
5897
|
-
isWrite: false,
|
|
5898
|
-
inputSchema: {
|
|
5899
|
-
type: "object",
|
|
5900
|
-
properties: {
|
|
5901
|
-
keyword: {
|
|
5902
|
-
type: "string",
|
|
5903
|
-
description: "Search keyword(s) extracted from user query (topic/entity). Multiple words are AND-combined. Omit to browse by filters only."
|
|
5904
|
-
},
|
|
5905
|
-
coins: { type: "string", description: D_COINS_NEWS + " Optional." },
|
|
5906
|
-
importance: { type: "string", enum: [...NEWS_IMPORTANCE], description: D_IMPORTANCE },
|
|
5907
|
-
sentiment: {
|
|
5908
|
-
type: "string",
|
|
5909
|
-
enum: [...NEWS_SENTIMENT],
|
|
5910
|
-
description: "Filter by sentiment if mentioned alongside the keyword."
|
|
5911
|
-
},
|
|
5912
|
-
sortBy: {
|
|
5913
|
-
type: "string",
|
|
5914
|
-
enum: [...NEWS_SORT],
|
|
5915
|
-
description: "Sort order: relevant (by relevance, default for keyword search), latest (by time)."
|
|
5916
|
-
},
|
|
5917
|
-
begin: { type: "number", description: D_BEGIN },
|
|
5918
|
-
end: { type: "number", description: D_END },
|
|
5919
|
-
language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE },
|
|
5920
|
-
detailLvl: { type: "string", enum: [...NEWS_DETAIL_LVL] },
|
|
5921
|
-
limit: { type: "number", description: D_LIMIT },
|
|
5922
|
-
after: { type: "string", description: "Pagination cursor from previous response nextCursor." }
|
|
5923
|
-
},
|
|
5924
|
-
required: []
|
|
5925
|
-
},
|
|
5926
|
-
handler: async (rawArgs, context) => {
|
|
5927
|
-
const args = asRecord(rawArgs);
|
|
5928
|
-
const response = await context.client.privateGet(
|
|
5929
|
-
NEWS_SEARCH,
|
|
5930
|
-
compactObject({
|
|
5931
|
-
keyword: readString(args, "keyword") || void 0,
|
|
5932
|
-
sortBy: readString(args, "sortBy") ?? "relevant",
|
|
5933
|
-
importance: readString(args, "importance"),
|
|
5934
|
-
ccyList: readString(args, "coins"),
|
|
5935
|
-
sentiment: readString(args, "sentiment"),
|
|
5936
|
-
begin: readNumber(args, "begin"),
|
|
5937
|
-
end: readNumber(args, "end"),
|
|
5938
|
-
detailLvl: readString(args, "detailLvl"),
|
|
5939
|
-
limit: readNumber(args, "limit") ?? 10,
|
|
5940
|
-
cursor: readString(args, "after")
|
|
5941
|
-
}),
|
|
5942
|
-
publicRateLimit("news_search", 20),
|
|
5943
|
-
langHeader(readString(args, "language"))
|
|
5944
|
-
);
|
|
5945
|
-
return normalizeResponse(response);
|
|
5946
|
-
}
|
|
5947
|
-
},
|
|
5948
|
-
{
|
|
5949
|
-
name: "news_get_detail",
|
|
5950
|
-
module: "news",
|
|
5951
|
-
description: "Get full article content by news ID (returns title + summary + full original text). Use when user says 'show full article', 'read more', or provides a specific news ID from a previous result.",
|
|
5952
|
-
isWrite: false,
|
|
5953
|
-
inputSchema: {
|
|
5954
|
-
type: "object",
|
|
5955
|
-
properties: {
|
|
5956
|
-
id: {
|
|
5957
|
-
type: "string",
|
|
5958
|
-
description: "News article ID from a previous news_get_latest / news_get_by_coin / news_search result. Required."
|
|
5959
|
-
},
|
|
5960
|
-
language: { type: "string", enum: [...NEWS_LANGUAGE], description: D_LANGUAGE }
|
|
5961
|
-
},
|
|
5962
|
-
required: ["id"]
|
|
5963
|
-
},
|
|
5964
|
-
handler: async (rawArgs, context) => {
|
|
5965
|
-
const args = asRecord(rawArgs);
|
|
5966
|
-
const id = readString(args, "id");
|
|
5967
|
-
if (!id) {
|
|
5968
|
-
throw new Error(`Missing required parameter "id".`);
|
|
5969
|
-
}
|
|
5970
|
-
const response = await context.client.privateGet(
|
|
5971
|
-
NEWS_DETAIL,
|
|
5972
|
-
{ id },
|
|
5973
|
-
publicRateLimit("news_get_detail", 20),
|
|
5974
|
-
langHeader(readString(args, "language"))
|
|
5975
|
-
);
|
|
5976
|
-
return normalizeResponse(response);
|
|
5977
|
-
}
|
|
5978
|
-
},
|
|
5979
|
-
{
|
|
5980
|
-
name: "news_get_domains",
|
|
5981
|
-
module: "news",
|
|
5982
|
-
description: "List available news source domains (e.g. coindesk, cointelegraph). Use when user asks what news sources are available or which platforms are covered.",
|
|
5983
|
-
isWrite: false,
|
|
5984
|
-
inputSchema: {
|
|
5985
|
-
type: "object",
|
|
5986
|
-
properties: {},
|
|
5987
|
-
required: []
|
|
5988
|
-
},
|
|
5989
|
-
handler: async (_rawArgs, context) => {
|
|
5990
|
-
const response = await context.client.privateGet(
|
|
5991
|
-
NEWS_DOMAINS,
|
|
5992
|
-
{},
|
|
5993
|
-
publicRateLimit("news_get_domains", 20)
|
|
5994
|
-
);
|
|
5995
|
-
return normalizeResponse(response);
|
|
5996
|
-
}
|
|
5997
|
-
},
|
|
5998
|
-
// -----------------------------------------------------------------------
|
|
5999
|
-
// Token sentiment tools
|
|
6000
|
-
// -----------------------------------------------------------------------
|
|
6001
|
-
{
|
|
6002
|
-
name: "news_get_coin_sentiment",
|
|
6003
|
-
module: "news",
|
|
6004
|
-
description: "Get sentiment snapshot or time-series trend for coins. Returns bullish/bearish ratios and mention counts. Pass trendPoints for trend data (1h\u219224 points, 4h\u21926, 24h\u21927). Use when user asks about coin sentiment, sentiment trend, or how bullish/bearish a coin is.",
|
|
6005
|
-
isWrite: false,
|
|
6006
|
-
inputSchema: {
|
|
6007
|
-
type: "object",
|
|
6008
|
-
properties: {
|
|
6009
|
-
coins: { type: "string", description: D_COINS_SENTIMENT + " Required." },
|
|
6010
|
-
period: {
|
|
6011
|
-
type: "string",
|
|
6012
|
-
enum: [...SENTIMENT_PERIOD],
|
|
6013
|
-
description: "Aggregation granularity: 1h, 4h, 24h. Snapshot default: 24h. Trend default: 1h."
|
|
6014
|
-
},
|
|
6015
|
-
trendPoints: {
|
|
6016
|
-
type: "number",
|
|
6017
|
-
description: "Trend data points. Pass for time-series trend; omit for snapshot. Guide: 1h\u219224, 4h\u21926, 24h\u21927."
|
|
6018
|
-
}
|
|
6019
|
-
},
|
|
6020
|
-
required: ["coins"]
|
|
6021
|
-
},
|
|
6022
|
-
handler: async (rawArgs, context) => {
|
|
6023
|
-
const args = asRecord(rawArgs);
|
|
6024
|
-
const coins = readString(args, "coins");
|
|
6025
|
-
if (!coins) {
|
|
6026
|
-
throw new Error(`Missing required parameter "coins".`);
|
|
6027
|
-
}
|
|
6028
|
-
const trendPoints = readNumber(args, "trendPoints");
|
|
6029
|
-
const inclTrend = trendPoints !== void 0;
|
|
6030
|
-
const response = await context.client.privateGet(
|
|
6031
|
-
SENTIMENT_QUERY,
|
|
6032
|
-
compactObject({
|
|
6033
|
-
ccy: coins,
|
|
6034
|
-
period: readString(args, "period") ?? (inclTrend ? "1h" : "24h"),
|
|
6035
|
-
...inclTrend ? { inclTrend: true, limit: trendPoints } : {}
|
|
6036
|
-
}),
|
|
6037
|
-
publicRateLimit("news_get_coin_sentiment", 20)
|
|
6038
|
-
);
|
|
6039
|
-
return normalizeResponse(response);
|
|
6040
|
-
}
|
|
6041
|
-
},
|
|
6042
|
-
{
|
|
6043
|
-
name: "news_get_sentiment_ranking",
|
|
6044
|
-
module: "news",
|
|
6045
|
-
description: "Get coin ranking by social hotness or sentiment direction. Use when user asks which coins are trending, most bullish/bearish coins. Sort by hot (mention count), bullish, or bearish.",
|
|
6046
|
-
isWrite: false,
|
|
6047
|
-
inputSchema: {
|
|
6048
|
-
type: "object",
|
|
6049
|
-
properties: {
|
|
6050
|
-
period: {
|
|
6051
|
-
type: "string",
|
|
6052
|
-
enum: [...SENTIMENT_PERIOD],
|
|
6053
|
-
description: "Aggregation granularity: 1h, 4h, 24h (default)."
|
|
6054
|
-
},
|
|
6055
|
-
sortBy: {
|
|
6056
|
-
type: "string",
|
|
6057
|
-
enum: ["hot", "bullish", "bearish"],
|
|
6058
|
-
description: "Sort: hot=by mentions (default), bullish=most bullish, bearish=most bearish."
|
|
6059
|
-
},
|
|
6060
|
-
limit: { type: "number", description: D_LIMIT }
|
|
6061
|
-
},
|
|
6062
|
-
required: []
|
|
6063
|
-
},
|
|
6064
|
-
handler: async (rawArgs, context) => {
|
|
6065
|
-
const args = asRecord(rawArgs);
|
|
6066
|
-
const response = await context.client.privateGet(
|
|
6067
|
-
SENTIMENT_RANKING,
|
|
6068
|
-
compactObject({
|
|
6069
|
-
period: readString(args, "period") ?? "24h",
|
|
6070
|
-
sortBy: readString(args, "sortBy") ?? "hot",
|
|
6071
|
-
limit: readNumber(args, "limit") ?? 10
|
|
6072
|
-
}),
|
|
6073
|
-
publicRateLimit("news_get_sentiment_ranking", 20)
|
|
6074
|
-
);
|
|
6075
|
-
return normalizeResponse(response);
|
|
6076
|
-
}
|
|
6077
|
-
}
|
|
6078
|
-
];
|
|
6079
|
-
}
|
|
6080
5766
|
function registerOptionAlgoTools() {
|
|
6081
5767
|
return [
|
|
6082
5768
|
{
|
|
@@ -6343,7 +6029,7 @@ function registerOptionTools() {
|
|
|
6343
6029
|
{
|
|
6344
6030
|
name: "option_place_order",
|
|
6345
6031
|
module: "option",
|
|
6346
|
-
description: "Place OPTION order. instId: {uly}-{expiry}-{strike}-C/P, e.g. BTC-USD-241227-50000-C. [CAUTION] Executes real trades.",
|
|
6032
|
+
description: "Place OPTION order. instId: {uly}-{expiry}-{strike}-C/P, e.g. BTC-USD-241227-50000-C. Before placing, use market_get_instruments to get ctVal (contract face value) \u2014 do NOT assume contract sizes. [CAUTION] Executes real trades.",
|
|
6347
6033
|
isWrite: true,
|
|
6348
6034
|
inputSchema: {
|
|
6349
6035
|
type: "object",
|
|
@@ -7550,7 +7236,6 @@ function allToolSpecs() {
|
|
|
7550
7236
|
...registerOptionAlgoTools(),
|
|
7551
7237
|
...registerAlgoTradeTools(),
|
|
7552
7238
|
...registerAccountTools(),
|
|
7553
|
-
...registerNewsTools(),
|
|
7554
7239
|
...registerBotTools(),
|
|
7555
7240
|
...registerAllEarnTools(),
|
|
7556
7241
|
...registerAuditTools(),
|
|
@@ -8563,7 +8248,7 @@ async function cmdDiagnoseMcp(options = {}) {
|
|
|
8563
8248
|
|
|
8564
8249
|
// src/commands/diagnose.ts
|
|
8565
8250
|
var CLI_VERSION = readCliVersion();
|
|
8566
|
-
var GIT_HASH = true ? "
|
|
8251
|
+
var GIT_HASH = true ? "e46af2f" : "dev";
|
|
8567
8252
|
function maskKey2(key) {
|
|
8568
8253
|
if (!key) return "(not set)";
|
|
8569
8254
|
if (key.length <= 8) return "****";
|
|
@@ -8961,223 +8646,6 @@ async function cmdUpgrade(currentVersion, options, json) {
|
|
|
8961
8646
|
}
|
|
8962
8647
|
}
|
|
8963
8648
|
|
|
8964
|
-
// src/commands/news.ts
|
|
8965
|
-
function getData(result) {
|
|
8966
|
-
return result.data;
|
|
8967
|
-
}
|
|
8968
|
-
function formatTime(ts) {
|
|
8969
|
-
if (!ts) return "-";
|
|
8970
|
-
return new Date(Number(ts)).toLocaleString();
|
|
8971
|
-
}
|
|
8972
|
-
async function cmdNewsLatest(run, opts) {
|
|
8973
|
-
const result = await run("news_get_latest", {
|
|
8974
|
-
coins: opts.coins,
|
|
8975
|
-
importance: opts.importance,
|
|
8976
|
-
begin: opts.begin,
|
|
8977
|
-
end: opts.end,
|
|
8978
|
-
language: opts.language,
|
|
8979
|
-
detailLvl: opts.detailLvl,
|
|
8980
|
-
limit: opts.limit,
|
|
8981
|
-
after: opts.after
|
|
8982
|
-
});
|
|
8983
|
-
const raw = getData(result);
|
|
8984
|
-
const pageData = raw?.[0];
|
|
8985
|
-
if (opts.json) return printJson(pageData ?? null);
|
|
8986
|
-
const items = pageData?.["details"] ?? [];
|
|
8987
|
-
printTable(
|
|
8988
|
-
items.map((n) => ({
|
|
8989
|
-
id: n["id"],
|
|
8990
|
-
time: formatTime(n["cTime"] ?? n["createTime"]),
|
|
8991
|
-
platforms: n["platformList"]?.join(",") ?? "-",
|
|
8992
|
-
title: String(n["title"] ?? "").slice(0, 80)
|
|
8993
|
-
}))
|
|
8994
|
-
);
|
|
8995
|
-
const cursor = pageData?.["nextCursor"];
|
|
8996
|
-
if (cursor) outputLine(`[next] --after ${cursor}`);
|
|
8997
|
-
}
|
|
8998
|
-
async function cmdNewsImportant(run, opts) {
|
|
8999
|
-
const result = await run("news_get_latest", {
|
|
9000
|
-
coins: opts.coins,
|
|
9001
|
-
importance: "high",
|
|
9002
|
-
begin: opts.begin,
|
|
9003
|
-
end: opts.end,
|
|
9004
|
-
language: opts.language,
|
|
9005
|
-
detailLvl: opts.detailLvl,
|
|
9006
|
-
limit: opts.limit
|
|
9007
|
-
});
|
|
9008
|
-
const raw = getData(result);
|
|
9009
|
-
const pageData = raw?.[0];
|
|
9010
|
-
if (opts.json) return printJson(pageData ?? null);
|
|
9011
|
-
const items = pageData?.["details"] ?? [];
|
|
9012
|
-
printTable(
|
|
9013
|
-
items.map((n) => ({
|
|
9014
|
-
id: n["id"],
|
|
9015
|
-
time: formatTime(n["cTime"] ?? n["createTime"]),
|
|
9016
|
-
importance: n["importance"] ?? "-",
|
|
9017
|
-
platforms: n["platformList"]?.join(",") ?? "-",
|
|
9018
|
-
title: String(n["title"] ?? "").slice(0, 80)
|
|
9019
|
-
}))
|
|
9020
|
-
);
|
|
9021
|
-
}
|
|
9022
|
-
async function cmdNewsByCoin(run, coins, opts) {
|
|
9023
|
-
const result = await run("news_get_by_coin", {
|
|
9024
|
-
coins,
|
|
9025
|
-
importance: opts.importance,
|
|
9026
|
-
begin: opts.begin,
|
|
9027
|
-
end: opts.end,
|
|
9028
|
-
language: opts.language,
|
|
9029
|
-
detailLvl: opts.detailLvl,
|
|
9030
|
-
limit: opts.limit
|
|
9031
|
-
});
|
|
9032
|
-
const raw = getData(result);
|
|
9033
|
-
const pageData = raw?.[0];
|
|
9034
|
-
if (opts.json) return printJson(pageData ?? null);
|
|
9035
|
-
const items = pageData?.["details"] ?? [];
|
|
9036
|
-
printTable(
|
|
9037
|
-
items.map((n) => ({
|
|
9038
|
-
id: n["id"],
|
|
9039
|
-
time: formatTime(n["cTime"] ?? n["createTime"]),
|
|
9040
|
-
coins: n["ccyList"]?.join(",") ?? "-",
|
|
9041
|
-
platforms: n["platformList"]?.join(",") ?? "-",
|
|
9042
|
-
title: String(n["title"] ?? "").slice(0, 80)
|
|
9043
|
-
}))
|
|
9044
|
-
);
|
|
9045
|
-
}
|
|
9046
|
-
async function cmdNewsSearch(run, keyword, opts) {
|
|
9047
|
-
const result = await run("news_search", {
|
|
9048
|
-
keyword: keyword || void 0,
|
|
9049
|
-
coins: opts.coins,
|
|
9050
|
-
importance: opts.importance,
|
|
9051
|
-
sentiment: opts.sentiment,
|
|
9052
|
-
sortBy: opts.sortBy,
|
|
9053
|
-
begin: opts.begin,
|
|
9054
|
-
end: opts.end,
|
|
9055
|
-
language: opts.language,
|
|
9056
|
-
detailLvl: opts.detailLvl,
|
|
9057
|
-
limit: opts.limit,
|
|
9058
|
-
after: opts.after
|
|
9059
|
-
});
|
|
9060
|
-
const raw = getData(result);
|
|
9061
|
-
const pageData = raw?.[0];
|
|
9062
|
-
if (opts.json) return printJson(pageData ?? null);
|
|
9063
|
-
const items = pageData?.["details"] ?? [];
|
|
9064
|
-
printTable(
|
|
9065
|
-
items.map((n) => ({
|
|
9066
|
-
id: n["id"],
|
|
9067
|
-
time: formatTime(n["cTime"] ?? n["createTime"]),
|
|
9068
|
-
platforms: n["platformList"]?.join(",") ?? "-",
|
|
9069
|
-
title: String(n["title"] ?? "").slice(0, 80)
|
|
9070
|
-
}))
|
|
9071
|
-
);
|
|
9072
|
-
const cursor = pageData?.["nextCursor"];
|
|
9073
|
-
if (cursor) outputLine(`[next] --after ${cursor}`);
|
|
9074
|
-
}
|
|
9075
|
-
async function cmdNewsDetail(run, id, opts) {
|
|
9076
|
-
const result = await run("news_get_detail", { id, language: opts.language });
|
|
9077
|
-
const items = getData(result);
|
|
9078
|
-
if (opts.json) return printJson(items);
|
|
9079
|
-
const article = items?.[0];
|
|
9080
|
-
if (!article) {
|
|
9081
|
-
outputLine("Article not found.");
|
|
9082
|
-
return;
|
|
9083
|
-
}
|
|
9084
|
-
const rawContent = article["content"] ? String(article["content"]) : void 0;
|
|
9085
|
-
let content;
|
|
9086
|
-
if (rawContent && rawContent.length > 500) {
|
|
9087
|
-
content = rawContent.slice(0, 500) + "... (use --json for full text)";
|
|
9088
|
-
} else {
|
|
9089
|
-
content = rawContent;
|
|
9090
|
-
}
|
|
9091
|
-
printKv({
|
|
9092
|
-
id: article["id"],
|
|
9093
|
-
title: article["title"],
|
|
9094
|
-
platforms: article["platformList"]?.join(", ") ?? "-",
|
|
9095
|
-
time: formatTime(article["cTime"] ?? article["createTime"]),
|
|
9096
|
-
sourceUrl: article["sourceUrl"],
|
|
9097
|
-
coins: article["ccyList"]?.join(", ") ?? "-",
|
|
9098
|
-
importance: article["importance"] ?? "-",
|
|
9099
|
-
summary: article["summary"] ?? "(see content)",
|
|
9100
|
-
content
|
|
9101
|
-
});
|
|
9102
|
-
}
|
|
9103
|
-
async function cmdNewsDomains(run, opts) {
|
|
9104
|
-
const result = await run("news_get_domains", {});
|
|
9105
|
-
const raw = getData(result);
|
|
9106
|
-
const items = raw?.[0]?.["platform"] ?? [];
|
|
9107
|
-
if (opts.json) return printJson(items);
|
|
9108
|
-
outputLine("Available news source domains:");
|
|
9109
|
-
(items ?? []).forEach((d) => outputLine(` ${d}`));
|
|
9110
|
-
}
|
|
9111
|
-
async function cmdNewsCoinSentiment(run, coins, opts) {
|
|
9112
|
-
const result = await run("news_get_coin_sentiment", {
|
|
9113
|
-
coins,
|
|
9114
|
-
period: opts.period
|
|
9115
|
-
});
|
|
9116
|
-
const raw = getData(result);
|
|
9117
|
-
if (opts.json) return printJson(raw);
|
|
9118
|
-
const items = raw?.[0]?.["details"] ?? [];
|
|
9119
|
-
printTable(
|
|
9120
|
-
items.map((c) => {
|
|
9121
|
-
const snt = c["sentiment"];
|
|
9122
|
-
return {
|
|
9123
|
-
symbol: c["ccy"],
|
|
9124
|
-
label: snt?.["label"] ?? "-",
|
|
9125
|
-
bullish: snt?.["bullishRatio"] ?? "-",
|
|
9126
|
-
bearish: snt?.["bearishRatio"] ?? "-",
|
|
9127
|
-
mentions: c["mentionCnt"]
|
|
9128
|
-
};
|
|
9129
|
-
})
|
|
9130
|
-
);
|
|
9131
|
-
}
|
|
9132
|
-
async function cmdNewsCoinTrend(run, coin, opts) {
|
|
9133
|
-
const result = await run("news_get_coin_sentiment", {
|
|
9134
|
-
coins: coin,
|
|
9135
|
-
period: opts.period,
|
|
9136
|
-
trendPoints: opts.points
|
|
9137
|
-
});
|
|
9138
|
-
const raw = getData(result);
|
|
9139
|
-
if (opts.json) return printJson(raw);
|
|
9140
|
-
const items = raw?.[0]?.["details"] ?? [];
|
|
9141
|
-
const coinData = items?.[0];
|
|
9142
|
-
if (!coinData) {
|
|
9143
|
-
outputLine("No trend data.");
|
|
9144
|
-
return;
|
|
9145
|
-
}
|
|
9146
|
-
const trend = coinData["trend"] ?? [];
|
|
9147
|
-
outputLine(`Sentiment trend for ${coin} (period: ${opts.period ?? "1h"}):`);
|
|
9148
|
-
printTable(
|
|
9149
|
-
trend.map((t) => ({
|
|
9150
|
-
time: formatTime(t["ts"]),
|
|
9151
|
-
bullish: t["bullishRatio"],
|
|
9152
|
-
bearish: t["bearishRatio"],
|
|
9153
|
-
mentions: t["mentionCnt"]
|
|
9154
|
-
}))
|
|
9155
|
-
);
|
|
9156
|
-
}
|
|
9157
|
-
async function cmdNewsSentimentRank(run, opts) {
|
|
9158
|
-
const result = await run("news_get_sentiment_ranking", {
|
|
9159
|
-
period: opts.period,
|
|
9160
|
-
sortBy: opts.sortBy,
|
|
9161
|
-
limit: opts.limit
|
|
9162
|
-
});
|
|
9163
|
-
const raw = getData(result);
|
|
9164
|
-
if (opts.json) return printJson(raw);
|
|
9165
|
-
const items = raw?.[0]?.["details"] ?? [];
|
|
9166
|
-
printTable(
|
|
9167
|
-
items.map((c, i) => {
|
|
9168
|
-
const snt = c["sentiment"];
|
|
9169
|
-
return {
|
|
9170
|
-
rank: i + 1,
|
|
9171
|
-
symbol: c["ccy"],
|
|
9172
|
-
label: snt?.["label"] ?? "-",
|
|
9173
|
-
bullish: snt?.["bullishRatio"] ?? "-",
|
|
9174
|
-
bearish: snt?.["bearishRatio"] ?? "-",
|
|
9175
|
-
mentions: c["mentionCnt"]
|
|
9176
|
-
};
|
|
9177
|
-
})
|
|
9178
|
-
);
|
|
9179
|
-
}
|
|
9180
|
-
|
|
9181
8649
|
// src/config/loader.ts
|
|
9182
8650
|
function loadProfileConfig(opts) {
|
|
9183
8651
|
return loadConfig({
|
|
@@ -9789,51 +9257,6 @@ var HELP_TREE = {
|
|
|
9789
9257
|
upgrade: {
|
|
9790
9258
|
description: "Upgrade okx CLI and MCP server to the latest stable version",
|
|
9791
9259
|
usage: "okx upgrade [--check] [--beta] [--force] [--json]"
|
|
9792
|
-
},
|
|
9793
|
-
news: {
|
|
9794
|
-
description: "Orbit News \u2014 crypto news feed, coin sentiment, and trend analysis",
|
|
9795
|
-
commands: {
|
|
9796
|
-
latest: {
|
|
9797
|
-
usage: "okx news latest [--limit <n>] [--lang <zh_CN|en_US>]",
|
|
9798
|
-
description: "Get latest crypto news"
|
|
9799
|
-
},
|
|
9800
|
-
important: {
|
|
9801
|
-
usage: "okx news important [--limit <n>] [--lang <zh_CN|en_US>]",
|
|
9802
|
-
description: "Get important / high-impact crypto news"
|
|
9803
|
-
},
|
|
9804
|
-
"by-coin": {
|
|
9805
|
-
usage: "okx news by-coin --coins <BTC,ETH,...> [--limit <n>] [--lang <zh_CN|en_US>]",
|
|
9806
|
-
description: "Get news filtered by coin(s)"
|
|
9807
|
-
},
|
|
9808
|
-
"by-sentiment": {
|
|
9809
|
-
usage: "okx news by-sentiment --sentiment <bullish|bearish|neutral> [--limit <n>] [--lang <zh_CN|en_US>]",
|
|
9810
|
-
description: "Get news filtered by sentiment"
|
|
9811
|
-
},
|
|
9812
|
-
search: {
|
|
9813
|
-
usage: "okx news search --keyword <text> [--limit <n>] [--lang <zh_CN|en_US>]",
|
|
9814
|
-
description: "Search news by keyword"
|
|
9815
|
-
},
|
|
9816
|
-
detail: {
|
|
9817
|
-
usage: "okx news detail <articleId> [--lang <zh_CN|en_US>]",
|
|
9818
|
-
description: "Get full article detail by ID"
|
|
9819
|
-
},
|
|
9820
|
-
domains: {
|
|
9821
|
-
usage: "okx news domains",
|
|
9822
|
-
description: "List available news source domains"
|
|
9823
|
-
},
|
|
9824
|
-
"coin-sentiment": {
|
|
9825
|
-
usage: "okx news coin-sentiment --coins <BTC,ETH,...> [--period <1h|24h>]",
|
|
9826
|
-
description: "Get sentiment score for specific coin(s)"
|
|
9827
|
-
},
|
|
9828
|
-
"coin-trend": {
|
|
9829
|
-
usage: "okx news coin-trend <coin> [--period <1h|24h>] [--points <n>]",
|
|
9830
|
-
description: "Get sentiment trend data points for a coin"
|
|
9831
|
-
},
|
|
9832
|
-
"sentiment-rank": {
|
|
9833
|
-
usage: "okx news sentiment-rank [--period <1h|24h>] [--sort-by <hot|bullish|bearish>] [--limit <n>]",
|
|
9834
|
-
description: "Get coin ranking by social hotness or sentiment direction"
|
|
9835
|
-
}
|
|
9836
|
-
}
|
|
9837
9260
|
}
|
|
9838
9261
|
};
|
|
9839
9262
|
function printGlobalHelp() {
|
|
@@ -10117,16 +9540,8 @@ var CLI_OPTIONS = {
|
|
|
10117
9540
|
params: { type: "string" },
|
|
10118
9541
|
list: { type: "boolean", default: false },
|
|
10119
9542
|
"backtest-time": { type: "string" },
|
|
10120
|
-
// news
|
|
10121
|
-
coins: { type: "string" },
|
|
10122
|
-
sentiment: { type: "string" },
|
|
10123
|
-
importance: { type: "string" },
|
|
10124
|
-
keyword: { type: "string" },
|
|
10125
|
-
"detail-lvl": { type: "string" },
|
|
10126
|
-
period: { type: "string" },
|
|
10127
|
-
points: { type: "string" },
|
|
10128
|
-
"sort-by": { type: "string" },
|
|
10129
9543
|
// skill marketplace
|
|
9544
|
+
keyword: { type: "string" },
|
|
10130
9545
|
categories: { type: "string" },
|
|
10131
9546
|
dir: { type: "string" },
|
|
10132
9547
|
page: { type: "string" },
|
|
@@ -10165,12 +9580,12 @@ function parseCli(argv) {
|
|
|
10165
9580
|
}
|
|
10166
9581
|
|
|
10167
9582
|
// src/commands/market.ts
|
|
10168
|
-
function
|
|
9583
|
+
function getData(result) {
|
|
10169
9584
|
return result.data;
|
|
10170
9585
|
}
|
|
10171
9586
|
async function cmdMarketInstruments(run, opts) {
|
|
10172
9587
|
const result = await run("market_get_instruments", { instType: opts.instType, instId: opts.instId });
|
|
10173
|
-
const items =
|
|
9588
|
+
const items = getData(result);
|
|
10174
9589
|
if (opts.json) return printJson(items);
|
|
10175
9590
|
printTable(
|
|
10176
9591
|
(items ?? []).slice(0, 50).map((t) => ({
|
|
@@ -10185,7 +9600,7 @@ async function cmdMarketInstruments(run, opts) {
|
|
|
10185
9600
|
}
|
|
10186
9601
|
async function cmdMarketFundingRate(run, instId, opts) {
|
|
10187
9602
|
const result = await run("market_get_funding_rate", { instId, history: opts.history, limit: opts.limit });
|
|
10188
|
-
const items =
|
|
9603
|
+
const items = getData(result);
|
|
10189
9604
|
if (opts.json) return printJson(items);
|
|
10190
9605
|
if (opts.history) {
|
|
10191
9606
|
printTable(
|
|
@@ -10213,7 +9628,7 @@ async function cmdMarketFundingRate(run, instId, opts) {
|
|
|
10213
9628
|
}
|
|
10214
9629
|
async function cmdMarketMarkPrice(run, opts) {
|
|
10215
9630
|
const result = await run("market_get_mark_price", { instType: opts.instType, instId: opts.instId });
|
|
10216
|
-
const items =
|
|
9631
|
+
const items = getData(result);
|
|
10217
9632
|
if (opts.json) return printJson(items);
|
|
10218
9633
|
printTable(
|
|
10219
9634
|
(items ?? []).map((r) => ({
|
|
@@ -10226,7 +9641,7 @@ async function cmdMarketMarkPrice(run, opts) {
|
|
|
10226
9641
|
}
|
|
10227
9642
|
async function cmdMarketTrades(run, instId, opts) {
|
|
10228
9643
|
const result = await run("market_get_trades", { instId, limit: opts.limit });
|
|
10229
|
-
const items =
|
|
9644
|
+
const items = getData(result);
|
|
10230
9645
|
if (opts.json) return printJson(items);
|
|
10231
9646
|
printTable(
|
|
10232
9647
|
(items ?? []).map((t) => ({
|
|
@@ -10240,7 +9655,7 @@ async function cmdMarketTrades(run, instId, opts) {
|
|
|
10240
9655
|
}
|
|
10241
9656
|
async function cmdMarketIndexTicker(run, opts) {
|
|
10242
9657
|
const result = await run("market_get_index_ticker", { instId: opts.instId, quoteCcy: opts.quoteCcy });
|
|
10243
|
-
const items =
|
|
9658
|
+
const items = getData(result);
|
|
10244
9659
|
if (opts.json) return printJson(items);
|
|
10245
9660
|
printTable(
|
|
10246
9661
|
(items ?? []).map((t) => ({
|
|
@@ -10254,7 +9669,7 @@ async function cmdMarketIndexTicker(run, opts) {
|
|
|
10254
9669
|
}
|
|
10255
9670
|
async function cmdMarketIndexCandles(run, instId, opts) {
|
|
10256
9671
|
const result = await run("market_get_index_candles", { instId, bar: opts.bar, limit: opts.limit, history: opts.history });
|
|
10257
|
-
const candles =
|
|
9672
|
+
const candles = getData(result);
|
|
10258
9673
|
if (opts.json) return printJson(candles);
|
|
10259
9674
|
printTable(
|
|
10260
9675
|
(candles ?? []).map(([ts, o, h, l, c]) => ({
|
|
@@ -10268,7 +9683,7 @@ async function cmdMarketIndexCandles(run, instId, opts) {
|
|
|
10268
9683
|
}
|
|
10269
9684
|
async function cmdMarketPriceLimit(run, instId, json) {
|
|
10270
9685
|
const result = await run("market_get_price_limit", { instId });
|
|
10271
|
-
const items =
|
|
9686
|
+
const items = getData(result);
|
|
10272
9687
|
if (json) return printJson(items);
|
|
10273
9688
|
const r = items?.[0];
|
|
10274
9689
|
if (!r) {
|
|
@@ -10284,7 +9699,7 @@ async function cmdMarketPriceLimit(run, instId, json) {
|
|
|
10284
9699
|
}
|
|
10285
9700
|
async function cmdMarketOpenInterest(run, opts) {
|
|
10286
9701
|
const result = await run("market_get_open_interest", { instType: opts.instType, instId: opts.instId });
|
|
10287
|
-
const items =
|
|
9702
|
+
const items = getData(result);
|
|
10288
9703
|
if (opts.json) return printJson(items);
|
|
10289
9704
|
printTable(
|
|
10290
9705
|
(items ?? []).map((r) => ({
|
|
@@ -10297,7 +9712,7 @@ async function cmdMarketOpenInterest(run, opts) {
|
|
|
10297
9712
|
}
|
|
10298
9713
|
async function cmdMarketTicker(run, instId, json) {
|
|
10299
9714
|
const result = await run("market_get_ticker", { instId });
|
|
10300
|
-
const items =
|
|
9715
|
+
const items = getData(result);
|
|
10301
9716
|
if (json) return printJson(items);
|
|
10302
9717
|
if (!items?.length) {
|
|
10303
9718
|
outputLine("No data");
|
|
@@ -10321,7 +9736,7 @@ async function cmdMarketTicker(run, instId, json) {
|
|
|
10321
9736
|
}
|
|
10322
9737
|
async function cmdMarketTickers(run, instType, json) {
|
|
10323
9738
|
const result = await run("market_get_tickers", { instType });
|
|
10324
|
-
const items =
|
|
9739
|
+
const items = getData(result);
|
|
10325
9740
|
if (json) return printJson(items);
|
|
10326
9741
|
printTable(
|
|
10327
9742
|
(items ?? []).map((t) => ({
|
|
@@ -10335,7 +9750,7 @@ async function cmdMarketTickers(run, instType, json) {
|
|
|
10335
9750
|
}
|
|
10336
9751
|
async function cmdMarketOrderbook(run, instId, sz, json) {
|
|
10337
9752
|
const result = await run("market_get_orderbook", { instId, sz });
|
|
10338
|
-
const data =
|
|
9753
|
+
const data = getData(result);
|
|
10339
9754
|
if (json) return printJson(data);
|
|
10340
9755
|
const book = data[0];
|
|
10341
9756
|
if (!book) {
|
|
@@ -10352,7 +9767,7 @@ async function cmdMarketOrderbook(run, instId, sz, json) {
|
|
|
10352
9767
|
}
|
|
10353
9768
|
async function cmdMarketCandles(run, instId, opts) {
|
|
10354
9769
|
const result = await run("market_get_candles", { instId, bar: opts.bar, limit: opts.limit, after: opts.after, before: opts.before });
|
|
10355
|
-
const candles =
|
|
9770
|
+
const candles = getData(result);
|
|
10356
9771
|
if (opts.json) return printJson(candles);
|
|
10357
9772
|
printTable(
|
|
10358
9773
|
(candles ?? []).map(([ts, o, h, l, c, vol]) => ({
|
|
@@ -10376,7 +9791,7 @@ async function cmdMarketIndicator(run, indicator, instId, opts) {
|
|
|
10376
9791
|
limit: opts.limit,
|
|
10377
9792
|
backtestTime: opts.backtestTime
|
|
10378
9793
|
});
|
|
10379
|
-
const outerArray =
|
|
9794
|
+
const outerArray = getData(result);
|
|
10380
9795
|
if (opts.json) return printJson(outerArray);
|
|
10381
9796
|
if (!outerArray?.length) {
|
|
10382
9797
|
process.stdout.write("No data\n");
|
|
@@ -10419,7 +9834,7 @@ async function cmdMarketInstrumentsByCategory(run, opts) {
|
|
|
10419
9834
|
instType: opts.instType,
|
|
10420
9835
|
instId: opts.instId
|
|
10421
9836
|
});
|
|
10422
|
-
const items =
|
|
9837
|
+
const items = getData(result);
|
|
10423
9838
|
if (opts.json) return printJson(items);
|
|
10424
9839
|
const CATEGORY_LABELS = {
|
|
10425
9840
|
"3": "Stock tokens",
|
|
@@ -10446,7 +9861,7 @@ async function cmdMarketInstrumentsByCategory(run, opts) {
|
|
|
10446
9861
|
}
|
|
10447
9862
|
async function cmdMarketStockTokens(run, opts) {
|
|
10448
9863
|
const result = await run("market_get_stock_tokens", { instType: opts.instType, instId: opts.instId });
|
|
10449
|
-
const items =
|
|
9864
|
+
const items = getData(result);
|
|
10450
9865
|
if (opts.json) return printJson(items);
|
|
10451
9866
|
printTable(
|
|
10452
9867
|
(items ?? []).slice(0, 50).map((t) => ({
|
|
@@ -10465,12 +9880,12 @@ async function cmdMarketStockTokens(run, opts) {
|
|
|
10465
9880
|
import * as fs6 from "fs";
|
|
10466
9881
|
import * as path4 from "path";
|
|
10467
9882
|
import * as os5 from "os";
|
|
10468
|
-
function
|
|
9883
|
+
function getData2(result) {
|
|
10469
9884
|
return result.data;
|
|
10470
9885
|
}
|
|
10471
9886
|
async function cmdAccountBalance(run, ccy, json) {
|
|
10472
9887
|
const result = await run("account_get_balance", { ccy });
|
|
10473
|
-
const data =
|
|
9888
|
+
const data = getData2(result);
|
|
10474
9889
|
if (json) return printJson(data);
|
|
10475
9890
|
const details = data?.[0]?.["details"] ?? [];
|
|
10476
9891
|
const rows = details.filter((d) => Number(d["eq"]) > 0).map((d) => ({
|
|
@@ -10523,7 +9938,7 @@ async function cmdAccountAssetBalance(run, ccy, json, showValuation) {
|
|
|
10523
9938
|
}
|
|
10524
9939
|
async function cmdAccountPositions(run, opts) {
|
|
10525
9940
|
const result = await run("account_get_positions", { instType: opts.instType, instId: opts.instId });
|
|
10526
|
-
const positions =
|
|
9941
|
+
const positions = getData2(result);
|
|
10527
9942
|
if (opts.json) return printJson(positions);
|
|
10528
9943
|
const open = (positions ?? []).filter((p) => Number(p["pos"]) !== 0);
|
|
10529
9944
|
if (!open.length) {
|
|
@@ -10545,7 +9960,7 @@ async function cmdAccountPositions(run, opts) {
|
|
|
10545
9960
|
async function cmdAccountBills(run, opts) {
|
|
10546
9961
|
const toolName = opts.archive ? "account_get_bills_archive" : "account_get_bills";
|
|
10547
9962
|
const result = await run(toolName, { instType: opts.instType, ccy: opts.ccy, limit: opts.limit });
|
|
10548
|
-
const bills =
|
|
9963
|
+
const bills = getData2(result);
|
|
10549
9964
|
if (opts.json) return printJson(bills);
|
|
10550
9965
|
printTable(
|
|
10551
9966
|
(bills ?? []).map((b) => ({
|
|
@@ -10561,7 +9976,7 @@ async function cmdAccountBills(run, opts) {
|
|
|
10561
9976
|
}
|
|
10562
9977
|
async function cmdAccountFees(run, opts) {
|
|
10563
9978
|
const result = await run("account_get_trade_fee", { instType: opts.instType, instId: opts.instId });
|
|
10564
|
-
const data =
|
|
9979
|
+
const data = getData2(result);
|
|
10565
9980
|
if (opts.json) return printJson(data);
|
|
10566
9981
|
const fee = data?.[0];
|
|
10567
9982
|
if (!fee) {
|
|
@@ -10579,7 +9994,7 @@ async function cmdAccountFees(run, opts) {
|
|
|
10579
9994
|
}
|
|
10580
9995
|
async function cmdAccountConfig(run, json) {
|
|
10581
9996
|
const result = await run("account_get_config", {});
|
|
10582
|
-
const data =
|
|
9997
|
+
const data = getData2(result);
|
|
10583
9998
|
if (json) return printJson(data);
|
|
10584
9999
|
const cfg = data?.[0];
|
|
10585
10000
|
if (!cfg) {
|
|
@@ -10598,14 +10013,14 @@ async function cmdAccountConfig(run, json) {
|
|
|
10598
10013
|
}
|
|
10599
10014
|
async function cmdAccountSetPositionMode(run, posMode, json) {
|
|
10600
10015
|
const result = await run("account_set_position_mode", { posMode });
|
|
10601
|
-
const data =
|
|
10016
|
+
const data = getData2(result);
|
|
10602
10017
|
if (json) return printJson(data);
|
|
10603
10018
|
const r = data?.[0];
|
|
10604
10019
|
outputLine(`Position mode set: ${r?.["posMode"]}`);
|
|
10605
10020
|
}
|
|
10606
10021
|
async function cmdAccountMaxSize(run, opts) {
|
|
10607
10022
|
const result = await run("account_get_max_size", { instId: opts.instId, tdMode: opts.tdMode, px: opts.px });
|
|
10608
|
-
const data =
|
|
10023
|
+
const data = getData2(result);
|
|
10609
10024
|
if (opts.json) return printJson(data);
|
|
10610
10025
|
const r = data?.[0];
|
|
10611
10026
|
if (!r) {
|
|
@@ -10616,7 +10031,7 @@ async function cmdAccountMaxSize(run, opts) {
|
|
|
10616
10031
|
}
|
|
10617
10032
|
async function cmdAccountMaxAvailSize(run, opts) {
|
|
10618
10033
|
const result = await run("account_get_max_avail_size", { instId: opts.instId, tdMode: opts.tdMode });
|
|
10619
|
-
const data =
|
|
10034
|
+
const data = getData2(result);
|
|
10620
10035
|
if (opts.json) return printJson(data);
|
|
10621
10036
|
const r = data?.[0];
|
|
10622
10037
|
if (!r) {
|
|
@@ -10627,7 +10042,7 @@ async function cmdAccountMaxAvailSize(run, opts) {
|
|
|
10627
10042
|
}
|
|
10628
10043
|
async function cmdAccountMaxWithdrawal(run, ccy, json) {
|
|
10629
10044
|
const result = await run("account_get_max_withdrawal", { ccy });
|
|
10630
|
-
const data =
|
|
10045
|
+
const data = getData2(result);
|
|
10631
10046
|
if (json) return printJson(data);
|
|
10632
10047
|
printTable(
|
|
10633
10048
|
(data ?? []).map((r) => ({
|
|
@@ -10639,7 +10054,7 @@ async function cmdAccountMaxWithdrawal(run, ccy, json) {
|
|
|
10639
10054
|
}
|
|
10640
10055
|
async function cmdAccountPositionsHistory(run, opts) {
|
|
10641
10056
|
const result = await run("account_get_positions_history", { instType: opts.instType, instId: opts.instId, limit: opts.limit });
|
|
10642
|
-
const data =
|
|
10057
|
+
const data = getData2(result);
|
|
10643
10058
|
if (opts.json) return printJson(data);
|
|
10644
10059
|
printTable(
|
|
10645
10060
|
(data ?? []).map((p) => ({
|
|
@@ -10661,7 +10076,7 @@ async function cmdAccountTransfer(run, opts) {
|
|
|
10661
10076
|
type: opts.transferType,
|
|
10662
10077
|
subAcct: opts.subAcct
|
|
10663
10078
|
});
|
|
10664
|
-
const data =
|
|
10079
|
+
const data = getData2(result);
|
|
10665
10080
|
if (opts.json) return printJson(data);
|
|
10666
10081
|
const r = data?.[0];
|
|
10667
10082
|
outputLine(`Transfer: ${r?.["transId"]} (${r?.["ccy"]} ${r?.["amt"]})`);
|
|
@@ -10721,7 +10136,7 @@ function cmdAccountAudit(opts) {
|
|
|
10721
10136
|
}
|
|
10722
10137
|
|
|
10723
10138
|
// src/commands/spot.ts
|
|
10724
|
-
function
|
|
10139
|
+
function getData3(result) {
|
|
10725
10140
|
return result.data;
|
|
10726
10141
|
}
|
|
10727
10142
|
function emitWriteResult(item, label, idKey) {
|
|
@@ -10745,7 +10160,7 @@ function emitBatchResults(items) {
|
|
|
10745
10160
|
}
|
|
10746
10161
|
async function cmdSpotOrders(run, opts) {
|
|
10747
10162
|
const result = await run("spot_get_orders", { instId: opts.instId, status: opts.status });
|
|
10748
|
-
const orders =
|
|
10163
|
+
const orders = getData3(result);
|
|
10749
10164
|
if (opts.json) return printJson(orders);
|
|
10750
10165
|
printTable(
|
|
10751
10166
|
(orders ?? []).map((o) => ({
|
|
@@ -10774,7 +10189,7 @@ async function cmdSpotPlace(run, opts) {
|
|
|
10774
10189
|
slTriggerPx: opts.slTriggerPx,
|
|
10775
10190
|
slOrdPx: opts.slOrdPx
|
|
10776
10191
|
});
|
|
10777
|
-
const data =
|
|
10192
|
+
const data = getData3(result);
|
|
10778
10193
|
if (opts.json) return printJson(data);
|
|
10779
10194
|
emitWriteResult(data?.[0], "Order placed", "ordId");
|
|
10780
10195
|
}
|
|
@@ -10782,7 +10197,7 @@ async function cmdSpotCancel(run, opts) {
|
|
|
10782
10197
|
const { instId, ordId, clOrdId, json } = opts;
|
|
10783
10198
|
if (!ordId && !clOrdId) throw new Error("Either --ordId or --clOrdId is required");
|
|
10784
10199
|
const result = await run("spot_cancel_order", { instId, ...ordId ? { ordId } : { clOrdId } });
|
|
10785
|
-
const data =
|
|
10200
|
+
const data = getData3(result);
|
|
10786
10201
|
if (json) return printJson(data);
|
|
10787
10202
|
emitWriteResult(data?.[0], "Cancelled", "ordId");
|
|
10788
10203
|
}
|
|
@@ -10802,7 +10217,7 @@ async function cmdSpotAlgoPlace(run, opts) {
|
|
|
10802
10217
|
callbackSpread: opts.callbackSpread,
|
|
10803
10218
|
activePx: opts.activePx
|
|
10804
10219
|
});
|
|
10805
|
-
const data =
|
|
10220
|
+
const data = getData3(result);
|
|
10806
10221
|
if (opts.json) return printJson(data);
|
|
10807
10222
|
emitWriteResult(data?.[0], "Algo order placed", "algoId");
|
|
10808
10223
|
}
|
|
@@ -10816,19 +10231,19 @@ async function cmdSpotAlgoAmend(run, opts) {
|
|
|
10816
10231
|
newSlTriggerPx: opts.newSlTriggerPx,
|
|
10817
10232
|
newSlOrdPx: opts.newSlOrdPx
|
|
10818
10233
|
});
|
|
10819
|
-
const data =
|
|
10234
|
+
const data = getData3(result);
|
|
10820
10235
|
if (opts.json) return printJson(data);
|
|
10821
10236
|
emitWriteResult(data?.[0], "Algo order amended", "algoId");
|
|
10822
10237
|
}
|
|
10823
10238
|
async function cmdSpotAlgoCancel(run, instId, algoId, json) {
|
|
10824
10239
|
const result = await run("spot_cancel_algo_order", { instId, algoId });
|
|
10825
|
-
const data =
|
|
10240
|
+
const data = getData3(result);
|
|
10826
10241
|
if (json) return printJson(data);
|
|
10827
10242
|
emitWriteResult(data?.[0], "Algo order cancelled", "algoId");
|
|
10828
10243
|
}
|
|
10829
10244
|
async function cmdSpotGet(run, opts) {
|
|
10830
10245
|
const result = await run("spot_get_order", { instId: opts.instId, ordId: opts.ordId, clOrdId: opts.clOrdId });
|
|
10831
|
-
const data =
|
|
10246
|
+
const data = getData3(result);
|
|
10832
10247
|
if (opts.json) return printJson(data);
|
|
10833
10248
|
const o = data?.[0];
|
|
10834
10249
|
if (!o) {
|
|
@@ -10856,7 +10271,7 @@ async function cmdSpotAmend(run, opts) {
|
|
|
10856
10271
|
newSz: opts.newSz,
|
|
10857
10272
|
newPx: opts.newPx
|
|
10858
10273
|
});
|
|
10859
|
-
const data =
|
|
10274
|
+
const data = getData3(result);
|
|
10860
10275
|
if (opts.json) return printJson(data);
|
|
10861
10276
|
emitWriteResult(data?.[0], "Order amended", "ordId");
|
|
10862
10277
|
}
|
|
@@ -10866,7 +10281,7 @@ async function cmdSpotAlgoOrders(run, opts) {
|
|
|
10866
10281
|
status: opts.status,
|
|
10867
10282
|
ordType: opts.ordType
|
|
10868
10283
|
});
|
|
10869
|
-
const orders =
|
|
10284
|
+
const orders = getData3(result);
|
|
10870
10285
|
if (opts.json) return printJson(orders);
|
|
10871
10286
|
if (!(orders ?? []).length) {
|
|
10872
10287
|
outputLine("No algo orders");
|
|
@@ -10887,7 +10302,7 @@ async function cmdSpotAlgoOrders(run, opts) {
|
|
|
10887
10302
|
}
|
|
10888
10303
|
async function cmdSpotFills(run, opts) {
|
|
10889
10304
|
const result = await run("spot_get_fills", { instId: opts.instId, ordId: opts.ordId });
|
|
10890
|
-
const fills =
|
|
10305
|
+
const fills = getData3(result);
|
|
10891
10306
|
if (opts.json) return printJson(fills);
|
|
10892
10307
|
printTable(
|
|
10893
10308
|
(fills ?? []).map((f) => ({
|
|
@@ -10911,7 +10326,7 @@ async function cmdSpotAlgoTrailPlace(run, opts) {
|
|
|
10911
10326
|
callbackSpread: opts.callbackSpread,
|
|
10912
10327
|
activePx: opts.activePx
|
|
10913
10328
|
});
|
|
10914
|
-
const data =
|
|
10329
|
+
const data = getData3(result);
|
|
10915
10330
|
if (opts.json) return printJson(data);
|
|
10916
10331
|
emitWriteResult(data?.[0], "Trailing stop placed", "algoId");
|
|
10917
10332
|
}
|
|
@@ -10941,13 +10356,13 @@ async function cmdSpotBatch(run, opts) {
|
|
|
10941
10356
|
return;
|
|
10942
10357
|
}
|
|
10943
10358
|
const result = await run(tool, tool === "spot_batch_orders" ? { action: opts.action, orders: parsed } : { orders: parsed });
|
|
10944
|
-
const data =
|
|
10359
|
+
const data = getData3(result);
|
|
10945
10360
|
if (opts.json) return printJson(data);
|
|
10946
10361
|
emitBatchResults(data ?? []);
|
|
10947
10362
|
}
|
|
10948
10363
|
|
|
10949
10364
|
// src/commands/swap.ts
|
|
10950
|
-
function
|
|
10365
|
+
function getData4(result) {
|
|
10951
10366
|
return result.data;
|
|
10952
10367
|
}
|
|
10953
10368
|
function emitWriteResult2(item, label, idKey) {
|
|
@@ -10971,7 +10386,7 @@ function emitBatchResults2(items) {
|
|
|
10971
10386
|
}
|
|
10972
10387
|
async function cmdSwapPositions(run, instId, json) {
|
|
10973
10388
|
const result = await run("swap_get_positions", { instId });
|
|
10974
|
-
const positions =
|
|
10389
|
+
const positions = getData4(result);
|
|
10975
10390
|
if (json) return printJson(positions);
|
|
10976
10391
|
const open = (positions ?? []).filter((p) => Number(p["pos"]) !== 0);
|
|
10977
10392
|
if (!open.length) {
|
|
@@ -10992,7 +10407,7 @@ async function cmdSwapPositions(run, instId, json) {
|
|
|
10992
10407
|
}
|
|
10993
10408
|
async function cmdSwapOrders(run, opts) {
|
|
10994
10409
|
const result = await run("swap_get_orders", { instId: opts.instId, status: opts.status });
|
|
10995
|
-
const orders =
|
|
10410
|
+
const orders = getData4(result);
|
|
10996
10411
|
if (opts.json) return printJson(orders);
|
|
10997
10412
|
printTable(
|
|
10998
10413
|
(orders ?? []).map((o) => ({
|
|
@@ -11022,7 +10437,7 @@ async function cmdSwapPlace(run, opts) {
|
|
|
11022
10437
|
slTriggerPx: opts.slTriggerPx,
|
|
11023
10438
|
slOrdPx: opts.slOrdPx
|
|
11024
10439
|
});
|
|
11025
|
-
const data =
|
|
10440
|
+
const data = getData4(result);
|
|
11026
10441
|
if (opts.json) return printJson(data);
|
|
11027
10442
|
emitWriteResult2(data?.[0], "Order placed", "ordId");
|
|
11028
10443
|
}
|
|
@@ -11030,7 +10445,7 @@ async function cmdSwapCancel(run, opts) {
|
|
|
11030
10445
|
const { instId, ordId, clOrdId, json } = opts;
|
|
11031
10446
|
if (!ordId && !clOrdId) throw new Error("Either --ordId or --clOrdId is required");
|
|
11032
10447
|
const result = await run("swap_cancel_order", { instId, ...ordId ? { ordId } : { clOrdId } });
|
|
11033
|
-
const data =
|
|
10448
|
+
const data = getData4(result);
|
|
11034
10449
|
if (json) return printJson(data);
|
|
11035
10450
|
emitWriteResult2(data?.[0], "Cancelled", "ordId");
|
|
11036
10451
|
}
|
|
@@ -11052,7 +10467,7 @@ async function cmdSwapAlgoPlace(run, opts) {
|
|
|
11052
10467
|
callbackSpread: opts.callbackSpread,
|
|
11053
10468
|
activePx: opts.activePx
|
|
11054
10469
|
});
|
|
11055
|
-
const data =
|
|
10470
|
+
const data = getData4(result);
|
|
11056
10471
|
if (opts.json) return printJson(data);
|
|
11057
10472
|
emitWriteResult2(data?.[0], "Algo order placed", "algoId");
|
|
11058
10473
|
}
|
|
@@ -11066,7 +10481,7 @@ async function cmdSwapAlgoAmend(run, opts) {
|
|
|
11066
10481
|
newSlTriggerPx: opts.newSlTriggerPx,
|
|
11067
10482
|
newSlOrdPx: opts.newSlOrdPx
|
|
11068
10483
|
});
|
|
11069
|
-
const data =
|
|
10484
|
+
const data = getData4(result);
|
|
11070
10485
|
if (opts.json) return printJson(data);
|
|
11071
10486
|
emitWriteResult2(data?.[0], "Algo order amended", "algoId");
|
|
11072
10487
|
}
|
|
@@ -11082,13 +10497,13 @@ async function cmdSwapAlgoTrailPlace(run, opts) {
|
|
|
11082
10497
|
posSide: opts.posSide,
|
|
11083
10498
|
reduceOnly: opts.reduceOnly
|
|
11084
10499
|
});
|
|
11085
|
-
const data =
|
|
10500
|
+
const data = getData4(result);
|
|
11086
10501
|
if (opts.json) return printJson(data);
|
|
11087
10502
|
emitWriteResult2(data?.[0], "Trailing stop placed", "algoId");
|
|
11088
10503
|
}
|
|
11089
10504
|
async function cmdSwapAlgoCancel(run, instId, algoId, json) {
|
|
11090
10505
|
const result = await run("swap_cancel_algo_orders", { orders: [{ instId, algoId }] });
|
|
11091
|
-
const data =
|
|
10506
|
+
const data = getData4(result);
|
|
11092
10507
|
if (json) return printJson(data);
|
|
11093
10508
|
emitWriteResult2(data?.[0], "Algo order cancelled", "algoId");
|
|
11094
10509
|
}
|
|
@@ -11098,7 +10513,7 @@ async function cmdSwapAlgoOrders(run, opts) {
|
|
|
11098
10513
|
status: opts.status,
|
|
11099
10514
|
ordType: opts.ordType
|
|
11100
10515
|
});
|
|
11101
|
-
const orders =
|
|
10516
|
+
const orders = getData4(result);
|
|
11102
10517
|
if (opts.json) return printJson(orders);
|
|
11103
10518
|
if (!(orders ?? []).length) {
|
|
11104
10519
|
outputLine("No algo orders");
|
|
@@ -11119,7 +10534,7 @@ async function cmdSwapAlgoOrders(run, opts) {
|
|
|
11119
10534
|
}
|
|
11120
10535
|
async function cmdSwapFills(run, opts) {
|
|
11121
10536
|
const result = await run("swap_get_fills", { instId: opts.instId, ordId: opts.ordId, archive: opts.archive });
|
|
11122
|
-
const fills =
|
|
10537
|
+
const fills = getData4(result);
|
|
11123
10538
|
if (opts.json) return printJson(fills);
|
|
11124
10539
|
printTable(
|
|
11125
10540
|
(fills ?? []).map((f) => ({
|
|
@@ -11134,7 +10549,7 @@ async function cmdSwapFills(run, opts) {
|
|
|
11134
10549
|
}
|
|
11135
10550
|
async function cmdSwapGet(run, opts) {
|
|
11136
10551
|
const result = await run("swap_get_order", { instId: opts.instId, ordId: opts.ordId, clOrdId: opts.clOrdId });
|
|
11137
|
-
const data =
|
|
10552
|
+
const data = getData4(result);
|
|
11138
10553
|
if (opts.json) return printJson(data);
|
|
11139
10554
|
const o = data?.[0];
|
|
11140
10555
|
if (!o) {
|
|
@@ -11162,14 +10577,14 @@ async function cmdSwapClose(run, opts) {
|
|
|
11162
10577
|
posSide: opts.posSide,
|
|
11163
10578
|
autoCxl: opts.autoCxl
|
|
11164
10579
|
});
|
|
11165
|
-
const data =
|
|
10580
|
+
const data = getData4(result);
|
|
11166
10581
|
if (opts.json) return printJson(data);
|
|
11167
10582
|
const r = data?.[0];
|
|
11168
10583
|
outputLine(`Position closed: ${r?.["instId"]} ${r?.["posSide"] ?? ""}`);
|
|
11169
10584
|
}
|
|
11170
10585
|
async function cmdSwapGetLeverage(run, opts) {
|
|
11171
10586
|
const result = await run("swap_get_leverage", { instId: opts.instId, mgnMode: opts.mgnMode });
|
|
11172
|
-
const data =
|
|
10587
|
+
const data = getData4(result);
|
|
11173
10588
|
if (opts.json) return printJson(data);
|
|
11174
10589
|
printTable(
|
|
11175
10590
|
(data ?? []).map((r) => ({
|
|
@@ -11188,7 +10603,7 @@ async function cmdSwapAmend(run, opts) {
|
|
|
11188
10603
|
newSz: opts.newSz,
|
|
11189
10604
|
newPx: opts.newPx
|
|
11190
10605
|
});
|
|
11191
|
-
const data =
|
|
10606
|
+
const data = getData4(result);
|
|
11192
10607
|
if (opts.json) return printJson(data);
|
|
11193
10608
|
emitWriteResult2(data?.[0], "Order amended", "ordId");
|
|
11194
10609
|
}
|
|
@@ -11199,7 +10614,7 @@ async function cmdSwapSetLeverage(run, opts) {
|
|
|
11199
10614
|
mgnMode: opts.mgnMode,
|
|
11200
10615
|
posSide: opts.posSide
|
|
11201
10616
|
});
|
|
11202
|
-
const data =
|
|
10617
|
+
const data = getData4(result);
|
|
11203
10618
|
if (opts.json) return printJson(data);
|
|
11204
10619
|
const r = data?.[0];
|
|
11205
10620
|
outputLine(`Leverage set: ${r?.["lever"]}x ${r?.["instId"]}`);
|
|
@@ -11230,13 +10645,13 @@ async function cmdSwapBatch(run, opts) {
|
|
|
11230
10645
|
return;
|
|
11231
10646
|
}
|
|
11232
10647
|
const result = await run(tool, tool === "swap_batch_orders" ? { action: opts.action, orders: parsed } : { orders: parsed });
|
|
11233
|
-
const data =
|
|
10648
|
+
const data = getData4(result);
|
|
11234
10649
|
if (opts.json) return printJson(data);
|
|
11235
10650
|
emitBatchResults2(data ?? []);
|
|
11236
10651
|
}
|
|
11237
10652
|
|
|
11238
10653
|
// src/commands/futures.ts
|
|
11239
|
-
function
|
|
10654
|
+
function getData5(result) {
|
|
11240
10655
|
return result.data;
|
|
11241
10656
|
}
|
|
11242
10657
|
function emitWriteResult3(item, label, idKey) {
|
|
@@ -11260,7 +10675,7 @@ function emitBatchResults3(items) {
|
|
|
11260
10675
|
}
|
|
11261
10676
|
async function cmdFuturesOrders(run, opts) {
|
|
11262
10677
|
const result = await run("futures_get_orders", { instId: opts.instId, status: opts.status });
|
|
11263
|
-
const orders =
|
|
10678
|
+
const orders = getData5(result);
|
|
11264
10679
|
if (opts.json) return printJson(orders);
|
|
11265
10680
|
printTable(
|
|
11266
10681
|
(orders ?? []).map((o) => ({
|
|
@@ -11277,7 +10692,7 @@ async function cmdFuturesOrders(run, opts) {
|
|
|
11277
10692
|
}
|
|
11278
10693
|
async function cmdFuturesPositions(run, instId, json) {
|
|
11279
10694
|
const result = await run("futures_get_positions", { instId });
|
|
11280
|
-
const positions =
|
|
10695
|
+
const positions = getData5(result);
|
|
11281
10696
|
if (json) return printJson(positions);
|
|
11282
10697
|
const open = (positions ?? []).filter((p) => Number(p["pos"]) !== 0);
|
|
11283
10698
|
if (!open.length) {
|
|
@@ -11297,7 +10712,7 @@ async function cmdFuturesPositions(run, instId, json) {
|
|
|
11297
10712
|
}
|
|
11298
10713
|
async function cmdFuturesFills(run, opts) {
|
|
11299
10714
|
const result = await run("futures_get_fills", { instId: opts.instId, ordId: opts.ordId, archive: opts.archive });
|
|
11300
|
-
const fills =
|
|
10715
|
+
const fills = getData5(result);
|
|
11301
10716
|
if (opts.json) return printJson(fills);
|
|
11302
10717
|
printTable(
|
|
11303
10718
|
(fills ?? []).map((f) => ({
|
|
@@ -11326,7 +10741,7 @@ async function cmdFuturesPlace(run, opts) {
|
|
|
11326
10741
|
slTriggerPx: opts.slTriggerPx,
|
|
11327
10742
|
slOrdPx: opts.slOrdPx
|
|
11328
10743
|
});
|
|
11329
|
-
const data =
|
|
10744
|
+
const data = getData5(result);
|
|
11330
10745
|
if (opts.json) return printJson(data);
|
|
11331
10746
|
emitWriteResult3(data?.[0], "Order placed", "ordId");
|
|
11332
10747
|
}
|
|
@@ -11334,13 +10749,13 @@ async function cmdFuturesCancel(run, opts) {
|
|
|
11334
10749
|
const { instId, ordId, clOrdId, json } = opts;
|
|
11335
10750
|
if (!ordId && !clOrdId) throw new Error("Either --ordId or --clOrdId is required");
|
|
11336
10751
|
const result = await run("futures_cancel_order", { instId, ...ordId ? { ordId } : { clOrdId } });
|
|
11337
|
-
const data =
|
|
10752
|
+
const data = getData5(result);
|
|
11338
10753
|
if (json) return printJson(data);
|
|
11339
10754
|
emitWriteResult3(data?.[0], "Cancelled", "ordId");
|
|
11340
10755
|
}
|
|
11341
10756
|
async function cmdFuturesGet(run, opts) {
|
|
11342
10757
|
const result = await run("futures_get_order", { instId: opts.instId, ordId: opts.ordId });
|
|
11343
|
-
const data =
|
|
10758
|
+
const data = getData5(result);
|
|
11344
10759
|
if (opts.json) return printJson(data);
|
|
11345
10760
|
const o = data?.[0];
|
|
11346
10761
|
if (!o) {
|
|
@@ -11369,7 +10784,7 @@ async function cmdFuturesAmend(run, opts) {
|
|
|
11369
10784
|
newSz: opts.newSz,
|
|
11370
10785
|
newPx: opts.newPx
|
|
11371
10786
|
});
|
|
11372
|
-
const data =
|
|
10787
|
+
const data = getData5(result);
|
|
11373
10788
|
if (opts.json) return printJson(data);
|
|
11374
10789
|
emitWriteResult3(data?.[0], "Order amended", "ordId");
|
|
11375
10790
|
}
|
|
@@ -11380,7 +10795,7 @@ async function cmdFuturesClose(run, opts) {
|
|
|
11380
10795
|
posSide: opts.posSide,
|
|
11381
10796
|
autoCxl: opts.autoCxl
|
|
11382
10797
|
});
|
|
11383
|
-
const data =
|
|
10798
|
+
const data = getData5(result);
|
|
11384
10799
|
if (opts.json) return printJson(data);
|
|
11385
10800
|
const r = data?.[0];
|
|
11386
10801
|
outputLine(`Position closed: ${r?.["instId"]} ${r?.["posSide"] ?? ""}`);
|
|
@@ -11392,14 +10807,14 @@ async function cmdFuturesSetLeverage(run, opts) {
|
|
|
11392
10807
|
mgnMode: opts.mgnMode,
|
|
11393
10808
|
posSide: opts.posSide
|
|
11394
10809
|
});
|
|
11395
|
-
const data =
|
|
10810
|
+
const data = getData5(result);
|
|
11396
10811
|
if (opts.json) return printJson(data);
|
|
11397
10812
|
const r = data?.[0];
|
|
11398
10813
|
outputLine(`Leverage set: ${r?.["lever"]}x ${r?.["instId"]}`);
|
|
11399
10814
|
}
|
|
11400
10815
|
async function cmdFuturesGetLeverage(run, opts) {
|
|
11401
10816
|
const result = await run("futures_get_leverage", { instId: opts.instId, mgnMode: opts.mgnMode });
|
|
11402
|
-
const data =
|
|
10817
|
+
const data = getData5(result);
|
|
11403
10818
|
if (opts.json) return printJson(data);
|
|
11404
10819
|
printTable(
|
|
11405
10820
|
(data ?? []).map((r) => ({
|
|
@@ -11436,7 +10851,7 @@ async function cmdFuturesBatch(run, opts) {
|
|
|
11436
10851
|
return;
|
|
11437
10852
|
}
|
|
11438
10853
|
const result = await run(tool, { orders: parsed });
|
|
11439
|
-
const data =
|
|
10854
|
+
const data = getData5(result);
|
|
11440
10855
|
if (opts.json) return printJson(data);
|
|
11441
10856
|
emitBatchResults3(data ?? []);
|
|
11442
10857
|
}
|
|
@@ -11458,7 +10873,7 @@ async function cmdFuturesAlgoPlace(run, opts) {
|
|
|
11458
10873
|
callbackSpread: opts.callbackSpread,
|
|
11459
10874
|
activePx: opts.activePx
|
|
11460
10875
|
});
|
|
11461
|
-
const data =
|
|
10876
|
+
const data = getData5(result);
|
|
11462
10877
|
if (opts.json) return printJson(data);
|
|
11463
10878
|
emitWriteResult3(data?.[0], "Algo order placed", "algoId");
|
|
11464
10879
|
}
|
|
@@ -11474,7 +10889,7 @@ async function cmdFuturesAlgoTrailPlace(run, opts) {
|
|
|
11474
10889
|
posSide: opts.posSide,
|
|
11475
10890
|
reduceOnly: opts.reduceOnly
|
|
11476
10891
|
});
|
|
11477
|
-
const data =
|
|
10892
|
+
const data = getData5(result);
|
|
11478
10893
|
if (opts.json) return printJson(data);
|
|
11479
10894
|
emitWriteResult3(data?.[0], "Trailing stop placed", "algoId");
|
|
11480
10895
|
}
|
|
@@ -11488,13 +10903,13 @@ async function cmdFuturesAlgoAmend(run, opts) {
|
|
|
11488
10903
|
newSlTriggerPx: opts.newSlTriggerPx,
|
|
11489
10904
|
newSlOrdPx: opts.newSlOrdPx
|
|
11490
10905
|
});
|
|
11491
|
-
const data =
|
|
10906
|
+
const data = getData5(result);
|
|
11492
10907
|
if (opts.json) return printJson(data);
|
|
11493
10908
|
emitWriteResult3(data?.[0], "Algo order amended", "algoId");
|
|
11494
10909
|
}
|
|
11495
10910
|
async function cmdFuturesAlgoCancel(run, instId, algoId, json) {
|
|
11496
10911
|
const result = await run("futures_cancel_algo_orders", { orders: [{ instId, algoId }] });
|
|
11497
|
-
const data =
|
|
10912
|
+
const data = getData5(result);
|
|
11498
10913
|
if (json) return printJson(data);
|
|
11499
10914
|
emitWriteResult3(data?.[0], "Algo order cancelled", "algoId");
|
|
11500
10915
|
}
|
|
@@ -11504,7 +10919,7 @@ async function cmdFuturesAlgoOrders(run, opts) {
|
|
|
11504
10919
|
status: opts.status,
|
|
11505
10920
|
ordType: opts.ordType
|
|
11506
10921
|
});
|
|
11507
|
-
const orders =
|
|
10922
|
+
const orders = getData5(result);
|
|
11508
10923
|
if (opts.json) return printJson(orders);
|
|
11509
10924
|
if (!(orders ?? []).length) {
|
|
11510
10925
|
outputLine("No algo orders");
|
|
@@ -11525,7 +10940,7 @@ async function cmdFuturesAlgoOrders(run, opts) {
|
|
|
11525
10940
|
}
|
|
11526
10941
|
|
|
11527
10942
|
// src/commands/option.ts
|
|
11528
|
-
function
|
|
10943
|
+
function getData6(result) {
|
|
11529
10944
|
return result.data;
|
|
11530
10945
|
}
|
|
11531
10946
|
function emitWriteResult4(item, label, idKey) {
|
|
@@ -11553,7 +10968,7 @@ async function cmdOptionOrders(run, opts) {
|
|
|
11553
10968
|
uly: opts.uly,
|
|
11554
10969
|
status: opts.status
|
|
11555
10970
|
});
|
|
11556
|
-
const orders =
|
|
10971
|
+
const orders = getData6(result);
|
|
11557
10972
|
if (opts.json) return printJson(orders);
|
|
11558
10973
|
printTable(
|
|
11559
10974
|
(orders ?? []).map((o) => ({
|
|
@@ -11573,7 +10988,7 @@ async function cmdOptionGet(run, opts) {
|
|
|
11573
10988
|
ordId: opts.ordId,
|
|
11574
10989
|
clOrdId: opts.clOrdId
|
|
11575
10990
|
});
|
|
11576
|
-
const data =
|
|
10991
|
+
const data = getData6(result);
|
|
11577
10992
|
if (opts.json) return printJson(data);
|
|
11578
10993
|
const o = data?.[0];
|
|
11579
10994
|
if (!o) {
|
|
@@ -11598,7 +11013,7 @@ async function cmdOptionPositions(run, opts) {
|
|
|
11598
11013
|
instId: opts.instId,
|
|
11599
11014
|
uly: opts.uly
|
|
11600
11015
|
});
|
|
11601
|
-
const positions =
|
|
11016
|
+
const positions = getData6(result);
|
|
11602
11017
|
if (opts.json) return printJson(positions);
|
|
11603
11018
|
const open = (positions ?? []).filter((p) => Number(p["pos"]) !== 0);
|
|
11604
11019
|
if (!open.length) {
|
|
@@ -11625,7 +11040,7 @@ async function cmdOptionFills(run, opts) {
|
|
|
11625
11040
|
ordId: opts.ordId,
|
|
11626
11041
|
archive: opts.archive
|
|
11627
11042
|
});
|
|
11628
|
-
const fills =
|
|
11043
|
+
const fills = getData6(result);
|
|
11629
11044
|
if (opts.json) return printJson(fills);
|
|
11630
11045
|
printTable(
|
|
11631
11046
|
(fills ?? []).map((f) => ({
|
|
@@ -11643,7 +11058,7 @@ async function cmdOptionInstruments(run, opts) {
|
|
|
11643
11058
|
uly: opts.uly,
|
|
11644
11059
|
expTime: opts.expTime
|
|
11645
11060
|
});
|
|
11646
|
-
const instruments =
|
|
11061
|
+
const instruments = getData6(result);
|
|
11647
11062
|
if (opts.json) return printJson(instruments);
|
|
11648
11063
|
printTable(
|
|
11649
11064
|
(instruments ?? []).map((i) => ({
|
|
@@ -11661,7 +11076,7 @@ async function cmdOptionGreeks(run, opts) {
|
|
|
11661
11076
|
uly: opts.uly,
|
|
11662
11077
|
expTime: opts.expTime
|
|
11663
11078
|
});
|
|
11664
|
-
const greeks =
|
|
11079
|
+
const greeks = getData6(result);
|
|
11665
11080
|
if (opts.json) return printJson(greeks);
|
|
11666
11081
|
printTable(
|
|
11667
11082
|
(greeks ?? []).map((g) => ({
|
|
@@ -11690,7 +11105,7 @@ async function cmdOptionPlace(run, opts) {
|
|
|
11690
11105
|
slTriggerPx: opts.slTriggerPx,
|
|
11691
11106
|
slOrdPx: opts.slOrdPx
|
|
11692
11107
|
});
|
|
11693
|
-
const data =
|
|
11108
|
+
const data = getData6(result);
|
|
11694
11109
|
if (opts.json) return printJson(data);
|
|
11695
11110
|
emitWriteResult4(data?.[0], "Order placed", "ordId");
|
|
11696
11111
|
}
|
|
@@ -11700,7 +11115,7 @@ async function cmdOptionCancel(run, opts) {
|
|
|
11700
11115
|
ordId: opts.ordId,
|
|
11701
11116
|
clOrdId: opts.clOrdId
|
|
11702
11117
|
});
|
|
11703
|
-
const data =
|
|
11118
|
+
const data = getData6(result);
|
|
11704
11119
|
if (opts.json) return printJson(data);
|
|
11705
11120
|
emitWriteResult4(data?.[0], "Cancelled", "ordId");
|
|
11706
11121
|
}
|
|
@@ -11712,7 +11127,7 @@ async function cmdOptionAmend(run, opts) {
|
|
|
11712
11127
|
newSz: opts.newSz,
|
|
11713
11128
|
newPx: opts.newPx
|
|
11714
11129
|
});
|
|
11715
|
-
const data =
|
|
11130
|
+
const data = getData6(result);
|
|
11716
11131
|
if (opts.json) return printJson(data);
|
|
11717
11132
|
emitWriteResult4(data?.[0], "Amended", "ordId");
|
|
11718
11133
|
}
|
|
@@ -11731,7 +11146,7 @@ async function cmdOptionBatchCancel(run, opts) {
|
|
|
11731
11146
|
return;
|
|
11732
11147
|
}
|
|
11733
11148
|
const result = await run("option_batch_cancel", { orders: parsed });
|
|
11734
|
-
const data =
|
|
11149
|
+
const data = getData6(result);
|
|
11735
11150
|
if (opts.json) return printJson(data);
|
|
11736
11151
|
emitBatchResults4(data ?? []);
|
|
11737
11152
|
}
|
|
@@ -11750,7 +11165,7 @@ async function cmdOptionAlgoPlace(run, opts) {
|
|
|
11750
11165
|
reduceOnly: opts.reduceOnly,
|
|
11751
11166
|
clOrdId: opts.clOrdId
|
|
11752
11167
|
});
|
|
11753
|
-
const data =
|
|
11168
|
+
const data = getData6(result);
|
|
11754
11169
|
if (opts.json) return printJson(data);
|
|
11755
11170
|
emitWriteResult4(data?.[0], "Algo order placed", "algoId");
|
|
11756
11171
|
}
|
|
@@ -11764,13 +11179,13 @@ async function cmdOptionAlgoAmend(run, opts) {
|
|
|
11764
11179
|
newSlTriggerPx: opts.newSlTriggerPx,
|
|
11765
11180
|
newSlOrdPx: opts.newSlOrdPx
|
|
11766
11181
|
});
|
|
11767
|
-
const data =
|
|
11182
|
+
const data = getData6(result);
|
|
11768
11183
|
if (opts.json) return printJson(data);
|
|
11769
11184
|
emitWriteResult4(data?.[0], "Algo order amended", "algoId");
|
|
11770
11185
|
}
|
|
11771
11186
|
async function cmdOptionAlgoCancel(run, opts) {
|
|
11772
11187
|
const result = await run("option_cancel_algo_orders", { orders: [{ instId: opts.instId, algoId: opts.algoId }] });
|
|
11773
|
-
const data =
|
|
11188
|
+
const data = getData6(result);
|
|
11774
11189
|
if (opts.json) return printJson(data);
|
|
11775
11190
|
emitWriteResult4(data?.[0], "Algo order cancelled", "algoId");
|
|
11776
11191
|
}
|
|
@@ -11780,7 +11195,7 @@ async function cmdOptionAlgoOrders(run, opts) {
|
|
|
11780
11195
|
status: opts.status,
|
|
11781
11196
|
ordType: opts.ordType
|
|
11782
11197
|
});
|
|
11783
|
-
const orders =
|
|
11198
|
+
const orders = getData6(result);
|
|
11784
11199
|
if (opts.json) return printJson(orders);
|
|
11785
11200
|
if (!(orders ?? []).length) {
|
|
11786
11201
|
outputLine("No algo orders");
|
|
@@ -12299,7 +11714,7 @@ function emitWriteResult5(item, label, idKey) {
|
|
|
12299
11714
|
outputLine(`${label}: ${item?.[idKey]} (OK)`);
|
|
12300
11715
|
}
|
|
12301
11716
|
}
|
|
12302
|
-
function
|
|
11717
|
+
function getData7(result) {
|
|
12303
11718
|
return result.data;
|
|
12304
11719
|
}
|
|
12305
11720
|
async function cmdGridOrders(run, opts) {
|
|
@@ -12309,7 +11724,7 @@ async function cmdGridOrders(run, opts) {
|
|
|
12309
11724
|
algoId: opts.algoId,
|
|
12310
11725
|
status: opts.status
|
|
12311
11726
|
});
|
|
12312
|
-
const orders =
|
|
11727
|
+
const orders = getData7(result) ?? [];
|
|
12313
11728
|
if (opts.json) return printJson(orders);
|
|
12314
11729
|
if (!orders.length) {
|
|
12315
11730
|
outputLine("No grid bots");
|
|
@@ -12334,7 +11749,7 @@ async function cmdGridDetails(run, opts) {
|
|
|
12334
11749
|
algoOrdType: opts.algoOrdType,
|
|
12335
11750
|
algoId: opts.algoId
|
|
12336
11751
|
});
|
|
12337
|
-
const detail = (
|
|
11752
|
+
const detail = (getData7(result) ?? [])[0];
|
|
12338
11753
|
if (!detail) {
|
|
12339
11754
|
outputLine("Bot not found");
|
|
12340
11755
|
return;
|
|
@@ -12362,7 +11777,7 @@ async function cmdGridSubOrders(run, opts) {
|
|
|
12362
11777
|
algoId: opts.algoId,
|
|
12363
11778
|
type: opts.type
|
|
12364
11779
|
});
|
|
12365
|
-
const orders =
|
|
11780
|
+
const orders = getData7(result) ?? [];
|
|
12366
11781
|
if (opts.json) return printJson(orders);
|
|
12367
11782
|
if (!orders.length) {
|
|
12368
11783
|
outputLine("No sub-orders");
|
|
@@ -12401,7 +11816,7 @@ async function cmdGridCreate(run, opts) {
|
|
|
12401
11816
|
slRatio: opts.slRatio,
|
|
12402
11817
|
algoClOrdId: opts.algoClOrdId
|
|
12403
11818
|
});
|
|
12404
|
-
const data =
|
|
11819
|
+
const data = getData7(result);
|
|
12405
11820
|
if (opts.json) return printJson(data);
|
|
12406
11821
|
emitWriteResult5(data?.[0], "Grid bot created", "algoId");
|
|
12407
11822
|
}
|
|
@@ -12412,7 +11827,7 @@ async function cmdGridStop(run, opts) {
|
|
|
12412
11827
|
instId: opts.instId,
|
|
12413
11828
|
stopType: opts.stopType
|
|
12414
11829
|
});
|
|
12415
|
-
const data =
|
|
11830
|
+
const data = getData7(result);
|
|
12416
11831
|
if (opts.json) return printJson(data);
|
|
12417
11832
|
emitWriteResult5(data?.[0], "Grid bot stopped", "algoId");
|
|
12418
11833
|
}
|
|
@@ -12442,7 +11857,7 @@ async function cmdDcaCreate(run, opts) {
|
|
|
12442
11857
|
reserveFunds: opts.reserveFunds,
|
|
12443
11858
|
tradeQuoteCcy: opts.tradeQuoteCcy
|
|
12444
11859
|
});
|
|
12445
|
-
const data =
|
|
11860
|
+
const data = getData7(result);
|
|
12446
11861
|
if (opts.json) return printJson(data);
|
|
12447
11862
|
emitWriteResult5(data?.[0], "DCA bot created", "algoId");
|
|
12448
11863
|
}
|
|
@@ -12452,7 +11867,7 @@ async function cmdDcaStop(run, opts) {
|
|
|
12452
11867
|
algoOrdType: opts.algoOrdType,
|
|
12453
11868
|
stopType: opts.stopType
|
|
12454
11869
|
});
|
|
12455
|
-
const data =
|
|
11870
|
+
const data = getData7(result);
|
|
12456
11871
|
if (opts.json) return printJson(data);
|
|
12457
11872
|
emitWriteResult5(data?.[0], "DCA bot stopped", "algoId");
|
|
12458
11873
|
}
|
|
@@ -12463,7 +11878,7 @@ async function cmdDcaOrders(run, opts) {
|
|
|
12463
11878
|
algoId: opts.algoId,
|
|
12464
11879
|
instId: opts.instId
|
|
12465
11880
|
});
|
|
12466
|
-
const orders =
|
|
11881
|
+
const orders = getData7(result) ?? [];
|
|
12467
11882
|
if (opts.json) return printJson(orders);
|
|
12468
11883
|
if (!orders.length) {
|
|
12469
11884
|
outputLine("No DCA bots");
|
|
@@ -12486,7 +11901,7 @@ async function cmdDcaDetails(run, opts) {
|
|
|
12486
11901
|
algoId: opts.algoId,
|
|
12487
11902
|
algoOrdType: opts.algoOrdType
|
|
12488
11903
|
});
|
|
12489
|
-
const detail = (
|
|
11904
|
+
const detail = (getData7(result) ?? [])[0];
|
|
12490
11905
|
if (!detail) {
|
|
12491
11906
|
outputLine("DCA bot not found");
|
|
12492
11907
|
return;
|
|
@@ -12515,7 +11930,7 @@ async function cmdDcaSubOrders(run, opts) {
|
|
|
12515
11930
|
algoOrdType: opts.algoOrdType,
|
|
12516
11931
|
cycleId: opts.cycleId
|
|
12517
11932
|
});
|
|
12518
|
-
const rows =
|
|
11933
|
+
const rows = getData7(result) ?? [];
|
|
12519
11934
|
if (opts.json) return printJson(rows);
|
|
12520
11935
|
if (!rows.length) {
|
|
12521
11936
|
outputLine("No sub-orders");
|
|
@@ -13031,7 +12446,7 @@ function cmdSkillList(json) {
|
|
|
13031
12446
|
// src/index.ts
|
|
13032
12447
|
var _require3 = createRequire3(import.meta.url);
|
|
13033
12448
|
var CLI_VERSION2 = _require3("../package.json").version;
|
|
13034
|
-
var GIT_HASH2 = true ? "
|
|
12449
|
+
var GIT_HASH2 = true ? "e46af2f" : "dev";
|
|
13035
12450
|
function handleConfigCommand(action, rest, json, lang, force) {
|
|
13036
12451
|
if (action === "init") return cmdConfigInit(lang === "zh" ? "zh" : "en");
|
|
13037
12452
|
if (action === "show") return cmdConfigShow(json);
|
|
@@ -13797,36 +13212,6 @@ function handleEarnDcdCommand(run, action, v, json) {
|
|
|
13797
13212
|
errorLine("Valid: pairs, products, quote-and-buy, redeem-execute, order, orders");
|
|
13798
13213
|
process.exitCode = 1;
|
|
13799
13214
|
}
|
|
13800
|
-
function handleNewsCommand(run, action, rest, v, json) {
|
|
13801
|
-
const limit = v.limit !== void 0 ? Number(v.limit) : void 0;
|
|
13802
|
-
const begin = v.begin !== void 0 ? Number(v.begin) : void 0;
|
|
13803
|
-
const end = v.end !== void 0 ? Number(v.end) : void 0;
|
|
13804
|
-
const language = v.lang;
|
|
13805
|
-
const detailLvl = v["detail-lvl"];
|
|
13806
|
-
const after = v.after;
|
|
13807
|
-
const period = v.period;
|
|
13808
|
-
const points = v.points !== void 0 ? Number(v.points) : 24;
|
|
13809
|
-
const sortBy = v["sort-by"];
|
|
13810
|
-
const searchOpts = { coins: v.coins, importance: v.importance, sentiment: v.sentiment, sortBy, begin, end, language, detailLvl, limit, after, json };
|
|
13811
|
-
const listOpts = { coins: v.coins, importance: v.importance, begin, end, language, detailLvl, limit, after, json };
|
|
13812
|
-
const dispatch = {
|
|
13813
|
-
latest: () => cmdNewsLatest(run, listOpts),
|
|
13814
|
-
important: () => cmdNewsImportant(run, { coins: v.coins, begin, end, language, detailLvl, limit, json }),
|
|
13815
|
-
"by-coin": () => cmdNewsByCoin(run, v.coins ?? rest[0], { importance: v.importance, begin, end, language, detailLvl, limit, json }),
|
|
13816
|
-
search: () => cmdNewsSearch(run, v.keyword ?? rest[0], searchOpts),
|
|
13817
|
-
detail: () => cmdNewsDetail(run, rest[0], { language, json }),
|
|
13818
|
-
domains: () => cmdNewsDomains(run, { json }),
|
|
13819
|
-
"coin-sentiment": () => cmdNewsCoinSentiment(run, v.coins ?? rest[0], { period, json }),
|
|
13820
|
-
"coin-trend": () => cmdNewsCoinTrend(run, rest[0], { period, points, json }),
|
|
13821
|
-
"by-sentiment": () => cmdNewsSearch(run, "", { ...searchOpts, sentiment: v.sentiment ?? rest[0], sortBy: sortBy ?? "latest" }),
|
|
13822
|
-
"sentiment-rank": () => cmdNewsSentimentRank(run, { period, sortBy, limit, json })
|
|
13823
|
-
};
|
|
13824
|
-
const handler = dispatch[action];
|
|
13825
|
-
if (handler) return handler();
|
|
13826
|
-
process.stderr.write(`Unknown news command: ${action}
|
|
13827
|
-
`);
|
|
13828
|
-
process.exitCode = 1;
|
|
13829
|
-
}
|
|
13830
13215
|
function requireSkillName(rest, usage) {
|
|
13831
13216
|
const name = rest[0];
|
|
13832
13217
|
if (!name) {
|
|
@@ -13923,7 +13308,6 @@ async function main() {
|
|
|
13923
13308
|
swap: () => handleSwapCommand(run, action, rest, v, json),
|
|
13924
13309
|
futures: () => handleFuturesCommand(run, action, rest, v, json),
|
|
13925
13310
|
option: () => handleOptionCommand(run, action, rest, v, json),
|
|
13926
|
-
news: () => handleNewsCommand(run, action, rest, v, json),
|
|
13927
13311
|
bot: () => handleBotCommand(run, action, rest, v, json),
|
|
13928
13312
|
earn: () => handleEarnCommand(run, action, rest, v, json),
|
|
13929
13313
|
skill: () => handleSkillCommand(run, action, rest, v, json, config)
|
|
@@ -13953,7 +13337,6 @@ export {
|
|
|
13953
13337
|
handleMarketCommand,
|
|
13954
13338
|
handleMarketDataCommand,
|
|
13955
13339
|
handleMarketPublicCommand,
|
|
13956
|
-
handleNewsCommand,
|
|
13957
13340
|
handleOptionAlgoCommand,
|
|
13958
13341
|
handleOptionCommand,
|
|
13959
13342
|
handleSetupCommand,
|