ccxt 4.1.31 → 4.1.32

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.
package/README.md CHANGED
@@ -210,13 +210,13 @@ console.log(version, Object.keys(exchanges));
210
210
 
211
211
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
212
212
 
213
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.31/dist/ccxt.browser.js
214
- * unpkg: https://unpkg.com/ccxt@4.1.31/dist/ccxt.browser.js
213
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.32/dist/ccxt.browser.js
214
+ * unpkg: https://unpkg.com/ccxt@4.1.32/dist/ccxt.browser.js
215
215
 
216
216
  CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
217
217
 
218
218
  ```HTML
219
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.31/dist/ccxt.browser.js"></script>
219
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.32/dist/ccxt.browser.js"></script>
220
220
  ```
221
221
 
222
222
  Creates a global `ccxt` object:
@@ -132062,6 +132062,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
132062
132062
  '1220': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AccountNotEnabled,
132063
132063
  '1303': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
132064
132064
  '1461': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder,
132065
+ '4007': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
132065
132066
  'bad-request': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
132066
132067
  'validation-format-error': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
132067
132068
  'validation-constraints-required': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
@@ -134204,6 +134205,13 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
134204
134205
  /**
134205
134206
  * @method
134206
134207
  * @name huobi#fetchBalance
134208
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#get-account-balance-of-a-specific-account
134209
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec4b429-7773-11ed-9966-0242ac110003
134210
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=10000074-77b7-11ed-9966-0242ac110003
134211
+ * @see https://huobiapi.github.io/docs/dm/v1/en/#query-asset-valuation
134212
+ * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-account-information
134213
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-account-information
134214
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-account-information
134207
134215
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
134208
134216
  * @param {object} [params] extra parameters specific to the huobi api endpoint
134209
134217
  * @param {bool} [params.unified] provide this parameter if you have a recent account with unified cross+isolated margin account
@@ -134216,10 +134224,8 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
134216
134224
  const isUnifiedAccount = this.safeValue2(params, 'isUnifiedAccount', 'unified', false);
134217
134225
  params = this.omit(params, ['isUnifiedAccount', 'unified']);
134218
134226
  const request = {};
134219
- let method = undefined;
134220
134227
  const spot = (type === 'spot');
134221
134228
  const future = (type === 'future');
134222
- const swap = (type === 'swap');
134223
134229
  const defaultSubType = this.safeString2(this.options, 'defaultSubType', 'subType', 'linear');
134224
134230
  let subType = this.safeString2(options, 'defaultSubType', 'subType', defaultSubType);
134225
134231
  subType = this.safeString2(params, 'defaultSubType', 'subType', subType);
@@ -134231,42 +134237,42 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
134231
134237
  const isolated = (marginMode === 'isolated');
134232
134238
  const cross = (marginMode === 'cross');
134233
134239
  const margin = (type === 'margin') || (spot && (cross || isolated));
134240
+ let response = undefined;
134234
134241
  if (spot || margin) {
134235
134242
  if (margin) {
134236
134243
  if (isolated) {
134237
- method = 'spotPrivateGetV1MarginAccountsBalance';
134244
+ response = await this.spotPrivateGetV1MarginAccountsBalance(this.extend(request, params));
134238
134245
  }
134239
134246
  else {
134240
- method = 'spotPrivateGetV1CrossMarginAccountsBalance';
134247
+ response = await this.spotPrivateGetV1CrossMarginAccountsBalance(this.extend(request, params));
134241
134248
  }
134242
134249
  }
134243
134250
  else {
134244
134251
  await this.loadAccounts();
134245
134252
  const accountId = await this.fetchAccountIdByType(type, undefined, undefined, params);
134246
134253
  request['account-id'] = accountId;
134247
- method = 'spotPrivateGetV1AccountAccountsAccountIdBalance';
134254
+ response = await this.spotPrivateGetV1AccountAccountsAccountIdBalance(this.extend(request, params));
134248
134255
  }
134249
134256
  }
134250
134257
  else if (isUnifiedAccount) {
134251
- method = 'contractPrivateGetLinearSwapApiV3UnifiedAccountInfo';
134258
+ response = await this.contractPrivateGetLinearSwapApiV3UnifiedAccountInfo(this.extend(request, params));
134252
134259
  }
134253
134260
  else if (linear) {
134254
134261
  if (isolated) {
134255
- method = 'contractPrivatePostLinearSwapApiV1SwapAccountInfo';
134262
+ response = await this.contractPrivatePostLinearSwapApiV1SwapAccountInfo(this.extend(request, params));
134256
134263
  }
134257
134264
  else {
134258
- method = 'contractPrivatePostLinearSwapApiV1SwapCrossAccountInfo';
134265
+ response = await this.contractPrivatePostLinearSwapApiV1SwapCrossAccountInfo(this.extend(request, params));
134259
134266
  }
134260
134267
  }
134261
134268
  else if (inverse) {
134262
134269
  if (future) {
134263
- method = 'contractPrivatePostApiV1ContractAccountInfo';
134270
+ response = await this.contractPrivatePostApiV1ContractAccountInfo(this.extend(request, params));
134264
134271
  }
134265
- else if (swap) {
134266
- method = 'contractPrivatePostSwapApiV1SwapAccountInfo';
134272
+ else {
134273
+ response = await this.contractPrivatePostSwapApiV1SwapAccountInfo(this.extend(request, params));
134267
134274
  }
134268
134275
  }
134269
- const response = await this[method](this.extend(request, params));
134270
134276
  //
134271
134277
  // spot
134272
134278
  //
@@ -150113,6 +150119,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
150113
150119
  }
150114
150120
  const url = this.urls['api'][api] + query;
150115
150121
  if (api === 'private' || access === 'private') {
150122
+ this.checkRequiredCredentials();
150116
150123
  let auth = postData + '/api/';
150117
150124
  if (api !== 'private') {
150118
150125
  auth += api + '/';
@@ -191375,17 +191382,19 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
191375
191382
  // 'limit': 20, // Page size default 20, max 200
191376
191383
  // 'offset': 0, // Page start default 0
191377
191384
  };
191378
- if (limit > 200) {
191379
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchFundingHistory() limit argument cannot exceed 200');
191380
- }
191381
191385
  if (limit !== undefined) {
191386
+ if (limit > 200) {
191387
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchFundingHistory() limit argument cannot exceed 200');
191388
+ }
191382
191389
  request['limit'] = limit;
191383
191390
  }
191384
- let method = 'privateGetApiDataFuturesFundingFees';
191391
+ let response = undefined;
191385
191392
  if (market['settle'] === 'USDT') {
191386
- method = 'privateGetApiDataGFuturesFundingFees';
191393
+ response = await this.privateGetApiDataGFuturesFundingFees(this.extend(request, params));
191394
+ }
191395
+ else {
191396
+ response = await this.privateGetApiDataFuturesFundingFees(this.extend(request, params));
191387
191397
  }
191388
- const response = await this[method](this.extend(request, params));
191389
191398
  //
191390
191399
  // {
191391
191400
  // "code": 0,
@@ -209815,9 +209824,9 @@ class bitstamp extends _bitstamp_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
209815
209824
  /* harmony export */ "Z": () => (/* binding */ bittrex)
