ccxt 4.1.12 → 4.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +219 -0
  2. package/CONTRIBUTING.md +1 -0
  3. package/README.md +3 -3
  4. package/dist/ccxt.browser.js +1242 -120
  5. package/dist/ccxt.browser.min.js +3 -3
  6. package/dist/cjs/ccxt.js +1 -1
  7. package/dist/cjs/src/ace.js +1 -0
  8. package/dist/cjs/src/alpaca.js +1 -0
  9. package/dist/cjs/src/ascendex.js +1 -0
  10. package/dist/cjs/src/base/Exchange.js +30 -0
  11. package/dist/cjs/src/bigone.js +1 -0
  12. package/dist/cjs/src/binance.js +237 -3
  13. package/dist/cjs/src/bingx.js +5 -2
  14. package/dist/cjs/src/bitbank.js +1 -0
  15. package/dist/cjs/src/bitbns.js +1 -0
  16. package/dist/cjs/src/bitfinex.js +1 -0
  17. package/dist/cjs/src/bitfinex2.js +1 -0
  18. package/dist/cjs/src/bitflyer.js +1 -0
  19. package/dist/cjs/src/bitforex.js +1 -0
  20. package/dist/cjs/src/bitget.js +203 -3
  21. package/dist/cjs/src/bithumb.js +1 -0
  22. package/dist/cjs/src/bitmart.js +105 -0
  23. package/dist/cjs/src/bitmex.js +70 -0
  24. package/dist/cjs/src/bitopro.js +1 -0
  25. package/dist/cjs/src/bitpanda.js +1 -0
  26. package/dist/cjs/src/bitrue.js +1 -0
  27. package/dist/cjs/src/bitso.js +1 -0
  28. package/dist/cjs/src/bitstamp.js +1 -0
  29. package/dist/cjs/src/bittrex.js +6 -0
  30. package/dist/cjs/src/bitvavo.js +1 -0
  31. package/dist/cjs/src/blockchaincom.js +1 -0
  32. package/dist/cjs/src/btcalpha.js +1 -0
  33. package/dist/cjs/src/btcmarkets.js +1 -0
  34. package/dist/cjs/src/btcturk.js +1 -0
  35. package/dist/cjs/src/bybit.js +3 -3
  36. package/dist/cjs/src/cex.js +1 -0
  37. package/dist/cjs/src/coinbase.js +1 -0
  38. package/dist/cjs/src/coinbasepro.js +1 -0
  39. package/dist/cjs/src/coinex.js +2 -0
  40. package/dist/cjs/src/coinfalcon.js +1 -0
  41. package/dist/cjs/src/coinmate.js +1 -0
  42. package/dist/cjs/src/coinone.js +2 -1
  43. package/dist/cjs/src/cryptocom.js +25 -87
  44. package/dist/cjs/src/currencycom.js +1 -0
  45. package/dist/cjs/src/delta.js +1 -0
  46. package/dist/cjs/src/deribit.js +164 -0
  47. package/dist/cjs/src/digifinex.js +1 -0
  48. package/dist/cjs/src/exmo.js +1 -0
  49. package/dist/cjs/src/gate.js +192 -0
  50. package/dist/cjs/src/gemini.js +1 -0
  51. package/dist/cjs/src/hitbtc.js +1 -0
  52. package/dist/cjs/src/hollaex.js +1 -0
  53. package/dist/cjs/src/huobi.js +102 -0
  54. package/dist/cjs/src/huobijp.js +1 -0
  55. package/dist/cjs/src/idex.js +1 -0
  56. package/dist/cjs/src/independentreserve.js +1 -0
  57. package/dist/cjs/src/indodax.js +1 -0
  58. package/dist/cjs/src/kraken.js +9 -0
  59. package/dist/cjs/src/krakenfutures.js +1 -0
  60. package/dist/cjs/src/kucoin.js +1 -0
  61. package/dist/cjs/src/kucoinfutures.js +1 -1
  62. package/dist/cjs/src/latoken.js +1 -0
  63. package/dist/cjs/src/okx.js +1 -0
  64. package/dist/cjs/src/poloniex.js +21 -7
  65. package/dist/cjs/src/poloniexfutures.js +8 -2
  66. package/dist/cjs/src/pro/krakenfutures.js +14 -10
  67. package/dist/cjs/src/woo.js +1 -0
  68. package/js/ccxt.d.ts +3 -3
  69. package/js/ccxt.js +1 -1
  70. package/js/src/abstract/binance.d.ts +4 -0
  71. package/js/src/abstract/binancecoinm.d.ts +4 -0
  72. package/js/src/abstract/binanceus.d.ts +4 -0
  73. package/js/src/abstract/binanceusdm.d.ts +4 -0
  74. package/js/src/abstract/kraken.d.ts +8 -0
  75. package/js/src/abstract/poloniex.d.ts +18 -5
  76. package/js/src/abstract/poloniexfutures.d.ts +6 -1
  77. package/js/src/ace.js +1 -0
  78. package/js/src/alpaca.js +1 -0
  79. package/js/src/ascendex.js +1 -0
  80. package/js/src/base/Exchange.d.ts +6 -2
  81. package/js/src/base/Exchange.js +30 -0
  82. package/js/src/base/types.d.ts +9 -0
  83. package/js/src/bigone.js +1 -0
  84. package/js/src/binance.d.ts +13 -1
  85. package/js/src/binance.js +237 -3
  86. package/js/src/bingx.d.ts +1 -0
  87. package/js/src/bingx.js +5 -2
  88. package/js/src/bitbank.js +1 -0
  89. package/js/src/bitbns.js +1 -0
  90. package/js/src/bitfinex.js +1 -0
  91. package/js/src/bitfinex2.js +1 -0
  92. package/js/src/bitflyer.js +1 -0
  93. package/js/src/bitforex.js +1 -0
  94. package/js/src/bitget.d.ts +28 -0
  95. package/js/src/bitget.js +203 -3
  96. package/js/src/bithumb.js +1 -0
  97. package/js/src/bitmart.d.ts +12 -0
  98. package/js/src/bitmart.js +105 -0
  99. package/js/src/bitmex.d.ts +13 -1
  100. package/js/src/bitmex.js +70 -0
  101. package/js/src/bitopro.js +1 -0
  102. package/js/src/bitpanda.js +1 -0
  103. package/js/src/bitrue.js +1 -0
  104. package/js/src/bitso.js +1 -0
  105. package/js/src/bitstamp.js +1 -0
  106. package/js/src/bittrex.d.ts +2 -2
  107. package/js/src/bittrex.js +6 -0
  108. package/js/src/bitvavo.js +1 -0
  109. package/js/src/blockchaincom.js +1 -0
  110. package/js/src/btcalpha.js +1 -0
  111. package/js/src/btcmarkets.js +1 -0
  112. package/js/src/btcturk.js +1 -0
  113. package/js/src/bybit.js +3 -3
  114. package/js/src/cex.js +1 -0
  115. package/js/src/coinbase.js +1 -0
  116. package/js/src/coinbasepro.js +1 -0
  117. package/js/src/coinex.js +2 -0
  118. package/js/src/coinfalcon.js +1 -0
  119. package/js/src/coinmate.js +1 -0
  120. package/js/src/coinone.js +2 -1
  121. package/js/src/cryptocom.d.ts +0 -2
  122. package/js/src/cryptocom.js +25 -87
  123. package/js/src/currencycom.js +1 -0
  124. package/js/src/delta.js +1 -0
  125. package/js/src/deribit.d.ts +14 -0
  126. package/js/src/deribit.js +164 -0
  127. package/js/src/digifinex.js +1 -0
  128. package/js/src/exmo.js +1 -0
  129. package/js/src/gate.d.ts +14 -0
  130. package/js/src/gate.js +192 -0
  131. package/js/src/gemini.d.ts +1 -0
  132. package/js/src/gemini.js +1 -0
  133. package/js/src/hitbtc.js +1 -0
  134. package/js/src/hollaex.js +1 -0
  135. package/js/src/huobi.d.ts +12 -0
  136. package/js/src/huobi.js +102 -0
  137. package/js/src/huobijp.js +1 -0
  138. package/js/src/idex.js +1 -0
  139. package/js/src/independentreserve.js +1 -0
  140. package/js/src/indodax.js +1 -0
  141. package/js/src/kraken.js +9 -0
  142. package/js/src/krakenfutures.js +1 -0
  143. package/js/src/kucoin.js +1 -0
  144. package/js/src/kucoinfutures.js +1 -1
  145. package/js/src/latoken.js +1 -0
  146. package/js/src/okx.js +1 -0
  147. package/js/src/poloniex.js +21 -7
  148. package/js/src/poloniexfutures.js +8 -2
  149. package/js/src/pro/krakenfutures.js +14 -10
  150. package/js/src/woo.js +1 -0
  151. package/package.json +1 -1
  152. package/skip-tests.json +94 -12
