ccxt 4.2.47 → 4.2.49

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 (59) hide show
  1. package/README.md +3 -3
  2. package/build.sh +7 -0
  3. package/dist/ccxt.browser.js +681 -84
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/binance.js +10 -4
  7. package/dist/cjs/src/bitmart.js +30 -4
  8. package/dist/cjs/src/bitstamp.js +8 -0
  9. package/dist/cjs/src/btcalpha.js +4 -0
  10. package/dist/cjs/src/btcmarkets.js +4 -0
  11. package/dist/cjs/src/btcturk.js +4 -0
  12. package/dist/cjs/src/bybit.js +138 -6
  13. package/dist/cjs/src/idex.js +52 -1
  14. package/dist/cjs/src/independentreserve.js +48 -0
  15. package/dist/cjs/src/indodax.js +120 -19
  16. package/dist/cjs/src/latoken.js +16 -0
  17. package/dist/cjs/src/luno.js +18 -0
  18. package/dist/cjs/src/lykke.js +19 -0
  19. package/dist/cjs/src/ndax.js +18 -0
  20. package/dist/cjs/src/okx.js +32 -5
  21. package/dist/cjs/src/pro/ascendex.js +22 -7
  22. package/dist/cjs/src/pro/bitget.js +28 -7
  23. package/dist/cjs/src/pro/bitstamp.js +1 -1
  24. package/dist/cjs/src/pro/hitbtc.js +6 -11
  25. package/dist/cjs/src/pro/mexc.js +2 -1
  26. package/dist/cjs/src/upbit.js +100 -17
  27. package/js/ccxt.d.ts +1 -1
  28. package/js/ccxt.js +1 -1
  29. package/js/src/abstract/bitstamp.d.ts +8 -0
  30. package/js/src/abstract/indodax.d.ts +9 -8
  31. package/js/src/binance.js +10 -4
  32. package/js/src/bitmart.js +30 -4
  33. package/js/src/bitstamp.js +8 -0
  34. package/js/src/btcalpha.js +4 -0
  35. package/js/src/btcmarkets.js +4 -0
  36. package/js/src/btcturk.js +4 -0
  37. package/js/src/bybit.d.ts +3 -1
  38. package/js/src/bybit.js +138 -6
  39. package/js/src/idex.d.ts +7 -0
  40. package/js/src/idex.js +52 -1
  41. package/js/src/independentreserve.d.ts +15 -1
  42. package/js/src/independentreserve.js +48 -0
  43. package/js/src/indodax.d.ts +3 -1
  44. package/js/src/indodax.js +120 -19
  45. package/js/src/latoken.js +16 -0
  46. package/js/src/luno.js +18 -0
  47. package/js/src/lykke.js +19 -0
  48. package/js/src/ndax.js +18 -0
  49. package/js/src/okx.js +32 -5
  50. package/js/src/pro/ascendex.d.ts +1 -0
  51. package/js/src/pro/ascendex.js +22 -7
  52. package/js/src/pro/bitget.js +28 -7
  53. package/js/src/pro/bitstamp.js +1 -1
  54. package/js/src/pro/hitbtc.js +6 -11
  55. package/js/src/pro/mexc.js +2 -1
  56. package/js/src/upbit.d.ts +2 -0
  57. package/js/src/upbit.js +100 -17
  58. package/package.json +3 -1
  59. package/skip-tests.json +4 -2
package/dist/cjs/ccxt.js CHANGED
@@ -177,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
177
177
 
178
178
  //-----------------------------------------------------------------------------
179
179
  // this is updated by vss.js when building
180
- const version = '4.2.47';
180
+ const version = '4.2.49';
181
181
  Exchange["default"].ccxtVersion = version;
