ccxt 4.1.11 → 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 (96) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1056 -66
  3. package/dist/ccxt.browser.min.js +3 -3
  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 +310 -37
  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 +20 -4
  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 +15 -9
  32. package/dist/cjs/src/cryptocom.js +1 -1
  33. package/dist/cjs/src/delta.js +2 -2
  34. package/dist/cjs/src/deribit.js +163 -0
  35. package/dist/cjs/src/gate.js +189 -0
  36. package/dist/cjs/src/huobi.js +105 -4
  37. package/dist/cjs/src/kucoin.js +1 -0
  38. package/dist/cjs/src/kucoinfutures.js +1 -1
  39. package/dist/cjs/src/okx.js +2 -0
  40. package/dist/cjs/src/poloniex.js +21 -7
  41. package/dist/cjs/src/whitebit.js +1 -0
  42. package/js/ccxt.d.ts +3 -3
  43. package/js/ccxt.js +1 -1
  44. package/js/src/abstract/poloniex.d.ts +18 -5
  45. package/js/src/ace.js +1 -0
  46. package/js/src/alpaca.js +1 -0
  47. package/js/src/base/Exchange.d.ts +6 -2
  48. package/js/src/base/Exchange.js +30 -0
  49. package/js/src/base/types.d.ts +9 -0
  50. package/js/src/bigone.js +1 -0
  51. package/js/src/binance.d.ts +13 -1
  52. package/js/src/binance.js +310 -37
  53. package/js/src/bingx.d.ts +1 -0
  54. package/js/src/bingx.js +1 -0
  55. package/js/src/bitbank.js +1 -0
  56. package/js/src/bitbns.js +1 -0
  57. package/js/src/bitfinex.js +1 -0
  58. package/js/src/bitfinex2.js +1 -0
  59. package/js/src/bitflyer.js +1 -0
  60. package/js/src/bitforex.js +1 -0
  61. package/js/src/bitget.js +20 -4
  62. package/js/src/bithumb.js +1 -0
  63. package/js/src/bitmart.d.ts +12 -0
  64. package/js/src/bitmart.js +103 -0
  65. package/js/src/bitmex.d.ts +13 -1
  66. package/js/src/bitmex.js +70 -0
  67. package/js/src/bitopro.js +1 -0
  68. package/js/src/bitpanda.js +1 -0
  69. package/js/src/bitrue.js +1 -0
  70. package/js/src/bitso.js +1 -0
  71. package/js/src/bitstamp.js +1 -0
  72. package/js/src/bitvavo.js +1 -0
  73. package/js/src/blockchaincom.js +1 -0
  74. package/js/src/btcalpha.js +1 -0
  75. package/js/src/btcmarkets.js +1 -0
  76. package/js/src/btcturk.js +1 -0
  77. package/js/src/bybit.d.ts +3 -3
  78. package/js/src/bybit.js +15 -9
  79. package/js/src/cryptocom.d.ts +1 -1
  80. package/js/src/cryptocom.js +1 -1
  81. package/js/src/delta.d.ts +2 -54
  82. package/js/src/delta.js +2 -2
  83. package/js/src/deribit.d.ts +14 -0
  84. package/js/src/deribit.js +163 -0
  85. package/js/src/gate.d.ts +13 -0
  86. package/js/src/gate.js +189 -0
  87. package/js/src/huobi.d.ts +13 -1
  88. package/js/src/huobi.js +105 -4
  89. package/js/src/kucoin.js +1 -0
  90. package/js/src/kucoinfutures.js +1 -1
  91. package/js/src/mexc.d.ts +4 -4
  92. package/js/src/okx.js +2 -0
  93. package/js/src/poloniex.js +21 -7
  94. package/js/src/whitebit.js +1 -0
  95. package/package.json +1 -1
  96. package/skip-tests.json +61 -5
package/js/src/bitget.js CHANGED
@@ -1477,6 +1477,7 @@ export default class bitget extends Exchange {
1477
1477
  'max': undefined,
1478
1478
  },
1479
1479
  },
1480
+ 'created': undefined,
1480
1481
  };
1481
1482
  }
1482
1483
  return result;
@@ -1576,7 +1577,7 @@ export default class bitget extends Exchange {
1576
1577
  }
1577
1578
  const currency = this.currency(code);
1578
1579
  if (since === undefined) {
1579
- since = this.milliseconds() - 31556952000; // 1yr
1580
+ since = this.milliseconds() - 7776000000; // 90 days
1580
1581
  }
