ccxt 4.5.35 → 4.5.36

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 (42) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +4 -4
  5. package/dist/cjs/src/base/functions/generic.js +27 -10
  6. package/dist/cjs/src/base/functions/time.js +0 -2
  7. package/dist/cjs/src/base/functions.js +0 -1
  8. package/dist/cjs/src/bybit.js +9 -4
  9. package/dist/cjs/src/coinbase.js +18 -7
  10. package/dist/cjs/src/coinex.js +2 -0
  11. package/dist/cjs/src/krakenfutures.js +1 -1
  12. package/dist/cjs/src/pro/aster.js +27 -24
  13. package/dist/cjs/src/pro/binance.js +9 -12
  14. package/dist/cjs/src/pro/bitmex.js +5 -8
  15. package/dist/cjs/src/pro/bybit.js +8 -12
  16. package/dist/cjs/src/pro/bydfi.js +20 -43
  17. package/dist/cjs/src/pro/gate.js +7 -8
  18. package/dist/cjs/src/pro/okx.js +8 -12
  19. package/dist/cjs/src/woo.js +1 -1
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/coinex.d.ts +2 -0
  23. package/js/src/base/Exchange.d.ts +4 -4
  24. package/js/src/base/Exchange.js +4 -4
  25. package/js/src/base/functions/generic.d.ts +1 -1
  26. package/js/src/base/functions/generic.js +28 -11
  27. package/js/src/base/functions/time.d.ts +1 -2
  28. package/js/src/base/functions/time.js +1 -2
  29. package/js/src/bybit.js +9 -4
  30. package/js/src/coinbase.d.ts +2 -0
  31. package/js/src/coinbase.js +18 -7
  32. package/js/src/coinex.js +2 -0
  33. package/js/src/krakenfutures.js +1 -1
  34. package/js/src/pro/aster.js +27 -24
  35. package/js/src/pro/binance.js +9 -12
  36. package/js/src/pro/bitmex.js +5 -8
  37. package/js/src/pro/bybit.js +8 -12
  38. package/js/src/pro/bydfi.js +20 -43
  39. package/js/src/pro/gate.js +7 -8
  40. package/js/src/pro/okx.js +8 -12
  41. package/js/src/woo.js +1 -1
  42. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -200,7 +200,7 @@ var xt$1 = require('./src/pro/xt.js');
200
200
 
201
201
  //-----------------------------------------------------------------------------
202
202
  // this is updated by vss.js when building
203
- const version = '4.5.35';
203
+ const version = '4.5.36';
204
204
  Exchange["default"].ccxtVersion = version;