182
182
  const exchanges = {
183
183
  'ace': ace,
@@ -3017,7 +3017,7 @@ class binance extends binance$1 {
3017
3017
  let fees = this.fees;
3018
3018
  let linear = undefined;
3019
3019
  let inverse = undefined;
3020
- const strike = this.safeInteger(market, 'strikePrice');
3020
+ const strike = this.safeString(market, 'strikePrice');
3021
3021
  let symbol = base + '/' + quote;
3022
3022
  if (contract) {
3023
3023
  if (swap) {
@@ -3027,7 +3027,7 @@ class binance extends binance$1 {
3027
3027
  symbol = symbol + ':' + settle + '-' + this.yymmdd(expiry);
3028
3028
  }
3029
3029
  else if (option) {
3030
- symbol = symbol + ':' + settle + '-' + this.yymmdd(expiry) + '-' + this.numberToString(strike) + '-' + this.safeString(optionParts, 3);
3030
+ symbol = symbol + ':' + settle + '-' + this.yymmdd(expiry) + '-' + strike + '-' + this.safeString(optionParts, 3);
3031
3031
  }
3032
3032
  contractSize = this.safeNumber2(market, 'contractSize', 'unit', this.parseNumber('1'));
3033
3033
  linear = settle === quote;
@@ -3060,6 +3060,10 @@ class binance extends binance$1 {
3060
3060
  unifiedType = 'option';
3061
3061
  active = undefined;
3062
3062
  }
3063
+ let parsedStrike = undefined;
3064
+ if (strike !== undefined) {
3065
+ parsedStrike = this.parseToNumeric(strike);
3066
+ }
3063
3067
  const entry = {
3064
3068
  'id': id,
3065
3069
  'lowercaseId': lowercaseId,
@@ -3085,7 +3089,7 @@ class binance extends binance$1 {
3085
3089
  'contractSize': contractSize,
3086
3090
  'expiry': expiry,
3087
3091
  'expiryDatetime': this.iso8601(expiry),
3088
- 'strike': strike,
3092
+ 'strike': parsedStrike,
3089
3093
  'optionType': this.safeStringLower(market, 'side'),
3090
3094
  'precision': {
3091
3095
  'amount': this.safeInteger2(market, 'quantityPrecision', 'quantityScale'),
@@ -5771,12 +5775,14 @@ class binance extends binance$1 {
5771
5775
  const trailingDelta = this.safeString(params, 'trailingDelta');
5772
5776
  const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activationPrice', this.numberToString(price));
5773
5777
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
5778
+ const priceMatch = this.safeString(params, 'priceMatch');
5774
5779
  const isTrailingPercentOrder = trailingPercent !== undefined;
5775
5780
  const isStopLoss = stopLossPrice !== undefined || trailingDelta !== undefined;
5776
5781
  const isTakeProfit = takeProfitPrice !== undefined;
5777
5782
  const isTriggerOrder = triggerPrice !== undefined;
5778
5783
  const isConditional = isTriggerOrder || isTrailingPercentOrder || isStopLoss || isTakeProfit;
5779
5784
  const isPortfolioMarginConditional = (isPortfolioMargin && isConditional);
5785
+ const isPriceMatch = priceMatch !== undefined;
5780
5786
  let uppercaseType = type.toUpperCase();
5781
5787
  let stopPrice = undefined;
5782
5788
  if (isTrailingPercentOrder) {
@@ -5957,7 +5963,7 @@ class binance extends binance$1 {
5957
5963
  request['quantity'] = this.amountToPrecision(symbol, amount);
5958
5964
  }
5959
5965
  }
5960
- if (priceIsRequired) {
5966
+ if (priceIsRequired && !isPriceMatch) {
5961
5967
  if (price === undefined) {
5962
5968
  throw new errors.InvalidOrder(this.id + ' createOrder() requires a price argument for a ' + type + ' order');
5963
5969
  }
@@ -1123,7 +1123,7 @@ class bitmart extends bitmart$1 {
1123
1123
  }
1124
1124
  parseTicker(ticker, market = undefined) {
1125
1125
  //
1126
- // spot
1126
+ // spot (REST)
1127
1127
  //
1128
1128
  // {
1129
1129
  // "symbol": "SOLAR_USDT",
@@ -1143,6 +1143,17 @@ class bitmart extends bitmart$1 {
1143
1143
  // "timestamp": 1667403439367
1144
1144
  // }
1145
1145
  //
1146
+ // spot (WS)
1147
+ // {
1148
+ // "symbol":"BTC_USDT",
1149
+ // "last_price":"146.24",
1150
+ // "open_24h":"147.17",
1151
+ // "high_24h":"147.48",
1152
+ // "low_24h":"143.88",
1153
+ // "base_volume_24h":"117387.58", // NOT base, but quote currency!!!
1154
+ // "s_t": 1610936002
1155
+ // }
1156
+ //
1146
1157
  // swap
1147
1158
  //
1148
1159
  // {
@@ -1158,7 +1169,11 @@ class bitmart extends bitmart$1 {
1158
1169
  // "legal_coin_price":"0.1302699"
1159
1170
  // }
1160
1171
  //
1161
- const timestamp = this.safeInteger(ticker, 'timestamp');
1172
+ let timestamp = this.safeInteger(ticker, 'timestamp');
1173
+ if (timestamp === undefined) {
1174
+ // ticker from WS has a different field (in seconds)
1175
+ timestamp = this.safeIntegerProduct(ticker, 's_t', 1000);
1176
+ }
1162
1177
  const marketId = this.safeString2(ticker, 'symbol', 'contract_symbol');
1163
1178
  market = this.safeMarket(marketId, market);
1164
1179
  const symbol = market['symbol'];
@@ -1174,9 +1189,20 @@ class bitmart extends bitmart$1 {
1174
1189
  percentage = '0';
1175
1190
  }
1176
1191
  }
1177
- const baseVolume = this.safeString(ticker, 'base_volume_24h');
1192
+ let baseVolume = this.safeString(ticker, 'base_volume_24h');
1178
1193
  let quoteVolume = this.safeString(ticker, 'quote_volume_24h');
1179
- quoteVolume = this.safeString(ticker, 'volume_24h', quoteVolume);
1194
+ if (quoteVolume === undefined) {
1195
+ if (baseVolume === undefined) {
1196
+ // this is swap
1197
+ quoteVolume = this.safeString(ticker, 'volume_24h', quoteVolume);
1198
+ }
1199
+ else {
1200
+ // this is a ticker from websockets
1201
+ // contrary to name and documentation, base_volume_24h is actually the quote volume
1202
+ quoteVolume = baseVolume;
1203
+ baseVolume = undefined;
1204
+ }
1205
+ }
1180
1206
  const average = this.safeString2(ticker, 'avg_price', 'index_price');
1181
1207
  const high = this.safeString2(ticker, 'high_24h', 'high_price');
1182
1208
  const low = this.safeString2(ticker, 'low_24h', 'low_price');
@@ -348,6 +348,14 @@ class bitstamp extends bitstamp$1 {
348
348
  'eurcv_address/': 1,
349
349
  'pyusd_withdrawal/': 1,
350
350
  'pyusd_address/': 1,
351
+ 'lmwr_withdrawal/': 1,
352
+ 'lmwr_address/': 1,
353
+ 'pepe_withdrawal/': 1,
354
+ 'pepe_address/': 1,
355
+ 'blur_withdrawal/': 1,
356
+ 'blur_address/': 1,
357
+ 'vext_withdrawal/': 1,
358
+ 'vext_address/': 1,
351
359
  },
352
360
  },
353
361
  },
@@ -30,6 +30,7 @@ class btcalpha extends btcalpha$1 {
30
30
  'cancelOrder': true,
31
31
  'closeAllPositions': false,
32
32
  'closePosition': false,
33
+ 'createDepositAddress': false,
33
34
  'createOrder': true,
34
35
  'createReduceOnlyOrder': false,
35
36
  'createStopLimitOrder': false,
@@ -42,6 +43,9 @@ class btcalpha extends btcalpha$1 {
42
43
  'fetchCrossBorrowRate': false,
43
44
  'fetchCrossBorrowRates': false,
44
45
  'fetchDeposit': false,
46
+ 'fetchDepositAddress': false,
47
+ 'fetchDepositAddresses': false,
48
+ 'fetchDepositAddressesByNetwork': false,
45
49
  'fetchDeposits': true,
46
50
  'fetchFundingHistory': false,
47
51
  'fetchFundingRate': false,
@@ -32,6 +32,7 @@ class btcmarkets extends btcmarkets$1 {
32
32
  'cancelOrders': true,
33
33
  'closeAllPositions': false,
34
34
  'closePosition': false,
35
+ 'createDepositAddress': false,
35
36
  'createOrder': true,
36
37
  'createReduceOnlyOrder': false,
37
38
  'fetchBalance': true,
@@ -40,6 +41,9 @@ class btcmarkets extends btcmarkets$1 {
40
41
  'fetchClosedOrders': 'emulated',
41
42
  'fetchCrossBorrowRate': false,
42
43
  'fetchCrossBorrowRates': false,
44
+ 'fetchDepositAddress': false,
45
+ 'fetchDepositAddresses': false,
46
+ 'fetchDepositAddressesByNetwork': false,
43
47
  'fetchDeposits': true,
44
48
  'fetchDepositsWithdrawals': true,
45
49
  'fetchFundingHistory': false,
@@ -31,6 +31,7 @@ class btcturk extends btcturk$1 {
31
31
  'cancelOrder': true,
32
32
  'closeAllPositions': false,
33
33
  'closePosition': false,
34
+ 'createDepositAddress': false,
34
35
  'createOrder': true,
35
36
  'createReduceOnlyOrder': false,
36
37
  'fetchBalance': true,
@@ -38,6 +39,9 @@ class btcturk extends btcturk$1 {
38
39
  'fetchBorrowRateHistory': false,
39
40
  'fetchCrossBorrowRate': false,
40
41
  'fetchCrossBorrowRates': false,
42
+ 'fetchDepositAddress': false,
43
+ 'fetchDepositAddresses': false,
44
+ 'fetchDepositAddressesByNetwork': false,
41
45
  'fetchFundingHistory': false,
42
46
  'fetchFundingRate': false,
43
47
  'fetchFundingRateHistory': false,
@@ -81,6 +81,7 @@ class bybit extends bybit$1 {
81
81
  'fetchMarketLeverageTiers': true,
82
82
  'fetchMarkets': true,
83
83
  'fetchMarkOHLCV': true,
84
+ 'fetchMyLiquidations': true,
84
85
  'fetchMySettlementHistory': true,
85
86
  'fetchMyTrades': true,
86
87
  'fetchOHLCV': true,
@@ -4576,7 +4577,7 @@ class bybit extends bybit$1 {
4576
4577
  let paginate = false;
4577
4578
  [paginate, params] = this.handleOptionAndParams(params, 'fetchOrders', 'paginate');
4578
4579
  if (paginate) {
4579
- return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
4580
+ return await this.fetchPaginatedCallCursor('fetchOrders', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 50);
4580
4581
  }
4581
4582
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4582
4583
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
@@ -4754,7 +4755,7 @@ class bybit extends bybit$1 {
4754
4755
  let paginate = false;
4755
4756
  [paginate, params] = this.handleOptionAndParams(params, 'fetchCanceledAndClosedOrders', 'paginate');
4756
4757
  if (paginate) {
4757
- return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
4758
+ return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 50);
4758
4759
  }
4759
4760
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
4760
4761
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
@@ -5126,7 +5127,7 @@ class bybit extends bybit$1 {
5126
5127
  let paginate = false;
5127
5128
  [paginate, params] = this.handleOptionAndParams(params, 'fetchMyTrades', 'paginate');
5128
5129
  if (paginate) {
5129
- return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 100);
5130
+ return await this.fetchPaginatedCallCursor('fetchMyTrades', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 100);
5130
5131
  }
5131
5132
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
5132
5133
  const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
@@ -5328,7 +5329,7 @@ class bybit extends bybit$1 {
5328
5329
  let paginate = false;
5329
5330
  [paginate, params] = this.handleOptionAndParams(params, 'fetchDeposits', 'paginate');
5330
5331
  if (paginate) {
5331
- return await this.fetchPaginatedCallCursor('fetchDeposits', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
5332
+ return await this.fetchPaginatedCallCursor('fetchDeposits', code, since, limit, params, 'nextPageCursor', 'cursor', undefined, 50);
5332
5333
  }
5333
5334
  let request = {
5334
5335
  // 'coin': currency['id'],
@@ -5396,7 +5397,7 @@ class bybit extends bybit$1 {
5396
5397
  let paginate = false;
5397
5398
  [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
5398
5399
  if (paginate) {
5399
- return await this.fetchPaginatedCallCursor('fetchWithdrawals', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
5400
+ return await this.fetchPaginatedCallCursor('fetchWithdrawals', code, since, limit, params, 'nextPageCursor', 'cursor', undefined, 50);
5400
5401
  }
5401
5402
  let request = {
5402
5403
  // 'coin': currency['id'],
@@ -6913,7 +6914,7 @@ class bybit extends bybit$1 {
6913
6914
  let paginate = false;
6914
6915
  [paginate, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'paginate');
6915
6916
  if (paginate) {
6916
- return await this.fetchPaginatedCallCursor('fetchTransfers', code, since, limit, params, 'nextPageCursor', 'nextPageCursor', undefined, 50);
6917
+ return await this.fetchPaginatedCallCursor('fetchTransfers', code, since, limit, params, 'nextPageCursor', 'cursor', undefined, 50);
6917
6918
  }
6918
6919
  let currency = undefined;
6919
6920
  let request = {};
@@ -7747,6 +7748,137 @@ class bybit extends bybit$1 {
7747
7748
  'info': greeks,
7748
7749
  };
7749
7750
  }
7751
+ async fetchMyLiquidations(symbol = undefined, since = undefined, limit = undefined, params = {}) {
7752
+ /**
7753
+ * @method
7754
+ * @name bybit#fetchMyLiquidations
7755
+ * @description retrieves the users liquidated positions
7756
+ * @see https://bybit-exchange.github.io/docs/api-explorer/v5/position/execution
7757
+ * @param {string} [symbol] unified CCXT market symbol
7758
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
7759
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
7760
+ * @param {object} [params] exchange specific parameters for the exchange API endpoint
7761
+ * @param {string} [params.type] market type, ['swap', 'option', 'spot']
7762
+ * @param {string} [params.subType] market subType, ['linear', 'inverse']
7763
+ * @param {boolean} [params.paginate] 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)
7764
+ * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
7765
+ */
7766
+ await this.loadMarkets();
7767
+ let paginate = false;
7768
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchMyLiquidations', 'paginate');
7769
+ if (paginate) {
7770
+ return await this.fetchPaginatedCallCursor('fetchMyLiquidations', symbol, since, limit, params, 'nextPageCursor', 'cursor', undefined, 100);
7771
+ }
7772
+ let request = {
7773
+ 'execType': 'BustTrade',
7774
+ };
7775
+ let market = undefined;
7776
+ if (symbol !== undefined) {
7777
+ market = this.market(symbol);
7778
+ request['symbol'] = market['id'];
7779
+ }
7780
+ let type = undefined;
7781
+ [type, params] = this.getBybitType('fetchMyLiquidations', market, params);
7782
+ request['category'] = type;
7783
+ if (limit !== undefined) {
7784
+ request['limit'] = limit;
7785
+ }
7786
+ if (since !== undefined) {
7787
+ request['startTime'] = since;
7788
+ }
7789
+ [request, params] = this.handleUntilOption('endTime', request, params);
7790
+ const response = await this.privateGetV5ExecutionList(this.extend(request, params));
7791
+ //
7792
+ // {
7793
+ // "retCode": 0,
7794
+ // "retMsg": "OK",
7795
+ // "result": {
7796
+ // "nextPageCursor": "132766%3A2%2C132766%3A2",
7797
+ // "category": "linear",
7798
+ // "list": [
7799
+ // {
7800
+ // "symbol": "ETHPERP",
7801
+ // "orderType": "Market",
7802
+ // "underlyingPrice": "",
7803
+ // "orderLinkId": "",
7804
+ // "side": "Buy",
7805
+ // "indexPrice": "",
7806
+ // "orderId": "8c065341-7b52-4ca9-ac2c-37e31ac55c94",
7807
+ // "stopOrderType": "UNKNOWN",
7808
+ // "leavesQty": "0",
7809
+ // "execTime": "1672282722429",
7810
+ // "isMaker": false,
7811
+ // "execFee": "0.071409",
7812
+ // "feeRate": "0.0006",
7813
+ // "execId": "e0cbe81d-0f18-5866-9415-cf319b5dab3b",
7814
+ // "tradeIv": "",
7815
+ // "blockTradeId": "",
7816
+ // "markPrice": "1183.54",
7817
+ // "execPrice": "1190.15",
7818
+ // "markIv": "",
7819
+ // "orderQty": "0.1",
7820
+ // "orderPrice": "1236.9",
7821
+ // "execValue": "119.015",
7822
+ // "execType": "Trade",
7823
+ // "execQty": "0.1"
7824
+ // }
7825
+ // ]
7826
+ // },
7827
+ // "retExtInfo": {},
7828
+ // "time": 1672283754510
7829
+ // }
7830
+ //
7831
+ const liquidations = this.addPaginationCursorToResult(response);
7832
+ return this.parseLiquidations(liquidations, market, since, limit);
7833
+ }
7834
+ parseLiquidation(liquidation, market = undefined) {
7835
+ //
7836
+ // {
7837
+ // "symbol": "ETHPERP",
7838
+ // "orderType": "Market",
7839
+ // "underlyingPrice": "",
7840
+ // "orderLinkId": "",
7841
+ // "side": "Buy",
7842
+ // "indexPrice": "",
7843
+ // "orderId": "8c065341-7b52-4ca9-ac2c-37e31ac55c94",
7844
+ // "stopOrderType": "UNKNOWN",
7845
+ // "leavesQty": "0",
7846
+ // "execTime": "1672282722429",
7847
+ // "isMaker": false,
7848
+ // "execFee": "0.071409",
7849
+ // "feeRate": "0.0006",
7850
+ // "execId": "e0cbe81d-0f18-5866-9415-cf319b5dab3b",
7851
+ // "tradeIv": "",
7852
+ // "blockTradeId": "",
7853
+ // "markPrice": "1183.54",
7854
+ // "execPrice": "1190.15",
7855
+ // "markIv": "",
7856
+ // "orderQty": "0.1",
7857
+ // "orderPrice": "1236.9",
7858
+ // "execValue": "119.015",
7859
+ // "execType": "Trade",
7860
+ // "execQty": "0.1"
7861
+ // }
7862
+ //
7863
+ const marketId = this.safeString(liquidation, 'symbol');
7864
+ const timestamp = this.safeInteger(liquidation, 'execTime');
7865
+ const contractsString = this.safeString(liquidation, 'execQty');
7866
+ const contractSizeString = this.safeString(market, 'contractSize');
7867
+ const priceString = this.safeString(liquidation, 'execPrice');
7868
+ const baseValueString = Precise["default"].stringMul(contractsString, contractSizeString);
7869
+ const quoteValueString = Precise["default"].stringMul(baseValueString, priceString);
7870
+ return this.safeLiquidation({
7871
+ 'info': liquidation,
7872
+ 'symbol': this.safeSymbol(marketId, market),
7873
+ 'contracts': this.parseNumber(contractsString),
7874
+ 'contractSize': this.parseNumber(contractSizeString),
7875
+ 'price': this.parseNumber(priceString),
7876
+ 'baseValue': this.parseNumber(baseValueString),
7877
+ 'quoteValue': this.parseNumber(quoteValueString),
7878
+ 'timestamp': timestamp,
7879
+ 'datetime': this.iso8601(timestamp),
7880
+ });
7881
+ }
7750
7882
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
7751
7883
  let url = this.implodeHostname(this.urls['api'][api]) + '/' + path;
7752
7884
  if (api === 'public') {
@@ -81,8 +81,10 @@ class idex extends idex$1 {
81
81
  'fetchPositions': false,
82
82
  'fetchPositionsRisk': false,
83
83
  'fetchPremiumIndexOHLCV': false,
84
+ 'fetchStatus': true,
84
85
  'fetchTicker': true,
85
86
  'fetchTickers': true,
87
+ 'fetchTime': true,
86
88
  'fetchTrades': true,
87
89
  'fetchTradingFee': false,
88
90
  'fetchTradingFees': true,
@@ -196,6 +198,7 @@ class idex extends idex$1 {
196
198
  * @method
197
199
  * @name idex#fetchMarkets
198
200
  * @description retrieves data on all markets for idex
201
+ * @see https://api-docs-v3.idex.io/#get-markets
199
202
  * @param {object} [params] extra parameters specific to the exchange API endpoint
200
203
  * @returns {object[]} an array of objects representing market data
201
204
  */
@@ -326,6 +329,7 @@ class idex extends idex$1 {
326
329
  * @method
327
330
  * @name idex#fetchTicker
328
331
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
332
+ * @see https://api-docs-v3.idex.io/#get-tickers
329
333
  * @param {string} symbol unified symbol of the market to fetch the ticker for
330
334
  * @param {object} [params] extra parameters specific to the exchange API endpoint
331
335
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -362,6 +366,7 @@ class idex extends idex$1 {
362
366
  * @method
363
367
  * @name idex#fetchTickers
364
368
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
369
+ * @see https://api-docs-v3.idex.io/#get-tickers
365
370
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
366
371
  * @param {object} [params] extra parameters specific to the exchange API endpoint
367
372
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -438,6 +443,7 @@ class idex extends idex$1 {
438
443
  * @method
439
444
  * @name idex#fetchOHLCV
440
445
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
446
+ * @see https://api-docs-v3.idex.io/#get-candles
441
447
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
442
448
  * @param {string} timeframe the length of time each candle represents
443
449
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -500,6 +506,7 @@ class idex extends idex$1 {
500
506
  * @method
501
507
  * @name idex#fetchTrades
502
508
  * @description get the list of most recent trades for a particular symbol
509
+ * @see https://api-docs-v3.idex.io/#get-trades
503
510
  * @param {string} symbol unified symbol of the market to fetch trades for
504
511
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
505
512
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -613,6 +620,7 @@ class idex extends idex$1 {
613
620
  * @method
614
621
  * @name idex#fetchTradingFees
615
622
  * @description fetch the trading fees for multiple markets
623
+ * @see https://api-docs-v3.idex.io/#get-api-account
616
624
  * @param {object} [params] extra parameters specific to the exchange API endpoint
617
625
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
618
626
  */
@@ -658,6 +666,7 @@ class idex extends idex$1 {
658
666
  * @method
659
667
  * @name idex#fetchOrderBook
660
668
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
669
+ * @see https://api-docs-v3.idex.io/#get-order-books
661
670
  * @param {string} symbol unified symbol of the market to fetch the order book for
662
671
  * @param {int} [limit] the maximum amount of order book entries to return
663
672
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -721,6 +730,7 @@ class idex extends idex$1 {
721
730
  * @method
722
731
  * @name idex#fetchCurrencies
723
732
  * @description fetches all available currencies on an exchange
733
+ * @see https://api-docs-v3.idex.io/#get-assets
724
734
  * @param {object} [params] extra parameters specific to the exchange API endpoint
725
735
  * @returns {object} an associative dictionary of currencies
726
736
  */
@@ -786,6 +796,7 @@ class idex extends idex$1 {
786
796
  * @method
787
797
  * @name idex#fetchBalance
788
798
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
799
+ * @see https://api-docs-v3.idex.io/#get-balances
789
800
  * @param {object} [params] extra parameters specific to the exchange API endpoint
790
801
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
791
802
  */
@@ -830,6 +841,7 @@ class idex extends idex$1 {
830
841
  * @method
831
842
  * @name idex#fetchMyTrades
832
843
  * @description fetch all trades made by the user
844
+ * @see https://api-docs-v3.idex.io/#get-fills
833
845
  * @param {string} symbol unified market symbol
834
846
  * @param {int} [since] the earliest time in ms to fetch trades for
835
847
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -898,6 +910,7 @@ class idex extends idex$1 {
898
910
  * @method
899
911
  * @name idex#fetchOrder
900
912
  * @description fetches information on an order made by the user
913
+ * @see https://api-docs-v3.idex.io/#get-orders
901
914
  * @param {string} symbol unified symbol of the market the order was made in
902
915
  * @param {object} [params] extra parameters specific to the exchange API endpoint
903
916
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -912,6 +925,7 @@ class idex extends idex$1 {
912
925
  * @method
913
926
  * @name idex#fetchOpenOrders
914
927
  * @description fetch all unfilled currently open orders
928
+ * @see https://api-docs-v3.idex.io/#get-orders
915
929
  * @param {string} symbol unified market symbol
916
930
  * @param {int} [since] the earliest time in ms to fetch open orders for
917
931
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -928,6 +942,7 @@ class idex extends idex$1 {
928
942
  * @method
929
943
  * @name idex#fetchClosedOrders
930
944
  * @description fetches information on multiple closed orders made by the user
945
+ * @see https://api-docs-v3.idex.io/#get-orders
931
946
  * @param {string} symbol unified market symbol of the market orders were made in
932
947
  * @param {int} [since] the earliest time in ms to fetch orders for
933
948
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1139,16 +1154,20 @@ class idex extends idex$1 {
1139
1154
  * @method
1140
1155
  * @name idex#createOrder
1141
1156
  * @description create a trade order, https://docs.idex.io/#create-order
1157
+ * @see https://api-docs-v3.idex.io/#create-order
1142
1158
  * @param {string} symbol unified symbol of the market to create an order in
1143
1159
  * @param {string} type 'market' or 'limit'
1144
1160
  * @param {string} side 'buy' or 'sell'
1145
1161
  * @param {float} amount how much of currency you want to trade in units of base currency
1146
1162
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1147
1163
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1164
+ * @param {bool} [params.test] set to true to test an order, no order will be created but the request will be validated
1148
1165
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1149
1166
  */
1150
1167
  this.checkRequiredCredentials();
1151
1168
  await this.loadMarkets();
1169
+ const testOrder = this.safeBool(params, 'test', false);
1170
+ params = this.omit(params, 'test');
1152
1171
  const market = this.market(symbol);
1153
1172
  const nonce = this.uuidv1();
1154
1173
  let typeEnum = undefined;
@@ -1329,7 +1348,13 @@ class idex extends idex$1 {
1329
1348
  // "avgExecutionPrice": "0.09905990"
1330
1349
  // }
1331
1350
  // we don't use extend here because it is a signed endpoint
1332
- const response = await this.privatePostOrders(request);
1351
+ let response = undefined;
1352
+ if (testOrder) {
1353
+ response = await this.privatePostOrdersTest(request);
1354
+ }
1355
+ else {
1356
+ response = await this.privatePostOrders(request);
1357
+ }
1333
1358
  return this.parseOrder(response, market);
1334
1359
  }
1335
1360
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -1337,6 +1362,7 @@ class idex extends idex$1 {
1337
1362
  * @method
1338
1363
  * @name idex#withdraw
1339
1364
  * @description make a withdrawal
1365
+ * @see https://api-docs-v3.idex.io/#withdraw-funds
1340
1366
  * @param {string} code unified currency code
1341
1367
  * @param {float} amount the amount to withdraw
1342
1368
  * @param {string} address the address to withdraw to
@@ -1390,6 +1416,7 @@ class idex extends idex$1 {
1390
1416
  * @method
1391
1417
  * @name idex#cancelAllOrders
1392
1418
  * @description cancel all open orders
1419
+ * @see https://api-docs-v3.idex.io/#cancel-order
1393
1420
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1394
1421
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1395
1422
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1429,6 +1456,7 @@ class idex extends idex$1 {
1429
1456
  * @method
1430
1457
  * @name idex#cancelOrder
1431
1458
  * @description cancels an open order
1459
+ * @see https://api-docs-v3.idex.io/#cancel-order
1432
1460
  * @param {string} id order id
1433
1461
  * @param {string} symbol unified symbol of the market the order was made in
1434
1462
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1480,6 +1508,7 @@ class idex extends idex$1 {
1480
1508
  * @method
1481
1509
  * @name idex#fetchDeposit
1482
1510
  * @description fetch information on a deposit
1511
+ * @see https://api-docs-v3.idex.io/#get-deposits
1483
1512
  * @param {string} id deposit id
1484
1513
  * @param {string} code not used by idex fetchDeposit ()
1485
1514
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1500,6 +1529,7 @@ class idex extends idex$1 {
1500
1529
  * @method
1501
1530
  * @name idex#fetchDeposits
1502
1531
  * @description fetch all deposits made to an account
1532
+ * @see https://api-docs-v3.idex.io/#get-deposits
1503
1533
  * @param {string} code unified currency code
1504
1534
  * @param {int} [since] the earliest time in ms to fetch deposits for
1505
1535
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -1511,11 +1541,30 @@ class idex extends idex$1 {
1511
1541
  }, params);
1512
1542
  return await this.fetchTransactionsHelper(code, since, limit, params);
1513
1543
  }
1544
+ async fetchStatus(params = {}) {
1545
+ /**
1546
+ * @method
1547
+ * @name idex#fetchStatus
1548
+ * @description the latest known information on the availability of the exchange API
1549
+ * @see https://api-docs-v3.idex.io/#get-ping
1550
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1551
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
1552
+ */
1553
+ const response = await this.publicGetPing(params);
1554
+ return {
1555
+ 'status': 'ok',
1556
+ 'updated': undefined,
1557
+ 'eta': undefined,
1558
+ 'url': undefined,
1559
+ 'info': response,
1560
+ };
1561
+ }
1514
1562
  async fetchTime(params = {}) {
1515
1563
  /**
1516
1564
  * @method
1517
1565
  * @name idex#fetchTime
1518
1566
  * @description fetches the current integer timestamp in milliseconds from the exchange server
1567
+ * @see https://api-docs-v3.idex.io/#get-time
1519
1568
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1520
1569
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
1521
1570
  */
@@ -1530,6 +1579,7 @@ class idex extends idex$1 {
1530
1579
  * @method
1531
1580
  * @name idex#fetchWithdrawal
1532
1581
  * @description fetch data on a currency withdrawal via the withdrawal id
1582
+ * @see https://api-docs-v3.idex.io/#get-withdrawals
1533
1583
  * @param {string} id withdrawal id
1534
1584
  * @param {string} code not used by idex.fetchWithdrawal
1535
1585
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1550,6 +1600,7 @@ class idex extends idex$1 {
1550
1600
  * @method
1551
1601
  * @name idex#fetchWithdrawals
1552
1602
  * @description fetch all withdrawals made from an account
1603
+ * @see https://api-docs-v3.idex.io/#get-withdrawals
1553
1604
  * @param {string} code unified currency code
1554
1605
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
1555
1606
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve