ccxt 4.3.61 → 4.3.63

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 (104) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/ace.js +34 -15
  5. package/dist/cjs/src/base/Exchange.js +8 -1
  6. package/dist/cjs/src/base/errors.js +8 -1
  7. package/dist/cjs/src/binance.js +50 -43
  8. package/dist/cjs/src/bingx.js +507 -184
  9. package/dist/cjs/src/bybit.js +1 -1
  10. package/dist/cjs/src/cryptocom.js +18 -2
  11. package/dist/cjs/src/mercado.js +5 -1
  12. package/dist/cjs/src/pro/alpaca.js +3 -3
  13. package/dist/cjs/src/pro/binance.js +60 -38
  14. package/dist/cjs/src/pro/bingx.js +2 -2
  15. package/dist/cjs/src/pro/bitfinex2.js +8 -5
  16. package/dist/cjs/src/pro/bitget.js +5 -2
  17. package/dist/cjs/src/pro/bitmex.js +1 -1
  18. package/dist/cjs/src/pro/bitopro.js +1 -1
  19. package/dist/cjs/src/pro/bitvavo.js +1 -1
  20. package/dist/cjs/src/pro/bybit.js +49 -23
  21. package/dist/cjs/src/pro/coinbaseexchange.js +2 -2
  22. package/dist/cjs/src/pro/coincheck.js +1 -1
  23. package/dist/cjs/src/pro/coinone.js +1 -1
  24. package/dist/cjs/src/pro/cryptocom.js +8 -2
  25. package/dist/cjs/src/pro/deribit.js +1 -1
  26. package/dist/cjs/src/pro/gate.js +8 -4
  27. package/dist/cjs/src/pro/hollaex.js +1 -1
  28. package/dist/cjs/src/pro/htx.js +6 -2
  29. package/dist/cjs/src/pro/hyperliquid.js +3 -3
  30. package/dist/cjs/src/pro/independentreserve.js +5 -3
  31. package/dist/cjs/src/pro/kraken.js +83 -5
  32. package/dist/cjs/src/pro/kucoin.js +1 -1
  33. package/dist/cjs/src/pro/mexc.js +1 -1
  34. package/dist/cjs/src/pro/okx.js +4 -4
  35. package/dist/cjs/src/pro/oxfun.js +1 -1
  36. package/dist/cjs/src/pro/phemex.js +1 -1
  37. package/dist/cjs/src/pro/poloniexfutures.js +5 -1
  38. package/dist/cjs/src/pro/upbit.js +1 -1
  39. package/dist/cjs/src/pro/vertex.js +2 -2
  40. package/dist/cjs/src/pro/whitebit.js +1 -1
  41. package/dist/cjs/src/pro/woo.js +1 -1
  42. package/dist/cjs/src/pro/woofipro.js +1 -1
  43. package/dist/cjs/src/tradeogre.js +1 -1
  44. package/dist/cjs/src/woo.js +313 -81
  45. package/dist/cjs/src/xt.js +1 -1
  46. package/js/ccxt.d.ts +3 -3
  47. package/js/ccxt.js +3 -3
  48. package/js/src/abstract/cryptocom.d.ts +11 -0
  49. package/js/src/abstract/woo.d.ts +3 -0
  50. package/js/src/ace.js +34 -15
  51. package/js/src/base/Exchange.d.ts +1 -0
  52. package/js/src/base/Exchange.js +8 -1
  53. package/js/src/base/errorHierarchy.d.ts +3 -1
  54. package/js/src/base/errorHierarchy.js +3 -1
  55. package/js/src/base/errors.d.ts +5 -1
  56. package/js/src/base/errors.js +8 -2
  57. package/js/src/base/ws/Client.d.ts +1 -1
  58. package/js/src/binance.js +50 -43
  59. package/js/src/bingx.d.ts +1 -0
  60. package/js/src/bingx.js +507 -184
  61. package/js/src/bybit.js +1 -1
  62. package/js/src/coinbaseinternational.d.ts +1 -1
  63. package/js/src/cryptocom.js +18 -2
  64. package/js/src/mercado.js +5 -1
  65. package/js/src/pro/alpaca.js +3 -3
  66. package/js/src/pro/binance.d.ts +1 -0
  67. package/js/src/pro/binance.js +61 -39
  68. package/js/src/pro/bingx.js +2 -2
  69. package/js/src/pro/bitfinex2.js +9 -6
  70. package/js/src/pro/bitget.js +6 -3
  71. package/js/src/pro/bitmex.js +1 -1
  72. package/js/src/pro/bitopro.js +1 -1
  73. package/js/src/pro/bitvavo.js +1 -1
  74. package/js/src/pro/bybit.d.ts +1 -0
  75. package/js/src/pro/bybit.js +49 -23
  76. package/js/src/pro/coinbaseexchange.js +2 -2
  77. package/js/src/pro/coincheck.js +1 -1
  78. package/js/src/pro/coinone.js +1 -1
  79. package/js/src/pro/cryptocom.js +9 -3
  80. package/js/src/pro/deribit.js +1 -1
  81. package/js/src/pro/gate.js +9 -5
  82. package/js/src/pro/hollaex.js +1 -1
  83. package/js/src/pro/htx.js +7 -3
  84. package/js/src/pro/hyperliquid.js +3 -3
  85. package/js/src/pro/independentreserve.js +6 -4
  86. package/js/src/pro/kraken.d.ts +3 -1
  87. package/js/src/pro/kraken.js +84 -6
  88. package/js/src/pro/kucoin.js +1 -1
  89. package/js/src/pro/mexc.js +1 -1
  90. package/js/src/pro/okx.js +5 -5
  91. package/js/src/pro/oxfun.js +1 -1
  92. package/js/src/pro/phemex.js +1 -1
  93. package/js/src/pro/poloniexfutures.js +6 -2
  94. package/js/src/pro/upbit.js +1 -1
  95. package/js/src/pro/vertex.js +2 -2
  96. package/js/src/pro/whitebit.js +1 -1
  97. package/js/src/pro/woo.js +1 -1
  98. package/js/src/pro/woofipro.js +1 -1
  99. package/js/src/tradeogre.js +1 -1
  100. package/js/src/woo.d.ts +5 -1
  101. package/js/src/woo.js +313 -81
  102. package/js/src/xt.d.ts +3 -3
  103. package/js/src/xt.js +1 -1
  104. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -191,7 +191,7 @@ var xt$1 = require('./src/pro/xt.js');