1581
1582
  let request = {
1582
1583
  'coin': currency['code'],
@@ -1732,7 +1733,7 @@ export default class bitget extends Exchange {
1732
1733
  }
1733
1734
  const currency = this.currency(code);
1734
1735
  if (since === undefined) {
1735
- since = this.milliseconds() - 31556952000; // 1yr
1736
+ since = this.milliseconds() - 7776000000; // 90 days
1736
1737
  }
1737
1738
  let request = {
1738
1739
  'coin': currency['code'],
@@ -3885,8 +3886,16 @@ export default class bitget extends Exchange {
3885
3886
  //
3886
3887
  const data = this.safeValue(response, 'data');
3887
3888
  if (data !== undefined) {
3888
- const result = this.safeValue(data, 'orderList', data);
3889
- return this.addPaginationCursorToResult(data, result);
3889
+ if ('orderList' in data) {
3890
+ const orderList = this.safeValue(data, 'orderList');
3891
+ if (!orderList) {
3892
+ return [];
3893
+ }
3894
+ return this.addPaginationCursorToResult(data, orderList);
3895
+ }
3896
+ else {
3897
+ return this.addPaginationCursorToResult(response, data);
3898
+ }
3890
3899
  }
3891
3900
  const parsedData = JSON.parse(response);
3892
3901
  return this.safeValue(parsedData, 'data', []);
@@ -4045,10 +4054,17 @@ export default class bitget extends Exchange {
4045
4054
  response = await this.privateSpotPostTradeFills(this.extend(request, params));
4046
4055
  }
4047
4056
  else {
4057
+ const orderId = this.safeString(params, 'orderId'); // when order id is not defined, startTime and endTime are required
4048
4058
  if (since !== undefined) {
4049
4059
  request['startTime'] = since;
4050
4060
  }
4061
+ else if (orderId === undefined) {
4062
+ request['startTime'] = 0;
4063
+ }
4051
4064
  [request, params] = this.handleUntilOption('endTime', params, request);
4065
+ if (!('endTime' in request) && (orderId === undefined)) {
4066
+ request['endTime'] = this.milliseconds();
4067
+ }
4052
4068
  response = await this.privateMixGetOrderFills(this.extend(request, params));
4053
4069
  }
4054
4070
  //
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,
@@ -3937,6 +3939,107 @@ export default class bitmart extends Exchange {
3937
3939
  'takeProfitPrice': undefined,
3938
3940
  });
3939
3941
  }
3942
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3943
+ /**
3944
+ * @method
3945
+ * @name bitmart#fetchMyLiquidations
3946
+ * @description retrieves the users liquidated positions
3947
+ * @see https://developer-pro.bitmart.com/en/futures/#get-order-history-keyed
3948
+ * @param {string} symbol unified CCXT market symbol
3949
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
3950
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
3951
+ * @param {object} [params] exchange specific parameters for the bitmart api endpoint
3952
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
3953
+ * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
3954
+ */
3955
+ this.checkRequiredSymbol('fetchMyLiquidations', symbol);
3956
+ await this.loadMarkets();
3957
+ const market = this.market(symbol);
3958
+ if (!market['swap']) {
3959
+ throw new NotSupported(this.id + ' fetchMyLiquidations() supports swap markets only');
3960
+ }
3961
+ let request = {
3962
+ 'symbol': market['id'],
3963
+ };
3964
+ if (since !== undefined) {
3965
+ request['start_time'] = since;
3966
+ }
3967
+ [request, params] = this.handleUntilOption('end_time', request, params);
3968
+ const response = await this.privateGetContractPrivateOrderHistory(this.extend(request, params));
3969
+ //
3970
+ // {
3971
+ // "code": 1000,
3972
+ // "message": "Ok",
3973
+ // "data": [
3974
+ // {
3975
+ // "order_id": "231007865458273",
3976
+ // "client_order_id": "",
3977
+ // "price": "27407.9",
3978
+ // "size": "1",
3979
+ // "symbol": "BTCUSDT",
3980
+ // "state": 4,
3981
+ // "side": 3,
3982
+ // "type": "liquidate",
3983
+ // "leverage": "10",
3984
+ // "open_type": "isolated",
3985
+ // "deal_avg_price": "27422.6",
3986
+ // "deal_size": "1",
3987
+ // "create_time": 1696405864011,
3988
+ // "update_time": 1696405864045
3989
+ // },
3990
+ // ],
3991
+ // "trace": "4cad855074664097ac6ba4257c47305d.71.16965658195443021"
3992
+ // }
3993
+ //
3994
+ const data = this.safeValue(response, 'data', []);
3995
+ const result = [];
3996
+ for (let i = 0; i < data.length; i++) {
3997
+ const entry = data[i];
3998
+ const checkLiquidation = this.safeString(entry, 'type');
3999
+ if (checkLiquidation === 'liquidate') {
4000
+ result.push(entry);
4001
+ }
4002
+ }
4003
+ return this.parseLiquidations(result, market, since, limit);
4004
+ }
4005
+ parseLiquidation(liquidation, market = undefined) {
4006
+ //
4007
+ // {
4008
+ // "order_id": "231007865458273",
4009
+ // "client_order_id": "",
4010
+ // "price": "27407.9",
4011
+ // "size": "1",
4012
+ // "symbol": "BTCUSDT",
4013
+ // "state": 4,
4014
+ // "side": 3,
4015
+ // "type": "market",
4016
+ // "leverage": "10",
4017
+ // "open_type": "isolated",
4018
+ // "deal_avg_price": "27422.6",
4019
+ // "deal_size": "1",
4020
+ // "create_time": 1696405864011,
4021
+ // "update_time": 1696405864045
4022
+ // }
4023
+ //
4024
+ const marketId = this.safeString(liquidation, 'symbol');
4025
+ const timestamp = this.safeInteger(liquidation, 'update_time');
4026
+ const contractsString = this.safeString(liquidation, 'deal_size');
4027
+ const contractSizeString = this.safeString(market, 'contractSize');
4028
+ const priceString = this.safeString(liquidation, 'deal_avg_price');
4029
+ const baseValueString = Precise.stringMul(contractsString, contractSizeString);
4030
+ const quoteValueString = Precise.stringMul(baseValueString, priceString);
4031
+ return {
4032
+ 'info': liquidation,
4033
+ 'symbol': this.safeSymbol(marketId, market),
4034
+ 'contracts': this.parseNumber(contractsString),
4035
+ 'contractSize': this.parseNumber(contractSizeString),
4036
+ 'price': this.parseNumber(priceString),
4037
+ 'baseValue': this.parseNumber(baseValueString),
4038
+ 'quoteValue': this.parseNumber(quoteValueString),
4039
+ 'timestamp': timestamp,
4040
+ 'datetime': this.iso8601(timestamp),
4041
+ };
4042
+ }
3940
4043
  nonce() {
3941
4044
  return this.milliseconds();
3942
4045
  }
@@ -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
  }
package/js/src/bitvavo.js CHANGED
@@ -387,6 +387,7 @@ export default class bitvavo extends Exchange {
387
387
  'max': undefined,
388
388
  },
389
389
  },
390
+ 'created': undefined,
390
391
  'info': market,
391
392
  });
392
393
  }
@@ -349,6 +349,7 @@ export default class blockchaincom extends Exchange {
349
349
  'max': undefined,
350
350
  },
351
351
  },
352
+ 'created': undefined,
352
353
  });
353
354
  }
354
355
  return result;
@@ -229,6 +229,7 @@ export default class btcalpha extends Exchange {
229
229
  'max': undefined,
230
230
  },
231
231
  },
232
+ 'created': undefined,
232
233
  'info': market,
233
234
  });
234
235
  }
@@ -434,6 +434,7 @@ export default class btcmarkets extends Exchange {
434
434
  'max': undefined,
435
435
  },
436
436
  },
437
+ 'created': undefined,
437
438
  'info': market,
438
439
  });
439
440
  }
package/js/src/btcturk.js CHANGED
@@ -262,6 +262,7 @@ export default class btcturk extends Exchange {
262
262
  'max': undefined,
263
263
  },
264
264
  },
265
+ 'created': undefined,
265
266
  'info': entry,
266
267
  });
267
268
  }
package/js/src/bybit.d.ts CHANGED
@@ -197,9 +197,9 @@ export default class bybit extends Exchange {
197
197
  updated: number;
198
198
  fee: any;
199
199
  }>;
200
- fetchPosition(symbol: string, params?: {}): Promise<any>;
201
- fetchUsdcPositions(symbols?: string[], params?: {}): Promise<any>;
202
- fetchPositions(symbols?: string[], params?: {}): Promise<any>;
200
+ fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
201
+ fetchUsdcPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
202
+ fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
203
203
  parsePosition(position: any, market?: any): import("./base/types.js").Position;
204
204
  setMarginMode(marginMode: any, symbol?: string, params?: {}): Promise<any>;
205
205
  setLeverage(leverage: any, symbol?: string, params?: {}): Promise<any>;
