ccxt 4.0.85 → 4.0.87

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
@@ -215,13 +215,13 @@ console.log(version, Object.keys(exchanges));
215
215
 
216
216
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
217
217
 
218
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.85/dist/ccxt.browser.js
219
- * unpkg: https://unpkg.com/ccxt@4.0.85/dist/ccxt.browser.js
218
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.0.87/dist/ccxt.browser.js
219
+ * unpkg: https://unpkg.com/ccxt@4.0.87/dist/ccxt.browser.js
220
220
 
221
221
  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.
222
222
 
223
223
  ```HTML
224
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.85/dist/ccxt.browser.js"></script>
224
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.0.87/dist/ccxt.browser.js"></script>
225
225
  ```
226
226
 
227
227
  Creates a global `ccxt` object:
@@ -37243,6 +37243,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
37243
37243
  'market/candles': 1,
37244
37244
  'market/depth': 1,
37245
37245
  'market/spot-vip-level': 2,
37246
+ 'market/merge-depth': 1,
37246
37247
  'market/history-candles': 1,
37247
37248
  'public/loan/coinInfos': 2,
37248
37249
  'public/loan/hour-interest': 2, // 10 times/1s (IP) => 20/10 = 2
@@ -37270,6 +37271,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
37270
37271
  'market/history-candles': 1,
37271
37272
  'market/history-index-candles': 1,
37272
37273
  'market/history-mark-candles': 1,
37274
+ 'market/merge-depth': 1,
37273
37275
  },
37274
37276
  },
37275
37277
  'margin': {
@@ -39658,6 +39660,8 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39658
39660
  /**
39659
39661
  * @method
39660
39662
  * @name bitget#fetchBalance
39663
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-account-assets
39664
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-account-list
39661
39665
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
39662
39666
  * @param {object} [params] extra parameters specific to the bitget api endpoint
39663
39667
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
@@ -39722,13 +39726,32 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39722
39726
  parseBalance(balance) {
39723
39727
  const result = { 'info': balance };
39724
39728
  //
39729
+ // spot
39730
+ //
39731
+ // {
39732
+ // coinId: '1',
39733
+ // coinName: 'BTC',
39734
+ // available: '0.00099900',
39735
+ // frozen: '0.00000000',
39736
+ // lock: '0.00000000',
39737
+ // uTime: '1661595535000'
39738
+ // }
39739
+ //
39740
+ // swap
39741
+ //
39725
39742
  // {
39726
- // coinId: '1',
39727
- // coinName: 'BTC',
39728
- // available: '0.00099900',
39729
- // frozen: '0.00000000',
39730
- // lock: '0.00000000',
39731
- // uTime: '1661595535000'
39743
+ // marginCoin: 'BTC',
39744
+ // locked: '0.00001948',
39745
+ // available: '0.00006622',
39746
+ // crossMaxAvailable: '0.00004674',
39747
+ // fixedMaxAvailable: '0.00004674',
39748
+ // maxTransferOut: '0.00004674',
39749
+ // equity: '0.00006622',
39750
+ // usdtEquity: '1.734307497491',
39751
+ // btcEquity: '0.000066229058',
39752
+ // crossRiskRate: '0.066308887072',
39753
+ // unrealizedPL: '0',
39754
+ // bonus: '0'
39732
39755
  // }
39733
39756
  //
39734
39757
  for (let i = 0; i < balance.length; i++) {
@@ -39736,10 +39759,12 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39736
39759
  const currencyId = this.safeString2(entry, 'coinName', 'marginCoin');
39737
39760
  const code = this.safeCurrencyCode(currencyId);
39738
39761
  const account = this.account();
39762
+ const spotAccountFree = this.safeString(entry, 'available');
39763
+ const contractAccountFree = this.safeString(entry, 'maxTransferOut');
39764
+ account['free'] = (contractAccountFree !== undefined) ? contractAccountFree : spotAccountFree;
39739
39765
  const frozen = this.safeString(entry, 'frozen');
39740
39766
  const locked = this.safeString2(entry, 'lock', 'locked');
39741
39767
  account['used'] = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringAdd */ .O.stringAdd(frozen, locked);
39742
- account['free'] = this.safeString(entry, 'available');
39743
39768
  result[code] = account;
39744
39769
  }
39745
39770
  return this.safeBalance(result);
@@ -114353,6 +114378,19 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
114353
114378
  // "commission_percent": "0.2"
114354
114379
  // }
114355
114380
  //
114381
+ // margin
114382
+ //
114383
+ // {
114384
+ // "is_maker": false,
114385
+ // "order_id": "123",
114386
+ // "pair": "BTC_USD",
114387
+ // "price": "54122.25",
114388
+ // "quantity": "0.00069994",
114389
+ // "trade_dt": "1619069561718824428",
114390
+ // "trade_id": "692842802860135010",
114391
+ // "type": "sell"
114392
+ // }
114393
+ //
114356
114394
  const timestamp = this.safeTimestamp(trade, 'date');
