ccxt 4.3.83 → 4.3.85

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 (41) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +2 -2
  3. package/dist/cjs/ccxt.js +2 -1
  4. package/dist/cjs/src/base/errors.js +8 -1
  5. package/dist/cjs/src/binance.js +1 -1
  6. package/dist/cjs/src/bitfinex2.js +2 -2
  7. package/dist/cjs/src/bitmex.js +4 -0
  8. package/dist/cjs/src/bybit.js +15 -14
  9. package/dist/cjs/src/cryptocom.js +117 -2
  10. package/dist/cjs/src/kraken.js +34 -8
  11. package/dist/cjs/src/kucoinfutures.js +5 -0
  12. package/dist/cjs/src/mexc.js +2 -2
  13. package/dist/cjs/src/pro/binance.js +7 -2
  14. package/dist/cjs/src/pro/bitget.js +113 -4
  15. package/dist/cjs/src/pro/bitrue.js +1 -9
  16. package/dist/cjs/src/pro/gate.js +4 -4
  17. package/dist/cjs/src/pro/okx.js +25 -4
  18. package/js/ccxt.d.ts +3 -3
  19. package/js/ccxt.js +3 -3
  20. package/js/src/abstract/cryptocom.d.ts +2 -0
  21. package/js/src/abstract/kucoinfutures.d.ts +2 -0
  22. package/js/src/base/errorHierarchy.d.ts +1 -0
  23. package/js/src/base/errorHierarchy.js +1 -0
  24. package/js/src/base/errors.d.ts +5 -1
  25. package/js/src/base/errors.js +8 -2
  26. package/js/src/binance.js +1 -1
  27. package/js/src/bitfinex2.js +2 -2
  28. package/js/src/bitmex.js +4 -0
  29. package/js/src/bybit.js +16 -15
  30. package/js/src/cryptocom.d.ts +5 -1
  31. package/js/src/cryptocom.js +117 -2
  32. package/js/src/kraken.js +34 -8
  33. package/js/src/kucoinfutures.js +5 -0
  34. package/js/src/mexc.js +2 -2
  35. package/js/src/pro/binance.js +7 -2
  36. package/js/src/pro/bitget.d.ts +4 -0
  37. package/js/src/pro/bitget.js +113 -4
  38. package/js/src/pro/bitrue.js +1 -9
  39. package/js/src/pro/gate.js +4 -4
  40. package/js/src/pro/okx.js +25 -4
  41. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
194
194
 
195
195
  //-----------------------------------------------------------------------------
196
196
  // this is updated by vss.js when building
197
- const version = '4.3.83';
197
+ const version = '4.3.85';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'ace': ace,
@@ -410,6 +410,7 @@ exports.InvalidAddress = errors.InvalidAddress;
410
410
  exports.InvalidNonce = errors.InvalidNonce;
411
411
  exports.InvalidOrder = errors.InvalidOrder;
412
412
  exports.InvalidProxySettings = errors.InvalidProxySettings;
413
+ exports.ManualInteractionNeeded = errors.ManualInteractionNeeded;
413
414
  exports.MarginModeAlreadySet = errors.MarginModeAlreadySet;
414
415
  exports.MarketClosed = errors.MarketClosed;
415
416
  exports.NetworkError = errors.NetworkError;
@@ -81,6 +81,12 @@ class MarketClosed extends OperationRejected {
81
81
  this.name = 'MarketClosed';
82
82
  }
83
83
  }
84
+ class ManualInteractionNeeded extends OperationRejected {
85
+ constructor(message) {
86
+ super(message);
87
+ this.name = 'ManualInteractionNeeded';
88
+ }
89
+ }
84
90
  class InsufficientFunds extends ExchangeError {
85
91
  constructor(message) {
86
92
  super(message);
@@ -231,7 +237,7 @@ class CancelPending extends OperationFailed {
231
237
  this.name = 'CancelPending';
232
238
  }
233
239
  }
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 };
240
+ var errors = { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, 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 };
235
241
 
236
242
  exports.AccountNotEnabled = AccountNotEnabled;
237
243
  exports.AccountSuspended = AccountSuspended;
