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
package/js/src/kraken.js CHANGED
@@ -455,7 +455,7 @@ export default class kraken extends Exchange {
455
455
  * @method
456
456
  * @name kraken#fetchMarkets
457
457
  * @description retrieves data on all markets for kraken
458
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTradableAssetPairs
458
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTradableAssetPairs
459
459
  * @param {object} [params] extra parameters specific to the exchange API endpoint
460
460
  * @returns {object[]} an array of objects representing market data
461
461
  */
@@ -642,7 +642,7 @@ export default class kraken extends Exchange {
642
642
  * @method
643
643
  * @name kraken#fetchCurrencies
644
644
  * @description fetches all available currencies on an exchange
645
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getAssetInfo
645
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getAssetInfo
646
646
  * @param {object} [params] extra parameters specific to the exchange API endpoint
647
647
  * @returns {object} an associative dictionary of currencies
648
648
  */
@@ -770,7 +770,7 @@ export default class kraken extends Exchange {
770
770
  * @method
771
771
  * @name kraken#fetchOrderBook
772
772
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
773
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getOrderBook
773
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getOrderBook
774
774
  * @param {string} symbol unified symbol of the market to fetch the order book for
775
775
  * @param {int} [limit] the maximum amount of order book entries to return
776
776
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -872,7 +872,7 @@ export default class kraken extends Exchange {
872
872
  * @method
873
873
  * @name kraken#fetchTickers
874
874
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
875
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTickerInformation
875
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTickerInformation
876
876
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
877
877
  * @param {object} [params] extra parameters specific to the exchange API endpoint
878
878
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -909,7 +909,7 @@ export default class kraken extends Exchange {
909
909
  * @method
910
910
  * @name kraken#fetchTicker
911
911
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
912
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTickerInformation
912
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getTickerInformation
913
913
  * @param {string} symbol unified symbol of the market to fetch the ticker for
914
914
  * @param {object} [params] extra parameters specific to the exchange API endpoint
915
915
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -954,7 +954,7 @@ export default class kraken extends Exchange {
954
954
  * @method
955
955
  * @name kraken#fetchOHLCV
956
956
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
957
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getOHLCData
957
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getOHLCData
958
958
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
959
959
  * @param {string} timeframe the length of time each candle represents
960
960
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1252,7 +1252,7 @@ export default class kraken extends Exchange {
1252
1252
  * @method
1253
1253
  * @name kraken#fetchTrades
1254
1254
  * @description get the list of most recent trades for a particular symbol
1255
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getRecentTrades
1255
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getRecentTrades
1256
1256
  * @param {string} symbol unified symbol of the market to fetch trades for
1257
1257
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1258
1258
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -2416,7 +2416,7 @@ export default class kraken extends Exchange {
2416
2416
  * @method
2417
2417
  * @name kraken#fetchTime
2418
2418
  * @description fetches the current integer timestamp in milliseconds from the exchange server
2419
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getServerTime
2419
+ * @see https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getServerTime
2420
2420
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2421
2421
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
2422
2422
  */
@@ -137,7 +137,7 @@ export default class kucoin extends Exchange {
137
137
  currency: string;
138
138
  rate: number;
139
139
  period: number;
140
- timestamp: string;
140
+ timestamp: number;
141
141
  datetime: string;
142
142
  info: any;
143
143
  };
@@ -153,6 +153,9 @@ export default class kucoin extends Exchange {
153
153
  datetime: string;
154
154
  info: any;
155
155
  };
156
+ fetchBorrowRateHistories(codes?: any, since?: Int, limit?: Int, params?: {}): Promise<{}>;
157
+ fetchBorrowRateHistory(code: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
158
+ parseBorrowRateHistories(response: any, codes: any, since: any, limit: any): {};
156
159
  borrowCrossMargin(code: string, amount: number, params?: {}): Promise<{
157
160
  id: string;
158
161
  currency: string;
package/js/src/kucoin.js CHANGED
@@ -55,8 +55,8 @@ export default class kucoin extends Exchange {
55
55
  'fetchAccounts': true,
56
56
  'fetchBalance': true,
57
57
  'fetchBorrowInterest': true,
58
- 'fetchBorrowRateHistories': false,
59
- 'fetchBorrowRateHistory': false,
58
+ 'fetchBorrowRateHistories': true,
59
+ 'fetchBorrowRateHistory': true,
60
60
  'fetchClosedOrders': true,
61
61
  'fetchCrossBorrowRate': false,
62
62
  'fetchCrossBorrowRates': false,
@@ -230,6 +230,7 @@ export default class kucoin extends Exchange {
230
230
  'isolated/account/{symbol}': 50,
231
231
  'margin/borrow': 15,
232
232
  'margin/repay': 15,
233
+ 'margin/interest': 20,
233
234
  'project/list': 10,
234
235
  'project/marketInterestRate': 7.5,
235
236
  'redeem/orders': 10,
@@ -448,6 +449,56 @@ export default class kucoin extends Exchange {
448
449
  '130202': ExchangeError,
449
450
  '130203': InsufficientFunds,
450
451
  '130204': BadRequest,
452
+ '130301': InsufficientFunds,
453
+ '130302': PermissionDenied,
454
+ '130303': NotSupported,
455
+ '130304': NotSupported,
456
+ '130305': NotSupported,
457
+ '130306': NotSupported,
458
+ '130307': NotSupported,
459
+ '130308': InvalidOrder,
460
+ '130309': InvalidOrder,
461
+ '130310': ExchangeError,
462
+ '130311': InvalidOrder,
463
+ '130312': InvalidOrder,
464
+ '130313': InvalidOrder,
465
+ '130314': InvalidOrder,
466
+ '130315': NotSupported,
467
+ '126000': ExchangeError,
468
+ '126001': NotSupported,
469
+ '126002': ExchangeError,
470
+ '126003': InvalidOrder,
471
+ '126004': ExchangeError,
472
+ '126005': PermissionDenied,
473
+ '126006': ExchangeError,
474
+ '126007': ExchangeError,
475
+ '126009': ExchangeError,
476
+ '126010': ExchangeError,
477
+ '126011': ExchangeError,
478
+ '126013': InsufficientFunds,
479
+ '126015': ExchangeError,
480
+ '126021': NotSupported,
481
+ '126022': InvalidOrder,
482
+ '126027': InvalidOrder,
483
+ '126028': InvalidOrder,
484
+ '126029': InvalidOrder,
485
+ '126030': InvalidOrder,
486
+ '126033': InvalidOrder,
487
+ '126034': InvalidOrder,
488
+ '126036': InvalidOrder,
489
+ '126037': ExchangeError,
490
+ '126038': ExchangeError,
491
+ '126039': ExchangeError,
492
+ '126041': ExchangeError,
493
+ '126042': ExchangeError,
494
+ '126043': OrderNotFound,
495
+ '126044': InvalidOrder,
496
+ '126045': NotSupported,
497
+ '126046': NotSupported,
498
+ '126047': PermissionDenied,
499
+ '126048': PermissionDenied,
500
+ '135005': ExchangeError,
501
+ '135018': ExchangeError,
451
502
  '200004': InsufficientFunds,
452
503
  '210014': InvalidOrder,
453
504
  '210021': InsufficientFunds,
@@ -469,10 +520,12 @@ export default class kucoin extends Exchange {
469
520
  '400350': InvalidOrder,
470
521
  '400370': InvalidOrder,
471
522
  '400400': BadRequest,
523
+ '400401': AuthenticationError,
472
524
  '400500': InvalidOrder,
473
525
  '400600': BadSymbol,
474
526
  '400760': InvalidOrder,
475
527
  '401000': BadRequest,
528
+ '408000': BadRequest,
476
529
  '411100': AccountSuspended,
477
530
  '415000': BadRequest,
478
531
  '400303': PermissionDenied,
@@ -591,6 +644,7 @@ export default class kucoin extends Exchange {
591
644
  'margin/currencies': 'v3',
592
645
  'margin/borrow': 'v3',
593
646
  'margin/repay': 'v3',
647
+ 'margin/interest': 'v3',
594
648
  'project/list': 'v3',
595
649
  'project/marketInterestRate': 'v3',
596
650
  'redeem/orders': 'v3',
@@ -4045,12 +4099,19 @@ export default class kucoin extends Exchange {
4045
4099
  // "timestamp": 1658531274508488480
4046
4100
  // },
4047
4101
  //
4048
- const timestampId = this.safeString(info, 'timestamp');
4049
- const timestamp = Precise.stringMul(timestampId, '0.000001');
4102
+ // {
4103
+ // "createdAt": 1697783812257,
4104
+ // "currency": "XMR",
4105
+ // "interestAmount": "0.1",
4106
+ // "dayRatio": "0.001"
4107
+ // }
4108
+ //
4109
+ const timestampId = this.safeString2(info, 'createdAt', 'timestamp');
4110
+ const timestamp = this.parseToInt(timestampId.slice(0, 13));
4050
4111
  const currencyId = this.safeString(info, 'currency');
4051
4112
  return {
4052
4113
  'currency': this.safeCurrencyCode(currencyId, currency),
4053
- 'rate': this.safeNumber(info, 'dailyIntRate'),
4114
+ 'rate': this.safeNumber2(info, 'dailyIntRate', 'dayRatio'),
4054
4115
  'period': 86400000,
4055
4116
  'timestamp': timestamp,
4056
4117
  'datetime': this.iso8601(timestamp),
@@ -4234,6 +4295,144 @@ export default class kucoin extends Exchange {
4234
4295
  'info': info,
4235
4296
  };
4236
4297
  }
4298
+ async fetchBorrowRateHistories(codes = undefined, since = undefined, limit = undefined, params = {}) {
4299
+ /**
4300
+ * @method
4301
+ * @name kucoin#fetchBorrowRateHistories
4302
+ * @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
4303
+ * @see https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/get-cross-isolated-margin-interest-records
4304
+ * @param {string[]|undefined} codes list of unified currency codes, default is undefined
4305
+ * @param {int} [since] timestamp in ms of the earliest borrowRate, default is undefined
4306
+ * @param {int} [limit] max number of borrow rate prices to return, default is undefined
4307
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4308
+ * @param {string} [params.marginMode] 'cross' or 'isolated' default is 'cross'
4309
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4310
+ * @returns {object} a dictionary of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure} indexed by the market symbol
4311
+ */
4312
+ await this.loadMarkets();
4313
+ const marginResult = this.handleMarginModeAndParams('fetchBorrowRateHistories', params);
4314
+ const marginMode = this.safeString(marginResult, 0, 'cross');
4315
+ const isIsolated = (marginMode === 'isolated'); // true-isolated, false-cross
4316
+ let request = {
4317
+ 'isIsolated': isIsolated,
4318
+ };
4319
+ if (since !== undefined) {
4320
+ request['startTime'] = since;
4321
+ }
4322
+ [request, params] = this.handleUntilOption('endTime', request, params);
4323
+ if (limit !== undefined) {
4324
+ request['pageSize'] = limit; // default:50, min:10, max:500
4325
+ }
4326
+ const response = await this.privateGetMarginInterest(this.extend(request, params));
4327
+ //
4328
+ // {
4329
+ // "code": "200000",
4330
+ // "data": {
4331
+ // "timestamp": 1710829939673,
4332
+ // "currentPage": 1,
4333
+ // "pageSize": 50,
4334
+ // "totalNum": 0,
4335
+ // "totalPage": 0,
4336
+ // "items": [
4337
+ // {
4338
+ // "createdAt": 1697783812257,
4339
+ // "currency": "XMR",
4340
+ // "interestAmount": "0.1",
4341
+ // "dayRatio": "0.001"
4342
+ // }
4343
+ // ]
4344
+ // }
4345
+ // }
4346
+ //
4347
+ const data = this.safeDict(response, 'data');
4348
+ const rows = this.safeList(data, 'items');
4349
+ return this.parseBorrowRateHistories(rows, codes, since, limit);
4350
+ }
4351
+ async fetchBorrowRateHistory(code, since = undefined, limit = undefined, params = {}) {
4352
+ /**
4353
+ * @method
4354
+ * @name kucoin#fetchBorrowRateHistory
4355
+ * @description retrieves a history of a currencies borrow interest rate at specific time slots
4356
+ * @see https://www.kucoin.com/docs/rest/margin-trading/margin-trading-v3-/get-cross-isolated-margin-interest-records
4357
+ * @param {string} code unified currency code
4358
+ * @param {int} [since] timestamp for the earliest borrow rate
4359
+ * @param {int} [limit] the maximum number of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure} to retrieve
4360
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4361
+ * @param {string} [params.marginMode] 'cross' or 'isolated' default is 'cross'
4362
+ * @param {int} [params.until] the latest time in ms to fetch entries for
4363
+ * @returns {object[]} an array of [borrow rate structures]{@link https://docs.ccxt.com/#/?id=borrow-rate-structure}
4364
+ */
4365
+ await this.loadMarkets();
4366
+ const marginResult = this.handleMarginModeAndParams('fetchBorrowRateHistories', params);
4367
+ const marginMode = this.safeString(marginResult, 0, 'cross');
4368
+ const isIsolated = (marginMode === 'isolated'); // true-isolated, false-cross
4369
+ const currency = this.currency(code);
4370
+ let request = {
4371
+ 'isIsolated': isIsolated,
4372
+ 'currency': currency['id'],
4373
+ };
4374
+ if (since !== undefined) {
4375
+ request['startTime'] = since;
4376
+ }
4377
+ [request, params] = this.handleUntilOption('endTime', request, params);
4378
+ if (limit !== undefined) {
4379
+ request['pageSize'] = limit; // default:50, min:10, max:500
4380
+ }
4381
+ const response = await this.privateGetMarginInterest(this.extend(request, params));
4382
+ //
4383
+ // {
4384
+ // "code": "200000",
4385
+ // "data": {
4386
+ // "timestamp": 1710829939673,
4387
+ // "currentPage": 1,
4388
+ // "pageSize": 50,
4389
+ // "totalNum": 0,
4390
+ // "totalPage": 0,
4391
+ // "items": [
4392
+ // {
4393
+ // "createdAt": 1697783812257,
4394
+ // "currency": "XMR",
4395
+ // "interestAmount": "0.1",
4396
+ // "dayRatio": "0.001"
4397
+ // }
4398
+ // ]
4399
+ // }
4400
+ // }
4401
+ //
4402
+ const data = this.safeDict(response, 'data');
4403
+ const rows = this.safeList(data, 'items');
4404
+ return this.parseBorrowRateHistory(rows, code, since, limit);
4405
+ }
4406
+ parseBorrowRateHistories(response, codes, since, limit) {
4407
+ //
4408
+ // [
4409
+ // {
4410
+ // "createdAt": 1697783812257,
4411
+ // "currency": "XMR",
4412
+ // "interestAmount": "0.1",
4413
+ // "dayRatio": "0.001"
4414
+ // }
4415
+ // ]
4416
+ //
4417
+ const borrowRateHistories = {};
4418
+ for (let i = 0; i < response.length; i++) {
4419
+ const item = response[i];
4420
+ const code = this.safeCurrencyCode(this.safeString(item, 'currency'));
4421
+ if (codes === undefined || this.inArray(code, codes)) {
4422
+ if (!(code in borrowRateHistories)) {
4423
+ borrowRateHistories[code] = [];
4424
+ }
4425
+ const borrowRateStructure = this.parseBorrowRate(item);
4426
+ borrowRateHistories[code].push(borrowRateStructure);
4427
+ }
4428
+ }
4429
+ const keys = Object.keys(borrowRateHistories);
4430
+ for (let i = 0; i < keys.length; i++) {
4431
+ const code = keys[i];
4432
+ borrowRateHistories[code] = this.filterByCurrencySinceLimit(borrowRateHistories[code], code, since, limit);
4433
+ }
4434
+ return borrowRateHistories;
4435
+ }
4237
4436
  async borrowCrossMargin(code, amount, params = {}) {
4238
4437
  /**
4239
4438
  * @method
package/js/src/okcoin.js CHANGED
@@ -248,6 +248,16 @@ export default class okcoin extends Exchange {
248
248
  '50026': ExchangeNotAvailable,
249
249
  '50027': PermissionDenied,
250
250
  '50028': ExchangeError,
251
+ '50029': ExchangeError,
252
+ '50030': PermissionDenied,
253
+ '50032': AccountSuspended,
254
+ '50033': AccountSuspended,
255
+ '50035': BadRequest,
256
+ '50036': BadRequest,
257
+ '50037': BadRequest,
258
+ '50038': ExchangeError,
259
+ '50039': ExchangeError,
260
+ '50041': ExchangeError,
251
261
  '50044': BadRequest,
252
262
  // API Class
253
263
  '50100': ExchangeError,
@@ -291,9 +301,25 @@ export default class okcoin extends Exchange {
291
301
  '51024': AccountSuspended,
292
302
  '51025': ExchangeError,
293
303
  '51026': BadSymbol,
304
+ '51030': InvalidOrder,
305
+ '51031': InvalidOrder,
306
+ '51032': InvalidOrder,
307
+ '51033': InvalidOrder,
308
+ '51037': InvalidOrder,
309
+ '51038': InvalidOrder,
310
+ '51044': InvalidOrder,
294
311
  '51046': InvalidOrder,
295
312
  '51047': InvalidOrder,
296
- '51031': InvalidOrder,
313
+ '51048': InvalidOrder,
314
+ '51049': InvalidOrder,
315
+ '51050': InvalidOrder,
316
+ '51051': InvalidOrder,
317
+ '51052': InvalidOrder,
318
+ '51053': InvalidOrder,
319
+ '51054': BadRequest,
320
+ '51056': InvalidOrder,
321
+ '51058': InvalidOrder,
322
+ '51059': InvalidOrder,
297
323
  '51100': InvalidOrder,
298
324
  '51102': InvalidOrder,
299
325
  '51103': InvalidOrder,
package/js/src/okx.d.ts CHANGED
@@ -10,7 +10,7 @@ export default class okx extends Exchange {
10
10
  convertToInstrumentType(type: any): string;
11
11
  convertExpireDate(date: any): string;
12
12
  createExpiredOptionMarket(symbol: string): MarketInterface;
13
- safeMarket(marketId?: any, market?: any, delimiter?: any, marketType?: any): MarketInterface;
13
+ safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
14
14
  fetchStatus(params?: {}): Promise<{
15
15
  updated: any;
16
16
  status: string;
package/js/src/okx.js CHANGED
@@ -576,6 +576,7 @@ export default class okx extends Exchange {
576
576
  '50027': PermissionDenied,
577
577
  '50028': ExchangeError,
578
578
  '50044': BadRequest,
579
+ '50061': ExchangeError,
579
580
  '50062': ExchangeError,
580
581
  // API Class
581
582
  '50100': ExchangeError,
@@ -763,6 +764,15 @@ export default class okx extends Exchange {
763
764
  // SPOT/MARGIN error codes 54000-54999
764
765
  '54000': ExchangeError,
765
766
  '54001': ExchangeError,
767
+ // Trading bot Error Code from 55100 to 55999
768
+ '55100': InvalidOrder,
769
+ '55101': InvalidOrder,
770
+ '55102': InvalidOrder,
771
+ '55103': InvalidOrder,
772
+ '55104': InvalidOrder,
773
+ '55111': InvalidOrder,
774
+ '55112': InvalidOrder,
775
+ '55113': InvalidOrder,
766
776
  // FUNDING error codes 58000-58999
767
777
  '58000': ExchangeError,
768
778
  '58001': AuthenticationError,
@@ -5024,6 +5034,14 @@ export default class okx extends Exchange {
5024
5034
  '3': 'pending',
5025
5035
  '4': 'pending',
5026
5036
  '5': 'pending',
5037
+ '6': 'pending',
5038
+ '7': 'pending',
5039
+ '8': 'pending',
5040
+ '9': 'pending',
5041
+ '10': 'pending',
5042
+ '12': 'pending',
5043
+ '15': 'pending',
5044
+ '16': 'pending',
5027
5045
  };
5028
5046
  return this.safeString(statuses, status, status);
5029
5047
  }
@@ -964,7 +964,7 @@ export default class ascendex extends ascendexRest {
964
964
  'key': this.apiKey,
965
965
  'sig': signature,
966
966
  };
967
- future = this.watch(url, messageHash, this.extend(request, params));
967
+ future = await this.watch(url, messageHash, this.extend(request, params), messageHash);
968
968
  client.subscriptions[messageHash] = future;
969
969
  }
970
970
  return future;
@@ -1215,7 +1215,7 @@ export default class bitvavo extends bitvavoRest {
1215
1215
  'timestamp': timestamp,
1216
1216
  };
1217
1217
  const message = this.extend(request, params);
1218
- future = this.watch(url, messageHash, message);
1218
+ future = await this.watch(url, messageHash, message, messageHash);
1219
1219
  client.subscriptions[messageHash] = future;
1220
1220
  }
1221
1221
  return future;
@@ -1019,8 +1019,12 @@ export default class coinex extends coinexRest {
1019
1019
  //
1020
1020
  const messageHashSpot = 'authenticated:spot';
1021
1021
  const messageHashSwap = 'authenticated:swap';
1022
- client.resolve(message, messageHashSpot);
1023
- client.resolve(message, messageHashSwap);
1022
+ // client.resolve (message, messageHashSpot);
1023
+ // client.resolve (message, messageHashSwap);
1024
+ const spotFuture = this.safeValue(client.futures, messageHashSpot);
1025
+ spotFuture.resolve(true);
1026
+ const swapFutures = this.safeValue(client.futures, messageHashSwap);
1027
+ swapFutures.resolve(true);
1024
1028
  return message;
1025
1029
  }
1026
1030
  handleSubscriptionStatus(client, message) {
@@ -1045,16 +1049,20 @@ export default class coinex extends coinexRest {
1045
1049
  const url = this.urls['api']['ws'][type];
1046
1050
  const client = this.client(url);
1047
1051
  const time = this.milliseconds();
1052
+ const isSpot = (type === 'spot');
1053
+ const spotMessageHash = 'authenticated:spot';
1054
+ const swapMessageHash = 'authenticated:swap';
1055
+ const messageHash = isSpot ? spotMessageHash : swapMessageHash;
1056
+ const future = client.future(messageHash);
1057
+ const authenticated = this.safeValue(client.subscriptions, messageHash);
1048
1058
  if (type === 'spot') {
1049
- const messageHash = 'authenticated:spot';
1050
- let future = this.safeValue(client.subscriptions, messageHash);
1051
- if (future !== undefined) {
1059
+ if (authenticated !== undefined) {
1052
1060
  return await future;
1053
1061
  }
1054
1062
  const requestId = this.requestId();
1055
1063
  const subscribe = {
1056
1064
  'id': requestId,
1057
- 'future': 'authenticated:spot',
1065
+ 'future': spotMessageHash,
1058
1066
  };
1059
1067
  const signData = 'access_id=' + this.apiKey + '&tonce=' + this.numberToString(time) + '&secret_key=' + this.secret;
1060
1068
  const hash = this.hash(this.encode(signData), md5);
@@ -1067,20 +1075,18 @@ export default class coinex extends coinexRest {
1067
1075
  ],
1068
1076
  'id': requestId,
1069
1077
  };
1070
- future = this.watch(url, messageHash, request, requestId, subscribe);
1071
- client.subscriptions[messageHash] = future;
1078
+ this.watch(url, messageHash, request, requestId, subscribe);
1079
+ client.subscriptions[messageHash] = true;
1072
1080
  return await future;
1073
1081
  }
1074
1082
  else {
1075
- const messageHash = 'authenticated:swap';
1076
- let future = this.safeValue(client.subscriptions, messageHash);
1077
- if (future !== undefined) {
1083
+ if (authenticated !== undefined) {
1078
1084
  return await future;
1079
1085
  }
1080
1086
  const requestId = this.requestId();
1081
1087
  const subscribe = {
1082
1088
  'id': requestId,
1083
- 'future': 'authenticated:swap',
1089
+ 'future': swapMessageHash,
1084
1090
  };
1085
1091
  const signData = 'access_id=' + this.apiKey + '&timestamp=' + this.numberToString(time) + '&secret_key=' + this.secret;
1086
1092
  const hash = this.hash(this.encode(signData), sha256, 'hex');
@@ -1093,8 +1099,8 @@ export default class coinex extends coinexRest {
1093
1099
  ],
1094
1100
  'id': requestId,
1095
1101
  };
1096
- future = this.watch(url, messageHash, request, requestId, subscribe);
1097
- client.subscriptions[messageHash] = future;
1102
+ this.watch(url, messageHash, request, requestId, subscribe);
1103
+ client.subscriptions[messageHash] = true;
1098
1104
  return await future;
1099
1105
  }
1100
1106
  }
@@ -937,7 +937,7 @@ export default class deribit extends deribitRest {
937
937
  'data': '',
938
938
  },
939
939
  };
940
- future = this.watch(url, messageHash, this.extend(request, params));
940
+ future = await this.watch(url, messageHash, this.extend(request, params), messageHash);
941
941
  client.subscriptions[messageHash] = future;
942
942
  }
943
943
  return future;
@@ -653,7 +653,7 @@ export default class exmo extends exmoRest {
653
653
  'nonce': time,
654
654
  };
655
655
  const message = this.extend(request, query);
656
- future = this.watch(url, messageHash, message);
656
+ future = await this.watch(url, messageHash, message, messageHash);
657
657
  client.subscriptions[messageHash] = future;
658
658
  }
659
659
  return future;
@@ -89,7 +89,7 @@ export default class krakenfutures extends krakenfuturesRest {
89
89
  'api_key': this.apiKey,
90
90
  };
91
91
  const message = this.extend(request, params);
92
- future = await this.watch(url, messageHash, message);
92
+ future = await this.watch(url, messageHash, message, messageHash);
93
93
  client.subscriptions[messageHash] = future;
94
94
  }
95
95
  return future;
@@ -1509,7 +1509,7 @@ export default class phemex extends phemexRest {
1509
1509
  if (!(messageHash in client.subscriptions)) {
1510
1510
  client.subscriptions[subscriptionHash] = this.handleAuthenticate;
1511
1511
  }
1512
- future = this.watch(url, messageHash, message);
1512
+ future = await this.watch(url, messageHash, message, messageHash);
1513
1513
  client.subscriptions[messageHash] = future;
1514
1514
  }
1515
1515
  return future;
@@ -106,7 +106,7 @@ export default class poloniex extends poloniexRest {
106
106
  },
107
107
  };
108
108
  const message = this.extend(request, params);
109
- future = await this.watch(url, messageHash, message);
109
+ future = await this.watch(url, messageHash, message, messageHash);
110
110
  //
111
111
  // {
112
112
  // "data": {
@@ -583,7 +583,7 @@ export default class probit extends probitRest {
583
583
  'type': 'authorization',
584
584
  'token': accessToken,
585
585
  };
586
- future = this.watch(url, messageHash, this.extend(request, params));
586
+ future = await this.watch(url, messageHash, this.extend(request, params), messageHash);
587
587
  client.subscriptions[messageHash] = future;
588
588
  }
589
589
  return future;
@@ -30,6 +30,7 @@ export default class woo extends wooRest {
30
30
  handlePositions(client: any, message: any): void;
31
31
  watchBalance(params?: {}): Promise<Balances>;
32
32
  handleBalance(client: any, message: any): void;
33
+ handleErrorMessage(client: Client, message: any): boolean;
33
34
  handleMessage(client: Client, message: any): void;
34
35
  ping(client: Client): {
35
36
  event: string;