ccxt 4.1.12 → 4.1.13

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 (86) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +947 -15
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ace.js +1 -0
  6. package/dist/cjs/src/alpaca.js +1 -0
  7. package/dist/cjs/src/base/Exchange.js +30 -0
  8. package/dist/cjs/src/bigone.js +1 -0
  9. package/dist/cjs/src/binance.js +231 -1
  10. package/dist/cjs/src/bingx.js +1 -0
  11. package/dist/cjs/src/bitbank.js +1 -0
  12. package/dist/cjs/src/bitbns.js +1 -0
  13. package/dist/cjs/src/bitfinex.js +1 -0
  14. package/dist/cjs/src/bitfinex2.js +1 -0
  15. package/dist/cjs/src/bitflyer.js +1 -0
  16. package/dist/cjs/src/bitforex.js +1 -0
  17. package/dist/cjs/src/bitget.js +11 -2
  18. package/dist/cjs/src/bithumb.js +1 -0
  19. package/dist/cjs/src/bitmart.js +103 -0
  20. package/dist/cjs/src/bitmex.js +70 -0
  21. package/dist/cjs/src/bitopro.js +1 -0
  22. package/dist/cjs/src/bitpanda.js +1 -0
  23. package/dist/cjs/src/bitrue.js +1 -0
  24. package/dist/cjs/src/bitso.js +1 -0
  25. package/dist/cjs/src/bitstamp.js +1 -0
  26. package/dist/cjs/src/bitvavo.js +1 -0
  27. package/dist/cjs/src/blockchaincom.js +1 -0
  28. package/dist/cjs/src/btcalpha.js +1 -0
  29. package/dist/cjs/src/btcmarkets.js +1 -0
  30. package/dist/cjs/src/btcturk.js +1 -0
  31. package/dist/cjs/src/bybit.js +3 -3
  32. package/dist/cjs/src/deribit.js +163 -0
  33. package/dist/cjs/src/gate.js +189 -0
  34. package/dist/cjs/src/huobi.js +102 -0
  35. package/dist/cjs/src/kucoin.js +1 -0
  36. package/dist/cjs/src/kucoinfutures.js +1 -1
  37. package/dist/cjs/src/okx.js +1 -0
  38. package/dist/cjs/src/poloniex.js +20 -7
  39. package/js/ccxt.d.ts +3 -3
  40. package/js/ccxt.js +1 -1
  41. package/js/src/abstract/poloniex.d.ts +18 -5
  42. package/js/src/ace.js +1 -0
  43. package/js/src/alpaca.js +1 -0
  44. package/js/src/base/Exchange.d.ts +6 -2
  45. package/js/src/base/Exchange.js +30 -0
  46. package/js/src/base/types.d.ts +9 -0
  47. package/js/src/bigone.js +1 -0
  48. package/js/src/binance.d.ts +13 -1
  49. package/js/src/binance.js +231 -1
  50. package/js/src/bingx.d.ts +1 -0
  51. package/js/src/bingx.js +1 -0
  52. package/js/src/bitbank.js +1 -0
  53. package/js/src/bitbns.js +1 -0
  54. package/js/src/bitfinex.js +1 -0
  55. package/js/src/bitfinex2.js +1 -0
  56. package/js/src/bitflyer.js +1 -0
  57. package/js/src/bitforex.js +1 -0
  58. package/js/src/bitget.js +11 -2
  59. package/js/src/bithumb.js +1 -0
  60. package/js/src/bitmart.d.ts +12 -0
  61. package/js/src/bitmart.js +103 -0
  62. package/js/src/bitmex.d.ts +13 -1
  63. package/js/src/bitmex.js +70 -0
  64. package/js/src/bitopro.js +1 -0
  65. package/js/src/bitpanda.js +1 -0
  66. package/js/src/bitrue.js +1 -0
  67. package/js/src/bitso.js +1 -0
  68. package/js/src/bitstamp.js +1 -0
  69. package/js/src/bitvavo.js +1 -0
  70. package/js/src/blockchaincom.js +1 -0
  71. package/js/src/btcalpha.js +1 -0
  72. package/js/src/btcmarkets.js +1 -0
  73. package/js/src/btcturk.js +1 -0
  74. package/js/src/bybit.js +3 -3
  75. package/js/src/deribit.d.ts +14 -0
  76. package/js/src/deribit.js +163 -0
  77. package/js/src/gate.d.ts +13 -0
  78. package/js/src/gate.js +189 -0
  79. package/js/src/huobi.d.ts +12 -0
  80. package/js/src/huobi.js +102 -0
  81. package/js/src/kucoin.js +1 -0
  82. package/js/src/kucoinfutures.js +1 -1
  83. package/js/src/okx.js +1 -0
  84. package/js/src/poloniex.js +20 -7
  85. package/package.json +1 -1
  86. package/skip-tests.json +61 -5
