ccxt 4.4.77 → 4.4.80

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.
Files changed (154) hide show
  1. package/README.md +8 -10
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +8 -4
  4. package/dist/cjs/src/abstract/ace.js +1 -1
  5. package/dist/cjs/src/abstract/apex.js +9 -0
  6. package/dist/cjs/src/ace.js +1 -1
  7. package/dist/cjs/src/apex.js +1949 -0
  8. package/dist/cjs/src/ascendex.js +25 -4
  9. package/dist/cjs/src/base/Exchange.js +42 -2
  10. package/dist/cjs/src/binance.js +9 -1
  11. package/dist/cjs/src/bingx.js +3 -3
  12. package/dist/cjs/src/bitfinex.js +64 -36
  13. package/dist/cjs/src/bitget.js +191 -138
  14. package/dist/cjs/src/bitmart.js +7 -2
  15. package/dist/cjs/src/bitmex.js +16 -8
  16. package/dist/cjs/src/bitopro.js +5 -1
  17. package/dist/cjs/src/bitrue.js +2 -1
  18. package/dist/cjs/src/bitso.js +1 -1
  19. package/dist/cjs/src/bitteam.js +2 -0
  20. package/dist/cjs/src/bitvavo.js +28 -10
  21. package/dist/cjs/src/btcalpha.js +1 -1
  22. package/dist/cjs/src/btcmarkets.js +1 -1
  23. package/dist/cjs/src/btcturk.js +1 -1
  24. package/dist/cjs/src/bybit.js +32 -16
  25. package/dist/cjs/src/cex.js +1 -1
  26. package/dist/cjs/src/coinbase.js +18 -2
  27. package/dist/cjs/src/coincatch.js +68 -0
  28. package/dist/cjs/src/coinex.js +1 -0
  29. package/dist/cjs/src/coinlist.js +1 -0
  30. package/dist/cjs/src/coinone.js +1 -0
  31. package/dist/cjs/src/delta.js +4 -0
  32. package/dist/cjs/src/deribit.js +1 -0
  33. package/dist/cjs/src/hitbtc.js +3 -0
  34. package/dist/cjs/src/hollaex.js +1 -0
  35. package/dist/cjs/src/htx.js +7 -3
  36. package/dist/cjs/src/huobijp.js +1 -0
  37. package/dist/cjs/src/hyperliquid.js +14 -4
  38. package/dist/cjs/src/kraken.js +2 -0
  39. package/dist/cjs/src/mexc.js +50 -57
  40. package/dist/cjs/src/okx.js +1 -1
  41. package/dist/cjs/src/phemex.js +2 -1
  42. package/dist/cjs/src/poloniex.js +2 -1
  43. package/dist/cjs/src/pro/apex.js +1043 -0
  44. package/dist/cjs/src/pro/binance.js +3 -3
  45. package/dist/cjs/src/pro/coinbase.js +45 -68
  46. package/dist/cjs/src/pro/gate.js +27 -2
  47. package/dist/cjs/src/pro/hollaex.js +2 -2
  48. package/dist/cjs/src/pro/p2b.js +2 -2
  49. package/dist/cjs/src/pro/tradeogre.js +283 -0
  50. package/dist/cjs/src/pro/upbit.js +43 -0
  51. package/dist/cjs/src/probit.js +1 -0
  52. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2639 -0
  53. package/dist/cjs/src/timex.js +2 -2
  54. package/dist/cjs/src/tradeogre.js +2 -1
  55. package/dist/cjs/src/upbit.js +277 -67
  56. package/dist/cjs/src/whitebit.js +66 -12
  57. package/dist/cjs/src/woo.js +3 -1
  58. package/dist/cjs/src/xt.js +9 -0
  59. package/js/ccxt.d.ts +11 -5
  60. package/js/ccxt.js +8 -4
  61. package/js/src/abstract/apex.d.ts +34 -0
  62. package/js/src/abstract/bitmart.d.ts +1 -0
  63. package/js/src/apex.d.ts +333 -0
  64. package/js/src/apex.js +1945 -0
  65. package/js/src/ascendex.d.ts +3 -3
  66. package/js/src/ascendex.js +25 -4
  67. package/js/src/base/Exchange.d.ts +2 -0
  68. package/js/src/base/Exchange.js +42 -1
  69. package/js/src/binance.d.ts +7 -7
  70. package/js/src/binance.js +9 -1
  71. package/js/src/bingx.js +3 -3
  72. package/js/src/bitfinex.d.ts +3 -3
  73. package/js/src/bitfinex.js +64 -36
  74. package/js/src/bitflyer.d.ts +2 -2
  75. package/js/src/bitget.d.ts +2 -0
  76. package/js/src/bitget.js +191 -138
  77. package/js/src/bitmart.d.ts +5 -4
  78. package/js/src/bitmart.js +7 -2
  79. package/js/src/bitmex.d.ts +3 -3
  80. package/js/src/bitmex.js +16 -8
  81. package/js/src/bitopro.js +5 -1
  82. package/js/src/bitrue.js +2 -1
  83. package/js/src/bitso.js +1 -1
  84. package/js/src/bitteam.js +2 -0
  85. package/js/src/bitvavo.js +28 -10
  86. package/js/src/btcalpha.js +1 -1
  87. package/js/src/btcmarkets.js +1 -1
  88. package/js/src/btcturk.js +1 -1
  89. package/js/src/bybit.js +32 -16
  90. package/js/src/cex.js +1 -1
  91. package/js/src/coinbase.d.ts +4 -4
  92. package/js/src/coinbase.js +18 -2
  93. package/js/src/coinbaseexchange.d.ts +1 -1
  94. package/js/src/coincatch.d.ts +11 -0
  95. package/js/src/coincatch.js +68 -0
  96. package/js/src/coinex.js +1 -0
  97. package/js/src/coinlist.js +1 -0
  98. package/js/src/coinone.js +1 -0
  99. package/js/src/cryptocom.d.ts +4 -4
  100. package/js/src/delta.js +4 -0
  101. package/js/src/deribit.d.ts +4 -4
  102. package/js/src/deribit.js +1 -0
  103. package/js/src/derive.d.ts +3 -3
  104. package/js/src/digifinex.d.ts +4 -4
  105. package/js/src/hitbtc.js +3 -0
  106. package/js/src/hollaex.js +1 -0
  107. package/js/src/htx.d.ts +4 -4
  108. package/js/src/htx.js +7 -3
  109. package/js/src/huobijp.js +1 -0
  110. package/js/src/hyperliquid.d.ts +1 -0
  111. package/js/src/hyperliquid.js +14 -4
  112. package/js/src/kraken.d.ts +3 -3
  113. package/js/src/kraken.js +2 -0
  114. package/js/src/krakenfutures.d.ts +2 -2
  115. package/js/src/kucoinfutures.d.ts +5 -5
  116. package/js/src/mexc.d.ts +1 -0
  117. package/js/src/mexc.js +50 -57
  118. package/js/src/okx.js +1 -1
  119. package/js/src/oxfun.d.ts +3 -3
  120. package/js/src/phemex.d.ts +3 -3
  121. package/js/src/phemex.js +2 -1
  122. package/js/src/poloniex.d.ts +3 -3
  123. package/js/src/poloniex.js +2 -1
  124. package/js/src/pro/apex.d.ts +160 -0
  125. package/js/src/pro/apex.js +1038 -0
  126. package/js/src/pro/binance.js +3 -3
  127. package/js/src/pro/coinbase.d.ts +4 -3
  128. package/js/src/pro/coinbase.js +45 -66
  129. package/js/src/pro/gate.js +27 -2
  130. package/js/src/pro/hollaex.js +2 -2
  131. package/js/src/pro/p2b.js +2 -2
  132. package/js/src/pro/tradeogre.d.ts +49 -0
  133. package/js/src/pro/tradeogre.js +278 -0
  134. package/js/src/pro/upbit.d.ts +16 -1
  135. package/js/src/pro/upbit.js +43 -0
  136. package/js/src/probit.js +1 -0
  137. package/js/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  138. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +4276 -0
  139. package/js/src/timex.js +2 -2
  140. package/js/src/tradeogre.js +2 -1
  141. package/js/src/upbit.d.ts +75 -23
  142. package/js/src/upbit.js +277 -67
  143. package/js/src/vertex.d.ts +3 -3
  144. package/js/src/whitebit.js +66 -12
  145. package/js/src/woo.d.ts +4 -4
  146. package/js/src/woo.js +3 -1
  147. package/js/src/woofipro.d.ts +4 -4
  148. package/js/src/xt.d.ts +4 -4
  149. package/js/src/xt.js +9 -0
  150. package/package.json +2 -2
  151. package/js/src/abstract/ace.d.ts +0 -18
  152. package/js/src/ace.d.ts +0 -158
  153. package/js/src/ace.js +0 -1175
  154. /package/js/src/abstract/{ace.js → apex.js} +0 -0
