ccxt 4.2.76 → 4.2.78

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 (74) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1181 -643
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +6 -0
  6. package/dist/cjs/src/binance.js +502 -443
  7. package/dist/cjs/src/bingx.js +1 -1
  8. package/dist/cjs/src/blofin.js +14 -2
  9. package/dist/cjs/src/bybit.js +106 -60
  10. package/dist/cjs/src/coinbase.js +23 -10
  11. package/dist/cjs/src/delta.js +66 -49
  12. package/dist/cjs/src/gate.js +1 -0
  13. package/dist/cjs/src/htx.js +36 -27
  14. package/dist/cjs/src/hyperliquid.js +7 -5
  15. package/dist/cjs/src/kraken.js +8 -8
  16. package/dist/cjs/src/kucoin.js +204 -5
  17. package/dist/cjs/src/okcoin.js +27 -1
  18. package/dist/cjs/src/okx.js +18 -0
  19. package/dist/cjs/src/pro/ascendex.js +1 -1
  20. package/dist/cjs/src/pro/bitvavo.js +1 -1
  21. package/dist/cjs/src/pro/coinex.js +20 -14
  22. package/dist/cjs/src/pro/deribit.js +1 -1
  23. package/dist/cjs/src/pro/exmo.js +1 -1
  24. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  25. package/dist/cjs/src/pro/phemex.js +1 -1
  26. package/dist/cjs/src/pro/poloniex.js +1 -1
  27. package/dist/cjs/src/pro/probit.js +1 -1
  28. package/dist/cjs/src/pro/woo.js +61 -6
  29. package/dist/cjs/src/woo.js +72 -3
  30. package/js/ccxt.d.ts +1 -1
  31. package/js/ccxt.js +1 -1
  32. package/js/src/abstract/kucoin.d.ts +1 -0
  33. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  34. package/js/src/base/Exchange.d.ts +3 -3
  35. package/js/src/base/Exchange.js +6 -0
  36. package/js/src/base/types.d.ts +3 -3
  37. package/js/src/binance.d.ts +2 -2
  38. package/js/src/binance.js +502 -443
  39. package/js/src/bingx.js +1 -1
  40. package/js/src/bitflyer.d.ts +2 -2
  41. package/js/src/bithumb.d.ts +2 -2
  42. package/js/src/blofin.js +14 -2
  43. package/js/src/bybit.d.ts +1 -1
  44. package/js/src/bybit.js +106 -60
  45. package/js/src/coinbase.d.ts +2 -2
  46. package/js/src/coinbase.js +23 -10
  47. package/js/src/delta.d.ts +2 -1
  48. package/js/src/delta.js +66 -49
  49. package/js/src/deribit.d.ts +1 -1
  50. package/js/src/gate.d.ts +1 -1
  51. package/js/src/gate.js +1 -0
  52. package/js/src/htx.js +36 -27
  53. package/js/src/hyperliquid.js +7 -5
  54. package/js/src/kraken.js +8 -8
  55. package/js/src/kucoin.d.ts +4 -1
  56. package/js/src/kucoin.js +204 -5
  57. package/js/src/okcoin.js +27 -1
  58. package/js/src/okx.d.ts +1 -1
  59. package/js/src/okx.js +18 -0
  60. package/js/src/pro/ascendex.js +1 -1
  61. package/js/src/pro/bitvavo.js +1 -1
  62. package/js/src/pro/coinex.js +20 -14
  63. package/js/src/pro/deribit.js +1 -1
  64. package/js/src/pro/exmo.js +1 -1
  65. package/js/src/pro/krakenfutures.js +1 -1
  66. package/js/src/pro/phemex.js +1 -1
  67. package/js/src/pro/poloniex.js +1 -1
  68. package/js/src/pro/probit.js +1 -1
  69. package/js/src/pro/woo.d.ts +1 -0
  70. package/js/src/pro/woo.js +61 -6
  71. package/js/src/woo.d.ts +2 -0
  72. package/js/src/woo.js +72 -3
  73. package/package.json +1 -1
  74. package/skip-tests.json +6 -3