package/js/src/bybit.js CHANGED
@@ -1753,6 +1753,7 @@ export default class bybit extends Exchange {
1753
1753
  'max': this.safeNumber(lotSizeFilter, 'maxOrderAmt'),
1754
1754
  },
1755
1755
  },
1756
+ 'created': undefined,
1756
1757
  'info': market,
1757
1758
  });
1758
1759
  }
@@ -1927,6 +1928,7 @@ export default class bybit extends Exchange {
1927
1928
  'max': undefined,
1928
1929
  },
1929
1930
  },
1931
+ 'created': this.safeInteger(market, 'launchTime'),
1930
1932
  'info': market,
1931
1933
  });
1932
1934
  }
@@ -2059,6 +2061,7 @@ export default class bybit extends Exchange {
2059
2061
  'max': undefined,
2060
2062
  },
2061
2063
  },
2064
+ 'created': this.safeInteger(market, 'launchTime'),
2062
2065
  'info': market,
2063
2066
  });
2064
2067
  }
@@ -2774,7 +2777,7 @@ export default class bybit extends Exchange {
2774
2777
  const feeToken = this.safeString(trade, 'feeTokenId');
2775
2778
  const feeCurrency = this.safeCurrencyCode(feeToken);
2776
2779
  fee = {
2777
- 'cost': feeCost,
2780
+ 'cost': Precise.stringAbs(feeCost),
2778
2781
  'currency': feeCurrency,
2779
2782
  };
2780
2783
  }
@@ -2940,7 +2943,7 @@ export default class bybit extends Exchange {
2940
2943
  feeCurrencyCode = market['inverse'] ? market['base'] : market['settle'];
2941
2944
  }
2942
2945
  fee = {
2943
- 'cost': feeCostString,
2946
+ 'cost': Precise.stringAbs(feeCostString),
2944
2947
  'currency': feeCurrencyCode,
2945
2948
  };
2946
2949
  }