package/dist/cjs/ccxt.js CHANGED
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
180
180
 
181
181
  //-----------------------------------------------------------------------------
182
182
  // this is updated by vss.js when building
183
- const version = '4.1.12';
183
+ const version = '4.1.13';
184
184
  Exchange["default"].ccxtVersion = version;
185
185
  const exchanges = {
186
186
  'ace': ace,
@@ -242,6 +242,7 @@ class ace extends ace$1 {
242
242
  'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'basePrecision'))),
243
243
  },
244
244
  'active': undefined,
245
+ 'created': undefined,
245
246
  'info': market,
246
247
  });
247
248
  }
@@ -306,6 +306,7 @@ class alpaca extends alpaca$1 {
306
306
  'max': undefined,
307
307
  },
308
308
  },
309
+ 'created': undefined,
309
310
  'info': asset,
310
311
  });
311
312
  }
@@ -3276,6 +3276,12 @@ class Exchange {
3276
3276
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3277
3277
  throw new errors.NotSupported(this.id + ' fetchMyTrades() is not supported yet');
3278
3278
  }
3279
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3280
+ throw new errors.NotSupported(this.id + ' fetchMyLiquidations() is not supported yet');
3281
+ }
3282
+ async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
3283
+ throw new errors.NotSupported(this.id + ' fetchLiquidations() is not supported yet');
3284
+ }
3279
3285
  async fetchMyTradesWs(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3280
3286
  throw new errors.NotSupported(this.id + ' fetchMyTradesWs() is not supported yet');
3281
3287
  }
@@ -4400,6 +4406,30 @@ class Exchange {
4400
4406
  'info': this.safeValue(interest, 'info'),
4401
4407
  });
4402
4408
  }
4409
+ parseLiquidation(liquidation, market = undefined) {
4410
+ throw new errors.NotSupported(this.id + ' parseLiquidation () is not supported yet');
4411
+ }
4412
+ parseLiquidations(liquidations, market = undefined, since = undefined, limit = undefined) {
4413
+ /**
4414
+ * @ignore
4415
+ * @method
4416
+ * @description parses liquidation info from the exchange response
4417
+ * @param {object[]} liquidations each item describes an instance of a liquidation event
4418
+ * @param {object} market ccxt market
4419
+ * @param {int} [since] when defined, the response items are filtered to only include items after this timestamp
4420
+ * @param {int} [limit] limits the number of items in the response
4421
+ * @returns {object[]} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
4422
+ */
4423
+ const result = [];
4424
+ for (let i = 0; i < liquidations.length; i++) {
4425
+ const entry = liquidations[i];
4426
+ const parsed = this.parseLiquidation(entry, market);
4427
+ result.push(parsed);
4428
+ }
4429
+ const sorted = this.sortBy(result, 'timestamp');
4430
+ const symbol = this.safeString(market, 'symbol');
4431
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
4432
+ }
4403
4433
  }
4404
4434
 