209816
209825
  /* harmony export */ });
209817
209826
  /* harmony import */ var _bittrex_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8963);
209818
- /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6689);
209819
- /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3020);
209820
- /* harmony import */ var _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7110);
209827
+ /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
209828
+ /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3020);
209829
+ /* harmony import */ var _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7110);
209821
209830
  /* harmony import */ var _static_dependencies_fflake_browser_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7348);
209822
209831
  // ---------------------------------------------------------------------------
209823
209832
 
@@ -209864,6 +209873,12 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
209864
209873
  'maxRetries': 3,
209865
209874
  },
209866
209875
  },
209876
+ 'exceptions': {
209877
+ 'exact': {
209878
+ 'INVALID_APIKEY': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
209879
+ 'UNAUTHORIZED_USER': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
209880
+ },
209881
+ },
209867
209882
  });
209868
209883
  }
209869
209884
  getSignalRUrl(negotiation) {
@@ -209891,7 +209906,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
209891
209906
  const timestamp = this.milliseconds();
209892
209907
  const uuid = this.uuid();
209893
209908
  const auth = timestamp.toString() + uuid;
209894
- const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_2__/* .sha512 */ .o);
209909
+ const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_3__/* .sha512 */ .o);
209895
209910
  const args = [this.apiKey, timestamp, uuid, signature];
209896
209911
  const method = 'Authenticate';
209897
209912
  return this.makeRequest(requestId, method, args);
@@ -209914,6 +209929,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
209914
209929
  return await this.watch(url, messageHash, request, messageHash, subscription);
209915
209930
  }
209916
209931
  async authenticate(params = {}) {
209932
+ this.checkRequiredCredentials();
209917
209933
  await this.loadMarkets();
209918
209934
  const request = await this.negotiate();
209919
209935
  return await this.sendRequestToAuthenticate(request, false, params);
@@ -209934,7 +209950,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
209934
209950
  'negotiation': negotiation,
209935
209951
  'method': this.handleAuthenticate,
209936
209952
  };
209937
- this.spawn(this.watch, url, messageHash, request, requestId, subscription);
209953
+ this.watch(url, messageHash, request, requestId, subscription);
209938
209954
  }
209939
209955
  return await future;
209940
209956
  }
@@ -210069,7 +210085,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210069
210085
  const parsed = this.parseOrder(delta);
210070
210086
  if (this.orders === undefined) {
210071
210087
  const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
210072
- this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolById */ .hl(limit);
210088
+ this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__/* .ArrayCacheBySymbolById */ .hl(limit);
210073
210089
  }
210074
210090
  const orders = this.orders;
210075
210091
  orders.append(parsed);
@@ -210257,7 +210273,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210257
210273
  let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
210258
210274
  if (stored === undefined) {
210259
210275
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
210260
- stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheByTimestamp */ .Py(limit);
210276
+ stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__/* .ArrayCacheByTimestamp */ .Py(limit);
210261
210277
  this.ohlcvs[symbol][timeframe] = stored;
210262
210278
  }
210263
210279
  stored.append(parsed);
@@ -210320,7 +210336,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210320
210336
  let stored = this.safeValue(this.trades, symbol);
210321
210337
  if (stored === undefined) {
210322
210338
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
210323
- stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCache */ .ZL(limit);
210339
+ stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__/* .ArrayCache */ .ZL(limit);
210324
210340
  }
210325
210341
  const trades = this.parseTrades(deltas, market);
210326
210342
  for (let i = 0; i < trades.length; i++) {
@@ -210341,7 +210357,9 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210341
210357
  * @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure
210342
210358
  */
210343
210359
  await this.loadMarkets();
210344
- symbol = this.symbol(symbol);
210360
+ if (symbol !== undefined) {
210361
+ symbol = this.symbol(symbol);
210362
+ }
210345
210363
  const authentication = await this.authenticate();
210346
210364
  const trades = await this.subscribeToMyTrades(authentication, params);
210347
210365
  if (this.newUpdates) {
@@ -210377,7 +210395,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210377
210395
  let stored = this.myTrades;
210378
210396
  if (stored === undefined) {
210379
210397
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
210380
- stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_3__/* .ArrayCacheBySymbolById */ .hl(limit);
210398
+ stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_4__/* .ArrayCacheBySymbolById */ .hl(limit);
210381
210399
  this.myTrades = stored;
210382
210400
  }
210383
210401
  for (let i = 0; i < trades.length; i++) {
@@ -210398,7 +210416,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210398
210416
  */
210399
210417
  limit = (limit === undefined) ? 25 : limit; // 25 by default
210400
210418
  if ((limit !== 1) && (limit !== 25) && (limit !== 500)) {
210401
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_4__.BadRequest(this.id + ' watchOrderBook() limit argument must be undefined, 1, 25 or 500, default is 25');
210419
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' watchOrderBook() limit argument must be undefined, 1, 25 or 500, default is 25');
210402
210420
  }
210403
210421
  await this.loadMarkets();
210404
210422
  symbol = this.symbol(symbol);
@@ -210461,7 +210479,7 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210461
210479
  }
210462
210480
  else {
210463
210481
  // throw upon failing to synchronize in maxAttempts
210464
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_4__.InvalidNonce(this.id + ' failed to synchronize WebSocket feed with the snapshot for symbol ' + symbol + ' in ' + maxAttempts.toString() + ' attempts');
210482
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidNonce(this.id + ' failed to synchronize WebSocket feed with the snapshot for symbol ' + symbol + ' in ' + maxAttempts.toString() + ' attempts');
210465
210483
  }
210466
210484
  }
