@okx_ai/okx-trade-cli 1.1.6 → 1.1.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 CHANGED
@@ -1232,7 +1232,7 @@ var MODULES = [
1232
1232
  "account",
1233
1233
  ...BOT_SUB_MODULE_IDS
1234
1234
  ];
1235
- var DEFAULT_MODULES = ["spot", "swap", "account", ...BOT_DEFAULT_SUB_MODULES];
1235
+ var DEFAULT_MODULES = ["spot", "swap", "option", "account", ...BOT_DEFAULT_SUB_MODULES];
1236
1236
  function asRecord(value) {
1237
1237
  if (!value || typeof value !== "object" || Array.isArray(value)) {
1238
1238
  return {};
@@ -5541,7 +5541,7 @@ function parseModuleList(rawModules) {
5541
5541
  }
5542
5542
  const trimmed = rawModules.trim().toLowerCase();
5543
5543
  if (trimmed === "all") {
5544
- return [...BASE_MODULES, ...BOT_DEFAULT_SUB_MODULES];
5544
+ return [...BASE_MODULES, ...BOT_SUB_MODULE_IDS];
5545
5545
  }
5546
5546
  const requested = trimmed.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
5547
5547
  if (requested.length === 0) {
@@ -5871,128 +5871,526 @@ function cmdSetupClients() {
5871
5871
  }
5872
5872
 
5873
5873
  // src/help.ts
5874
- function printHelp() {
5875
- process.stdout.write(`
5876
- Usage: okx [--profile <name>] [--json] <command> [args]
5877
-
5878
- Global Options:
5879
- --profile <name> Use a named profile from ${configFilePath()}
5880
- --demo Use simulated trading (demo) mode
5881
- --json Output raw JSON
5882
- --version, -v Show version
5883
- --help Show this help
5884
-
5885
- Commands:
5886
- market ticker <instId>
5887
- market tickers <instType> (SPOT|SWAP|FUTURES|OPTION)
5888
- market orderbook <instId> [--sz <n>]
5889
- market candles <instId> [--bar <bar>] [--limit <n>]
5890
- market instruments --instType <type> [--instId <id>]
5891
- market funding-rate <instId> [--history] [--limit <n>]
5892
- market mark-price --instType <MARGIN|SWAP|FUTURES|OPTION> [--instId <id>]
5893
- market trades <instId> [--limit <n>]
5894
- market index-ticker [--instId <id>] [--quoteCcy <ccy>]
5895
- market index-candles <instId> [--bar <bar>] [--limit <n>] [--history]
5896
- market price-limit <instId>
5897
- market open-interest --instType <SWAP|FUTURES|OPTION> [--instId <id>]
5898
-
5899
- account balance [<ccy>]
5900
- account asset-balance [--ccy <ccy>]
5901
- account positions [--instType <type>] [--instId <id>]
5902
- account positions-history [--instType <type>] [--instId <id>] [--limit <n>]
5903
- account bills [--instType <type>] [--ccy <ccy>] [--limit <n>] [--archive]
5904
- account fees --instType <type> [--instId <id>]
5905
- account config
5906
- account set-position-mode --posMode <long_short_mode|net_mode>
5907
- account max-size --instId <id> --tdMode <cross|isolated> [--px <price>]
5908
- account max-avail-size --instId <id> --tdMode <cross|isolated|cash>
5909
- account max-withdrawal [--ccy <ccy>]
5910
- account transfer --ccy <ccy> --amt <n> --from <acct> --to <acct> [--transferType <0|1|2|3>]
5911
- account audit [--tool <name>] [--since <ISO-date>] [--limit <n>]
5912
-
5913
- spot orders [--instId <id>] [--history]
5914
- spot get --instId <id> --ordId <id>
5915
- spot fills [--instId <id>] [--ordId <id>]
5916
- spot place --instId <id> --side <buy|sell> --ordType <type> --sz <n> [--px <price>] [--tdMode <cash|cross|isolated>]
5917
- spot amend --instId <id> --ordId <id> [--newSz <n>] [--newPx <price>]
5918
- spot cancel <instId> --ordId <id>
5919
- spot algo orders [--instId <id>] [--history] [--ordType <conditional|oco>]
5920
- spot algo place --instId <id> --side <buy|sell> --sz <n> [--ordType <conditional|oco>]
5921
- [--tpTriggerPx <price>] [--tpOrdPx <price|-1>]
5922
- [--slTriggerPx <price>] [--slOrdPx <price|-1>] [--tdMode <cash|cross|isolated>]
5923
- spot algo amend --instId <id> --algoId <id> [--newSz <n>]
5924
- [--newTpTriggerPx <price>] [--newTpOrdPx <price|-1>]
5925
- [--newSlTriggerPx <price>] [--newSlOrdPx <price|-1>]
5926
- spot algo cancel --instId <id> --algoId <id>
5927
- spot batch --action <place|amend|cancel> --orders '<json>'
5928
-
5929
- swap positions [<instId>]
5930
- swap orders [--instId <id>] [--history] [--archive]
5931
- swap get --instId <id> --ordId <id>
5932
- swap fills [--instId <id>] [--ordId <id>] [--archive]
5933
- swap place --instId <id> --side <buy|sell> --ordType <type> --sz <n> [--posSide <side>] [--px <price>] [--tdMode <cross|isolated>]
5934
- swap cancel <instId> --ordId <id>
5935
- swap amend --instId <id> --ordId <id> [--newSz <n>] [--newPx <price>]
5936
- swap close --instId <id> --mgnMode <cross|isolated> [--posSide <net|long|short>] [--autoCxl]
5937
- swap leverage --instId <id> --lever <n> --mgnMode <cross|isolated> [--posSide <side>]
5938
- swap get-leverage --instId <id> --mgnMode <cross|isolated>
5939
- swap algo orders [--instId <id>] [--history] [--ordType <conditional|oco>]
5940
- swap algo trail --instId <id> --side <buy|sell> --sz <n> --callbackRatio <ratio>
5941
- [--activePx <price>] [--posSide <net|long|short>] [--tdMode <cross|isolated>] [--reduceOnly]
5942
- swap algo place --instId <id> --side <buy|sell> --sz <n> [--ordType <conditional|oco>]
5943
- [--tpTriggerPx <price>] [--tpOrdPx <price|-1>]
5944
- [--slTriggerPx <price>] [--slOrdPx <price|-1>]
5945
- [--posSide <net|long|short>] [--tdMode <cross|isolated>] [--reduceOnly]
5946
- swap algo amend --instId <id> --algoId <id> [--newSz <n>]
5947
- [--newTpTriggerPx <price>] [--newTpOrdPx <price|-1>]
5948
- [--newSlTriggerPx <price>] [--newSlOrdPx <price|-1>]
5949
- swap algo cancel --instId <id> --algoId <id>
5950
- swap batch --action <place|amend|cancel> --orders '<json>'
5951
-
5952
- futures orders [--instId <id>] [--history] [--archive]
5953
- futures positions [--instId <id>]
5954
- futures fills [--instId <id>] [--ordId <id>] [--archive]
5955
- futures place --instId <id> --side <buy|sell> --ordType <type> --sz <n> [--tdMode <cross|isolated>]
5956
- [--posSide <net|long|short>] [--px <price>] [--reduceOnly]
5957
- futures cancel <instId> --ordId <id>
5958
- futures get --instId <id> --ordId <id>
5959
-
5960
- option orders [--instId <id>] [--uly <uly>] [--history] [--archive]
5961
- option get --instId <id> [--ordId <id>] [--clOrdId <id>]
5962
- option positions [--instId <id>] [--uly <uly>]
5963
- option fills [--instId <id>] [--ordId <id>] [--archive]
5964
- option instruments --uly <uly> [--expTime <date>]
5965
- option greeks --uly <uly> [--expTime <date>]
5966
- option place --instId <id> --tdMode <cash|cross|isolated> --side <buy|sell> --ordType <type> --sz <n> [--px <price>] [--reduceOnly] [--clOrdId <id>]
5967
- option cancel --instId <id> [--ordId <id>] [--clOrdId <id>]
5968
- option amend --instId <id> [--ordId <id>] [--clOrdId <id>] [--newSz <n>] [--newPx <price>]
5969
- option batch-cancel --orders '<json>'
5970
-
5971
- bot grid orders --algoOrdType <grid|contract_grid|moon_grid> [--instId <id>] [--algoId <id>] [--history]
5972
- bot grid details --algoOrdType <type> --algoId <id>
5973
- bot grid sub-orders --algoOrdType <type> --algoId <id> [--live]
5974
- bot grid create --instId <id> --algoOrdType <grid|contract_grid> --maxPx <px> --minPx <px> --gridNum <n>
5975
- [--runType <1|2>] [--quoteSz <n>] [--baseSz <n>]
5976
- [--direction <long|short|neutral>] [--lever <n>] [--sz <n>]
5977
- bot grid stop --algoId <id> --algoOrdType <type> --instId <id> [--stopType <1|2|3|5|6>]
5978
-
5979
- bot dca orders [--type <spot|contract>] [--history]
5980
- bot dca details [--type <spot|contract>] --algoId <id>
5981
- bot dca sub-orders [--type <spot|contract>] --algoId <id> [--live] [--cycleId <id>]
5982
- bot dca create --instId <id> --initOrdAmt <n> --safetyOrdAmt <n> --maxSafetyOrds <n>
5983
- --pxSteps <n> --pxStepsMult <n> --volMult <n> --tpPct <n> [--slPct <n>]
5984
- [--type <spot|contract>] [--triggerType <1|2>] [--lever <n>] [--side <buy|sell>]
5985
- bot dca stop [--type <spot|contract>] --algoId <id> --instId <id> [--stopType <1|2>]
5986
-
5987
- config init [--lang zh]
5988
- config show
5989
- config set <key> <value>
5990
- config setup-clients
5991
-
5992
- setup --client <client> [--profile <name>] [--modules <list>]
5993
-
5994
- Clients: ${SUPPORTED_CLIENTS.join(", ")}
5874
+ var HELP_TREE = {
5875
+ market: {
5876
+ description: "Market data (ticker, orderbook, candles, trades)",
5877
+ commands: {
5878
+ ticker: {
5879
+ usage: "okx market ticker <instId>",
5880
+ description: "Get latest ticker data for an instrument"
5881
+ },
5882
+ tickers: {
5883
+ usage: "okx market tickers <instType>",
5884
+ description: "Get all tickers for an instrument type (SPOT|SWAP|FUTURES|OPTION)"
5885
+ },
5886
+ orderbook: {
5887
+ usage: "okx market orderbook <instId> [--sz <n>]",
5888
+ description: "Get order book depth for an instrument"
5889
+ },
5890
+ candles: {
5891
+ usage: "okx market candles <instId> [--bar <bar>] [--limit <n>]",
5892
+ description: "Get candlestick (OHLCV) data"
5893
+ },
5894
+ instruments: {
5895
+ usage: "okx market instruments --instType <type> [--instId <id>]",
5896
+ description: "List tradable instruments of a given type"
5897
+ },
5898
+ "funding-rate": {
5899
+ usage: "okx market funding-rate <instId> [--history] [--limit <n>]",
5900
+ description: "Get current or historical funding rate for perpetual swaps"
5901
+ },
5902
+ "mark-price": {
5903
+ usage: "okx market mark-price --instType <MARGIN|SWAP|FUTURES|OPTION> [--instId <id>]",
5904
+ description: "Get mark price for instruments"
5905
+ },
5906
+ trades: {
5907
+ usage: "okx market trades <instId> [--limit <n>]",
5908
+ description: "Get recent trades for an instrument"
5909
+ },
5910
+ "index-ticker": {
5911
+ usage: "okx market index-ticker [--instId <id>] [--quoteCcy <ccy>]",
5912
+ description: "Get index ticker data"
5913
+ },
5914
+ "index-candles": {
5915
+ usage: "okx market index-candles <instId> [--bar <bar>] [--limit <n>] [--history]",
5916
+ description: "Get index candlestick data"
5917
+ },
5918
+ "price-limit": {
5919
+ usage: "okx market price-limit <instId>",
5920
+ description: "Get price limit for an instrument"
5921
+ },
5922
+ "open-interest": {
5923
+ usage: "okx market open-interest --instType <SWAP|FUTURES|OPTION> [--instId <id>]",
5924
+ description: "Get open interest for instruments"
5925
+ }
5926
+ }
5927
+ },
5928
+ account: {
5929
+ description: "Account balance, positions, bills, and configuration",
5930
+ commands: {
5931
+ balance: {
5932
+ usage: "okx account balance [<ccy>]",
5933
+ description: "Get trading account balance"
5934
+ },
5935
+ "asset-balance": {
5936
+ usage: "okx account asset-balance [--ccy <ccy>]",
5937
+ description: "Get funding account asset balance"
5938
+ },
5939
+ positions: {
5940
+ usage: "okx account positions [--instType <type>] [--instId <id>]",
5941
+ description: "Get current open positions"
5942
+ },
5943
+ "positions-history": {
5944
+ usage: "okx account positions-history [--instType <type>] [--instId <id>] [--limit <n>]",
5945
+ description: "Get historical positions"
5946
+ },
5947
+ bills: {
5948
+ usage: "okx account bills [--instType <type>] [--ccy <ccy>] [--limit <n>] [--archive]",
5949
+ description: "Get account bill history"
5950
+ },
5951
+ fees: {
5952
+ usage: "okx account fees --instType <type> [--instId <id>]",
5953
+ description: "Get trading fee rates"
5954
+ },
5955
+ config: {
5956
+ usage: "okx account config",
5957
+ description: "Get account configuration"
5958
+ },
5959
+ "set-position-mode": {
5960
+ usage: "okx account set-position-mode --posMode <long_short_mode|net_mode>",
5961
+ description: "Set position mode (long/short or net)"
5962
+ },
5963
+ "max-size": {
5964
+ usage: "okx account max-size --instId <id> --tdMode <cross|isolated> [--px <price>]",
5965
+ description: "Get maximum order size for an instrument"
5966
+ },
5967
+ "max-avail-size": {
5968
+ usage: "okx account max-avail-size --instId <id> --tdMode <cross|isolated|cash>",
5969
+ description: "Get maximum available tradable amount"
5970
+ },
5971
+ "max-withdrawal": {
5972
+ usage: "okx account max-withdrawal [--ccy <ccy>]",
5973
+ description: "Get maximum withdrawable amount"
5974
+ },
5975
+ transfer: {
5976
+ usage: "okx account transfer --ccy <ccy> --amt <n> --from <acct> --to <acct> [--transferType <0|1|2|3>]",
5977
+ description: "Transfer funds between accounts"
5978
+ },
5979
+ audit: {
5980
+ usage: "okx account audit [--tool <name>] [--since <ISO-date>] [--limit <n>]",
5981
+ description: "Audit account activity and tool call history"
5982
+ }
5983
+ }
5984
+ },
5985
+ spot: {
5986
+ description: "Spot trading (orders, algo orders)",
5987
+ commands: {
5988
+ orders: {
5989
+ usage: "okx spot orders [--instId <id>] [--history]",
5990
+ description: "List open or historical spot orders"
5991
+ },
5992
+ get: {
5993
+ usage: "okx spot get --instId <id> --ordId <id>",
5994
+ description: "Get details of a specific spot order"
5995
+ },
5996
+ fills: {
5997
+ usage: "okx spot fills [--instId <id>] [--ordId <id>]",
5998
+ description: "Get trade fill history for spot orders"
5999
+ },
6000
+ place: {
6001
+ usage: "okx spot place --instId <id> --side <buy|sell> --ordType <type> --sz <n> [--px <price>] [--tdMode <cash|cross|isolated>]",
6002
+ description: "Place a new spot order"
6003
+ },
6004
+ amend: {
6005
+ usage: "okx spot amend --instId <id> --ordId <id> [--newSz <n>] [--newPx <price>]",
6006
+ description: "Amend a pending spot order"
6007
+ },
6008
+ cancel: {
6009
+ usage: "okx spot cancel <instId> --ordId <id>",
6010
+ description: "Cancel a pending spot order"
6011
+ },
6012
+ batch: {
6013
+ usage: "okx spot batch --action <place|amend|cancel> --orders '<json>'",
6014
+ description: "Batch place, amend, or cancel spot orders"
6015
+ }
6016
+ },
6017
+ subgroups: {
6018
+ algo: {
6019
+ description: "Spot algo orders (conditional, OCO, take-profit/stop-loss)",
6020
+ commands: {
6021
+ orders: {
6022
+ usage: "okx spot algo orders [--instId <id>] [--history] [--ordType <conditional|oco>]",
6023
+ description: "List spot algo orders"
6024
+ },
6025
+ place: {
6026
+ usage: "okx spot algo place --instId <id> --side <buy|sell> --sz <n> [--ordType <conditional|oco>]\n [--tpTriggerPx <price>] [--tpOrdPx <price|-1>]\n [--slTriggerPx <price>] [--slOrdPx <price|-1>] [--tdMode <cash|cross|isolated>]",
6027
+ description: "Place a spot algo order (take-profit/stop-loss)"
6028
+ },
6029
+ amend: {
6030
+ usage: "okx spot algo amend --instId <id> --algoId <id> [--newSz <n>]\n [--newTpTriggerPx <price>] [--newTpOrdPx <price|-1>]\n [--newSlTriggerPx <price>] [--newSlOrdPx <price|-1>]",
6031
+ description: "Amend a pending spot algo order"
6032
+ },
6033
+ cancel: {
6034
+ usage: "okx spot algo cancel --instId <id> --algoId <id>",
6035
+ description: "Cancel a pending spot algo order"
6036
+ }
6037
+ }
6038
+ }
6039
+ }
6040
+ },
6041
+ swap: {
6042
+ description: "Perpetual swap trading (orders, algo orders)",
6043
+ commands: {
6044
+ positions: {
6045
+ usage: "okx swap positions [<instId>]",
6046
+ description: "Get current perpetual swap positions"
6047
+ },
6048
+ orders: {
6049
+ usage: "okx swap orders [--instId <id>] [--history] [--archive]",
6050
+ description: "List open or historical swap orders"
6051
+ },
6052
+ get: {
6053
+ usage: "okx swap get --instId <id> --ordId <id>",
6054
+ description: "Get details of a specific swap order"
6055
+ },
6056
+ fills: {
6057
+ usage: "okx swap fills [--instId <id>] [--ordId <id>] [--archive]",
6058
+ description: "Get trade fill history for swap orders"
6059
+ },
6060
+ place: {
6061
+ usage: "okx swap place --instId <id> --side <buy|sell> --ordType <type> --sz <n> [--posSide <side>] [--px <price>] [--tdMode <cross|isolated>]",
6062
+ description: "Place a new perpetual swap order"
6063
+ },
6064
+ cancel: {
6065
+ usage: "okx swap cancel <instId> --ordId <id>",
6066
+ description: "Cancel a pending swap order"
6067
+ },
6068
+ amend: {
6069
+ usage: "okx swap amend --instId <id> --ordId <id> [--newSz <n>] [--newPx <price>]",
6070
+ description: "Amend a pending swap order"
6071
+ },
6072
+ close: {
6073
+ usage: "okx swap close --instId <id> --mgnMode <cross|isolated> [--posSide <net|long|short>] [--autoCxl]",
6074
+ description: "Close a swap position"
6075
+ },
6076
+ leverage: {
6077
+ usage: "okx swap leverage --instId <id> --lever <n> --mgnMode <cross|isolated> [--posSide <side>]",
6078
+ description: "Set leverage for a swap instrument"
6079
+ },
6080
+ "get-leverage": {
6081
+ usage: "okx swap get-leverage --instId <id> --mgnMode <cross|isolated>",
6082
+ description: "Get current leverage setting for a swap instrument"
6083
+ },
6084
+ batch: {
6085
+ usage: "okx swap batch --action <place|amend|cancel> --orders '<json>'",
6086
+ description: "Batch place, amend, or cancel swap orders"
6087
+ }
6088
+ },
6089
+ subgroups: {
6090
+ algo: {
6091
+ description: "Perpetual swap algo orders (trailing stop, conditional, OCO)",
6092
+ commands: {
6093
+ orders: {
6094
+ usage: "okx swap algo orders [--instId <id>] [--history] [--ordType <conditional|oco>]",
6095
+ description: "List swap algo orders"
6096
+ },
6097
+ trail: {
6098
+ usage: "okx swap algo trail --instId <id> --side <buy|sell> --sz <n> --callbackRatio <ratio>\n [--activePx <price>] [--posSide <net|long|short>] [--tdMode <cross|isolated>] [--reduceOnly]",
6099
+ description: "Place a trailing stop algo order for perpetual swap"
6100
+ },
6101
+ place: {
6102
+ usage: "okx swap algo place --instId <id> --side <buy|sell> --sz <n> [--ordType <conditional|oco>]\n [--tpTriggerPx <price>] [--tpOrdPx <price|-1>]\n [--slTriggerPx <price>] [--slOrdPx <price|-1>]\n [--posSide <net|long|short>] [--tdMode <cross|isolated>] [--reduceOnly]",
6103
+ description: "Place a swap algo order (take-profit/stop-loss)"
6104
+ },
6105
+ amend: {
6106
+ usage: "okx swap algo amend --instId <id> --algoId <id> [--newSz <n>]\n [--newTpTriggerPx <price>] [--newTpOrdPx <price|-1>]\n [--newSlTriggerPx <price>] [--newSlOrdPx <price|-1>]",
6107
+ description: "Amend a pending swap algo order"
6108
+ },
6109
+ cancel: {
6110
+ usage: "okx swap algo cancel --instId <id> --algoId <id>",
6111
+ description: "Cancel a pending swap algo order"
6112
+ }
6113
+ }
6114
+ }
6115
+ }
6116
+ },
6117
+ futures: {
6118
+ description: "Futures trading (orders, positions)",
6119
+ commands: {
6120
+ orders: {
6121
+ usage: "okx futures orders [--instId <id>] [--history] [--archive]",
6122
+ description: "List open or historical futures orders"
6123
+ },
6124
+ positions: {
6125
+ usage: "okx futures positions [--instId <id>]",
6126
+ description: "Get current futures positions"
6127
+ },
6128
+ fills: {
6129
+ usage: "okx futures fills [--instId <id>] [--ordId <id>] [--archive]",
6130
+ description: "Get trade fill history for futures orders"
6131
+ },
6132
+ place: {
6133
+ usage: "okx futures place --instId <id> --side <buy|sell> --ordType <type> --sz <n>\n [--tdMode <cross|isolated>] [--posSide <net|long|short>] [--px <price>] [--reduceOnly]",
6134
+ description: "Place a new futures order"
6135
+ },
6136
+ cancel: {
6137
+ usage: "okx futures cancel <instId> --ordId <id>",
6138
+ description: "Cancel a pending futures order"
6139
+ },
6140
+ get: {
6141
+ usage: "okx futures get --instId <id> --ordId <id>",
6142
+ description: "Get details of a specific futures order"
6143
+ }
6144
+ }
6145
+ },
6146
+ option: {
6147
+ description: "Options trading (orders, positions, greeks)",
6148
+ commands: {
6149
+ orders: {
6150
+ usage: "okx option orders [--instId <id>] [--uly <uly>] [--history] [--archive]",
6151
+ description: "List open or historical option orders"
6152
+ },
6153
+ get: {
6154
+ usage: "okx option get --instId <id> [--ordId <id>] [--clOrdId <id>]",
6155
+ description: "Get details of a specific option order"
6156
+ },
6157
+ positions: {
6158
+ usage: "okx option positions [--instId <id>] [--uly <uly>]",
6159
+ description: "Get current option positions"
6160
+ },
6161
+ fills: {
6162
+ usage: "okx option fills [--instId <id>] [--ordId <id>] [--archive]",
6163
+ description: "Get trade fill history for option orders"
6164
+ },
6165
+ instruments: {
6166
+ usage: "okx option instruments --uly <uly> [--expTime <date>]",
6167
+ description: "List tradable option instruments for an underlying"
6168
+ },
6169
+ greeks: {
6170
+ usage: "okx option greeks --uly <uly> [--expTime <date>]",
6171
+ description: "Get option greeks (delta, gamma, theta, vega)"
6172
+ },
6173
+ place: {
6174
+ usage: "okx option place --instId <id> --tdMode <cash|cross|isolated> --side <buy|sell> --ordType <type> --sz <n>\n [--px <price>] [--reduceOnly] [--clOrdId <id>]",
6175
+ description: "Place a new option order"
6176
+ },
6177
+ cancel: {
6178
+ usage: "okx option cancel --instId <id> [--ordId <id>] [--clOrdId <id>]",
6179
+ description: "Cancel a pending option order"
6180
+ },
6181
+ amend: {
6182
+ usage: "okx option amend --instId <id> [--ordId <id>] [--clOrdId <id>] [--newSz <n>] [--newPx <price>]",
6183
+ description: "Amend a pending option order"
6184
+ },
6185
+ "batch-cancel": {
6186
+ usage: "okx option batch-cancel --orders '<json>'",
6187
+ description: "Batch cancel option orders"
6188
+ }
6189
+ }
6190
+ },
6191
+ bot: {
6192
+ description: "Trading bot strategies (grid, dca)",
6193
+ subgroups: {
6194
+ grid: {
6195
+ description: "Grid trading bot \u2014 create, monitor, and stop grid orders",
6196
+ commands: {
6197
+ orders: {
6198
+ usage: "okx bot grid orders --algoOrdType <grid|contract_grid|moon_grid> [--instId <id>] [--algoId <id>] [--history]",
6199
+ description: "List active or historical grid bot orders"
6200
+ },
6201
+ details: {
6202
+ usage: "okx bot grid details --algoOrdType <type> --algoId <id>",
6203
+ description: "Get details of a specific grid bot order"
6204
+ },
6205
+ "sub-orders": {
6206
+ usage: "okx bot grid sub-orders --algoOrdType <type> --algoId <id> [--live]",
6207
+ description: "List sub-orders of a grid bot (filled or live)"
6208
+ },
6209
+ create: {
6210
+ usage: "okx bot grid create --instId <id> --algoOrdType <grid|contract_grid> --maxPx <px> --minPx <px> --gridNum <n>\n [--runType <1|2>] [--quoteSz <n>] [--baseSz <n>]\n [--direction <long|short|neutral>] [--lever <n>] [--sz <n>]",
6211
+ description: "Create a new grid bot order"
6212
+ },
6213
+ stop: {
6214
+ usage: "okx bot grid stop --algoId <id> --algoOrdType <type> --instId <id> [--stopType <1|2|3|5|6>]",
6215
+ description: "Stop a running grid bot order"
6216
+ }
6217
+ }
6218
+ },
6219
+ dca: {
6220
+ description: "DCA (Dollar Cost Averaging) bot \u2014 automated recurring buys",
6221
+ commands: {
6222
+ orders: {
6223
+ usage: "okx bot dca orders [--type <spot|contract>] [--history]",
6224
+ description: "List active or historical DCA bot orders"
6225
+ },
6226
+ details: {
6227
+ usage: "okx bot dca details [--type <spot|contract>] --algoId <id>",
6228
+ description: "Get details of a specific DCA bot order"
6229
+ },
6230
+ "sub-orders": {
6231
+ usage: "okx bot dca sub-orders [--type <spot|contract>] --algoId <id> [--live] [--cycleId <id>]",
6232
+ description: "List sub-orders of a DCA bot"
6233
+ },
6234
+ create: {
6235
+ usage: "okx bot dca create --instId <id> --initOrdAmt <n> --safetyOrdAmt <n> --maxSafetyOrds <n>\n --pxSteps <n> --pxStepsMult <n> --volMult <n> --tpPct <n> [--slPct <n>]\n [--type <spot|contract>] [--triggerType <1|2>] [--lever <n>] [--side <buy|sell>]\n [--reserveFunds <true|false>]",
6236
+ description: "Create a new DCA bot order"
6237
+ },
6238
+ stop: {
6239
+ usage: "okx bot dca stop [--type <spot|contract>] --algoId <id> --instId <id> [--stopType <1|2>]",
6240
+ description: "Stop a running DCA bot order"
6241
+ }
6242
+ }
6243
+ }
6244
+ }
6245
+ },
6246
+ config: {
6247
+ description: "Manage CLI configuration profiles",
6248
+ commands: {
6249
+ init: {
6250
+ usage: "okx config init [--lang zh]",
6251
+ description: "Initialize a new configuration profile interactively"
6252
+ },
6253
+ show: {
6254
+ usage: "okx config show",
6255
+ description: `Show current configuration (file: ${configFilePath()})`
6256
+ },
6257
+ set: {
6258
+ usage: "okx config set <key> <value>",
6259
+ description: "Set a configuration value"
6260
+ },
6261
+ "setup-clients": {
6262
+ usage: "okx config setup-clients",
6263
+ description: "Set up MCP client integrations (Cursor, Windsurf, etc.)"
6264
+ }
6265
+ }
6266
+ },
6267
+ setup: {
6268
+ description: "Set up client integrations (Cursor, Windsurf, Claude, etc.)",
6269
+ usage: `okx setup --client <${SUPPORTED_CLIENTS.join("|")}> [--profile <name>] [--modules <list>]`
6270
+ }
6271
+ };
6272
+ function printGlobalHelp() {
6273
+ const lines = [
6274
+ "",
6275
+ `Usage: okx [--profile <name>] [--demo] [--json] <module> <action> [args...]`,
6276
+ "",
6277
+ "Global Options:",
6278
+ ` --profile <name> Use a named profile from ${configFilePath()}`,
6279
+ " --demo Use simulated trading (demo) mode",
6280
+ " --json Output raw JSON",
6281
+ " --version, -v Show version",
6282
+ " --help Show this help",
6283
+ "",
6284
+ "Modules:"
6285
+ ];
6286
+ const colWidth = 12;
6287
+ for (const [name, group] of Object.entries(HELP_TREE)) {
6288
+ lines.push(` ${name.padEnd(colWidth)}${group.description}`);
6289
+ }
6290
+ lines.push("", 'Run "okx <module> --help" for module details.', "");
6291
+ process.stdout.write(lines.join("\n"));
6292
+ }
6293
+ function printModuleHelp(moduleName) {
6294
+ const group = HELP_TREE[moduleName];
6295
+ if (!group) {
6296
+ process.stderr.write(`Unknown module: ${moduleName}
6297
+ `);
6298
+ process.exitCode = 1;
6299
+ return;
6300
+ }
6301
+ const hasSubgroups = group.subgroups && Object.keys(group.subgroups).length > 0;
6302
+ const hasCommands = group.commands && Object.keys(group.commands).length > 0;
6303
+ const lines = [""];
6304
+ if (hasSubgroups && !hasCommands) {
6305
+ const subgroupNames = Object.keys(group.subgroups);
6306
+ lines.push(`Usage: okx ${moduleName} <strategy> <action> [args...]`);
6307
+ lines.push("", `${group.description}.`, "");
6308
+ lines.push("Strategies:");
6309
+ const colWidth = Math.max(...subgroupNames.map((n) => n.length)) + 4;
6310
+ for (const [sgName, sg] of Object.entries(group.subgroups)) {
6311
+ lines.push(` ${sgName.padEnd(colWidth)}${sg.description}`);
6312
+ }
6313
+ lines.push("", `Run "okx ${moduleName} <strategy> --help" for details.`);
6314
+ } else if (hasSubgroups && hasCommands) {
6315
+ lines.push(`Usage: okx ${moduleName} <action> [args...]`);
6316
+ lines.push("", `${group.description}.`, "", "Commands:");
6317
+ printCommandList(lines, group.commands);
6318
+ lines.push("", "Subgroups:");
6319
+ const subgroupEntries = Object.entries(group.subgroups);
6320
+ const colWidth = Math.max(...subgroupEntries.map(([n]) => n.length)) + 4;
6321
+ for (const [sgName, sg] of subgroupEntries) {
6322
+ lines.push(` ${sgName.padEnd(colWidth)}${sg.description}`);
6323
+ }
6324
+ lines.push("", `Run "okx ${moduleName} <subgroup> --help" for subgroup details.`);
6325
+ } else if (hasCommands) {
6326
+ lines.push(`Usage: okx ${moduleName} <action> [args...]`);
6327
+ lines.push("", `${group.description}.`, "", "Commands:");
6328
+ printCommandList(lines, group.commands);
6329
+ } else if (group.usage) {
6330
+ lines.push(`Usage: ${group.usage}`);
6331
+ lines.push("", `${group.description}.`);
6332
+ if (group.commands) {
6333
+ lines.push("");
6334
+ for (const cmd of Object.values(group.commands)) {
6335
+ lines.push(` ${cmd.description}`);
6336
+ lines.push(` Usage: ${cmd.usage}`);
6337
+ }
6338
+ }
6339
+ }
6340
+ lines.push("");
6341
+ process.stdout.write(lines.join("\n"));
6342
+ }
6343
+ function printSubgroupHelp(moduleName, subgroupName) {
6344
+ const group = HELP_TREE[moduleName];
6345
+ if (!group) {
6346
+ process.stderr.write(`Unknown module: ${moduleName}
6347
+ `);
6348
+ process.exitCode = 1;
6349
+ return;
6350
+ }
6351
+ const subgroup = group.subgroups?.[subgroupName];
6352
+ if (!subgroup) {
6353
+ process.stderr.write(`Unknown subgroup: ${moduleName} ${subgroupName}
5995
6354
  `);
6355
+ process.exitCode = 1;
6356
+ return;
6357
+ }
6358
+ const lines = [
6359
+ "",
6360
+ `Usage: okx ${moduleName} ${subgroupName} <action> [args...]`,
6361
+ "",
6362
+ `${subgroup.description}.`,
6363
+ "",
6364
+ "Commands:"
6365
+ ];
6366
+ if (subgroup.commands) {
6367
+ printCommandList(lines, subgroup.commands);
6368
+ }
6369
+ lines.push("");
6370
+ process.stdout.write(lines.join("\n"));
6371
+ }
6372
+ function printCommandList(lines, commands) {
6373
+ const names = Object.keys(commands);
6374
+ const colWidth = Math.max(...names.map((n) => n.length)) + 4;
6375
+ for (const [name, cmd] of Object.entries(commands)) {
6376
+ lines.push(` ${name.padEnd(colWidth)}${cmd.description}`);
6377
+ const usageLines = cmd.usage.split("\n");
6378
+ lines.push(` ${" ".repeat(colWidth)}Usage: ${usageLines[0]}`);
6379
+ for (const extra of usageLines.slice(1)) {
6380
+ lines.push(` ${" ".repeat(colWidth)} ${extra.trimStart()}`);
6381
+ }
6382
+ lines.push("");
6383
+ }
6384
+ }
6385
+ function printHelp(...path4) {
6386
+ const [moduleName, subgroupName] = path4;
6387
+ if (!moduleName) {
6388
+ printGlobalHelp();
6389
+ } else if (!subgroupName) {
6390
+ printModuleHelp(moduleName);
6391
+ } else {
6392
+ printSubgroupHelp(moduleName, subgroupName);
6393
+ }
5996
6394
  }
5997
6395
 
5998
6396
  // src/parser.ts
@@ -7853,6 +8251,7 @@ async function cmdDcaSubOrders(run, opts) {
7853
8251
  // src/index.ts
7854
8252
  var _require = createRequire(import.meta.url);
7855
8253
  var CLI_VERSION = _require("../package.json").version;
8254
+ var GIT_HASH = true ? "b0b33d7" : "dev";
7856
8255
  function handleConfigCommand(action, rest, json, lang) {
7857
8256
  if (action === "init") return cmdConfigInit(lang === "zh" ? "zh" : "en");
7858
8257
  if (action === "show") return cmdConfigShow(json);
@@ -8303,12 +8702,19 @@ async function main() {
8303
8702
  checkForUpdates("@okx_ai/okx-trade-cli", CLI_VERSION);
8304
8703
  const { values, positionals } = parseCli(process.argv.slice(2));
8305
8704
  if (values.version) {
8306
- process.stdout.write(`${CLI_VERSION}
8705
+ process.stdout.write(`${CLI_VERSION} (${GIT_HASH})
8307
8706
  `);
8308
8707
  return;
8309
8708
  }
8310
8709
  if (values.help || positionals.length === 0) {
8311
- printHelp();
8710
+ const [module2, subgroup] = positionals;
8711
+ if (!module2) {
8712
+ printHelp();
8713
+ } else if (!subgroup) {
8714
+ printHelp(module2);
8715
+ } else {
8716
+ printHelp(module2, subgroup);
8717
+ }
8312
8718
  return;
8313
8719
  }
8314
8720
  const [module, action, ...rest] = positionals;