4405
4435
  exports.Exchange = Exchange;
@@ -567,6 +567,7 @@ class bigone extends bigone$1 {
567
567
  'max': this.safeNumber(market, 'max_quote_value'),
568
568
  },
569
569
  },
570
+ 'created': undefined,
570
571
  'info': market,
571
572
  };
572
573
  result.push(entry);
@@ -74,9 +74,11 @@ class binance extends binance$1 {
74
74
  'fetchLedger': true,
75
75
  'fetchLeverage': false,
76
76
  'fetchLeverageTiers': true,
77
+ 'fetchLiquidations': false,
77
78
  'fetchMarketLeverageTiers': 'emulated',
78
79
  'fetchMarkets': true,
79
80
  'fetchMarkOHLCV': true,
81
+ 'fetchMyLiquidations': true,
80
82
  'fetchMySettlementHistory': true,
81
83
  'fetchMyTrades': true,
82
84
  'fetchOHLCV': true,
@@ -8258,13 +8260,15 @@ class binance extends binance$1 {
8258
8260
  let type = undefined;
8259
8261
  let subType = undefined;
8260
8262
  let currency = undefined;
8263
+ if (code !== undefined) {
8264
+ currency = this.currency(code);
8265
+ }
8261
8266
  let method = undefined;
8262
8267
  const request = {};
8263
8268
  [type, params] = this.handleMarketTypeAndParams('fetchLedger', undefined, params);
8264
8269
  [subType, params] = this.handleSubTypeAndParams('fetchLedger', undefined, params);
8265
8270
  if (type === 'option') {
8266
8271
  this.checkRequiredArgument('fetchLedger', code, 'code');
8267
- currency = this.currency(code);
8268
8272
  request['currency'] = currency['id'];
8269
8273
  method = 'eapiPrivateGetBill';
8270
8274
  }
@@ -9219,6 +9223,232 @@ class binance extends binance$1 {
9219
9223
  'info': interest,
9220
9224
  }, market);
9221
9225
  }
