ccxt 4.2.12 → 4.2.14

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 (81) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1338 -366
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/js/ccxt.js +1 -1
  6. package/dist/cjs/js/src/base/Exchange.js +148 -1
  7. package/dist/cjs/js/src/bigone.js +125 -54
  8. package/dist/cjs/js/src/binance.js +142 -27
  9. package/dist/cjs/js/src/binanceus.js +8 -0
  10. package/dist/cjs/js/src/bingx.js +110 -36
  11. package/dist/cjs/js/src/bitget.js +17 -6
  12. package/dist/cjs/js/src/bitmart.js +3 -3
  13. package/dist/cjs/js/src/bybit.js +5 -1
  14. package/dist/cjs/js/src/coinbase.js +176 -26
  15. package/dist/cjs/js/src/coinex.js +3 -0
  16. package/dist/cjs/js/src/coinlist.js +1 -1
  17. package/dist/cjs/js/src/coinone.js +1 -1
  18. package/dist/cjs/js/src/delta.js +7 -1
  19. package/dist/cjs/js/src/deribit.js +1 -1
  20. package/dist/cjs/js/src/gate.js +79 -56
  21. package/dist/cjs/js/src/gemini.js +1 -1
  22. package/dist/cjs/js/src/htx.js +151 -1
  23. package/dist/cjs/js/src/independentreserve.js +7 -5
  24. package/dist/cjs/js/src/kraken.js +22 -14
  25. package/dist/cjs/js/src/kucoin.js +5 -0
  26. package/dist/cjs/js/src/kucoinfutures.js +131 -77
  27. package/dist/cjs/js/src/lbank.js +59 -33
  28. package/dist/cjs/js/src/oceanex.js +1 -1
  29. package/dist/cjs/js/src/okx.js +11 -9
  30. package/dist/cjs/js/src/phemex.js +9 -2
  31. package/dist/cjs/js/src/pro/kraken.js +1 -1
  32. package/dist/cjs/js/src/pro/okx.js +52 -2
  33. package/dist/cjs/js/src/probit.js +4 -2
  34. package/dist/cjs/js/src/wavesexchange.js +1 -1
  35. package/dist/cjs/js/src/woo.js +56 -2
  36. package/js/ccxt.d.ts +1 -1
  37. package/js/ccxt.js +1 -1
  38. package/js/src/abstract/bigone.d.ts +1 -0
  39. package/js/src/abstract/bingx.d.ts +2 -0
  40. package/js/src/abstract/kucoin.d.ts +4 -0
  41. package/js/src/abstract/kucoinfutures.d.ts +4 -0
  42. package/js/src/abstract/okx.d.ts +1 -0
  43. package/js/src/base/Exchange.d.ts +8 -0
  44. package/js/src/base/Exchange.js +148 -1
  45. package/js/src/bigone.d.ts +2 -0
  46. package/js/src/bigone.js +125 -54
  47. package/js/src/binance.d.ts +9 -0
  48. package/js/src/binance.js +142 -27
  49. package/js/src/binanceus.js +8 -0
  50. package/js/src/bingx.js +110 -36
  51. package/js/src/bitget.js +17 -6
  52. package/js/src/bitmart.js +3 -3
  53. package/js/src/bybit.js +5 -1
  54. package/js/src/coinbase.d.ts +26 -3
  55. package/js/src/coinbase.js +176 -26
  56. package/js/src/coinex.js +3 -0
  57. package/js/src/coinlist.js +1 -1
  58. package/js/src/coinone.js +1 -1
  59. package/js/src/delta.js +7 -1
  60. package/js/src/deribit.js +1 -1
  61. package/js/src/gate.js +79 -56
  62. package/js/src/gemini.js +1 -1
  63. package/js/src/htx.d.ts +10 -0
  64. package/js/src/htx.js +151 -1
  65. package/js/src/independentreserve.js +7 -5
  66. package/js/src/kraken.js +22 -14
  67. package/js/src/kucoin.js +5 -0
  68. package/js/src/kucoinfutures.d.ts +4 -2
  69. package/js/src/kucoinfutures.js +131 -77
  70. package/js/src/lbank.js +59 -33
  71. package/js/src/oceanex.js +1 -1
  72. package/js/src/okx.js +11 -9
  73. package/js/src/phemex.js +9 -2
  74. package/js/src/pro/kraken.js +1 -1
  75. package/js/src/pro/okx.d.ts +1 -0
  76. package/js/src/pro/okx.js +52 -2
  77. package/js/src/probit.js +4 -2
  78. package/js/src/wavesexchange.js +1 -1
  79. package/js/src/woo.d.ts +2 -0
  80. package/js/src/woo.js +56 -2
  81. package/package.json +1 -1
@@ -7352,13 +7352,17 @@ class Exchange {
7352
7352
  'createMarketOrderWithCost': undefined,
7353
7353
  'createMarketSellOrderWithCost': undefined,
7354
7354
  'createOrders': undefined,
7355
+ 'createOrderWithTakeProfitAndStopLoss': undefined,
7355
7356
  'createPostOnlyOrder': undefined,
7356
7357
  'createReduceOnlyOrder': undefined,
7358
+ 'createStopLossOrder': undefined,
7357
7359
  'createStopOrder': undefined,
7358
7360
  'createStopLimitOrder': undefined,
7359
7361
  'createStopMarketOrder': undefined,
7362
+ 'createTakeProfitOrder': undefined,
7360
7363
  'createTrailingAmountOrder': undefined,
7361
7364
  'createTrailingPercentOrder': undefined,
7365
+ 'createTriggerOrder': undefined,
7362
7366
  'createOrderWs': undefined,
7363
7367
  'editOrderWs': undefined,
7364
7368
  'fetchOpenOrdersWs': undefined,
@@ -10861,11 +10865,154 @@ class Exchange {
10861
10865
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10862
10866
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
10863
10867
  */
10864
- if (this.options['createMarketSellOrderRequiresPrice'] || this.options['createMarketSellOrderWithCost']) {
10868
+ if (this.options['createMarketSellOrderRequiresPrice'] || this.has['createMarketSellOrderWithCost']) {
10865
10869
  return await this.createOrder(symbol, 'market', 'sell', cost, 1, params);
10866
10870
  }
10867
10871
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createMarketSellOrderWithCost() is not supported yet');
10868
10872
  }
10873
+ async createTriggerOrder(symbol, type, side, amount, price = undefined, triggerPrice = undefined, params = {}) {
10874
+ /**
10875
+ * @method
10876
+ * @name createTriggerOrder
10877
+ * @description create a trigger stop order (type 1)
10878
+ * @param {string} symbol unified symbol of the market to create an order in
10879
+ * @param {string} type 'market' or 'limit'
10880
+ * @param {string} side 'buy' or 'sell'
10881
+ * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10882
+ * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10883
+ * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
10884
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
10885
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
10886
+ */
10887
+ if (triggerPrice === undefined) {
10888
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' createTriggerOrder() requires a triggerPrice argument');
10889
+ }
10890
+ params['triggerPrice'] = triggerPrice;
10891
+ if (this.has['createTriggerOrder']) {
10892
+ return await this.createOrder(symbol, type, side, amount, price, params);
10893
+ }
10894
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createTriggerOrder() is not supported yet');
10895
+ }
10896
+ async createStopLossOrder(symbol, type, side, amount, price = undefined, stopLossPrice = undefined, params = {}) {
10897
+ /**
10898
+ * @method
10899
+ * @name createStopLossOrder
10900
+ * @description create a trigger stop loss order (type 2)
10901
+ * @param {string} symbol unified symbol of the market to create an order in
10902
+ * @param {string} type 'market' or 'limit'
10903
+ * @param {string} side 'buy' or 'sell'
10904
+ * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10905
+ * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10906
+ * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
10907
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
10908
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
10909
+ */
10910
+ if (stopLossPrice === undefined) {
10911
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' createStopLossOrder() requires a stopLossPrice argument');
10912
+ }
10913
+ params['stopLossPrice'] = stopLossPrice;
10914
+ if (this.has['createStopLossOrder']) {
10915
+ return await this.createOrder(symbol, type, side, amount, price, params);
10916
+ }
10917
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createStopLossOrder() is not supported yet');
10918
+ }
10919
+ async createTakeProfitOrder(symbol, type, side, amount, price = undefined, takeProfitPrice = undefined, params = {}) {
10920
+ /**
10921
+ * @method
10922
+ * @name createTakeProfitOrder
10923
+ * @description create a trigger take profit order (type 2)
10924
+ * @param {string} symbol unified symbol of the market to create an order in
10925
+ * @param {string} type 'market' or 'limit'
10926
+ * @param {string} side 'buy' or 'sell'
10927
+ * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10928
+ * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10929
+ * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
10930
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
10931
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
10932
+ */
10933
+ if (takeProfitPrice === undefined) {
10934
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' createTakeProfitOrder() requires a takeProfitPrice argument');
10935
+ }
10936
+ params['takeProfitPrice'] = takeProfitPrice;
10937
+ if (this.has['createTakeProfitOrder']) {
10938
+ return await this.createOrder(symbol, type, side, amount, price, params);
10939
+ }
10940
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createTakeProfitOrder() is not supported yet');
10941
+ }
10942
+ async createOrderWithTakeProfitAndStopLoss(symbol, type, side, amount, price = undefined, takeProfit = undefined, stopLoss = undefined, params = {}) {
10943
+ /**
10944
+ * @method
10945
+ * @name createOrderWithTakeProfitAndStopLoss
10946
+ * @description create an order with a stop loss or take profit attached (type 3)
10947
+ * @param {string} symbol unified symbol of the market to create an order in
10948
+ * @param {string} type 'market' or 'limit'
10949
+ * @param {string} side 'buy' or 'sell'
10950
+ * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
10951
+ * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
10952
+ * @param {float} [takeProfit] the take profit price, in units of the quote currency
10953
+ * @param {float} [stopLoss] the stop loss price, in units of the quote currency
10954
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
10955
+ * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
10956
+ * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
10957
+ * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
10958
+ * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
10959
+ * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
10960
+ * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
10961
+ * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
10962
+ * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
10963
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
10964
+ */
10965
+ if ((takeProfit === undefined) && (stopLoss === undefined)) {
10966
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument');
10967
+ }
10968
+ if (takeProfit !== undefined) {
10969
+ params['takeProfit'] = {
10970
+ 'triggerPrice': takeProfit,
10971
+ };
10972
+ }
10973
+ if (stopLoss !== undefined) {
10974
+ params['stopLoss'] = {
10975
+ 'triggerPrice': stopLoss,
10976
+ };
10977
+ }
10978
+ const takeProfitType = this.safeString(params, 'takeProfitType');
10979
+ const takeProfitPriceType = this.safeString(params, 'takeProfitPriceType');
10980
+ const takeProfitLimitPrice = this.safeString(params, 'takeProfitLimitPrice');
10981
+ const takeProfitAmount = this.safeString(params, 'takeProfitAmount');
10982
+ const stopLossType = this.safeString(params, 'stopLossType');
10983
+ const stopLossPriceType = this.safeString(params, 'stopLossPriceType');
10984
+ const stopLossLimitPrice = this.safeString(params, 'stopLossLimitPrice');
10985
+ const stopLossAmount = this.safeString(params, 'stopLossAmount');
10986
+ if (takeProfitType !== undefined) {
10987
+ params['takeProfit']['type'] = takeProfitType;
10988
+ }
10989
+ if (takeProfitPriceType !== undefined) {
10990
+ params['takeProfit']['priceType'] = takeProfitPriceType;
10991
+ }
10992
+ if (takeProfitLimitPrice !== undefined) {
10993
+ params['takeProfit']['price'] = this.parseToNumeric(takeProfitLimitPrice);
10994
+ }
10995
+ if (takeProfitAmount !== undefined) {
10996
+ params['takeProfit']['amount'] = this.parseToNumeric(takeProfitAmount);
10997
+ }
10998
+ if (stopLossType !== undefined) {
10999
+ params['stopLoss']['type'] = stopLossType;
11000
+ }
11001
+ if (stopLossPriceType !== undefined) {
11002
+ params['stopLoss']['priceType'] = stopLossPriceType;
11003
+ }
11004
+ if (stopLossLimitPrice !== undefined) {
11005
+ params['stopLoss']['price'] = this.parseToNumeric(stopLossLimitPrice);
11006
+ }
11007
+ if (stopLossAmount !== undefined) {
11008
+ params['stopLoss']['amount'] = this.parseToNumeric(stopLossAmount);
11009
+ }
11010
+ params = this.omit(params, ['takeProfitType', 'takeProfitPriceType', 'takeProfitLimitPrice', 'takeProfitAmount', 'stopLossType', 'stopLossPriceType', 'stopLossLimitPrice', 'stopLossAmount']);
11011
+ if (this.has['createOrderWithTakeProfitAndStopLoss']) {
11012
+ return await this.createOrder(symbol, type, side, amount, price, params);
11013
+ }
11014
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrderWithTakeProfitAndStopLoss() is not supported yet');
11015
+ }
10869
11016
  async createOrders(orders, params = {}) {
10870
11017
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' createOrders() is not supported yet');
10871
11018
  }
@@ -15453,6 +15600,7 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
15453
15600
  },