@@ -577,6 +577,7 @@ export default class bitfinex2 extends Exchange {
577
577
  'max': undefined,
578
578
  },
579
579
  },
580
+ 'created': undefined,
580
581
  'info': market,
581
582
  });
582
583
  }
@@ -295,6 +295,7 @@ export default class bitflyer extends Exchange {
295
295
  'max': undefined,
296
296
  },
297
297
  },
298
+ 'created': undefined,
298
299
  'info': market,
299
300
  });
300
301
  }
@@ -233,6 +233,7 @@ export default class bitforex extends Exchange {
233
233
  'max': undefined,
234
234
  },
235
235
  },
236
+ 'created': undefined,
236
237
  'info': market,
237
238
  });
238
239
  }
@@ -58,6 +58,7 @@ export default class bitget extends Exchange {
58
58
  max: any;
59
59
  };
60
60
  };
61
+ created: any;
61
62
  info: any;
62
63
  };
63
64
  fetchMarketsByType(type: any, params?: {}): Promise<any[]>;
@@ -286,6 +287,33 @@ export default class bitget extends Exchange {
286
287
  fetchDepositWithdrawFees(codes?: string[], params?: {}): Promise<any>;
287
288
  parseTransferStatus(status: any): string;
288
289
  parseOpenInterest(interest: any, market?: any): import("./base/types.js").OpenInterest;
290
+ borrowMargin(code: string, amount: any, symbol?: string, params?: {}): Promise<{
291
+ id: string;
292
+ currency: any;
293
+ amount: number;
294
+ symbol: any;
295
+ timestamp: any;
296
+ datetime: any;
297
+ info: any;
298
+ }>;
299
+ repayMargin(code: string, amount: any, symbol?: string, params?: {}): Promise<{
300
+ id: string;
301
+ currency: any;
302
+ amount: number;
303
+ symbol: any;
304
+ timestamp: any;
305
+ datetime: any;
306
+ info: any;
307
+ }>;
308
+ parseMarginLoan(info: any, currency?: any): {
309
+ id: string;
310
+ currency: any;
311
+ amount: number;
312
+ symbol: any;
313
+ timestamp: any;
314
+ datetime: any;
315
+ info: any;
316
+ };
289
317
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
290
318
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
291
319
  url: string;
package/js/src/bitget.js CHANGED
@@ -28,11 +28,12 @@ export default class bitget extends Exchange {
28
28
  'has': {
29
29
  'CORS': undefined,
30
30
  'spot': true,
31
- 'margin': false,
31
+ 'margin': undefined,
32
32
  'swap': true,
33
33
  'future': true,
34
34
  'option': false,
35
35
  'addMargin': true,
36
+ 'borrowMargin': true,
36
37
  'cancelAllOrders': true,
37
38
  'cancelOrder': true,
38
39
  'cancelOrders': true,
@@ -91,6 +92,7 @@ export default class bitget extends Exchange {
91
92
  'fetchWithdrawal': false,
92
93
  'fetchWithdrawals': true,
93
94
  'reduceMargin': true,
95
+ 'repayMargin': true,
94
96
  'setLeverage': true,
95
97
  'setMarginMode': true,
96
98
  'setPositionMode': true,
@@ -1295,6 +1297,7 @@ export default class bitget extends Exchange {
1295
1297
  'max': undefined,
1296
1298
  },
1297
1299
  },
1300
+ 'created': undefined,
1298
1301
  'info': market,
1299
1302
  };
1300
1303
  }
@@ -1477,6 +1480,7 @@ export default class bitget extends Exchange {
1477
1480
  'max': undefined,
1478
1481
  },
1479
1482
  },