9226
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
9227
+ /**
9228
+ * @method
9229
+ * @name binance#fetchMyLiquidations
9230
+ * @description retrieves the users liquidated positions
9231
+ * @see https://binance-docs.github.io/apidocs/spot/en/#get-force-liquidation-record-user_data
9232
+ * @see https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data
9233
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
9234
+ * @param {string} [symbol] unified CCXT market symbol
9235
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
9236
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
9237
+ * @param {object} [params] exchange specific parameters for the binance api endpoint
9238
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
9239
+ * @param {boolean} [params.paginate] *spot only* default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
9240
+ * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
9241
+ */
9242
+ await this.loadMarkets();
9243
+ let paginate = false;
9244
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyLiquidations', 'paginate');
9245
+ if (paginate) {
9246
+ return await this.fetchPaginatedCallIncremental('fetchMyLiquidations', symbol, since, limit, params, 'current', 100);
9247
+ }
9248
+ let market = undefined;
9249
+ if (symbol !== undefined) {
9250
+ market = this.market(symbol);
9251
+ }
9252
+ let type = undefined;
9253
+ [type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
9254
+ let subType = undefined;
9255
+ [subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params, 'linear');
9256
+ let request = {};
9257
+ if (type !== 'spot') {
9258
+ request['autoCloseType'] = 'LIQUIDATION';
9259
+ }
9260
+ if (market !== undefined) {
9261
+ const symbolKey = market['spot'] ? 'isolatedSymbol' : 'symbol';
9262
+ request[symbolKey] = market['id'];
9263
+ }
9264
+ if (since !== undefined) {
9265
+ request['startTime'] = since;
9266
+ }
9267
+ if (limit !== undefined) {
9268
+ if (type === 'spot') {
9269
+ request['size'] = limit;
9270
+ }
9271
+ else {
9272
+ request['limit'] = limit;
9273
+ }
9274
+ }
9275
+ [request, params] = this.handleUntilOption('endTime', request, params);
9276
+ let response = undefined;
9277
+ if (type === 'spot') {
9278
+ response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
9279
+ }
9280
+ else if (subType === 'linear') {
9281
+ response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
9282
+ }
9283
+ else if (subType === 'inverse') {
9284
+ response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
9285
+ }
9286
+ else {
9287
+ throw new errors.NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
9288
+ }
9289
+ //
9290
+ // margin
9291
+ //
9292
+ // {
9293
+ // "rows": [
9294
+ // {
9295
+ // "avgPrice": "0.00388359",
9296
+ // "executedQty": "31.39000000",
9297
+ // "orderId": 180015097,
9298
+ // "price": "0.00388110",
9299
+ // "qty": "31.39000000",
9300
+ // "side": "SELL",
9301
+ // "symbol": "BNBBTC",
9302
+ // "timeInForce": "GTC",
9303
+ // "isIsolated": true,
9304
+ // "updatedTime": 1558941374745
9305
+ // }
9306
+ // ],
9307
+ // "total": 1
9308
+ // }
9309
+ //
9310
+ // linear
9311
+ //
9312
+ // [
9313
+ // {
9314
+ // "orderId": 6071832819,
9315
+ // "symbol": "BTCUSDT",
9316
+ // "status": "FILLED",
9317
+ // "clientOrderId": "autoclose-1596107620040000020",
9318
+ // "price": "10871.09",
9319
+ // "avgPrice": "10913.21000",
9320
+ // "origQty": "0.001",
9321
+ // "executedQty": "0.001",
9322
+ // "cumQuote": "10.91321",
9323
+ // "timeInForce": "IOC",
9324
+ // "type": "LIMIT",
9325
+ // "reduceOnly": false,
9326
+ // "closePosition": false,
9327
+ // "side": "SELL",
9328
+ // "positionSide": "BOTH",
9329
+ // "stopPrice": "0",
9330
+ // "workingType": "CONTRACT_PRICE",
9331
+ // "origType": "LIMIT",
9332
+ // "time": 1596107620044,
9333
+ // "updateTime": 1596107620087
9334
+ // },
9335
+ // ]
9336
+ //
9337
+ // inverse
9338
+ //
9339
+ // [
9340
+ // {
9341
+ // "orderId": 165123080,
9342
+ // "symbol": "BTCUSD_200925",
9343
+ // "pair": "BTCUSD",
9344
+ // "status": "FILLED",
9345
+ // "clientOrderId": "autoclose-1596542005017000006",
9346
+ // "price": "11326.9",
9347
+ // "avgPrice": "11326.9",
9348
+ // "origQty": "1",
9349
+ // "executedQty": "1",
9350
+ // "cumBase": "0.00882854",
9351
+ // "timeInForce": "IOC",
9352
+ // "type": "LIMIT",
9353
+ // "reduceOnly": false,
9354
+ // "closePosition": false,
9355
+ // "side": "SELL",
9356
+ // "positionSide": "BOTH",
9357
+ // "stopPrice": "0",
9358
+ // "workingType": "CONTRACT_PRICE",
9359
+ // "priceProtect": false,
9360
+ // "origType": "LIMIT",
9361
+ // "time": 1596542005019,
9362
+ // "updateTime": 1596542005050
9363
+ // },
9364
+ // ]
9365
+ //
9366
+ const liquidations = this.safeValue(response, 'rows', response);
9367
+ return this.parseLiquidations(liquidations, market, since, limit);
9368
+ }
9369
+ parseLiquidation(liquidation, market = undefined) {
9370
+ //
9371
+ // margin
9372
+ //
9373
+ // {
9374
+ // "avgPrice": "0.00388359",
9375
+ // "executedQty": "31.39000000",
9376
+ // "orderId": 180015097,
9377
+ // "price": "0.00388110",
9378
+ // "qty": "31.39000000",
9379
+ // "side": "SELL",
9380
+ // "symbol": "BNBBTC",
9381
+ // "timeInForce": "GTC",
9382
+ // "isIsolated": true,
9383
+ // "updatedTime": 1558941374745
9384
+ // }
9385
+ //
9386
+ // linear
9387
+ //
9388
+ // {
9389
+ // "orderId": 6071832819,
9390
+ // "symbol": "BTCUSDT",
9391
+ // "status": "FILLED",
9392
+ // "clientOrderId": "autoclose-1596107620040000020",
9393
+ // "price": "10871.09",
9394
+ // "avgPrice": "10913.21000",
9395
+ // "origQty": "0.001",
9396
+ // "executedQty": "0.001",
9397
+ // "cumQuote": "10.91321",
9398
+ // "timeInForce": "IOC",
9399
+ // "type": "LIMIT",
9400
+ // "reduceOnly": false,
9401
+ // "closePosition": false,
9402
+ // "side": "SELL",
9403
+ // "positionSide": "BOTH",
9404
+ // "stopPrice": "0",
9405
+ // "workingType": "CONTRACT_PRICE",
9406
+ // "origType": "LIMIT",
9407
+ // "time": 1596107620044,
9408
+ // "updateTime": 1596107620087
9409
+ // }
9410
+ //
9411
+ // inverse
9412
+ //
9413
+ // {
9414
+ // "orderId": 165123080,
9415
+ // "symbol": "BTCUSD_200925",
9416
+ // "pair": "BTCUSD",
9417
+ // "status": "FILLED",
9418
+ // "clientOrderId": "autoclose-1596542005017000006",
9419
+ // "price": "11326.9",
9420
+ // "avgPrice": "11326.9",
9421
+ // "origQty": "1",
9422
+ // "executedQty": "1",
9423
+ // "cumBase": "0.00882854",
9424
+ // "timeInForce": "IOC",
9425
+ // "type": "LIMIT",
9426
+ // "reduceOnly": false,
9427
+ // "closePosition": false,
9428
+ // "side": "SELL",
9429
+ // "positionSide": "BOTH",
9430
+ // "stopPrice": "0",
9431
+ // "workingType": "CONTRACT_PRICE",
9432
+ // "priceProtect": false,
9433
+ // "origType": "LIMIT",
9434
+ // "time": 1596542005019,
9435
+ // "updateTime": 1596542005050
9436
+ // }
9437
+ //
9438
+ const marketId = this.safeString(liquidation, 'symbol');
9439
+ const timestamp = this.safeInteger2(liquidation, 'updatedTime', 'updateTime');
9440
+ return {
9441
+ 'info': liquidation,
9442
+ 'symbol': this.safeSymbol(marketId, market),
9443
+ 'contracts': this.safeNumber(liquidation, 'executedQty'),
9444
+ 'contractSize': this.safeNumber(market, 'contractSize'),
9445
+ 'price': this.safeNumber(liquidation, 'avgPrice'),
9446
+ 'baseValue': this.safeNumber(liquidation, 'cumBase'),
9447
+ 'quoteValue': this.safeNumber(liquidation, 'cumQuote'),
9448
+ 'timestamp': timestamp,
9449
+ 'datetime': this.iso8601(timestamp),
9450
+ };
9451
+ }
9222
9452
  }
