ccxt 4.1.25 → 4.1.27

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.
@@ -38838,7 +38838,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
38838
38838
  'editOrder': true,
38839
38839
  'fetchAccounts': false,
38840
38840
  'fetchBalance': true,
38841
- 'fetchBorrowRate': false,
38841
+ 'fetchBorrowRate': true,
38842
38842
  'fetchBorrowRateHistories': false,
38843
38843
  'fetchBorrowRateHistory': false,
38844
38844
  'fetchBorrowRates': false,
@@ -44977,6 +44977,201 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44977
44977
  'datetime': this.iso8601(timestamp),
44978
44978
  };
44979
44979
  }
44980
+ async fetchBorrowRate(code, params = {}) {
44981
+ /**
44982
+ * @method
44983
+ * @name bitget#fetchBorrowRate
44984
+ * @description fetch the rate of interest to borrow a currency for margin trading
44985
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-margin-interest-rate-and-max-borrowable-amount
44986
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-margin-interest-rate-and-borrowable
44987
+ * @param {string} code unified currency code
44988
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
44989
+ * @param {string} [params.symbol] required for isolated margin
44990
+ * @returns {object} a [borrow rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure}
44991
+ */
44992
+ await this.loadMarkets();
44993
+ const currency = this.currency(code);
44994
+ let market = undefined;
44995
+ const symbol = this.safeString(params, 'symbol');
44996
+ params = this.omit(params, 'symbol');
44997
+ if (symbol !== undefined) {
44998
+ market = this.market(symbol);
44999
+ }
45000
+ const request = {};
45001
+ let response = undefined;
45002
+ let marginMode = undefined;
45003
+ [marginMode, params] = this.handleMarginModeAndParams('fetchBorrowRate', params, 'cross');
45004
+ if ((symbol !== undefined) || (marginMode === 'isolated')) {
45005
+ this.checkRequiredSymbol('fetchBorrowRate', symbol);
45006
+ request['symbol'] = market['info']['symbolName'];
45007
+ response = await this.publicMarginGetIsolatedPublicInterestRateAndLimit(this.extend(request, params));
45008
+ }
45009
+ else if (marginMode === 'cross') {
45010
+ request['coin'] = currency['code'];
45011
+ response = await this.publicMarginGetCrossPublicInterestRateAndLimit(this.extend(request, params));
45012
+ }
45013
+ //
45014
+ // isolated
45015
+ //
45016
+ // {
45017
+ // "code": "00000",
45018
+ // "msg": "success",
45019
+ // "requestTime": 1698208075332,
45020
+ // "data": [
45021
+ // {
45022
+ // "symbol": "BTCUSDT",
45023
+ // "leverage": "10",
45024
+ // "baseCoin": "BTC",
45025
+ // "baseTransferInAble": true,
45026
+ // "baseBorrowAble": true,
45027
+ // "baseDailyInterestRate": "0.00007",
45028
+ // "baseYearlyInterestRate": "0.02555",
45029
+ // "baseMaxBorrowableAmount": "35",
45030
+ // "baseVips": [
45031
+ // {
45032
+ // "level": "0",
45033
+ // "dailyInterestRate": "0.00007",
45034
+ // "yearlyInterestRate": "0.02555",
45035
+ // "discountRate": "1"
45036
+ // },
45037
+ // ],
45038
+ // "quoteCoin": "USDT",
45039
+ // "quoteTransferInAble": true,
45040
+ // "quoteBorrowAble": true,
45041
+ // "quoteDailyInterestRate": "0.00012627",
45042
+ // "quoteYearlyInterestRate": "0.04608855",
45043
+ // "quoteMaxBorrowableAmount": "300000",
45044
+ // "quoteVips": [
45045
+ // {
45046
+ // "level": "0",
45047
+ // "dailyInterestRate": "0.000126279",
45048
+ // "yearlyInterestRate": "0.046091835",
45049
+ // "discountRate": "1"
45050
+ // },
45051
+ // ]
45052
+ // }
45053
+ // ]
45054
+ // }
45055
+ //
45056
+ // cross
45057
+ //
45058
+ // {
45059
+ // "code": "00000",
45060
+ // "msg": "success",
45061
+ // "requestTime": 1698208150986,
45062
+ // "data": [
45063
+ // {
45064
+ // "coin": "BTC",
45065
+ // "leverage": "3",
45066
+ // "transferInAble": true,
45067
+ // "borrowAble": true,
45068
+ // "dailyInterestRate": "0.00007",
45069
+ // "yearlyInterestRate": "0.02555",
45070
+ // "maxBorrowableAmount": "26",
45071
+ // "vips": [
45072
+ // {
45073
+ // "level": "0",
45074
+ // "dailyInterestRate": "0.00007",
45075
+ // "yearlyInterestRate": "0.02555",
45076
+ // "discountRate": "1"
45077
+ // },
45078
+ // ]
45079
+ // }
45080
+ // ]
45081
+ // }
45082
+ //
45083
+ const timestamp = this.safeInteger(response, 'requestTime');
45084
+ const data = this.safeValue(response, 'data', []);
45085
+ const first = this.safeValue(data, 0, {});
45086
+ first['timestamp'] = timestamp;
45087
+ return this.parseBorrowRate(first, currency);
45088
+ }
45089
+ parseBorrowRate(info, currency = undefined) {
45090
+ //
45091
+ // isolated
45092
+ //
45093
+ // {
45094
+ // "symbol": "BTCUSDT",
45095
+ // "leverage": "10",
45096
+ // "baseCoin": "BTC",
45097
+ // "baseTransferInAble": true,
45098
+ // "baseBorrowAble": true,
45099
+ // "baseDailyInterestRate": "0.00007",
45100
+ // "baseYearlyInterestRate": "0.02555",
45101
+ // "baseMaxBorrowableAmount": "35",
45102
+ // "baseVips": [
45103
+ // {
45104
+ // "level": "0",
45105
+ // "dailyInterestRate": "0.00007",
45106
+ // "yearlyInterestRate": "0.02555",
45107
+ // "discountRate": "1"
45108
+ // },
45109
+ // ],
45110
+ // "quoteCoin": "USDT",
45111
+ // "quoteTransferInAble": true,
45112
+ // "quoteBorrowAble": true,
45113
+ // "quoteDailyInterestRate": "0.00012627",
45114
+ // "quoteYearlyInterestRate": "0.04608855",
45115
+ // "quoteMaxBorrowableAmount": "300000",
45116
+ // "quoteVips": [
45117
+ // {
45118
+ // "level": "0",
45119
+ // "dailyInterestRate": "0.000126279",
45120
+ // "yearlyInterestRate": "0.046091835",
45121
+ // "discountRate": "1"
45122
+ // },
45123
+ // ]
45124
+ // }
45125
+ //
45126
+ // cross
45127
+ //
45128
+ // {
45129
+ // "coin": "BTC",
45130
+ // "leverage": "3",
45131
+ // "transferInAble": true,
45132
+ // "borrowAble": true,
45133
+ // "dailyInterestRate": "0.00007",
45134
+ // "yearlyInterestRate": "0.02555",
45135
+ // "maxBorrowableAmount": "26",
45136
+ // "vips": [
45137
+ // {
45138
+ // "level": "0",
45139
+ // "dailyInterestRate": "0.00007",
45140
+ // "yearlyInterestRate": "0.02555",
45141
+ // "discountRate": "1"
45142
+ // },
45143
+ // ]
45144
+ // }
45145
+ //
45146
+ const code = currency['code'];
45147
+ const baseCoin = this.safeString(info, 'baseCoin');
45148
+ const quoteCoin = this.safeString(info, 'quoteCoin');
45149
+ let currencyId = undefined;
45150
+ let interestRate = undefined;
45151
+ if (baseCoin !== undefined) {
45152
+ if (code === baseCoin) {
45153
+ currencyId = baseCoin;
45154
+ interestRate = this.safeNumber(info, 'baseDailyInterestRate');
45155
+ }
45156
+ else if (code === quoteCoin) {
45157
+ currencyId = quoteCoin;
45158
+ interestRate = this.safeNumber(info, 'quoteDailyInterestRate');
45159
+ }
45160
+ }
45161
+ else {
45162
+ currencyId = this.safeString(info, 'coin');
45163
+ interestRate = this.safeNumber(info, 'dailyInterestRate');
45164
+ }
45165
+ const timestamp = this.safeInteger(info, 'timestamp');
45166
+ return {
45167
+ 'currency': this.safeCurrencyCode(currencyId, currency),
45168
+ 'rate': interestRate,
45169
+ 'period': 86400000,
45170
+ 'timestamp': timestamp,
45171
+ 'datetime': this.iso8601(timestamp),
45172
+ 'info': info,
45173
+ };
45174
+ }
44980
45175
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
44981
45176
  if (!response) {
44982
45177
  return undefined; // fallback to default error handler
@@ -53320,6 +53515,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53320
53515
  * @method
53321
53516
  * @name bitopro#fetchCurrencies
53322
53517
  * @description fetches all available currencies on an exchange
53518
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_currency_info.md
53323
53519
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
53324
53520
  * @returns {object} an associative dictionary of currencies
53325
53521
  */
@@ -53382,6 +53578,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53382
53578
  * @method
53383
53579
  * @name bitopro#fetchMarkets
53384
53580
  * @description retrieves data on all markets for bitopro
53581
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_trading_pair_info.md
53385
53582
  * @param {object} [params] extra parameters specific to the exchange api endpoint
53386
53583
  * @returns {object[]} an array of objects representing market data
53387
53584
  */
@@ -53516,6 +53713,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53516
53713
  * @method
53517
53714
  * @name bitopro#fetchTicker
53518
53715
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
53716
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ticker_data.md
53519
53717
  * @param {string} symbol unified symbol of the market to fetch the ticker for
53520
53718
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
53521
53719
  * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -53547,6 +53745,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53547
53745
  * @method
53548
53746
  * @name bitopro#fetchTickers
53549
53747
  * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
53748
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ticker_data.md
53550
53749
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
53551
53750
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
53552
53751
  * @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -53576,6 +53775,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53576
53775
  * @method
53577
53776
  * @name bitopro#fetchOrderBook
53578
53777
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
53778
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_orderbook_data.md
53579
53779
  * @param {string} symbol unified symbol of the market to fetch the order book for
53580
53780
  * @param {int} [limit] the maximum amount of order book entries to return
53581
53781
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
@@ -53706,6 +53906,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53706
53906
  * @method
53707
53907
  * @name bitopro#fetchTrades
53708
53908
  * @description get the list of most recent trades for a particular symbol
53909
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_trades_data.md
53709
53910
  * @param {string} symbol unified symbol of the market to fetch trades for
53710
53911
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
53711
53912
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -53738,6 +53939,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53738
53939
  * @method
53739
53940
  * @name bitopro#fetchTradingFees
53740
53941
  * @description fetch the trading fees for multiple markets
53942
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_limitations_and_fees.md
53741
53943
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
53742
53944
  * @returns {object} a dictionary of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure} indexed by market symbols