1483
+ 'created': undefined,
1480
1484
  };
1481
1485
  }
1482
1486
  return result;
@@ -3885,8 +3889,16 @@ export default class bitget extends Exchange {
3885
3889
  //
3886
3890
  const data = this.safeValue(response, 'data');
3887
3891
  if (data !== undefined) {
3888
- const result = this.safeValue(data, 'orderList', data);
3889
- return this.addPaginationCursorToResult(data, result);
3892
+ if ('orderList' in data) {
3893
+ const orderList = this.safeValue(data, 'orderList');
3894
+ if (!orderList) {
3895
+ return [];
3896
+ }
3897
+ return this.addPaginationCursorToResult(data, orderList);
3898
+ }
3899
+ else {
3900
+ return this.addPaginationCursorToResult(response, data);
3901
+ }
3890
3902
  }
3891
3903
  const parsedData = JSON.parse(response);
3892
3904
  return this.safeValue(parsedData, 'data', []);
@@ -5192,6 +5204,194 @@ export default class bitget extends Exchange {
5192
5204
  'info': interest,
5193
5205
  }, market);
5194
5206
  }
5207
+ async borrowMargin(code, amount, symbol = undefined, params = {}) {
5208
+ /**
5209
+ * @method
5210
+ * @name bitget#borrowMargin
5211
+ * @description create a loan to borrow margin
5212
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-borrow
5213
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-borrow
5214
+ * @param {string} code unified currency code of the currency to borrow
5215
+ * @param {string} amount the amount to borrow
5216
+ * @param {string} [symbol] unified market symbol
5217
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
5218
+ * @param {string} [params.marginMode] 'isolated' or 'cross', symbol is required for 'isolated'
5219
+ * @returns {object} a [margin loan structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#margin-loan-structure}
5220
+ */
5221
+ await this.loadMarkets();
5222
+ const currency = this.currency(code);
5223
+ const request = {
5224
+ 'coin': currency['info']['coinName'],
5225
+ 'borrowAmount': this.currencyToPrecision(code, amount),
5226
+ };
5227
+ let response = undefined;
5228
+ let marginMode = undefined;
5229
+ [marginMode, params] = this.handleMarginModeAndParams('borrowMargin', params);
5230
+ if ((symbol !== undefined) || (marginMode === 'isolated')) {
5231
+ this.checkRequiredSymbol('borrowMargin', symbol);
5232
+ const market = this.market(symbol);
5233
+ const marketId = market['id'];
5234
+ const parts = marketId.split('_');
5235
+ const marginMarketId = this.safeStringUpper(parts, 0);
5236
+ request['symbol'] = marginMarketId;
5237
+ response = await this.privateMarginPostIsolatedAccountBorrow(this.extend(request, params));
5238
+ }
5239
+ else {
5240
+ response = await this.privateMarginPostCrossAccountBorrow(this.extend(request, params));
5241
+ }
5242
+ //
5243
+ // isolated
5244
+ //
5245
+ // {
5246
+ // "code": "00000",
5247
+ // "msg": "success",
5248
+ // "requestTime": 1697250952516,
5249
+ // "data": {
5250
+ // "clientOid": null,
5251
+ // "symbol": "BTCUSDT",
5252
+ // "coin": "BTC",
5253
+ // "borrowAmount": "0.001"
5254
+ // }
5255
+ // }
5256
+ //
5257
+ // cross
5258
+ //
5259
+ // {
5260
+ // "code": "00000",
5261
+ // "msg": "success",
5262
+ // "requestTime": 1697251314271,
5263
+ // "data": {
5264
+ // "clientOid": null,
5265
+ // "coin": "BTC",
5266
+ // "borrowAmount": "0.0001"
5267
+ // }
5268
+ // }
5269
+ //
5270
+ const data = this.safeValue(response, 'data', {});
5271
+ return this.parseMarginLoan(data, currency);
5272
+ }
5273
+ async repayMargin(code, amount, symbol = undefined, params = {}) {
5274
+ /**
5275
+ * @method
5276
+ * @name bitget#repayMargin
5277
+ * @description repay borrowed margin and interest
5278
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-repay
5279
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-repay
5280
+ * @param {string} code unified currency code of the currency to repay
5281
+ * @param {string} amount the amount to repay
5282
+ * @param {string} [symbol] unified market symbol
5283
+ * @param {object} [params] extra parameters specific to the bitget api endpoint
5284
+ * @param {string} [params.marginMode] 'isolated' or 'cross', symbol is required for 'isolated'
5285
+ * @returns {object} a [margin loan structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#margin-loan-structure}
5286
+ */
5287
+ await this.loadMarkets();
5288
+ const currency = this.currency(code);
5289
+ const request = {
5290
+ 'coin': currency['info']['coinName'],
5291
+ 'repayAmount': this.currencyToPrecision(code, amount),
5292
+ };
5293
+ let response = undefined;
5294
+ let marginMode = undefined;
5295
+ [marginMode, params] = this.handleMarginModeAndParams('repayMargin', params);
5296
+ if ((symbol !== undefined) || (marginMode === 'isolated')) {
5297
+ this.checkRequiredSymbol('repayMargin', symbol);
5298
+ const market = this.market(symbol);
5299
+ const marketId = market['id'];
5300
+ const parts = marketId.split('_');
5301
+ const marginMarketId = this.safeStringUpper(parts, 0);
5302
+ request['symbol'] = marginMarketId;
5303
+ response = await this.privateMarginPostIsolatedAccountRepay(this.extend(request, params));
5304
+ }
5305
+ else {
5306
+ response = await this.privateMarginPostCrossAccountRepay(this.extend(request, params));
5307
+ }
5308
+ //
5309
+ // isolated
5310
+ //
5311
+ // {
5312
+ // "code": "00000",
5313
+ // "msg": "success",
5314
+ // "requestTime": 1697251988593,
5315
+ // "data": {
5316
+ // "remainDebtAmount": "0",
5317
+ // "clientOid": null,
5318
+ // "symbol": "BTCUSDT",
5319
+ // "coin": "BTC",
5320
+ // "repayAmount": "0.00100001"
5321
+ // }
5322
+ // }
5323
+ //
5324
+ // cross
5325
+ //
5326
+ // {
5327
+ // "code": "00000",
5328
+ // "msg": "success",
5329
+ // "requestTime": 1697252151042,
5330
+ // "data": {
5331
+ // "remainDebtAmount": "0",
5332
+ // "clientOid": null,
5333
+ // "coin": "BTC",
5334
+ // "repayAmount": "0.00010001"
5335
+ // }
5336
+ // }
5337
+ //
5338
+ const data = this.safeValue(response, 'data', {});
5339
+ return this.parseMarginLoan(data, currency);
5340
+ }
5341
+ parseMarginLoan(info, currency = undefined) {
5342
+ //
5343
+ // isolated: borrowMargin
5344
+ //
5345
+ // {
5346
+ // "clientOid": null,
5347
+ // "symbol": "BTCUSDT",
5348
+ // "coin": "BTC",
5349
+ // "borrowAmount": "0.001"
5350
+ // }
5351
+ //
5352
+ // cross: borrowMargin
5353
+ //
5354
+ // {
5355
+ // "clientOid": null,
5356
+ // "coin": "BTC",
5357
+ // "borrowAmount": "0.0001"
5358
+ // }
5359
+ //
5360
+ // isolated: repayMargin
5361
+ //
5362
+ // {
5363
+ // "remainDebtAmount": "0",
5364
+ // "clientOid": null,
5365
+ // "symbol": "BTCUSDT",
5366
+ // "coin": "BTC",
5367
+ // "repayAmount": "0.00100001"
5368
+ // }
5369
+ //
5370
+ // cross: repayMargin
5371
+ //
5372
+ // {
5373
+ // "remainDebtAmount": "0",
5374
+ // "clientOid": null,
5375
+ // "coin": "BTC",
5376
+ // "repayAmount": "0.00010001"
5377
+ // }
5378
+ //
5379
+ const currencyId = this.safeString(info, 'coin');
5380
+ const marketId = this.safeString(info, 'symbol');
5381
+ let symbol = undefined;
5382
+ if (marketId !== undefined) {
5383
+ symbol = this.safeSymbol(marketId);
5384
+ }
5385
+ return {
5386
+ 'id': this.safeString(info, 'clientOid'),
5387
+ 'currency': this.safeCurrencyCode(currencyId, currency),
5388
+ 'amount': this.safeNumber2(info, 'borrowAmount', 'repayAmount'),
5389
+ 'symbol': symbol,
5390
+ 'timestamp': undefined,
5391
+ 'datetime': undefined,
5392
+ 'info': info,
5393
+ };
5394
+ }
5195
5395
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
5196
5396
  if (!response) {
5197
5397
  return undefined; // fallback to default error handler
package/js/src/bithumb.js CHANGED
@@ -261,6 +261,7 @@ export default class bithumb extends Exchange {
261
261
  },
262
262
  'cost': {}, // set via options
263
263
  },