15454
15601
  'contractPublic': {
15455
15602
  'get': [
15603
+ 'symbols',
15456
15604
  'instruments',
15457
15605
  'depth@{symbol}/snapshot',
15458
15606
  'instruments/difference',
@@ -15848,7 +15996,10 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
15848
15996
  * @param {object} [params] extra parameters specific to the exchange API endpoint
15849
15997
  * @returns {object[]} an array of objects representing market data
15850
15998
  */
15851
- const response = await this.publicGetAssetPairs(params);
15999
+ const promises = [this.publicGetAssetPairs(params), this.contractPublicGetSymbols(params)];
16000
+ const promisesResult = await Promise.all(promises);
16001
+ const response = promisesResult[0];
16002
+ const contractResponse = promisesResult[1];
15852
16003
  //
15853
16004
  // {
15854
16005
  // "code":0,
@@ -15874,29 +16025,30 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
15874
16025
  // ]
15875
16026
  // }
15876
16027
  //
15877
- const contractResponse = await this.contractPublicGetInstruments(params);
15878
16028
  //
15879
16029
  // [
15880
16030
  // {
15881
- // "usdtPrice": 1.00031998,
16031
+ // "baseCurrency": "BTC",
16032
+ // "multiplier": 1,
16033
+ // "enable": true,
16034
+ // "priceStep": 0.5,
16035
+ // "maxRiskLimit": 1000,
16036
+ // "pricePrecision": 1,
16037
+ // "maintenanceMargin": 0.00500,
15882
16038
  // "symbol": "BTCUSD",
15883
- // "btcPrice": 34700.4,
15884
- // "ethPrice": 1787.83,
15885
- // "nextFundingRate": 0.00010,
15886
- // "fundingRate": 0.00010,
15887
- // "latestPrice": 34708.5,
15888
- // "last24hPriceChange": 0.0321,
15889
- // "indexPrice": 34700.4,
15890
- // "volume24h": 261319063,
15891
- // "turnover24h": 8204.129380685496,
15892
- // "nextFundingTime": 1698285600000,
15893
- // "markPrice": 34702.4646738,
15894
- // "last24hMaxPrice": 35127.5,
15895
- // "volume24hInUsd": 0.0,
15896
- // "openValue": 32.88054722085945,
15897
- // "last24hMinPrice": 33552.0,
15898
- // "openInterest": 1141372.0
15899
- // }
16039
+ // "valuePrecision": 4,
16040
+ // "minRiskLimit": 100,
16041
+ // "riskLimit": 100,
16042
+ // "isInverse": true,
16043
+ // "riskStep": 1,
16044
+ // "settleCurrency": "BTC",
16045
+ // "baseName": "Bitcoin",
16046
+ // "feePrecision": 8,
16047
+ // "priceMin": 0.5,
16048
+ // "priceMax": 1E+6,
16049
+ // "initialMargin": 0.01000,
16050
+ // "quoteCurrency": "USD"
16051
+ // },
15900
16052
  // ...
15901
16053
  // ]
15902
16054
  //
@@ -15963,15 +16115,14 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
15963
16115
  }
15964
16116
  for (let i = 0; i < contractResponse.length; i++) {
15965
16117
  const market = contractResponse[i];
16118
+ const baseId = this.safeString(market, 'baseCurrency');
16119
+ const quoteId = this.safeString(market, 'quoteCurrency');
16120
+ const settleId = this.safeString(market, 'settleCurrency');
15966
16121
  const marketId = this.safeString(market, 'symbol');
15967
- const index = marketId.indexOf('USD');
15968
- const baseId = marketId.slice(0, index);
15969
- const quoteId = marketId.slice(index);
15970
- const inverse = (quoteId === 'USD');
15971
- const settleId = inverse ? baseId : quoteId;
15972
16122
  const base = this.safeCurrencyCode(baseId);
15973
16123
  const quote = this.safeCurrencyCode(quoteId);
15974
16124
  const settle = this.safeCurrencyCode(settleId);
16125
+ const inverse = this.safeValue(market, 'isInverse');
15975
16126
  result.push(this.safeMarketStructure({
15976
16127
  'id': marketId,
15977
16128
  'symbol': base + '/' + quote + ':' + settle,
@@ -15987,18 +16138,18 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
15987
16138
  'swap': true,
15988
16139
  'future': false,
15989
16140
  'option': false,
15990
- 'active': true,
16141
+ 'active': this.safeValue(market, 'enable'),
15991
16142
  'contract': true,
15992
16143
  'linear': !inverse,
15993
16144
  'inverse': inverse,
15994
- 'contractSize': 1,
16145
+ 'contractSize': this.safeNumber(market, 'multiplier'),
15995
16146
  'expiry': undefined,
15996
16147
  'expiryDatetime': undefined,
15997
16148
  'strike': undefined,
15998
16149
  'optionType': undefined,
15999
16150
  'precision': {
16000
- 'amount': undefined,
16001
- 'price': undefined,
16151
+ 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'valuePrecision'))),
16152
+ 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision'))),
16002
16153
  },
16003
16154
  'limits': {
16004
16155
  'leverage': {
@@ -16010,11 +16161,11 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
16010
16161
  'max': undefined,
16011
16162
  },
16012
16163
  'price': {
16013
- 'min': undefined,
16014
- 'max': undefined,
16164
+ 'min': this.safeNumber(market, 'priceMin'),
16165
+ 'max': this.safeNumber(market, 'priceMax'),
16015
16166
  },
16016
16167
  'cost': {
16017
- 'min': undefined,
16168
+ 'min': this.safeNumber(market, 'initialMargin'),
16018
16169
  'max': undefined,
16019
16170
  },
16020
16171
  },
@@ -16260,29 +16411,90 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
16260
16411
  */
16261
16412
  await this.loadMarkets();
16262
16413
  const market = this.market(symbol);
16263
- const request = {
16264
- 'asset_pair_name': market['id'],
16265
- };
16266
- if (limit !== undefined) {
16267
- request['limit'] = limit; // default 50, max 200
16414
+ let response = undefined;
16415
+ if (market['contract']) {
16416
+ const request = {
16417
+ 'symbol': market['id'],
16418
+ };
16419
+ response = await this.contractPublicGetDepthSymbolSnapshot(this.extend(request, params));
16420
+ //
16421
+ // {
16422
+ // bids: {
16423
+ // '20000': '20',
16424
+ // ...
16425
+ // '34552': '64851',
16426
+ // '34526.5': '59594',
16427
+ // ...
16428
+ // '34551.5': '29711'
16429
+ // },
16430
+ // asks: {
16431
+ // '34557': '34395',
16432
+ // ...
16433
+ // '40000': '20',
16434
+ // '34611.5': '56024',
16435
+ // ...
16436
+ // '34578.5': '66367'
16437
+ // },
16438
+ // to: '59737174',
16439
+ // lastPrice: '34554.5',
16440
+ // bestPrices: {
16441
+ // ask: '34557.0',
16442
+ // bid: '34552.0'
16443
+ // },
16444
+ // from: '0'
16445
+ // }
16446
+ //
16447
+ return this.parseContractOrderBook(response, market['symbol'], limit);
16448
+ }
16449
+ else {
16450
+ const request = {
16451
+ 'asset_pair_name': market['id'],
16452
+ };
16453
+ if (limit !== undefined) {
16454
+ request['limit'] = limit; // default 50, max 200
16455
+ }
16456
+ response = await this.publicGetAssetPairsAssetPairNameDepth(this.extend(request, params));
16457
+ //
16458
+ // {
16459
+ // "code":0,
16460
+ // "data": {
16461
+ // "asset_pair_name": "EOS-BTC",
16462
+ // "bids": [
16463
+ // { "price": "42", "order_count": 4, "quantity": "23.33363711" }
16464
+ // ],
16465
+ // "asks": [
16466
+ // { "price": "45", "order_count": 2, "quantity": "4193.3283464" }
16467
+ // ]
16468
+ // }
16469
+ // }
16470
+ //
16471
+ const orderbook = this.safeValue(response, 'data', {});
16472
+ return this.parseOrderBook(orderbook, market['symbol'], undefined, 'bids', 'asks', 'price', 'quantity');
16268
16473
  }
16269
- const response = await this.publicGetAssetPairsAssetPairNameDepth(this.extend(request, params));
16270
- //
16271
- // {
16272
- // "code":0,
16273
- // "data": {
16274
- // "asset_pair_name": "EOS-BTC",
16275
- // "bids": [
16276
- // { "price": "42", "order_count": 4, "quantity": "23.33363711" }
16277
- // ],
16278
- // "asks": [
16279
- // { "price": "45", "order_count": 2, "quantity": "4193.3283464" }
16280
- // ]
16281
- // }
16282
- // }
16283
- //
16284
- const orderbook = this.safeValue(response, 'data', {});
16285
- return this.parseOrderBook(orderbook, market['symbol'], undefined, 'bids', 'asks', 'price', 'quantity');
16474
+ }
16475
+ parseContractBidsAsks(bidsAsks) {
16476
+ const bidsAsksKeys = Object.keys(bidsAsks);
16477
+ const result = [];
16478
+ for (let i = 0; i < bidsAsksKeys.length; i++) {
16479
+ const price = bidsAsksKeys[i];
16480
+ const amount = bidsAsks[price];
16481
+ result.push([this.parseNumber(price), this.parseNumber(amount)]);
16482
+ }
16483
+ return result;
16484
+ }
16485
+ parseContractOrderBook(orderbook, symbol, limit = undefined) {
16486
+ const responseBids = this.safeValue(orderbook, 'bids');
16487
+ const responseAsks = this.safeValue(orderbook, 'asks');
16488
+ const bids = this.parseContractBidsAsks(responseBids);
16489
+ const asks = this.parseContractBidsAsks(responseAsks);
16490
+ return {
16491
+ 'symbol': symbol,
16492
+ 'bids': this.filterByLimit(this.sortBy(bids, 0, true), limit),
16493
+ 'asks': this.filterByLimit(this.sortBy(asks, 0), limit),
16494
+ 'timestamp': undefined,
16495
+ 'datetime': undefined,
16496
+ 'nonce': undefined,
16497
+ };
16286
16498
  }
16287
16499
  parseTrade(trade, market = undefined) {
16288
16500
  //
@@ -16442,6 +16654,9 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
16442
16654
  */
16443
16655
  await this.loadMarkets();
16444
16656
  const market = this.market(symbol);
16657
+ if (market['contract']) {
16658
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchTrades () can only fetch trades for spot markets');
16659
+ }
16445
16660
  const request = {
16446
16661
  'asset_pair_name': market['id'],
16447
16662
  };
@@ -16504,6 +16719,9 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
16504
16719
  */
16505
16720
  await this.loadMarkets();
16506
16721
  const market = this.market(symbol);
16722
+ if (market['contract']) {
16723
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOHLCV () can only fetch ohlcvs for spot markets');
16724
+ }
16507
16725
  if (limit === undefined) {
16508
16726
  limit = 100; // default 100, max 500
16509
16727
  }
@@ -17528,7 +17746,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17528
17746
  'createMarketBuyOrderWithCost': true,
17529
17747
  'createMarketOrderWithCost': true,
17530
17748
  'createMarketSellOrderWithCost': true,
17531
- 'createTrailingPercentOrder': true,
17532
17749
  'createOrder': true,
17533
17750
  'createOrders': true,
17534
17751
  'createPostOnlyOrder': true,
@@ -17536,6 +17753,10 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17536
17753
  'createStopLimitOrder': true,
17537
17754
  'createStopMarketOrder': false,
17538
17755
  'createStopOrder': true,
17756
+ 'createTrailingPercentOrder': true,
17757
+ 'createTriggerOrder': true,
17758
+ 'createTakeProfitOrder': true,
17759
+ 'createStopLossOrder': true,
17539
17760
  'editOrder': true,
17540
17761
  'fetchAccounts': undefined,
17541
17762
  'fetchBalance': true,
@@ -17566,6 +17787,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17566
17787
  'fetchIsolatedBorrowRate': false,
17567
17788
  'fetchIsolatedBorrowRates': false,
17568
17789
  'fetchL3OrderBook': false,
17790
+ 'fetchLastPrices': true,
17569
17791
  'fetchLedger': true,
17570
17792
  'fetchLeverage': false,
17571
17793
  'fetchLeverageTiers': true,
@@ -20641,6 +20863,110 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20641
20863
  }
20642
20864
  return this.parseTickers(response, symbols);
20643
20865
  }
20866
+ async fetchLastPrices(symbols = undefined, params = {}) {
20867
+ /**
20868
+ * @method
20869
+ * @name binance#fetchLastPrices
20870
+ * @description fetches the last price for multiple markets
20871
+ * @see https://binance-docs.github.io/apidocs/spot/en/#symbol-price-ticker // spot
20872
+ * @see https://binance-docs.github.io/apidocs/future/en/#symbol-price-ticker // swap
20873
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#symbol-price-ticker // future
20874
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
20875
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
20876
+ * @returns {object} a dictionary of lastprices structures
20877
+ */
20878
+ await this.loadMarkets();
20879
+ symbols = this.marketSymbols(symbols);
20880
+ const market = this.getMarketFromSymbols(symbols);
20881
+ let type = undefined;
20882
+ let subType = undefined;
20883
+ [subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
20884
+ [type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
20885
+ let response = undefined;
20886
+ if (this.isLinear(type, subType)) {
20887
+ response = await this.fapiPublicV2GetTickerPrice(params);
20888
+ //
20889
+ // [
20890
+ // {
20891
+ // "symbol": "LTCBTC",
20892
+ // "price": "4.00000200"
20893
+ // "time": 1589437530011
20894
+ // },
20895
+ // ...
20896
+ // ]
20897
+ //
20898
+ }
20899
+ else if (this.isInverse(type, subType)) {
20900
+ response = await this.dapiPublicGetTickerPrice(params);
20901
+ //
20902
+ // [
20903
+ // {
20904
+ // "symbol": "BTCUSD_200626",
20905
+ // "ps": "9647.8",
20906
+ // "price": "9647.8",
20907
+ // "time": 1591257246176
20908
+ // }
20909
+ // ]
20910
+ //
20911
+ }
20912
+ else if (type === 'spot') {
20913
+ response = await this.publicGetTickerPrice(params);
20914
+ //
20915
+ // [
20916
+ // {
20917
+ // "symbol": "LTCBTC",
20918
+ // "price": "4.00000200"
20919
+ // },
20920
+ // ...
20921
+ // ]
20922
+ //
20923
+ }
20924
+ else {
20925
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
20926
+ }
20927
+ return this.parseLastPrices(response, symbols);
20928
+ }
20929
+ parseLastPrice(entry, market = undefined) {
20930
+ //
20931
+ // spot
20932
+ //
20933
+ // {
20934
+ // "symbol": "LTCBTC",
20935
+ // "price": "4.00000200"
20936
+ // }
20937
+ //
20938
+ // usdm (swap/future)
20939
+ //
20940
+ // {
20941
+ // "symbol": "BTCUSDT",
20942
+ // "price": "6000.01",
20943
+ // "time": 1589437530011 // Transaction time
20944
+ // }
20945
+ //
20946
+ //
20947
+ // coinm (swap/future)
20948
+ //
20949
+ // {
20950
+ // "symbol": "BTCUSD_200626", // symbol ("BTCUSD_200626", "BTCUSD_PERP", etc..)
20951
+ // "ps": "BTCUSD", // pair
20952
+ // "price": "9647.8",
20953
+ // "time": 1591257246176
20954
+ // }
20955
+ //
20956
+ const timestamp = this.safeInteger(entry, 'time');
20957
+ const type = (timestamp === undefined) ? 'spot' : 'swap';
20958
+ const marketId = this.safeString(entry, 'symbol');
20959
+ market = this.safeMarket(marketId, market, undefined, type);
20960
+ const price = this.safeNumber(entry, 'price');
20961
+ return {
20962
+ 'symbol': market['symbol'],
20963
+ 'timestamp': timestamp,
20964
+ 'datetime': this.iso8601(timestamp),
20965
+ 'price': price,
20966
+ 'side': undefined,
20967
+ 'info': entry,
20968
+ };
20969
+ }
20644
20970
  async fetchTickers(symbols = undefined, params = {}) {
20645
20971
  /**
20646
20972
  * @method
@@ -23589,12 +23915,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23589
23915
  * @name binance#transfer
23590
23916
  * @description transfer currency internally between wallets on the same account
23591
23917
  * @see https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer-user_data
23592
- * @see https://binance-docs.github.io/apidocs/spot/en/#isolated-margin-account-transfer-margin
23593
23918
  * @param {string} code unified currency code
23594
23919
  * @param {float} amount amount to transfer
23595
23920
  * @param {string} fromAccount account to transfer from
23596
23921
  * @param {string} toAccount account to transfer to
23597
23922
  * @param {object} [params] extra parameters specific to the exchange API endpoint
23923
+ * @param {string} [params.type] exchange specific transfer type
23924
+ * @param {string} [params.symbol] the unified symbol, required for isolated margin transfers
23598
23925
  * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
23599
23926
  */
23600
23927
  await this.loadMarkets();
@@ -23605,76 +23932,82 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23605
23932
  };
23606
23933
  request['type'] = this.safeString(params, 'type');
23607
23934
  params = this.omit(params, 'type');
23608
- let response = undefined;
23609
23935
  if (request['type'] === undefined) {
23610
23936
  const symbol = this.safeString(params, 'symbol');
23937
+ let market = undefined;
23611
23938
  if (symbol !== undefined) {
23939
+ market = this.market(symbol);
23612
23940
  params = this.omit(params, 'symbol');
23613
23941
  }
23614
23942
  let fromId = this.convertTypeToAccount(fromAccount).toUpperCase();
23615
23943
  let toId = this.convertTypeToAccount(toAccount).toUpperCase();
23944
+ let isolatedSymbol = undefined;
23945
+ if (market !== undefined) {
23946
+ isolatedSymbol = market['id'];
23947
+ }
23616
23948
  if (fromId === 'ISOLATED') {
23617
23949
  if (symbol === undefined) {
23618
23950
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' transfer () requires params["symbol"] when fromAccount is ' + fromAccount);
23619
23951
  }
23620
- else {
23621
- fromId = this.marketId(symbol);
23622
- }
23623
23952
  }
23624
23953
  if (toId === 'ISOLATED') {
23625
23954
  if (symbol === undefined) {
23626
23955
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' transfer () requires params["symbol"] when toAccount is ' + toAccount);
23627
23956
  }
23628
- else {
23629
- toId = this.marketId(symbol);
23630
- }
23631
23957
  }
23632
23958
  const accountsById = this.safeValue(this.options, 'accountsById', {});
23633
23959
  const fromIsolated = !(fromId in accountsById);
23634
23960
  const toIsolated = !(toId in accountsById);
23961
+ if (fromIsolated && (market === undefined)) {
23962
+ isolatedSymbol = fromId; // allow user provide symbol as the from/to account
23963
+ }
23964
+ if (toIsolated && (market === undefined)) {
23965
+ isolatedSymbol = toId;
23966
+ }
23635
23967
  if (fromIsolated || toIsolated) { // Isolated margin transfer
23636
23968
  const fromFuture = fromId === 'UMFUTURE' || fromId === 'CMFUTURE';
23637
23969
  const toFuture = toId === 'UMFUTURE' || toId === 'CMFUTURE';
23638
23970
  const fromSpot = fromId === 'MAIN';
23639
23971
  const toSpot = toId === 'MAIN';
23640
23972
  const funding = fromId === 'FUNDING' || toId === 'FUNDING';
23641
- const mining = fromId === 'MINING' || toId === 'MINING';
23642
23973
  const option = fromId === 'OPTION' || toId === 'OPTION';
23643
- const prohibitedWithIsolated = fromFuture || toFuture || mining || funding || option;
23974
+ const prohibitedWithIsolated = fromFuture || toFuture || funding || option;
23644
23975
  if ((fromIsolated || toIsolated) && prohibitedWithIsolated) {
23645
23976
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' transfer () does not allow transfers between ' + fromAccount + ' and ' + toAccount);
23646
23977
  }
23647
23978
  else if (toSpot && fromIsolated) {
23648
- request['transFrom'] = 'ISOLATED_MARGIN';
23649
- request['transTo'] = 'SPOT';
23650
- request['symbol'] = fromId;
23651
- response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
23979
+ fromId = 'ISOLATED_MARGIN';
23980
+ request['fromSymbol'] = isolatedSymbol;
23652
23981
  }
23653
23982
  else if (fromSpot && toIsolated) {
23654
- request['transFrom'] = 'SPOT';
23655
- request['transTo'] = 'ISOLATED_MARGIN';
23656
- request['symbol'] = toId;
23657
- response = await this.sapiPostMarginIsolatedTransfer(this.extend(request, params));
23983
+ toId = 'ISOLATED_MARGIN';
23984
+ request['toSymbol'] = isolatedSymbol;
23658
23985
  }
23659
23986
  else {
23660
- if (fromIsolated) {
23987
+ if (fromIsolated && toIsolated) {
23661
23988
  request['fromSymbol'] = fromId;
23662
- fromId = 'ISOLATEDMARGIN';
23663
- }
23664
- if (toIsolated) {
23665
23989
  request['toSymbol'] = toId;
23990
+ fromId = 'ISOLATEDMARGIN';
23666
23991
  toId = 'ISOLATEDMARGIN';
23667
23992
  }
23668
- request['type'] = fromId + '_' + toId;
23993
+ else {
23994
+ if (fromIsolated) {
23995
+ request['fromSymbol'] = isolatedSymbol;
23996
+ fromId = 'ISOLATEDMARGIN';
23997
+ }
23998
+ if (toIsolated) {
23999
+ request['toSymbol'] = isolatedSymbol;
24000
+ toId = 'ISOLATEDMARGIN';
24001
+ }
24002
+ }
23669
24003
  }
24004
+ request['type'] = fromId + '_' + toId;
23670
24005
  }
23671
24006
  else {
23672
24007
  request['type'] = fromId + '_' + toId;
23673
24008
  }
23674
24009
  }
23675
- if (response === undefined) {
23676
- response = await this.sapiPostAssetTransfer(this.extend(request, params));
23677
- }
24010
+ const response = await this.sapiPostAssetTransfer(this.extend(request, params));
23678
24011
  //
23679
24012
  // {
23680
24013
  // "tranId":13526853623
@@ -27280,6 +27613,7 @@ class binanceus extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
27280
27613
  'id': 'binanceus',
27281
27614
  'name': 'Binance US',
27282
27615
  'countries': ['US'],
27616
+ 'rateLimit': 50,
27283
27617
  'certified': false,
27284
27618
  'pro': true,
27285
27619
  'urls': {
@@ -27347,6 +27681,13 @@ class binanceus extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
27347
27681
  'setMarginMode': false,
27348
27682
  'setPositionMode': false,
27349
27683
  },
27684
+ 'api': {
27685
+ 'public': {
27686
+ 'get': {
27687
+ 'ticker/price': { 'cost': 1, 'noSymbol': 2 },
27688
+ },
27689
+ },
27690
+ },
27350
27691
  });