53743
53945
  */
@@ -53837,6 +54039,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53837
54039
  * @method
53838
54040
  * @name bitopro#fetchOHLCV
53839
54041
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
54042
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ohlc_data.md
53840
54043
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
53841
54044
  * @param {string} timeframe the length of time each candle represents
53842
54045
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -53959,6 +54162,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
53959
54162
  * @method
53960
54163
  * @name bitopro#fetchBalance
53961
54164
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
54165
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_account_balance.md
53962
54166
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
53963
54167
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
53964
54168
  */
@@ -54086,6 +54290,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54086
54290
  * @method
54087
54291
  * @name bitopro#createOrder
54088
54292
  * @description create a trade order
54293
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/create_an_order.md
54089
54294
  * @param {string} symbol unified symbol of the market to create an order in
54090
54295
  * @param {string} type 'market' or 'limit'
54091
54296
  * @param {string} side 'buy' or 'sell'
@@ -54147,6 +54352,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54147
54352
  * @method
54148
54353
  * @name bitopro#cancelOrder
54149
54354
  * @description cancels an open order
54355
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_an_order.md
54150
54356
  * @param {string} id order id
54151
54357
  * @param {string} symbol unified symbol of the market the order was made in
54152
54358
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
@@ -54178,6 +54384,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54178
54384
  * @method