264
+ 'created': undefined,
264
265
  'info': market,
265
266
  }, extension);
266
267
  result.push(entry);
@@ -256,6 +256,18 @@ export default class bitmart extends Exchange {
256
256
  fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
257
257
  fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
258
258
  parsePosition(position: any, market?: any): import("./base/types.js").Position;
259
+ fetchMyLiquidations(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Liquidation[]>;
260
+ parseLiquidation(liquidation: any, market?: any): {
261
+ info: any;
262
+ symbol: any;
263
+ contracts: number;
264
+ contractSize: number;
265
+ price: number;
266
+ baseValue: number;
267
+ quoteValue: number;
268
+ timestamp: number;
269
+ datetime: string;
270
+ };
259
271
  nonce(): number;
260
272
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
261
273
  url: string;
package/js/src/bitmart.js CHANGED
@@ -63,8 +63,10 @@ export default class bitmart extends Exchange {
63
63
  'fetchFundingRate': true,
64
64
  'fetchFundingRateHistory': false,
65
65
  'fetchFundingRates': false,
66
+ 'fetchLiquidations': false,
66
67
  'fetchMarginMode': false,
67
68
  'fetchMarkets': true,
69
+ 'fetchMyLiquidations': true,
68
70
  'fetchMyTrades': true,
69
71
  'fetchOHLCV': true,
70
72
  'fetchOpenInterest': true,
@@ -758,6 +760,7 @@ export default class bitmart extends Exchange {
758
760
  'max': undefined,
759
761
  },
760
762
  },
763
+ 'created': undefined,
761
764
  'info': market,
762
765
  });