114357
114395
  const id = this.safeString(trade, 'trade_id');
114358
114396
  const orderId = this.safeString(trade, 'order_id');
@@ -114364,7 +114402,12 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
114364
114402
  const marketId = this.safeString(trade, 'pair');
114365
114403
  market = this.safeMarket(marketId, market, '_');
114366
114404
  const symbol = market['symbol'];
114367
- const takerOrMaker = this.safeString(trade, 'exec_type');
114405
+ const isMaker = this.safeValue(trade, 'is_maker');
114406
+ let takerOrMakerDefault = undefined;
114407
+ if (isMaker !== undefined) {
114408
+ takerOrMakerDefault = isMaker ? 'maker' : 'taker';
114409
+ }
114410
+ const takerOrMaker = this.safeString(trade, 'exec_type', takerOrMakerDefault);
114368
114411
  let fee = undefined;
114369
114412
  const feeCostString = this.safeString(trade, 'commission_amount');
114370
114413
  if (feeCostString !== undefined) {
@@ -114604,13 +114647,21 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
114604
114647
  * @method
114605
114648
  * @name exmo#fetchOrderTrades
114606
114649
  * @description fetch all the trades made from a single order
114650
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#cf27781e-28e5-4b39-a52d-3110f5d22459 // spot
114651
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#00810661-9119-46c5-aec5-55abe9cb42c7 // margin
114607
114652
  * @param {string} id order id
114608
114653
  * @param {string} symbol unified market symbol
114609
114654
  * @param {int} [since] the earliest time in ms to fetch trades for
114610
114655
  * @param {int} [limit] the maximum number of trades to retrieve
114611
114656
  * @param {object} [params] extra parameters specific to the exmo api endpoint
114657
+ * @param {string} [params.marginMode] set to "isolated" to fetch trades for a margin order
114612
114658
  * @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
114613
114659
  */
114660
+ let marginMode = undefined;
114661
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOrderTrades', params);
114662
+ if (marginMode === 'cross') {
114663
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' only supports isolated margin');
114664
+ }
114614
114665
  let market = undefined;
114615
114666
  if (symbol !== undefined) {
114616
114667
  market = this.market(symbol);
@@ -114618,32 +114669,54 @@ class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
114618
114669
  const request = {
114619
114670
  'order_id': id.toString(),
114620
114671
  };
114621
- const response = await this.privatePostOrderTrades(this.extend(request, params));
114622
- //
114623
- // {
114624
- // "type": "buy",
114625
- // "in_currency": "BTC",
114626
- // "in_amount": "1",
114627
- // "out_currency": "USD",
114628
- // "out_amount": "100",
114629
- // "trades": [
114630
- // {
114631
- // "trade_id": 3,
114632
- // "date": 1435488248,
114633
- // "type": "buy",
114634
- // "pair": "BTC_USD",
114635
- // "order_id": 12345,
114636
- // "quantity": 1,
114637
- // "price": 100,
114638
- // "amount": 100,
114639
- // "exec_type": "taker",
114640
- // "commission_amount": "0.02",
114641
- // "commission_currency": "BTC",
114642
- // "commission_percent": "0.2"
114643
- // }
114644
- // ]
114645
- // }
114646
- //
114672
+ let response = undefined;
114673
+ if (marginMode === 'isolated') {
114674
+ response = await this.privatePostMarginUserOrderTrades(this.extend(request, params));
114675
+ //
114676
+ // {
114677
+ // "trades": [
114678
+ // {
114679
+ // "is_maker": false,
114680
+ // "order_id": "123",
114681
+ // "pair": "BTC_USD",
114682
+ // "price": "54122.25",
114683
+ // "quantity": "0.00069994",
114684
+ // "trade_dt": "1619069561718824428",
114685
+ // "trade_id": "692842802860135010",
114686
+ // "type": "sell"
114687
+ // }
114688
+ // ]
114689
+ // }
114690
+ //
114691
+ }
114692
+ else {
114693
+ response = await this.privatePostOrderTrades(this.extend(request, params));
114694
+ //
114695
+ // {
114696
+ // "type": "buy",
114697
+ // "in_currency": "BTC",
114698
+ // "in_amount": "1",
114699
+ // "out_currency": "USD",
114700
+ // "out_amount": "100",
114701
+ // "trades": [
114702
+ // {
114703
+ // "trade_id": 3,
114704
+ // "date": 1435488248,
114705
+ // "type": "buy",
114706
+ // "pair": "BTC_USD",
114707
+ // "order_id": 12345,
114708
+ // "quantity": 1,
114709
+ // "price": 100,
114710
+ // "amount": 100,
114711
+ // "exec_type": "taker",
114712
+ // "commission_amount": "0.02",
114713
+ // "commission_currency": "BTC",
114714
+ // "commission_percent": "0.2"
114715
+ // }
114716
+ // ]
114717
+ // }
114718
+ //
114719
+ }
114647
114720
  const trades = this.safeValue(response, 'trades');
114648
114721
  return this.parseTrades(trades, market, since, limit);
114649
114722
  }
@@ -124712,6 +124785,9 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
124712
124785
  if (taker !== undefined) {
124713
124786
  takerOrMaker = taker ? 'taker' : 'maker';
124714
124787
  }
124788
+ else {
124789
+ takerOrMaker = 'taker'; // the only case when `taker` field is missing, is public fetchTrades and it must be taker
124790
+ }
124715
124791
  if (feeCostString !== undefined) {
124716
124792
  const info = this.safeValue(market, 'info', {});
124717
124793
  const feeCurrency = this.safeString(info, 'fee_currency');
@@ -152301,11 +152377,18 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
152301
152377
  'leverage': 1,
152302
152378
  };
152303
152379
  const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
152380
+ const triggerPriceTypes = {
152381
+ 'mark': 'MP',
152382
+ 'last': 'TP',
152383
+ 'index': 'IP',
152384
+ };
152385
+ const triggerPriceType = this.safeString(params, 'triggerPriceType', 'mark');
152386
+ const triggerPriceTypeValue = this.safeString(triggerPriceTypes, triggerPriceType, triggerPriceType);
152304
152387
  params = this.omit(params, ['stopLossPrice', 'takeProfitPrice', 'triggerPrice', 'stopPrice']);
152305
152388
  if (triggerPrice) {
152306
152389
  request['stop'] = (side === 'buy') ? 'up' : 'down';
152307
152390
  request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
152308
- request['stopPriceType'] = 'MP';
152391
+ request['stopPriceType'] = triggerPriceTypeValue;
152309
152392
  }
152310
152393
  else if (stopLossPrice || takeProfitPrice) {
152311
152394
  if (stopLossPrice) {
@@ -152317,7 +152400,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
152317
152400
  request['stopPrice'] = this.priceToPrecision(symbol, takeProfitPrice);
152318
152401
  }
152319
152402
  request['reduceOnly'] = true;
152320
- request['stopPriceType'] = 'MP';
152403
+ request['stopPriceType'] = triggerPriceTypeValue;
152321
152404
  }
152322
152405
  const uppercaseType = type.toUpperCase();
152323
152406
  const timeInForce = this.safeStringUpper(params, 'timeInForce');
@@ -198404,13 +198487,13 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
198404
198487
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
198405
198488
  this.myTrades = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_1__/* .ArrayCacheBySymbolById */ .hl(limit);
198406
198489
  }
198407
- const array = this.myTrades;
198408
- array.append(trade);
198409
- this.myTrades = array;
198490
+ const tradesArray = this.myTrades;
198491
+ tradesArray.append(trade);
198492
+ this.myTrades = tradesArray;
198410
198493
  // generic subscription
198411
- client.resolve(array, name);
198494
+ client.resolve(tradesArray, name);
198412
198495
  // specific subscription
198413
- client.resolve(array, messageHash);
198496
+ client.resolve(tradesArray, messageHash);
198414
198497
  }
198415
198498
  handleTrades(client, message, subscription) {
198416
198499
  //
@@ -207629,8 +207712,8 @@ class blockchaincom extends _blockchaincom_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
207629
207712
  };
207630
207713
  }
207631
207714
  handleDelta(bookside, delta) {
207632
- const array = this.parseCountedBidAsk(delta, 'px', 'qty', 'num');
207633
- bookside.storeArray(array);
207715
+ const bookArray = this.parseCountedBidAsk(delta, 'px', 'qty', 'num');
207716
+ bookside.storeArray(bookArray);
207634
207717
  }
207635
207718
  handleDeltas(bookside, deltas) {
207636
207719
  for (let i = 0; i < deltas.length; i++) {
@@ -227137,13 +227220,13 @@ class luno extends _luno_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
227137
227220
  const asksOrderSide = orderbook['asks'];
227138
227221
  const bidsOrderSide = orderbook['bids'];
227139
227222
  if (createUpdate !== undefined) {
227140
- const array = this.customParseBidAsk(createUpdate, 'price', 'volume', 'order_id');
227223
+ const bidAskArray = this.customParseBidAsk(createUpdate, 'price', 'volume', 'order_id');
227141
227224
  const type = this.safeString(createUpdate, 'type');
227142
227225
  if (type === 'ASK') {
227143
- asksOrderSide.storeArray(array);
227226
+ asksOrderSide.storeArray(bidAskArray);
227144
227227
  }
227145
227228
  else if (type === 'BID') {
227146
- bidsOrderSide.storeArray(array);
227229
+ bidsOrderSide.storeArray(bidAskArray);
227147
227230
  }
227148
227231
  }
227149
227232
  const deleteUpdate = this.safeValue(message, 'delete_update');
@@ -273674,7 +273757,7 @@ SOFTWARE.
273674
273757
 
273675
273758
  //-----------------------------------------------------------------------------
273676
273759
  // this is updated by vss.js when building
273677
- const version = '4.0.85';
273760
+ const version = '4.0.87';
273678
273761
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
273679
273762
  //-----------------------------------------------------------------------------
273680
273763