ccxt 4.1.91 → 4.1.95

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.
@@ -11912,7 +11912,8 @@ class Exchange {
11912
11912
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
11913
11913
 
11914
11914
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11915
- /* harmony export */ O: () => (/* binding */ Precise)
11915
+ /* harmony export */ O: () => (/* binding */ Precise),
11916
+ /* harmony export */ Z: () => (__WEBPACK_DEFAULT_EXPORT__)
11916
11917
  /* harmony export */ });
11917
11918
  const zero = BigInt(0);
11918
11919
  const minusOne = BigInt(-1);
@@ -12170,7 +12171,7 @@ class Precise {
12170
12171
  return (new Precise(string1)).le(new Precise(string2));
12171
12172
  }
12172
12173
  }
12173
- /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = ((/* unused pure expression or super */ null && (Precise)));
12174
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Precise);
12174
12175
 
12175
12176
 
12176
12177
 
@@ -20218,7 +20219,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20218
20219
  * @see https://binance-docs.github.io/apidocs/futures/en/#24hr-ticker-price-change-statistics // swap
20219
20220
  * @see https://binance-docs.github.io/apidocs/delivery/en/#24hr-ticker-price-change-statistics // future
20220
20221
  * @see https://binance-docs.github.io/apidocs/voptions/en/#24hr-ticker-price-change-statistics // option
20221
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
20222
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
20222
20223
  * @param {object} [params] extra parameters specific to the exchange API endpoint
20223
20224
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
20224
20225
  */
@@ -20233,22 +20234,24 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20233
20234
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
20234
20235
  let subType = undefined;
20235
20236
  [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params);
20236
- const query = this.omit(params, 'type');
20237
- let defaultMethod = undefined;
20237
+ let response = undefined;
20238
20238
  if (type === 'option') {
20239
- defaultMethod = 'eapiPublicGetTicker';
20239
+ response = await this.eapiPublicGetTicker(params);
20240
20240
  }
20241
20241
  else if (this.isLinear(type, subType)) {
20242
- defaultMethod = 'fapiPublicGetTicker24hr';
20242
+ response = await this.fapiPublicGetTicker24hr(params);
20243
20243
  }
20244
20244
  else if (this.isInverse(type, subType)) {
20245
- defaultMethod = 'dapiPublicGetTicker24hr';
20245
+ response = await this.dapiPublicGetTicker24hr(params);
20246
20246
  }
20247
20247
  else {
20248
- defaultMethod = 'publicGetTicker24hr';
20248
+ const request = {};
20249
+ if (symbols !== undefined) {
20250
+ const marketIds = this.marketIds(symbols);
20251
+ request['symbols'] = this.json(marketIds);
20252
+ }
20253
+ response = await this.publicGetTicker24hr(this.extend(request, params));
20249
20254
  }
20250
- const method = this.safeString(this.options, 'fetchTickersMethod', defaultMethod);
20251
- const response = await this[method](query);
20252
20255
  return this.parseTickers(response, symbols);
20253
20256
  }