@@ -1553,7 +1553,7 @@ class timex extends timex$1 {
1553
1553
  'currency': feeCurrency,
1554
1554
  };
1555
1555
  }
1556
- return {
1556
+ return this.safeTrade({
1557
1557
  'info': trade,
1558
1558
  'id': id,
1559
1559
  'timestamp': timestamp,
@@ -1567,7 +1567,7 @@ class timex extends timex$1 {
1567
1567
  'cost': cost,
1568
1568
  'takerOrMaker': takerOrMaker,
1569
1569
  'fee': fee,
1570
- };
1570
+ });
1571
1571
  }
1572
1572
  parseOHLCV(ohlcv, market = undefined) {
1573
1573
  //
@@ -18,7 +18,7 @@ class tradeogre extends tradeogre$1 {
18
18
  'countries': [],
19
19
  'rateLimit': 100,
20
20
  'version': 'v2',
21
- 'pro': false,
21
+ 'pro': true,
22
22
  'has': {
23
23
  'CORS': undefined,
24
24
  'spot': true,
@@ -529,6 +529,7 @@ class tradeogre extends tradeogre$1 {
529
529
  'asks': rawAsks,
530
530
  };
531
531
  const orderbook = this.parseOrderBook(rawOrderbook, symbol);
532
+ orderbook['nonce'] = this.safeInteger(response, 's');
532
533
  return orderbook;
533
534
  }
534
535
  parseBidsAsks(bidasks, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
@@ -38,6 +38,7 @@ class upbit extends upbit$1 {
38
38
  'createMarketOrderWithCost': false,
39
39
  'createMarketSellOrderWithCost': false,
40
40
  'createOrder': true,
41
+ 'editOrder': true,
41
42
  'fetchBalance': true,
42
43
  'fetchCanceledOrders': true,
43
44
  'fetchClosedOrders': true,
@@ -68,7 +69,7 @@ class upbit extends upbit$1 {
68
69
  'fetchTickers': true,
69
70
  'fetchTrades': true,
70
71
  'fetchTradingFee': true,
71
- 'fetchTradingFees': false,
72
+ 'fetchTradingFees': true,
72
73
  'fetchTransactions': false,
73
74
  'fetchWithdrawal': true,
74
75
  'fetchWithdrawals': true,
@@ -268,8 +269,6 @@ class upbit extends upbit$1 {
268
269
  },
269
270
  'options': {
270
271
  'createMarketBuyOrderRequiresPrice': true,
271
- 'fetchTickersMaxLength': 4096,
272
- 'fetchOrderBooksMaxLength': 4096,
273
272
  'tradingFeesByQuoteCurrency': {
274
273
  'KRW': 0.0005,
275
274
  },
@@ -491,7 +490,8 @@ class upbit extends upbit$1 {
491
490
  /**
492
491
  * @method
493
492
  * @name upbit#fetchMarkets
494
- * @see https://docs.upbit.com/reference/%EB%A7%88%EC%BC%93-%EC%BD%94%EB%93%9C-%EC%A1%B0%ED%9A%8C
493
+ * @see https://docs.upbit.com/kr/reference/마켓-코드-조회
494
+ * @see https://global-docs.upbit.com/reference/listing-market-list
495
495
  * @description retrieves data on all markets for upbit
496
496
  * @param {object} [params] extra parameters specific to the exchange API endpoint
497
497
  * @returns {object[]} an array of objects representing market data
@@ -587,7 +587,8 @@ class upbit extends upbit$1 {
587
587
  /**
588
588
  * @method
589
589
  * @name upbit#fetchBalance
590
- * @see https://docs.upbit.com/reference/%EC%A0%84%EC%B2%B4-%EA%B3%84%EC%A2%8C-%EC%A1%B0%ED%9A%8C
590
+ * @see https://docs.upbit.com/kr/reference/전체-계좌-조회
591
+ * @see https://global-docs.upbit.com/reference/overall-account-inquiry
591
592
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
592
593
  * @param {object} [params] extra parameters specific to the exchange API endpoint
593
594
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
@@ -612,7 +613,8 @@ class upbit extends upbit$1 {
612
613
  /**
613
614
  * @method
614
615
  * @name upbit#fetchOrderBooks
615
- * @see https://docs.upbit.com/reference/%ED%98%B8%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C
616
+ * @see https://docs.upbit.com/kr/reference/호가-정보-조회
617
+ * @see https://global-docs.upbit.com/reference/order-book-list
616
618
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
617
619
  * @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
618
620
  * @param {int} [limit] not used by upbit fetchOrderBooks ()
@@ -624,11 +626,6 @@ class upbit extends upbit$1 {
624
626
  let ids = undefined;
625
627
  if (symbols === undefined) {
626
628
  ids = this.ids.join(',');
627
- // max URL length is 2083 symbols, including http schema, hostname, tld, etc...
628
- if (ids.length > this.options['fetchOrderBooksMaxLength']) {
629
- const numIds = this.ids.length;
630
- throw new errors.ExchangeError(this.id + ' fetchOrderBooks() has ' + numIds.toString() + ' symbols (' + ids.length.toString() + ' characters) exceeding max URL length (' + this.options['fetchOrderBooksMaxLength'].toString() + ' characters), you are required to specify a list of symbols in the first argument to fetchOrderBooks');
631
- }
632
629
  }
633
630
  else {
634
631
  ids = this.marketIds(symbols);
@@ -686,7 +683,8 @@ class upbit extends upbit$1 {
686
683
  /**
687
684
  * @method
688
685
  * @name upbit#fetchOrderBook
689
- * @see https://docs.upbit.com/reference/%ED%98%B8%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C
686
+ * @see https://docs.upbit.com/kr/reference/호가-정보-조회
687
+ * @see https://global-docs.upbit.com/reference/order-book-list
690
688
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
691
689
  * @param {string} symbol unified symbol of the market to fetch the order book for
692
690
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -756,7 +754,8 @@ class upbit extends upbit$1 {
756
754
  /**
757
755
  * @method
758
756
  * @name upbit#fetchTickers
759
- * @see https://docs.upbit.com/reference/ticker%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4
757
+ * @see https://docs.upbit.com/kr/reference/ticker현재가-정보
758
+ * @see https://global-docs.upbit.com/reference/tickers
760
759
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
761
760
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
762
761
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -768,11 +767,6 @@ class upbit extends upbit$1 {
768
767
  let ids = undefined;
769
768
  if (symbols === undefined) {
770
769
  ids = this.ids.join(',');
771
- // max URL length is 2083 symbols, including http schema, hostname, tld, etc...
772
- if (ids.length > this.options['fetchTickersMaxLength']) {
773
- const numIds = this.ids.length;
774
- throw new errors.ExchangeError(this.id + ' fetchTickers() has ' + numIds.toString() + ' symbols exceeding max URL length, you are required to specify a list of symbols in the first argument to fetchTickers');
775
- }
776
770
  }
777
771
  else {
778
772
  ids = this.marketIds(symbols);
@@ -821,7 +815,8 @@ class upbit extends upbit$1 {
821
815
  /**
822
816
  * @method
823
817
  * @name upbit#fetchTicker
824
- * @see https://docs.upbit.com/reference/ticker%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4
818
+ * @see https://docs.upbit.com/kr/reference/ticker현재가-정보
819
+ * @see https://global-docs.upbit.com/reference/tickers
825
820
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
826
821
  * @param {string} symbol unified symbol of the market to fetch the ticker for
827
822
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -906,7 +901,8 @@ class upbit extends upbit$1 {
906
901
  /**
907
902
  * @method
908
903
  * @name upbit#fetchTrades
909
- * @see https://docs.upbit.com/reference/%EC%B5%9C%EA%B7%BC-%EC%B2%B4%EA%B2%B0-%EB%82%B4%EC%97%AD
904
+ * @see https://docs.upbit.com/kr/reference/최근-체결-내역
905
+ * @see https://global-docs.upbit.com/reference/today-trades-history
910
906
  * @description get the list of most recent trades for a particular symbol
911
907
  * @param {string} symbol unified symbol of the market to fetch trades for
912
908
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -952,7 +948,8 @@ class upbit extends upbit$1 {
952
948
  /**
953
949
  * @method
954
950
  * @name upbit#fetchTradingFee
955
- * @see https://docs.upbit.com/reference/%EC%A3%BC%EB%AC%B8-%EA%B0%80%EB%8A%A5-%EC%A0%95%EB%B3%B4
951
+ * @see https://docs.upbit.com/kr/reference/주문-가능-정보
952
+ * @see https://global-docs.upbit.com/reference/available-order-information
956
953
  * @description fetch the trading fees for a market
957
954
  * @param {string} symbol unified market symbol
958
955
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -983,7 +980,7 @@ class upbit extends upbit$1 {
983
980
  // },
984
981
  // "bid_account": {
985
982
  // "currency": "KRW",
986
- // "balance": "0.34202414",
983
+ // "balance": "0.34202415",
987
984
  // "locked": "4999.99999922",
988
985
  // "avg_buy_price": "0",
989
986
  // "avg_buy_price_modified": true,
@@ -1014,6 +1011,29 @@ class upbit extends upbit$1 {
1014
1011
  'tierBased': false,
1015
1012
  };
1016
1013
  }
1014
+ /**
1015
+ * @method
1016
+ * @name upbit#fetchTradingFees
1017
+ * @description fetch the trading fees for markets
1018
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1019
+ * @returns {object} a [trading fee structure]{@link https://docs.ccxt.com/#/?id=trading-fee-structure}
1020
+ */
1021
+ async fetchTradingFees(params = {}) {
1022
+ await this.loadMarkets();
1023
+ const fetchMarketResponse = await this.fetchMarkets(params);
1024
+ const response = {};
1025
+ for (let i = 0; i < fetchMarketResponse.length; i++) {
1026
+ const element = {};
1027
+ element['maker'] = this.safeNumber(fetchMarketResponse[i], 'maker');
1028
+ element['taker'] = this.safeNumber(fetchMarketResponse[i], 'taker');
1029
+ element['symbol'] = this.safeString(fetchMarketResponse[i], 'symbol');
1030
+ element['percentage'] = true;
1031
+ element['tierBased'] = false;
1032
+ element['info'] = fetchMarketResponse[i];
1033
+ response[this.safeString(fetchMarketResponse[i], 'symbol')] = element;
1034
+ }
1035
+ return response;
1036
+ }
1017
1037
  parseOHLCV(ohlcv, market = undefined) {
1018
1038
  //
1019
1039
  // {
@@ -1042,7 +1062,8 @@ class upbit extends upbit$1 {
1042
1062
  /**
1043
1063
  * @method
1044
1064
  * @name upbit#fetchOHLCV
1045
- * @see https://docs.upbit.com/reference/%EB%B6%84minute-%EC%BA%94%EB%93%A4-1
1065
+ * @see https://docs.upbit.com/kr/reference/분minute-캔들-1
1066
+ * @see https://global-docs.upbit.com/reference/minutes
1046
1067
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1047
1068
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1048
1069
  * @param {string} timeframe the length of time each candle represents
@@ -1109,20 +1130,45 @@ class upbit extends upbit$1 {
1109
1130
  //
1110
1131
  return this.parseOHLCVs(response, market, timeframe, since, limit);
1111
1132
  }
1133
+ calcOrderPrice(symbol, amount, price = undefined, params = {}) {
1134
+ let quoteAmount = undefined;
1135
+ const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice');
1136
+ const cost = this.safeString(params, 'cost');
1137
+ if (cost !== undefined) {
1138
+ quoteAmount = this.costToPrecision(symbol, cost);
1139
+ }
1140
+ else if (createMarketBuyOrderRequiresPrice) {
1141
+ if (price === undefined || amount === undefined) {
1142
+ throw new errors.InvalidOrder(this.id + ' createOrder() requires the price and amount argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
1143
+ }
1144
+ const amountString = this.numberToString(amount);
1145
+ const priceString = this.numberToString(price);
1146
+ const costRequest = Precise["default"].stringMul(amountString, priceString);
1147
+ quoteAmount = this.costToPrecision(symbol, costRequest);
1148
+ }
1149
+ else {
1150
+ if (amount === undefined) {
1151
+ throw new errors.ArgumentsRequired(this.id + ' When createMarketBuyOrderRequiresPrice is false, "amount" is required and should be the total quote amount to spend.');
1152
+ }
1153
+ quoteAmount = this.costToPrecision(symbol, amount);
1154
+ }
1155
+ return quoteAmount;
1156
+ }
1112
1157
  /**
1113
1158
  * @method
1114
1159
  * @name upbit#createOrder
1115
1160
  * @description create a trade order
1116
- * @see https://docs.upbit.com/reference/%EC%A3%BC%EB%AC%B8%ED%95%98%EA%B8%B0
1161
+ * @see https://docs.upbit.com/kr/reference/주문하기
1117
1162
  * @see https://global-docs.upbit.com/reference/order
1118
1163
  * @param {string} symbol unified symbol of the market to create an order in
1119
- * @param {string} type 'market' or 'limit'
1164
+ * @param {string} type supports 'market' and 'limit'. if params.ordType is set to best, a best-type order will be created regardless of the value of type.
1120
1165
  * @param {string} side 'buy' or 'sell'
1121
1166
  * @param {float} amount how much you want to trade in units of the base currency
1122
1167
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1123
1168
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1124
- * @param {float} [params.cost] for market buy orders, the quote quantity that can be used as an alternative for the amount
1125
- * @param {string} [params.timeInForce] 'IOC' or 'FOK'
1169
+ * @param {float} [params.cost] for market buy and best buy orders, the quote quantity that can be used as an alternative for the amount
1170
+ * @param {string} [params.ordType] this field can be used to place a ‘best’ type order
1171
+ * @param {string} [params.timeInForce] 'IOC' or 'FOK'. only for limit or best type orders. this field is required when the order type is 'best'.
1126
1172
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1127
1173
  */
1128
1174
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -1136,58 +1182,69 @@ class upbit extends upbit$1 {
1136
1182
  orderSide = 'ask';
1137
1183
  }
1138
1184
  else {
1139
- throw new errors.InvalidOrder(this.id + ' createOrder() allows buy or sell side only!');
1185
+ throw new errors.InvalidOrder(this.id + ' createOrder() supports only buy or sell in the side argument.');
1140
1186
  }
1141
1187
  const request = {
1142
1188
  'market': market['id'],
1143
1189
  'side': orderSide,
1144
1190
  };
1145
1191
  if (type === 'limit') {
1192
+ if (price === undefined || amount === undefined) {
1193
+ throw new errors.ArgumentsRequired(this.id + ' the limit type order in createOrder() is required price and amount.');
1194
+ }
1195
+ request['ord_type'] = 'limit';
1146
1196
  request['price'] = this.priceToPrecision(symbol, price);
1197
+ request['volume'] = this.amountToPrecision(symbol, amount);
1147
1198
  }
1148
- if ((type === 'market') && (side === 'buy')) {
1149
- // for market buy it requires the amount of quote currency to spend
1150
- let quoteAmount = undefined;
1151
- let createMarketBuyOrderRequiresPrice = true;
1152
- [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
1153
- const cost = this.safeNumber(params, 'cost');
1154
- params = this.omit(params, 'cost');
1155
- if (cost !== undefined) {
1156
- quoteAmount = this.costToPrecision(symbol, cost);
1157
- }
1158
- else if (createMarketBuyOrderRequiresPrice) {
1159
- if (price === undefined) {
1160
- throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
1161
- }
1162
- else {
1163
- const amountString = this.numberToString(amount);
1164
- const priceString = this.numberToString(price);
1165
- const costRequest = Precise["default"].stringMul(amountString, priceString);
1166
- quoteAmount = this.costToPrecision(symbol, costRequest);
1167
- }
1199
+ else if (type === 'market') {
1200
+ if (side === 'buy') {
1201
+ request['ord_type'] = 'price';
1202
+ const orderPrice = this.calcOrderPrice(symbol, amount, price, params);
1203
+ request['price'] = orderPrice;
1168
1204
  }
1169
1205
  else {
1170
- quoteAmount = this.costToPrecision(symbol, amount);
1206
+ if (amount === undefined) {
1207
+ throw new errors.ArgumentsRequired(this.id + ' the market sell type order in createOrder() is required amount.');
1208
+ }
1209
+ request['ord_type'] = 'market';
1210
+ request['volume'] = this.amountToPrecision(symbol, amount);
1171
1211
  }
1172
- request['ord_type'] = 'price';
1173
- request['price'] = quoteAmount;
1174
1212
  }
1175
1213
  else {
1176
- request['ord_type'] = type;
1177
- request['volume'] = this.amountToPrecision(symbol, amount);
1214
+ throw new errors.InvalidOrder(this.id + ' createOrder() supports only limit or market types in the type argument.');
1178
1215
  }
1179
- const clientOrderId = this.safeString2(params, 'clientOrderId', 'identifier');
1216
+ const customType = this.safeString2(params, 'ordType', 'ord_type');
1217
+ if (customType === 'best') {
1218
+ params = this.omit(params, ['ordType', 'ord_type']);
1219
+ request['ord_type'] = 'best';
1220
+ if (side === 'buy') {
1221
+ const orderPrice = this.calcOrderPrice(symbol, amount, price, params);
1222
+ request['price'] = orderPrice;
1223
+ }
1224
+ else {
1225
+ if (amount === undefined) {
1226
+ throw new errors.ArgumentsRequired(this.id + ' the best sell type order in createOrder() is required amount.');
1227
+ }
1228
+ request['volume'] = this.amountToPrecision(symbol, amount);
1229
+ }
1230
+ }
1231
+ const clientOrderId = this.safeString(params, 'clientOrderId');
1180
1232
  if (clientOrderId !== undefined) {
1181
1233
  request['identifier'] = clientOrderId;
1182
1234
  }
1183
- if (type !== 'market') {
1235
+ if (request['ord_type'] !== 'market' && request['ord_type'] !== 'price') {
1184
1236
  const timeInForce = this.safeStringLower2(params, 'timeInForce', 'time_in_force');
1185
- params = this.omit(params, 'timeInForce');
1237
+ params = this.omit(params, ['timeInForce']);
1186
1238
  if (timeInForce !== undefined) {
1187
1239
  request['time_in_force'] = timeInForce;
1188
1240
  }
1241
+ else {
1242
+ if (request['ord_type'] === 'best') {
1243
+ throw new errors.ArgumentsRequired(this.id + ' the best type order in createOrder() is required timeInForce.');
1244
+ }
1245
+ }
1189
1246
  }
1190
- params = this.omit(params, ['clientOrderId', 'identifier']);
1247
+ params = this.omit(params, ['clientOrderId', 'cost']);
1191
1248
  const response = await this.privatePostOrders(this.extend(request, params));
1192
1249
  //
1193
1250
  // {
@@ -1214,7 +1271,8 @@ class upbit extends upbit$1 {
1214
1271
  /**
1215
1272
  * @method
1216
1273
  * @name upbit#cancelOrder
1217
- * @see https://docs.upbit.com/reference/%EC%A3%BC%EB%AC%B8-%EC%B7%A8%EC%86%8C
1274
+ * @see https://docs.upbit.com/kr/reference/주문-취소
1275
+ * @see https://global-docs.upbit.com/reference/order-cancel
1218
1276
  * @description cancels an open order
1219
1277
  * @param {string} id order id
1220
1278
  * @param {string} symbol not used by upbit cancelOrder ()
@@ -1248,10 +1306,131 @@ class upbit extends upbit$1 {
1248
1306
  //
1249
1307
  return this.parseOrder(response);
1250
1308
  }
1309
+ /**
1310
+ * @method
1311
+ * @name upbit#editOrder
1312
+ * @see https://docs.upbit.com/kr/reference/취소-후-재주문
1313
+ * @see https://global-docs.upbit.com/reference/cancel-and-new
1314
+ * @description canceled existing order and create new order. It's only generated same side and symbol as the canceled order. it returns the data of the canceled order, except for `new_order_uuid` and `new_identifier`. to get the details of the new order, use `fetchOrder(new_order_uuid)`.
1315
+ * @param {string} id the uuid of the previous order you want to edit.
1316
+ * @param {string} symbol the symbol of the new order. it must be the same as the symbol of the previous order.
1317
+ * @param {string} type the type of the new order. only limit or market is accepted. if params.newOrdType is set to best, a best-type order will be created regardless of the value of type.
1318
+ * @param {string} side the side of the new order. it must be the same as the side of the previous order.
1319
+ * @param {number} amount the amount of the asset you want to buy or sell. It could be overridden by specifying the new_volume parameter in params.
1320
+ * @param {number} price the price of the asset you want to buy or sell. It could be overridden by specifying the new_price parameter in params.
1321
+ * @param {object} [params] extra parameters specific to the exchange API endpoint.
1322
+ * @param {string} [params.clientOrderId] to identify the previous order, either the id or this field is required in this method.
1323
+ * @param {float} [params.cost] for market buy and best buy orders, the quote quantity that can be used as an alternative for the amount.
1324
+ * @param {string} [params.newTimeInForce] 'IOC' or 'FOK'. only for limit or best type orders. this field is required when the order type is 'best'.
1325
+ * @param {string} [params.newClientOrderId] the order ID that the user can define.
1326
+ * @param {string} [params.newOrdType] this field only accepts limit, price, market, or best. You can refer to the Upbit developer documentation for details on how to use this field.
1327
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1328
+ */
1329
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1330
+ await this.loadMarkets();
1331
+ const request = {};
1332
+ const prevClientOrderId = this.safeString(params, 'clientOrderId');
1333
+ params = this.omit(params, 'clientOrderId');
1334
+ if (id !== undefined) {
1335
+ request['prev_order_uuid'] = id;
1336
+ }
1337
+ else if (prevClientOrderId !== undefined) {
1338
+ request['prev_order_identifier'] = prevClientOrderId;
1339
+ }
1340
+ else {
1341
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() is required id or clientOrderId.');
1342
+ }
1343
+ if (type === 'limit') {
1344
+ if (price === undefined || amount === undefined) {
1345
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() is required price and amount to create limit type order.');
1346
+ }
1347
+ request['new_ord_type'] = 'limit';
1348
+ request['new_price'] = this.priceToPrecision(symbol, price);
1349
+ request['new_volume'] = this.amountToPrecision(symbol, amount);
1350
+ }
1351
+ else if (type === 'market') {
1352
+ if (side === 'buy') {
1353
+ request['new_ord_type'] = 'price';
1354
+ const orderPrice = this.calcOrderPrice(symbol, amount, price, params);
1355
+ request['new_price'] = orderPrice;
1356
+ }
1357
+ else {
1358
+ if (amount === undefined) {
1359
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() is required amount to create market sell type order.');
1360
+ }
1361
+ request['new_ord_type'] = 'market';
1362
+ request['new_volume'] = this.amountToPrecision(symbol, amount);
1363
+ }
1364
+ }
1365
+ else {
1366
+ throw new errors.InvalidOrder(this.id + ' editOrder() supports only limit or market types in the type argument.');
1367
+ }
1368
+ const customType = this.safeString2(params, 'newOrdType', 'new_ord_type');
1369
+ if (customType === 'best') {
1370
+ params = this.omit(params, ['newOrdType', 'new_ord_type']);
1371
+ request['new_ord_type'] = 'best';
1372
+ if (side === 'buy') {
1373
+ const orderPrice = this.calcOrderPrice(symbol, amount, price, params);
1374
+ request['new_price'] = orderPrice;
1375
+ }
1376
+ else {
1377
+ if (amount === undefined) {
1378
+ throw new errors.ArgumentsRequired(this.id + ' editOrder() is required amount to create best sell order.');
1379
+ }
1380
+ request['new_volume'] = this.amountToPrecision(symbol, amount);
1381
+ }
1382
+ }
1383
+ const clientOrderId = this.safeString(params, 'newClientOrderId');
1384
+ if (clientOrderId !== undefined) {
1385
+ request['new_identifier'] = clientOrderId;
1386
+ }
1387
+ if (request['new_ord_type'] !== 'market' && request['new_ord_type'] !== 'price') {
1388
+ const timeInForce = this.safeStringLower2(params, 'newTimeInForce', 'new_time_in_force');
1389
+ params = this.omit(params, ['newTimeInForce', 'new_time_in_force']);
1390
+ if (timeInForce !== undefined) {
1391
+ request['new_time_in_force'] = timeInForce;
1392
+ }
1393
+ else {
1394
+ if (request['new_ord_type'] === 'best') {
1395
+ throw new errors.ArgumentsRequired(this.id + ' the best type order is required timeInForce.');
1396
+ }
1397
+ }
1398
+ }
1399
+ params = this.omit(params, ['newClientOrderId', 'cost']);
1400
+ // console.log ('check the each request params: ', request);
1401
+ const response = await this.privatePostOrdersCancelAndNew(this.extend(request, params));
1402
+ // {
1403
+ // uuid: '63b38774-27db-4439-ac20-1be16a24d18e', //previous order data
1404
+ // side: 'bid', //previous order data
1405
+ // ord_type: 'limit', //previous order data
1406
+ // price: '100000000', //previous order data
1407
+ // state: 'wait', //previous order data
1408
+ // market: 'KRW-BTC', //previous order data
1409
+ // created_at: '2025-04-01T15:30:47+09:00', //previous order data
1410
+ // volume: '0.00008', //previous order data
1411
+ // remaining_volume: '0.00008', //previous order data
1412
+ // reserved_fee: '4', //previous order data
1413
+ // remaining_fee: '4', //previous order data
1414
+ // paid_fee: '0', //previous order data
1415
+ // locked: '8004', //previous order data
1416
+ // executed_volume: '0', //previous order data
1417
+ // trades_count: '0', //previous order data
1418
+ // identifier: '21', //previous order data
1419
+ // new_order_uuid: 'cb1cce56-6237-4a78-bc11-4cfffc1bb4c2', // new order data
1420
+ // new_order_identifier: '22' // new order data
1421
+ // }
1422
+ const result = {};
1423
+ result['uuid'] = this.safeString(response, 'new_order_uuid');
1424
+ result['identifier'] = this.safeString(response, 'new_order_identifier');
1425
+ result['side'] = this.safeString(response, 'side');
1426
+ result['market'] = this.safeString(response, 'market');
1427
+ return this.parseOrder(result);
1428
+ }
1251
1429
  /**
1252
1430
  * @method
1253
1431
  * @name upbit#fetchDeposits
1254
- * @see https://docs.upbit.com/reference/%EC%9E%85%EA%B8%88-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
1432
+ * @see https://docs.upbit.com/kr/reference/입금-리스트-조회
1433
+ * @see https://global-docs.upbit.com/reference/deposit-list-inquiry
1255
1434
  * @description fetch all deposits made to an account
1256
1435
  * @param {string} code unified currency code
1257
1436
  * @param {int} [since] the earliest time in ms to fetch deposits for
@@ -1296,6 +1475,7 @@ class upbit extends upbit$1 {
1296
1475
  * @method
1297
1476
  * @name upbit#fetchDeposit
1298
1477
  * @description fetch information on a deposit
1478
+ * @see https://docs.upbit.com/kr/reference/개별-입금-조회
1299
1479
  * @see https://global-docs.upbit.com/reference/individual-deposit-inquiry
1300
1480
  * @param {string} id the unique id for the deposit
1301
1481
  * @param {string} [code] unified currency code of the currency deposited
@@ -1334,7 +1514,8 @@ class upbit extends upbit$1 {
1334
1514
  /**
1335
1515
  * @method
1336
1516
  * @name upbit#fetchWithdrawals
1337
- * @see https://docs.upbit.com/reference/%EC%A0%84%EC%B2%B4-%EC%B6%9C%EA%B8%88-%EC%A1%B0%ED%9A%8C
1517
+ * @see https://docs.upbit.com/kr/reference/전체-출금-조회
1518
+ * @see https://global-docs.upbit.com/reference/withdrawal-list-inquiry
1338
1519
  * @description fetch all withdrawals made from an account
1339
1520
  * @param {string} code unified currency code
1340
1521
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
@@ -1379,6 +1560,7 @@ class upbit extends upbit$1 {
1379
1560
  * @method
1380
1561
  * @name upbit#fetchWithdrawal
1381
1562
  * @description fetch data on a currency withdrawal via the withdrawal id
1563
+ * @see https://docs.upbit.com/kr/reference/개별-출금-조회
1382
1564
  * @see https://global-docs.upbit.com/reference/individual-withdrawal-inquiry
1383
1565
  * @param {string} id the unique id for the withdrawal
1384
1566
  * @param {string} [code] unified currency code of the currency withdrawn
@@ -1568,6 +1750,26 @@ class upbit extends upbit$1 {
1568
1750
  // "time_in_force": "ioc"
1569
1751
  // }
1570
1752
  //
1753
+ // {
1754
+ // uuid: '63b38774-27db-4439-ac20-1be16a24d18e',
1755
+ // side: 'bid',
1756
+ // ord_type: 'limit',
1757
+ // price: '100000000',
1758
+ // state: 'wait',
1759
+ // market: 'KRW-BTC',
1760
+ // created_at: '2025-04-01T15:30:47+09:00',
1761
+ // volume: '0.00008',
1762
+ // remaining_volume: '0.00008',
1763
+ // reserved_fee: '4',
1764
+ // remaining_fee: '4',
1765
+ // paid_fee: '0',
1766
+ // locked: '8004',
1767
+ // executed_volume: '0',
1768
+ // trades_count: '0',
1769
+ // identifier: '21',
1770
+ // new_order_uuid: 'cb1cce56-6237-4a78-bc11-4cfffc1bb4c2',
1771
+ // new_order_identifier: '22'
1772
+ // }
1571
1773
  const id = this.safeString(order, 'uuid');
1572
1774
  let side = this.safeString(order, 'side');
1573
1775
  if (side === 'bid') {
@@ -1576,6 +1778,7 @@ class upbit extends upbit$1 {
1576
1778
  else {
1577
1779
  side = 'sell';
1578
1780
  }
1781
+ const identifier = this.safeString(order, 'identifier');
1579
1782
  let type = this.safeString(order, 'ord_type');
1580
1783
  const timestamp = this.parse8601(this.safeString(order, 'created_at'));
1581
1784
  const status = this.parseOrderStatus(this.safeString(order, 'state'));
@@ -1632,7 +1835,7 @@ class upbit extends upbit$1 {
1632
1835
  return this.safeOrder({
1633
1836
  'info': order,
1634
1837
  'id': id,
1635
- 'clientOrderId': undefined,
1838
+ 'clientOrderId': identifier,
1636
1839
  'timestamp': timestamp,
1637
1840
  'datetime': this.iso8601(timestamp),
1638
1841
  'lastTradeTimestamp': lastTradeTimestamp,
@@ -1657,6 +1860,7 @@ class upbit extends upbit$1 {
1657
1860
  * @method
1658
1861
  * @name upbit#fetchOpenOrders
1659
1862
  * @description fetch all unfilled currently open orders
1863
+ * @see https://docs.upbit.com/kr/reference/대기-주문-조회
1660
1864
  * @see https://global-docs.upbit.com/reference/open-order
1661
1865
  * @param {string} symbol unified market symbol
1662
1866
  * @param {int} [since] the earliest time in ms to fetch open orders for
@@ -1705,6 +1909,7 @@ class upbit extends upbit$1 {
1705
1909
  * @method
1706
1910
  * @name upbit#fetchClosedOrders
1707
1911
  * @description fetches information on multiple closed orders made by the user
1912
+ * @see https://docs.upbit.com/kr/reference/종료-주문-조회
1708
1913
  * @see https://global-docs.upbit.com/reference/closed-order
1709
1914
  * @param {string} symbol unified market symbol of the market orders were made in
1710
1915
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -1760,6 +1965,7 @@ class upbit extends upbit$1 {
1760
1965
  * @method
1761
1966
  * @name upbit#fetchCanceledOrders
1762
1967
  * @description fetches information on multiple canceled orders made by the user
1968
+ * @see https://docs.upbit.com/kr/reference/종료-주문-조회
1763
1969
  * @see https://global-docs.upbit.com/reference/closed-order
1764
1970
  * @param {string} symbol unified market symbol of the market orders were made in
1765
1971
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
@@ -1814,7 +2020,8 @@ class upbit extends upbit$1 {
1814
2020
  /**
1815
2021
  * @method
1816
2022
  * @name upbit#fetchOrder
1817
- * @see https://docs.upbit.com/reference/%EA%B0%9C%EB%B3%84-%EC%A3%BC%EB%AC%B8-%EC%A1%B0%ED%9A%8C
2023
+ * @see https://docs.upbit.com/kr/reference/개별-주문-조회
2024
+ * @see https://global-docs.upbit.com/reference/individual-order-inquiry
1818
2025
  * @description fetches information on an order made by the user
1819
2026
  * @param {string} id order id
1820
2027
  * @param {string} symbol not used by upbit fetchOrder
@@ -1875,7 +2082,8 @@ class upbit extends upbit$1 {
1875
2082
  /**
1876
2083
  * @method
1877
2084
  * @name upbit#fetchDepositAddresses
1878
- * @see https://docs.upbit.com/reference/%EC%A0%84%EC%B2%B4-%EC%9E%85%EA%B8%88-%EC%A3%BC%EC%86%8C-%EC%A1%B0%ED%9A%8C
2085
+ * @see https://docs.upbit.com/kr/reference/전체-입금-주소-조회
2086
+ * @see https://global-docs.upbit.com/reference/general-deposit-address-inquiry
1879
2087
  * @description fetch deposit addresses for multiple currencies and chain types
1880
2088
  * @param {string[]|undefined} codes list of unified currency codes, default is undefined
1881
2089
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1931,7 +2139,8 @@ class upbit extends upbit$1 {
1931
2139
  /**
1932
2140
  * @method
1933
2141
  * @name upbit#fetchDepositAddress
1934
- * @see https://docs.upbit.com/reference/%EC%A0%84%EC%B2%B4-%EC%9E%85%EA%B8%88-%EC%A3%BC%EC%86%8C-%EC%A1%B0%ED%9A%8C
2142
+ * @see https://docs.upbit.com/kr/reference/개별-입금-주소-조회
2143
+ * @see https://global-docs.upbit.com/reference/individual-deposit-address-inquiry
1935
2144
  * @description fetch the deposit address for a currency associated with this account
1936
2145
  * @param {string} code unified currency code
1937
2146
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1963,7 +2172,8 @@ class upbit extends upbit$1 {
1963
2172
  /**
1964
2173
  * @method
1965
2174
  * @name upbit#createDepositAddress
1966
- * @see https://docs.upbit.com/reference/%EC%9E%85%EA%B8%88-%EC%A3%BC%EC%86%8C-%EC%83%9D%EC%84%B1-%EC%9A%94%EC%B2%AD
2175
+ * @see https://docs.upbit.com/kr/reference/입금-주소-생성-요청
2176
+ * @see https://global-docs.upbit.com/reference/deposit-address-generation
1967
2177
  * @description create a currency deposit address
1968
2178
  * @param {string} code unified currency code of the currency for the deposit address
1969
2179
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -2001,8 +2211,8 @@ class upbit extends upbit$1 {
2001
2211
  /**
2002
2212
  * @method
2003
2213
  * @name upbit#withdraw
2004
- * @see https://docs.upbit.com/reference/디지털자산-출금하기
2005
- * @see https://docs.upbit.com/reference/%EC%9B%90%ED%99%94-%EC%B6%9C%EA%B8%88%ED%95%98%EA%B8%B0
2214
+ * @see https://docs.upbit.com/kr/reference/디지털자산-출금하기
2215
+ * @see https://global-docs.upbit.com/reference/withdrawal-digital-assets
2006
2216
  * @description make a withdrawal
2007
2217
  * @param {string} code unified currency code
2008
2218
  * @param {float} amount the amount to withdraw