54179
54385
  * @name bitopro#cancelOrders
54180
54386
  * @description cancel multiple orders
54387
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_batch_orders.md
54181
54388
  * @param {string[]} ids order ids
54182
54389
  * @param {string} symbol unified market symbol
54183
54390
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
@@ -54209,6 +54416,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54209
54416
  * @method
54210
54417
  * @name bitopro#cancelAllOrders
54211
54418
  * @description cancel all open orders
54419
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_all_orders.md
54212
54420
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
54213
54421
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
54214
54422
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -54243,6 +54451,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54243
54451
  * @method
54244
54452
  * @name bitopro#fetchOrder
54245
54453
  * @description fetches information on an order made by the user
54454
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_an_order_data.md
54246
54455
  * @param {string} symbol unified symbol of the market the order was made in
54247
54456
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
54248
54457
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -54287,6 +54496,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54287
54496
  * @method
54288
54497
  * @name bitopro#fetchOrders
54289
54498
  * @description fetches information on multiple orders made by the user
54499
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_orders_data.md
54290
54500
  * @param {string} symbol unified market symbol of the market orders were made in
54291
54501
  * @param {int} [since] the earliest time in ms to fetch orders for
54292
54502
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -54355,6 +54565,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54355
54565
  * @method
54356
54566
  * @name bitopro#fetchClosedOrders