@@ -452,7 +452,7 @@ class kraken extends kraken$1 {
452
452
  * @method
453
453
  * @name kraken#fetchMarkets
454
454
  * @description retrieves data on all markets for kraken
455
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTradableAssetPairs
455
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTradableAssetPairs
456
456
  * @param {object} [params] extra parameters specific to the exchange API endpoint
457
457
  * @returns {object[]} an array of objects representing market data
458
458
  */
@@ -639,7 +639,7 @@ class kraken extends kraken$1 {
639
639
  * @method
640
640
  * @name kraken#fetchCurrencies
641
641
  * @description fetches all available currencies on an exchange
642
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getAssetInfo
642
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getAssetInfo
643
643
  * @param {object} [params] extra parameters specific to the exchange API endpoint
644
644
  * @returns {object} an associative dictionary of currencies
645
645
  */
@@ -767,7 +767,7 @@ class kraken extends kraken$1 {
767
767
  * @method
768
768
  * @name kraken#fetchOrderBook
769
769
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
770
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getOrderBook
770
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getOrderBook
771
771
  * @param {string} symbol unified symbol of the market to fetch the order book for
772
772
  * @param {int} [limit] the maximum amount of order book entries to return
773
773
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -869,7 +869,7 @@ class kraken extends kraken$1 {
869
869
  * @method
870
870
  * @name kraken#fetchTickers
871
871
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
872
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTickerInformation
872
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTickerInformation
873
873
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
874
874
  * @param {object} [params] extra parameters specific to the exchange API endpoint
875
875
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -906,7 +906,7 @@ class kraken extends kraken$1 {
906
906
  * @method
907
907
  * @name kraken#fetchTicker
908
908
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
909
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTickerInformation
909
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTickerInformation
910
910
  * @param {string} symbol unified symbol of the market to fetch the ticker for
911
911
  * @param {object} [params] extra parameters specific to the exchange API endpoint
912
912
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -951,7 +951,7 @@ class kraken extends kraken$1 {
951
951
  * @method
952
952
  * @name kraken#fetchOHLCV
953
953
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
954
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getOHLCData
954
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getOHLCData
955
955
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
956
956
  * @param {string} timeframe the length of time each candle represents
957
957
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1249,7 +1249,7 @@ class kraken extends kraken$1 {
1249
1249
  * @method
1250
1250
  * @name kraken#fetchTrades
1251
1251
  * @description get the list of most recent trades for a particular symbol
1252
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getRecentTrades
1252
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getRecentTrades
1253
1253
  * @param {string} symbol unified symbol of the market to fetch trades for
1254
1254
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1255
1255
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -2413,7 +2413,7 @@ class kraken extends kraken$1 {
2413
2413
  * @method
2414
2414
  * @name kraken#fetchTime
2415
2415
  * @description fetches the current integer timestamp in milliseconds from the exchange server
2416
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getServerTime
2416
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getServerTime
2417
2417
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2418
2418
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
2419
2419
  */
@@ -52,8 +52,8 @@ class kucoin extends kucoin$1 {
52
52
  'fetchAccounts': true,
53
53
  'fetchBalance': true,
54
54
  'fetchBorrowInterest': true,
55
- 'fetchBorrowRateHistories': false,
56
- 'fetchBorrowRateHistory': false,
55
+ 'fetchBorrowRateHistories': true,
56
+ 'fetchBorrowRateHistory': true,
57
57
  'fetchClosedOrders': true,
58
58
  'fetchCrossBorrowRate': false,
59
59
  'fetchCrossBorrowRates': false,
@@ -227,6 +227,7 @@ class kucoin extends kucoin$1 {
227
227
  'isolated/account/{symbol}': 50,
228
228
  'margin/borrow': 15,
229
229
  'margin/repay': 15,
230
+ 'margin/interest': 20,
230
231
  'project/list': 10,
231
232
  'project/marketInterestRate': 7.5,
232
233
  'redeem/orders': 10,
@@ -445,6 +446,56 @@ class kucoin extends kucoin$1 {
445
446
  '130202': errors.ExchangeError,
446
447
  '130203': errors.InsufficientFunds,
447
448
  '130204': errors.BadRequest,
449
+ '130301': errors.InsufficientFunds,
450
+ '130302': errors.PermissionDenied,
451
+ '130303': errors.NotSupported,
452
+ '130304': errors.NotSupported,
453
+ '130305': errors.NotSupported,
454
+ '130306': errors.NotSupported,
455
+ '130307': errors.NotSupported,
456
+ '130308': errors.InvalidOrder,
457
+ '130309': errors.InvalidOrder,
458
+ '130310': errors.ExchangeError,
459
+ '130311': errors.InvalidOrder,
460
+ '130312': errors.InvalidOrder,
461
+ '130313': errors.InvalidOrder,
462
+ '130314': errors.InvalidOrder,
463
+ '130315': errors.NotSupported,
464
+ '126000': errors.ExchangeError,
465
+ '126001': errors.NotSupported,
466
+ '126002': errors.ExchangeError,
467
+ '126003': errors.InvalidOrder,
468
+ '126004': errors.ExchangeError,
469
+ '126005': errors.PermissionDenied,
470
+ '126006': errors.ExchangeError,
471
+ '126007': errors.ExchangeError,
472
+ '126009': errors.ExchangeError,
473
+ '126010': errors.ExchangeError,
474
+ '126011': errors.ExchangeError,
475
+ '126013': errors.InsufficientFunds,
476
+ '126015': errors.ExchangeError,
477
+ '126021': errors.NotSupported,
478
+ '126022': errors.InvalidOrder,
479
+ '126027': errors.InvalidOrder,
480
+ '126028': errors.InvalidOrder,
481
+ '126029': errors.InvalidOrder,
482
+ '126030': errors.InvalidOrder,
483
+ '126033': errors.InvalidOrder,
484
+ '126034': errors.InvalidOrder,
485
+ '126036': errors.InvalidOrder,
486
+ '126037': errors.ExchangeError,
487
+ '126038': errors.ExchangeError,
488
+ '126039': errors.ExchangeError,
489
+ '126041': errors.ExchangeError,
490
+ '126042': errors.ExchangeError,
491
+ '126043': errors.OrderNotFound,
492
+ '126044': errors.InvalidOrder,
493
+ '126045': errors.NotSupported,
494
+ '126046': errors.NotSupported,
495
+ '126047': errors.PermissionDenied,
496
+ '126048': errors.PermissionDenied,
497
+ '135005': errors.ExchangeError,
498
+ '135018': errors.ExchangeError,
448
499
  '200004': errors.InsufficientFunds,
449
500
  '210014': errors.InvalidOrder,
450
501
  '210021': errors.InsufficientFunds,
@@ -466,10 +517,12 @@ class kucoin extends kucoin$1 {
466
517
  '400350': errors.InvalidOrder,
467
518
  '400370': errors.InvalidOrder,
468
519
  '400400': errors.BadRequest,
520
+ '400401': errors.AuthenticationError,
469
521
  '400500': errors.InvalidOrder,
470
522
  '400600': errors.BadSymbol,
471
523
  '400760': errors.InvalidOrder,
472
524
  '401000': errors.BadRequest,
525
+ '408000': errors.BadRequest,
473
526
  '411100': errors.AccountSuspended,
474
527
  '415000': errors.BadRequest,
475
528
  '400303': errors.PermissionDenied,
@@ -588,6 +641,7 @@ class kucoin extends kucoin$1 {
588
641
  'margin/currencies': 'v3',
589
642
  'margin/borrow': 'v3',
590
643
  'margin/repay': 'v3',
644
+ 'margin/interest': 'v3',
591
645
  'project/list': 'v3',
592
646
  'project/marketInterestRate': 'v3',
593
647
  'redeem/orders': 'v3',
@@ -4042,12 +4096,19 @@ class kucoin extends kucoin$1 {
4042
4096
  // "timestamp": 1658531274508488480
4043
4097
  // },
4044
4098
  //
4045
- const timestampId = this.safeString(info, 'timestamp');
4046
- const timestamp = Precise["default"].stringMul(timestampId, '0.000001');
4099
+ // {
4100
+ // "createdAt": 1697783812257,
4101
+ // "currency": "XMR",
4102
+ // "interestAmount": "0.1",
4103
+ // "dayRatio": "0.001"
4104
+ // }
4105
+ //
4106
+ const timestampId = this.safeString2(info, 'createdAt', 'timestamp');
4107
+ const timestamp = this.parseToInt(timestampId.slice(0, 13));
4047
4108
  const currencyId = this.safeString(info, 'currency');
4048
4109
  return {
4049
4110
  'currency': this.safeCurrencyCode(currencyId, currency),
4050
- 'rate': this.safeNumber(info, 'dailyIntRate'),
4111
+ 'rate': this.safeNumber2(info, 'dailyIntRate', 'dayRatio'),
4051
4112
  'period': 86400000,
4052
4113
  'timestamp': timestamp,
4053
4114
  'datetime': this.iso8601(timestamp),
@@ -4231,6 +4292,144 @@ class kucoin extends kucoin$1 {
4231
4292
  'info': info,
4232
4293
  };
4233
4294
  }
4295
+ async fetchBorrowRateHistories(codes = undefined, since = undefined, limit = undefined, params = {}) {
4296
+ /**
4297
+ * @method
4298
+ * @name kucoin#fetchBorrowRateHistories
4299
+ * @description retrieves a history of a multiple currencies borrow interest rate at specific time slots, returns all currencies if no symbols passed, default is undefined
4300
+ * @see https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/get-cross-isolated-margin-interest-records
4301
+ * @param {string[]|undefined} codes list of unified currency codes, default is undefined
4302
+ * @param {int} [since] timestamp in ms of the earliest borrowRate, default is undefined
4303
+ * @param {int} [limit] max number of borrow rate prices to return, default is undefined
4304
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4305
+ * @param {string} [params.marginMode] 'cross' or 'isolated' default is 'cross'
4306
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4307
+ * @returns {object} a dictionary of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure} indexed by the market symbol
4308
+ */
4309
+ await this.loadMarkets();
4310
+ const marginResult = this.handleMarginModeAndParams('fetchBorrowRateHistories', params);
4311
+ const marginMode = this.safeString(marginResult, 0, 'cross');
4312
+ const isIsolated = (marginMode === 'isolated'); // true-isolated, false-cross
4313
+ let request = {
4314
+ 'isIsolated': isIsolated,
4315
+ };
4316
+ if (since !== undefined) {
4317
+ request['startTime'] = since;
4318
+ }
4319
+ [request, params] = this.handleUntilOption('endTime', request, params);
4320
+ if (limit !== undefined) {
4321
+ request['pageSize'] = limit; // default:50, min:10, max:500
4322
+ }
4323
+ const response = await this.privateGetMarginInterest(this.extend(request, params));
4324
+ //
4325
+ // {
4326
+ // "code": "200000",
4327
+ // "data": {
4328
+ // "timestamp": 1710829939673,
4329
+ // "currentPage": 1,
4330
+ // "pageSize": 50,
4331
+ // "totalNum": 0,
4332
+ // "totalPage": 0,
4333
+ // "items": [
4334
+ // {
4335
+ // "createdAt": 1697783812257,
4336
+ // "currency": "XMR",
4337
+ // "interestAmount": "0.1",
4338
+ // "dayRatio": "0.001"
4339
+ // }
4340
+ // ]
4341
+ // }
4342
+ // }
4343
+ //
4344
+ const data = this.safeDict(response, 'data');
4345
+ const rows = this.safeList(data, 'items');
4346
+ return this.parseBorrowRateHistories(rows, codes, since, limit);
4347
+ }
4348
+ async fetchBorrowRateHistory(code, since = undefined, limit = undefined, params = {}) {
4349
+ /**
4350
+ * @method
4351
+ * @name kucoin#fetchBorrowRateHistory
4352
+ * @description retrieves a history of a currencies borrow interest rate at specific time slots
4353
+ * @see https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/get-cross-isolated-margin-interest-records
4354
+ * @param {string} code unified currency code
4355
+ * @param {int} [since] timestamp for the earliest borrow rate
4356
+ * @param {int} [limit] the maximum number of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure} to retrieve
4357
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4358
+ * @param {string} [params.marginMode] 'cross' or 'isolated' default is 'cross'
4359
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4360
+ * @returns {object[]} an array of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
4361
+ */
4362
+ await this.loadMarkets();
4363
+ const marginResult = this.handleMarginModeAndParams('fetchBorrowRateHistories', params);
4364
+ const marginMode = this.safeString(marginResult, 0, 'cross');
4365
+ const isIsolated = (marginMode === 'isolated'); // true-isolated, false-cross
4366
+ const currency = this.currency(code);
4367
+ let request = {
4368
+ 'isIsolated': isIsolated,
4369
+ 'currency': currency['id'],
4370
+ };
4371
+ if (since !== undefined) {
4372
+ request['startTime'] = since;
4373
+ }
4374
+ [request, params] = this.handleUntilOption('endTime', request, params);
4375
+ if (limit !== undefined) {
4376
+ request['pageSize'] = limit; // default:50, min:10, max:500
4377
+ }
4378
+ const response = await this.privateGetMarginInterest(this.extend(request, params));
4379
+ //
4380
+ // {
4381
+ // "code": "200000",
4382
+ // "data": {
4383
+ // "timestamp": 1710829939673,
4384
+ // "currentPage": 1,
4385
+ // "pageSize": 50,
4386
+ // "totalNum": 0,
4387
+ // "totalPage": 0,
4388
+ // "items": [
4389
+ // {
4390
+ // "createdAt": 1697783812257,
4391
+ // "currency": "XMR",
4392
+ // "interestAmount": "0.1",
4393
+ // "dayRatio": "0.001"
4394
+ // }
4395
+ // ]
4396
+ // }
4397
+ // }
4398
+ //
4399
+ const data = this.safeDict(response, 'data');
4400
+ const rows = this.safeList(data, 'items');
4401
+ return this.parseBorrowRateHistory(rows, code, since, limit);
4402
+ }
4403
+ parseBorrowRateHistories(response, codes, since, limit) {
4404
+ //
4405
+ // [
4406
+ // {
4407
+ // "createdAt": 1697783812257,
4408
+ // "currency": "XMR",
4409
+ // "interestAmount": "0.1",
4410
+ // "dayRatio": "0.001"
4411
+ // }
4412
+ // ]
4413
+ //
4414
+ const borrowRateHistories = {};
4415
+ for (let i = 0; i < response.length; i++) {
4416
+ const item = response[i];
4417
+ const code = this.safeCurrencyCode(this.safeString(item, 'currency'));
4418
+ if (codes === undefined || this.inArray(code, codes)) {
4419
+ if (!(code in borrowRateHistories)) {
4420
+ borrowRateHistories[code] = [];
4421
+ }
4422
+ const borrowRateStructure = this.parseBorrowRate(item);
4423
+ borrowRateHistories[code].push(borrowRateStructure);
4424
+ }
4425
+ }
4426
+ const keys = Object.keys(borrowRateHistories);
4427
+ for (let i = 0; i < keys.length; i++) {
4428
+ const code = keys[i];
4429
+ borrowRateHistories[code] = this.filterByCurrencySinceLimit(borrowRateHistories[code], code, since, limit);
4430
+ }
4431
+ return borrowRateHistories;
4432
+ }
4234
4433
  async borrowCrossMargin(code, amount, params = {}) {
4235
4434
  /**
4236
4435
  * @method
@@ -245,6 +245,16 @@ class okcoin extends okcoin$1 {
245
245
  '50026': errors.ExchangeNotAvailable,
246
246
  '50027': errors.PermissionDenied,
247
247
  '50028': errors.ExchangeError,
248
+ '50029': errors.ExchangeError,
249
+ '50030': errors.PermissionDenied,
250
+ '50032': errors.AccountSuspended,
251
+ '50033': errors.AccountSuspended,
252
+ '50035': errors.BadRequest,
253
+ '50036': errors.BadRequest,
254
+ '50037': errors.BadRequest,
255
+ '50038': errors.ExchangeError,
256
+ '50039': errors.ExchangeError,
257
+ '50041': errors.ExchangeError,
248
258
  '50044': errors.BadRequest,
249
259
  // API Class
250
260
  '50100': errors.ExchangeError,
@@ -288,9 +298,25 @@ class okcoin extends okcoin$1 {
288
298
  '51024': errors.AccountSuspended,
289
299
  '51025': errors.ExchangeError,
290
300
  '51026': errors.BadSymbol,
301
+ '51030': errors.InvalidOrder,
302
+ '51031': errors.InvalidOrder,
303
+ '51032': errors.InvalidOrder,
304
+ '51033': errors.InvalidOrder,
305
+ '51037': errors.InvalidOrder,
306
+ '51038': errors.InvalidOrder,
307
+ '51044': errors.InvalidOrder,
291
308
  '51046': errors.InvalidOrder,
292
309
  '51047': errors.InvalidOrder,
293
- '51031': errors.InvalidOrder,
310
+ '51048': errors.InvalidOrder,
311
+ '51049': errors.InvalidOrder,
312
+ '51050': errors.InvalidOrder,
313
+ '51051': errors.InvalidOrder,
314
+ '51052': errors.InvalidOrder,
315
+ '51053': errors.InvalidOrder,
316
+ '51054': errors.BadRequest,
317
+ '51056': errors.InvalidOrder,
318
+ '51058': errors.InvalidOrder,
319
+ '51059': errors.InvalidOrder,
294
320
  '51100': errors.InvalidOrder,
295
321
  '51102': errors.InvalidOrder,
296
322
  '51103': errors.InvalidOrder,
@@ -573,6 +573,7 @@ class okx extends okx$1 {
573
573
  '50027': errors.PermissionDenied,
574
574
  '50028': errors.ExchangeError,
575
575
  '50044': errors.BadRequest,
576
+ '50061': errors.ExchangeError,
576
577
  '50062': errors.ExchangeError,
577
578
  // API Class
578
579
  '50100': errors.ExchangeError,
@@ -760,6 +761,15 @@ class okx extends okx$1 {
760
761
  // SPOT/MARGIN error codes 54000-54999
761
762
  '54000': errors.ExchangeError,
762
763
  '54001': errors.ExchangeError,
764
+ // Trading bot Error Code from 55100 to 55999
765
+ '55100': errors.InvalidOrder,
766
+ '55101': errors.InvalidOrder,
767
+ '55102': errors.InvalidOrder,
768
+ '55103': errors.InvalidOrder,
769
+ '55104': errors.InvalidOrder,
770
+ '55111': errors.InvalidOrder,
771
+ '55112': errors.InvalidOrder,
772
+ '55113': errors.InvalidOrder,
763
773
  // FUNDING error codes 58000-58999
764
774
  '58000': errors.ExchangeError,
765
775
  '58001': errors.AuthenticationError,
@@ -5021,6 +5031,14 @@ class okx extends okx$1 {
5021
5031
  '3': 'pending',
5022
5032
  '4': 'pending',
5023
5033
  '5': 'pending',
5034
+ '6': 'pending',
5035
+ '7': 'pending',
5036
+ '8': 'pending',
5037
+ '9': 'pending',
5038
+ '10': 'pending',
5039
+ '12': 'pending',
5040
+ '15': 'pending',
5041
+ '16': 'pending',
5024
5042
  };
5025
5043
  return this.safeString(statuses, status, status);
5026
5044
  }
@@ -961,7 +961,7 @@ class ascendex extends ascendex$1 {
961
961
  'key': this.apiKey,
962
962
  'sig': signature,
963
963
  };
964
- future = this.watch(url, messageHash, this.extend(request, params));
964
+ future = await this.watch(url, messageHash, this.extend(request, params), messageHash);
965
965
  client.subscriptions[messageHash] = future;
966
966
  }
967
967
  return future;
@@ -1212,7 +1212,7 @@ class bitvavo extends bitvavo$1 {
1212
1212
  'timestamp': timestamp,
1213
1213
  };
1214
1214
  const message = this.extend(request, params);
1215
- future = this.watch(url, messageHash, message);
1215
+ future = await this.watch(url, messageHash, message, messageHash);
1216
1216
  client.subscriptions[messageHash] = future;
1217
1217
  }
1218
1218
  return future;
@@ -1016,8 +1016,12 @@ class coinex extends coinex$1 {
1016
1016
  //
1017
1017
  const messageHashSpot = 'authenticated:spot';
1018
1018
  const messageHashSwap = 'authenticated:swap';
1019
- client.resolve(message, messageHashSpot);
1020
- client.resolve(message, messageHashSwap);
1019
+ // client.resolve (message, messageHashSpot);
1020
+ // client.resolve (message, messageHashSwap);
1021
+ const spotFuture = this.safeValue(client.futures, messageHashSpot);
1022
+ spotFuture.resolve(true);
1023
+ const swapFutures = this.safeValue(client.futures, messageHashSwap);
1024
+ swapFutures.resolve(true);
1021
1025
  return message;
1022
1026
  }
1023
1027
  handleSubscriptionStatus(client, message) {
@@ -1042,16 +1046,20 @@ class coinex extends coinex$1 {
1042
1046
  const url = this.urls['api']['ws'][type];
1043
1047
  const client = this.client(url);
1044
1048
  const time = this.milliseconds();
1049
+ const isSpot = (type === 'spot');
1050
+ const spotMessageHash = 'authenticated:spot';
1051
+ const swapMessageHash = 'authenticated:swap';
1052
+ const messageHash = isSpot ? spotMessageHash : swapMessageHash;
1053
+ const future = client.future(messageHash);
1054
+ const authenticated = this.safeValue(client.subscriptions, messageHash);
1045
1055
  if (type === 'spot') {
1046
- const messageHash = 'authenticated:spot';
1047
- let future = this.safeValue(client.subscriptions, messageHash);
1048
- if (future !== undefined) {
1056
+ if (authenticated !== undefined) {
1049
1057
  return await future;
1050
1058
  }
1051
1059
  const requestId = this.requestId();
1052
1060
  const subscribe = {
1053
1061
  'id': requestId,
1054
- 'future': 'authenticated:spot',
1062
+ 'future': spotMessageHash,
1055
1063
  };
1056
1064
  const signData = 'access_id=' + this.apiKey + '&tonce=' + this.numberToString(time) + '&secret_key=' + this.secret;
1057
1065
  const hash = this.hash(this.encode(signData), md5.md5);
@@ -1064,20 +1072,18 @@ class coinex extends coinex$1 {
1064
1072
  ],
1065
1073
  'id': requestId,
1066
1074
  };
1067
- future = this.watch(url, messageHash, request, requestId, subscribe);
1068
- client.subscriptions[messageHash] = future;
1075
+ this.watch(url, messageHash, request, requestId, subscribe);
1076
+ client.subscriptions[messageHash] = true;
1069
1077
  return await future;
1070
1078
  }
1071
1079
  else {
1072
- const messageHash = 'authenticated:swap';
1073
- let future = this.safeValue(client.subscriptions, messageHash);
1074
- if (future !== undefined) {
1080
+ if (authenticated !== undefined) {
1075
1081
  return await future;
1076
1082
  }
1077
1083
  const requestId = this.requestId();
1078
1084
  const subscribe = {
1079
1085
  'id': requestId,
1080
- 'future': 'authenticated:swap',
1086
+ 'future': swapMessageHash,
1081
1087
  };
1082
1088
  const signData = 'access_id=' + this.apiKey + '&timestamp=' + this.numberToString(time) + '&secret_key=' + this.secret;
1083
1089
  const hash = this.hash(this.encode(signData), sha256.sha256, 'hex');
@@ -1090,8 +1096,8 @@ class coinex extends coinex$1 {
1090
1096
  ],
1091
1097
  'id': requestId,
1092
1098
  };
1093
- future = this.watch(url, messageHash, request, requestId, subscribe);
1094
- client.subscriptions[messageHash] = future;
1099
+ this.watch(url, messageHash, request, requestId, subscribe);
1100
+ client.subscriptions[messageHash] = true;
1095
1101
  return await future;
1096
1102
  }
1097
1103
  }
@@ -932,7 +932,7 @@ class deribit extends deribit$1 {
932
932
  'data': '',
933
933
  },
934
934
  };
935
- future = this.watch(url, messageHash, this.extend(request, params));
935
+ future = await this.watch(url, messageHash, this.extend(request, params), messageHash);
936
936
  client.subscriptions[messageHash] = future;
937
937
  }
938
938
  return future;
@@ -650,7 +650,7 @@ class exmo extends exmo$1 {
650
650
  'nonce': time,
651
651
  };
652
652
  const message = this.extend(request, query);
653
- future = this.watch(url, messageHash, message);
653
+ future = await this.watch(url, messageHash, message, messageHash);
654
654
  client.subscriptions[messageHash] = future;
655
655
  }
656
656
  return future;
@@ -86,7 +86,7 @@ class krakenfutures extends krakenfutures$1 {
86
86
  'api_key': this.apiKey,
87
87
  };
88
88
  const message = this.extend(request, params);
89
- future = await this.watch(url, messageHash, message);
89
+ future = await this.watch(url, messageHash, message, messageHash);
90
90
  client.subscriptions[messageHash] = future;
91
91
  }
92
92
  return future;
@@ -1506,7 +1506,7 @@ class phemex extends phemex$1 {
1506
1506
  if (!(messageHash in client.subscriptions)) {
1507
1507
  client.subscriptions[subscriptionHash] = this.handleAuthenticate;
1508
1508
  }
1509
- future = this.watch(url, messageHash, message);
1509
+ future = await this.watch(url, messageHash, message, messageHash);
1510
1510
  client.subscriptions[messageHash] = future;
1511
1511
  }
1512
1512
  return future;
@@ -103,7 +103,7 @@ class poloniex extends poloniex$1 {
103
103
  },
104
104
  };
105
105
  const message = this.extend(request, params);
106
- future = await this.watch(url, messageHash, message);
106
+ future = await this.watch(url, messageHash, message, messageHash);
107
107
  //
108
108
  // {
109
109
  // "data": {
@@ -580,7 +580,7 @@ class probit extends probit$1 {
580
580
  'type': 'authorization',
581
581
  'token': accessToken,
582
582
  };
583
- future = this.watch(url, messageHash, this.extend(request, params));
583
+ future = await this.watch(url, messageHash, this.extend(request, params), messageHash);
584
584
  client.subscriptions[messageHash] = future;
585
585
  }
586
586
  return future;