27351
27692
  }
27352
27693
  }
@@ -27467,6 +27808,10 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27467
27808
  'createOrders': true,
27468
27809
  'createTrailingAmountOrder': true,
27469
27810
  'createTrailingPercentOrder': true,
27811
+ 'createTriggerOrder': true,
27812
+ 'createTakeProfitOrder': true,
27813
+ 'createStopLossOrder': true,
27814
+ 'createOrderWithTakeProfitAndStopLoss': true,
27470
27815
  'fetchBalance': true,
27471
27816
  'fetchClosedOrders': true,
27472
27817
  'fetchCurrencies': true,
@@ -27548,6 +27893,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27548
27893
  'trade/query': 3,
27549
27894
  'trade/openOrders': 3,
27550
27895
  'trade/historyOrders': 3,
27896
+ 'trade/myTrades': 3,
27551
27897
  'user/commissionRate': 3,
27552
27898
  'account/balance': 3,
27553
27899
  },
@@ -27607,6 +27953,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27607
27953
  'user/positions': 3,
27608
27954
  'user/income': 3,
27609
27955
  'trade/openOrders': 3,
27956
+ 'trade/openOrder': 3,
27610
27957
  'trade/order': 3,
27611
27958
  'trade/marginType': 3,
27612
27959
  'trade/leverage': 3,
@@ -28274,6 +28621,22 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28274
28621
  // "buyerMaker": false
28275
28622
  // }
28276
28623
  //
28624
+ // spot
28625
+ // fetchMyTrades
28626
+ // {
28627
+ // "symbol": "LTC-USDT",
28628
+ // "id": 36237072,
28629
+ // "orderId": 1674069326895775744,
28630
+ // "price": "85.891",
28631
+ // "qty": "0.0582",
28632
+ // "quoteQty": "4.9988562000000005",
28633
+ // "commission": -0.00005820000000000001,
28634
+ // "commissionAsset": "LTC",
28635
+ // "time": 1687964205000,
28636
+ // "isBuyer": true,
28637
+ // "isMaker": false
28638
+ // }
28639
+ //
28277
28640
  // swap
28278
28641
  // fetchTrades
28279
28642
  //
@@ -28336,7 +28699,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28336
28699
  }
28337
28700
  const cost = this.safeString(trade, 'quoteQty');
28338
28701
  const type = (cost === undefined) ? 'spot' : 'swap';
28339
- const currencyId = this.safeString2(trade, 'currency', 'N');
28702
+ const currencyId = this.safeStringN(trade, ['currency', 'N', 'commissionAsset']);
28340
28703
  const currencyCode = this.safeCurrencyCode(currencyId);
28341
28704
  const m = this.safeValue(trade, 'm');
28342
28705
  const marketId = this.safeString(trade, 's');
@@ -28352,6 +28715,14 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28352
28715
  takeOrMaker = 'taker';
28353
28716
  }
28354
28717
  }
28718
+ const isBuyer = this.safeValue(trade, 'isBuyer');
28719
+ if (isBuyer !== undefined) {
28720
+ side = isBuyer ? 'buy' : 'sell';
28721
+ }
28722
+ const isMaker = this.safeValue(trade, 'isMaker');
28723
+ if (isMaker !== undefined) {
28724
+ takeOrMaker = isMaker ? 'maker' : 'taker';
28725
+ }
28355
28726
  return this.safeTrade({
28356
28727
  'id': this.safeStringN(trade, ['id', 't']),
28357
28728
  'info': trade,
@@ -30686,57 +31057,101 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
30686
31057
  * @method
30687
31058
  * @name bingx#fetchMyTrades
30688
31059
  * @description fetch all trades made by the user
31060
+ * @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Query%20Order%20History
30689
31061
  * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Query%20historical%20transaction%20orders
30690
31062
  * @param {string} [symbol] unified market symbol
30691
31063
  * @param {int} [since] the earliest time in ms to fetch trades for
30692
31064
  * @param {int} [limit] the maximum number of trades structures to retrieve
30693
31065
  * @param {object} [params] extra parameters specific to the exchange API endpoint
31066
+ * @param {int} [params.until] timestamp in ms for the ending date filter, default is undefined
30694
31067
  * @param {string} params.trandingUnit COIN (directly represent assets such as BTC and ETH) or CONT (represents the number of contract sheets)
30695
31068
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
30696
31069
  */
30697
31070
  if (symbol === undefined) {
30698
31071
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
30699
31072
  }
30700
- if (since === undefined) {
30701
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a since argument');
30702
- }
30703
- const tradingUnit = this.safeStringUpper(params, 'tradingUnit', 'CONT');
30704
31073
  await this.loadMarkets();
30705
31074
  const market = this.market(symbol);
30706
- if (market['spot']) {
30707
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' fetchMyTrades() supports swap contracts only');
30708
- }
31075
+ const now = this.milliseconds();
31076
+ let response = undefined;
30709
31077
  const request = {
30710
31078
  'symbol': market['id'],
30711
- 'tradingUnit': tradingUnit,
30712
- 'startTs': since,
30713
- 'endTs': this.nonce(),
30714
31079
  };
30715
- const query = this.omit(params, 'tradingUnit');
30716
- const response = await this.swapV2PrivateGetTradeAllFillOrders(this.extend(request, query));
30717
- //
30718
- // {
30719
- // "code": "0",
30720
- // "msg": '',
30721
- // "data": { fill_orders: [
30722
- // {
30723
- // "volume": "0.1",
30724
- // "price": "106.75",
30725
- // "amount": "10.6750",
30726
- // "commission": "-0.0053",
30727
- // "currency": "USDT",
30728
- // "orderId": "1676213270274379776",
30729
- // "liquidatedPrice": "0.00",
30730
- // "liquidatedMarginRatio": "0.00",
30731
- // "filledTime": "2023-07-04T20:56:01.000+0800"
30732
- // }
30733
- // ]
30734
- // }
30735
- // }
30736
- //
30737
- const data = this.safeValue(response, 'data', []);
30738
- const fillOrders = this.safeValue(data, 'fill_orders', []);
30739
- return this.parseTrades(fillOrders, market, since, limit, query);
31080
+ if (since !== undefined) {
31081
+ const startTimeReq = market['spot'] ? 'startTime' : 'startTs';
31082
+ request[startTimeReq] = since;
31083
+ }
31084
+ else if (market['swap']) {
31085
+ request['startTs'] = now - 7776000000; // 90 days
31086
+ }
31087
+ const until = this.safeInteger(params, 'until');
31088
+ params = this.omit(params, 'until');
31089
+ if (until !== undefined) {
31090
+ const endTimeReq = market['spot'] ? 'endTime' : 'endTs';
31091
+ request[endTimeReq] = until;
31092
+ }
31093
+ else if (market['swap']) {
31094
+ request['endTs'] = now;
31095
+ }
31096
+ let fills = undefined;
31097
+ if (market['spot']) {
31098
+ response = await this.spotV1PrivateGetTradeMyTrades(this.extend(request, params));
31099
+ const data = this.safeValue(response, 'data', []);
31100
+ fills = this.safeValue(data, 'fills', []);
31101
+ //
31102
+ // {
31103
+ // "code": 0,
31104
+ // "msg": "",
31105
+ // "debugMsg": "",
31106
+ // "data": {
31107
+ // "fills": [
31108
+ // {
31109
+ // "symbol": "LTC-USDT",
31110
+ // "id": 36237072,
31111
+ // "orderId": 1674069326895775744,
31112
+ // "price": "85.891",
31113
+ // "qty": "0.0582",
31114
+ // "quoteQty": "4.9988562000000005",
31115
+ // "commission": -0.00005820000000000001,
31116
+ // "commissionAsset": "LTC",
31117
+ // "time": 1687964205000,
31118
+ // "isBuyer": true,
31119
+ // "isMaker": false
31120
+ // }
31121
+ // ]
31122
+ // }
31123
+ // }
31124
+ //
31125
+ }
31126
+ else {
31127
+ const tradingUnit = this.safeStringUpper(params, 'tradingUnit', 'CONT');
31128
+ params = this.omit(params, 'tradingUnit');
31129
+ request['tradingUnit'] = tradingUnit;
31130
+ response = await this.swapV2PrivateGetTradeAllFillOrders(this.extend(request, params));
31131
+ const data = this.safeValue(response, 'data', []);
31132
+ fills = this.safeValue(data, 'fill_orders', []);
31133
+ //
31134
+ // {
31135
+ // "code": "0",
31136
+ // "msg": '',
31137
+ // "data": { fill_orders: [
31138
+ // {
31139
+ // "volume": "0.1",
31140
+ // "price": "106.75",
31141
+ // "amount": "10.6750",
31142
+ // "commission": "-0.0053",
31143
+ // "currency": "USDT",
31144
+ // "orderId": "1676213270274379776",
31145
+ // "liquidatedPrice": "0.00",
31146
+ // "liquidatedMarginRatio": "0.00",
31147
+ // "filledTime": "2023-07-04T20:56:01.000+0800"
31148
+ // }
31149
+ // ]
31150
+ // }
31151
+ // }
31152
+ //
31153
+ }
31154
+ return this.parseTrades(fills, market, since, limit, params);
30740
31155
  }