@@ -3513,10 +3516,14 @@ export default class bybit extends Exchange {
3513
3516
  // }
3514
3517
  //
3515
3518
  const marketId = this.safeString(order, 'symbol');
3516
- let marketType = 'contract';
3519
+ const isContract = ('tpslMode' in order);
3520
+ let marketType = undefined;
3517
3521
  if (market !== undefined) {
3518
3522
  marketType = market['type'];
3519
3523
  }
3524
+ else {
3525
+ marketType = isContract ? 'contract' : 'spot';
3526
+ }
3520
3527
  market = this.safeMarket(marketId, market, undefined, marketType);
3521
3528
  const symbol = market['symbol'];
3522
3529
  const timestamp = this.safeInteger2(order, 'createdTime', 'createdAt');
@@ -5536,7 +5543,7 @@ export default class bybit extends Exchange {
5536
5543
  'referenceAccount': undefined,
5537
5544
  'referenceId': referenceId,
5538
5545
  'status': undefined,
5539
- 'amount': this.parseNumber(amount),
5546
+ 'amount': this.parseNumber(Precise.stringAbs(amount)),
5540
5547
  'before': this.parseNumber(before),
5541
5548
  'after': this.parseNumber(after),
5542
5549
  'fee': this.parseNumber(this.safeString(item, 'fee')),
@@ -5693,10 +5700,9 @@ export default class bybit extends Exchange {
5693
5700
  const timestamp = this.safeInteger(response, 'time');
5694
5701
  const first = this.safeValue(positions, 0, {});
5695
5702
  const position = this.parsePosition(first, market);
5696
- return this.extend(position, {
5697
- 'timestamp': timestamp,
5698
- 'datetime': this.iso8601(timestamp),
5699
- });
5703
+ position['timestamp'] = timestamp;
5704
+ position['datetime'] = this.iso8601(timestamp);
5705
+ return position;
5700
5706
  }
5701
5707
  async fetchUsdcPositions(symbols = undefined, params = {}) {
5702
5708
  await this.loadMarkets();
@@ -5771,7 +5777,7 @@ export default class bybit extends Exchange {
5771
5777
  }
5772
5778
  results.push(this.parsePosition(rawPosition, market));
5773
5779
  }
5774
- return this.filterByArray(results, 'symbol', symbols, false);
5780
+ return this.filterByArrayPositions(results, 'symbol', symbols, false);
5775
5781
  }
5776
5782
  async fetchPositions(symbols = undefined, params = {}) {
5777
5783
  /**
@@ -181,7 +181,7 @@ export default class cryptocom extends Exchange {
181
181
  parseSettlements(settlements: any, market: any): any[];
182
182
  fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
183
183
  fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
184
- fetchPositions(symbols?: string[], params?: {}): Promise<any>;
184
+ fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
185
185
  parsePosition(position: any, market?: any): import("./base/types.js").Position;
186
186
  nonce(): number;
187
187
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
@@ -2956,7 +2956,7 @@ export default class cryptocom extends Exchange {
2956
2956
  const marketInner = this.safeMarket(marketId, undefined, undefined, 'contract');
2957
2957
  result.push(this.parsePosition(entry, marketInner));
2958
2958
  }
2959
- return this.filterByArray(result, 'symbol', undefined, false);
2959
+ return this.filterByArrayPositions(result, 'symbol', undefined, false);
2960
2960
  }
2961
2961
  parsePosition(position, market = undefined) {
2962
2962
  //
package/js/src/delta.d.ts CHANGED
@@ -74,61 +74,9 @@ export default class delta extends Exchange {
74
74
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").OHLCV[]>;
75
75
  parseBalance(response: any): import("./base/types.js").Balances;
76
76
  fetchBalance(params?: {}): Promise<import("./base/types.js").Balances>;
77
- fetchPosition(symbol: string, params?: {}): Promise<{
78
- info: any;
79
- id: any;
80
- symbol: any;
81
- notional: any;
82
- marginMode: any;
83
- liquidationPrice: number;
84
- entryPrice: number;
85
- unrealizedPnl: any;
86
- percentage: any;
87
- contracts: number;
88
- contractSize: number;
89
- markPrice: any;
90
- side: any;
91
- hedged: any;
92
- timestamp: number;
93
- datetime: string;
94
- maintenanceMargin: any;
95
- maintenanceMarginPercentage: any;
96
- collateral: any;
97
- initialMargin: any;
98
- initialMarginPercentage: any;
99
- leverage: any;
100
- marginRatio: any;
101
- stopLossPrice: any;
102
- takeProfitPrice: any;
103
- }>;
77
+ fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
104
78
  fetchPositions(symbols?: string[], params?: {}): Promise<import("./base/types.js").Position[]>;
105
- parsePosition(position: any, market?: any): {
106
- info: any;
107
- id: any;
108
- symbol: any;
109
- notional: any;
110
- marginMode: any;
111
- liquidationPrice: number;
112
- entryPrice: number;
113
- unrealizedPnl: any;
114
- percentage: any;
115
- contracts: number;
116
- contractSize: number;
117
- markPrice: any;
118
- side: any;
119
- hedged: any;
120
- timestamp: number;
121
- datetime: string;
122
- maintenanceMargin: any;
123
- maintenanceMarginPercentage: any;
124
- collateral: any;
125
- initialMargin: any;
126
- initialMarginPercentage: any;
127
- leverage: any;
128
- marginRatio: any;
129
- stopLossPrice: any;
130
- takeProfitPrice: any;
131
- };
79
+ parsePosition(position: any, market?: any): import("./base/types.js").Position;
132
80
  parseOrderStatus(status: any): string;
133
81
  parseOrder(order: any, market?: any): import("./base/types.js").Order;
134
82
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<import("./base/types.js").Order>;
package/js/src/delta.js CHANGED
@@ -1675,7 +1675,7 @@ export default class delta extends Exchange {
1675
1675
  side = 'sell';
1676
1676
  }
1677
1677
  }
1678
- return {
1678
+ return this.safePosition({
1679
1679
  'info': position,
1680
1680
  'id': undefined,
1681
1681
  'symbol': symbol,
@@ -1701,7 +1701,7 @@ export default class delta extends Exchange {
1701
1701
  'marginRatio': undefined,
1702
1702
  'stopLossPrice': undefined,
1703
1703
  'takeProfitPrice': undefined,
1704
- };
1704
+ });
1705
1705
  }
1706
1706
  parseOrderStatus(status) {
1707
1707
  const statuses = {
@@ -182,6 +182,20 @@ export default class deribit extends Exchange {
182
182
  previousFundingTimestamp: any;
183
183
  previousFundingDatetime: any;
184
184
  };
185
+ fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
186
+ addPaginationCursorToResult(cursor: any, data: any): any;
187
+ fetchMyLiquidations(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<import("./base/types.js").Liquidation[]>;
188
+ parseLiquidation(liquidation: any, market?: any): {
189
+ info: any;
190
+ symbol: any;
191
+ contracts: any;
192
+ contractSize: number;
193
+ price: any;
194
+ baseValue: number;
195
+ quoteValue: any;
196
+ timestamp: number;
197
+ datetime: string;
198
+ };
185
199
  nonce(): number;
186
200
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
187
201
  url: string;