54357
54567
  * @description fetches information on multiple closed orders made by the user
54568
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_orders_data.md
54358
54569
  * @param {string} symbol unified market symbol of the market orders were made in
54359
54570
  * @param {int} [since] the earliest time in ms to fetch orders for
54360
54571
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -54371,6 +54582,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54371
54582
  * @method
54372
54583
  * @name bitopro#fetchMyTrades
54373
54584
  * @description fetch all trades made by the user
54585
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_trades_data.md
54374
54586
  * @param {string} symbol unified market symbol
54375
54587
  * @param {int} [since] the earliest time in ms to fetch trades for
54376
54588
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -54508,6 +54720,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54508
54720
  * @method
54509
54721
  * @name bitopro#fetchDeposits
54510
54722
  * @description fetch all deposits made to an account
54723
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_deposit_invoices_data.md
54511
54724
  * @param {string} code unified currency code
54512
54725
  * @param {int} [since] the earliest time in ms to fetch deposits for
54513
54726
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -54559,6 +54772,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54559
54772
  * @method
54560
54773
  * @name bitopro#fetchWithdrawals
54561
54774
  * @description fetch all withdrawals made from an account
54775
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_withdraw_invoices_data.md
54562
54776
  * @param {string} code unified currency code
54563
54777
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
54564
54778
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -54609,6 +54823,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54609
54823
  * @method
54610
54824
  * @name bitopro#fetchWithdrawal
54611
54825
  * @description fetch data on a currency withdrawal via the withdrawal id
54826
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_an_withdraw_invoice_data.md
54612
54827
  * @param {string} id withdrawal id
54613
54828
  * @param {string} code unified currency code of the currency withdrawn, default is undefined
54614
54829
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
@@ -54648,6 +54863,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54648
54863
  * @method
54649
54864
  * @name bitopro#withdraw
54650
54865
  * @description make a withdrawal
54866
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/create_an_withdraw_invoice.md
54651
54867
  * @param {string} code unified currency code
54652
54868
  * @param {float} amount the amount to withdraw
54653
54869
  * @param {string} address the address to withdraw to
@@ -54723,7 +54939,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
54723
54939
  * @method
54724
54940
  * @name bitopro#fetchDepositWithdrawFees
54725
54941
  * @description fetch deposit and withdraw fees
54726
- * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/v3-1/rest-1/open/currencies.md
54942
+ * @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_currency_info.md
54727
54943
  * @param {string[]|undefined} codes list of unified currency codes
54728
54944
  * @param {object} [params] extra parameters specific to the bitopro api endpoint
54729
54945
  * @returns {object} a list of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
@@ -149402,6 +149618,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
149402
149618
  'cancelOrder': true,
149403
149619
  'createDepositAddress': true,
149404
149620
  'createOrder': true,
149621
+ 'createOrders': true,
149405
149622
  'createPostOnlyOrder': true,
149406
149623
  'createStopLimitOrder': true,
149407
149624
  'createStopMarketOrder': true,
@@ -149584,12 +149801,14 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
149584
149801
  'deposit-addresses': 1,
149585
149802
  'withdrawals': 1,
149586
149803
  'orders': 4,
149804
+ 'orders/test': 4,
149587
149805
  'orders/multi': 20,
149588
149806
  'isolated/borrow': 2,
149589
149807
  'isolated/repay/all': 2,
149590
149808
  'isolated/repay/single': 2,
149591
149809
  'margin/borrow': 1,
149592
149810
  'margin/order': 1,