30741
31156
  parseDepositWithdrawFee(fee, currency = undefined) {
30742
31157
  //
@@ -41023,10 +41438,14 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41023
41438
  'createMarketBuyOrderWithCost': true,
41024
41439
  'createMarketOrderWithCost': false,
41025
41440
  'createMarketSellOrderWithCost': false,
41026
- 'createTrailingPercentOrder': true,
41027
41441
  'createOrder': true,
41028
41442
  'createOrders': true,
41029
41443
  'createReduceOnlyOrder': false,
41444
+ 'createTrailingPercentOrder': true,
41445
+ 'createTriggerOrder': true,
41446
+ 'createTakeProfitOrder': true,
41447
+ 'createStopLossOrder': true,
41448
+ 'createOrderWithTakeProfitAndStopLoss': true,
41030
41449
  'editOrder': true,
41031
41450
  'fetchAccounts': false,
41032
41451
  'fetchBalance': true,
@@ -43940,7 +44359,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43940
44359
  'symbol': market['id'],
43941
44360
  };
43942
44361
  if (limit !== undefined) {
43943
- request['limit'] = limit;
44362
+ if (market['contract']) {
44363
+ request['limit'] = Math.min(limit, 1000);
44364
+ }
44365
+ else {
44366
+ request['limit'] = limit;
44367
+ }
43944
44368
  }
43945
44369
  const options = this.safeValue(this.options, 'fetchTrades', {});
43946
44370
  let response = undefined;
@@ -44252,11 +44676,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44252
44676
  const marketType = market['spot'] ? 'spot' : 'swap';
44253
44677
  const timeframes = this.options['timeframes'][marketType];
44254
44678
  const selectedTimeframe = this.safeString(timeframes, timeframe, timeframe);
44255
- let request = {
44679
+ const request = {
44256
44680
  'symbol': market['id'],
44257
44681
  'granularity': selectedTimeframe,
44258
44682
  };
44259
- [request, params] = this.handleUntilOption('endTime', request, params);
44683
+ const until = this.safeInteger2(params, 'until', 'till');
44684
+ params = this.omit(params, ['until', 'till']);
44260
44685
  if (limit !== undefined) {
44261
44686
  request['limit'] = limit;
44262
44687
  }
@@ -44269,6 +44694,9 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44269
44694
  if (since !== undefined) {
44270
44695
  request['startTime'] = since;
44271
44696
  }
44697
+ if (until !== undefined) {
44698
+ request['endTime'] = until;
44699
+ }
44272
44700
  }
44273
44701
  let response = undefined;
44274
44702
  if (market['spot']) {
@@ -44276,8 +44704,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44276
44704
  response = await this.publicSpotGetV2SpotMarketCandles(this.extend(request, params));
44277
44705
  }