191
191
 
192
192
  //-----------------------------------------------------------------------------
193
193
  // this is updated by vss.js when building
194
- const version = '4.3.61';
194
+ const version = '4.3.63';
195
195
  Exchange["default"].ccxtVersion = version;
196
196
  const exchanges = {
197
197
  'ace': ace,
@@ -392,6 +392,7 @@ exports.BadResponse = errors.BadResponse;
392
392
  exports.BadSymbol = errors.BadSymbol;
393
393
  exports.BaseError = errors.BaseError;
394
394
  exports.CancelPending = errors.CancelPending;
395
+ exports.ChecksumError = errors.ChecksumError;
395
396
  exports.ContractUnavailable = errors.ContractUnavailable;
396
397
  exports.DDoSProtection = errors.DDoSProtection;
397
398
  exports.DuplicateOrderId = errors.DuplicateOrderId;
@@ -198,10 +198,23 @@ class ace extends ace$1 {
198
198
  return this.parseMarkets(response);
199
199
  }
200
200
  parseMarket(market) {
201
- const baseId = this.safeString(market, 'base');
202
- const base = this.safeCurrencyCode(baseId);
203
- const quoteId = this.safeString(market, 'quote');
204
- const quote = this.safeCurrencyCode(quoteId);
201
+ //
202
+ // {
203
+ // "symbol": "ADA/TWD",
204
+ // "base": "ADA",
205
+ // "baseCurrencyId": "122",
206
+ // "quote": "TWD",
207
+ // "quoteCurrencyId": "1",
208
+ // "basePrecision": "2",
209
+ // "quotePrecision": "3",
210
+ // "minLimitBaseAmount": "1.0",
211
+ // "maxLimitBaseAmount": "150000.0"
212
+ // }
213
+ //
214
+ const baseId = this.safeString(market, 'baseCurrencyId');
215
+ const base = this.safeCurrencyCode(this.safeString(market, 'base'));
216
+ const quoteId = this.safeString(market, 'quoteCurrencyId');
217
+ const quote = this.safeCurrencyCode(this.safeString(market, 'quote'));
205
218
  const symbol = base + '/' + quote;
206
219
  return {
207
220
  'id': this.safeString(market, 'symbol'),
@@ -301,7 +314,7 @@ class ace extends ace$1 {
301
314
  const market = this.market(symbol);
302
315
  const response = await this.publicGetOapiV2ListTradePrice(params);
303
316
  const marketId = market['id'];
304
- const ticker = this.safeValue(response, marketId, {});
317
+ const ticker = this.safeDict(response, marketId, {});
305
318
  //
306
319
  // {
307
320
  // "BTC/USDT":{
@@ -339,7 +352,7 @@ class ace extends ace$1 {
339
352
  for (let i = 0; i < pairs.length; i++) {
340
353
  const marketId = pairs[i];
341
354
  const market = this.safeMarket(marketId);
342
- const rawTicker = this.safeValue(response, marketId);
355
+ const rawTicker = this.safeDict(response, marketId);
343
356
  const ticker = this.parseTicker(rawTicker, market);
344
357
  tickers.push(ticker);
345
358
  }
@@ -462,7 +475,7 @@ class ace extends ace$1 {
462
475
  request['startTime'] = since;
463
476
  }
464
477
  const response = await this.privatePostV2KlineGetKline(this.extend(request, params));
465
- const data = this.safeValue(response, 'attachment', []);
478
+ const data = this.safeList(response, 'attachment', []);
466
479
  //
467
480
  // {
468
481
  // "attachment":[
@@ -544,9 +557,9 @@ class ace extends ace$1 {
544
557
  timestamp = timestamp - 28800000; // 8 hours
545
558
  }
546
559
  }
547
- const orderSide = this.safeNumber(order, 'buyOrSell');
560
+ const orderSide = this.safeString(order, 'buyOrSell');
548
561
  if (orderSide !== undefined) {
549
- side = (orderSide === 1) ? 'buy' : 'sell';
562
+ side = (orderSide === '1') ? 'buy' : 'sell';
550
563
  }
551
564
  amount = this.safeString(order, 'num');
552
565
  price = this.safeString(order, 'price');
@@ -555,9 +568,9 @@ class ace extends ace$1 {
555
568
  if (quoteId !== undefined && baseId !== undefined) {
556
569
  symbol = baseId + '/' + quoteId;
557
570
  }
558
- const orderType = this.safeNumber(order, 'type');
571
+ const orderType = this.safeString(order, 'type');
559
572
  if (orderType !== undefined) {
560
- type = (orderType === 1) ? 'limit' : 'market';
573
+ type = (orderType === '1') ? 'limit' : 'market';
561
574
  }
562
575
  filled = this.safeString(order, 'tradeNum');
563
576
  remaining = this.safeString(order, 'remainNum');
@@ -720,7 +733,7 @@ class ace extends ace$1 {
720
733
  request['size'] = limit;
721
734
  }
722
735
  const response = await this.privatePostV2OrderGetOrderList(this.extend(request, params));
723
- const orders = this.safeValue(response, 'attachment');
736
+ const orders = this.safeList(response, 'attachment');
724
737
  //
725
738
  // {
726
739
  // "attachment": [
@@ -883,7 +896,7 @@ class ace extends ace$1 {
883
896
  // "status": 200
884
897
  // }
885
898
  //
886
- const data = this.safeValue(response, 'attachment');
899
+ const data = this.safeDict(response, 'attachment');
887
900
  const trades = this.safeList(data, 'trades', []);
888
901
  return this.parseTrades(trades, market, since, limit);
889
902
  }
@@ -986,7 +999,7 @@ class ace extends ace$1 {
986
999
  */
987
1000
  await this.loadMarkets();
988
1001
  const response = await this.privatePostV2CoinCustomerAccount(params);
989
- const balances = this.safeValue(response, 'attachment', []);
1002
+ const balances = this.safeList(response, 'attachment', []);
990
1003
  //
991
1004
  // {
992
1005
  // "attachment":[
@@ -1021,7 +1034,13 @@ class ace extends ace$1 {
1021
1034
  }, params);
1022
1035
  const sortedData = this.keysort(data);
1023
1036
  const values = Object.values(sortedData);
1024
- auth += values.join('');
1037
+ const stringifiedValues = [];
1038
+ for (let i = 0; i < values.length; i++) {
1039
+ const value = values[i];
1040
+ const strValue = value.toString();
1041
+ stringifiedValues.push(strValue);
1042
+ }
1043
+ auth += stringifiedValues.join('');
1025
1044
  const signature = this.hash(this.encode(auth), sha256.sha256, 'hex');
1026
1045
  data['signKey'] = signature;
1027
1046
  headers = {
@@ -2199,6 +2199,9 @@ class Exchange {
2199
2199
  afterConstruct() {
2200
2200
  this.createNetworksByIdObject();
2201
2201
  }
2202
+ orderbookChecksumMessage(symbol) {
2203
+ return symbol + ' : ' + 'orderbook data checksum validation failed. You can reconnect by calling watchOrderBook again or you can mute the error by setting exchange.options["watchOrderBook"]["checksum"] = false';
2204
+ }
2202
2205
  createNetworksByIdObject() {
2203
2206
  // automatically generate network-id-to-code mappings
2204
2207
  const networkIdsToCodesGenerated = this.invertFlatStringDictionary(this.safeValue(this.options, 'networks', {})); // invert defined networks dictionary
@@ -6147,8 +6150,12 @@ class Exchange {
6147
6150
  return [request, params];
6148
6151
  }
6149
6152
  safeOpenInterest(interest, market = undefined) {
6153
+ let symbol = this.safeString(interest, 'symbol');
6154
+ if (symbol === undefined) {
6155
+ symbol = this.safeString(market, 'symbol');
6156
+ }
6150
6157
  return this.extend(interest, {
6151
- 'symbol': this.safeString(market, 'symbol'),
6158
+ 'symbol': symbol,
6152
6159
  'baseVolume': this.safeNumber(interest, 'baseVolume'),
6153
6160
  'quoteVolume': this.safeNumber(interest, 'quoteVolume'),
6154
6161
  'openInterestAmount': this.safeNumber(interest, 'openInterestAmount'),
@@ -201,6 +201,12 @@ class InvalidNonce extends NetworkError {
201
201
  this.name = 'InvalidNonce';
202
202
  }
203
203
  }
204
+ class ChecksumError extends InvalidNonce {
205
+ constructor(message) {
206
+ super(message);
207
+ this.name = 'ChecksumError';
208
+ }
209
+ }
204
210
  class RequestTimeout extends NetworkError {
205
211
  constructor(message) {
206
212
  super(message);
@@ -225,7 +231,7 @@ class CancelPending extends OperationFailed {
225
231
  this.name = 'CancelPending';
226
232
  }
227
233
  }
228
- var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, BadResponse, NullResponse, CancelPending };
234
+ var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending };
229
235
 
230
236
  exports.AccountNotEnabled = AccountNotEnabled;
231
237
  exports.AccountSuspended = AccountSuspended;
@@ -237,6 +243,7 @@ exports.BadResponse = BadResponse;
237
243
  exports.BadSymbol = BadSymbol;
238
244
  exports.BaseError = BaseError;
239
245
  exports.CancelPending = CancelPending;
246
+ exports.ChecksumError = ChecksumError;
240
247
  exports.ContractUnavailable = ContractUnavailable;
241
248
  exports.DDoSProtection = DDoSProtection;
242
249
  exports.DuplicateOrderId = DuplicateOrderId;
@@ -813,7 +813,7 @@ class binance extends binance$1 {
813
813
  'forceOrders': { 'cost': 20, 'noSymbol': 50 },
814
814
  'allOrders': 5,
815
815
  'openOrder': 1,
816
- 'openOrders': 1,
816
+ 'openOrders': { 'cost': 1, 'noSymbol': 40 },
817
817
  'order': 1,
818
818
  'account': 5,
819
819
  'balance': 5,
@@ -1005,18 +1005,18 @@ class binance extends binance$1 {
1005
1005
  'ping': 1,
1006
1006
  'um/order': 1,
1007
1007
  'um/openOrder': 1,
1008
- 'um/openOrders': 1,
1008
+ 'um/openOrders': { 'cost': 1, 'noSymbol': 40 },
1009
1009
  'um/allOrders': 5,
1010
1010
  'cm/order': 1,
1011
1011
  'cm/openOrder': 1,
1012
- 'cm/openOrders': 1,
1012
+ 'cm/openOrders': { 'cost': 1, 'noSymbol': 40 },
1013
1013
  'cm/allOrders': 20,
1014
1014
  'um/conditional/openOrder': 1,
1015
- 'um/conditional/openOrders': 40,
1015
+ 'um/conditional/openOrders': { 'cost': 1, 'noSymbol': 40 },
1016
1016
  'um/conditional/orderHistory': 1,
1017
1017
  'um/conditional/allOrders': 40,
1018
1018
  'cm/conditional/openOrder': 1,
1019
- 'cm/conditional/openOrders': 40,
1019
+ 'cm/conditional/openOrders': { 'cost': 1, 'noSymbol': 40 },
1020
1020
  'cm/conditional/orderHistory': 1,
1021
1021
  'cm/conditional/allOrders': 40,
1022
1022
  'margin/order': 5,
@@ -6580,10 +6580,7 @@ class binance extends binance$1 {
6580
6580
  type = this.safeString(params, 'type', marketType);
6581
6581
  }
6582
6582
  else if (this.options['warnOnFetchOpenOrdersWithoutSymbol']) {
6583
- const symbols = this.symbols;
6584
- const numSymbols = symbols.length;
6585
- const fetchOpenOrdersRateLimit = this.parseToInt(numSymbols / 2);
6586
- throw new errors.ExchangeError(this.id + ' fetchOpenOrders() WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString() + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.');
6583
+ throw new errors.ExchangeError(this.id + ' fetchOpenOrders() WARNING: fetching open orders without specifying a symbol has stricter rate limits (10 times more for spot, 40 times more for other markets) compared to requesting with symbol argument. To acknowledge this warning, set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.');
6587
6584
  }
6588
6585
  else {
6589
6586
  const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
@@ -9784,40 +9781,45 @@ class binance extends binance$1 {
9784
9781
  if (marginMode === 'cross') {
9785
9782
  // calculate collateral
9786
9783
  const precision = this.safeDict(market, 'precision', {});
9787
- if (linear) {
9788
- // walletBalance = (liquidationPrice * (±1 + mmp) ± entryPrice) * contracts
9789
- let onePlusMaintenanceMarginPercentageString = undefined;
9790
- let entryPriceSignString = entryPriceString;
9791
- if (side === 'short') {
9792
- onePlusMaintenanceMarginPercentageString = Precise["default"].stringAdd('1', maintenanceMarginPercentageString);
9793
- entryPriceSignString = Precise["default"].stringMul('-1', entryPriceSignString);
9794
- }
9795
- else {
9796
- onePlusMaintenanceMarginPercentageString = Precise["default"].stringAdd('-1', maintenanceMarginPercentageString);
9797
- }
9798
- const inner = Precise["default"].stringMul(liquidationPriceString, onePlusMaintenanceMarginPercentageString);
9799
- const leftSide = Precise["default"].stringAdd(inner, entryPriceSignString);
9800
- const quotePrecision = this.precisionFromString(this.safeString2(precision, 'quote', 'price'));
9801
- if (quotePrecision !== undefined) {
9802
- collateralString = Precise["default"].stringDiv(Precise["default"].stringMul(leftSide, contractsAbs), '1', quotePrecision);
9803
- }
9804
- }
9805
- else {
9806
- // walletBalance = (contracts * contractSize) * (±1/entryPrice - (±1 - mmp) / liquidationPrice)
9807
- let onePlusMaintenanceMarginPercentageString = undefined;
9808
- let entryPriceSignString = entryPriceString;
9809
- if (side === 'short') {
9810
- onePlusMaintenanceMarginPercentageString = Precise["default"].stringSub('1', maintenanceMarginPercentageString);
9784
+ const basePrecisionValue = this.safeString(precision, 'base');
9785
+ const quotePrecisionValue = this.safeString2(precision, 'quote', 'price');
9786
+ const precisionIsUndefined = (basePrecisionValue === undefined) && (quotePrecisionValue === undefined);
9787
+ if (!precisionIsUndefined) {
9788
+ if (linear) {
9789
+ // walletBalance = (liquidationPrice * (±1 + mmp) ± entryPrice) * contracts
9790
+ let onePlusMaintenanceMarginPercentageString = undefined;
9791
+ let entryPriceSignString = entryPriceString;
9792
+ if (side === 'short') {
9793
+ onePlusMaintenanceMarginPercentageString = Precise["default"].stringAdd('1', maintenanceMarginPercentageString);
9794
+ entryPriceSignString = Precise["default"].stringMul('-1', entryPriceSignString);
9795
+ }
9796
+ else {
9797
+ onePlusMaintenanceMarginPercentageString = Precise["default"].stringAdd('-1', maintenanceMarginPercentageString);
9798
+ }
9799
+ const inner = Precise["default"].stringMul(liquidationPriceString, onePlusMaintenanceMarginPercentageString);
9800
+ const leftSide = Precise["default"].stringAdd(inner, entryPriceSignString);
9801
+ const quotePrecision = this.precisionFromString(this.safeString2(precision, 'quote', 'price'));
9802
+ if (quotePrecision !== undefined) {
9803
+ collateralString = Precise["default"].stringDiv(Precise["default"].stringMul(leftSide, contractsAbs), '1', quotePrecision);
9804
+ }
9811
9805
  }
9812
9806
  else {
9813
- onePlusMaintenanceMarginPercentageString = Precise["default"].stringSub('-1', maintenanceMarginPercentageString);
9814
- entryPriceSignString = Precise["default"].stringMul('-1', entryPriceSignString);
9815
- }
9816
- const leftSide = Precise["default"].stringMul(contractsAbs, contractSizeString);
9817
- const rightSide = Precise["default"].stringSub(Precise["default"].stringDiv('1', entryPriceSignString), Precise["default"].stringDiv(onePlusMaintenanceMarginPercentageString, liquidationPriceString));
9818
- const basePrecision = this.precisionFromString(this.safeString(precision, 'base'));
9819
- if (basePrecision !== undefined) {
9820
- collateralString = Precise["default"].stringDiv(Precise["default"].stringMul(leftSide, rightSide), '1', basePrecision);
9807
+ // walletBalance = (contracts * contractSize) * (±1/entryPrice -1 - mmp) / liquidationPrice)
9808
+ let onePlusMaintenanceMarginPercentageString = undefined;
9809
+ let entryPriceSignString = entryPriceString;
9810
+ if (side === 'short') {
9811
+ onePlusMaintenanceMarginPercentageString = Precise["default"].stringSub('1', maintenanceMarginPercentageString);
9812
+ }
9813
+ else {
9814
+ onePlusMaintenanceMarginPercentageString = Precise["default"].stringSub('-1', maintenanceMarginPercentageString);
9815
+ entryPriceSignString = Precise["default"].stringMul('-1', entryPriceSignString);
9816
+ }
9817
+ const leftSide = Precise["default"].stringMul(contractsAbs, contractSizeString);
9818
+ const rightSide = Precise["default"].stringSub(Precise["default"].stringDiv('1', entryPriceSignString), Precise["default"].stringDiv(onePlusMaintenanceMarginPercentageString, liquidationPriceString));
9819
+ const basePrecision = this.precisionFromString(this.safeString(precision, 'base'));
9820
+ if (basePrecision !== undefined) {
9821
+ collateralString = Precise["default"].stringDiv(Precise["default"].stringMul(leftSide, rightSide), '1', basePrecision);
9822
+ }
9821
9823
  }
9822
9824
  }
9823
9825
  }
@@ -10449,9 +10451,10 @@ class binance extends binance$1 {
10449
10451
  //
10450
10452
  const result = [];
10451
10453
  for (let i = 0; i < response.length; i++) {
10452
- const parsed = this.parsePositionRisk(response[i]);
10453
- const entryPrice = this.safeString(parsed, 'entryPrice');
10454
+ const rawPosition = response[i];
10455
+ const entryPrice = this.safeString(rawPosition, 'entryPrice');
10454
10456
  if ((entryPrice !== '0') && (entryPrice !== '0.0') && (entryPrice !== '0.00000000')) {
10457
+ const parsed = this.parsePositionRisk(response[i]);
10455
10458
  result.push(parsed);
10456
10459
  }
10457
10460
  }
@@ -12172,6 +12175,9 @@ class binance extends binance$1 {
12172
12175
  const request = {};
12173
12176
  if (market['option']) {
12174
12177
  request['underlyingAsset'] = market['baseId'];
12178
+ if (market['expiry'] === undefined) {
12179
+ throw new errors.NotSupported(this.id + ' fetchOpenInterest does not support ' + symbol);
12180
+ }
12175
12181
  request['expiration'] = this.yymmdd(market['expiry']);
12176
12182
  }
12177
12183
  else {
@@ -12218,6 +12224,7 @@ class binance extends binance$1 {
12218
12224
  // ]
12219
12225
  //
12220
12226
  if (market['option']) {
12227
+ symbol = market['symbol'];
12221
12228
  const result = this.parseOpenInterests(response, market);
12222
12229
  for (let i = 0; i < result.length; i++) {
12223
12230
  const item = result[i];