149811
+ 'margin/order/test': 1,
149593
149812
  'margin/repay/all': 1,
149594
149813
  'margin/repay/single': 1,
149595
149814
  'margin/lend': 1,
@@ -151189,6 +151408,8 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151189
151408
  * @see https://docs.kucoin.com/spot#place-a-new-order-2
151190
151409
  * @see https://docs.kucoin.com/spot#place-a-margin-order
151191
151410
  * @see https://docs.kucoin.com/spot-hf/#place-hf-order
151411
+ * @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-order-test
151412
+ * @see https://www.kucoin.com/docs/rest/margin-trading/orders/place-margin-order-test
151192
151413
  * @param {string} symbol Unified CCXT market symbol
151193
151414
  * @param {string} type 'limit' or 'market'
151194
151415
  * @param {string} side 'buy' or 'sell'
@@ -151218,9 +151439,140 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151218
151439
  * @param {string} [params.stp] '', // self trade prevention, CN, CO, CB or DC
151219
151440
  * @param {bool} [params.autoBorrow] false, // The system will first borrow you funds at the optimal interest rate and then place an order for you
151220
151441
  * @param {bool} [params.hf] false, // true for hf order
151442
+ * @param {bool} [params.test] set to true to test an order, no order will be created but the request will be validated
151221
151443
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
151222
151444
  */
151223
151445
  await this.loadMarkets();
151446
+ const market = this.market(symbol);
151447
+ const testOrder = this.safeValue(params, 'test', false);
151448
+ params = this.omit(params, 'test');
151449
+ const isHf = this.safeValue(params, 'hf', false);
151450
+ const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
151451
+ const tradeType = this.safeString(params, 'tradeType'); // keep it for backward compatibility
151452
+ const isTriggerOrder = (triggerPrice || stopLossPrice || takeProfitPrice);
151453
+ const marginResult = this.handleMarginModeAndParams('createOrder', params);
151454
+ const marginMode = this.safeString(marginResult, 0);
151455
+ const isMarginOrder = tradeType === 'MARGIN_TRADE' || marginMode !== undefined;
151456
+ // don't omit anything before calling createOrderRequest
151457
+ const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
151458
+ let response = undefined;
151459
+ if (testOrder) {
151460
+ if (isMarginOrder) {
151461
+ response = await this.privatePostMarginOrderTest(orderRequest);
151462
+ }
151463
+ else {
151464
+ response = await this.privatePostOrdersTest(orderRequest);
151465
+ }
151466
+ }
151467
+ else if (isHf) {
151468
+ response = await this.privatePostHfOrders(orderRequest);
151469
+ }
151470
+ else if (isTriggerOrder) {
151471
+ response = await this.privatePostStopOrder(orderRequest);
151472
+ }
151473
+ else if (isMarginOrder) {
151474
+ response = await this.privatePostMarginOrder(orderRequest);
151475
+ }
151476
+ else {
151477
+ response = await this.privatePostOrders(orderRequest);
151478
+ }
151479
+ //
151480
+ // {
151481
+ // code: '200000',
151482
+ // data: {
151483
+ // "orderId": "5bd6e9286d99522a52e458de"
151484
+ // }
151485
+ // }
151486
+ //
151487
+ const data = this.safeValue(response, 'data', {});
151488
+ return this.parseOrder(data, market);
151489
+ }
151490
+ async createOrders(orders, params = {}) {
151491
+ /**
151492
+ * @method
151493
+ * @name kucoin#createOrders
151494
+ * @description create a list of trade orders
151495
+ * @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-multiple-orders
151496
+ * @see https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/place-multiple-hf-orders
151497
+ * @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
151498
+ * @param {object} [params] Extra parameters specific to the exchange API endpoint
151499
+ * @param {bool} [params.hf] false, // true for hf orders
151500
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
151501
+ */
151502
+ await this.loadMarkets();
151503
+ const ordersRequests = [];
151504
+ let symbol = undefined;
151505
+ for (let i = 0; i < orders.length; i++) {
151506
+ const rawOrder = orders[i];
151507
+ const marketId = this.safeString(rawOrder, 'symbol');
151508
+ if (symbol === undefined) {
151509
+ symbol = marketId;
151510
+ }
151511
+ else {
151512
+ if (symbol !== marketId) {
151513
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
151514
+ }
151515
+ }
151516
+ const type = this.safeString(rawOrder, 'type');
151517
+ if (type !== 'limit') {
151518
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrders() only supports limit orders');
151519
+ }
151520
+ const side = this.safeString(rawOrder, 'side');
151521
+ const amount = this.safeValue(rawOrder, 'amount');
151522
+ const price = this.safeValue(rawOrder, 'price');
151523
+ const orderParams = this.safeValue(rawOrder, 'params', {});
151524
+ const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
151525
+ ordersRequests.push(orderRequest);
151526
+ }
151527
+ const market = this.market(symbol);
151528
+ const request = {
151529
+ 'symbol': market['id'],
151530
+ 'orderList': ordersRequests,
151531
+ };
151532
+ const hf = this.safeValue(params, 'hf', false);
151533
+ params = this.omit(params, 'hf');
151534
+ let response = undefined;
151535
+ if (hf) {
151536
+ response = await this.privatePostHfOrdersMulti(this.extend(request, params));
151537
+ }
151538
+ else {
151539
+ response = await this.privatePostOrdersMulti(this.extend(request, params));
151540
+ }
151541
+ //
151542
+ // {
151543
+ // "code": "200000",
151544
+ // "data": {
151545
+ // "data": [
151546
+ // {
151547
+ // "symbol": "LTC-USDT",
151548
+ // "type": "limit",
151549
+ // "side": "sell",
151550
+ // "price": "90",
151551
+ // "size": "0.1",
151552
+ // "funds": null,
151553
+ // "stp": "",
151554
+ // "stop": "",
151555
+ // "stopPrice": null,
151556
+ // "timeInForce": "GTC",
151557
+ // "cancelAfter": 0,
151558
+ // "postOnly": false,
151559
+ // "hidden": false,
151560
+ // "iceberge": false,
151561
+ // "iceberg": false,
151562
+ // "visibleSize": null,
151563
+ // "channel": "API",
151564
+ // "id": "6539148443fcf500079d15e5",
151565
+ // "status": "success",
151566
+ // "failMsg": null,
151567
+ // "clientOid": "5c4c5398-8ab2-4b4e-af8a-e2d90ad2488f"
151568
+ // },
151569
+ // }
151570
+ //
151571
+ let data = this.safeValue(response, 'data', {});
151572
+ data = this.safeValue(data, 'data', []);
151573
+ return this.parseOrders(data);
151574
+ }
151575
+ createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
151224
151576
  const market = this.market(symbol);