@@ -255,6 +261,7 @@ exports.InvalidAddress = InvalidAddress;
255
261
  exports.InvalidNonce = InvalidNonce;
256
262
  exports.InvalidOrder = InvalidOrder;
257
263
  exports.InvalidProxySettings = InvalidProxySettings;
264
+ exports.ManualInteractionNeeded = ManualInteractionNeeded;
258
265
  exports.MarginModeAlreadySet = MarginModeAlreadySet;
259
266
  exports.MarketClosed = MarketClosed;
260
267
  exports.NetworkError = NetworkError;
@@ -11406,7 +11406,7 @@ class binance extends binance$1 {
11406
11406
  if ((api === 'sapi') && (path === 'asset/dust')) {
11407
11407
  query = this.urlencodeWithArrayRepeat(extendedParams);
11408
11408
  }
11409
- else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path.indexOf('staking') >= 0)) {
11409
+ else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path.indexOf('staking') >= 0) || (path.indexOf('simple-earn') >= 0)) {
11410
11410
  if ((method === 'DELETE') && (path === 'batchOrders')) {
11411
11411
  const orderidlist = this.safeList(extendedParams, 'orderidlist', []);
11412
11412
  const origclientorderidlist = this.safeList(extendedParams, 'origclientorderidlist', []);
@@ -335,9 +335,9 @@ class bitfinex2 extends bitfinex2$1 {
335
335
  // convert 'EXCHANGE LIMIT' to lowercase 'limit'
336
336
  // everything else remains uppercase
337
337
  'exchangeTypes': {
338
- // 'MARKET': undefined,
338
+ 'MARKET': 'market',
339
339
  'EXCHANGE MARKET': 'market',
340
- // 'LIMIT': undefined,
340
+ 'LIMIT': 'limit',
341
341
  'EXCHANGE LIMIT': 'limit',
342
342
  // 'STOP': undefined,
343
343
  'EXCHANGE STOP': 'market',
@@ -5,6 +5,7 @@ var number = require('./base/functions/number.js');
5
5
  var errors = require('./base/errors.js');
6
6
  var Precise = require('./base/Precise.js');
7
7
  var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
8
+ var totp = require('./base/functions/totp.js');
8
9
 
9
10
  // ---------------------------------------------------------------------------
10
11
  // ---------------------------------------------------------------------------
@@ -2455,6 +2456,9 @@ class bitmex extends bitmex$1 {
2455
2456
  // 'otpToken': '123456', // requires if two-factor auth (OTP) is enabled
2456
2457
  // 'fee': 0.001, // bitcoin network fee
2457
2458
  };
2459
+ if (this.twofa !== undefined) {
2460
+ request['otpToken'] = totp.totp(this.twofa);
2461
+ }
2458
2462
  const response = await this.privatePostUserRequestWithdrawal(this.extend(request, params));
2459
2463
  //
2460
2464
  // {
@@ -753,8 +753,11 @@ class bybit extends bybit$1 {
753
753
  '140069': errors.PermissionDenied,
754
754
  '140070': errors.InvalidOrder,
755
755
  '170001': errors.ExchangeError,
756
- '170007': errors.RequestTimeout,
757
756
  '170005': errors.InvalidOrder,
757
+ '170007': errors.RequestTimeout,
758
+ '170010': errors.InvalidOrder,
759
+ '170011': errors.InvalidOrder,
760
+ '170019': errors.InvalidOrder,
758
761
  '170031': errors.ExchangeError,
759
762
  '170032': errors.ExchangeError,
760
763
  '170033': errors.InsufficientFunds,
@@ -767,6 +770,7 @@ class bybit extends bybit$1 {
767
770
  '170116': errors.InvalidOrder,
768
771
  '170117': errors.InvalidOrder,
769
772
  '170121': errors.InvalidOrder,
773
+ '170124': errors.InvalidOrder,
770
774
  '170130': errors.BadRequest,
771
775
  '170131': errors.InsufficientFunds,
772
776
  '170132': errors.InvalidOrder,
@@ -777,7 +781,6 @@ class bybit extends bybit$1 {
777
781
  '170137': errors.InvalidOrder,
778
782
  '170139': errors.InvalidOrder,
779
783
  '170140': errors.InvalidOrder,
780
- '170124': errors.InvalidOrder,
781
784
  '170141': errors.InvalidOrder,
782
785
  '170142': errors.InvalidOrder,
783
786
  '170143': errors.InvalidOrder,
@@ -802,6 +805,15 @@ class bybit extends bybit$1 {
802
805
  '170198': errors.InvalidOrder,
803
806
  '170199': errors.InvalidOrder,
804
807
  '170200': errors.InvalidOrder,
808
+ '170201': errors.PermissionDenied,
809
+ '170202': errors.InvalidOrder,
810
+ '170203': errors.InvalidOrder,
811
+ '170204': errors.InvalidOrder,
812
+ '170206': errors.InvalidOrder,
813
+ '170210': errors.InvalidOrder,
814
+ '170213': errors.OrderNotFound,
815
+ '170217': errors.InvalidOrder,
816
+ '170218': errors.InvalidOrder,
805
817
  '170221': errors.BadRequest,
806
818
  '170222': errors.RateLimitExceeded,
807
819
  '170223': errors.InsufficientFunds,
@@ -811,18 +823,7 @@ class bybit extends bybit$1 {
811
823
  '170228': errors.InvalidOrder,
812
824
  '170229': errors.InvalidOrder,
813
825
  '170234': errors.ExchangeError,
814
- '170210': errors.InvalidOrder,
815
- '170213': errors.OrderNotFound,
816
- '170217': errors.InvalidOrder,
817
- '170218': errors.InvalidOrder,
818
- '170010': errors.InvalidOrder,
819
- '170011': errors.InvalidOrder,
820
- '170019': errors.InvalidOrder,
821
- '170201': errors.PermissionDenied,
822
- '170202': errors.InvalidOrder,
823
- '170203': errors.InvalidOrder,
824
- '170204': errors.InvalidOrder,
825
- '170206': errors.InvalidOrder,
826
+ '170241': errors.ManualInteractionNeeded,
826
827
  '175000': errors.InvalidOrder,
827
828
  '175001': errors.InvalidOrder,
828
829
  '175002': errors.InvalidOrder,
@@ -91,8 +91,8 @@ class cryptocom extends cryptocom$1 {
91
91
  'fetchTickers': true,
92
92
  'fetchTime': false,
93
93
  'fetchTrades': true,
94
- 'fetchTradingFee': false,
95
- 'fetchTradingFees': false,
94
+ 'fetchTradingFee': true,
95
+ 'fetchTradingFees': true,
96
96
  'fetchTransactionFees': false,
97
97
  'fetchTransactions': false,
98
98
  'fetchTransfers': false,
@@ -193,6 +193,8 @@ class cryptocom extends cryptocom$1 {
193
193
  'private/get-accounts': 10 / 3,
194
194
  'private/get-withdrawal-history': 10 / 3,
195
195
  'private/get-deposit-history': 10 / 3,
196
+ 'private/get-fee-rate': 2,
197
+ 'private/get-instrument-fee-rate': 2,
196
198
  'private/staking/stake': 2,
197
199
  'private/staking/unstake': 2,
198
200
  'private/staking/get-staking-position': 2,
@@ -3019,6 +3021,119 @@ class cryptocom extends cryptocom$1 {
3019
3021
  const result = this.safeDict(response, 'result');
3020
3022
  return this.parseOrder(result, market);
3021
3023
  }
3024
+ async fetchTradingFee(symbol, params = {}) {
3025
+ /**
3026
+ * @method
3027
+ * @name cryptocom#fetchTradingFee
3028
+ * @description fetch the trading fees for a market
3029
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-instrument-fee-rate
3030
+ * @param {string} symbol unified market symbol
3031
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3032
+ * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
3033
+ */
3034
+ await this.loadMarkets();
3035
+ const market = this.market(symbol);
3036
+ const request = {
3037
+ 'instrument_name': market['id'],
3038
+ };
3039
+ const response = await this.v1PrivatePostPrivateGetInstrumentFeeRate(this.extend(request, params));
3040
+ //
3041
+ // {
3042
+ // "id": 1,
3043
+ // "code": 0,
3044
+ // "method": "private/staking/unstake",
3045
+ // "result": {
3046
+ // "staking_id": "1",
3047
+ // "instrument_name": "SOL.staked",
3048
+ // "status": "NEW",
3049
+ // "quantity": "1",
3050
+ // "underlying_inst_name": "SOL",
3051
+ // "reason": "NO_ERROR"
3052
+ // }
3053
+ // }
3054
+ //
3055
+ const data = this.safeDict(response, 'result', {});
3056
+ return this.parseTradingFee(data, market);
3057
+ }
3058
+ async fetchTradingFees(params = {}) {
3059
+ /**
3060
+ * @method
3061
+ * @name cryptocom#fetchTradingFees
3062
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-get-fee-rate
3063
+ * @description fetch the trading fees for multiple markets
3064
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3065
+ * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
3066
+ */
3067
+ await this.loadMarkets();
3068
+ const response = await this.v1PrivatePostPrivateGetFeeRate(params);
3069
+ //
3070
+ // {
3071
+ // "id": 1,
3072
+ // "method": "/private/get-fee-rate",
3073
+ // "code": 0,
3074
+ // "result": {
3075
+ // "spot_tier": "3",
3076
+ // "deriv_tier": "3",
3077
+ // "effective_spot_maker_rate_bps": "6.5",
3078
+ // "effective_spot_taker_rate_bps": "6.9",
3079
+ // "effective_deriv_maker_rate_bps": "1.1",
3080
+ // "effective_deriv_taker_rate_bps": "3"
3081
+ // }
3082
+ // }
3083
+ //
3084
+ const result = this.safeDict(response, 'result', {});
3085
+ return this.parseTradingFees(result);
3086
+ }
3087
+ parseTradingFees(response) {
3088
+ //
3089
+ // {
3090
+ // "spot_tier": "3",
3091
+ // "deriv_tier": "3",
3092
+ // "effective_spot_maker_rate_bps": "6.5",
3093
+ // "effective_spot_taker_rate_bps": "6.9",
3094
+ // "effective_deriv_maker_rate_bps": "1.1",
3095
+ // "effective_deriv_taker_rate_bps": "3"
3096
+ // }
3097
+ //
3098
+ const result = {};
3099
+ result['info'] = response;
3100
+ for (let i = 0; i < this.symbols.length; i++) {
3101
+ const symbol = this.symbols[i];
3102
+ const market = this.market(symbol);
3103
+ const isSwap = market['swap'];
3104
+ const takerFeeKey = isSwap ? 'effective_deriv_taker_rate_bps' : 'effective_spot_taker_rate_bps';
3105
+ const makerFeeKey = isSwap ? 'effective_deriv_maker_rate_bps' : 'effective_spot_maker_rate_bps';
3106
+ const tradingFee = {
3107
+ 'info': response,
3108
+ 'symbol': symbol,
3109
+ 'maker': this.parseNumber(Precise["default"].stringDiv(this.safeString(response, makerFeeKey), '10000')),
3110
+ 'taker': this.parseNumber(Precise["default"].stringDiv(this.safeString(response, takerFeeKey), '10000')),
3111
+ 'percentage': undefined,
3112
+ 'tierBased': undefined,
3113
+ };
3114
+ result[symbol] = tradingFee;
3115
+ }
3116
+ return result;
3117
+ }
3118
+ parseTradingFee(fee, market = undefined) {
3119
+ //
3120
+ // {
3121
+ // "instrument_name": "BTC_USD",
3122
+ // "effective_maker_rate_bps": "6.5",
3123
+ // "effective_taker_rate_bps": "6.9"
3124
+ // }
3125
+ //
3126
+ const marketId = this.safeString(fee, 'instrument_name');
3127
+ const symbol = this.safeSymbol(marketId, market);
3128
+ return {
3129
+ 'info': fee,
3130
+ 'symbol': symbol,
3131
+ 'maker': this.parseNumber(Precise["default"].stringDiv(this.safeString(fee, 'effective_maker_rate_bps'), '10000')),
3132
+ 'taker': this.parseNumber(Precise["default"].stringDiv(this.safeString(fee, 'effective_taker_rate_bps'), '10000')),
3133
+ 'percentage': undefined,
3134
+ 'tierBased': undefined,
3135
+ };
3136
+ }
3022
3137
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3023
3138
  const type = this.safeString(api, 0);
3024
3139
  const access = this.safeString(api, 1);
@@ -1208,6 +1208,26 @@ class kraken extends kraken$1 {
1208
1208
  // "misc": ''
1209
1209
  // }
1210
1210
  //
1211
+ // fetchMyTrades
1212
+ //
1213
+ // {
1214
+ // "ordertxid": "OSJVN7-A2AE-63WZV",
1215
+ // "postxid": "TBP7O6-PNXI-CONU",
1216
+ // "pair": "XXBTZUSD",
1217
+ // "time": 1710429248.3052235,
1218
+ // "type": "sell",
1219
+ // "ordertype": "liquidation market",
1220
+ // "price": "72026.50000",
1221
+ // "cost": "7.20265",
1222
+ // "fee": "0.01873",
1223
+ // "vol": "0.00010000",
1224
+ // "margin": "1.44053",
1225
+ // "leverage": "5",
1226
+ // "misc": "closing",
1227
+ // "trade_id": 68230622,
1228
+ // "maker": false
1229
+ // }
1230
+ //
1211
1231
  let timestamp = undefined;
1212
1232
  let side = undefined;
1213
1233
  let type = undefined;
@@ -1263,6 +1283,11 @@ class kraken extends kraken$1 {
1263
1283
  symbol = market['symbol'];
1264
1284
  }
1265
1285
  const cost = this.safeString(trade, 'cost');
1286
+ const maker = this.safeBool(trade, 'maker');
1287
+ let takerOrMaker = undefined;
1288
+ if (maker !== undefined) {
1289
+ takerOrMaker = maker ? 'maker' : 'taker';
1290
+ }
1266
1291
  return this.safeTrade({
1267
1292
  'id': id,
1268
1293
  'order': orderId,
@@ -1272,7 +1297,7 @@ class kraken extends kraken$1 {
1272
1297
  'symbol': symbol,
1273
1298
  'type': type,
1274
1299
  'side': side,
1275
- 'takerOrMaker': undefined,
1300
+ 'takerOrMaker': takerOrMaker,
1276
1301
  'price': price,
1277
1302
  'amount': amount,
1278
1303
  'cost': cost,
@@ -2128,7 +2153,10 @@ class kraken extends kraken$1 {
2128
2153
  // "fee": "0.000026",
2129
2154
  // "vol": "16.00000000",
2130
2155
  // "margin": "0.000000",
2156
+ // "leverage": "5",
2131
2157
  // "misc": ""
2158
+ // "trade_id": 68230622,
2159
+ // "maker": false
2132
2160
  // },
2133
2161
  // ...
2134
2162
  // },
@@ -2525,14 +2553,12 @@ class kraken extends kraken$1 {
2525
2553
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2526
2554
  */
2527
2555
  // https://www.kraken.com/en-us/help/api#deposit-status
2528
- if (code === undefined) {
2529
- throw new errors.ArgumentsRequired(this.id + ' fetchDeposits() requires a currency code argument');
2530
- }
2531
2556
  await this.loadMarkets();
2532
- const currency = this.currency(code);
2533
- const request = {
2534
- 'asset': currency['id'],
2535
- };
2557
+ const request = {};
2558
+ if (code !== undefined) {
2559
+ const currency = this.currency(code);
2560
+ request['asset'] = currency['id'];
2561
+ }
2536
2562
  if (since !== undefined) {
2537
2563
  request['start'] = since;
2538
2564
  }
@@ -124,6 +124,7 @@ class kucoinfutures extends kucoinfutures$1 {
124
124
  'contracts/{symbol}': 1,
125
125
  'contracts/risk-limit/{symbol}': 1,
126
126
  'ticker': 1,
127
+ 'allTickers': 1,
127
128
  'level2/snapshot': 1.33,
128
129
  'level2/depth{limit}': 1,
129
130
  'level2/message/query': 1,
@@ -167,6 +168,7 @@ class kucoinfutures extends kucoinfutures$1 {
167
168
  'trade-statistics': 1,
168
169
  'trade-fees': 1,
169
170
  'history-positions': 1,
171
+ 'getMaxOpenSize': 1,
170
172
  },
171
173
  'post': {
172
174
  'withdrawals': 1,
@@ -312,6 +314,9 @@ class kucoinfutures extends kucoinfutures$1 {
312
314
  // endpoint versions
313
315
  'versions': {
314
316
  'futuresPrivate': {
317
+ 'GET': {
318
+ 'getMaxOpenSize': 'v2',
319
+ },
315
320
  'POST': {
316
321
  'transfer-out': 'v2',
317
322
  },
@@ -1165,7 +1165,7 @@ class mexc extends mexc$1 {
1165
1165
  // "symbols": [
1166
1166
  // {
1167
1167
  // "symbol": "OGNUSDT",
1168
- // "status": "ENABLED",
1168
+ // "status": "1",
1169
1169
  // "baseAsset": "OGN",
1170
1170
  // "baseAssetPrecision": "2",
1171
1171
  // "quoteAsset": "USDT",
@@ -1210,7 +1210,7 @@ class mexc extends mexc$1 {
1210
1210
  const status = this.safeString(market, 'status');
1211
1211
  const isSpotTradingAllowed = this.safeValue(market, 'isSpotTradingAllowed');
1212
1212
  let active = false;
1213
- if ((status === 'ENABLED') && (isSpotTradingAllowed)) {
1213
+ if ((status === '1') && (isSpotTradingAllowed)) {
1214
1214
  active = true;
1215
1215
  }
1216
1216
  const isMarginTradingAllowed = this.safeValue(market, 'isMarginTradingAllowed');
@@ -230,7 +230,7 @@ class binance extends binance$1 {
230
230
  else {
231
231
  for (let i = 0; i < symbols.length; i++) {
232
232
  const market = this.market(symbols[i]);
233
- subscriptionHashes.push(market['id'] + '@forceOrder');
233
+ subscriptionHashes.push(market['lowercaseId'] + '@forceOrder');
234
234
  messageHashes.push('liquidations::' + symbols[i]);
235
235
  }
236
236
  streamHash += '::' + symbols.join(',');
@@ -1217,6 +1217,9 @@ class binance extends binance$1 {
1217
1217
  * @param {object} [params.timezone] if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
1218
1218
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1219
1219
  */
1220
+ await this.loadMarkets();
1221
+ const market = this.market(symbol);
1222
+ symbol = market['symbol'];
1220
1223
  params['callerMethodName'] = 'watchOHLCV';
1221
1224
  const result = await this.watchOHLCVForSymbols([[symbol, timeframe]], since, limit, params);
1222
1225
  return result[symbol][timeframe];
@@ -1267,7 +1270,7 @@ class binance extends binance$1 {
1267
1270
  const suffix = '@+08:00';
1268
1271
  const utcSuffix = shouldUseUTC8 ? suffix : '';
1269
1272
  rawHashes.push(marketId + '@' + klineType + '_' + interval + utcSuffix);
1270
- messageHashes.push('ohlcv::' + symbolString + '::' + timeframeString);
1273
+ messageHashes.push('ohlcv::' + market['symbol'] + '::' + timeframeString);
1271
1274
  }
1272
1275
  const url = this.urls['api']['ws'][type] + '/' + this.stream(type, 'multipleOHLCV');
1273
1276
  const requestId = this.requestId(url);
@@ -1543,6 +1546,8 @@ class binance extends binance$1 {
1543
1546
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1544
1547
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1545
1548
  */
1549
+ await this.loadMarkets();
1550
+ symbols = this.marketSymbols(symbols, undefined, true, false, true);
1546
1551
  const result = await this.watchMultiTickerHelper('watchBidsAsks', 'bookTicker', symbols, params);
1547
1552
  if (this.newUpdates) {
1548
1553
  return result;
@@ -439,6 +439,35 @@ class bitget extends bitget$1 {
439
439
  */
440
440
  return await this.watchOrderBookForSymbols([symbol], limit, params);
441
441
  }
442
+ async unWatchOrderBook(symbol, params = {}) {
443
+ /**
444
+ * @method
445
+ * @name bitget#unWatchOrderBook
446
+ * @description unsubscribe from the orderbook channel
447
+ * @see https://www.bitget.com/api-doc/spot/websocket/public/Depth-Channel
448
+ * @see https://www.bitget.com/api-doc/contract/websocket/public/Order-Book-Channel
449
+ * @param {string} symbol unified symbol of the market to fetch the order book for
450
+ * @param {int} [params.limit] orderbook limit, default is undefined
451
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
452
+ */
453
+ await this.loadMarkets();
454
+ const market = this.market(symbol);
455
+ const messageHash = 'unsubscribe:orderbook:' + market['symbol'];
456
+ let channel = 'books';
457
+ const limit = this.safeInteger(params, 'limit');
458
+ if ((limit === 1) || (limit === 5) || (limit === 15)) {
459
+ params = this.omit(params, 'limit');
460
+ channel += limit.toString();
461
+ }
462
+ let instType = undefined;
463
+ [instType, params] = this.getInstType(market, params);
464
+ const args = {
465
+ 'instType': instType,
466
+ 'channel': channel,
467
+ 'instId': market['id'],
468
+ };
469
+ return await this.unWatchPublic(messageHash, args, params);
470
+ }
442
471
  async watchOrderBookForSymbols(symbols, limit = undefined, params = {}) {
443
472
  /**
444
473
  * @method
@@ -562,10 +591,11 @@ class bitget extends bitget$1 {
562
591
  const calculatedChecksum = this.crc32(payload, true);
563
592
  const responseChecksum = this.safeInteger(rawOrderBook, 'checksum');
564
593
  if (calculatedChecksum !== responseChecksum) {
565
- delete client.subscriptions[messageHash];
566
- delete this.orderbooks[symbol];
567
- const error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
568
- client.reject(error, messageHash);
594
+ // if (messageHash in client.subscriptions) {
595
+ // // delete client.subscriptions[messageHash];
596
+ // // delete this.orderbooks[symbol];
597
+ // }
598
+ this.spawn(this.handleCheckSumError, client, symbol, messageHash);
569
599
  return;
570
600
  }
571
601
  }
@@ -578,6 +608,11 @@ class bitget extends bitget$1 {
578
608
  }
579
609
  client.resolve(this.orderbooks[symbol], messageHash);
580
610
  }
611
+ async handleCheckSumError(client, symbol, messageHash) {
612
+ await this.unWatchOrderBook(symbol);
613
+ const error = new errors.ChecksumError(this.id + ' ' + this.orderbookChecksumMessage(symbol));
614
+ client.reject(error, messageHash);
615
+ }
581
616
  handleDelta(bookside, delta) {
582
617
  const bidAsk = this.parseBidAsk(delta, 0, 1);
583
618
  // we store the string representations in the orderbook for checksum calculation
@@ -1624,6 +1659,15 @@ class bitget extends bitget$1 {
1624
1659
  const message = this.extend(request, params);
1625
1660
  return await this.watch(url, messageHash, message, messageHash);
1626
1661
  }
1662
+ async unWatchPublic(messageHash, args, params = {}) {
1663
+ const url = this.urls['api']['ws']['public'];
1664
+ const request = {
1665
+ 'op': 'unsubscribe',
1666
+ 'args': [args],
1667
+ };
1668
+ const message = this.extend(request, params);
1669
+ return await this.watch(url, messageHash, message, messageHash);
1670
+ }
1627
1671
  async watchPublicMultiple(messageHashes, argsArray, params = {}) {
1628
1672
  const url = this.urls['api']['ws']['public'];
1629
1673
  const request = {
@@ -1744,6 +1788,17 @@ class bitget extends bitget$1 {
1744
1788
  // "event": "subscribe",
1745
1789
  // "arg": { instType: 'SPOT', channel: "account", instId: "default" }
1746
1790
  // }
1791
+ // unsubscribe
1792
+ // {
1793
+ // "op":"unsubscribe",
1794
+ // "args":[
1795
+ // {
1796
+ // "instType":"USDT-FUTURES",
1797
+ // "channel":"ticker",
1798
+ // "instId":"BTCUSDT"
1799
+ // }
1800
+ // ]
1801
+ // }
1747
1802
  //
1748
1803
  if (this.handleErrorMessage(client, message)) {
1749
1804
  return;
@@ -1766,6 +1821,10 @@ class bitget extends bitget$1 {
1766
1821
  this.handleSubscriptionStatus(client, message);
1767
1822
  return;
1768
1823
  }
1824
+ if (event === 'unsubscribe') {
1825
+ this.handleUnSubscriptionStatus(client, message);
1826
+ return;
1827
+ }
1769
1828
  const methods = {
1770
1829
  'ticker': this.handleTicker,
1771
1830
  'trade': this.handleTrades,
@@ -1809,6 +1868,56 @@ class bitget extends bitget$1 {
1809
1868
  //
1810
1869
  return message;
1811
1870
  }
1871
+ handleUnSubscriptionStatus(client, message) {
1872
+ //
1873
+ // {
1874
+ // "op":"unsubscribe",
1875
+ // "args":[
1876
+ // {
1877
+ // "instType":"USDT-FUTURES",
1878
+ // "channel":"ticker",
1879
+ // "instId":"BTCUSDT"
1880
+ // },
1881
+ // {
1882
+ // "instType":"USDT-FUTURES",
1883
+ // "channel":"candle1m",
1884
+ // "instId":"BTCUSDT"
1885
+ // }
1886
+ // ]
1887
+ // }
1888
+ // or
1889
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"books","instId":"BTCUSDT"}}
1890
+ //
1891
+ let argsList = this.safeList(message, 'args');
1892
+ if (argsList === undefined) {
1893
+ argsList = [this.safeDict(message, 'arg', {})];
1894
+ }
1895
+ for (let i = 0; i < argsList.length; i++) {
1896
+ const arg = argsList[i];
1897
+ const channel = this.safeString(arg, 'channel');
1898
+ if (channel === 'books') {
1899
+ // for now only unWatchOrderBook is supporteod
1900
+ const instType = this.safeStringLower(arg, 'instType');
1901
+ const type = (instType === 'spot') ? 'spot' : 'contract';
1902
+ const instId = this.safeString(arg, 'instId');
1903
+ const market = this.safeMarket(instId, undefined, undefined, type);
1904
+ const symbol = market['symbol'];
1905
+ const messageHash = 'unsubscribe:orderbook:' + market['symbol'];
1906
+ const subMessageHash = 'orderbook:' + symbol;
1907
+ if (symbol in this.orderbooks) {
1908
+ delete this.orderbooks[symbol];
1909
+ }
1910
+ if (subMessageHash in client.subscriptions) {
1911
+ delete client.subscriptions[subMessageHash];
1912
+ }
1913
+ if (messageHash in client.subscriptions) {
1914
+ delete client.subscriptions[messageHash];
1915
+ }
1916
+ client.resolve(true, messageHash);
1917
+ }
1918
+ }
1919
+ return message;
1920
+ }
1812
1921
  }
1813
1922
 
1814
1923
  module.exports = bitget;
@@ -411,15 +411,7 @@ class bitrue extends bitrue$1 {
411
411
  async authenticate(params = {}) {
412
412
  const listenKey = this.safeValue(this.options, 'listenKey');
413
413
  if (listenKey === undefined) {
414
- let response = undefined;
415
- try {
416
- response = await this.openPrivatePostPoseidonApiV1ListenKey(params);
417
- }
418
- catch (error) {
419
- this.options['listenKey'] = undefined;
420
- this.options['listenKeyUrl'] = undefined;
421
- return undefined;
422
- }
414
+ const response = await this.openPrivatePostPoseidonApiV1ListenKey(params);
423
415
  //
424
416
  // {
425
417
  // "msg": "succ",