9223
9453
 
9224
9454
  module.exports = binance;
@@ -610,6 +610,7 @@ class bingx extends bingx$1 {
610
610
  'max': this.safeNumber(market, 'maxNotional'),
611
611
  },
612
612
  },
613
+ 'created': undefined,
613
614
  'info': market,
614
615
  };
615
616
  return entry;
@@ -246,6 +246,7 @@ class bitbank extends bitbank$1 {
246
246
  'max': undefined,
247
247
  },
248
248
  },
249
+ 'created': undefined,
249
250
  'info': entry,
250
251
  });
251
252
  }
@@ -275,6 +275,7 @@ class bitbns extends bitbns$1 {
275
275
  'max': this.safeNumber(costLimits, 'max'),
276
276
  },
277
277
  },
278
+ 'created': undefined,
278
279
  'info': market,
279
280
  });
280
281
  }
@@ -654,6 +654,7 @@ class bitfinex extends bitfinex$1 {
654
654
  'max': undefined,
655
655
  },
656
656
  },
657
+ 'created': undefined,
657
658
  'info': market,
658
659
  });
659
660
  }
@@ -574,6 +574,7 @@ class bitfinex2 extends bitfinex2$1 {
574
574
  'max': undefined,
575
575
  },
576
576
  },
577
+ 'created': undefined,
577
578
  'info': market,