763
766
  }
@@ -864,6 +867,7 @@ export default class bitmart extends Exchange {
864
867
  'max': undefined,
865
868
  },
866
869
  },
870
+ 'created': this.safeInteger(market, 'open_timestamp'),
867
871
  'info': market,
868
872
  });
869
873
  }
@@ -3937,6 +3941,107 @@ export default class bitmart extends Exchange {
3937
3941
  'takeProfitPrice': undefined,
3938
3942
  });
3939
3943
  }
3944
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3945
+ /**
3946
+ * @method
3947
+ * @name bitmart#fetchMyLiquidations
3948
+ * @description retrieves the users liquidated positions
3949
+ * @see https://developer-pro.bitmart.com/en/futures/#get-order-history-keyed
3950
+ * @param {string} symbol unified CCXT market symbol
3951
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
3952
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
3953
+ * @param {object} [params] exchange specific parameters for the bitmart api endpoint
3954
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
3955
+ * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
3956
+ */
3957
+ this.checkRequiredSymbol('fetchMyLiquidations', symbol);
3958
+ await this.loadMarkets();
3959
+ const market = this.market(symbol);
3960
+ if (!market['swap']) {
3961
+ throw new NotSupported(this.id + ' fetchMyLiquidations() supports swap markets only');
3962
+ }
3963
+ let request = {
3964
+ 'symbol': market['id'],
3965
+ };
3966
+ if (since !== undefined) {
3967
+ request['start_time'] = since;
3968
+ }
3969
+ [request, params] = this.handleUntilOption('end_time', request, params);
3970
+ const response = await this.privateGetContractPrivateOrderHistory(this.extend(request, params));
3971
+ //
3972
+ // {
3973
+ // "code": 1000,
3974
+ // "message": "Ok",
3975
+ // "data": [
3976
+ // {
3977
+ // "order_id": "231007865458273",
3978
+ // "client_order_id": "",
3979
+ // "price": "27407.9",
3980
+ // "size": "1",
3981
+ // "symbol": "BTCUSDT",
3982
+ // "state": 4,
3983
+ // "side": 3,
3984
+ // "type": "liquidate",
3985
+ // "leverage": "10",
3986
+ // "open_type": "isolated",
3987
+ // "deal_avg_price": "27422.6",
3988
+ // "deal_size": "1",
3989
+ // "create_time": 1696405864011,
3990
+ // "update_time": 1696405864045
3991
+ // },
3992
+ // ],
3993
+ // "trace": "4cad855074664097ac6ba4257c47305d.71.16965658195443021"
3994
+ // }
3995
+ //
3996
+ const data = this.safeValue(response, 'data', []);
3997
+ const result = [];
3998
+ for (let i = 0; i < data.length; i++) {
3999
+ const entry = data[i];
4000
+ const checkLiquidation = this.safeString(entry, 'type');
4001
+ if (checkLiquidation === 'liquidate') {
4002
+ result.push(entry);
4003
+ }
4004
+ }
4005
+ return this.parseLiquidations(result, market, since, limit);
4006
+ }
4007
+ parseLiquidation(liquidation, market = undefined) {
4008
+ //
4009
+ // {
4010
+ // "order_id": "231007865458273",
4011
+ // "client_order_id": "",
4012
+ // "price": "27407.9",
4013
+ // "size": "1",
4014
+ // "symbol": "BTCUSDT",
4015
+ // "state": 4,
4016
+ // "side": 3,
4017
+ // "type": "market",
4018
+ // "leverage": "10",
4019
+ // "open_type": "isolated",
4020
+ // "deal_avg_price": "27422.6",
4021
+ // "deal_size": "1",
4022
+ // "create_time": 1696405864011,
4023
+ // "update_time": 1696405864045
4024
+ // }
4025
+ //
4026
+ const marketId = this.safeString(liquidation, 'symbol');
4027
+ const timestamp = this.safeInteger(liquidation, 'update_time');
4028
+ const contractsString = this.safeString(liquidation, 'deal_size');
4029
+ const contractSizeString = this.safeString(market, 'contractSize');
4030
+ const priceString = this.safeString(liquidation, 'deal_avg_price');
4031
+ const baseValueString = Precise.stringMul(contractsString, contractSizeString);
4032
+ const quoteValueString = Precise.stringMul(baseValueString, priceString);
4033
+ return {
4034
+ 'info': liquidation,
4035
+ 'symbol': this.safeSymbol(marketId, market),
4036
+ 'contracts': this.parseNumber(contractsString),
4037
+ 'contractSize': this.parseNumber(contractSizeString),
4038
+ 'price': this.parseNumber(priceString),
4039
+ 'baseValue': this.parseNumber(baseValueString),
4040
+ 'quoteValue': this.parseNumber(quoteValueString),
4041
+ 'timestamp': timestamp,
4042
+ 'datetime': this.iso8601(timestamp),
4043
+ };
4044
+ }
3940
4045
  nonce() {
3941
4046
  return this.milliseconds();
3942
4047
  }
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitmex.js';
2
- import { Int, OrderSide, OrderType, Trade, OHLCV, Order } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation } from './base/types.js';
3
3
  /**
4
4
  * @class bitmex
5
5
  * @extends Exchange
@@ -163,6 +163,18 @@ export default class bitmex extends Exchange {
163
163
  };
164
164
  fetchDepositWithdrawFees(codes?: string[], params?: {}): Promise<any>;
165
165
  calculateRateLimiterCost(api: any, method: any, path: any, params: any, config?: {}): any;
166
+ fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
167
+ parseLiquidation(liquidation: any, market?: any): {
168
+ info: any;
169
+ symbol: any;
170
+ contracts: any;
171
+ contractSize: number;
172
+ price: number;
173
+ baseValue: any;
174
+ quoteValue: any;
175
+ timestamp: any;
176
+ datetime: any;
177
+ };
166
178
  handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
167
179
  nonce(): number;
168
180
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
package/js/src/bitmex.js CHANGED
@@ -61,9 +61,11 @@ export default class bitmex extends Exchange {
61
61
  'fetchLedger': true,
62
62
  'fetchLeverage': false,
63
63
  'fetchLeverageTiers': false,
64
+ 'fetchLiquidations': true,
64
65
  'fetchMarketLeverageTiers': false,
65
66
  'fetchMarkets': true,
66
67
  'fetchMarkOHLCV': false,
68
+ 'fetchMyLiquidations': false,
67
69
  'fetchMyTrades': true,
68
70
  'fetchOHLCV': true,
69
71
  'fetchOpenOrders': true,
@@ -2651,6 +2653,74 @@ export default class bitmex extends Exchange {
2651
2653
  }
2652
2654
  return cost;
2653
2655
  }
2656
+ async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
2657
+ /**
2658
+ * @method
2659
+ * @name bitmex#fetchLiquidations
2660
+ * @description retrieves the public liquidations of a trading pair
2661
+ * @see https://www.bitmex.com/api/explorer/#!/Liquidation/Liquidation_get
2662
+ * @param {string} symbol unified CCXT market symbol
2663
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
2664
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
2665
+ * @param {object} [params] exchange specific parameters for the bitmex api endpoint
2666
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
2667
+ * @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)
2668
+ * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
2669
+ */
2670
+ await this.loadMarkets();
2671
+ let paginate = false;
2672
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
2673
+ if (paginate) {
2674
+ return await this.fetchPaginatedCallDynamic('fetchLiquidations', symbol, since, limit, params);
2675
+ }
2676
+ const market = this.market(symbol);
2677
+ let request = {
2678
+ 'symbol': market['id'],
2679
+ };
2680
+ if (since !== undefined) {
2681
+ request['startTime'] = since;
2682
+ }
2683
+ if (limit !== undefined) {
2684
+ request['count'] = limit;
2685
+ }
2686
+ [request, params] = this.handleUntilOption('endTime', request, params);
2687
+ const response = await this.publicGetLiquidation(this.extend(request, params));
2688
+ //
2689
+ // [
2690
+ // {
2691
+ // "orderID": "string",
2692
+ // "symbol": "string",
2693
+ // "side": "string",
2694
+ // "price": 0,
2695
+ // "leavesQty": 0
2696
+ // }
2697
+ // ]
2698
+ //
2699
+ return this.parseLiquidations(response, market, since, limit);
2700
+ }
2701
+ parseLiquidation(liquidation, market = undefined) {
2702
+ //
2703
+ // {
2704
+ // "orderID": "string",
2705
+ // "symbol": "string",
2706
+ // "side": "string",
2707
+ // "price": 0,
2708
+ // "leavesQty": 0
2709
+ // }
2710
+ //
2711
+ const marketId = this.safeString(liquidation, 'symbol');
2712
+ return {
2713
+ 'info': liquidation,
2714
+ 'symbol': this.safeSymbol(marketId, market),
2715
+ 'contracts': undefined,
2716
+ 'contractSize': this.safeNumber(market, 'contractSize'),
2717
+ 'price': this.safeNumber(liquidation, 'price'),
2718
+ 'baseValue': undefined,
2719
+ 'quoteValue': undefined,
2720
+ 'timestamp': undefined,
2721
+ 'datetime': undefined,
2722
+ };
2723
+ }
2654
2724
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2655
2725
  if (response === undefined) {
2656
2726
  return undefined;
package/js/src/bitopro.js CHANGED
@@ -361,6 +361,7 @@ export default class bitopro extends Exchange {
361
361
  'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'basePrecision'))),
362
362
  },
363
363
  'active': active,
364
+ 'created': undefined,
364
365
  'info': market,
365
366
  });