210467
210485
  else {
@@ -210606,6 +210624,60 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210606
210624
  }
210607
210625
  return message;
210608
210626
  }
210627
+ handleErrorMessage(client, message) {
210628
+ //
210629
+ // {
210630
+ // R: [{ Success: false, ErrorCode: 'UNAUTHORIZED_USER' }, ... ],
210631
+ // I: '1698601759267'
210632
+ // }
210633
+ // {
210634
+ // R: { Success: false, ErrorCode: 'INVALID_APIKEY' },
210635
+ // I: '1698601759266'
210636
+ // }
210637
+ //
210638
+ const R = this.safeValue(message, 'R');
210639
+ if (R === undefined) {
210640
+ // Return there is no error
210641
+ return false;
210642
+ }
210643
+ const I = this.safeString(message, 'I');
210644
+ let errorCode = undefined;
210645
+ if (Array.isArray(R)) {
210646
+ for (let i = 0; i < R.length; i++) {
210647
+ const response = this.safeValue(R, i);
210648
+ const success = this.safeValue(response, 'Success', true);
210649
+ if (!success) {
210650
+ errorCode = this.safeString(response, 'ErrorCode');
210651
+ break;
210652
+ }
210653
+ }
210654
+ }
210655
+ else {
210656
+ const success = this.safeValue(R, 'Success', true);
210657
+ if (!success) {
210658
+ errorCode = this.safeString(R, 'ErrorCode');
210659
+ }
210660
+ }
210661
+ if (errorCode === undefined) {
210662
+ // Return there is no error
210663
+ return false;
210664
+ }
210665
+ const feedback = this.id + ' ' + errorCode;
210666
+ try {
210667
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
210668
+ if (message !== undefined) {
210669
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorCode, feedback);
210670
+ }
210671
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(feedback);
210672
+ }
210673
+ catch (e) {
210674
+ if (e instanceof _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError) {
210675
+ client.reject(e, 'authenticate');
210676
+ }
210677
+ client.reject(e, I);
210678
+ }
210679
+ return true;
210680
+ }
210609
210681
  handleMessage(client, message) {
210610
210682
  //
210611
210683
  // subscription confirmation
@@ -210652,6 +210724,9 @@ class bittrex extends _bittrex_js__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */
210652
210724
  // M: [ { H: 'C3', M: 'authenticationExpiring', A: [] } ]
210653
210725
  // }
210654
210726
  //
210727
+ if (this.handleErrorMessage(client, message)) {
210728
+ return;
210729
+ }
210655
210730
  const methods = {
210656
210731
  'authenticationExpiring': this.handleAuthenticationExpiring,
210657
210732
  'order': this.handleOrder,
@@ -224423,7 +224498,8 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
224423
224498
  '2021': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
224424
224499
  '2001': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadSymbol,
224425
224500
  '2011': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadSymbol,
224426
- '2040': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest, // { op: 'sub', cid: '1649152947', 'err-code': 2040, 'err-msg': 'Missing required parameter.', ts: 1649152948684 }
224501
+ '2040': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest,
224502
+ '4007': _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.BadRequest, // { op: 'sub', cid: '1', topic: 'accounts_unify.USDT', 'err-code': 4007, 'err-msg': 'Non - single account user is not available, please check through the cross and isolated account asset interface', ts: 1698419318540 }
224427
224503
  },
224428
224504
  },
224429
224505
  },
@@ -225512,12 +225588,12 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
225512
225588
  * @param {object} [params] extra parameters specific to the huobi api endpoint
225513
225589
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
225514
225590
  */
225515
- let type = this.safeString2(this.options, 'watchBalance', 'defaultType', 'spot');
225516
- type = this.safeString(params, 'type', type);
225517
- let subType = this.safeString2(this.options, 'watchBalance', 'subType', 'linear');
225518
- subType = this.safeString(params, 'subType', subType);
225519
- params = this.omit(params, ['type', 'subType']);
225520
- params = this.omit(params, 'type');
225591
+ let type = undefined;
225592
+ [type, params] = this.handleMarketTypeAndParams('watchBalance', undefined, params);
225593
+ let subType = undefined;
225594
+ [subType, params] = this.handleSubTypeAndParams('watchBalance', undefined, params, 'linear');
225595
+ const isUnifiedAccount = this.safeValue2(params, 'isUnifiedAccount', 'unified', false);
225596
+ params = this.omit(params, ['isUnifiedAccount', 'unified']);
225521
225597
  await this.loadMarkets();