578
579
  });
579
580
  }
@@ -292,6 +292,7 @@ class bitflyer extends bitflyer$1 {
292
292
  'max': undefined,
293
293
  },
294
294
  },
295
+ 'created': undefined,
295
296
  'info': market,
296
297
  });
297
298
  }
@@ -230,6 +230,7 @@ class bitforex extends bitforex$1 {
230
230
  'max': undefined,
231
231
  },
232
232
  },
233
+ 'created': undefined,
233
234
  'info': market,
234
235
  });
235
236
  }
@@ -1474,6 +1474,7 @@ class bitget extends bitget$1 {
1474
1474
  'max': undefined,
1475
1475
  },
1476
1476
  },
1477
+ 'created': undefined,
1477
1478
  };
1478
1479
  }
1479
1480
  return result;
@@ -3882,8 +3883,16 @@ class bitget extends bitget$1 {
3882
3883
  //
3883
3884
  const data = this.safeValue(response, 'data');
3884
3885
  if (data !== undefined) {
3885
- const result = this.safeValue(data, 'orderList', data);
3886
- return this.addPaginationCursorToResult(data, result);
3886
+ if ('orderList' in data) {
3887
+ const orderList = this.safeValue(data, 'orderList');
3888
+ if (!orderList) {
3889
+ return [];
3890
+ }
3891
+ return this.addPaginationCursorToResult(data, orderList);
3892
+ }
3893
+ else {
3894
+ return this.addPaginationCursorToResult(response, data);
3895
+ }
3887
3896
  }
3888
3897
  const parsedData = JSON.parse(response);
3889
3898
  return this.safeValue(parsedData, 'data', []);
@@ -258,6 +258,7 @@ class bithumb extends bithumb$1 {
258
258
  },
259
259
  'cost': {}, // set via options
260
260
  },
261
+ 'created': undefined,
261
262
  'info': market,
262
263
  }, extension);
263
264
  result.push(entry);
@@ -60,8 +60,10 @@ class bitmart extends bitmart$1 {
60
60
  'fetchFundingRate': true,
61
61
  'fetchFundingRateHistory': false,
62
62
  'fetchFundingRates': false,
63
+ 'fetchLiquidations': false,
63
64
  'fetchMarginMode': false,
64
65
  'fetchMarkets': true,
66
+ 'fetchMyLiquidations': true,
65
67
  'fetchMyTrades': true,
66
68
  'fetchOHLCV': true,
67
69
  'fetchOpenInterest': true,
@@ -3934,6 +3936,107 @@ class bitmart extends bitmart$1 {
3934
3936
  'takeProfitPrice': undefined,
3935
3937
  });
3936
3938
  }
