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
package/js/src/upbit.js CHANGED
@@ -35,6 +35,7 @@ export default class upbit extends Exchange {
35
35
  'createMarketOrderWithCost': false,
36
36
  'createMarketSellOrderWithCost': false,
37
37
  'createOrder': true,
38
+ 'editOrder': true,
38
39
  'fetchBalance': true,
39
40
  'fetchCanceledOrders': true,
40
41
  'fetchClosedOrders': true,
@@ -65,7 +66,7 @@ export default class upbit extends Exchange {
65
66
  'fetchTickers': true,
66
67
  'fetchTrades': true,
67
68
  'fetchTradingFee': true,
68
- 'fetchTradingFees': false,
69
+ 'fetchTradingFees': true,
69
70
  'fetchTransactions': false,
70
71
  'fetchWithdrawal': true,
71
72
  'fetchWithdrawals': true,
@@ -265,8 +266,6 @@ export default class upbit extends Exchange {
265
266
  },
266
267
  'options': {
267
268
  'createMarketBuyOrderRequiresPrice': true,
268
- 'fetchTickersMaxLength': 4096,
269
- 'fetchOrderBooksMaxLength': 4096,
270
269
  'tradingFeesByQuoteCurrency': {
271
270
  'KRW': 0.0005,
272
271
  },
@@ -488,7 +487,8 @@ export default class upbit extends Exchange {
488
487
  /**
489
488
  * @method
490
489
  * @name upbit#fetchMarkets
491
- * @see https://docs.upbit.com/reference/%EB%A7%88%EC%BC%93-%EC%BD%94%EB%93%9C-%EC%A1%B0%ED%9A%8C
490
+ * @see https://docs.upbit.com/kr/reference/마켓-코드-조회
491
+ * @see https://global-docs.upbit.com/reference/listing-market-list
492
492
  * @description retrieves data on all markets for upbit
493
493
  * @param {object} [params] extra parameters specific to the exchange API endpoint
494
494
  * @returns {object[]} an array of objects representing market data
@@ -584,7 +584,8 @@ export default class upbit extends Exchange {
584
584
  /**
585
585
  * @method
586
586
  * @name upbit#fetchBalance
587
- * @see https://docs.upbit.com/reference/%EC%A0%84%EC%B2%B4-%EA%B3%84%EC%A2%8C-%EC%A1%B0%ED%9A%8C
587
+ * @see https://docs.upbit.com/kr/reference/전체-계좌-조회
588
+ * @see https://global-docs.upbit.com/reference/overall-account-inquiry
588
589
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
589
590
  * @param {object} [params] extra parameters specific to the exchange API endpoint
590
591
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
@@ -609,7 +610,8 @@ export default class upbit extends Exchange {
609
610
  /**
610
611
  * @method
611
612
  * @name upbit#fetchOrderBooks
612
- * @see https://docs.upbit.com/reference/%ED%98%B8%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C
613
+ * @see https://docs.upbit.com/kr/reference/호가-정보-조회
614
+ * @see https://global-docs.upbit.com/reference/order-book-list
613
615
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
614
616
  * @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
615
617
  * @param {int} [limit] not used by upbit fetchOrderBooks ()
@@ -621,11 +623,6 @@ export default class upbit extends Exchange {
621
623
  let ids = undefined;
622
624
  if (symbols === undefined) {
623
625
  ids = this.ids.join(',');
624
- // max URL length is 2083 symbols, including http schema, hostname, tld, etc...
625
- if (ids.length > this.options['fetchOrderBooksMaxLength']) {
626
- const numIds = this.ids.length;
627
- throw new 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');
628
- }
629
626
  }
630
627
  else {
631
628
  ids = this.marketIds(symbols);
@@ -683,7 +680,8 @@ export default class upbit extends Exchange {
683
680
  /**
684
681
  * @method
685
682
  * @name upbit#fetchOrderBook
686
- * @see https://docs.upbit.com/reference/%ED%98%B8%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C
683
+ * @see https://docs.upbit.com/kr/reference/호가-정보-조회
684
+ * @see https://global-docs.upbit.com/reference/order-book-list
687
685
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
688
686
  * @param {string} symbol unified symbol of the market to fetch the order book for
689
687
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -753,7 +751,8 @@ export default class upbit extends Exchange {
753
751
  /**
754
752
  * @method
755
753
  * @name upbit#fetchTickers
756
- * @see https://docs.upbit.com/reference/ticker%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4
754
+ * @see https://docs.upbit.com/kr/reference/ticker현재가-정보
755
+ * @see https://global-docs.upbit.com/reference/tickers
757
756
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
758
757
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
759
758
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -765,11 +764,6 @@ export default class upbit extends Exchange {
765
764
  let ids = undefined;
766
765
  if (symbols === undefined) {
767
766
  ids = this.ids.join(',');
768
- // max URL length is 2083 symbols, including http schema, hostname, tld, etc...
769
- if (ids.length > this.options['fetchTickersMaxLength']) {
770
- const numIds = this.ids.length;
771
- throw new 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');
772
- }
773
767
  }
774
768
  else {
775
769
  ids = this.marketIds(symbols);
@@ -818,7 +812,8 @@ export default class upbit extends Exchange {
818
812
  /**
819
813
  * @method
820
814
  * @name upbit#fetchTicker
821
- * @see https://docs.upbit.com/reference/ticker%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4
815
+ * @see https://docs.upbit.com/kr/reference/ticker현재가-정보
816
+ * @see https://global-docs.upbit.com/reference/tickers
822
817
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
823
818
  * @param {string} symbol unified symbol of the market to fetch the ticker for
824
819
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -903,7 +898,8 @@ export default class upbit extends Exchange {
903
898
  /**
904
899
  * @method
905
900
  * @name upbit#fetchTrades
906
- * @see https://docs.upbit.com/reference/%EC%B5%9C%EA%B7%BC-%EC%B2%B4%EA%B2%B0-%EB%82%B4%EC%97%AD
901
+ * @see https://docs.upbit.com/kr/reference/최근-체결-내역
902
+ * @see https://global-docs.upbit.com/reference/today-trades-history
907
903
  * @description get the list of most recent trades for a particular symbol
908
904
  * @param {string} symbol unified symbol of the market to fetch trades for
909
905
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -949,7 +945,8 @@ export default class upbit extends Exchange {
949
945
  /**
950
946
  * @method
951
947
  * @name upbit#fetchTradingFee
952
- * @see https://docs.upbit.com/reference/%EC%A3%BC%EB%AC%B8-%EA%B0%80%EB%8A%A5-%EC%A0%95%EB%B3%B4
948
+ * @see https://docs.upbit.com/kr/reference/주문-가능-정보
949
+ * @see https://global-docs.upbit.com/reference/available-order-information
953
950
  * @description fetch the trading fees for a market
954
951
  * @param {string} symbol unified market symbol
955
952
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -980,7 +977,7 @@ export default class upbit extends Exchange {
980
977
  // },
981
978
  // "bid_account": {
982
979
  // "currency": "KRW",
983
- // "balance": "0.34202414",
980
+ // "balance": "0.34202415",
984
981
  // "locked": "4999.99999922",
985
982
  // "avg_buy_price": "0",
986
983
  // "avg_buy_price_modified": true,
@@ -1011,6 +1008,29 @@ export default class upbit extends Exchange {
1011
1008
  'tierBased': false,
1012
1009
  };
1013
1010
  }
1011
+ /**
1012
+ * @method
1013
+ * @name upbit#fetchTradingFees
1014
+ * @description fetch the trading fees for markets
1015
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1016
+ * @returns {object} a [trading fee structure]{@link https://docs.ccxt.com/#/?id=trading-fee-structure}
1017
+ */
1018
+ async fetchTradingFees(params = {}) {
1019
+ await this.loadMarkets();
1020
+ const fetchMarketResponse = await this.fetchMarkets(params);
1021
+ const response = {};
1022
+ for (let i = 0; i < fetchMarketResponse.length; i++) {
1023
+ const element = {};
1024
+ element['maker'] = this.safeNumber(fetchMarketResponse[i], 'maker');
1025
+ element['taker'] = this.safeNumber(fetchMarketResponse[i], 'taker');
1026
+ element['symbol'] = this.safeString(fetchMarketResponse[i], 'symbol');
1027
+ element['percentage'] = true;
1028
+ element['tierBased'] = false;
1029
+ element['info'] = fetchMarketResponse[i];
1030
+ response[this.safeString(fetchMarketResponse[i], 'symbol')] = element;
1031
+ }
1032
+ return response;
1033
+ }
1014
1034
  parseOHLCV(ohlcv, market = undefined) {
1015
1035
  //
1016
1036
  // {
@@ -1039,7 +1059,8 @@ export default class upbit extends Exchange {
1039
1059
  /**
1040
1060
  * @method
1041
1061
  * @name upbit#fetchOHLCV
1042
- * @see https://docs.upbit.com/reference/%EB%B6%84minute-%EC%BA%94%EB%93%A4-1
1062
+ * @see https://docs.upbit.com/kr/reference/분minute-캔들-1
1063
+ * @see https://global-docs.upbit.com/reference/minutes
1043
1064
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1044
1065
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1045
1066
  * @param {string} timeframe the length of time each candle represents
@@ -1106,20 +1127,45 @@ export default class upbit extends Exchange {
1106
1127
  //
1107
1128
  return this.parseOHLCVs(response, market, timeframe, since, limit);
1108
1129
  }
1130
+ calcOrderPrice(symbol, amount, price = undefined, params = {}) {
1131
+ let quoteAmount = undefined;
1132
+ const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice');
1133
+ const cost = this.safeString(params, 'cost');
1134
+ if (cost !== undefined) {
1135
+ quoteAmount = this.costToPrecision(symbol, cost);
1136
+ }
1137
+ else if (createMarketBuyOrderRequiresPrice) {
1138
+ if (price === undefined || amount === undefined) {
1139
+ throw new 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');
1140
+ }
1141
+ const amountString = this.numberToString(amount);
1142
+ const priceString = this.numberToString(price);
1143
+ const costRequest = Precise.stringMul(amountString, priceString);
1144
+ quoteAmount = this.costToPrecision(symbol, costRequest);
1145
+ }
1146
+ else {
1147
+ if (amount === undefined) {
1148
+ throw new ArgumentsRequired(this.id + ' When createMarketBuyOrderRequiresPrice is false, "amount" is required and should be the total quote amount to spend.');
1149
+ }
1150
+ quoteAmount = this.costToPrecision(symbol, amount);
1151
+ }
1152
+ return quoteAmount;
1153
+ }
1109
1154
  /**
1110
1155
  * @method
1111
1156
  * @name upbit#createOrder
1112
1157
  * @description create a trade order
1113
- * @see https://docs.upbit.com/reference/%EC%A3%BC%EB%AC%B8%ED%95%98%EA%B8%B0
1158
+ * @see https://docs.upbit.com/kr/reference/주문하기
1114
1159
  * @see https://global-docs.upbit.com/reference/order
1115
1160
  * @param {string} symbol unified symbol of the market to create an order in
1116
- * @param {string} type 'market' or 'limit'
1161
+ * @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.
1117
1162
  * @param {string} side 'buy' or 'sell'
1118
1163
  * @param {float} amount how much you want to trade in units of the base currency
1119
1164
  * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1120
1165
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1121
- * @param {float} [params.cost] for market buy orders, the quote quantity that can be used as an alternative for the amount
1122
- * @param {string} [params.timeInForce] 'IOC' or 'FOK'
1166
+ * @param {float} [params.cost] for market buy and best buy orders, the quote quantity that can be used as an alternative for the amount
1167
+ * @param {string} [params.ordType] this field can be used to place a ‘best’ type order
1168
+ * @param {string} [params.timeInForce] 'IOC' or 'FOK'. only for limit or best type orders. this field is required when the order type is 'best'.
1123
1169
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1124
1170
  */
1125
1171
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -1133,58 +1179,69 @@ export default class upbit extends Exchange {
1133
1179
  orderSide = 'ask';
1134
1180
  }
1135
1181
  else {
1136
- throw new InvalidOrder(this.id + ' createOrder() allows buy or sell side only!');
1182
+ throw new InvalidOrder(this.id + ' createOrder() supports only buy or sell in the side argument.');
1137
1183
  }
1138
1184
  const request = {
1139
1185
  'market': market['id'],
1140
1186
  'side': orderSide,
1141
1187
  };
1142
1188
  if (type === 'limit') {
1189
+ if (price === undefined || amount === undefined) {
1190
+ throw new ArgumentsRequired(this.id + ' the limit type order in createOrder() is required price and amount.');
1191
+ }
1192
+ request['ord_type'] = 'limit';
1143
1193
  request['price'] = this.priceToPrecision(symbol, price);
1194
+ request['volume'] = this.amountToPrecision(symbol, amount);
1144
1195
  }
1145
- if ((type === 'market') && (side === 'buy')) {
1146
- // for market buy it requires the amount of quote currency to spend
1147
- let quoteAmount = undefined;
1148
- let createMarketBuyOrderRequiresPrice = true;
1149
- [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
1150
- const cost = this.safeNumber(params, 'cost');
1151
- params = this.omit(params, 'cost');
1152
- if (cost !== undefined) {
1153
- quoteAmount = this.costToPrecision(symbol, cost);
1154
- }
1155
- else if (createMarketBuyOrderRequiresPrice) {
1156
- if (price === undefined) {
1157
- throw new 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');
1158
- }
1159
- else {
1160
- const amountString = this.numberToString(amount);
1161
- const priceString = this.numberToString(price);
1162
- const costRequest = Precise.stringMul(amountString, priceString);
1163
- quoteAmount = this.costToPrecision(symbol, costRequest);
1164
- }
1196
+ else if (type === 'market') {
1197
+ if (side === 'buy') {
1198
+ request['ord_type'] = 'price';
1199
+ const orderPrice = this.calcOrderPrice(symbol, amount, price, params);
1200
+ request['price'] = orderPrice;
1165
1201
  }
1166
1202
  else {
1167
- quoteAmount = this.costToPrecision(symbol, amount);
1203
+ if (amount === undefined) {
1204
+ throw new ArgumentsRequired(this.id + ' the market sell type order in createOrder() is required amount.');
1205
+ }
1206
+ request['ord_type'] = 'market';
1207
+ request['volume'] = this.amountToPrecision(symbol, amount);
1168
1208
  }
1169
- request['ord_type'] = 'price';
1170
- request['price'] = quoteAmount;
1171
1209
  }
1172
1210
  else {
1173
- request['ord_type'] = type;
1174
- request['volume'] = this.amountToPrecision(symbol, amount);
1211
+ throw new InvalidOrder(this.id + ' createOrder() supports only limit or market types in the type argument.');
1175
1212
  }
1176
- const clientOrderId = this.safeString2(params, 'clientOrderId', 'identifier');
1213
+ const customType = this.safeString2(params, 'ordType', 'ord_type');
1214
+ if (customType === 'best') {
1215
+ params = this.omit(params, ['ordType', 'ord_type']);
1216
+ request['ord_type'] = 'best';
1217
+ if (side === 'buy') {
1218
+ const orderPrice = this.calcOrderPrice(symbol, amount, price, params);
1219
+ request['price'] = orderPrice;
1220
+ }
1221
+ else {
1222
+ if (amount === undefined) {
1223
+ throw new ArgumentsRequired(this.id + ' the best sell type order in createOrder() is required amount.');
1224
+ }
1225
+ request['volume'] = this.amountToPrecision(symbol, amount);
1226
+ }
1227
+ }
1228
+ const clientOrderId = this.safeString(params, 'clientOrderId');
1177
1229
  if (clientOrderId !== undefined) {
1178
1230
  request['identifier'] = clientOrderId;
1179
1231
  }
1180
- if (type !== 'market') {
1232
+ if (request['ord_type'] !== 'market' && request['ord_type'] !== 'price') {
1181
1233
  const timeInForce = this.safeStringLower2(params, 'timeInForce', 'time_in_force');
1182
- params = this.omit(params, 'timeInForce');
1234
+ params = this.omit(params, ['timeInForce']);
1183
1235
  if (timeInForce !== undefined) {
1184
1236
  request['time_in_force'] = timeInForce;
1185
1237
  }
1238
+ else {
1239
+ if (request['ord_type'] === 'best') {
1240
+ throw new ArgumentsRequired(this.id + ' the best type order in createOrder() is required timeInForce.');
1241
+ }
1242
+ }
1186
1243
  }
1187
- params = this.omit(params, ['clientOrderId', 'identifier']);
1244
+ params = this.omit(params, ['clientOrderId', 'cost']);
1188
1245
  const response = await this.privatePostOrders(this.extend(request, params));
1189
1246
  //
1190
1247
  // {
@@ -1211,7 +1268,8 @@ export default class upbit extends Exchange {
1211
1268
  /**
1212
1269
  * @method
1213
1270
  * @name upbit#cancelOrder
1214
- * @see https://docs.upbit.com/reference/%EC%A3%BC%EB%AC%B8-%EC%B7%A8%EC%86%8C
1271
+ * @see https://docs.upbit.com/kr/reference/주문-취소
1272
+ * @see https://global-docs.upbit.com/reference/order-cancel
1215
1273
  * @description cancels an open order
1216
1274
  * @param {string} id order id
1217
1275
  * @param {string} symbol not used by upbit cancelOrder ()
@@ -1245,10 +1303,131 @@ export default class upbit extends Exchange {
1245
1303
  //
1246
1304
  return this.parseOrder(response);
1247
1305
  }
1306
+ /**
1307
+ * @method
1308
+ * @name upbit#editOrder
1309
+ * @see https://docs.upbit.com/kr/reference/취소-후-재주문
1310
+ * @see https://global-docs.upbit.com/reference/cancel-and-new
1311
+ * @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)`.
1312
+ * @param {string} id the uuid of the previous order you want to edit.
1313
+ * @param {string} symbol the symbol of the new order. it must be the same as the symbol of the previous order.
1314
+ * @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.
1315
+ * @param {string} side the side of the new order. it must be the same as the side of the previous order.
1316
+ * @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.
1317
+ * @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.
1318
+ * @param {object} [params] extra parameters specific to the exchange API endpoint.
1319
+ * @param {string} [params.clientOrderId] to identify the previous order, either the id or this field is required in this method.
1320
+ * @param {float} [params.cost] for market buy and best buy orders, the quote quantity that can be used as an alternative for the amount.
1321
+ * @param {string} [params.newTimeInForce] 'IOC' or 'FOK'. only for limit or best type orders. this field is required when the order type is 'best'.
1322
+ * @param {string} [params.newClientOrderId] the order ID that the user can define.
1323
+ * @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.
1324
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1325
+ */
1326
+ async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1327
+ await this.loadMarkets();
1328
+ const request = {};
1329
+ const prevClientOrderId = this.safeString(params, 'clientOrderId');
1330
+ params = this.omit(params, 'clientOrderId');
1331
+ if (id !== undefined) {
1332
+ request['prev_order_uuid'] = id;
1333
+ }
1334
+ else if (prevClientOrderId !== undefined) {
1335
+ request['prev_order_identifier'] = prevClientOrderId;
1336
+ }
1337
+ else {
1338
+ throw new ArgumentsRequired(this.id + ' editOrder() is required id or clientOrderId.');
1339
+ }
1340
+ if (type === 'limit') {
1341
+ if (price === undefined || amount === undefined) {
1342
+ throw new ArgumentsRequired(this.id + ' editOrder() is required price and amount to create limit type order.');
1343
+ }
1344
+ request['new_ord_type'] = 'limit';
1345
+ request['new_price'] = this.priceToPrecision(symbol, price);
1346
+ request['new_volume'] = this.amountToPrecision(symbol, amount);
1347
+ }
1348
+ else if (type === 'market') {
1349
+ if (side === 'buy') {
1350
+ request['new_ord_type'] = 'price';
1351
+ const orderPrice = this.calcOrderPrice(symbol, amount, price, params);
1352
+ request['new_price'] = orderPrice;
1353
+ }
1354
+ else {
1355
+ if (amount === undefined) {
1356
+ throw new ArgumentsRequired(this.id + ' editOrder() is required amount to create market sell type order.');
1357
+ }
1358
+ request['new_ord_type'] = 'market';
1359
+ request['new_volume'] = this.amountToPrecision(symbol, amount);
1360
+ }
1361
+ }
1362
+ else {
1363
+ throw new InvalidOrder(this.id + ' editOrder() supports only limit or market types in the type argument.');
1364
+ }
1365
+ const customType = this.safeString2(params, 'newOrdType', 'new_ord_type');
1366
+ if (customType === 'best') {
1367
+ params = this.omit(params, ['newOrdType', 'new_ord_type']);
1368
+ request['new_ord_type'] = 'best';
1369
+ if (side === 'buy') {
1370
+ const orderPrice = this.calcOrderPrice(symbol, amount, price, params);
1371
+ request['new_price'] = orderPrice;
1372
+ }
1373
+ else {
1374
+ if (amount === undefined) {
1375
+ throw new ArgumentsRequired(this.id + ' editOrder() is required amount to create best sell order.');
1376
+ }
1377
+ request['new_volume'] = this.amountToPrecision(symbol, amount);
1378
+ }
1379
+ }
1380
+ const clientOrderId = this.safeString(params, 'newClientOrderId');
1381
+ if (clientOrderId !== undefined) {
1382
+ request['new_identifier'] = clientOrderId;
1383
+ }
1384
+ if (request['new_ord_type'] !== 'market' && request['new_ord_type'] !== 'price') {
1385
+ const timeInForce = this.safeStringLower2(params, 'newTimeInForce', 'new_time_in_force');
1386
+ params = this.omit(params, ['newTimeInForce', 'new_time_in_force']);
1387
+ if (timeInForce !== undefined) {
1388
+ request['new_time_in_force'] = timeInForce;
1389
+ }
1390
+ else {
1391
+ if (request['new_ord_type'] === 'best') {
1392
+ throw new ArgumentsRequired(this.id + ' the best type order is required timeInForce.');
1393
+ }
1394
+ }
1395
+ }
1396
+ params = this.omit(params, ['newClientOrderId', 'cost']);
1397
+ // console.log ('check the each request params: ', request);
1398
+ const response = await this.privatePostOrdersCancelAndNew(this.extend(request, params));
1399
+ // {
1400
+ // uuid: '63b38774-27db-4439-ac20-1be16a24d18e', //previous order data
1401
+ // side: 'bid', //previous order data
1402
+ // ord_type: 'limit', //previous order data
1403
+ // price: '100000000', //previous order data
1404
+ // state: 'wait', //previous order data
1405
+ // market: 'KRW-BTC', //previous order data
1406
+ // created_at: '2025-04-01T15:30:47+09:00', //previous order data
1407
+ // volume: '0.00008', //previous order data
1408
+ // remaining_volume: '0.00008', //previous order data
1409
+ // reserved_fee: '4', //previous order data
1410
+ // remaining_fee: '4', //previous order data
1411
+ // paid_fee: '0', //previous order data
1412
+ // locked: '8004', //previous order data
1413
+ // executed_volume: '0', //previous order data
1414
+ // trades_count: '0', //previous order data
1415
+ // identifier: '21', //previous order data
1416
+ // new_order_uuid: 'cb1cce56-6237-4a78-bc11-4cfffc1bb4c2', // new order data
1417
+ // new_order_identifier: '22' // new order data
1418
+ // }
1419
+ const result = {};
1420
+ result['uuid'] = this.safeString(response, 'new_order_uuid');
1421
+ result['identifier'] = this.safeString(response, 'new_order_identifier');
1422
+ result['side'] = this.safeString(response, 'side');
1423
+ result['market'] = this.safeString(response, 'market');
1424
+ return this.parseOrder(result);
1425
+ }
1248
1426
  /**
1249
1427
  * @method
1250
1428
  * @name upbit#fetchDeposits
1251
- * @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
1429
+ * @see https://docs.upbit.com/kr/reference/입금-리스트-조회
1430
+ * @see https://global-docs.upbit.com/reference/deposit-list-inquiry
1252
1431
  * @description fetch all deposits made to an account
1253
1432
  * @param {string} code unified currency code
1254
1433
  * @param {int} [since] the earliest time in ms to fetch deposits for
@@ -1293,6 +1472,7 @@ export default class upbit extends Exchange {
1293
1472
  * @method
1294
1473
  * @name upbit#fetchDeposit
1295
1474
  * @description fetch information on a deposit
1475
+ * @see https://docs.upbit.com/kr/reference/개별-입금-조회
1296
1476
  * @see https://global-docs.upbit.com/reference/individual-deposit-inquiry
1297
1477
  * @param {string} id the unique id for the deposit
1298
1478
  * @param {string} [code] unified currency code of the currency deposited
@@ -1331,7 +1511,8 @@ export default class upbit extends Exchange {
1331
1511
  /**
1332
1512
  * @method
1333
1513
  * @name upbit#fetchWithdrawals
1334
- * @see https://docs.upbit.com/reference/%EC%A0%84%EC%B2%B4-%EC%B6%9C%EA%B8%88-%EC%A1%B0%ED%9A%8C
1514
+ * @see https://docs.upbit.com/kr/reference/전체-출금-조회
1515
+ * @see https://global-docs.upbit.com/reference/withdrawal-list-inquiry
1335
1516
  * @description fetch all withdrawals made from an account
1336
1517
  * @param {string} code unified currency code
1337
1518
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
@@ -1376,6 +1557,7 @@ export default class upbit extends Exchange {
1376
1557
  * @method
1377
1558
  * @name upbit#fetchWithdrawal
1378
1559
  * @description fetch data on a currency withdrawal via the withdrawal id
1560
+ * @see https://docs.upbit.com/kr/reference/개별-출금-조회
1379
1561
  * @see https://global-docs.upbit.com/reference/individual-withdrawal-inquiry
1380
1562
  * @param {string} id the unique id for the withdrawal
1381
1563
  * @param {string} [code] unified currency code of the currency withdrawn
@@ -1565,6 +1747,26 @@ export default class upbit extends Exchange {
1565
1747
  // "time_in_force": "ioc"
1566
1748
  // }
1567
1749
  //
1750
+ // {
1751
+ // uuid: '63b38774-27db-4439-ac20-1be16a24d18e',
1752
+ // side: 'bid',
1753
+ // ord_type: 'limit',
1754
+ // price: '100000000',
1755
+ // state: 'wait',
1756
+ // market: 'KRW-BTC',
1757
+ // created_at: '2025-04-01T15:30:47+09:00',
1758
+ // volume: '0.00008',
1759
+ // remaining_volume: '0.00008',
1760
+ // reserved_fee: '4',
1761
+ // remaining_fee: '4',
1762
+ // paid_fee: '0',
1763
+ // locked: '8004',
1764
+ // executed_volume: '0',
1765
+ // trades_count: '0',
1766
+ // identifier: '21',
1767
+ // new_order_uuid: 'cb1cce56-6237-4a78-bc11-4cfffc1bb4c2',
1768
+ // new_order_identifier: '22'
1769
+ // }
1568
1770
  const id = this.safeString(order, 'uuid');
1569
1771
  let side = this.safeString(order, 'side');
1570
1772
  if (side === 'bid') {
@@ -1573,6 +1775,7 @@ export default class upbit extends Exchange {
1573
1775
  else {
1574
1776
  side = 'sell';
1575
1777
  }
1778
+ const identifier = this.safeString(order, 'identifier');
1576
1779
  let type = this.safeString(order, 'ord_type');
1577
1780
  const timestamp = this.parse8601(this.safeString(order, 'created_at'));
1578
1781
  const status = this.parseOrderStatus(this.safeString(order, 'state'));
@@ -1629,7 +1832,7 @@ export default class upbit extends Exchange {
1629
1832
  return this.safeOrder({
1630
1833
  'info': order,
1631
1834
  'id': id,
1632
- 'clientOrderId': undefined,
1835
+ 'clientOrderId': identifier,
1633
1836
  'timestamp': timestamp,
1634
1837
  'datetime': this.iso8601(timestamp),
1635
1838
  'lastTradeTimestamp': lastTradeTimestamp,
@@ -1654,6 +1857,7 @@ export default class upbit extends Exchange {
1654
1857
  * @method
1655
1858
  * @name upbit#fetchOpenOrders
1656
1859
  * @description fetch all unfilled currently open orders
1860
+ * @see https://docs.upbit.com/kr/reference/대기-주문-조회
1657
1861
  * @see https://global-docs.upbit.com/reference/open-order
1658
1862
  * @param {string} symbol unified market symbol
1659
1863
  * @param {int} [since] the earliest time in ms to fetch open orders for
@@ -1702,6 +1906,7 @@ export default class upbit extends Exchange {
1702
1906
  * @method
1703
1907
  * @name upbit#fetchClosedOrders
1704
1908
  * @description fetches information on multiple closed orders made by the user
1909
+ * @see https://docs.upbit.com/kr/reference/종료-주문-조회
1705
1910
  * @see https://global-docs.upbit.com/reference/closed-order
1706
1911
  * @param {string} symbol unified market symbol of the market orders were made in
1707
1912
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -1757,6 +1962,7 @@ export default class upbit extends Exchange {
1757
1962
  * @method
1758
1963
  * @name upbit#fetchCanceledOrders
1759
1964
  * @description fetches information on multiple canceled orders made by the user
1965
+ * @see https://docs.upbit.com/kr/reference/종료-주문-조회
1760
1966
  * @see https://global-docs.upbit.com/reference/closed-order
1761
1967
  * @param {string} symbol unified market symbol of the market orders were made in
1762
1968
  * @param {int} [since] timestamp in ms of the earliest order, default is undefined
@@ -1811,7 +2017,8 @@ export default class upbit extends Exchange {
1811
2017
  /**
1812
2018
  * @method
1813
2019
  * @name upbit#fetchOrder
1814
- * @see https://docs.upbit.com/reference/%EA%B0%9C%EB%B3%84-%EC%A3%BC%EB%AC%B8-%EC%A1%B0%ED%9A%8C
2020
+ * @see https://docs.upbit.com/kr/reference/개별-주문-조회
2021
+ * @see https://global-docs.upbit.com/reference/individual-order-inquiry
1815
2022
  * @description fetches information on an order made by the user
1816
2023
  * @param {string} id order id
1817
2024
  * @param {string} symbol not used by upbit fetchOrder
@@ -1872,7 +2079,8 @@ export default class upbit extends Exchange {
1872
2079
  /**
1873
2080
  * @method
1874
2081
  * @name upbit#fetchDepositAddresses
1875
- * @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
2082
+ * @see https://docs.upbit.com/kr/reference/전체-입금-주소-조회
2083
+ * @see https://global-docs.upbit.com/reference/general-deposit-address-inquiry
1876
2084
  * @description fetch deposit addresses for multiple currencies and chain types
1877
2085
  * @param {string[]|undefined} codes list of unified currency codes, default is undefined
1878
2086
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1928,7 +2136,8 @@ export default class upbit extends Exchange {
1928
2136
  /**
1929
2137
  * @method
1930
2138
  * @name upbit#fetchDepositAddress
1931
- * @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
2139
+ * @see https://docs.upbit.com/kr/reference/개별-입금-주소-조회
2140
+ * @see https://global-docs.upbit.com/reference/individual-deposit-address-inquiry
1932
2141
  * @description fetch the deposit address for a currency associated with this account
1933
2142
  * @param {string} code unified currency code
1934
2143
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1960,7 +2169,8 @@ export default class upbit extends Exchange {
1960
2169
  /**
1961
2170
  * @method
1962
2171
  * @name upbit#createDepositAddress
1963
- * @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
2172
+ * @see https://docs.upbit.com/kr/reference/입금-주소-생성-요청
2173
+ * @see https://global-docs.upbit.com/reference/deposit-address-generation
1964
2174
  * @description create a currency deposit address
1965
2175
  * @param {string} code unified currency code of the currency for the deposit address
1966
2176
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1998,8 +2208,8 @@ export default class upbit extends Exchange {
1998
2208
  /**
1999
2209
  * @method
2000
2210
  * @name upbit#withdraw
2001
- * @see https://docs.upbit.com/reference/디지털자산-출금하기
2002
- * @see https://docs.upbit.com/reference/%EC%9B%90%ED%99%94-%EC%B6%9C%EA%B8%88%ED%95%98%EA%B8%B0
2211
+ * @see https://docs.upbit.com/kr/reference/디지털자산-출금하기
2212
+ * @see https://global-docs.upbit.com/reference/withdrawal-digital-assets
2003
2213
  * @description make a withdrawal
2004
2214
  * @param {string} code unified currency code
2005
2215
  * @param {float} amount the amount to withdraw
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/vertex.js';
2
- import type { Market, Ticker, Tickers, TradingFees, Balances, Int, OrderBook, OHLCV, Str, Order, OrderType, OrderSide, Trade, Strings, Dict, Num, Currencies, FundingRate, FundingRates, Currency, Transaction, OpenInterests } from './base/types.js';
2
+ import type { Market, Ticker, Tickers, TradingFees, Balances, Int, OrderBook, OHLCV, Str, Order, OrderType, OrderSide, Trade, Strings, Dict, Num, Currencies, FundingRate, FundingRates, Currency, Transaction, OpenInterests, Position } from './base/types.js';
3
3
  /**
4
4
  * @class vertex
5
5
  * @augments Exchange
@@ -307,7 +307,7 @@ export default class vertex extends Exchange {
307
307
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
308
308
  */
309
309
  fetchBalance(params?: {}): Promise<Balances>;
310
- parsePosition(position: any, market?: Market): import("./base/types.js").Position;
310
+ parsePosition(position: any, market?: Market): Position;
311
311
  /**
312
312
  * @method
313
313
  * @name vertex#fetchPositions
@@ -318,7 +318,7 @@ export default class vertex extends Exchange {
318
318
  * @param {string} [params.user] user address, will default to this.walletAddress if not provided
319
319
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
320
320
  */
321
- fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
321
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
322
322
  queryNonces(): Promise<import("./base/types.js").Dictionary<any>>;
323
323
  /**
324
324
  * @method