205
205
  const exchanges = {
206
206
  'alp': alp["default"],
@@ -118,7 +118,7 @@ class Exchange {
118
118
  this.verbose = false;
119
119
  this.twofa = undefined; // two-factor authentication (2-FA)
120
120
  this.balance = {};
121
- this.liquidations = {};
121
+ this.liquidations = undefined;
122
122
  this.orderbooks = {};
123
123
  this.tickers = {};
124
124
  this.fundingRates = {};
@@ -126,7 +126,7 @@ class Exchange {
126
126
  this.orders = undefined;
127
127
  this.triggerOrders = undefined;
128
128
  this.transactions = {};
129
- this.myLiquidations = {};
129
+ this.myLiquidations = undefined;
130
130
  this.requiresWeb3 = false;
131
131
  this.requiresEddsa = false;
132
132
  this.precision = undefined;
@@ -336,12 +336,12 @@ class Exchange {
336
336
  this.bidsasks = {};
337
337
  this.orderbooks = {};
338
338
  this.tickers = {};
339
- this.liquidations = {};
339
+ this.liquidations = undefined;
340
340
  this.orders = undefined;
341
341
  this.trades = {};
342
342
  this.transactions = {};
343
343
  this.ohlcvs = {};
344
- this.myLiquidations = {};
344
+ this.myLiquidations = undefined;
345
345
  this.myTrades = undefined;
346
346
  this.positions = undefined;
347
347
  // web3 and cryptography flags
@@ -141,22 +141,39 @@ const sum = (...xs) => {
141
141
  const ns = xs.filter(type.isNumber); // leave only numbers
142
142
  return (ns.length > 0) ? ns.reduce((a, b) => a + b, 0) : undefined;
143
143
  };
144
- const deepExtend = function deepExtend(...xs) {
145
- let out = undefined;
146
- for (const x of xs) {
147
- if (type.isDictionary(x)) {
148
- if (!type.isDictionary(out)) {
149
- out = {};
144
+ const deepExtend = function (...args) {
145
+ let result = null;
146
+ let resultIsObject = false;
147
+ for (const arg of args) {
148
+ if (arg !== null && typeof arg === 'object' && arg.constructor === Object) {
149
+ // This is a plain object (even if empty) so set the return type.
150
+ if (result === null || !resultIsObject) {
151
+ result = {};
152
+ resultIsObject = true;
150
153
  }
151
- for (const k in x) {
152
- out[k] = deepExtend(out[k], x[k]);
154
+ // Skip actual merging if object is empty.
155
+ if (Object.keys(arg).length === 0) {
156
+ continue;
157
+ }
158
+ for (const key in arg) {
159
+ const value = arg[key];
160
+ const current = result[key];
161
+ if (current !== null && typeof current === 'object' && current.constructor === Object &&
162
+ value !== null && typeof value === 'object' && value.constructor === Object) {
163
+ result[key] = deepExtend(current, value);
164
+ }
165
+ else {
166
+ result[key] = value;
167
+ }
153
168
  }
154
169
  }
155
170
  else {
156
- out = x;
171
+ // arg is null or other non-object.
172
+ result = arg;
173
+ resultIsObject = false;
157
174
  }
158
175
  }
159
- return out;
176
+ return result;
160
177
  };
161
178
  const merge = (target, ...args) => {
162
179
  // doesn't overwrite defined keys with undefined
@@ -119,7 +119,6 @@ const parseDate = (x) => {
119
119
  }
120
120
  return parse8601(x);
121
121
  };
122
- const rfc2616 = (timestamp = undefined) => new Date(timestamp).toUTCString();
123
122
  const mdy = (timestamp, infix = '-') => {
124
123
  infix = infix || '';
125
124
  const date = new Date(timestamp);
@@ -181,7 +180,6 @@ exports.milliseconds = milliseconds;
181
180
  exports.now = now;
182
181
  exports.parse8601 = parse8601;
183
182
  exports.parseDate = parseDate;
184
- exports.rfc2616 = rfc2616;
185
183
  exports.seconds = seconds;
186
184
  exports.setTimeout_safe = setTimeout_safe;
187
185
  exports.sleep = sleep;
@@ -142,7 +142,6 @@ exports.milliseconds = time.milliseconds;
142
142
  exports.now = time.now;
143
143
  exports.parse8601 = time.parse8601;
144
144
  exports.parseDate = time.parseDate;
145
- exports.rfc2616 = time.rfc2616;
146
145
  exports.seconds = time.seconds;
147
146
  exports.setTimeout_safe = time.setTimeout_safe;
148
147
  exports.sleep = time.sleep;
@@ -349,7 +349,7 @@ class bybit extends bybit$1["default"] {
349
349
  'v5/asset/coin-greeks': 1,
350
350
  'v5/account/fee-rate': 10,
351
351
  'v5/account/info': 5,
352
- 'v5/account/transaction-log': 1,
352
+ 'v5/account/transaction-log': 1.66,
353
353
  'v5/account/contract-transaction-log': 1,
354
354
  'v5/account/smp-group': 1,
355
355
  'v5/account/mmp-state': 5,
@@ -4186,11 +4186,16 @@ class bybit extends bybit$1["default"] {
4186
4186
  }
4187
4187
  }
4188
4188
  }
4189
- if (tpslModeSl !== tpslModeTp) {
4189
+ if (isTakeProfitOrder && isStopLossOrder && tpslModeSl !== tpslModeTp) {
4190
4190
  throw new errors.InvalidOrder(this.id + ' createOrder() requires both stopLoss and takeProfit to be full or partial when using as OCO combination');
4191
4191
  }
4192
- request['tpslMode'] = tpslModeSl; // same as tpslModeTp
4193
- params = this.omit(params, ['stopLossLimitPrice', 'takeProfitLimitPrice']);
4192
+ if (tpslModeSl !== undefined) {
4193
+ request['tpslMode'] = tpslModeSl;
4194
+ }
4195
+ else {
4196
+ request['tpslMode'] = tpslModeTp;
4197
+ }
4198
+ params = this.omit(params, ['stopLossLimitPrice', 'takeProfitLimitPrice', 'tradingStopEndpoint']);
4194
4199
  }
4195
4200
  }
4196
4201
  else {
@@ -2977,6 +2977,7 @@ class coinbase extends coinbase$1["default"] {
2977
2977
  * @param {string} [params.retail_portfolio_id] portfolio uid
2978
2978
  * @param {boolean} [params.is_max] Used in conjunction with tradable_balance to indicate the user wants to use their entire tradable balance
2979
2979
  * @param {string} [params.tradable_balance] amount of tradable balance
2980
+ * @param {float} [params.reduceOnly] set to true for closing a position or use closePosition
2980
2981
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
2981
2982
  */
2982
2983
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -2988,6 +2989,12 @@ class coinbase extends coinbase$1["default"] {
2988
2989
  'product_id': market['id'],
2989
2990
  'side': side.toUpperCase(),
2990
2991
  };
2992
+ const reduceOnly = this.safeBool(params, 'reduceOnly');
2993
+ if (reduceOnly) {
2994
+ params = this.omit(params, 'reduceOnly');
2995
+ params['amount'] = amount;
2996
+ return await this.closePosition(symbol, side, params);
2997
+ }
2991
2998
  const triggerPrice = this.safeNumberN(params, ['stopPrice', 'stop_price', 'triggerPrice']);
2992
2999
  const stopLossPrice = this.safeNumber(params, 'stopLossPrice');
2993
3000
  const takeProfitPrice = this.safeNumber(params, 'takeProfitPrice');
@@ -4101,6 +4108,7 @@ class coinbase extends coinbase$1["default"] {
4101
4108
  * @param {string} [tag] an optional tag for the withdrawal
4102
4109
  * @param {object} [params] extra parameters specific to the exchange API endpoint
4103
4110
  * @param {string} [params.network] the cryptocurrency network to use for the withdrawal using the lowercase name like bitcoin, ethereum, solana, etc.
4111
+ * @param {object} [params.travel_rule_data] some regions require travel rule information for crypto withdrawals, see the exchange docs for details https://docs.cdp.coinbase.com/coinbase-app/transfer-apis/travel-rule
4104
4112
  * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
4105
4113
  */
4106
4114
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -4108,6 +4116,12 @@ class coinbase extends coinbase$1["default"] {
4108
4116
  this.checkAddress(address);
4109
4117
  await this.loadMarkets();
4110
4118
  const currency = this.currency(code);
4119
+ const request = {
4120
+ 'type': 'send',
4121
+ 'to': address,
4122
+ 'amount': this.numberToString(amount),
4123
+ 'currency': currency['id'],
4124
+ };
4111
4125
  let accountId = this.safeString2(params, 'account_id', 'accountId');
4112
4126
  params = this.omit(params, ['account_id', 'accountId']);
4113
4127
  if (accountId === undefined) {
@@ -4118,14 +4132,11 @@ class coinbase extends coinbase$1["default"] {
4118
4132
  if (accountId === undefined) {
4119
4133
  throw new errors.ExchangeError(this.id + ' withdraw() could not find account id for ' + code);
4120
4134
  }
4135
+ request['account_id'] = accountId;
4136
+ }
4137
+ else {
4138
+ request['account_id'] = accountId;
4121
4139
  }
4122
- const request = {
4123
- 'account_id': accountId,
4124
- 'type': 'send',
4125
- 'to': address,
4126
- 'amount': amount,
4127
- 'currency': currency['id'],
4128
- };
4129
4140
  if (tag !== undefined) {
4130
4141
  request['destination_tag'] = tag;
4131
4142
  }
@@ -420,6 +420,8 @@ class coinex extends coinex$1["default"] {
420
420
  'futures/stop-order': 20,
421
421
  'futures/batch-order': 1,
422
422
  'futures/batch-stop-order': 1,
423
+ 'futures/cancel-position-stop-loss': 20,
424
+ 'futures/cancel-position-take-profit': 20,
423
425
  'futures/modify-order': 20,
424
426
  'futures/modify-stop-order': 20,
425
427
  'futures/batch-modify-order': 20,
@@ -2692,7 +2692,7 @@ class krakenfutures extends krakenfutures$1["default"] {
2692
2692
  for (let i = 0; i < marginLevels.length; i++) {
2693
2693
  const tier = marginLevels[i];
2694
2694
  const initialMargin = this.safeString(tier, 'initialMargin');
2695
- const minNotional = this.safeNumber(tier, 'numNonContractUnits');
2695
+ const minNotional = this.safeNumber2(tier, 'numNonContractUnits', 'contracts');
2696
2696
  if (i !== 0) {
2697
2697
  const tiersLength = tiers.length;
2698
2698
  const previousTier = tiers[tiersLength - 1];
@@ -1480,23 +1480,26 @@ class aster extends aster$1["default"] {
1480
1480
  // }
1481
1481
  //
1482
1482
  const messageHash = 'positions';
1483
+ if (this.positions === undefined) {
1484
+ this.positions = new Cache.ArrayCacheBySymbolBySide();
1485
+ }
1486
+ const cache = this.positions;
1487
+ const data = this.safeDict(message, 'a', {});
1488
+ const rawPositions = this.safeList(data, 'P', []);
1489
+ const newPositions = [];
1490
+ for (let i = 0; i < rawPositions.length; i++) {
1491
+ const rawPosition = rawPositions[i];
1492
+ const position = this.parseWsPosition(rawPosition);
1493
+ const timestamp = this.safeInteger(message, 'E');
1494
+ position['timestamp'] = timestamp;
1495
+ position['datetime'] = this.iso8601(timestamp);
1496
+ newPositions.push(position);
1497
+ cache.append(position);
1498
+ }
1483
1499
  const messageHashes = this.findMessageHashes(client, messageHash);
1484
1500
  if (!this.isEmpty(messageHashes)) {
1485
- if (this.positions === undefined) {
1486
- this.positions = new Cache.ArrayCacheBySymbolBySide();
1487
- }
1488
- const cache = this.positions;
1489
- const data = this.safeDict(message, 'a', {});
1490
- const rawPositions = this.safeList(data, 'P', []);
1491
- const newPositions = [];
1492
- for (let i = 0; i < rawPositions.length; i++) {
1493
- const rawPosition = rawPositions[i];
1494
- const position = this.parseWsPosition(rawPosition);
1495
- const timestamp = this.safeInteger(message, 'E');
1496
- position['timestamp'] = timestamp;
1497
- position['datetime'] = this.iso8601(timestamp);
1498
- newPositions.push(position);
1499
- cache.append(position);
1501
+ for (let i = 0; i < newPositions.length; i++) {
1502
+ const position = newPositions[i];
1500
1503
  const symbol = position['symbol'];
1501
1504
  const symbolMessageHash = messageHash + '::' + symbol;
1502
1505
  client.resolve(position, symbolMessageHash);
@@ -1788,18 +1791,18 @@ class aster extends aster$1["default"] {
1788
1791
  // }
1789
1792
  //
1790
1793
  const messageHash = 'orders';
1794
+ const market = this.getMarketFromOrder(client, message);
1795
+ if (this.orders === undefined) {
1796
+ const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
1797
+ this.orders = new Cache.ArrayCacheBySymbolById(limit);
1798
+ }
1799
+ const cache = this.orders;
1800
+ const parsed = this.parseWsOrder(message, market);
1801
+ const symbol = market['symbol'];
1802
+ cache.append(parsed);
1791
1803
  const messageHashes = this.findMessageHashes(client, messageHash);
1792
1804
  if (!this.isEmpty(messageHashes)) {
1793
- const market = this.getMarketFromOrder(client, message);
1794
- if (this.orders === undefined) {
1795
- const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
1796
- this.orders = new Cache.ArrayCacheBySymbolById(limit);
1797
- }
1798
- const cache = this.orders;
1799
- const parsed = this.parseWsOrder(message, market);
1800
- const symbol = market['symbol'];
1801
1805
  const symbolMessageHash = messageHash + '::' + symbol;
1802
- cache.append(parsed);
1803
1806
  client.resolve(cache, symbolMessageHash);
1804
1807
  client.resolve(cache, messageHash);
1805
1808
  }
@@ -351,13 +351,11 @@ class binance extends binance$1["default"] {
351
351
  const market = this.safeMarket(marketId, undefined, '', 'contract');
352
352
  const symbol = market['symbol'];
353
353
  const liquidation = this.parseWsLiquidation(rawLiquidation, market);
354
- let liquidations = this.safeValue(this.liquidations, symbol);
355
- if (liquidations === undefined) {
356
- const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
357
- liquidations = new Cache.ArrayCache(limit);
354
+ if (this.liquidations === undefined) {
355
+ this.liquidations = new Cache.ArrayCacheBySymbolBySide();
358
356
  }
359
- liquidations.append(liquidation);
360
- this.liquidations[symbol] = liquidations;
357
+ const cache = this.liquidations;
358
+ cache.append(liquidation);
361
359
  client.resolve([liquidation], 'liquidations');
362
360
  client.resolve([liquidation], 'liquidations::' + symbol);
363
361
  }
@@ -562,13 +560,12 @@ class binance extends binance$1["default"] {
562
560
  const market = this.safeMarket(marketId, undefined, undefined, 'swap');
563
561
  const symbol = this.safeSymbol(marketId, market);
564
562
  const liquidation = this.parseWsLiquidation(message, market);
565
- let myLiquidations = this.safeValue(this.myLiquidations, symbol);
566
- if (myLiquidations === undefined) {
567
- const limit = this.safeInteger(this.options, 'myLiquidationsLimit', 1000);
568
- myLiquidations = new Cache.ArrayCache(limit);
563
+ let cache = this.myLiquidations;
564
+ if (cache === undefined) {
565
+ cache = new Cache.ArrayCacheBySymbolBySide();
569
566
  }
570
- myLiquidations.append(liquidation);
571
- this.myLiquidations[symbol] = myLiquidations;
567
+ cache.append(liquidation);
568
+ this.myLiquidations = cache;
572
569
  client.resolve([liquidation], 'myLiquidations');
573
570
  client.resolve([liquidation], 'myLiquidations::' + symbol);
574
571
  }
@@ -439,17 +439,14 @@ class bitmex extends bitmex$1["default"] {
439
439
  //
440
440
  const rawLiquidations = this.safeValue(message, 'data', []);
441
441
  const newLiquidations = [];
442
+ if (this.liquidations === undefined) {
443
+ this.liquidations = new Cache.ArrayCacheBySymbolBySide();
444
+ }
445
+ const cache = this.liquidations;
442
446
  for (let i = 0; i < rawLiquidations.length; i++) {
443
447
  const rawLiquidation = rawLiquidations[i];
444
448
  const liquidation = this.parseLiquidation(rawLiquidation);
445
- const symbol = liquidation['symbol'];
446
- let liquidations = this.safeValue(this.liquidations, symbol);
447
- if (liquidations === undefined) {
448
- const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
449
- liquidations = new Cache.ArrayCache(limit);
450
- }
451
- liquidations.append(liquidation);
452
- this.liquidations[symbol] = liquidations;
449
+ cache.append(liquidation);
453
450
  newLiquidations.push(liquidation);
454
451
  }
455
452
  client.resolve(newLiquidations, 'liquidations');
@@ -1695,13 +1695,11 @@ class bybit extends bybit$1["default"] {
1695
1695
  const market = this.safeMarket(marketId, undefined, '', 'contract');
1696
1696
  const symbol = market['symbol'];
1697
1697
  const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1698
- let liquidations = this.safeValue(this.liquidations, symbol);
1699
- if (liquidations === undefined) {
1700
- const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1701
- liquidations = new Cache.ArrayCache(limit);
1698
+ if (this.liquidations === undefined) {
1699
+ this.liquidations = new Cache.ArrayCacheBySymbolBySide();
1702
1700
  }
1703
- liquidations.append(liquidation);
1704
- this.liquidations[symbol] = liquidations;
1701
+ const cache = this.liquidations;
1702
+ cache.append(liquidation);
1705
1703
  client.resolve([liquidation], 'liquidations');
1706
1704
  client.resolve([liquidation], 'liquidations::' + symbol);
1707
1705
  }
@@ -1712,13 +1710,11 @@ class bybit extends bybit$1["default"] {
1712
1710
  const market = this.safeMarket(marketId, undefined, '', 'contract');
1713
1711
  const symbol = market['symbol'];
1714
1712
  const liquidation = this.parseWsLiquidation(rawLiquidation, market);
1715
- let liquidations = this.safeValue(this.liquidations, symbol);
1716
- if (liquidations === undefined) {
1717
- const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1718
- liquidations = new Cache.ArrayCache(limit);
1713
+ if (this.liquidations === undefined) {
1714
+ this.liquidations = new Cache.ArrayCacheBySymbolBySide();
1719
1715
  }
1720
- liquidations.append(liquidation);
1721
- this.liquidations[symbol] = liquidations;
1716
+ const cache = this.liquidations;
1717
+ cache.append(liquidation);
1722
1718
  client.resolve([liquidation], 'liquidations');
1723
1719
  client.resolve([liquidation], 'liquidations::' + symbol);
1724
1720
  }
@@ -617,30 +617,19 @@ class bydfi extends bydfi$1["default"] {
617
617
  const marketId = this.safeString(rawOrder, 's');
618
618
  const market = this.safeMarket(marketId);
619
619
  const symbol = market['symbol'];
620
- let match = false;
621
620
  const messageHash = 'orders';
622
621
  const symbolMessageHash = messageHash + '::' + symbol;
623
- const messageHashes = this.findMessageHashes(client, messageHash);
624
- for (let i = 0; i < messageHashes.length; i++) {
625
- const hash = messageHashes[i];
626
- if (hash === symbolMessageHash || hash === messageHash) {
627
- match = true;
628
- break;
629
- }
630
- }
631
- if (match) {
632
- if (this.orders === undefined) {
633
- const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
634
- this.orders = new Cache.ArrayCacheBySymbolById(limit);
635
- }
636
- const orders = this.orders;
637
- const order = this.parseWsOrder(rawOrder, market);
638
- const lastUpdateTimestamp = this.safeInteger(message, 'T');
639
- order['lastUpdateTimestamp'] = lastUpdateTimestamp;
640
- orders.append(order);
641
- client.resolve(orders, messageHash);
642
- client.resolve(orders, symbolMessageHash);
622
+ if (this.orders === undefined) {
623
+ const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
624
+ this.orders = new Cache.ArrayCacheBySymbolById(limit);
643
625
  }
626
+ const orders = this.orders;
627
+ const order = this.parseWsOrder(rawOrder, market);
628
+ const lastUpdateTimestamp = this.safeInteger(message, 'T');
629
+ order['lastUpdateTimestamp'] = lastUpdateTimestamp;
630
+ orders.append(order);
631
+ client.resolve(orders, messageHash);
632
+ client.resolve(orders, symbolMessageHash);
644
633
  }
645
634
  parseWsOrder(order, market = undefined) {
646
635
  //
@@ -786,29 +775,17 @@ class bydfi extends bydfi$1["default"] {
786
775
  const symbol = market['symbol'];
787
776
  const messageHash = 'positions';
788
777
  const symbolMessageHash = messageHash + '::' + symbol;
789
- const messageHashes = this.findMessageHashes(client, messageHash);
790
- let match = false;
791
- for (let i = 0; i < messageHashes.length; i++) {
792
- const hash = messageHashes[i];
793
- if (hash === symbolMessageHash || hash === messageHash) {
794
- match = true;
795
- break;
796
- }
797
- }
798
- if (match) {
799
- if (this.positions === undefined) {
800
- this.positions = new Cache.ArrayCacheBySymbolBySide();
801
- }
802
- const cache = this.positions;
803
- const parsedPosition = this.parseWsPosition(rawPosition, market);
804
- const timestamp = this.safeInteger(message, 'T');
805
- parsedPosition['timestamp'] = timestamp;
806
- parsedPosition['datetime'] = this.iso8601(timestamp);
807
- cache.append(parsedPosition);
808
- const symbolSpecificMessageHash = messageHash + ':' + parsedPosition['symbol'];
809
- client.resolve([parsedPosition], messageHash);
810
- client.resolve([parsedPosition], symbolSpecificMessageHash);
778
+ if (this.positions === undefined) {
779
+ this.positions = new Cache.ArrayCacheBySymbolBySide();
811
780
  }
781
+ const cache = this.positions;
782
+ const parsedPosition = this.parseWsPosition(rawPosition, market);
783
+ const timestamp = this.safeInteger(message, 'T');
784
+ parsedPosition['timestamp'] = timestamp;
785
+ parsedPosition['datetime'] = this.iso8601(timestamp);
786
+ cache.append(parsedPosition);
787
+ client.resolve([parsedPosition], messageHash);
788
+ client.resolve([parsedPosition], symbolMessageHash);
812
789
  }
813
790
  parseWsPosition(position, market = undefined) {
814
791
  //
@@ -1523,18 +1523,17 @@ class gate extends gate$1["default"] {
1523
1523
  //
1524
1524
  const rawLiquidations = this.safeList(message, 'result', []);
1525
1525
  const newLiquidations = [];
1526
+ if (this.liquidations === undefined) {
1527
+ this.liquidations = new Cache.ArrayCacheBySymbolBySide();
1528
+ }
1529
+ const cache = this.liquidations;
1526
1530
  for (let i = 0; i < rawLiquidations.length; i++) {
1527
1531
  const rawLiquidation = rawLiquidations[i];
1528
1532
  const liquidation = this.parseWsLiquidation(rawLiquidation);
1533
+ cache.append(liquidation);
1529
1534
  const symbol = this.safeString(liquidation, 'symbol');
1530
- let liquidations = this.safeValue(this.liquidations, symbol);
1531
- if (liquidations === undefined) {
1532
- const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
1533
- liquidations = new Cache.ArrayCache(limit);
1534
- }
1535
- liquidations.append(liquidation);
1536
- this.liquidations[symbol] = liquidations;
1537
- client.resolve(liquidations, 'myLiquidations::' + symbol);
1535
+ const symbolLiquidations = this.safeValue(cache, symbol, []);
1536
+ client.resolve(symbolLiquidations, 'myLiquidations::' + symbol);
1538
1537
  }
1539
1538
  client.resolve(newLiquidations, 'myLiquidations');
1540
1539
  }
@@ -757,13 +757,11 @@ class okx extends okx$1["default"] {
757
757
  const rawLiquidation = rawLiquidations[i];
758
758
  const liquidation = this.parseWsLiquidation(rawLiquidation);
759
759
  const symbol = this.safeString(liquidation, 'symbol');
760
- let liquidations = this.safeValue(this.liquidations, symbol);
761
- if (liquidations === undefined) {
762
- const limit = this.safeInteger(this.options, 'liquidationsLimit', 1000);
763
- liquidations = new Cache.ArrayCache(limit);
760
+ if (this.liquidations === undefined) {
761
+ this.liquidations = new Cache.ArrayCacheBySymbolBySide();
764
762
  }
765
- liquidations.append(liquidation);
766
- this.liquidations[symbol] = liquidations;
763
+ const cache = this.liquidations;
764
+ cache.append(liquidation);
767
765
  client.resolve([liquidation], 'liquidations');
768
766
  client.resolve([liquidation], 'liquidations::' + symbol);
769
767
  }
@@ -856,13 +854,11 @@ class okx extends okx$1["default"] {
856
854
  }
857
855
  const liquidation = this.parseWsMyLiquidation(rawLiquidation);
858
856
  const symbol = this.safeString(liquidation, 'symbol');
859
- let liquidations = this.safeValue(this.liquidations, symbol);
860
- if (liquidations === undefined) {
861
- const limit = this.safeInteger(this.options, 'myLiquidationsLimit', 1000);
862
- liquidations = new Cache.ArrayCache(limit);
857
+ if (this.liquidations === undefined) {
858
+ this.liquidations = new Cache.ArrayCacheBySymbolBySide();
863
859
  }
864
- liquidations.append(liquidation);
865
- this.liquidations[symbol] = liquidations;
860
+ const cache = this.liquidations;
861
+ cache.append(liquidation);
866
862
  client.resolve([liquidation], 'myLiquidations');
867
863
  client.resolve([liquidation], 'myLiquidations::' + symbol);
868
864
  }
@@ -2150,7 +2150,7 @@ class woo extends woo$1["default"] {
2150
2150
  request['limit'] = Math.min(limit, 1000);
2151
2151
  }
2152
2152
  if (since !== undefined) {
2153
- request['after'] = since;
2153
+ request['after'] = since - 1; // #27793
2154
2154
  }
2155
2155
  const until = this.safeInteger(params, 'until');
2156
2156
  params = this.omit(params, 'until');
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers, LongShortRatio, OrderBooks, OpenInterests, ConstructorArgs } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, RestrictedLocation, 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, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.5.34";
7
+ declare const version = "4.5.35";
8
8
  import alp from './src/alp.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import apex from './src/apex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, RestrictedLocation, 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, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.5.34';
41
+ const version = '4.5.35';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import alp from './src/alp.js';
@@ -235,6 +235,8 @@ interface Exchange {
235
235
  v2PrivatePostFuturesStopOrder(params?: {}): Promise<implicitReturnType>;
236
236
  v2PrivatePostFuturesBatchOrder(params?: {}): Promise<implicitReturnType>;
237
237
  v2PrivatePostFuturesBatchStopOrder(params?: {}): Promise<implicitReturnType>;
238
+ v2PrivatePostFuturesCancelPositionStopLoss(params?: {}): Promise<implicitReturnType>;
239
+ v2PrivatePostFuturesCancelPositionTakeProfit(params?: {}): Promise<implicitReturnType>;
238
240
  v2PrivatePostFuturesModifyOrder(params?: {}): Promise<implicitReturnType>;
239
241
  v2PrivatePostFuturesModifyStopOrder(params?: {}): Promise<implicitReturnType>;
240
242
  v2PrivatePostFuturesBatchModifyOrder(params?: {}): Promise<implicitReturnType>;
@@ -77,7 +77,7 @@ export default class Exchange {
77
77
  walletAddress: string;
78
78
  token: string;
79
79
  balance: any;
80
- liquidations: Dictionary<Liquidation>;
80
+ liquidations: any;
81
81
  orderbooks: Dictionary<Ob>;
82
82
  tickers: Dictionary<Ticker>;
83
83
  fundingRates: Dictionary<FundingRate>;
@@ -87,7 +87,7 @@ export default class Exchange {
87
87
  trades: Dictionary<ArrayCache>;
88
88
  transactions: Dictionary<Transaction>;
89
89
  ohlcvs: Dictionary<Dictionary<ArrayCacheByTimestamp>>;
90
- myLiquidations: Dictionary<Liquidation>;
90
+ myLiquidations: any;
91
91
  myTrades: ArrayCache;
92
92
  positions: any;
93
93
  urls: {
@@ -203,8 +203,8 @@ export default class Exchange {
203
203
  newUpdates: boolean;
204
204
  streaming: Dictionary<any>;
205
205
  sleep: (ms: any) => Promise<unknown>;
206
- deepExtend: (...xs: any) => any;
207
- deepExtendSafe: (...xs: any) => any;
206
+ deepExtend: (...args: any) => any;
207
+ deepExtendSafe: (...args: any) => any;
208
208
  isNode: boolean;
209
209
  keys: {
210
210
  (o: object): string[];