3939
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3940
+ /**
3941
+ * @method
3942
+ * @name bitmart#fetchMyLiquidations
3943
+ * @description retrieves the users liquidated positions
3944
+ * @see https://developer-pro.bitmart.com/en/futures/#get-order-history-keyed
3945
+ * @param {string} symbol unified CCXT market symbol
3946
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
3947
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
3948
+ * @param {object} [params] exchange specific parameters for the bitmart api endpoint
3949
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
3950
+ * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
3951
+ */
3952
+ this.checkRequiredSymbol('fetchMyLiquidations', symbol);
3953
+ await this.loadMarkets();
3954
+ const market = this.market(symbol);
3955
+ if (!market['swap']) {
3956
+ throw new errors.NotSupported(this.id + ' fetchMyLiquidations() supports swap markets only');
3957
+ }
3958
+ let request = {
3959
+ 'symbol': market['id'],
3960
+ };
3961
+ if (since !== undefined) {
3962
+ request['start_time'] = since;
3963
+ }
3964
+ [request, params] = this.handleUntilOption('end_time', request, params);
3965
+ const response = await this.privateGetContractPrivateOrderHistory(this.extend(request, params));
3966
+ //
3967
+ // {
3968
+ // "code": 1000,
3969
+ // "message": "Ok",
3970
+ // "data": [
3971
+ // {
3972
+ // "order_id": "231007865458273",
3973
+ // "client_order_id": "",
3974
+ // "price": "27407.9",
3975
+ // "size": "1",
3976
+ // "symbol": "BTCUSDT",
3977
+ // "state": 4,
3978
+ // "side": 3,
3979
+ // "type": "liquidate",
3980
+ // "leverage": "10",
3981
+ // "open_type": "isolated",
3982
+ // "deal_avg_price": "27422.6",
3983
+ // "deal_size": "1",
3984
+ // "create_time": 1696405864011,
3985
+ // "update_time": 1696405864045
3986
+ // },
3987
+ // ],
3988
+ // "trace": "4cad855074664097ac6ba4257c47305d.71.16965658195443021"
3989
+ // }
3990
+ //
3991
+ const data = this.safeValue(response, 'data', []);
3992
+ const result = [];
3993
+ for (let i = 0; i < data.length; i++) {
3994
+ const entry = data[i];
3995
+ const checkLiquidation = this.safeString(entry, 'type');
3996
+ if (checkLiquidation === 'liquidate') {
3997
+ result.push(entry);
3998
+ }
3999
+ }
4000
+ return this.parseLiquidations(result, market, since, limit);
4001
+ }
4002
+ parseLiquidation(liquidation, market = undefined) {
4003
+ //
4004
+ // {
4005
+ // "order_id": "231007865458273",
4006
+ // "client_order_id": "",
4007
+ // "price": "27407.9",
4008
+ // "size": "1",
4009
+ // "symbol": "BTCUSDT",
4010
+ // "state": 4,
4011
+ // "side": 3,
4012
+ // "type": "market",
4013
+ // "leverage": "10",
4014
+ // "open_type": "isolated",
4015
+ // "deal_avg_price": "27422.6",
4016
+ // "deal_size": "1",
4017
+ // "create_time": 1696405864011,
4018
+ // "update_time": 1696405864045
4019
+ // }
4020
+ //
4021
+ const marketId = this.safeString(liquidation, 'symbol');
4022
+ const timestamp = this.safeInteger(liquidation, 'update_time');
4023
+ const contractsString = this.safeString(liquidation, 'deal_size');
4024
+ const contractSizeString = this.safeString(market, 'contractSize');
4025
+ const priceString = this.safeString(liquidation, 'deal_avg_price');
4026
+ const baseValueString = Precise["default"].stringMul(contractsString, contractSizeString);
4027
+ const quoteValueString = Precise["default"].stringMul(baseValueString, priceString);
4028
+ return {
4029
+ 'info': liquidation,
4030
+ 'symbol': this.safeSymbol(marketId, market),
4031
+ 'contracts': this.parseNumber(contractsString),
4032
+ 'contractSize': this.parseNumber(contractSizeString),
4033
+ 'price': this.parseNumber(priceString),
4034
+ 'baseValue': this.parseNumber(baseValueString),
4035
+ 'quoteValue': this.parseNumber(quoteValueString),
4036
+ 'timestamp': timestamp,
4037
+ 'datetime': this.iso8601(timestamp),
4038
+ };
4039
+ }
3937
4040
  nonce() {
3938
4041
  return this.milliseconds();
3939
4042
  }