44278
44706
  else if (method === 'publicSpotGetV2SpotMarketHistoryCandles') {
44279
- const until = this.safeInteger2(params, 'until', 'till');
44280
- params = this.omit(params, ['until', 'till']);
44281
44707
  if (since !== undefined) {
44282
44708
  if (limit === undefined) {
44283
44709
  limit = 100; // exchange default
@@ -50416,12 +50842,12 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50416
50842
  'createMarketBuyOrderWithCost': true,
50417
50843
  'createMarketOrderWithCost': false,
50418
50844
  'createMarketSellOrderWithCost': false,
50419
- 'createTrailingPercentOrder': true,
50420
50845
  'createOrder': true,
50421
50846
  'createPostOnlyOrder': true,
50422
50847
  'createStopLimitOrder': false,
50423
50848
  'createStopMarketOrder': false,
50424
50849
  'createStopOrder': false,
50850
+ 'createTrailingPercentOrder': true,
50425
50851
  'fetchBalance': true,
50426
50852
  'fetchBorrowInterest': true,
50427
50853
  'fetchBorrowRateHistories': false,
@@ -50640,8 +51066,8 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50640
51066
  'trading': {
50641
51067
  'tierBased': true,
50642
51068
  'percentage': true,
50643
- 'taker': this.parseNumber('0.0025'),
50644
- 'maker': this.parseNumber('0.0025'),
51069
+ 'taker': this.parseNumber('0.0040'),
51070
+ 'maker': this.parseNumber('0.0035'),
50645
51071
  'tiers': {
50646
51072
  'taker': [
50647
51073
  [this.parseNumber('0'), this.parseNumber('0.0020')],
@@ -78365,7 +78791,6 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
78365
78791
  'closePosition': false,
78366
78792
  'createMarketBuyOrderWithCost': true,
78367
78793
  'createMarketSellOrderWithCost': false,
78368
- 'createTrailingAmountOrder': true,
78369
78794
  'createOrder': true,
78370
78795
  'createOrders': true,
78371
78796
  'createPostOnlyOrder': true,
@@ -78373,6 +78798,11 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
78373
78798
  'createStopLimitOrder': true,
78374
78799
  'createStopMarketOrder': true,
78375
78800
  'createStopOrder': true,
78801
+ 'createTrailingAmountOrder': true,
78802
+ 'createTriggerOrder': true,
78803
+ 'createTakeProfitOrder': true,
78804
+ 'createStopLossOrder': true,
78805
+ 'createOrderWithTakeProfitAndStopLoss': true,
78376
78806
  'editOrder': true,
78377
78807
  'fetchBalance': true,
78378
78808
  'fetchBorrowInterest': false,
@@ -87791,7 +88221,7 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
87791
88221
  'setLeverage': false,
87792
88222
  'setMarginMode': false,
87793
88223
  'setPositionMode': false,
87794
- 'withdraw': undefined,
88224
+ 'withdraw': true,
87795
88225
  },
87796
88226
  'urls': {
87797
88227
  'logo': 'https://user-images.githubusercontent.com/1294454/40811661-b6eceae2-653a-11e8-829e-10bfadb078cf.jpg',
@@ -88462,46 +88892,102 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
88462
88892
  // "next_step": null
88463
88893
  // }
88464
88894
  //
88465
- const subtotalObject = this.safeValue(transaction, 'subtotal', {});
88466
- const feeObject = this.safeValue(transaction, 'fee', {});
88467
- const id = this.safeString(transaction, 'id');
88468
- const timestamp = this.parse8601(this.safeValue(transaction, 'created_at'));
88469
- const updated = this.parse8601(this.safeValue(transaction, 'updated_at'));
88470
- const type = this.safeString(transaction, 'resource');
88471
- const amount = this.safeNumber(subtotalObject, 'amount');
88472
- const currencyId = this.safeString(subtotalObject, 'currency');
88473
- const code = this.safeCurrencyCode(currencyId, currency);
88474
- const feeCost = this.safeNumber(feeObject, 'amount');
88475
- const feeCurrencyId = this.safeString(feeObject, 'currency');
88476
- const feeCurrency = this.safeCurrencyCode(feeCurrencyId);
88477
- const fee = {
88478
- 'cost': feeCost,
88479
- 'currency': feeCurrency,
88480
- };
88895
+ // withdraw
88896
+ //
88897
+ // {
88898
+ // "id": "a1794ecf-5693-55fa-70cf-ef731748ed82",
88899
+ // "type": "send",
88900
+ // "status": "pending",
88901
+ // "amount": {
88902
+ // "amount": "-14.008308",
88903
+ // "currency": "USDC"
88904
+ // },
88905
+ // "native_amount": {
88906
+ // "amount": "-18.74",
88907
+ // "currency": "CAD"
88908
+ // },
88909
+ // "description": null,
88910
+ // "created_at": "2024-01-12T01:27:31Z",
88911
+ // "updated_at": "2024-01-12T01:27:31Z",
88912
+ // "resource": "transaction",
88913
+ // "resource_path": "/v2/accounts/a34bgfad-ed67-538b-bffc-730c98c10da0/transactions/a1794ecf-5693-55fa-70cf-ef731748ed82",
88914
+ // "instant_exchange": false,
88915
+ // "network": {
88916
+ // "status": "pending",
88917
+ // "status_description": "Pending (est. less than 10 minutes)",
88918
+ // "transaction_fee": {
88919
+ // "amount": "4.008308",
88920
+ // "currency": "USDC"
88921
+ // },
88922
+ // "transaction_amount": {
88923
+ // "amount": "10.000000",
88924
+ // "currency": "USDC"
88925
+ // },
88926
+ // "confirmations": 0
88927
+ // },
88928
+ // "to": {
88929
+ // "resource": "ethereum_address",
88930
+ // "address": "0x9...",
88931
+ // "currency": "USDC",
88932
+ // "address_info": {
88933
+ // "address": "0x9..."
88934
+ // }
88935
+ // },
88936
+ // "idem": "748d8591-dg9a-7831-a45b-crd61dg78762",
88937
+ // "details": {
88938
+ // "title": "Sent USDC",
88939
+ // "subtitle": "To USDC address on Ethereum network",
88940
+ // "header": "Sent 14.008308 USDC ($18.74)",
88941
+ // "health": "warning"
88942
+ // },
88943
+ // "hide_native_amount": false
88944
+ // }
88945
+ //
88946
+ const transactionType = this.safeString(transaction, 'type');
88947
+ let amountAndCurrencyObject = undefined;
88948
+ let feeObject = undefined;
88949
+ if (transactionType === 'send') {
88950
+ const network = this.safeValue(transaction, 'network', {});
88951
+ amountAndCurrencyObject = this.safeValue(network, 'transaction_amount', {});
88952
+ feeObject = this.safeValue(network, 'transaction_fee', {});
88953
+ }
88954
+ else {
88955
+ amountAndCurrencyObject = this.safeValue(transaction, 'subtotal', {});
88956
+ feeObject = this.safeValue(transaction, 'fee', {});
88957
+ }
88481
88958
  let status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
88482
88959
  if (status === undefined) {
88483
88960
  const committed = this.safeValue(transaction, 'committed');
88484
88961
  status = committed ? 'ok' : 'pending';
88485
88962
  }
88963
+ const id = this.safeString(transaction, 'id');
88964
+ const currencyId = this.safeString(amountAndCurrencyObject, 'currency');
88965
+ const feeCurrencyId = this.safeString(feeObject, 'currency');
88966
+ const datetime = this.safeValue(transaction, 'created_at');
88967
+ const toObject = this.safeValue(transaction, 'to', {});
88968
+ const toAddress = this.safeString(toObject, 'address');
88486
88969
  return {
88487
88970
  'info': transaction,
88488
88971
  'id': id,
88489
88972
  'txid': id,
88490
- 'timestamp': timestamp,
88491
- 'datetime': this.iso8601(timestamp),
88973
+ 'timestamp': this.parse8601(datetime),
88974
+ 'datetime': datetime,
88492
88975
  'network': undefined,
88493
- 'address': undefined,
88494
- 'addressTo': undefined,
88976
+ 'address': toAddress,
88977
+ 'addressTo': toAddress,
88495
88978
  'addressFrom': undefined,
88496
88979
  'tag': undefined,
88497
88980
  'tagTo': undefined,
88498
88981
  'tagFrom': undefined,
88499
- 'type': type,
88500
- 'amount': amount,
88501
- 'currency': code,
88982
+ 'type': this.safeString(transaction, 'resource'),
88983
+ 'amount': this.safeNumber(amountAndCurrencyObject, 'amount'),
88984
+ 'currency': this.safeCurrencyCode(currencyId, currency),
88502
88985
  'status': status,
88503
- 'updated': updated,
88504
- 'fee': fee,
88986
+ 'updated': this.parse8601(this.safeValue(transaction, 'updated_at')),
88987
+ 'fee': {
88988
+ 'cost': this.safeNumber(feeObject, 'amount'),
88989
+ 'currency': this.safeCurrencyCode(feeCurrencyId),
88990
+ },
88505
88991
  };
88506
88992
  }
88507
88993
  parseTrade(trade, market = undefined) {
@@ -90855,6 +91341,100 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
90855
91341
  const tickers = this.safeValue(response, 'pricebooks', []);
90856
91342
  return this.parseTickers(tickers, symbols);
90857
91343
  }
91344
+ async withdraw(code, amount, address, tag = undefined, params = {}) {
91345
+ /**
91346
+ * @method
91347
+ * @name coinbase#withdraw
91348
+ * @description make a withdrawal
91349
+ * @see https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-transactions#send-money
91350
+ * @param {string} code unified currency code
91351
+ * @param {float} amount the amount to withdraw
91352
+ * @param {string} address the address to withdraw to
91353
+ * @param {string} [tag] an optional tag for the withdrawal
91354
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
91355
+ * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
91356
+ */
91357
+ [tag, params] = this.handleWithdrawTagAndParams(tag, params);
91358
+ this.checkAddress(address);
91359
+ await this.loadMarkets();
91360
+ const currency = this.currency(code);
91361
+ let accountId = this.safeString2(params, 'account_id', 'accountId');
91362
+ params = this.omit(params, ['account_id', 'accountId']);
91363
+ if (accountId === undefined) {
91364
+ if (code === undefined) {
91365
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' withdraw() requires an account_id (or accountId) parameter OR a currency code argument');
91366
+ }
91367
+ accountId = await this.findAccountId(code);
91368
+ if (accountId === undefined) {
91369
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' withdraw() could not find account id for ' + code);
91370
+ }
91371
+ }
91372
+ const request = {
91373
+ 'account_id': accountId,
91374
+ 'type': 'send',
91375
+ 'to': address,
91376
+ 'amount': amount,
91377
+ 'currency': currency['id'],
91378
+ };
91379
+ if (tag !== undefined) {
91380
+ request['destination_tag'] = tag;
91381
+ }
91382
+ const response = await this.v2PrivatePostAccountsAccountIdTransactions(this.extend(request, params));
91383
+ //
91384
+ // {
91385
+ // "data": {
91386
+ // "id": "a1794ecf-5693-55fa-70cf-ef731748ed82",
91387
+ // "type": "send",
91388
+ // "status": "pending",
91389
+ // "amount": {
91390
+ // "amount": "-14.008308",
91391
+ // "currency": "USDC"
91392
+ // },
91393
+ // "native_amount": {
91394
+ // "amount": "-18.74",
91395
+ // "currency": "CAD"
91396
+ // },
91397
+ // "description": null,
91398
+ // "created_at": "2024-01-12T01:27:31Z",
91399
+ // "updated_at": "2024-01-12T01:27:31Z",
91400
+ // "resource": "transaction",
91401
+ // "resource_path": "/v2/accounts/a34bgfad-ed67-538b-bffc-730c98c10da0/transactions/a1794ecf-5693-55fa-70cf-ef731748ed82",
91402
+ // "instant_exchange": false,
91403
+ // "network": {
91404
+ // "status": "pending",
91405
+ // "status_description": "Pending (est. less than 10 minutes)",
91406
+ // "transaction_fee": {
91407
+ // "amount": "4.008308",
91408
+ // "currency": "USDC"
91409
+ // },
91410
+ // "transaction_amount": {
91411
+ // "amount": "10.000000",
91412
+ // "currency": "USDC"
91413
+ // },
91414
+ // "confirmations": 0
91415
+ // },
91416
+ // "to": {
91417
+ // "resource": "ethereum_address",
91418
+ // "address": "0x9...",
91419
+ // "currency": "USDC",
91420
+ // "address_info": {
91421
+ // "address": "0x9..."
91422
+ // }
91423
+ // },
91424
+ // "idem": "748d8591-dg9a-7831-a45b-crd61dg78762",
91425
+ // "details": {
91426
+ // "title": "Sent USDC",
91427
+ // "subtitle": "To USDC address on Ethereum network",
91428
+ // "header": "Sent 14.008308 USDC ($18.74)",
91429
+ // "health": "warning"
91430
+ // },
91431
+ // "hide_native_amount": false
91432
+ // }
91433
+ // }
91434
+ //
91435
+ const data = this.safeValue(response, 'data', {});
91436
+ return this.parseTransaction(data, currency);
91437
+ }
90858
91438
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
90859
91439
  const version = api[0];
90860
91440
  const signed = api[1] === 'private';
@@ -93750,6 +94330,9 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93750
94330
  'createMarketBuyOrderWithCost': true,
93751
94331
  'createMarketOrderWithCost': false,
93752
94332
  'createMarketSellOrderWithCost': false,
94333
+ 'createTriggerOrder': true,
94334
+ 'createTakeProfitOrder': true,
94335
+ 'createStopLossOrder': true,
93753
94336
  'createOrder': true,
93754
94337
  'createOrders': true,
93755
94338
  'createReduceOnlyOrder': true,
@@ -99876,7 +100459,7 @@ class coinlist extends _abstract_coinlist_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
99876
100459
  request['start_time'] = this.iso8601(since);
99877
100460
  }
99878
100461
  if (limit !== undefined) {
99879
- request['count'] = limit;
100462
+ request['count'] = Math.min(limit, 500);
99880
100463
  }
99881
100464
  const until = this.safeInteger2(params, 'till', 'until');
99882
100465
  if (until !== undefined) {
@@ -103173,7 +103756,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
103173
103756
  'target_currency': market['base'],
103174
103757
  };
103175
103758
  if (limit !== undefined) {
103176
- request['size'] = limit; // only support 10, 50, 100, 150, 200
103759
+ request['size'] = Math.min(limit, 200);
103177
103760
  }
103178
103761
  const response = await this.v2PublicGetTradesQuoteCurrencyTargetCurrency(this.extend(request, params));
103179
103762
  //
@@ -113273,7 +113856,13 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
113273
113856
  if (limit !== undefined) {
113274
113857
  request['page_size'] = limit;
113275
113858
  }
113276
- const response = await this[method](this.extend(request, params));
113859
+ let response = undefined;
113860
+ if (method === 'privateGetOrders') {
113861
+ response = await this.privateGetOrders(this.extend(request, params));
113862
+ }
113863
+ else if (method === 'privateGetOrdersHistory') {
113864
+ response = await this.privateGetOrdersHistory(this.extend(request, params));
113865
+ }
113277
113866
  //
113278
113867
  // {
113279
113868
  // "success": true,
@@ -114505,11 +115094,11 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
114505
115094
  'cancelOrder': true,
114506
115095
  'cancelOrders': false,
114507
115096
  'createDepositAddress': true,
114508
- 'createTrailingAmountOrder': true,
114509
115097
  'createOrder': true,
114510
115098
  'createStopLimitOrder': true,
114511
115099
  'createStopMarketOrder': true,
114512
115100
  'createStopOrder': true,
115101
+ 'createTrailingAmountOrder': true,
114513
115102
  'editOrder': true,
114514
115103
  'fetchAccounts': true,
114515
115104
  'fetchBalance': true,
@@ -124914,6 +125503,9 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
124914
125503
  'createReduceOnlyOrder': true,
124915
125504
  'createStopLimitOrder': true,
124916
125505
  'createStopMarketOrder': false,
125506
+ 'createTriggerOrder': true,
125507
+ 'createTakeProfitOrder': true,
125508
+ 'createStopLossOrder': true,
124917
125509
  'createStopOrder': true,
124918
125510
  'editOrder': true,
124919
125511
  'fetchBalance': true,
@@ -127944,7 +128536,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
127944
128536
  request['to'] = this.parseToInt(until / 1000);
127945
128537
  }
127946
128538
  if (limit !== undefined) {
127947
- request['limit'] = limit; // default 100, max 1000
128539
+ request['limit'] = Math.min(limit, 1000); // default 100, max 1000
127948
128540
  }
127949
128541
  if (since !== undefined && (market['contract'])) {
127950
128542
  request['from'] = this.parseToInt(since / 1000);
@@ -128590,6 +129182,8 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
128590
129182
  * @param {object} [params] extra parameters specific to the exchange API endpoint
128591
129183
  * @param {float} [params.stopPrice] The price at which a trigger order is triggered at
128592
129184
  * @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
129185
+ * @param {float} [params.stopLossPrice] The price at which a stop loss order is triggered at
129186
+ * @param {float} [params.takeProfitPrice] The price at which a take profit order is triggered at
128593
129187
  * @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
128594
129188
  * @param {int} [params.iceberg] Amount to display for the iceberg order, Null or 0 for normal orders, Set to -1 to hide the order completely
128595
129189
  * @param {string} [params.text] User defined information
@@ -130084,29 +130678,35 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
130084
130678
  // swap and future
130085
130679
  //
130086
130680
  // {
130087
- // "value": "12.475572",
130681
+ // "value": "4.60516",
130088
130682
  // "leverage": "0",
130089
130683
  // "mode": "single",
130090
130684
  // "realised_point": "0",
130091
130685
  // "contract": "BTC_USDT",
130092
- // "entry_price": "62422.6",
130093
- // "mark_price": "62377.86",
130686
+ // "entry_price": "46030.3",
130687
+ // "mark_price": "46051.6",
130094
130688
  // "history_point": "0",
130095
- // "realised_pnl": "-0.00624226",
130096
- // "close_order": null,
130097
- // "size": "2",
130098
- // "cross_leverage_limit": "25",
130099
- // "pending_orders": "0",
130100
- // "adl_ranking": "5",
130101
- // "maintenance_rate": "0.005",
130102
- // "unrealised_pnl": "-0.008948",
130103
- // "user": "663337",
130104
- // "leverage_max": "100",
130105
- // "history_pnl": "14.98868396636",
130689
+ // "realised_pnl": "-0.002301515",
130690
+ // "close_order": null,
130691
+ // "size": 1,
130692
+ // "cross_leverage_limit": "0",
130693
+ // "pending_orders": 0,
130694
+ // "adl_ranking": 5,
130695
+ // "maintenance_rate": "0.004",
130696
+ // "unrealised_pnl": "0.00213",
130697
+ // "user": 5691076,
130698
+ // "leverage_max": "125",
130699
+ // "history_pnl": "0",
130106
130700
  // "risk_limit": "1000000",
130107
- // "margin": "0.740721495056",
130108
- // "last_close_pnl": "-0.041996015",
130109
- // "liq_price": "59058.58"
130701
+ // "margin": "8.997698485",
130702
+ // "last_close_pnl": "0",
130703
+ // "liq_price": "0",
130704
+ // "update_time": 1705034246,
130705
+ // "update_id": 1,
130706
+ // "initial_margin": "0",
130707
+ // "maintenance_margin": "0",
130708
+ // "open_time": 1705034246,
130709
+ // "trade_max_size": "0"
130110
130710
  // }
130111
130711
  //
130112
130712
  // option
@@ -130157,14 +130757,14 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
130157
130757
  const takerFee = '0.00075';
130158
130758
  const feePaid = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(takerFee, notional);
130159
130759
  const initialMarginString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAdd(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(notional, leverage), feePaid);
130160
- const timestamp = this.safeInteger(position, 'time_ms');
130760
+ const timestamp = this.safeTimestamp(position, 'open_time');
130161
130761
  return this.safePosition({
130162
130762
  'info': position,
130163
130763
  'id': undefined,
130164
130764
  'symbol': this.safeString(market, 'symbol'),
130165
- 'timestamp': undefined,
130166
- 'datetime': undefined,
130167
- 'lastUpdateTimestamp': timestamp,
130765
+ 'timestamp': timestamp,
130766
+ 'datetime': this.iso8601(timestamp),
130767
+ 'lastUpdateTimestamp': this.safeTimestamp(position, 'update_time'),
130168
130768
  'initialMargin': this.parseNumber(initialMarginString),
130169
130769
  'initialMarginPercentage': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(initialMarginString, notional)),
130170
130770
  'maintenanceMargin': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(maintenanceRate, notional)),
@@ -130223,29 +130823,35 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
130223
130823
  // swap and future
130224
130824
  //
130225
130825
  // {
130226
- // "value": "12.475572",
130826
+ // "value": "4.60516",
130227
130827
  // "leverage": "0",
130228
130828
  // "mode": "single",
130229
130829
  // "realised_point": "0",
130230
130830
  // "contract": "BTC_USDT",
130231
- // "entry_price": "62422.6",
130232
- // "mark_price": "62377.86",
130831
+ // "entry_price": "46030.3",
130832
+ // "mark_price": "46051.6",
130233
130833
  // "history_point": "0",
130234
- // "realised_pnl": "-0.00624226",
130235
- // "close_order": null,
130236
- // "size": "2",
130237
- // "cross_leverage_limit": "25",
130238
- // "pending_orders": "0",
130239
- // "adl_ranking": "5",
130240
- // "maintenance_rate": "0.005",
130241
- // "unrealised_pnl": "-0.008948",
130242
- // "user": "6693577",
130243
- // "leverage_max": "100",
130244
- // "history_pnl": "14.98868396636",
130834
+ // "realised_pnl": "-0.002301515",
130835
+ // "close_order": null,
130836
+ // "size": 1,
130837
+ // "cross_leverage_limit": "0",
130838
+ // "pending_orders": 0,
130839
+ // "adl_ranking": 5,
130840
+ // "maintenance_rate": "0.004",
130841
+ // "unrealised_pnl": "0.00213",
130842
+ // "user": 5691076,
130843
+ // "leverage_max": "125",
130844
+ // "history_pnl": "0",
130245
130845
  // "risk_limit": "1000000",
130246
- // "margin": "0.740721495056",
130247
- // "last_close_pnl": "-0.041996015",
130248
- // "liq_price": "59058.58"
130846
+ // "margin": "8.997698485",
130847
+ // "last_close_pnl": "0",
130848
+ // "liq_price": "0",
130849
+ // "update_time": 1705034246,
130850
+ // "update_id": 1,
130851
+ // "initial_margin": "0",
130852
+ // "maintenance_margin": "0",
130853
+ // "open_time": 1705034246,
130854
+ // "trade_max_size": "0"
130249
130855
  // }
130250
130856
  //
130251
130857
  // option
@@ -130325,29 +130931,35 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
130325
130931
  //
130326
130932
  // [
130327
130933
  // {
130328
- // "value": "12.475572",
130934
+ // "value": "4.602828",
130329
130935
  // "leverage": "0",
130330
130936
  // "mode": "single",
130331
130937
  // "realised_point": "0",
130332
130938
  // "contract": "BTC_USDT",
130333
- // "entry_price": "62422.6",
130334
- // "mark_price": "62377.86",
130939
+ // "entry_price": "46030.3",
130940
+ // "mark_price": "46028.28",
130335
130941
  // "history_point": "0",
130336
- // "realised_pnl": "-0.00624226",
130337
- // "close_order": null,
130338
- // "size": "2",
130339
- // "cross_leverage_limit": "25",
130340
- // "pending_orders": "0",
130341
- // "adl_ranking": "5",
130342
- // "maintenance_rate": "0.005",
130343
- // "unrealised_pnl": "-0.008948",
130344
- // "user": "6693577",
130345
- // "leverage_max": "100",
130346
- // "history_pnl": "14.98868396636",
130942
+ // "realised_pnl": "-0.002301515",
130943
+ // "close_order": null,
130944
+ // "size": 1,
130945
+ // "cross_leverage_limit": "0",
130946
+ // "pending_orders": 0,
130947
+ // "adl_ranking": 5,
130948
+ // "maintenance_rate": "0.004",
130949
+ // "unrealised_pnl": "-0.000202",
130950
+ // "user": 5691076,
130951
+ // "leverage_max": "125",
130952
+ // "history_pnl": "0",
130347
130953
  // "risk_limit": "1000000",
130348
- // "margin": "0.740721495056",
130349
- // "last_close_pnl": "-0.041996015",
130350
- // "liq_price": "59058.58"
130954
+ // "margin": "8.997698485",
130955
+ // "last_close_pnl": "0",
130956
+ // "liq_price": "0",
130957
+ // "update_time": 1705034246,
130958
+ // "update_id": 1,
130959
+ // "initial_margin": "0",
130960
+ // "maintenance_margin": "0",
130961
+ // "open_time": 1705034246,
130962
+ // "trade_max_size": "0"
130351
130963
  // }
130352
130964
  // ]
130353
130965
  //
@@ -132861,7 +133473,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
132861
133473
  'symbol': market['id'],
132862
133474
  };
132863
133475
  if (limit !== undefined) {
132864
- request['limit_trades'] = limit;
133476
+ request['limit_trades'] = Math.min(limit, 500);
132865
133477
  }
132866
133478
  if (since !== undefined) {
132867
133479
  request['timestamp'] = since;
@@ -139349,13 +139961,16 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139349
139961
  'createMarketBuyOrderWithCost': true,
139350
139962
  'createMarketOrderWithCost': false,
139351
139963
  'createMarketSellOrderWithCost': false,
139352
- 'createTrailingPercentOrder': true,
139353
139964
  'createOrder': true,
139354
139965
  'createOrders': true,
139355
139966
  'createReduceOnlyOrder': false,
139356
139967
  'createStopLimitOrder': true,
139357
139968
  'createStopMarketOrder': true,
139358
139969
  'createStopOrder': true,
139970
+ 'createTrailingPercentOrder': true,
139971
+ 'createTriggerOrder': true,
139972
+ 'createTakeProfitOrder': true,
139973
+ 'createStopLossOrder': true,
139359
139974
  'fetchAccounts': true,
139360
139975
  'fetchBalance': true,
139361
139976
  'fetchBidsAsks': undefined,
@@ -139383,6 +139998,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
139383
139998
  'fetchIsolatedBorrowRate': false,
139384
139999
  'fetchIsolatedBorrowRates': true,
139385
140000
  'fetchL3OrderBook': undefined,
140001
+ 'fetchLastPrices': true,
139386
140002
  'fetchLedger': true,
139387
140003
  'fetchLedgerEntry': undefined,
139388
140004
  'fetchLeverage': false,
@@ -141575,6 +142191,127 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
141575
142191
  }
141576
142192
  return this.filterByArrayTickers(result, 'symbol', symbols);
141577
142193
  }