151225
151577
  // required param, cannot be used twice
151226
151578
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId', this.uuid());
@@ -151253,15 +151605,12 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151253
151605
  request['size'] = amountString;
151254
151606
  request['price'] = this.priceToPrecision(symbol, price);
151255
151607
  }
151608
+ const tradeType = this.safeString(params, 'tradeType'); // keep it for backward compatibility
151256
151609
  const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
151610
+ const isTriggerOrder = (triggerPrice || stopLossPrice || takeProfitPrice);
151611
+ const isMarginOrder = tradeType === 'MARGIN_TRADE' || marginMode !== undefined;
151257
151612
  params = this.omit(params, ['stopLossPrice', 'takeProfitPrice', 'triggerPrice', 'stopPrice']);
151258
- const tradeType = this.safeString(params, 'tradeType'); // keep it for backward compatibility
151259
- let method = 'privatePostOrders';
151260
- const isHf = this.safeValue(params, 'hf', false);
151261
- if (isHf) {
151262
- method = 'privatePostHfOrders';
151263
- }
151264
- else if (triggerPrice || stopLossPrice || takeProfitPrice) {
151613
+ if (isTriggerOrder) {
151265
151614
  if (triggerPrice) {
151266
151615
  request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
151267
151616
  }
@@ -151275,7 +151624,6 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151275
151624
  request['stopPrice'] = this.priceToPrecision(symbol, takeProfitPrice);
151276
151625
  }
151277
151626
  }
151278
- method = 'privatePostStopOrder';
151279
151627
  if (marginMode === 'isolated') {
151280
151628
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrder does not support isolated margin for stop orders');
151281
151629
  }
@@ -151283,8 +151631,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151283
151631
  request['tradeType'] = this.options['marginModes'][marginMode];
151284
151632
  }
151285
151633
  }