@@ -58,9 +58,11 @@ class bitmex extends bitmex$1 {
58
58
  'fetchLedger': true,
59
59
  'fetchLeverage': false,
60
60
  'fetchLeverageTiers': false,
61
+ 'fetchLiquidations': true,
61
62
  'fetchMarketLeverageTiers': false,
62
63
  'fetchMarkets': true,
63
64
  'fetchMarkOHLCV': false,
65
+ 'fetchMyLiquidations': false,
64
66
  'fetchMyTrades': true,
65
67
  'fetchOHLCV': true,
66
68
  'fetchOpenOrders': true,
@@ -2648,6 +2650,74 @@ class bitmex extends bitmex$1 {
2648
2650
  }
2649
2651
  return cost;
2650
2652
  }
2653
+ async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
2654
+ /**
2655
+ * @method
2656
+ * @name bitmex#fetchLiquidations
2657
+ * @description retrieves the public liquidations of a trading pair
2658
+ * @see https://www.bitmex.com/api/explorer/#!/Liquidation/Liquidation_get
2659
+ * @param {string} symbol unified CCXT market symbol
2660
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
2661
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
2662
+ * @param {object} [params] exchange specific parameters for the bitmex api endpoint
2663
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
2664
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
2665
+ * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
2666
+ */
2667
+ await this.loadMarkets();
2668
+ let paginate = false;
2669
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
2670
+ if (paginate) {
2671
+ return await this.fetchPaginatedCallDynamic('fetchLiquidations', symbol, since, limit, params);
2672
+ }
2673
+ const market = this.market(symbol);
2674
+ let request = {
2675
+ 'symbol': market['id'],
2676
+ };
2677
+ if (since !== undefined) {
2678
+ request['startTime'] = since;
2679
+ }
2680
+ if (limit !== undefined) {
2681
+ request['count'] = limit;
2682
+ }
2683
+ [request, params] = this.handleUntilOption('endTime', request, params);
2684
+ const response = await this.publicGetLiquidation(this.extend(request, params));
2685
+ //
2686
+ // [
2687
+ // {
2688
+ // "orderID": "string",
2689
+ // "symbol": "string",
2690
+ // "side": "string",
2691
+ // "price": 0,
2692
+ // "leavesQty": 0
2693
+ // }
2694
+ // ]
2695
+ //
2696
+ return this.parseLiquidations(response, market, since, limit);
2697
+ }
2698
+ parseLiquidation(liquidation, market = undefined) {
2699
+ //
2700
+ // {
2701
+ // "orderID": "string",
2702
+ // "symbol": "string",
2703
+ // "side": "string",
2704
+ // "price": 0,
2705
+ // "leavesQty": 0
2706
+ // }
2707
+ //
2708
+ const marketId = this.safeString(liquidation, 'symbol');
2709
+ return {
2710
+ 'info': liquidation,
2711
+ 'symbol': this.safeSymbol(marketId, market),
2712
+ 'contracts': undefined,
2713
+ 'contractSize': this.safeNumber(market, 'contractSize'),
2714
+ 'price': this.safeNumber(liquidation, 'price'),
2715
+ 'baseValue': undefined,
2716
+ 'quoteValue': undefined,
2717
+ 'timestamp': undefined,
2718
+ 'datetime': undefined,
2719
+ };
2720
+ }
2651
2721
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2652
2722
  if (response === undefined) {
2653
2723
  return undefined;
@@ -358,6 +358,7 @@ class bitopro extends bitopro$1 {
358
358
  'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'basePrecision'))),
359
359
  },
360
360
  'active': active,
361
+ 'created': undefined,
361
362
  'info': market,
362
363
  });
363
364
  }