225522
225598
  let messageHash = undefined;
225523
225599
  let channel = undefined;
@@ -225538,29 +225614,37 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
225538
225614
  let prefix = 'accounts';
225539
225615
  messageHash = prefix;
225540
225616
  if (subType === 'linear') {
225541
- // usdt contracts account
225542
- prefix = (marginMode === 'cross') ? prefix + '_cross' : prefix;
225543
- messageHash = prefix;
225544
- if (marginMode === 'isolated') {
225545
- // isolated margin only allows filtering by symbol3
225546
- if (symbol !== undefined) {
225547
- messageHash += '.' + market['id'];
225548
- channel = messageHash;
225549
- }
225550
- else {
225551
- // subscribe to all
225552
- channel = prefix + '.' + '*';
225553
- }
225617
+ if (isUnifiedAccount) {
225618
+ // usdt contracts account
225619
+ prefix = 'accounts_unify';
225620
+ messageHash = prefix;
225621
+ channel = prefix + '.' + 'usdt';
225554
225622
  }
225555
225623
  else {
225556
- // cross margin
225557
- if (currencyCode !== undefined) {
225558
- channel = prefix + '.' + currencyCode['id'];
225559
- messageHash = channel;
225624
+ // usdt contracts account
225625
+ prefix = (marginMode === 'cross') ? prefix + '_cross' : prefix;
225626
+ messageHash = prefix;
225627
+ if (marginMode === 'isolated') {
225628
+ // isolated margin only allows filtering by symbol3
225629
+ if (symbol !== undefined) {
225630
+ messageHash += '.' + market['id'];
225631
+ channel = messageHash;
225632
+ }
225633
+ else {
225634
+ // subscribe to all
225635
+ channel = prefix + '.' + '*';
225636
+ }
225560
225637
  }
225561
225638
  else {
225562
- // subscribe to all
225563
- channel = prefix + '.' + '*';
225639
+ // cross margin
225640
+ if (currencyCode !== undefined) {
225641
+ channel = prefix + '.' + currencyCode['id'];
225642
+ messageHash = channel;
225643
+ }
225644
+ else {
225645
+ // subscribe to all
225646
+ channel = prefix + '.' + '*';
225647
+ }
225564
225648
  }
225565
225649
  }
225566
225650
  }
@@ -225738,7 +225822,9 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
225738
225822
  return;
225739
225823
  }
225740
225824
  const first = this.safeValue(data, 0, {});
225741
- let messageHash = this.safeString(message, 'topic');
225825
+ const topic = this.safeString(message, 'topic');
225826
+ const splitTopic = topic.split('.');
225827
+ let messageHash = this.safeString(splitTopic, 0);
225742
225828
  let subscription = this.safeValue2(client.subscriptions, messageHash, messageHash + '.*');
225743
225829
  if (subscription === undefined) {
225744
225830
  // if subscription not found means that we subscribed to a specific currency/symbol
@@ -225746,13 +225832,37 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
225746
225832
  // Example: topic = 'accounts'
225747
225833
  // client.subscription hash = 'accounts.usdt'
225748
225834
  // we do 'accounts' + '.' + data[0]]['margin_asset'] to get it
225749
- const marginAsset = this.safeString(first, 'margin_asset');
225750
- messageHash += '.' + marginAsset.toLowerCase();
225835
+ const currencyId = this.safeString2(first, 'margin_asset', 'symbol');
225836
+ messageHash += '.' + currencyId.toLowerCase();
225751
225837
  subscription = this.safeValue(client.subscriptions, messageHash);
225752
225838
  }
225753
225839
  const type = this.safeString(subscription, 'type');
225754
225840
  const subType = this.safeString(subscription, 'subType');
225755
- if (subType === 'linear') {
225841
+ if (topic === 'accounts_unify') {
225842
+ // {
225843
+ // margin_asset: 'USDT',
225844
+ // margin_static: 10,
225845
+ // cross_margin_static: 10,
225846
+ // margin_balance: 10,
225847
+ // cross_profit_unreal: 0,
225848
+ // margin_frozen: 0,
225849
+ // withdraw_available: 10,
225850
+ // cross_risk_rate: null,
225851
+ // cross_swap: [],
225852
+ // cross_future: [],
225853
+ // isolated_swap: []
225854
+ // }
225855
+ const marginAsset = this.safeString(first, 'margin_asset');
225856
+ const code = this.safeCurrencyCode(marginAsset);
225857
+ const marginFrozen = this.safeString(first, 'margin_frozen');
225858
+ const unifiedAccount = this.account();
225859
+ unifiedAccount['free'] = this.safeString(first, 'withdraw_available');
225860
+ unifiedAccount['used'] = marginFrozen;
225861
+ this.balance[code] = unifiedAccount;
225862
+ this.balance = this.safeBalance(this.balance);
225863
+ client.resolve(this.balance, 'accounts_unify');
225864
+ }
225865
+ else if (subType === 'linear') {
225756
225866
  const margin = this.safeString(subscription, 'margin');
225757
225867
  if (margin === 'cross') {
225758
225868
  const fieldName = (type === 'future') ? 'futures_contract_detail' : 'contract_detail';
@@ -226050,6 +226160,15 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
226050
226160
  // id: '2'
226051
226161
  // }
226052
226162
  //
226163
+ // {
226164
+ // op: 'sub',
226165
+ // cid: '1',
226166
+ // topic: 'accounts_unify.USDT',
226167
+ // 'err-code': 4007,
226168
+ // 'err-msg': 'Non - single account user is not available, please check through the cross and isolated account asset interface',
226169
+ // ts: 1698419490189
226170
+ // }
226171
+ //
226053
226172
  const status = this.safeString(message, 'status');
226054
226173
  if (status === 'error') {
226055
226174
  const id = this.safeString(message, 'id');
@@ -226071,8 +226190,8 @@ class huobi extends _huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
226071
226190
  }
226072
226191
  return false;
226073
226192
  }
226074
- const code = this.safeInteger(message, 'code');
226075
- if (code !== undefined && code !== 200) {
226193
+ const code = this.safeInteger2(message, 'code', 'err-code');
226194
+ if (code !== undefined && ((code !== 200) && (code !== 0))) {
226076
226195
  const feedback = this.id + ' ' + this.json(message);
226077
226196
  try {
226078
226197
  this.throwExactlyMatchedException(this.exceptions['ws']['exact'], code, feedback);
@@ -268523,29 +268642,27 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
268523
268642
  if (stopPrice !== undefined) {
268524
268643
  request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
268525
268644
  }
268645
+ params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice']);
268526
268646
  const isStop = (stopPrice !== undefined) || (this.safeValue(params, 'childOrders') !== undefined);
268527
- let method = undefined;
268647
+ let response = undefined;
268528
268648
  if (isByClientOrder) {
268649
+ request['client_order_id'] = clientOrderIdExchangeSpecific;
268529
268650
  if (isStop) {
268530
- method = 'v3PrivatePutAlgoOrderClientClientOrderId';
268531
- request['oid'] = id;
268651
+ response = await this.v3PrivatePutAlgoOrderClientClientOrderId(this.extend(request, params));
268532
268652
  }
268533
268653
  else {
268534
- method = 'v3PrivatePutOrderClientClientOrderId';
268535
- request['client_order_id'] = clientOrderIdExchangeSpecific;
268654
+ response = await this.v3PrivatePutOrderClientClientOrderId(this.extend(request, params));
268536
268655
  }
268537
268656
  }
268538
268657
  else {
268658
+ request['oid'] = id;
268539
268659
  if (isStop) {
268540
- method = 'v3PrivatePutAlgoOrderOid';
268660
+ response = await this.v3PrivatePutAlgoOrderOid(this.extend(request, params));
268541
268661
  }
268542
268662
  else {
268543
- method = 'v3PrivatePutOrderOid';
268663
+ response = await this.v3PrivatePutOrderOid(this.extend(request, params));
268544
268664
  }
268545
- request['oid'] = id;
268546
268665
  }
268547
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id', 'stopPrice', 'triggerPrice', 'takeProfitPrice', 'stopLossPrice']);
268548
- const response = await this[method](this.extend(request, params));
268549
268666
  //
268550
268667
  // {
268551
268668
  // "code": 0,
@@ -268581,32 +268698,31 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
268581
268698
  this.checkRequiredSymbol('cancelOrder', symbol);
268582
268699
  }
268583
268700
  await this.loadMarkets();
268701
+ let market = undefined;
268702
+ if (symbol !== undefined) {
268703
+ market = this.market(symbol);
268704
+ }
268584
268705
  const request = {};
268585
268706
  const clientOrderIdUnified = this.safeString2(params, 'clOrdID', 'clientOrderId');
268586
268707
  const clientOrderIdExchangeSpecific = this.safeString(params, 'client_order_id', clientOrderIdUnified);
268587
268708
  const isByClientOrder = clientOrderIdExchangeSpecific !== undefined;
268588
- let method = undefined;
268709
+ let response = undefined;
268589
268710
  if (stop) {
268590
- method = 'v3PrivateDeleteAlgoOrderOrderId';
268591
268711
  request['order_id'] = id;
268592
- }
268593
- else if (isByClientOrder) {
268594
- method = 'v1PrivateDeleteClientOrder';
268595
- request['client_order_id'] = clientOrderIdExchangeSpecific;
268596
- params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id']);
268712
+ response = await this.v3PrivateDeleteAlgoOrderOrderId(this.extend(request, params));
268597
268713
  }
268598
268714
  else {
268599
- method = 'v1PrivateDeleteOrder';
268600
- request['order_id'] = id;
268601
- }
268602
- let market = undefined;
268603
- if (symbol !== undefined) {
268604
- market = this.market(symbol);
268605
- }
268606
- if (!stop) {
268607
268715
  request['symbol'] = market['id'];
268716
+ if (isByClientOrder) {
268717
+ request['client_order_id'] = clientOrderIdExchangeSpecific;
268718
+ params = this.omit(params, ['clOrdID', 'clientOrderId', 'client_order_id']);
268719
+ response = await this.v1PrivateDeleteClientOrder(this.extend(request, params));
268720
+ }
268721
+ else {
268722
+ request['order_id'] = id;
268723
+ response = await this.v1PrivateDeleteOrder(this.extend(request, params));
268724
+ }
268608
268725
  }
268609
- const response = await this[method](this.extend(request, params));
268610
268726
  //
268611
268727
  // { success: true, status: 'CANCEL_SENT' }
268612
268728
  //
@@ -268670,20 +268786,19 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
268670
268786
  params = this.omit(params, 'stop');
268671
268787
  const request = {};
268672
268788
  const clientOrderId = this.safeString2(params, 'clOrdID', 'clientOrderId');
268673
- let method = undefined;
268789
+ let response = undefined;
268674
268790
  if (stop) {
268675
- method = 'v3PrivateGetAlgoOrderOid';
268676
268791
  request['oid'] = id;
268792
+ response = await this.v3PrivateGetAlgoOrderOid(this.extend(request, params));
268677
268793
  }
268678
268794
  else if (clientOrderId) {
268679
- method = 'v1PrivateGetClientOrderClientOrderId';
268680
268795
  request['client_order_id'] = clientOrderId;
268796
+ response = await this.v1PrivateGetClientOrderClientOrderId(this.extend(request, params));
268681
268797
  }
268682
268798
  else {
268683
- method = 'v1PrivateGetOrderOid';
268684
268799
  request['oid'] = id;
268800
+ response = await this.v1PrivateGetOrderOid(this.extend(request, params));
268685
268801
  }
268686
- const response = await this[method](this.extend(request, params));
268687
268802
  //
268688
268803
  // {
268689
268804
  // success: true,
@@ -279734,7 +279849,7 @@ SOFTWARE.
279734
279849
 
279735
279850
  //-----------------------------------------------------------------------------
279736
279851
  // this is updated by vss.js when building
279737
- const version = '4.1.31';
279852
+ const version = '4.1.32';
279738
279853
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
279739
279854
  //-----------------------------------------------------------------------------
279740
279855