142194
+ async fetchLastPrices(symbols = undefined, params = {}) {
142195
+ /**
142196
+ * @method
142197
+ * @name binance#fetchLastPrices
142198
+ * @description fetches the last price for multiple markets
142199
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
142200
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
142201
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap
142202
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the last prices
142203
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
142204
+ * @returns {object} a dictionary of lastprices structures
142205
+ */
142206
+ await this.loadMarkets();
142207
+ symbols = this.marketSymbols(symbols);
142208
+ const market = this.getMarketFromSymbols(symbols);
142209
+ let type = undefined;
142210
+ let subType = undefined;
142211
+ [subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
142212
+ [type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
142213
+ let response = undefined;
142214
+ if (((type === 'swap') || (type === 'future')) && (subType === 'linear')) {
142215
+ response = await this.contractPublicGetLinearSwapExMarketTrade(params);
142216
+ //
142217
+ // {
142218
+ // "ch": "market.*.trade.detail",
142219
+ // "status": "ok",
142220
+ // "tick": {
142221
+ // "data": [
142222
+ // {
142223
+ // "amount": "4",
142224
+ // "quantity": "40",
142225
+ // "trade_turnover": "22.176",
142226
+ // "ts": 1703697705028,
142227
+ // "id": 1000003558478170000,
142228
+ // "price": "0.5544",
142229
+ // "direction": "buy",
142230
+ // "contract_code": "MANA-USDT",
142231
+ // "business_type": "swap",
142232
+ // "trade_partition": "USDT"
142233
+ // },
142234
+ // ],
142235
+ // "id": 1703697740147,
142236
+ // "ts": 1703697740147
142237
+ // },
142238
+ // "ts": 1703697740147
142239
+ // }
142240
+ //
142241
+ }
142242
+ else if ((type === 'swap') && (subType === 'inverse')) {
142243
+ response = await this.contractPublicGetSwapExMarketTrade(params);
142244
+ //
142245
+ // {
142246
+ // "ch": "market.*.trade.detail",
142247
+ // "status": "ok",
142248
+ // "tick": {
142249
+ // "data": [
142250
+ // {
142251
+ // "amount": "6",
142252
+ // "quantity": "94.5000945000945000945000945000945000945",
142253
+ // "ts": 1703698704594,
142254
+ // "id": 1000001187811060000,
142255
+ // "price": "0.63492",
142256
+ // "direction": "buy",
142257
+ // "contract_code": "XRP-USD"
142258
+ // },
142259
+ // ],
142260
+ // "id": 1703698706589,
142261
+ // "ts": 1703698706589
142262
+ // },
142263
+ // "ts": 1703698706589
142264
+ // }
142265
+ //
142266
+ }
142267
+ else if ((type === 'future') && (subType === 'inverse')) {
142268
+ response = await this.contractPublicGetMarketTrade(params);
142269
+ //
142270
+ // {
142271
+ // "ch": "market.*.trade.detail",
142272
+ // "status": "ok",
142273
+ // "tick": {
142274
+ // "data": [
142275
+ // {
142276
+ // "amount": "20",
142277
+ // "quantity": "44.4444444444444444444444444444444444444",
142278
+ // "ts": 1686134498885,
142279
+ // "id": 2323000000174820000,
142280
+ // "price": "4.5",
142281
+ // "direction": "sell",
142282
+ // "symbol": "DORA_CW"
142283
+ // },
142284
+ // ],
142285
+ // "id": 1703698855142,
142286
+ // "ts": 1703698855142
142287
+ // },
142288
+ // "ts": 1703698855142
142289
+ // }
142290
+ //
142291
+ }
142292
+ else {
142293
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
142294
+ }
142295
+ const tick = this.safeValue(response, 'tick', {});
142296
+ const data = this.safeValue(tick, 'data', []);
142297
+ return this.parseLastPrices(data, symbols);
142298
+ }
142299
+ parseLastPrice(entry, market = undefined) {
142300
+ // example responses are documented in fetchLastPrices
142301
+ const marketId = this.safeString2(entry, 'symbol', 'contract_code');
142302
+ market = this.safeMarket(marketId, market);
142303
+ const price = this.safeNumber(entry, 'price');
142304
+ const direction = this.safeString(entry, 'direction'); // "buy" or "sell"
142305
+ // group timestamp should not be assigned to the individual trades' times
142306
+ return {
142307
+ 'symbol': market['symbol'],
142308
+ 'timestamp': undefined,
142309
+ 'datetime': undefined,
142310
+ 'price': price,
142311
+ 'side': direction,
142312
+ 'info': entry,
142313
+ };
142314
+ }
141578
142315
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
141579
142316
  /**
141580
142317
  * @method
@@ -144277,6 +145014,31 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
144277
145014
  params['createMarketBuyOrderRequiresPrice'] = false;
144278
145015
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
144279
145016
  }
145017
+ async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
145018
+ /**
145019
+ * @method
145020
+ * @name htx#createTrailingPercentOrder
145021
+ * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
145022
+ * @param {string} symbol unified symbol of the market to create an order in
145023
+ * @param {string} type 'market' or 'limit'
145024
+ * @param {string} side 'buy' or 'sell'
145025
+ * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
145026
+ * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
145027
+ * @param {float} trailingPercent the percent to trail away from the current market price
145028
+ * @param {float} trailingTriggerPrice the price to activate a trailing order, default uses the price argument
145029
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
145030
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
145031
+ */
145032
+ if (trailingPercent === undefined) {
145033
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createTrailingPercentOrder() requires a trailingPercent argument');
145034
+ }
145035
+ if (trailingTriggerPrice === undefined) {
145036
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createTrailingPercentOrder() requires a trailingTriggerPrice argument');
145037
+ }
145038
+ params['trailingPercent'] = trailingPercent;
145039
+ params['trailingTriggerPrice'] = trailingTriggerPrice;
145040
+ return await this.createOrder(symbol, type, side, amount, price, params);
145041
+ }
144280
145042
  async createSpotOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
144281
145043
  /**
144282
145044
  * @method
@@ -152757,20 +153519,22 @@ class independentreserve extends _abstract_independentreserve_js__WEBPACK_IMPORT
152757
153519
  */
152758
153520
  await this.loadMarkets();
152759
153521
  const market = this.market(symbol);
152760
- const capitalizedOrderType = this.capitalize(type);
152761
- const method = 'privatePostPlace' + capitalizedOrderType + 'Order';
152762
- let orderType = capitalizedOrderType;
153522
+ let orderType = this.capitalize(type);
152763
153523
  orderType += (side === 'sell') ? 'Offer' : 'Bid';
152764
153524
  const request = this.ordered({
152765
153525
  'primaryCurrencyCode': market['baseId'],
152766
153526
  'secondaryCurrencyCode': market['quoteId'],
152767
153527
  'orderType': orderType,
152768
153528
  });
153529
+ let response = undefined;
153530
+ request['volume'] = amount;
152769
153531
  if (type === 'limit') {
152770
153532
  request['price'] = price;
153533
+ response = await this.privatePostPlaceLimitOrder(this.extend(request, params));
153534
+ }
153535
+ else {
153536
+ response = await this.privatePostPlaceMarketOrder(this.extend(request, params));
152771
153537
  }
152772
- request['volume'] = amount;
152773
- const response = await this[method](this.extend(request, params));
152774
153538
  return this.safeOrder({
152775
153539
  'info': response,
152776
153540
  'id': response['OrderGuid'],
@@ -153960,8 +154724,8 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
153960
154724
  'createOrder': true,
153961
154725
  'createStopLimitOrder': true,
153962
154726
  'createStopMarketOrder': true,
153963
- 'createTrailingAmountOrder': true,
153964
154727
  'createStopOrder': true,
154728
+ 'createTrailingAmountOrder': true,
153965
154729
  'editOrder': true,
153966
154730
  'fetchBalance': true,
153967
154731
  'fetchBorrowInterest': false,
@@ -155186,12 +155950,8 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155186
155950
  request['since'] = since * 1e6;
155187
155951
  request['since'] = since.toString() + '000000'; // expected to be in nanoseconds
155188
155952
  }
155189
- // https://github.com/ccxt/ccxt/issues/5698
155190
- if (limit !== undefined && limit !== 1000) {
155191
- const fetchTradesWarning = this.safeValue(this.options, 'fetchTradesWarning', true);
155192
- if (fetchTradesWarning) {
155193
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' fetchTrades() cannot serve ' + limit.toString() + " trades without breaking the pagination, see https://github.com/ccxt/ccxt/issues/5698 for more details. Set exchange.options['fetchTradesWarning'] to acknowledge this warning and silence it.");
155194
- }
155953
+ if (limit !== undefined) {
155954
+ request['count'] = limit;
155195
155955
  }
155196
155956
  const response = await this.publicGetTrades(this.extend(request, params));
155197
155957
  //
@@ -155546,27 +156306,39 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155546
156306
  const trailingAmount = this.safeString(params, 'trailingAmount');
155547
156307
  const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
155548
156308
  const isTrailingAmountOrder = trailingAmount !== undefined;
155549
- if ((type === 'limit') && !isTrailingAmountOrder) {
156309
+ const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
156310
+ if (isLimitOrder && !isTrailingAmountOrder) {
155550
156311
  request['price'] = this.priceToPrecision(symbol, price);
155551
156312
  }
155552
- let reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
156313
+ const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
155553
156314
  if (isStopLossOrTakeProfitTrigger) {
155554
156315
  if (isStopLossTriggerOrder) {
155555
156316
  request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
155556
- request['ordertype'] = 'stop-loss-limit';
156317
+ if (isLimitOrder) {
156318
+ request['ordertype'] = 'stop-loss-limit';
156319
+ }
156320
+ else {
156321
+ request['ordertype'] = 'stop-loss';
156322
+ }
155557
156323
  }
155558
156324
  else if (isTakeProfitTriggerOrder) {
155559
156325
  request['price'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
155560
- request['ordertype'] = 'take-profit-limit';
156326
+ if (isLimitOrder) {
156327
+ request['ordertype'] = 'take-profit-limit';
156328
+ }
156329
+ else {
156330
+ request['ordertype'] = 'take-profit';
156331
+ }
156332
+ }
156333
+ if (isLimitOrder) {
156334
+ request['price2'] = this.priceToPrecision(symbol, price);
155561
156335
  }
155562
- request['price2'] = this.priceToPrecision(symbol, price);
155563
- reduceOnly = true;
155564
156336
  }
155565
156337
  else if (isTrailingAmountOrder) {
155566
156338
  const trailingActivationPriceType = this.safeString(params, 'trigger', 'last');
155567
156339
  const trailingAmountString = '+' + trailingAmount;
155568
156340
  request['trigger'] = trailingActivationPriceType;
155569
- if ((type === 'limit') || (trailingLimitAmount !== undefined)) {
156341
+ if (isLimitOrder || (trailingLimitAmount !== undefined)) {
155570
156342
  const offset = this.safeString(params, 'offset', '-');
155571
156343
  const trailingLimitAmountString = offset + this.numberToString(trailingLimitAmount);
155572
156344
  request['price'] = trailingAmountString;
@@ -159257,6 +160029,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
159257
160029
  'createPostOnlyOrder': true,
159258
160030
  'createStopLimitOrder': true,
159259
160031
  'createStopMarketOrder': true,
160032
+ 'createTriggerOrder': true,
159260
160033
  'createStopOrder': true,
159261
160034
  'editOrder': true,
159262
160035
  'fetchAccounts': true,
@@ -159524,6 +160297,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
159524
160297
  'premium/query': 4.5,
159525
160298
  'trade-statistics': 4.5,
159526
160299
  'funding-rate/{symbol}/current': 3,
160300
+ 'contract/funding-rates': 7.5,
159527
160301
  'timestamp': 3,
159528
160302
  'status': 6,
159529
160303
  // ?
@@ -159553,6 +160327,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
159553
160327
  'openOrderStatistics': 15,
159554
160328
  'position': 3,
159555
160329
  'positions': 3,
160330
+ 'margin/maxWithdrawMargin': 15,
159556
160331
  'contracts/risk-limit/{symbol}': 7.5,
159557
160332
  'funding-history': 7.5, // 5FW
159558
160333
  },
@@ -159563,7 +160338,9 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
159563
160338
  // futures
159564
160339
  'orders': 3,
159565
160340
  'orders/test': 3,
160341
+ 'orders/multi': 4.5,
159566
160342
  'position/margin/auto-deposit-status': 6,
160343
+ 'margin/withdrawMargin': 15,
159567
160344
  'position/margin/deposit-margin': 6,
159568
160345
  'position/risk-limit-level/change': 6,
159569
160346
  // ws
@@ -163742,10 +164519,14 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
163742
164519
  'closePositions': false,
163743
164520
  'createDepositAddress': true,
163744
164521
  'createOrder': true,
164522
+ 'createOrders': true,
163745
164523
  'createReduceOnlyOrder': true,
163746
164524
  'createStopLimitOrder': true,
163747
164525
  'createStopMarketOrder': true,
163748
164526
  'createStopOrder': true,
164527
+ 'createTriggerOrder': true,
164528
+ 'createTakeProfitOrder': true,
164529
+ 'createStopLossOrder': true,
163749
164530
  'fetchAccounts': true,
163750
164531
  'fetchBalance': true,
163751
164532
  'fetchBorrowRateHistories': false,
@@ -163760,7 +164541,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
163760
164541
  'fetchDepositWithdrawFees': false,
163761
164542
  'fetchFundingHistory': true,
163762
164543
  'fetchFundingRate': true,
163763
- 'fetchFundingRateHistory': false,
164544
+ 'fetchFundingRateHistory': true,
163764
164545
  'fetchIndexOHLCV': false,
163765
164546
  'fetchIsolatedBorrowRate': false,
163766
164547
  'fetchIsolatedBorrowRates': false,
@@ -164821,6 +165602,78 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
164821
165602
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
164822
165603
  */
164823
165604
  await this.loadMarkets();
165605
+ const market = this.market(symbol);
165606
+ const testOrder = this.safeValue(params, 'test', false);
165607
+ params = this.omit(params, 'test');
165608
+ const orderRequest = this.createContractOrderRequest(symbol, type, side, amount, price, params);
165609
+ let response = undefined;
165610
+ if (testOrder) {
165611
+ response = await this.futuresPrivatePostOrdersTest(orderRequest);
165612
+ }
165613
+ else {
165614
+ response = await this.futuresPrivatePostOrders(orderRequest);
165615
+ }
165616
+ //
165617
+ // {
165618
+ // "code": "200000",
165619
+ // "data": {
165620
+ // "orderId": "619717484f1d010001510cde",
165621
+ // },
165622
+ // }
165623
+ //
165624
+ const data = this.safeValue(response, 'data', {});
165625
+ return this.parseOrder(data, market);
165626
+ }
165627
+ async createOrders(orders, params = {}) {
165628
+ /**
165629
+ * @method
165630
+ * @name kucoinfutures#createOrders
165631
+ * @description create a list of trade orders
165632
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/place-multiple-orders
165633
+ * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
165634
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
165635
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
165636
+ */
165637
+ await this.loadMarkets();
165638
+ const ordersRequests = [];
165639
+ for (let i = 0; i < orders.length; i++) {
165640
+ const rawOrder = orders[i];
165641
+ const symbol = this.safeString(rawOrder, 'symbol');
165642
+ const market = this.market(symbol);
165643
+ const type = this.safeString(rawOrder, 'type');
165644
+ const side = this.safeString(rawOrder, 'side');
165645
+ const amount = this.safeValue(rawOrder, 'amount');
165646
+ const price = this.safeValue(rawOrder, 'price');
165647
+ const orderParams = this.safeValue(rawOrder, 'params', {});
165648
+ const orderRequest = this.createContractOrderRequest(market['id'], type, side, amount, price, orderParams);
165649
+ ordersRequests.push(orderRequest);
165650
+ }
165651
+ const response = await this.futuresPrivatePostOrdersMulti(ordersRequests);
165652
+ //
165653
+ // {
165654
+ // "code": "200000",
165655
+ // "data": [
165656
+ // {
165657
+ // "orderId": "135241412609331200",
165658
+ // "clientOid": "3d8fcc13-0b13-447f-ad30-4b3441e05213",
165659
+ // "symbol": "LTCUSDTM",
165660
+ // "code": "200000",
165661
+ // "msg": "success"
165662
+ // },
165663
+ // {
165664
+ // "orderId": "135241412747743234",
165665
+ // "clientOid": "b878c7ee-ae3e-4d63-a20b-038acbb7306f",
165666
+ // "symbol": "LTCUSDTM",
165667
+ // "code": "200000",
165668
+ // "msg": "success"
165669
+ // }
165670
+ // ]
165671
+ // }
165672
+ //
165673
+ const data = this.safeValue(response, 'data', []);
165674
+ return this.parseOrders(data);
165675
+ }
165676
+ createContractOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
164824
165677
  const market = this.market(symbol);
164825
165678
  // required param, cannot be used twice
164826
165679
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId', this.uuid());
@@ -164893,48 +165746,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
164893
165746
  }
164894
165747
  }
164895
165748
  params = this.omit(params, ['timeInForce', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']); // Time in force only valid for limit orders, exchange error when gtc for market orders
164896
- let response = undefined;
164897
- const testOrder = this.safeValue(params, 'test', false);
164898
- params = this.omit(params, 'test');
164899
- if (testOrder) {
164900
- response = await this.futuresPrivatePostOrdersTest(this.extend(request, params));
164901
- }
164902
- else {
164903
- response = await this.futuresPrivatePostOrders(this.extend(request, params));
164904
- }
164905
- //
164906
- // {
164907
- // "code": "200000",
164908
- // "data": {
164909
- // "orderId": "619717484f1d010001510cde",
164910
- // },
164911
- // }
164912
- //
164913
- const data = this.safeValue(response, 'data', {});
164914
- return this.safeOrder({
164915
- 'id': this.safeString(data, 'orderId'),
164916
- 'clientOrderId': undefined,
164917
- 'timestamp': undefined,
164918
- 'datetime': undefined,
164919
- 'lastTradeTimestamp': undefined,
164920
- 'symbol': undefined,
164921
- 'type': undefined,
164922
- 'side': undefined,
164923
- 'price': undefined,
164924
- 'amount': undefined,
164925
- 'cost': undefined,
164926
- 'average': undefined,
164927
- 'filled': undefined,
164928
- 'remaining': undefined,
164929
- 'status': undefined,
164930
- 'fee': undefined,
164931
- 'trades': undefined,
164932
- 'timeInForce': undefined,
164933
- 'postOnly': undefined,
164934
- 'stopPrice': undefined,
164935
- 'triggerPrice': undefined,
164936
- 'info': response,
164937
- }, market);
165749
+ return this.extend(request, params);
164938
165750
  }
164939
165751
  async cancelOrder(id, symbol = undefined, params = {}) {
164940
165752
  /**
@@ -165407,10 +166219,26 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
165407
166219
  // "reduceOnly": false
165408
166220
  // }
165409
166221
  //
166222
+ // createOrder
166223
+ //
166224
+ // {
166225
+ // "orderId": "619717484f1d010001510cde"
166226
+ // }
166227
+ //
166228
+ // createOrders
166229
+ //
166230
+ // {
166231
+ // "orderId": "80465574458560512",
166232
+ // "clientOid": "5c52e11203aa677f33e491",
166233
+ // "symbol": "ETHUSDTM",
166234
+ // "code": "200000",
166235
+ // "msg": "success"
166236
+ // }
166237
+ //
165410
166238
  const marketId = this.safeString(order, 'symbol');
165411
166239
  market = this.safeMarket(marketId, market);
165412
166240
  const symbol = market['symbol'];
165413
- const orderId = this.safeString(order, 'id');
166241
+ const orderId = this.safeString2(order, 'id', 'orderId');
165414
166242
  const type = this.safeString(order, 'type');
165415
166243
  const timestamp = this.safeInteger(order, 'createdAt');
165416
166244
  const datetime = this.iso8601(timestamp);
@@ -165437,9 +166265,12 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
165437
166265
  // precision reported by their api is 8 d.p.
165438
166266
  // const average = Precise.stringDiv (cost, Precise.stringMul (filled, market['contractSize']));
165439
166267
  // bool
165440
- const isActive = this.safeValue(order, 'isActive', false);
166268
+ const isActive = this.safeValue(order, 'isActive');
165441
166269
  const cancelExist = this.safeValue(order, 'cancelExist', false);
165442
- let status = isActive ? 'open' : 'closed';
166270
+ let status = undefined;
166271
+ if (isActive !== undefined) {
166272
+ status = isActive ? 'open' : 'closed';
166273
+ }
165443
166274
  status = cancelExist ? 'canceled' : status;
165444
166275
  let fee = undefined;
165445
166276
  if (feeCost !== undefined) {
@@ -166084,62 +166915,62 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
166084
166915
  /**
166085
166916
  * @method
166086
166917
  * @name kucoinfutures#fetchFundingRateHistory
166918
+ * @see https://www.kucoin.com/docs/rest/futures-trading/funding-fees/get-public-funding-history#request-url
166087
166919
  * @description fetches historical funding rate prices
166088
166920
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
166089
166921
  * @param {int} [since] not used by kucuoinfutures
166090
166922
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
166091
166923
  * @param {object} [params] extra parameters specific to the exchange API endpoint
166092
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
166924
+ * @param {int} [params.until] end time in ms
166093
166925
  * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
166094
166926
  */
166095
166927
  if (symbol === undefined) {
166096
166928
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
166097
166929
  }
166098
166930
  await this.loadMarkets();
166099
- let paginate = false;
166100
- [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
166101
- if (paginate) {
166102
- return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params);
166103
- }
166104
166931
  const market = this.market(symbol);
166105
166932
  const request = {
166106
166933
  'symbol': market['id'],
166934
+ 'from': 0,
166935
+ 'to': this.milliseconds(),
166107
166936
  };
166108
- if (limit !== undefined) {
166109
- request['maxCount'] = limit;
166937
+ const until = this.safeInteger2(params, 'until', 'till');
166938
+ params = this.omit(params, ['until', 'till']);
166939
+ if (since !== undefined) {
166940
+ request['from'] = since;
166941
+ if (until === undefined) {
166942
+ request['to'] = since + 1000 * 8 * 60 * 60 * 100;
166943
+ }
166944
+ }
166945
+ if (until !== undefined) {
166946
+ request['to'] = until;
166947
+ if (since === undefined) {
166948
+ request['to'] = until - 1000 * 8 * 60 * 60 * 100;
166949
+ }
166110
166950
  }
166111
- const response = await this.webExchangeGetContractSymbolFundingRates(this.extend(request, params));
166951
+ const response = await this.futuresPublicGetContractFundingRates(this.extend(request, params));
166112
166952
  //
166113
- // {
166114
- // "success": true,
166115
- // "code": "200",
166116
- // "msg": "success",
166117
- // "retry": false,
166118
- // "data": {
166119
- // "dataList": [
166120
- // {
166121
- // "symbol": "XBTUSDTM",
166122
- // "granularity": 28800000,
166123
- // "timePoint": 1675108800000,
166124
- // "value": 0.0001
166125
- // },
166126
- // ...
166127
- // ],
166128
- // "hasMore": true
166129
- // }
166130
- // }
166953
+ // {
166954
+ // "code": "200000",
166955
+ // "data": [
166956
+ // {
166957
+ // "symbol": "IDUSDTM",
166958
+ // "fundingRate": 2.26E-4,
166959
+ // "timepoint": 1702296000000
166960
+ // }
166961
+ // ]
166962
+ // }
166131
166963
  //
166132
166964
  const data = this.safeValue(response, 'data');
166133
- const dataList = this.safeValue(data, 'dataList');
166134
- return this.parseFundingRateHistories(dataList, market, since, limit);
166965
+ return this.parseFundingRateHistories(data, market, since, limit);
166135
166966
  }
166136
166967
  parseFundingRateHistory(info, market = undefined) {
166137
- const timestamp = this.safeInteger(info, 'timePoint');
166968
+ const timestamp = this.safeInteger(info, 'timepoint');
166138
166969
  const marketId = this.safeString(info, 'symbol');
166139
166970
  return {
166140
166971
  'info': info,
166141
166972
  'symbol': this.safeSymbol(marketId, market),
166142
- 'fundingRate': this.safeNumber(info, 'value'),
166973
+ 'fundingRate': this.safeNumber(info, 'fundingRate'),
166143
166974
  'timestamp': timestamp,
166144
166975
  'datetime': this.iso8601(timestamp),
166145
166976
  };
@@ -170823,13 +171654,17 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
170823
171654
  else {
170824
171655
  request['size'] = 600; // max
170825
171656
  }
170826
- let method = this.safeString(params, 'method');
171657
+ const options = this.safeValue(this.options, 'fetchTrades', {});
171658
+ const defaultMethod = this.safeString(options, 'method', 'spotPublicGetTrades');
171659
+ const method = this.safeString(params, 'method', defaultMethod);
170827
171660
  params = this.omit(params, 'method');
170828
- if (method === undefined) {
170829
- const options = this.safeValue(this.options, 'fetchTrades', {});
170830
- method = this.safeString(options, 'method', 'spotPublicGetTrades');
171661
+ let response = undefined;
171662
+ if (method === 'spotPublicGetSupplementTrades') {
171663
+ response = await this.spotPublicGetSupplementTrades(this.extend(request, params));
171664
+ }
171665
+ else {
171666
+ response = await this.spotPublicGetTrades(this.extend(request, params));
170831
171667
  }
170832
- const response = await this[method](this.extend(request, params));
170833
171668
  //
170834
171669
  // {
170835
171670
  // "result":"true",
@@ -171066,12 +171901,19 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
171066
171901
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
171067
171902
  */
171068
171903
  await this.loadMarkets();
171069
- let method = this.safeString(params, 'method');
171070
- if (method === undefined) {
171071
- const options = this.safeValue(this.options, 'fetchBalance', {});
171072
- method = this.safeString(options, 'method', 'spotPrivatePostSupplementUserInfo');
171904
+ const options = this.safeValue(this.options, 'fetchBalance', {});
171905
+ const defaultMethod = this.safeString(options, 'method', 'spotPrivatePostSupplementUserInfo');
171906
+ const method = this.safeString(params, 'method', defaultMethod);
171907
+ let response = undefined;
171908
+ if (method === 'spotPrivatePostSupplementUserInfoAccount') {
171909
+ response = await this.spotPrivatePostSupplementUserInfoAccount();
171910
+ }
171911
+ else if (method === 'spotPrivatePostUserInfo') {
171912
+ response = await this.spotPrivatePostUserInfo();
171913
+ }
171914
+ else {
171915
+ response = await this.spotPrivatePostSupplementUserInfo();
171073
171916
  }
171074
- const response = await this[method]();
171075
171917
  //
171076
171918
  // {
171077
171919
  // "result": "true",
@@ -171256,14 +172098,17 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
171256
172098
  if (clientOrderId !== undefined) {
171257
172099
  request['custom_id'] = clientOrderId;
171258
172100
  }
171259
- let method = undefined;
171260
- method = this.safeString(params, 'method');
172101
+ const options = this.safeValue(this.options, 'createOrder', {});
172102
+ const defaultMethod = this.safeString(options, 'method', 'spotPrivatePostSupplementCreateOrder');
172103
+ const method = this.safeString(params, 'method', defaultMethod);
171261
172104
  params = this.omit(params, 'method');
171262
- if (method === undefined) {
171263
- const options = this.safeValue(this.options, 'createOrder', {});
171264
- method = this.safeString(options, 'method', 'spotPrivatePostSupplementCreateOrder');
172105
+ let response = undefined;
172106
+ if (method === 'spotPrivatePostCreateOrder') {
172107
+ response = await this.spotPrivatePostCreateOrder(this.extend(request, params));
172108
+ }
172109
+ else {
172110
+ response = await this.spotPrivatePostSupplementCreateOrder(this.extend(request, params));
171265
172111
  }
171266
- const response = await this[method](this.extend(request, params));
171267
172112
  //
171268
172113
  // {
171269
172114
  // "result":true,
@@ -171798,13 +172643,18 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
171798
172643
  * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
171799
172644
  */
171800
172645
  await this.loadMarkets();
171801
- let method = this.safeString(params, 'method');
172646
+ const options = this.safeValue(this.options, 'fetchDepositAddress', {});
172647
+ const defaultMethod = this.safeString(options, 'method', 'fetchDepositAddressDefault');
172648
+ const method = this.safeString(params, 'method', defaultMethod);
171802
172649
  params = this.omit(params, 'method');
171803
- if (method === undefined) {
171804
- const options = this.safeValue(this.options, 'fetchDepositAddress', {});
171805
- method = this.safeString(options, 'method', 'fetchDepositAddressDefault');
172650
+ let response = undefined;
172651
+ if (method === 'fetchDepositAddressSupplement') {
172652
+ response = await this.fetchDepositAddressSupplement(code, params);
171806
172653
  }
171807
- return await this[method](code, params);
172654
+ else {
172655
+ response = await this.fetchDepositAddressDefault(code, params);
172656
+ }
172657
+ return response;
171808
172658
  }
171809
172659
  async fetchDepositAddressDefault(code, params = {}) {
171810
172660
  await this.loadMarkets();
@@ -172176,13 +173026,16 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
172176
173026
  const isAuthorized = this.checkRequiredCredentials(false);
172177
173027
  let result = undefined;
172178
173028
  if (isAuthorized === true) {
172179
- let method = this.safeString(params, 'method');
173029
+ const options = this.safeValue(this.options, 'fetchTransactionFees', {});
173030
+ const defaultMethod = this.safeString(options, 'method', 'fetchPrivateTransactionFees');
173031
+ const method = this.safeString(params, 'method', defaultMethod);
172180
173032
  params = this.omit(params, 'method');
172181
- if (method === undefined) {
172182
- const options = this.safeValue(this.options, 'fetchTransactionFees', {});
172183
- method = this.safeString(options, 'method', 'fetchPrivateTransactionFees');
173033
+ if (method === 'fetchPublicTransactionFees') {
173034
+ result = await this.fetchPublicTransactionFees(params);
173035
+ }
173036
+ else {
173037
+ result = await this.fetchPrivateTransactionFees(params);
172184
173038
  }
172185
- result = await this[method](params);
172186
173039
  }
172187
173040
  else {
172188
173041
  result = await this.fetchPublicTransactionFees(params);
@@ -172320,19 +173173,23 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
172320
173173
  */
172321
173174
  await this.loadMarkets();
172322
173175
  const isAuthorized = this.checkRequiredCredentials(false);
172323
- let method = undefined;
173176
+ const response = undefined;
172324
173177
  if (isAuthorized === true) {
172325
- method = this.safeString(params, 'method');
173178
+ const options = this.safeValue(this.options, 'fetchDepositWithdrawFees', {});
173179
+ const defaultMethod = this.safeString(options, 'method', 'fetchPrivateDepositWithdrawFees');
173180
+ const method = this.safeString(params, 'method', defaultMethod);
172326
173181
  params = this.omit(params, 'method');
172327
- if (method === undefined) {
172328
- const options = this.safeValue(this.options, 'fetchDepositWithdrawFees', {});
172329
- method = this.safeString(options, 'method', 'fetchPrivateDepositWithdrawFees');
173182
+ if (method === 'fetchPublicDepositWithdrawFees') {
173183
+ await this.fetchPublicDepositWithdrawFees(codes, params);
173184
+ }
173185
+ else {
173186
+ await this.fetchPrivateDepositWithdrawFees(codes, params);
172330
173187
  }
172331
173188
  }
172332
173189
  else {
172333
- method = 'fetchPublicDepositWithdrawFees';
173190
+ await this.fetchPublicDepositWithdrawFees(codes, params);
172334
173191
  }
172335
- return await this[method](codes, params);
173192
+ return response;
172336
173193
  }
172337
173194
  async fetchPrivateDepositWithdrawFees(codes = undefined, params = {}) {
172338
173195
  // complete response
@@ -185918,7 +186775,7 @@ class oceanex extends _abstract_oceanex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
185918
186775
  'market': market['id'],
185919
186776
  };
185920
186777
  if (limit !== undefined) {
185921
- request['limit'] = limit;
186778
+ request['limit'] = Math.min(limit, 1000);
185922
186779
  }
185923
186780
  const response = await this.publicGetTrades(this.extend(request, params));
185924
186781
  //
@@ -189583,14 +190440,18 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
189583
190440
  'createDepositAddress': false,
189584
190441
  'createMarketBuyOrderWithCost': true,
189585
190442
  'createMarketSellOrderWithCost': true,
189586
- 'createTrailingPercentOrder': true,
189587
190443
  'createOrder': true,
189588
190444
  'createOrders': true,
190445
+ 'createOrderWithTakeProfitAndStopLoss': true,
189589
190446
  'createPostOnlyOrder': true,
189590
190447
  'createReduceOnlyOrder': true,
190448
+ 'createStopLossOrder': true,
189591
190449
  'createStopLimitOrder': true,
189592
190450
  'createStopMarketOrder': true,
189593
190451
  'createStopOrder': true,
190452
+ 'createTakeProfitOrder': true,
190453
+ 'createTrailingPercentOrder': true,
190454
+ 'createTriggerOrder': true,
189594
190455
  'editOrder': true,
189595
190456
  'fetchAccounts': true,
189596
190457
  'fetchBalance': true,
@@ -189804,6 +190665,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
189804
190665
  'sprd/order': 1 / 3,
189805
190666
  'sprd/orders-pending': 1 / 3,
189806
190667
  'sprd/orders-history': 1 / 2,
190668
+ 'sprd/orders-history-archive': 1 / 2,
189807
190669
  'sprd/trades': 1 / 3,
189808
190670
  // trade
189809
190671
  'trade/order': 1 / 3,
@@ -191677,17 +192539,14 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
191677
192539
  let defaultType = 'Candles';
191678
192540
  if (since !== undefined) {
191679
192541
  const now = this.milliseconds();
191680
- const difference = now - since;
191681
192542
  const durationInMilliseconds = duration * 1000;
191682
- // if the since timestamp is more than limit candles back in the past
191683
- // additional one bar for max offset to round the current day to UTC
191684
- const calc = (1440 - limit - 1) * durationInMilliseconds;
191685
- if (difference > calc) {
192543
+ // switch to history candles if since is past the cutoff for current candles
192544
+ const historyBorder = now - ((1440 - 1) * durationInMilliseconds);
192545
+ if (since < historyBorder) {
191686
192546
  defaultType = 'HistoryCandles';
191687
192547
  }
191688
- const startTime = Math.max(since - 1, 0);
191689
- request['before'] = startTime;
191690
- request['after'] = this.sum(startTime, durationInMilliseconds * limit);
192548
+ request['before'] = since;
192549
+ request['after'] = this.sum(since, durationInMilliseconds * limit);
191691
192550
  }
191692
192551
  const until = this.safeInteger(params, 'until');
191693
192552
  if (until !== undefined) {
@@ -199195,7 +200054,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
199195
200054
  },
199196
200055
  },
199197
200056
  'options': {
199198
- 'brokerId': 'CCXT',
200057
+ 'brokerId': 'CCXT123456',
199199
200058
  'x-phemex-request-expiry': 60,
199200
200059
  'createOrderByQuoteRequiresPrice': true,
199201
200060
  'networks': {
@@ -201220,7 +202079,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
201220
202079
  const takeProfit = this.safeValue(params, 'takeProfit');
201221
202080
  const takeProfitDefined = (takeProfit !== undefined);
201222
202081
  if (clientOrderId === undefined) {
201223
- const brokerId = this.safeString(this.options, 'brokerId');
202082
+ const brokerId = this.safeString(this.options, 'brokerId', 'CCXT123456');
201224
202083
  if (brokerId !== undefined) {
201225
202084
  request['clOrdID'] = brokerId + this.uuid16();
201226
202085
  }
@@ -203016,6 +203875,13 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
203016
203875
  };
203017
203876
  let payload = '';
203018
203877
  if (method === 'POST') {
203878
+ const isOrderPlacement = (path === 'g-orders') || (path === 'spot/orders') || (path === 'orders');
203879
+ if (isOrderPlacement) {
203880
+ if (this.safeString(params, 'clOrdID') === undefined) {
203881
+ const id = this.safeString(this.options, 'brokerId', 'CCXT123456');
203882
+ params['clOrdID'] = id + this.uuid16();
203883
+ }
203884
+ }
203019
203885
  payload = this.json(params);
203020
203886
  body = payload;
203021
203887
  headers['Content-Type'] = 'application/json';
@@ -241808,7 +242674,7 @@ class kraken extends _kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
241808
242674
  ],
241809
242675
  'subscription': {
241810
242676
  'name': name,
241811
- 'interval': this.safeString(this.timeframes, timeframe, timeframe),
242677
+ 'interval': this.safeValue(this.timeframes, timeframe, timeframe),
241812
242678
  },
241813
242679
  };
241814
242680
  const request = this.deepExtend(subscribe, params);
@@ -249048,6 +249914,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
249048
249914
  'watchOrderBookForSymbols': true,
249049
249915
  'watchBalance': true,
249050
249916
  'watchOHLCV': true,
249917
+ 'watchOHLCVForSymbols': true,
249051
249918
  'watchOrders': true,
249052
249919
  'watchMyTrades': true,
249053
249920
  'watchPositions': true,
@@ -249384,6 +250251,50 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
249384
250251
  }
249385
250252
  return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
249386
250253
  }
250254
+ async watchOHLCVForSymbols(symbolsAndTimeframes, since = undefined, limit = undefined, params = {}) {
250255
+ /**
250256
+ * @method
250257
+ * @name okx#watchOHLCVForSymbols
250258
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
250259
+ * @param {string[][]} symbolsAndTimeframes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
250260
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
250261
+ * @param {int} [limit] the maximum amount of candles to fetch
250262
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
250263
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
250264
+ */
250265
+ const symbolsLength = symbolsAndTimeframes.length;
250266
+ if (symbolsLength === 0 || !Array.isArray(symbolsAndTimeframes[0])) {
250267
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + " watchOHLCVForSymbols() requires a an array of symbols and timeframes, like [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]");
250268
+ }
250269
+ await this.loadMarkets();
250270
+ const topics = [];
250271
+ const messageHashes = [];
250272
+ for (let i = 0; i < symbolsAndTimeframes.length; i++) {
250273
+ const symbolAndTimeframe = symbolsAndTimeframes[i];
250274
+ const sym = symbolAndTimeframe[0];
250275
+ const tf = symbolAndTimeframe[1];
250276
+ const marketId = this.marketId(sym);
250277
+ const interval = this.safeString(this.timeframes, tf, tf);
250278
+ const channel = 'candle' + interval;
250279
+ const topic = {
250280
+ 'channel': channel,
250281
+ 'instId': marketId,
250282
+ };
250283
+ topics.push(topic);
250284
+ messageHashes.push('multi:' + channel + ':' + sym);
250285
+ }
250286
+ const request = {
250287
+ 'op': 'subscribe',
250288
+ 'args': topics,
250289
+ };
250290
+ const url = this.getUrl('candle', 'public');
250291
+ const [symbol, timeframe, candles] = await this.watchMultiple(url, messageHashes, request, messageHashes);
250292
+ if (this.newUpdates) {
250293
+ limit = candles.getLimit(symbol, limit);
250294
+ }
250295
+ const filtered = this.filterBySinceLimit(candles, since, limit, 0, true);
250296
+ return this.createOHLCVObject(symbol, timeframe, filtered);
250297
+ }
249387
250298
  handleOHLCV(client, message) {
249388
250299
  //
249389
250300
  // {
@@ -249406,7 +250317,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
249406
250317
  const data = this.safeValue(message, 'data', []);
249407
250318
  const marketId = this.safeString(arg, 'instId');
249408
250319
  const market = this.safeMarket(marketId);
249409
- const symbol = market['id'];
250320
+ const symbol = market['symbol'];
249410
250321
  const interval = channel.replace('candle', '');
249411
250322
  // use a reverse lookup in a static map instead
249412
250323
  const timeframe = this.findTimeframe(interval);
@@ -249420,8 +250331,13 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
249420
250331
  this.ohlcvs[symbol][timeframe] = stored;
249421
250332
  }
249422
250333
  stored.append(parsed);
249423
- const messageHash = channel + ':' + marketId;
250334
+ const messageHash = channel + ':' + market['id'];
249424
250335
  client.resolve(stored, messageHash);
250336
+ // for multiOHLCV we need special object, as opposed to other "multi"
250337
+ // methods, because OHLCV response item does not contain symbol
250338
+ // or timeframe, thus otherwise it would be unrecognizable
250339
+ const messageHashForMulti = 'multi:' + channel + ':' + symbol;
250340
+ client.resolve([symbol, timeframe, stored], messageHashForMulti);
249425
250341
  }
249426
250342
  }
249427
250343
  async watchOrderBook(symbol, limit = undefined, params = {}) {
@@ -258515,7 +259431,6 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
258515
259431
  const market = this.market(symbol);
258516
259432
  const request = {
258517
259433
  'market_id': market['id'],
258518
- 'limit': 100,
258519
259434
  'start_time': '1970-01-01T00:00:00.000Z',
258520
259435
  'end_time': this.iso8601(this.milliseconds()),
258521
259436
  };
@@ -258523,7 +259438,10 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
258523
259438
  request['start_time'] = this.iso8601(since);
258524
259439
  }
258525
259440
  if (limit !== undefined) {
258526
- request['limit'] = Math.min(limit, 10000);
259441
+ request['limit'] = Math.min(limit, 1000);
259442
+ }
259443
+ else {
259444
+ request['limit'] = 1000; // required to set any value
258527
259445
  }
258528
259446
  const response = await this.publicGetTrade(this.extend(request, params));
258529
259447
  //
@@ -276616,7 +277534,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
276616
277534
  'priceAsset': market['quoteId'],
276617
277535
  };
276618
277536
  if (limit !== undefined) {
276619
- request['limit'] = limit;
277537
+ request['limit'] = Math.min(limit, 100);
276620
277538
  }
276621
277539
  if (since !== undefined) {
276622
277540
  request['timeStart'] = since;
@@ -280464,13 +281382,17 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
280464
281382
  'createMarketOrder': false,
280465
281383
  'createMarketOrderWithCost': false,
280466
281384
  'createMarketSellOrderWithCost': false,
280467
- 'createTrailingAmountOrder': true,
280468
- 'createTrailingPercentOrder': true,
280469
281385
  'createOrder': true,
280470
281386
  'createReduceOnlyOrder': true,
280471
281387
  'createStopLimitOrder': false,
280472
281388
  'createStopMarketOrder': false,
280473
281389
  'createStopOrder': false,
281390
+ 'createTrailingAmountOrder': true,
281391
+ 'createTrailingPercentOrder': true,
281392
+ 'createTriggerOrder': true,
281393
+ 'createTakeProfitOrder': true,
281394
+ 'createStopLossOrder': true,
281395
+ 'createOrderWithTakeProfitAndStopLoss': true,
280474
281396
  'fetchAccounts': true,
280475
281397
  'fetchBalance': true,
280476
281398
  'fetchCanceledOrders': false,
@@ -281186,6 +282108,56 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
281186
282108
  params['createMarketBuyOrderRequiresPrice'] = false;
281187
282109
  return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
281188
282110
  }
282111
+ async createTrailingAmountOrder(symbol, type, side, amount, price = undefined, trailingAmount = undefined, trailingTriggerPrice = undefined, params = {}) {
282112
+ /**
282113
+ * @method
282114
+ * @name woo#createTrailingAmountOrder
282115
+ * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
282116
+ * @param {string} symbol unified symbol of the market to create an order in
282117
+ * @param {string} type 'market' or 'limit'
282118
+ * @param {string} side 'buy' or 'sell'
282119
+ * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
282120
+ * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
282121
+ * @param {float} trailingAmount the quote amount to trail away from the current market price
282122
+ * @param {float} trailingTriggerPrice the price to activate a trailing order, default uses the price argument
282123
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
282124
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
282125
+ */
282126
+ if (trailingAmount === undefined) {
282127
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createTrailingAmountOrder() requires a trailingAmount argument');
282128
+ }
282129
+ if (trailingTriggerPrice === undefined) {
282130
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createTrailingAmountOrder() requires a trailingTriggerPrice argument');
282131
+ }
282132
+ params['trailingAmount'] = trailingAmount;
282133
+ params['trailingTriggerPrice'] = trailingTriggerPrice;
282134
+ return await this.createOrder(symbol, type, side, amount, price, params);
282135
+ }
282136
+ async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
282137
+ /**
282138
+ * @method
282139
+ * @name woo#createTrailingPercentOrder
282140
+ * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
282141
+ * @param {string} symbol unified symbol of the market to create an order in
282142
+ * @param {string} type 'market' or 'limit'
282143
+ * @param {string} side 'buy' or 'sell'
282144
+ * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
282145
+ * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
282146
+ * @param {float} trailingPercent the percent to trail away from the current market price
282147
+ * @param {float} trailingTriggerPrice the price to activate a trailing order, default uses the price argument
282148
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
282149
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
282150
+ */
282151
+ if (trailingPercent === undefined) {
282152
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createTrailingPercentOrder() requires a trailingPercent argument');
282153
+ }
282154
+ if (trailingTriggerPrice === undefined) {
282155
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createTrailingPercentOrder() requires a trailingTriggerPrice argument');
282156
+ }
282157
+ params['trailingPercent'] = trailingPercent;
282158
+ params['trailingTriggerPrice'] = trailingTriggerPrice;
282159
+ return await this.createOrder(symbol, type, side, amount, price, params);
282160
+ }
281189
282161
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
281190
282162
  /**
281191
282163
  * @method
@@ -292654,7 +293626,7 @@ SOFTWARE.
292654
293626
 
292655
293627
  //-----------------------------------------------------------------------------
292656
293628
  // this is updated by vss.js when building
292657
- const version = '4.2.12';
293629
+ const version = '4.2.14';
292658
293630
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
292659
293631
  //-----------------------------------------------------------------------------
292660
293632