151286
- else if (tradeType === 'MARGIN_TRADE' || marginMode !== undefined) {
151287
- method = 'privatePostMarginOrder';
151634
+ else if (isMarginOrder) {
151288
151635
  if (marginMode === 'isolated') {
151289
151636
  request['marginModel'] = 'isolated';
151290
151637
  }
@@ -151294,17 +151641,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151294
151641
  if (postOnly) {
151295
151642
  request['postOnly'] = true;
151296
151643
  }
151297
- const response = await this[method](this.extend(request, params));
151298
- //
151299
- // {
151300
- // code: '200000',
151301
- // data: {
151302
- // "orderId": "5bd6e9286d99522a52e458de"
151303
- // }
151304
- // }
151305
- //
151306
- const data = this.safeValue(response, 'data', {});
151307
- return this.parseOrder(data, market);
151644
+ return this.extend(request, params);
151308
151645
  }
151309
151646
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
151310
151647
  /**
@@ -151834,6 +152171,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151834
152171
  const stop = responseStop !== undefined;
151835
152172
  const stopTriggered = this.safeValue(order, 'stopTriggered', false);
151836
152173
  const isActive = this.safeValue2(order, 'isActive', 'active');
152174
+ const responseStatus = this.safeString(order, 'status');
151837
152175
  let status = undefined;
151838
152176
  if (isActive !== undefined) {
151839
152177
  if (isActive === true) {
@@ -151844,7 +152182,6 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151844
152182
  }
151845
152183
  }
151846
152184
  if (stop) {
151847
- const responseStatus = this.safeString(order, 'status');
151848
152185
  if (responseStatus === 'NEW') {
151849
152186
  status = 'open';
151850
152187
  }
@@ -151855,6 +152192,9 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151855
152192
  if (cancelExist) {
151856
152193
  status = 'canceled';
151857
152194
  }
152195
+ if (responseStatus === 'fail') {
152196
+ status = 'rejected';
152197
+ }
151858
152198
  const stopPrice = this.safeNumber(order, 'stopPrice');
151859
152199
  return this.safeOrder({
151860
152200
  'info': order,
@@ -153775,6 +154115,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
153775
154115
  'transfer-out': 1,
153776
154116
  'transfer-in': 1,
153777
154117
  'orders': 1.33,
154118
+ 'orders/test': 1.33,
153778
154119
  'position/margin/auto-deposit-status': 1,
153779
154120
  'position/margin/deposit-margin': 1,
153780
154121
  'position/risk-limit-level/change': 1,
@@ -154721,6 +155062,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
154721
155062
  * @param {string} [params.stop] 'up' or 'down', the direction the stopPrice is triggered from, requires stopPrice. down: Triggers when the price reaches or goes below the stopPrice. up: Triggers when the price reaches or goes above the stopPrice.
154722
155063
  * @param {string} [params.stopPriceType] TP, IP or MP, defaults to MP: Mark Price
154723
155064
  * @param {bool} [params.closeOrder] set to true to close position
155065
+ * @param {bool} [params.test] set to true to use the test order endpoint (does not submit order, use to validate params)
154724
155066
  * @param {bool} [params.forceHold] A mark to forcely hold the funds for an order, even though it's an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default.
154725
155067
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
154726
155068
  */
@@ -154797,7 +155139,15 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
154797
155139
  }
154798
155140
  }
154799
155141
  params = this.omit(params, ['timeInForce', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']); // Time in force only valid for limit orders, exchange error when gtc for market orders
154800
- const response = await this.futuresPrivatePostOrders(this.extend(request, params));
155142
+ let response = undefined;
155143
+ const testOrder = this.safeValue(params, 'test', false);
155144
+ params = this.omit(params, 'test');
155145
+ if (testOrder) {
155146
+ response = await this.futuresPrivatePostOrdersTest(this.extend(request, params));
155147
+ }
155148
+ else {
155149
+ response = await this.futuresPrivatePostOrders(this.extend(request, params));
155150
+ }
154801
155151
  //
154802
155152
  // {
154803
155153
  // code: "200000",
@@ -278718,7 +279068,7 @@ SOFTWARE.
278718
279068
 
278719
279069
  //-----------------------------------------------------------------------------
278720
279070
  // this is updated by vss.js when building
278721
- const version = '4.1.25';
279071
+ const version = '4.1.27';
278722
279072
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
278723
279073
  //-----------------------------------------------------------------------------
278724
279074