20254
20257
  parseOHLCV(ohlcv, market = undefined) {
@@ -27856,14 +27859,19 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27856
27859
  const type = (cost === undefined) ? 'spot' : 'swap';
27857
27860
  const currencyId = this.safeString2(trade, 'currency', 'N');
27858
27861
  const currencyCode = this.safeCurrencyCode(currencyId);
27859
- const m = this.safeValue(trade, 'm', false);
27862
+ const m = this.safeValue(trade, 'm');
27860
27863
  const marketId = this.safeString(trade, 's');
27861
27864
  const isBuyerMaker = this.safeValue2(trade, 'buyerMaker', 'isBuyerMaker');
27862
- let takeOrMaker = (isBuyerMaker || m) ? 'maker' : 'taker';
27865
+ let takeOrMaker = undefined;
27866
+ if ((isBuyerMaker !== undefined) || (m !== undefined)) {
27867
+ takeOrMaker = (isBuyerMaker || m) ? 'maker' : 'taker';
27868
+ }
27863
27869
  let side = this.safeStringLower2(trade, 'side', 'S');
27864
27870
  if (side === undefined) {
27865
- side = (isBuyerMaker || m) ? 'sell' : 'buy';
27866
- takeOrMaker = 'taker';
27871
+ if ((isBuyerMaker !== undefined) || (m !== undefined)) {
27872
+ side = (isBuyerMaker || m) ? 'sell' : 'buy';
27873
+ takeOrMaker = 'taker';
27874
+ }
27867
27875
  }
27868
27876
  return this.safeTrade({
27869
27877
  'id': this.safeStringN(trade, ['id', 't']),
@@ -27876,7 +27884,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27876
27884
  'side': this.parseOrderSide(side),
27877
27885
  'takerOrMaker': takeOrMaker,
27878
27886
  'price': this.safeString2(trade, 'price', 'p'),
27879
- 'amount': this.safeStringN(trade, ['qty', 'amount', 'q']),
27887
+ 'amount': this.safeStringN(trade, ['qty', 'volume', 'amount', 'q']),
27880
27888
  'cost': cost,
27881
27889
  'fee': {
27882
27890
  'cost': this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(this.safeString2(trade, 'commission', 'n'))),
@@ -28312,7 +28320,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28312
28320
  async fetchBalance(params = {}) {
28313
28321
  /**
28314
28322
  * @method
28315
- * @name cryptocom#fetchBalance
28323
+ * @name bingx#fetchBalance
28316
28324
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
28317
28325
  * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Query%20Assets
28318
28326
  * @see https://bingx-api.github.io/docs/#/swapV2/account-api.html#Get%20Perpetual%20Swap%20Account%20Asset%20Information
@@ -40303,7 +40311,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
40303
40311
  'cancelOrder': true,
40304
40312
  'cancelOrders': true,
40305
40313
  'closeAllPositions': true,
40306
- 'closePosition': false,
40314
+ 'closePosition': true,
40307
40315
  'createMarketBuyOrderWithCost': true,
40308
40316
  'createMarketOrderWithCost': false,
40309
40317
  'createMarketSellOrderWithCost': false,
@@ -43834,7 +43842,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43834
43842
  }
43835
43843
  parseOrder(order, market = undefined) {
43836
43844
  //
43837
- // createOrder, editOrder
43845
+ // createOrder, editOrder, closePosition
43838
43846
  //
43839
43847
  // {
43840
43848
  // "clientOid": "abe95dbe-6081-4a6f-a2d3-ae49601cd479",
@@ -44112,8 +44120,13 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
44112
44120
  'status': 'rejected',
44113
44121
  }, market);
44114
44122
  }
44123
+ const isContractOrder = ('posSide' in order);
44124
+ let marketType = isContractOrder ? 'contract' : 'spot';
44125
+ if (market !== undefined) {
44126
+ marketType = market['type'];
44127
+ }
44115
44128
  const marketId = this.safeString(order, 'symbol');
44116
- market = this.safeMarket(marketId, market);
44129
+ market = this.safeMarket(marketId, market, undefined, marketType);
44117
44130
  const timestamp = this.safeInteger2(order, 'cTime', 'ctime');
44118
44131
  const updateTimestamp = this.safeInteger(order, 'uTime');
44119
44132
  const rawStatus = this.safeString2(order, 'status', 'state');
@@ -45263,26 +45276,35 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45263
45276
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45264
45277
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45265
45278
  */
45266
- if (symbol === undefined) {
45267
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
45268
- }
45269
45279
  await this.loadMarkets();
45270
45280
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
45271
45281
  let market = undefined;
45272
- if (sandboxMode) {
45273
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
45274
- market = this.market(sandboxSymbol);
45282
+ let type = undefined;
45283
+ let request = {};
45284
+ let marginMode = undefined;
45285
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
45286
+ if (symbol !== undefined) {
45287
+ if (sandboxMode) {
45288
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
45289
+ market = this.market(sandboxSymbol);
45290
+ }
45291
+ else {
45292
+ market = this.market(symbol);
45293
+ }
45294
+ request['symbol'] = market['id'];
45295
+ const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
45296
+ const marketType = ('type' in market) ? market['type'] : defaultType;
45297
+ type = this.safeString(params, 'type', marketType);
45275
45298
  }
45276
45299
  else {
45277
- market = this.market(symbol);
45300
+ const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
45301
+ type = this.safeString(params, 'type', defaultType);
45278
45302
  }
45279
- let marginMode = undefined;
45280
- [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
45281
45303
  let paginate = false;
45282
45304
  [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
45283
45305
  if (paginate) {
45284
45306
  let cursorReceived = undefined;
45285
- if (market['spot']) {
45307
+ if (type === 'spot') {
45286
45308
  if (marginMode !== undefined) {
45287
45309
  cursorReceived = 'minId';
45288
45310
  }
@@ -45292,9 +45314,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45292
45314
  }
45293
45315
  return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
45294
45316
  }
45295
- let request = {
45296
- 'symbol': market['id'],
45297
- };
45298
45317
  let response = undefined;
45299
45318
  const stop = this.safeValue2(params, 'stop', 'trigger');
45300
45319
  params = this.omit(params, ['stop', 'trigger']);
@@ -45305,46 +45324,48 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45305
45324
  if (limit !== undefined) {
45306
45325
  request['limit'] = limit;
45307
45326
  }
45308
- if ((market['swap']) || (market['future']) || (marginMode !== undefined)) {
45327
+ if ((type === 'swap') || (type === 'future') || (marginMode !== undefined)) {
45309
45328
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
45310
45329
  params = this.omit(params, 'clientOrderId');
45311
45330
  if (clientOrderId !== undefined) {
45312
45331
  request['clientOid'] = clientOrderId;
45313
45332
  }
45314
45333
  }
45315
- if (market['spot']) {
45334
+ let query = undefined;
45335
+ query = this.omit(params, ['type']);
45336
+ if (type === 'spot') {
45316
45337
  if (marginMode !== undefined) {
45317
45338
  if (since === undefined) {
45318
45339
  since = this.milliseconds() - 7776000000;
45319
45340
  request['startTime'] = since;
45320
45341
  }
45321
45342
  if (marginMode === 'isolated') {
45322
- response = await this.privateMarginGetV2MarginIsolatedOpenOrders(this.extend(request, params));
45343
+ response = await this.privateMarginGetV2MarginIsolatedOpenOrders(this.extend(request, query));
45323
45344
  }
45324
45345
  else if (marginMode === 'cross') {
45325
- response = await this.privateMarginGetV2MarginCrossedOpenOrders(this.extend(request, params));
45346
+ response = await this.privateMarginGetV2MarginCrossedOpenOrders(this.extend(request, query));
45326
45347
  }
45327
45348
  }
45328
45349
  else {
45329
45350
  if (stop) {
45330
- response = await this.privateSpotGetV2SpotTradeCurrentPlanOrder(this.extend(request, params));
45351
+ response = await this.privateSpotGetV2SpotTradeCurrentPlanOrder(this.extend(request, query));
45331
45352
  }
45332
45353
  else {
45333
- response = await this.privateSpotGetV2SpotTradeUnfilledOrders(this.extend(request, params));
45354
+ response = await this.privateSpotGetV2SpotTradeUnfilledOrders(this.extend(request, query));
45334
45355
  }
45335
45356
  }
45336
45357
  }
45337
45358
  else {
45338
45359
  let productType = undefined;
45339
- [productType, params] = this.handleProductTypeAndParams(market, params);
45360
+ [productType, query] = this.handleProductTypeAndParams(market, query);
45340
45361
  request['productType'] = productType;
45341
45362
  if (stop) {
45342
- const planType = this.safeString(params, 'planType', 'normal_plan');
45363
+ const planType = this.safeString(query, 'planType', 'normal_plan');
45343
45364
  request['planType'] = planType;
45344
- response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, params));
45365
+ response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
45345
45366
  }
45346
45367
  else {
45347
- response = await this.privateMixGetV2MixOrderOrdersPending(this.extend(request, params));
45368
+ response = await this.privateMixGetV2MixOrderOrdersPending(this.extend(request, query));
45348
45369
  }
45349
45370
  }
45350
45371
  //
@@ -45523,7 +45544,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45523
45544
  // }
45524
45545
  //
45525
45546
  const data = this.safeValue(response, 'data');
45526
- if (market['spot']) {
45547
+ if (type === 'spot') {
45527
45548
  if ((marginMode !== undefined) || stop) {
45528
45549
  const resultList = this.safeValue(data, 'orderList', []);
45529
45550
  return this.parseOrders(resultList, market, since, limit);
@@ -45553,13 +45574,14 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45553
45574
  * @param {int} [params.until] the latest time in ms to fetch entries for
45554
45575
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
45555
45576
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45577
+ * @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
45556
45578
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45557
45579
  */
45558
- if (symbol === undefined) {
45559
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
45560
- }
45561
45580
  await this.loadMarkets();
45562
- const market = this.market(symbol);
45581
+ let market = undefined;
45582
+ if (symbol !== undefined) {
45583
+ market = this.market(symbol);
45584
+ }
45563
45585
  const response = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
45564
45586
  const result = [];
45565
45587
  for (let i = 0; i < response.length; i++) {
@@ -45589,13 +45611,14 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45589
45611
  * @param {int} [params.until] the latest time in ms to fetch entries for
45590
45612
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
45591
45613
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45614
+ * @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
45592
45615
  * @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45593
45616
  */
45594
- if (symbol === undefined) {
45595
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchCanceledOrders() requires a symbol argument');
45596
- }
45597
45617
  await this.loadMarkets();
45598
- const market = this.market(symbol);
45618
+ let market = undefined;
45619
+ if (symbol !== undefined) {
45620
+ market = this.market(symbol);
45621
+ }
45599
45622
  const response = await this.fetchCanceledAndClosedOrders(symbol, since, limit, params);
45600
45623
  const result = [];
45601
45624
  for (let i = 0; i < response.length; i++) {
@@ -45612,19 +45635,25 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45612
45635
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
45613
45636
  let market = undefined;
45614
45637
  if (sandboxMode) {
45615
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
45616
- market = this.market(sandboxSymbol);
45638
+ if (symbol !== undefined) {
45639
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
45640
+ symbol = sandboxSymbol;
45641
+ }
45617
45642
  }
45618
- else {
45643
+ let request = {};
45644
+ if (symbol !== undefined) {
45619
45645
  market = this.market(symbol);
45646
+ request['symbol'] = market['id'];
45620
45647
  }
45648
+ let marketType = undefined;
45649
+ [marketType, params] = this.handleMarketTypeAndParams('fetchCanceledAndClosedOrders', market, params);
45621
45650
  let marginMode = undefined;
45622
45651
  [marginMode, params] = this.handleMarginModeAndParams('fetchCanceledAndClosedOrders', params);
45623
45652
  let paginate = false;
45624
45653
  [paginate, params] = this.handleOptionAndParams(params, 'fetchCanceledAndClosedOrders', 'paginate');
45625
45654
  if (paginate) {
45626
45655
  let cursorReceived = undefined;
45627
- if (market['spot']) {
45656
+ if (marketType === 'spot') {
45628
45657
  if (marginMode !== undefined) {
45629
45658
  cursorReceived = 'minId';
45630
45659
  }
@@ -45634,9 +45663,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45634
45663
  }
45635
45664
  return await this.fetchPaginatedCallCursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
45636
45665
  }
45637
- let request = {
45638
- 'symbol': market['id'],
45639
- };
45640
45666
  let response = undefined;
45641
45667
  const stop = this.safeValue2(params, 'stop', 'trigger');
45642
45668
  params = this.omit(params, ['stop', 'trigger']);
@@ -45647,7 +45673,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45647
45673
  if (limit !== undefined) {
45648
45674
  request['limit'] = limit;
45649
45675
  }
45650
- if ((market['swap']) || (market['future']) || (marginMode !== undefined)) {
45676
+ if ((marketType === 'swap') || (marketType === 'future') || (marginMode !== undefined)) {
45651
45677
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
45652
45678
  params = this.omit(params, 'clientOrderId');
45653
45679
  if (clientOrderId !== undefined) {
@@ -45655,7 +45681,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45655
45681
  }
45656
45682
  }
45657
45683
  const now = this.milliseconds();
45658
- if (market['spot']) {
45684
+ if (marketType === 'spot') {
45659
45685
  if (marginMode !== undefined) {
45660
45686
  if (since === undefined) {
45661
45687
  since = now - 7776000000;
@@ -45670,6 +45696,9 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45670
45696
  }
45671
45697
  else {
45672
45698
  if (stop) {
45699
+ if (symbol === undefined) {
45700
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchCanceledAndClosedOrders() requires a symbol argument');
45701
+ }
45673
45702
  const endTime = this.safeIntegerN(params, ['endTime', 'until', 'till']);
45674
45703
  params = this.omit(params, ['until', 'till']);
45675
45704
  if (since === undefined) {
@@ -45878,7 +45907,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45878
45907
  // }
45879
45908
  //
45880
45909
  const data = this.safeValue(response, 'data', {});
45881
- if (market['spot']) {
45910
+ if (marketType === 'spot') {
45882
45911
  if ((marginMode !== undefined) || stop) {
45883
45912
  return this.safeValue(data, 'orderList', []);
45884
45913
  }
@@ -46566,11 +46595,10 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46566
46595
  //
46567
46596
  // closeAllPositions
46568
46597
  //
46569
- // {
46570
- // "symbol": "XRPUSDT_UMCBL",
46571
- // "orderId": "1111861847410757635",
46572
- // "clientOid": "1111861847410757637"
46573
- // }
46598
+ // {
46599
+ // "orderId": "1120923953904893955",
46600
+ // "clientOid": "1120923953904893956"
46601
+ // }
46574
46602
  //
46575
46603
  const marketId = this.safeString(position, 'symbol');
46576
46604
  market = this.safeMarket(marketId, market, undefined, 'contract');
@@ -46639,7 +46667,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46639
46667
  const percentage = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringDiv(unrealizedPnl, initialMargin, 4), '100');
46640
46668
  return this.safePosition({
46641
46669
  'info': position,
46642
- 'id': undefined,
46670
+ 'id': this.safeString(position, 'orderId'),
46643
46671
  'symbol': symbol,
46644
46672
  'notional': this.parseNumber(notional),
46645
46673
  'marginMode': marginMode,
@@ -48259,65 +48287,94 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
48259
48287
  'info': info,
48260
48288
  };
48261
48289
  }
48262
- async closeAllPositions(params = {}) {
48290
+ async closePosition(symbol, side = undefined, params = {}) {
48263
48291
  /**
48264
48292
  * @method
48265
- * @name bitget#closePositions
48266
- * @description closes open positions for a market
48267
- * @see https://bitgetlimited.github.io/apidoc/en/mix/#close-all-position
48268
- * @param {object} [params] extra parameters specific to the okx api endpoint
48269
- * @param {string} [params.subType] 'linear' or 'inverse'
48270
- * @param {string} [params.settle] *required and only valid when params.subType === "linear"* 'USDT' or 'USDC'
48271
- * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
48293
+ * @name bitget#closePosition
48294
+ * @description closes an open position for a market
48295
+ * @see https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
48296
+ * @param {string} symbol unified CCXT market symbol
48297
+ * @param {string} [side] one-way mode: 'buy' or 'sell', hedge-mode: 'long' or 'short'
48298
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
48299
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
48272
48300
  */
48273
48301
  await this.loadMarkets();
48274
- let subType = undefined;
48275
- let settle = undefined;
48276
- [subType, params] = this.handleSubTypeAndParams('closeAllPositions', undefined, params);
48277
- settle = this.safeString(params, 'settle', 'USDT');
48278
- params = this.omit(params, ['settle']);
48279
- const productType = this.safeString(params, 'productType');
48280
- const request = {};
48281
- if (productType === undefined) {
48282
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
48283
- let localProductType = undefined;
48284
- if (subType === 'inverse') {
48285
- localProductType = 'dmcbl';
48286
- }
48287
- else {
48288
- if (settle === 'USDT') {
48289
- localProductType = 'umcbl';
48290
- }
48291
- else if (settle === 'USDC') {
48292
- localProductType = 'cmcbl';
48293
- }
48294
- }
48295
- if (sandboxMode) {
48296
- localProductType = 's' + localProductType;
48297
- }
48298
- request['productType'] = localProductType;
48302
+ const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
48303
+ let market = undefined;
48304
+ if (sandboxMode) {
48305
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
48306
+ market = this.market(sandboxSymbol);
48307
+ }
48308
+ else {
48309
+ market = this.market(symbol);
48310
+ }
48311
+ let productType = undefined;
48312
+ [productType, params] = this.handleProductTypeAndParams(market, params);
48313
+ const request = {
48314
+ 'symbol': market['id'],
48315
+ 'productType': productType,
48316
+ };
48317
+ if (side !== undefined) {
48318
+ request['holdSide'] = side;
48299
48319
  }
48300
- const response = await this.privateMixPostMixV1OrderCloseAllPositions(this.extend(request, params));
48320
+ const response = await this.privateMixPostV2MixOrderClosePositions(this.extend(request, params));
48301
48321
  //
48302
- // {
48303
- // "code": "00000",
48304
- // "msg": "success",
48305
- // "requestTime": 1700814442466,
48306
- // "data": {
48307
- // "orderInfo": [
48308
- // {
48309
- // "symbol": "XRPUSDT_UMCBL",
48310
- // "orderId": "1111861847410757635",
48311
- // "clientOid": "1111861847410757637"
48312
- // },
48313
- // ],
48314
- // "failure": [],
48315
- // "result": true
48316
- // }
48317
- // }
48322
+ // {
48323
+ // "code": "00000",
48324
+ // "msg": "success",
48325
+ // "requestTime": 1702975017017,
48326
+ // "data": {
48327
+ // "successList": [
48328
+ // {
48329
+ // "orderId": "1120923953904893955",
48330
+ // "clientOid": "1120923953904893956"
48331
+ // }
48332
+ // ],
48333
+ // "failureList": [],
48334
+ // "result": false
48335
+ // }
48336
+ // }
48318
48337
  //
48319
48338
  const data = this.safeValue(response, 'data', {});
48320
- const orderInfo = this.safeValue(data, 'orderInfo', []);
48339
+ const order = this.safeValue(data, 'successList', []);
48340
+ return this.parseOrder(order[0], market);
48341
+ }
48342
+ async closeAllPositions(params = {}) {
48343
+ /**
48344
+ * @method
48345
+ * @name bitget#closeAllPositions
48346
+ * @description closes all open positions for a market type
48347
+ * @see https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
48348
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
48349
+ * @param {string} [params.productType] 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
48350
+ * @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
48351
+ */
48352
+ await this.loadMarkets();
48353
+ let productType = undefined;
48354
+ [productType, params] = this.handleProductTypeAndParams(undefined, params);
48355
+ const request = {
48356
+ 'productType': productType,
48357
+ };
48358
+ const response = await this.privateMixPostV2MixOrderClosePositions(this.extend(request, params));
48359
+ //
48360
+ // {
48361
+ // "code": "00000",
48362
+ // "msg": "success",
48363
+ // "requestTime": 1702975017017,
48364
+ // "data": {
48365
+ // "successList": [
48366
+ // {
48367
+ // "orderId": "1120923953904893955",
48368
+ // "clientOid": "1120923953904893956"
48369
+ // }
48370
+ // ],
48371
+ // "failureList": [],
48372
+ // "result": false
48373
+ // }
48374
+ // }
48375
+ //
48376
+ const data = this.safeValue(response, 'data', {});
48377
+ const orderInfo = this.safeValue(data, 'successList', []);
48321
48378
  return this.parsePositions(orderInfo, undefined, params);
48322
48379
  }
48323
48380
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
@@ -61963,18 +62020,9 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
61963
62020
  const first = this.safeString(symbols, 0);
61964
62021
  const market = this.market(first);
61965
62022
  if (market['swap']) {
61966
- request['contractName'] = market['id'];
61967
- if (market['linear']) {
61968
- response = await this.fapiV1PublicGetTicker(this.extend(request, params));
61969
- }
61970
- else if (market['inverse']) {
61971
- response = await this.dapiV1PublicGetTicker(this.extend(request, params));
61972
- }
61973
- response['symbol'] = market['id'];
61974
- data = [response];
62023
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTickers does not support swap markets, please use fetchTicker instead');
61975
62024
  }
61976
62025
  else if (market['spot']) {
61977
- request['symbol'] = market['id'];
61978
62026
  response = await this.spotV1PublicGetTicker24hr(this.extend(request, params));
61979
62027
  data = response;
61980
62028
  }
@@ -61985,7 +62033,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
61985
62033
  else {
61986
62034
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', undefined, params);
61987
62035
  if (type !== 'spot') {
61988
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTickers only support spot when symbols is not set');
62036
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTickers only support spot when symbols are not proved');
61989
62037
  }
61990
62038
  response = await this.spotV1PublicGetTicker24hr(this.extend(request, params));
61991
62039
  data = response;
@@ -75194,6 +75242,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75194
75242
  'v5/account/fee-rate': 10,
75195
75243
  'v5/account/info': 5,
75196
75244
  'v5/account/transaction-log': 1,
75245
+ 'v5/account/smp-group': 1,
75197
75246
  'v5/account/mmp-state': 5,
75198
75247
  // asset
75199
75248
  'v5/asset/exchange/order-record': 5,
@@ -84430,6 +84479,8 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
84430
84479
  'brokerage/products/{product_id}',
84431
84480
  'brokerage/products/{product_id}/candles',
84432
84481
  'brokerage/products/{product_id}/ticker',
84482
+ 'brokerage/portfolios',
84483
+ 'brokerage/portfolios/{portfolio_uuid}',
84433
84484
  'brokerage/transaction_summary',
84434
84485
  'brokerage/product_book',
84435
84486
  'brokerage/best_bid_ask',
@@ -84441,9 +84492,17 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
84441
84492
  'brokerage/orders/batch_cancel',
84442
84493
  'brokerage/orders/edit',
84443
84494
  'brokerage/orders/edit_preview',
84495
+ 'brokerage/portfolios',
84496
+ 'brokerage/portfolios/move_funds',
84444
84497
  'brokerage/convert/quote',
84445
84498
  'brokerage/convert/trade/{trade_id}',
84446
84499
  ],
84500
+ 'put': [
84501
+ 'brokerage/portfolios/{portfolio_uuid}',
84502
+ ],
84503
+ 'delete': [
84504
+ 'brokerage/portfolios/{portfolio_uuid}',
84505
+ ],
84447
84506
  },
84448
84507
  },
84449
84508
  },
@@ -84499,7 +84558,9 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
84499
84558
  'invalid_scope': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError,
84500
84559
  'not_found': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
84501
84560
  'rate_limit_exceeded': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.RateLimitExceeded,
84502
- 'internal_server_error': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError, // 500 Internal server error
84561
+ 'internal_server_error': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
84562
+ 'UNSUPPORTED_ORDER_CONFIGURATION': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
84563
+ 'INSUFFICIENT_FUND': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
84503
84564
  },
84504
84565
  'broad': {
84505
84566
  'request timestamp expired': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidNonce,
@@ -86504,6 +86565,8 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
86504
86565
  params = this.omit(params, ['timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'stop_price', 'stopDirection', 'stop_direction', 'clientOrderId', 'postOnly', 'post_only', 'end_time']);
86505
86566
  const response = await this.v3PrivatePostBrokerageOrders(this.extend(request, params));
86506
86567
  //
86568
+ // successful order
86569
+ //
86507
86570
  // {
86508
86571
  // "success": true,
86509
86572
  // "failure_reason": "UNKNOWN_FAILURE_REASON",
@@ -86517,9 +86580,37 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
86517
86580
  // "order_configuration": null
86518
86581
  // }
86519
86582
  //
86583
+ // failed order
86584
+ //
86585
+ // {
86586
+ // "success": false,
86587
+ // "failure_reason": "UNKNOWN_FAILURE_REASON",
86588
+ // "order_id": "",
86589
+ // "error_response": {
86590
+ // "error": "UNSUPPORTED_ORDER_CONFIGURATION",
86591
+ // "message": "source is not enabled for trading",
86592
+ // "error_details": "",
86593
+ // "new_order_failure_reason": "UNSUPPORTED_ORDER_CONFIGURATION"
86594
+ // },
86595
+ // "order_configuration": {
86596
+ // "limit_limit_gtc": {
86597
+ // "base_size": "100",
86598
+ // "limit_price": "40000",
86599
+ // "post_only": false
86600
+ // }
86601
+ // }
86602
+ // }
86603
+ //
86520
86604
  const success = this.safeValue(response, 'success');
86521
86605
  if (success !== true) {
86522
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrder() has failed, check your arguments and parameters');
86606
+ const errorResponse = this.safeValue(response, 'error_response');
86607
+ const errorTitle = this.safeString(errorResponse, 'error');
86608
+ const errorMessage = this.safeString(errorResponse, 'message');
86609
+ if (errorResponse !== undefined) {
86610
+ this.throwExactlyMatchedException(this.exceptions['exact'], errorTitle, errorMessage);
86611
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorTitle, errorMessage);
86612
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(errorMessage);
86613
+ }
86523
86614
  }
86524
86615
  const data = this.safeValue(response, 'success_response', {});
86525
86616
  return this.parseOrder(data, market);
@@ -98969,6 +99060,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
98969
99060
  'fetchClosedOrders': false,
98970
99061
  'fetchCrossBorrowRate': false,
98971
99062
  'fetchCrossBorrowRates': false,
99063
+ 'fetchCurrencies': true,
98972
99064
  'fetchDepositAddresses': true,
98973
99065
  'fetchFundingHistory': false,
98974
99066
  'fetchFundingRate': false,
@@ -99005,6 +99097,9 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99005
99097
  'logo': 'https://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpg',
99006
99098
  'api': {
99007
99099
  'rest': 'https://api.coinone.co.kr',
99100
+ 'v2Public': 'https://api.coinone.co.kr/public/v2',
99101
+ 'v2Private': 'https://api.coinone.co.kr/v2',
99102
+ 'v2_1Private': 'https://api.coinone.co.kr/v2.1',
99008
99103
  },
99009
99104
  'www': 'https://coinone.co.kr',
99010
99105
  'doc': 'https://doc.coinone.co.kr',
@@ -99016,31 +99111,85 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99016
99111
  'api': {
99017
99112
  'public': {
99018
99113
  'get': [
99019
- 'orderbook/',
99020
- 'trades/',
99021
- 'ticker/',
99114
+ 'orderbook',
99115
+ 'ticker',
99116
+ 'ticker_utc',
99117
+ 'trades',
99118
+ ],
99119
+ },
99120
+ 'v2Public': {
99121
+ 'get': [
99122
+ 'range_units',
99123
+ 'markets/{quote_currency}',
99124
+ 'markets/{quote_currency}/{target_currency}',
99125
+ 'orderbook/{quote_currency}/{target_currency}',
99126
+ 'trades/{quote_currency}/{target_currency}',
99127
+ 'ticker_new/{quote_currency}',
99128
+ 'ticker_new/{quote_currency}/{target_currency}',
99129
+ 'ticker_utc_new/{quote_currency}',
99130
+ 'ticker_utc_new/{quote_currency}/{target_currency}',
99131
+ 'currencies',
99132
+ 'currencies/{currency}',
99133
+ 'chart/{quote_currency}/{target_currency}',
99022
99134
  ],
99023
99135
  },
99024
99136
  'private': {
99025
99137
  'post': [
99026
- 'account/deposit_address/',
99027
- 'account/btc_deposit_address/',
99028
- 'account/balance/',
99029
- 'account/daily_balance/',
99030
- 'account/user_info/',
99031
- 'account/virtual_account/',
99032
- 'order/cancel_all/',
99033
- 'order/cancel/',
99034
- 'order/limit_buy/',
99035
- 'order/limit_sell/',
99036
- 'order/complete_orders/',
99037
- 'order/limit_orders/',
99038
- 'order/query_order/',
99039
- 'transaction/auth_number/',
99040
- 'transaction/history/',
99041
- 'transaction/krw/history/',
99042
- 'transaction/btc/',
99043
- 'transaction/coin/',
99138
+ 'account/deposit_address',
99139
+ 'account/btc_deposit_address',
99140
+ 'account/balance',
99141
+ 'account/daily_balance',
99142
+ 'account/user_info',
99143
+ 'account/virtual_account',
99144
+ 'order/cancel_all',
99145
+ 'order/cancel',
99146
+ 'order/limit_buy',
99147
+ 'order/limit_sell',
99148
+ 'order/complete_orders',
99149
+ 'order/limit_orders',
99150
+ 'order/order_info',
99151
+ 'transaction/auth_number',
99152
+ 'transaction/history',
99153
+ 'transaction/krw/history',
99154
+ 'transaction/btc',
99155
+ 'transaction/coin',
99156
+ ],
99157
+ },
99158
+ 'v2Private': {
99159
+ 'post': [
99160
+ 'account/balance',
99161
+ 'account/deposit_address',
99162
+ 'account/user_info',
99163
+ 'account/virtual_account',
99164
+ 'order/cancel',
99165
+ 'order/limit_buy',
99166
+ 'order/limit_sell',
99167
+ 'order/limit_orders',
99168
+ 'order/complete_orders',
99169
+ 'order/query_order',
99170
+ 'transaction/auth_number',
99171
+ 'transaction/btc',
99172
+ 'transaction/history',
99173
+ 'transaction/krw/history',
99174
+ ],
99175
+ },
99176
+ 'v2_1Private': {
99177
+ 'post': [
99178
+ 'account/balance/all',
99179
+ 'account/balance',
99180
+ 'account/trade_fee',
99181
+ 'account/trade_fee/{quote_currency}/{target_currency}',
99182
+ 'order/limit',
99183
+ 'order/cancel',
99184
+ 'order/cancel/all',
99185
+ 'order/open_orders',
99186
+ 'order/open_orders/all',
99187
+ 'order/complete_orders',
99188
+ 'order/complete_orders/all',
99189
+ 'order/info',
99190
+ 'transaction/krw/history',
99191
+ 'transaction/coin/history',
99192
+ 'transaction/coin/withdrawal/limit',
99044
99193
  ],
99045
99194
  },
99046
99195
  },
@@ -99064,53 +99213,129 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99064
99213
  },
99065
99214
  });
99066
99215
  }
99216
+ async fetchCurrencies(params = {}) {
99217
+ /**
99218
+ * @method
99219
+ * @name coinone#fetchCurrencies
99220
+ * @description fetches all available currencies on an exchange
99221
+ * @see https://docs.coinone.co.kr/reference/currencies
99222
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
99223
+ * @returns {object} an associative dictionary of currencies
99224
+ */
99225
+ const response = await this.v2PublicGetCurrencies(params);
99226
+ //
99227
+ // {
99228
+ // "result": "success",
99229
+ // "error_code": "0",
99230
+ // "server_time": 1701054555578,
99231
+ // "currencies": [
99232
+ // {
99233
+ // "name": "Polygon",
99234
+ // "symbol": "MATIC",
99235
+ // "deposit_status": "normal",
99236
+ // "withdraw_status": "normal",
99237
+ // "deposit_confirm_count": 150,
99238
+ // "max_precision": 8,
99239
+ // "deposit_fee": "0.0",
99240
+ // "withdrawal_min_amount": "1.0",
99241
+ // "withdrawal_fee": "3.0"
99242
+ // }
99243
+ // ]
99244
+ // }
99245
+ //
99246
+ const result = {};
99247
+ const currencies = this.safeValue(response, 'currencies', []);
99248
+ for (let i = 0; i < currencies.length; i++) {
99249
+ const entry = currencies[i];
99250
+ const id = this.safeString(entry, 'symbol');
99251
+ const name = this.safeString(entry, 'name');
99252
+ const code = this.safeCurrencyCode(id);
99253
+ const withdrawStatus = this.safeString(entry, 'withdraw_status', '');
99254
+ const depositStatus = this.safeString(entry, 'deposit_status', '');
99255
+ const isWithdrawEnabled = withdrawStatus === 'normal';
99256
+ const isDepositEnabled = depositStatus === 'normal';
99257
+ result[code] = {
99258
+ 'id': id,
99259
+ 'code': code,
99260
+ 'info': entry,
99261
+ 'name': name,
99262
+ 'active': isWithdrawEnabled && isDepositEnabled,
99263
+ 'deposit': isDepositEnabled,
99264
+ 'withdraw': isWithdrawEnabled,
99265
+ 'fee': this.safeNumber(entry, 'withdrawal_fee'),
99266
+ 'precision': this.parseNumber(this.parsePrecision(this.safeString(entry, 'max_precision'))),
99267
+ 'limits': {
99268
+ 'amount': {
99269
+ 'min': undefined,
99270
+ 'max': undefined,
99271
+ },
99272
+ 'withdraw': {
99273
+ 'min': this.safeNumber(entry, 'withdrawal_min_amount'),
99274
+ 'max': undefined,
99275
+ },
99276
+ },
99277
+ 'networks': {},
99278
+ };
99279
+ }
99280
+ return result;
99281
+ }
99067
99282
  async fetchMarkets(params = {}) {
99068
99283
  /**
99069
99284
  * @method
99070
99285
  * @name coinone#fetchMarkets
99071
99286
  * @description retrieves data on all markets for coinone
99287
+ * @see https://docs.coinone.co.kr/v1.0/reference/tickers
99072
99288
  * @param {object} [params] extra parameters specific to the exchange API endpoint
99073
99289
  * @returns {object[]} an array of objects representing market data
99074
99290
  */
99075
99291
  const request = {
99076
- 'currency': 'all',
99292
+ 'quote_currency': 'KRW',
99077
99293
  };
99078
- const response = await this.publicGetTicker(request);
99294
+ const response = await this.v2PublicGetTickerNewQuoteCurrency(request);
99079
99295
  //
99080
- // {
99081
- // "result": "success",
99082
- // "errorCode": "0",
99083
- // "timestamp": "1643676668",
99084
- // "xec": {
99085
- // "currency": "xec",
99086
- // "first": "0.0914",
99087
- // "low": "0.0894",
99088
- // "high": "0.096",
99089
- // "last": "0.0937",
99090
- // "volume": "1673283662.9797",
99091
- // "yesterday_first": "0.0929",
99092
- // "yesterday_low": "0.0913",
99093
- // "yesterday_high": "0.0978",
99094
- // "yesterday_last": "0.0913",
99095
- // "yesterday_volume": "1167285865.4571"
99096
- // },
99097
- // ...
99098
- // }
99296
+ // {
99297
+ // "result": "success",
99298
+ // "error_code": "0",
99299
+ // "server_time": 1701067923060,
99300
+ // "tickers": [
99301
+ // {
99302
+ // "quote_currency": "krw",
99303
+ // "target_currency": "stg",
99304
+ // "timestamp": 1701067920001,
99305
+ // "high": "667.5",
99306
+ // "low": "667.5",
99307
+ // "first": "667.5",
99308
+ // "last": "667.5",
99309
+ // "quote_volume": "0.0",
99310
+ // "target_volume": "0.0",
99311
+ // "best_asks": [
99312
+ // {
99313
+ // "price": "777.0",
99314
+ // "qty": "73.9098"
99315
+ // }
99316
+ // ],
99317
+ // "best_bids": [
99318
+ // {
99319
+ // "price": "690.8",
99320
+ // "qty": "40.7768"
99321
+ // }
99322
+ // ],
99323
+ // "id": "1701067920001001"
99324
+ // }
99325
+ // ]
99326
+ // }
99099
99327
  //
99328
+ const tickers = this.safeValue(response, 'tickers', []);
99100
99329
  const result = [];
99101
- const quoteId = 'krw';
99102
- const quote = this.safeCurrencyCode(quoteId);
99103
- const baseIds = Object.keys(response);
99104
- for (let i = 0; i < baseIds.length; i++) {
99105
- const baseId = baseIds[i];
99106
- const ticker = this.safeValue(response, baseId, {});
99107
- const currency = this.safeValue(ticker, 'currency');
99108
- if (currency === undefined) {
99109
- continue;
99110
- }
99330
+ for (let i = 0; i < tickers.length; i++) {
99331
+ const entry = this.safeValue(tickers, i);
99332
+ const id = this.safeString(entry, 'id');
99333
+ const baseId = this.safeStringUpper(entry, 'target_currency');
99334
+ const quoteId = this.safeStringUpper(entry, 'quote_currency');
99111
99335
  const base = this.safeCurrencyCode(baseId);
99336
+ const quote = this.safeCurrencyCode(quoteId);
99112
99337
  result.push({
99113
- 'id': baseId,
99338
+ 'id': id,
99114
99339
  'symbol': base + '/' + quote,
99115
99340
  'base': base,
99116
99341
  'quote': quote,
@@ -99157,7 +99382,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99157
99382
  },
99158
99383
  },
99159
99384
  'created': undefined,
99160
- 'info': ticker,
99385
+ 'info': entry,
99161
99386
  });
99162
99387
  }
99163
99388
  return result;
@@ -99186,11 +99411,12 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99186
99411
  * @method
99187
99412
  * @name coinone#fetchBalance
99188
99413
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
99414
+ * @see https://docs.coinone.co.kr/v1.0/reference/v21
99189
99415
  * @param {object} [params] extra parameters specific to the exchange API endpoint
99190
99416
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
99191
99417
  */
99192
99418
  await this.loadMarkets();
99193
- const response = await this.privatePostAccountBalance(params);
99419
+ const response = await this.v2PrivatePostAccountBalance(params);
99194
99420
  return this.parseBalance(response);
99195
99421
  }
99196
99422
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
@@ -99198,6 +99424,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99198
99424
  * @method
99199
99425
  * @name coinone#fetchOrderBook
99200
99426
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
99427
+ * @see https://docs.coinone.co.kr/v1.0/reference/orderbook
99201
99428
  * @param {string} symbol unified symbol of the market to fetch the order book for
99202
99429
  * @param {int} [limit] the maximum amount of order book entries to return
99203
99430
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -99206,18 +99433,46 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99206
99433
  await this.loadMarkets();
99207
99434
  const market = this.market(symbol);
99208
99435
  const request = {
99209
- 'currency': market['id'],
99210
- 'format': 'json',
99436
+ 'quote_currency': market['quote'],
99437
+ 'target_currency': market['base'],
99211
99438
  };
99212
- const response = await this.publicGetOrderbook(this.extend(request, params));
99213
- const timestamp = this.safeTimestamp(response, 'timestamp');
99214
- return this.parseOrderBook(response, market['symbol'], timestamp, 'bid', 'ask', 'price', 'qty');
99439
+ if (limit !== undefined) {
99440
+ request['size'] = limit; // only support 5, 10, 15, 16
99441
+ }
99442
+ const response = await this.v2PublicGetOrderbookQuoteCurrencyTargetCurrency(this.extend(request, params));
99443
+ //
99444
+ // {
99445
+ // "result": "success",
99446
+ // "error_code": "0",
99447
+ // "timestamp": 1701071108673,
99448
+ // "id": "1701071108673001",
99449
+ // "quote_currency": "KRW",
99450
+ // "target_currency": "BTC",
99451
+ // "order_book_unit": "0.0",
99452
+ // "bids": [
99453
+ // {
99454
+ // "price": "50048000",
99455
+ // "qty": "0.01080229"
99456
+ // }
99457
+ // ],
99458
+ // "asks": [
99459
+ // {
99460
+ // "price": "50058000",
99461
+ // "qty": "0.00272592"
99462
+ // }
99463
+ // ]
99464
+ // }
99465
+ //
99466
+ const timestamp = this.safeInteger(response, 'timestamp');
99467
+ return this.parseOrderBook(response, market['symbol'], timestamp, 'bids', 'asks', 'price', 'qty');
99215
99468
  }
99216
99469
  async fetchTickers(symbols = undefined, params = {}) {
99217
99470
  /**
99218
99471
  * @method
99219
99472
  * @name coinone#fetchTickers
99220
99473
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
99474
+ * @see https://docs.coinone.co.kr/v1.0/reference/tickers
99475
+ * @see https://docs.coinone.co.kr/v1.0/reference/ticker
99221
99476
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
99222
99477
  * @param {object} [params] extra parameters specific to the exchange API endpoint
99223
99478
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -99225,28 +99480,62 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99225
99480
  await this.loadMarkets();
99226
99481
  symbols = this.marketSymbols(symbols);
99227
99482
  const request = {
99228
- 'currency': 'all',
99229
- 'format': 'json',
99483
+ 'quote_currency': 'KRW',
99230
99484
  };
99231
- const response = await this.publicGetTicker(this.extend(request, params));
99232
- const result = {};
99233
- const ids = Object.keys(response);
99234
- const timestamp = this.safeTimestamp(response, 'timestamp');
99235
- for (let i = 0; i < ids.length; i++) {
99236
- const id = ids[i];
99237
- const market = this.safeMarket(id);
99238
- const symbol = market['symbol'];
99239
- const ticker = response[id];
99240
- result[symbol] = this.parseTicker(ticker, market);
99241
- result[symbol]['timestamp'] = timestamp;
99485
+ let market = undefined;
99486
+ let response = undefined;
99487
+ if (symbols !== undefined) {
99488
+ const first = this.safeString(symbols, 0);
99489
+ market = this.market(first);
99490
+ request['quote_currency'] = market['quote'];
99491
+ request['target_currency'] = market['base'];
99492
+ response = await this.v2PublicGetTickerNewQuoteCurrencyTargetCurrency(this.extend(request, params));
99242
99493
  }
99243
- return this.filterByArrayTickers(result, 'symbol', symbols);
99494
+ else {
99495
+ response = await this.v2PublicGetTickerNewQuoteCurrency(this.extend(request, params));
99496
+ }
99497
+ //
99498
+ // {
99499
+ // "result": "success",
99500
+ // "error_code": "0",
99501
+ // "server_time": 1701073358487,
99502
+ // "tickers": [
99503
+ // {
99504
+ // "quote_currency": "krw",
99505
+ // "target_currency": "btc",
99506
+ // "timestamp": 1701073357818,
99507
+ // "high": "50543000.0",
99508
+ // "low": "49945000.0",
99509
+ // "first": "50487000.0",
99510
+ // "last": "50062000.0",
99511
+ // "quote_volume": "11349804285.3859",
99512
+ // "target_volume": "226.07268994",
99513
+ // "best_asks": [
99514
+ // {
99515
+ // "price": "50081000.0",
99516
+ // "qty": "0.18471358"
99517
+ // }
99518
+ // ],
99519
+ // "best_bids": [
99520
+ // {
99521
+ // "price": "50062000.0",
99522
+ // "qty": "0.04213455"
99523
+ // }
99524
+ // ],
99525
+ // "id": "1701073357818001"
99526
+ // }
99527
+ // ]
99528
+ // }
99529
+ //
99530
+ const data = this.safeValue(response, 'tickers', []);
99531
+ return this.parseTickers(data, symbols);
99244
99532
  }
99245
99533
  async fetchTicker(symbol, params = {}) {
99246
99534
  /**
99247
99535
  * @method
99248
99536
  * @name coinone#fetchTicker
99249
99537
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
99538
+ * @see https://docs.coinone.co.kr/v1.0/reference/ticker
99250
99539
  * @param {string} symbol unified symbol of the market to fetch the ticker for
99251
99540
  * @param {object} [params] extra parameters specific to the exchange API endpoint
99252
99541
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -99254,53 +99543,102 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99254
99543
  await this.loadMarkets();
99255
99544
  const market = this.market(symbol);
99256
99545
  const request = {
99257
- 'currency': market['id'],
99258
- 'format': 'json',
99546
+ 'quote_currency': market['quote'],
99547
+ 'target_currency': market['base'],
99259
99548
  };
99260
- const response = await this.publicGetTicker(this.extend(request, params));
99261
- return this.parseTicker(response, market);
99549
+ const response = await this.v2PublicGetTickerNewQuoteCurrencyTargetCurrency(this.extend(request, params));
99550
+ //
99551
+ // {
99552
+ // "result": "success",
99553
+ // "error_code": "0",
99554
+ // "server_time": 1701073358487,
99555
+ // "tickers": [
99556
+ // {
99557
+ // "quote_currency": "krw",
99558
+ // "target_currency": "btc",
99559
+ // "timestamp": 1701073357818,
99560
+ // "high": "50543000.0",
99561
+ // "low": "49945000.0",
99562
+ // "first": "50487000.0",
99563
+ // "last": "50062000.0",
99564
+ // "quote_volume": "11349804285.3859",
99565
+ // "target_volume": "226.07268994",
99566
+ // "best_asks": [
99567
+ // {
99568
+ // "price": "50081000.0",
99569
+ // "qty": "0.18471358"
99570
+ // }
99571
+ // ],
99572
+ // "best_bids": [
99573
+ // {
99574
+ // "price": "50062000.0",
99575
+ // "qty": "0.04213455"
99576
+ // }
99577
+ // ],
99578
+ // "id": "1701073357818001"
99579
+ // }
99580
+ // ]
99581
+ // }
99582
+ //
99583
+ const data = this.safeValue(response, 'tickers', []);
99584
+ const ticker = this.safeValue(data, 0, {});
99585
+ return this.parseTicker(ticker, market);
99262
99586
  }
99263
99587
  parseTicker(ticker, market = undefined) {
99264
99588
  //
99265
99589
  // {
99266
- // "currency":"xec",
99267
- // "first":"0.1069",
99268
- // "low":"0.09",
99269
- // "high":"0.1069",
99270
- // "last":"0.0911",
99271
- // "volume":"4591217267.4974",
99272
- // "yesterday_first":"0.1128",
99273
- // "yesterday_low":"0.1035",
99274
- // "yesterday_high":"0.1167",
99275
- // "yesterday_last":"0.1069",
99276
- // "yesterday_volume":"4014832231.5102"
99590
+ // "quote_currency": "krw",
99591
+ // "target_currency": "btc",
99592
+ // "timestamp": 1701073357818,
99593
+ // "high": "50543000.0",
99594
+ // "low": "49945000.0",
99595
+ // "first": "50487000.0",
99596
+ // "last": "50062000.0",
99597
+ // "quote_volume": "11349804285.3859",
99598
+ // "target_volume": "226.07268994",
99599
+ // "best_asks": [
99600
+ // {
99601
+ // "price": "50081000.0",
99602
+ // "qty": "0.18471358"
99603
+ // }
99604
+ // ],
99605
+ // "best_bids": [
99606
+ // {
99607
+ // "price": "50062000.0",
99608
+ // "qty": "0.04213455"
99609
+ // }
99610
+ // ],
99611
+ // "id": "1701073357818001"
99277
99612
  // }
99278
99613
  //
99279
- const timestamp = this.safeTimestamp(ticker, 'timestamp');
99280
- const open = this.safeString(ticker, 'first');
99614
+ const timestamp = this.safeInteger(ticker, 'timestamp');
99281
99615
  const last = this.safeString(ticker, 'last');
99282
- const previousClose = this.safeString(ticker, 'yesterday_last');
99283
- const symbol = this.safeSymbol(undefined, market);
99616
+ const asks = this.safeValue(ticker, 'best_asks');
99617
+ const bids = this.safeValue(ticker, 'best_bids');
99618
+ const baseId = this.safeString(ticker, 'target_currency');
99619
+ const quoteId = this.safeString(ticker, 'quote_currency');
99620
+ const base = this.safeCurrencyCode(baseId);
99621
+ const quote = this.safeCurrencyCode(quoteId);
99284
99622
  return this.safeTicker({
99285
- 'symbol': symbol,
99623
+ 'symbol': base + '/' + quote,
99286
99624
  'timestamp': timestamp,
99287
99625
  'datetime': this.iso8601(timestamp),
99288
99626
  'high': this.safeString(ticker, 'high'),
99289
99627
  'low': this.safeString(ticker, 'low'),
99290
- 'bid': undefined,
99291
- 'bidVolume': undefined,
99292
- 'ask': undefined,
99293
- 'askVolume': undefined,
99628
+ 'bid': this.safeString(bids, 'price'),
99629
+ 'bidVolume': this.safeString(bids, 'qty'),
99630
+ 'ask': this.safeString(asks, 'price'),
99631
+ 'askVolume': this.safeString(asks, 'qty'),
99294
99632
  'vwap': undefined,
99295
- 'open': open,
99633
+ 'open': this.safeString(ticker, 'first'),
99296
99634
  'close': last,
99297
99635
  'last': last,
99298
- 'previousClose': previousClose,
99636
+ 'previousClose': undefined,
99299
99637
  'change': undefined,
99300
99638
  'percentage': undefined,
99301
99639
  'average': undefined,
99302
- 'baseVolume': this.safeString(ticker, 'volume'),
99303
- 'quoteVolume': undefined,
99640
+ 'baseVolume': this.safeString(ticker, 'target_volume'),
99641
+ 'quoteVolume': this.safeString(ticker, 'quote_volume'),
99304
99642
  'info': ticker,
99305
99643
  }, market);
99306
99644
  }
@@ -99309,10 +99647,11 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99309
99647
  // fetchTrades (public)
99310
99648
  //
99311
99649
  // {
99312
- // "timestamp": "1416893212",
99313
- // "price": "420000.0",
99314
- // "qty": "0.1",
99315
- // "is_ask": "1"
99650
+ // "id": "1701075265708001",
99651
+ // "timestamp": 1701075265708,
99652
+ // "price": "50020000",
99653
+ // "qty": "0.00155177",
99654
+ // "is_seller_maker": false
99316
99655
  // }
99317
99656
  //
99318
99657
  // fetchMyTrades (private)
@@ -99327,25 +99666,12 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99327
99666
  // "orderId": "E84A1AC2-8088-4FA0-B093-A3BCDB9B3C85"
99328
99667
  // }
99329
99668
  //
99330
- const timestamp = this.safeTimestamp(trade, 'timestamp');
99669
+ const timestamp = this.safeInteger(trade, 'timestamp');
99331
99670
  market = this.safeMarket(undefined, market);
99332
- const is_ask = this.safeString(trade, 'is_ask');
99333
- let side = this.safeString(trade, 'type');
99334
- if (is_ask !== undefined) {
99335
- if (is_ask === '1') {
99336
- side = 'sell';
99337
- }
99338
- else if (is_ask === '0') {
99339
- side = 'buy';
99340
- }
99341
- }
99342
- else {
99343
- if (side === 'ask') {
99344
- side = 'sell';
99345
- }
99346
- else if (side === 'bid') {
99347
- side = 'buy';
99348
- }
99671
+ const isSellerMaker = this.safeValue(trade, 'is_seller_maker');
99672
+ let side = undefined;
99673
+ if (isSellerMaker !== undefined) {
99674
+ side = isSellerMaker ? 'sell' : 'buy';
99349
99675
  }
99350
99676
  const priceString = this.safeString(trade, 'price');
99351
99677
  const amountString = this.safeString(trade, 'qty');
@@ -99384,6 +99710,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99384
99710
  * @method
99385
99711
  * @name coinone#fetchTrades
99386
99712
  * @description get the list of most recent trades for a particular symbol
99713
+ * @see https://docs.coinone.co.kr/v1.0/reference/recent-completed-orders
99387
99714
  * @param {string} symbol unified symbol of the market to fetch trades for
99388
99715
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
99389
99716
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -99393,28 +99720,33 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99393
99720
  await this.loadMarkets();
99394
99721
  const market = this.market(symbol);
99395
99722
  const request = {
99396
- 'currency': market['id'],
99397
- 'format': 'json',
99723
+ 'quote_currency': market['quote'],
99724
+ 'target_currency': market['base'],
99398
99725
  };
99399
- const response = await this.publicGetTrades(this.extend(request, params));
99726
+ if (limit !== undefined) {
99727
+ request['size'] = limit; // only support 10, 50, 100, 150, 200
99728
+ }
99729
+ const response = await this.v2PublicGetTradesQuoteCurrencyTargetCurrency(this.extend(request, params));
99400
99730
  //
99401
99731
  // {
99402
99732
  // "result": "success",
99403
- // "errorCode": "0",
99404
- // "timestamp": "1416895635",
99405
- // "currency": "btc",
99406
- // "completeOrders": [
99733
+ // "error_code": "0",
99734
+ // "server_time": 1701075315771,
99735
+ // "quote_currency": "KRW",
99736
+ // "target_currency": "BTC",
99737
+ // "transactions": [
99407
99738
  // {
99408
- // "timestamp": "1416893212",
99409
- // "price": "420000.0",
99410
- // "qty": "0.1",
99411
- // "is_ask": "1"
99739
+ // "id": "1701075265708001",
99740
+ // "timestamp": 1701075265708,
99741
+ // "price": "50020000",
99742
+ // "qty": "0.00155177",
99743
+ // "is_seller_maker": false
99412
99744
  // }
99413
99745
  // ]
99414
99746
  // }
99415
99747
  //
99416
- const completeOrders = this.safeValue(response, 'completeOrders', []);
99417
- return this.parseTrades(completeOrders, market, since, limit);
99748
+ const data = this.safeValue(response, 'transactions', []);
99749
+ return this.parseTrades(data, market, since, limit);
99418
99750
  }
99419
99751
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
99420
99752
  /**
@@ -99470,7 +99802,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99470
99802
  'order_id': id,
99471
99803
  'currency': market['id'],
99472
99804
  };
99473
- const response = await this.privatePostOrderQueryOrder(this.extend(request, params));
99805
+ const response = await this.v2PrivatePostOrderQueryOrder(this.extend(request, params));
99474
99806
  //
99475
99807
  // {
99476
99808
  // "result": "success",
@@ -99681,7 +100013,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99681
100013
  const request = {
99682
100014
  'currency': market['id'],
99683
100015
  };
99684
- const response = await this.privatePostOrderCompleteOrders(this.extend(request, params));
100016
+ const response = await this.v2PrivatePostOrderCompleteOrders(this.extend(request, params));
99685
100017
  //
99686
100018
  // despite the name of the endpoint it returns trades which may have a duplicate orderId
99687
100019
  // https://github.com/ccxt/ccxt/pull/7067
@@ -99734,7 +100066,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99734
100066
  'is_ask': isAsk,
99735
100067
  'currency': this.marketId(symbol),
99736
100068
  };
99737
- const response = await this.privatePostOrderCancel(this.extend(request, params));
100069
+ const response = await this.v2PrivatePostOrderCancel(this.extend(request, params));
99738
100070
  //
99739
100071
  // {
99740
100072
  // "result": "success",
@@ -99753,7 +100085,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99753
100085
  * @returns {object} a list of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}
99754
100086
  */
99755
100087
  await this.loadMarkets();
99756
- const response = await this.privatePostAccountDepositAddress(params);
100088
+ const response = await this.v2PrivatePostAccountDepositAddress(params);
99757
100089
  //
99758
100090
  // {
99759
100091
  // "result": "success",
@@ -99806,6 +100138,16 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99806
100138
  const request = this.implodeParams(path, params);
99807
100139
  const query = this.omit(params, this.extractParams(path));
99808
100140
  let url = this.urls['api']['rest'] + '/';
100141
+ if (api === 'v2Public') {
100142
+ url = this.urls['api']['v2Public'] + '/';
100143
+ api = 'public';
100144
+ }
100145
+ else if (api === 'v2Private') {
100146
+ url = this.urls['api']['v2Private'] + '/';
100147
+ }
100148
+ else if (api === 'v2_1Private') {
100149
+ url = this.urls['api']['v2_1Private'] + '/';
100150
+ }
99809
100151
  if (api === 'public') {
99810
100152
  url += request;
99811
100153
  if (Object.keys(query).length) {
@@ -99814,7 +100156,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
99814
100156
  }
99815
100157
  else {
99816
100158
  this.checkRequiredCredentials();
99817
- url += this.version + '/' + request;
100159
+ url += request;
99818
100160
  const nonce = this.nonce().toString();
99819
100161
  const json = this.json(this.extend({
99820
100162
  'access_token': this.apiKey,
@@ -129867,6 +130209,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
129867
130209
  'addMargin': true,
129868
130210
  'cancelAllOrders': true,
129869
130211
  'cancelOrder': true,
130212
+ 'closePosition': false,
129870
130213
  'createDepositAddress': true,
129871
130214
  'createOrder': true,
129872
130215
  'createPostOnlyOrder': true,
@@ -132706,6 +133049,9 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
132706
133049
  let marketType = undefined;
132707
133050
  let marginMode = undefined;
132708
133051
  [marketType, params] = this.handleMarketTypeAndParams('fetchPositions', undefined, params);
133052
+ if (marketType === 'spot') {
133053
+ marketType = 'swap';
133054
+ }
132709
133055
  [marginMode, params] = this.handleMarginModeAndParams('fetchPositions', params);
132710
133056
  params = this.omit(params, ['marginMode', 'margin']);
132711
133057
  let response = undefined;
@@ -133364,6 +133710,43 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
133364
133710
  }
133365
133711
  return result;
133366
133712
  }
133713
+ async closePosition(symbol, side = undefined, params = {}) {
133714
+ /**
133715
+ * @method
133716
+ * @name hitbtc#closePosition
133717
+ * @description closes open positions for a market
133718
+ * @see https://api.hitbtc.com/#close-all-futures-margin-positions
133719
+ * @param {object} [params] extra parameters specific to the okx api endpoint
133720
+ * @param {string} [params.symbol] *required* unified market symbol
133721
+ * @param {string} [params.marginMode] 'cross' or 'isolated', default is 'cross'
133722
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
133723
+ */
133724
+ await this.loadMarkets();
133725
+ let marginMode = undefined;
133726
+ [marginMode, params] = this.handleMarginModeAndParams('closePosition', params, 'cross');
133727
+ const market = this.market(symbol);
133728
+ const request = {
133729
+ 'symbol': market['id'],
133730
+ 'margin_mode': marginMode,
133731
+ };
133732
+ const response = await this.privateDeleteFuturesPositionMarginModeSymbol(this.extend(request, params));
133733
+ //
133734
+ // {
133735
+ // "id":"202471640",
133736
+ // "symbol":"TRXUSDT_PERP",
133737
+ // "margin_mode":"Cross",
133738
+ // "leverage":"1.00",
133739
+ // "quantity":"0",
133740
+ // "price_entry":"0",
133741
+ // "price_margin_call":"0",
133742
+ // "price_liquidation":"0",
133743
+ // "pnl":"0.001234100000",
133744
+ // "created_at":"2023-10-29T14:46:13.235Z",
133745
+ // "updated_at":"2023-12-19T09:34:40.014Z"
133746
+ // }
133747
+ //
133748
+ return this.parseOrder(response, market);
133749
+ }
133367
133750
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
133368
133751
  /**
133369
133752
  * @ignore
@@ -159470,14 +159853,14 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159470
159853
  'addMargin': true,
159471
159854
  'cancelAllOrders': true,
159472
159855
  'cancelOrder': true,
159856
+ 'closePosition': true,
159857
+ 'closePositions': false,
159473
159858
  'createDepositAddress': true,
159474
159859
  'createOrder': true,
159475
159860
  'createReduceOnlyOrder': true,
159476
159861
  'createStopLimitOrder': true,
159477
159862
  'createStopMarketOrder': true,
159478
159863
  'createStopOrder': true,
159479
- 'closePosition': true,
159480
- 'closePositions': false,
159481
159864
  'fetchAccounts': true,
159482
159865
  'fetchBalance': true,
159483
159866
  'fetchBorrowRateHistories': false,
@@ -159592,6 +159975,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159592
159975
  'positions': 4.44,
159593
159976
  'funding-history': 4.44,
159594
159977
  'sub/api-key': 1,
159978
+ 'trade-statistics': 1,
159595
159979
  },
159596
159980
  'post': {
159597
159981
  'withdrawals': 1,
@@ -159613,6 +159997,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
159613
159997
  'orders': 4.44,
159614
159998
  'stopOrders': 1,
159615
159999
  'sub/api-key': 1,
160000
+ 'orders/client-order/{clientOid}': 1,
159616
160001
  },
159617
160002
  },
159618
160003
  'webExchange': {
@@ -160675,13 +161060,27 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
160675
161060
  * @param {string} id order id
160676
161061
  * @param {string} symbol unified symbol of the market the order was made in
160677
161062
  * @param {object} [params] extra parameters specific to the exchange API endpoint
161063
+ * @param {string} [params.clientOrderId] cancel order by client order id
160678
161064
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
160679
161065
  */
160680
161066
  await this.loadMarkets();
160681
- const request = {
160682
- 'orderId': id,
160683
- };
160684
- const response = await this.futuresPrivateDeleteOrdersOrderId(this.extend(request, params));
161067
+ const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
161068
+ params = this.omit(params, ['clientOrderId']);
161069
+ const request = {};
161070
+ let response = undefined;
161071
+ if (clientOrderId !== undefined) {
161072
+ if (symbol === undefined) {
161073
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument when cancelling by clientOrderId');
161074
+ }
161075
+ const market = this.market(symbol);
161076
+ request['symbol'] = market['id'];
161077
+ request['clientOid'] = clientOrderId;
161078
+ response = await this.futuresPrivateDeleteOrdersClientOrderClientOid(this.extend(request, params));
161079
+ }
161080
+ else {
161081
+ request['orderId'] = id;
161082
+ response = await this.futuresPrivateDeleteOrdersOrderId(this.extend(request, params));
161083
+ }
160685
161084
  //
160686
161085
  // {
160687
161086
  // "code": "200000",
@@ -185494,6 +185893,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
185494
185893
  // rfq
185495
185894
  'rfq/counterparties': 4,
185496
185895
  'rfq/maker-instrument-settings': 4,
185896
+ 'rfq/mmp-config': 4,
185497
185897
  'rfq/rfqs': 10,
185498
185898
  'rfq/quotes': 10,
185499
185899
  'rfq/trades': 4,
@@ -185633,6 +186033,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
185633
186033
  'rfq/execute-quote': 15,
185634
186034
  'rfq/maker-instrument-settings': 4,
185635
186035
  'rfq/mmp-reset': 4,
186036
+ 'rfq/mmp-config': 100,
185636
186037
  'rfq/create-quote': 0.4,
185637
186038
  'rfq/cancel-quote': 0.4,
185638
186039
  'rfq/cancel-batch-quotes': 10,
@@ -207880,10 +208281,12 @@ class binanceusdm extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
207880
208281
  /* harmony import */ var _bingx_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7960);
207881
208282
  /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
207882
208283
  /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3020);
208284
+ /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2194);
207883
208285
  // ---------------------------------------------------------------------------
207884
208286
 
207885
208287
 
207886
208288
 
208289
+
207887
208290
  // ---------------------------------------------------------------------------
207888
208291
  class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
207889
208292
  describe() {
@@ -207939,6 +208342,10 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
207939
208342
  '1d': '1day',
207940
208343
  },
207941
208344
  },
208345
+ 'watchBalance': {
208346
+ 'fetchBalanceSnapshot': true,
208347
+ 'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
208348
+ },
207942
208349
  },
207943
208350
  'streaming': {
207944
208351
  'keepAlive': 1800000, // 30 minutes
@@ -208426,8 +208833,41 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208426
208833
  'dataType': 'ACCOUNT_UPDATE',
208427
208834
  };
208428
208835
  }
208836
+ const client = this.client(url);
208837
+ this.setBalanceCache(client, type, subscriptionHash, params);
208838
+ let fetchBalanceSnapshot = undefined;
208839
+ let awaitBalanceSnapshot = undefined;
208840
+ [fetchBalanceSnapshot, params] = this.handleOptionAndParams(params, 'watchBalance', 'fetchBalanceSnapshot', true);
208841
+ [awaitBalanceSnapshot, params] = this.handleOptionAndParams(params, 'watchBalance', 'awaitBalanceSnapshot', false);
208842
+ if (fetchBalanceSnapshot && awaitBalanceSnapshot) {
208843
+ await client.future(type + ':fetchBalanceSnapshot');
208844
+ }
208429
208845
  return await this.watch(url, messageHash, request, subscriptionHash);
208430
208846
  }
208847
+ setBalanceCache(client, type, subscriptionHash, params) {
208848
+ if (subscriptionHash in client.subscriptions) {
208849
+ return undefined;
208850
+ }
208851
+ const fetchBalanceSnapshot = this.handleOptionAndParams(params, 'watchBalance', 'fetchBalanceSnapshot', true);
208852
+ if (fetchBalanceSnapshot) {
208853
+ const messageHash = type + ':fetchBalanceSnapshot';
208854
+ if (!(messageHash in client.futures)) {
208855
+ client.future(messageHash);
208856
+ this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
208857
+ }
208858
+ }
208859
+ else {
208860
+ this.balance[type] = {};
208861
+ }
208862
+ }
208863
+ async loadBalanceSnapshot(client, messageHash, type) {
208864
+ const response = await this.fetchBalance({ 'type': type });
208865
+ this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
208866
+ // don't remove the future from the .futures cache
208867
+ const future = client.futures[messageHash];
208868
+ future.resolve();
208869
+ client.resolve(this.balance[type], type + ':balance');
208870
+ }
208431
208871
  handleErrorMessage(client, message) {
208432
208872
  //
208433
208873
  // { code: 100400, msg: '', timestamp: 1696245808833 }
@@ -208710,9 +209150,6 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208710
209150
  const data = this.safeValue(a, 'B', []);
208711
209151
  const timestamp = this.safeInteger2(message, 'T', 'E');
208712
209152
  const type = ('P' in a) ? 'swap' : 'spot';
208713
- if (!(type in this.balance)) {
208714
- this.balance[type] = {};
208715
- }
208716
209153
  this.balance[type]['info'] = data;
208717
209154
  this.balance[type]['timestamp'] = timestamp;
208718
209155
  this.balance[type]['datetime'] = this.iso8601(timestamp);
@@ -208720,8 +209157,12 @@ class bingx extends _bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
208720
209157
  const balance = data[i];
208721
209158
  const currencyId = this.safeString(balance, 'a');
208722
209159
  const code = this.safeCurrencyCode(currencyId);
208723
- const account = (code in this.balance) ? this.balance[code] : this.account();
208724
- account['total'] = this.safeString(balance, 'wb');
209160
+ const account = (code in this.balance[type]) ? this.balance[type][code] : this.account();
209161
+ account['free'] = this.safeString(balance, 'wb');
209162
+ const balanceChange = this.safeString(balance, 'bc');
209163
+ if (account['used'] !== undefined) {
209164
+ account['used'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.stringSub(this.safeString(account, 'used'), balanceChange);
209165
+ }
208725
209166
  this.balance[type][code] = account;
208726
209167
  }
208727
209168
  this.balance[type] = this.safeBalance(this.balance[type]);
@@ -287994,7 +288435,7 @@ SOFTWARE.
287994
288435
 
287995
288436
  //-----------------------------------------------------------------------------
287996
288437
  // this is updated by vss.js when building
287997
- const version = '4.1.91';
288438
+ const version = '4.1.95';
287998
288439
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
287999
288440
  //-----------------------------------------------------------------------------
288000
288441