366
367
  }
@@ -433,6 +433,7 @@ export default class bitpanda extends Exchange {
433
433
  'max': undefined,
434
434
  },
435
435
  },
436
+ 'created': undefined,
436
437
  'info': market,
437
438
  });
438
439
  }
package/js/src/bitrue.js CHANGED
@@ -705,6 +705,7 @@ export default class bitrue extends Exchange {
705
705
  'max': undefined,
706
706
  },
707
707
  },
708
+ 'created': undefined,
708
709
  'info': market,
709
710
  };
710
711
  result.push(entry);
package/js/src/bitso.js CHANGED
@@ -471,6 +471,7 @@ export default class bitso extends Exchange {
471
471
  'max': this.safeNumber(market, 'maximum_value'),
472
472
  },
473
473
  },
474
+ 'created': undefined,
474
475
  'info': market,
475
476
  }, fee));
476
477
  }
@@ -508,6 +508,7 @@ export default class bitstamp extends Exchange {
508
508
  'max': undefined,
509
509
  },
510
510
  },
511
+ 'created': undefined,
511
512
  'info': market,
512
513
  });
513
514
  }
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bittrex.js';
2
- import { Int, OrderSide, OrderType } from './base/types.js';
2
+ import { Int, OrderSide, OrderType, OHLCV } from './base/types.js';
3
3
  /**
4
4
  * @class bittrex
5
5
  * @extends Exchange
@@ -38,7 +38,7 @@ export default class bittrex extends Exchange {
38
38
  info: any;
39
39
  };
40
40
  parseOHLCV(ohlcv: any, market?: any): number[];
41
- fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
41
+ fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
42
42
  fetchOpenOrders(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Order[]>;
43
43
  fetchOrderTrades(id: string, symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Trade[]>;
44
44
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;