ccxt 4.1.11 → 4.1.12

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
@@ -214,13 +214,13 @@ console.log(version, Object.keys(exchanges));
214
214
 
215
215
  All-in-one browser bundle (dependencies included), served from a CDN of your choice:
216
216
 
217
- * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.11/dist/ccxt.browser.js
218
- * unpkg: https://unpkg.com/ccxt@4.1.11/dist/ccxt.browser.js
217
+ * jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.12/dist/ccxt.browser.js
218
+ * unpkg: https://unpkg.com/ccxt@4.1.12/dist/ccxt.browser.js
219
219
 
220
220
  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.
221
221
 
222
222
  ```HTML
223
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.11/dist/ccxt.browser.js"></script>
223
+ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.12/dist/ccxt.browser.js"></script>
224
224
  ```
225
225
 
226
226
  Creates a global `ccxt` object:
@@ -17789,14 +17789,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
17789
17789
  const query = this.omit(params, 'type');
17790
17790
  let subType = undefined;
17791
17791
  [subType, params] = this.handleSubTypeAndParams('fetchTime', undefined, params);
17792
- let method = 'publicGetTime';
17792
+ let response = undefined;
17793
17793
  if (this.isLinear(type, subType)) {
17794
- method = 'fapiPublicGetTime';
17794
+ response = await this.fapiPublicGetTime(query);
17795
17795
  }
17796
17796
  else if (this.isInverse(type, subType)) {
17797
- method = 'dapiPublicGetTime';
17797
+ response = await this.dapiPublicGetTime(query);
17798
+ }
17799
+ else {
17800
+ response = await this.publicGetTime(query);
17798
17801
  }
17799
- const response = await this[method](query);
17800
17802
  return this.safeInteger(response, 'serverTime');
17801
17803
  }
17802
17804
  async fetchCurrencies(params = {}) {
@@ -18782,17 +18784,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18782
18784
  if (limit !== undefined) {
18783
18785
  request['limit'] = limit; // default 100, max 5000, see https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book
18784
18786
  }
18785
- let method = 'publicGetDepth';
18787
+ let response = undefined;
18786
18788
  if (market['option']) {
18787
- method = 'eapiPublicGetDepth';
18789
+ response = await this.eapiPublicGetDepth(this.extend(request, params));
18788
18790
  }
18789
18791
  else if (market['linear']) {
18790
- method = 'fapiPublicGetDepth';
18792
+ response = await this.fapiPublicGetDepth(this.extend(request, params));
18791
18793
  }
18792
18794
  else if (market['inverse']) {
18793
- method = 'dapiPublicGetDepth';
18795
+ response = await this.dapiPublicGetDepth(this.extend(request, params));
18796
+ }
18797
+ else {
18798
+ response = await this.publicGetDepth(this.extend(request, params));
18794
18799
  }
18795
- const response = await this[method](this.extend(request, params));
18796
18800
  //
18797
18801
  // future
18798
18802
  //
@@ -19026,17 +19030,19 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19026
19030
  const request = {
19027
19031
  'symbol': market['id'],
19028
19032
  };
19029
- let method = 'publicGetTicker24hr';
19033
+ let response = undefined;
19030
19034
  if (market['option']) {
19031
- method = 'eapiPublicGetTicker';
19035
+ response = await this.eapiPublicGetTicker(this.extend(request, params));
19032
19036
  }
19033
19037
  else if (market['linear']) {
19034
- method = 'fapiPublicGetTicker24hr';
19038
+ response = await this.fapiPublicGetTicker24hr(this.extend(request, params));
19035
19039
  }
19036
19040
  else if (market['inverse']) {
19037
- method = 'dapiPublicGetTicker24hr';
19041
+ response = await this.dapiPublicGetTicker24hr(this.extend(request, params));
19042
+ }
19043
+ else {
19044
+ response = await this.publicGetTicker24hr(this.extend(request, params));
19038
19045
  }
19039
- const response = await this[method](this.extend(request, params));
19040
19046
  if (Array.isArray(response)) {
19041
19047
  const firstTicker = this.safeValue(response, 0, {});
19042
19048
  return this.parseTicker(firstTicker, market);
@@ -19066,17 +19072,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19066
19072
  let subType = undefined;
19067
19073
  [subType, params] = this.handleSubTypeAndParams('fetchBidsAsks', market, params);
19068
19074
  [type, params] = this.handleMarketTypeAndParams('fetchBidsAsks', market, params);
19069
- let method = undefined;
19075
+ let response = undefined;
19070
19076
  if (this.isLinear(type, subType)) {
19071
- method = 'fapiPublicGetTickerBookTicker';
19077
+ response = await this.fapiPublicGetTickerBookTicker(params);
19072
19078
  }
19073
19079
  else if (this.isInverse(type, subType)) {
19074
- method = 'dapiPublicGetTickerBookTicker';
19080
+ response = await this.dapiPublicGetTickerBookTicker(params);
19075
19081
  }
19076
19082
  else {
19077
- method = 'publicGetTickerBookTicker';
19083
+ response = await this.publicGetTickerBookTicker(params);
19078
19084
  }
19079
- const response = await this[method](params);
19080
19085
  return this.parseTickers(response, symbols);
19081
19086
  }
19082
19087
  async fetchLastPrices(symbols = undefined, params = {}) {
@@ -19098,9 +19103,9 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19098
19103
  let subType = undefined;
19099
19104
  [subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
19100
19105
  [type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
19101
- let method = undefined;
19106
+ let response = undefined;
19102
19107
  if (this.isLinear(type, subType)) {
19103
- method = 'fapiPublicGetTickerPrice';
19108
+ response = await this.fapiPublicGetTickerPrice(params);
19104
19109
  //
19105
19110
  // [
19106
19111
  // {
@@ -19113,7 +19118,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19113
19118
  //
19114
19119
  }
19115
19120
  else if (this.isInverse(type, subType)) {
19116
- method = 'dapiPublicGetTickerPrice';
19121
+ response = await this.dapiPublicGetTickerPrice(params);
19117
19122
  //
19118
19123
  // [
19119
19124
  // {
@@ -19126,7 +19131,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19126
19131
  //
19127
19132
  }
19128
19133
  else if (type === 'spot') {
19129
- method = 'publicGetTickerPrice';
19134
+ response = await this.publicGetTickerPrice(params);
19130
19135
  //
19131
19136
  // [
19132
19137
  // {
@@ -19140,7 +19145,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19140
19145
  else {
19141
19146
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
19142
19147
  }
19143
- const response = await this[method](params);
19144
19148
  return this.parseLastPrices(response, symbols);
19145
19149
  }
19146
19150
  parseLastPrice(info, market = undefined) {
@@ -22460,10 +22464,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22460
22464
  }
22461
22465
  parseTradingFee(fee, market = undefined) {
22462
22466
  //
22467
+ // spot
22468
+ // [
22469
+ // {
22470
+ // "symbol": "BTCUSDT",
22471
+ // "makerCommission": "0.001",
22472
+ // "takerCommission": "0.001"
22473
+ // }
22474
+ // ]
22475
+ //
22476
+ // swap
22463
22477
  // {
22464
- // "symbol": "ADABNB",
22465
- // "makerCommission": 0.001,
22466
- // "takerCommission": 0.001
22478
+ // "symbol": "BTCUSD_PERP",
22479
+ // "makerCommissionRate": "0.00015", // 0.015%
22480
+ // "takerCommissionRate": "0.00040" // 0.040%
22467
22481
  // }
22468
22482
  //
22469
22483
  const marketId = this.safeString(fee, 'symbol');
@@ -22471,8 +22485,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22471
22485
  return {
22472
22486
  'info': fee,
22473
22487
  'symbol': symbol,
22474
- 'maker': this.safeNumber(fee, 'makerCommission'),
22475
- 'taker': this.safeNumber(fee, 'takerCommission'),
22488
+ 'maker': this.safeNumber2(fee, 'makerCommission', 'makerCommissionRate'),
22489
+ 'taker': this.safeNumber2(fee, 'takerCommission', 'takerCommissionRate'),
22476
22490
  };
22477
22491
  }
22478
22492
  async fetchTradingFee(symbol, params = {}) {
@@ -22481,17 +22495,37 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22481
22495
  * @name binance#fetchTradingFee
22482
22496
  * @description fetch the trading fees for a market
22483
22497
  * @see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
22498
+ * @see https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
22499
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
22484
22500
  * @param {string} symbol unified market symbol
22485
22501
  * @param {object} [params] extra parameters specific to the binance api endpoint
22486
22502
  * @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
22487
22503
  */
22488
22504
  await this.loadMarkets();
22489
22505
  const market = this.market(symbol);
22506
+ const defaultType = this.safeString2(this.options, 'fetchTradingFee', 'defaultType', 'linear');
22507
+ const type = this.safeString(params, 'type', defaultType);
22508
+ params = this.omit(params, 'type');
22509
+ let subType = undefined;
22510
+ [subType, params] = this.handleSubTypeAndParams('fetchTradingFee', market, params);
22511
+ const isSpotOrMargin = (type === 'spot') || (type === 'margin');
22512
+ const isLinear = this.isLinear(type, subType);
22513
+ const isInverse = this.isInverse(type, subType);
22490
22514
  const request = {
22491
22515
  'symbol': market['id'],
22492
22516
  };
22493
- const response = await this.sapiGetAssetTradeFee(this.extend(request, params));
22517
+ let response = undefined;
22518
+ if (isSpotOrMargin) {
22519
+ response = await this.sapiGetAssetTradeFee(this.extend(request, params));
22520
+ }
22521
+ else if (isLinear) {
22522
+ response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
22523
+ }
22524
+ else if (isInverse) {
22525
+ response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
22526
+ }
22494
22527
  //
22528
+ // spot
22495
22529
  // [
22496
22530
  // {
22497
22531
  // "symbol": "BTCUSDT",
@@ -22500,8 +22534,18 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22500
22534
  // }
22501
22535
  // ]
22502
22536
  //
22503
- const first = this.safeValue(response, 0, {});
22504
- return this.parseTradingFee(first);
22537
+ // swap
22538
+ // {
22539
+ // "symbol": "BTCUSD_PERP",
22540
+ // "makerCommissionRate": "0.00015", // 0.015%
22541
+ // "takerCommissionRate": "0.00040" // 0.040%
22542
+ // }
22543
+ //
22544
+ let data = response;
22545
+ if (Array.isArray(data)) {
22546
+ data = this.safeValue(data, 0, {});
22547
+ }
22548
+ return this.parseTradingFee(data);
22505
22549
  }
22506
22550
  async fetchTradingFees(params = {}) {
22507
22551
  /**
@@ -22516,11 +22560,10 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22516
22560
  */
22517
22561
  await this.loadMarkets();
22518
22562
  let method = undefined;
22519
- const defaultType = this.safeString2(this.options, 'fetchTradingFees', 'defaultType', 'linear');
22520
- const type = this.safeString(params, 'type', defaultType);
22521
- params = this.omit(params, 'type');
22563
+ let type = undefined;
22564
+ [type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
22522
22565
  let subType = undefined;
22523
- [subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params);
22566
+ [subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params, 'linear');
22524
22567
  const isSpotOrMargin = (type === 'spot') || (type === 'margin');
22525
22568
  const isLinear = this.isLinear(type, subType);
22526
22569
  const isInverse = this.isInverse(type, subType);
@@ -39832,7 +39875,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39832
39875
  }
39833
39876
  const currency = this.currency(code);
39834
39877
  if (since === undefined) {
39835
- since = this.milliseconds() - 31556952000; // 1yr
39878
+ since = this.milliseconds() - 7776000000; // 90 days
39836
39879
  }
39837
39880
  let request = {
39838
39881
  'coin': currency['code'],
@@ -39988,7 +40031,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
39988
40031
  }
39989
40032
  const currency = this.currency(code);
39990
40033
  if (since === undefined) {
39991
- since = this.milliseconds() - 31556952000; // 1yr
40034
+ since = this.milliseconds() - 7776000000; // 90 days
39992
40035
  }
39993
40036
  let request = {
39994
40037
  'coin': currency['code'],
@@ -42301,10 +42344,17 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
42301
42344
  response = await this.privateSpotPostTradeFills(this.extend(request, params));
42302
42345
  }
42303
42346
  else {
42347
+ const orderId = this.safeString(params, 'orderId'); // when order id is not defined, startTime and endTime are required
42304
42348
  if (since !== undefined) {
42305
42349
  request['startTime'] = since;
42306
42350
  }
42351
+ else if (orderId === undefined) {
42352
+ request['startTime'] = 0;
42353
+ }
42307
42354
  [request, params] = this.handleUntilOption('endTime', params, request);
42355
+ if (!('endTime' in request) && (orderId === undefined)) {
42356
+ request['endTime'] = this.milliseconds();
42357
+ }
42308
42358
  response = await this.privateMixGetOrderFills(this.extend(request, params));
42309
42359
  }
42310
42360
  //
@@ -73416,6 +73466,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
73416
73466
  'max': this.safeNumber(lotSizeFilter, 'maxOrderAmt'),
73417
73467
  },
73418
73468
  },
73469
+ 'created': undefined,
73419
73470
  'info': market,
73420
73471
  });
73421
73472
  }
@@ -73590,6 +73641,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
73590
73641
  'max': undefined,
73591
73642
  },
73592
73643
  },
73644
+ 'created': this.safeInteger(market, 'launchTime'),
73593
73645
  'info': market,
73594
73646
  });
73595
73647
  }
@@ -73722,6 +73774,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
73722
73774
  'max': undefined,
73723
73775
  },
73724
73776
  },
73777
+ 'created': this.safeInteger(market, 'launchTime'),
73725
73778
  'info': market,
73726
73779
  });
73727
73780
  }
@@ -75176,10 +75229,14 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
75176
75229
  // }
75177
75230
  //
75178
75231
  const marketId = this.safeString(order, 'symbol');
75179
- let marketType = 'contract';
75232
+ const isContract = ('tpslMode' in order);
75233
+ let marketType = undefined;
75180
75234
  if (market !== undefined) {
75181
75235
  marketType = market['type'];
75182
75236
  }
75237
+ else {
75238
+ marketType = isContract ? 'contract' : 'spot';
75239
+ }
75183
75240
  market = this.safeMarket(marketId, market, undefined, marketType);
75184
75241
  const symbol = market['symbol'];
75185
75242
  const timestamp = this.safeInteger2(order, 'createdTime', 'createdAt');
@@ -77356,10 +77413,9 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
77356
77413
  const timestamp = this.safeInteger(response, 'time');
77357
77414
  const first = this.safeValue(positions, 0, {});
77358
77415
  const position = this.parsePosition(first, market);
77359
- return this.extend(position, {
77360
- 'timestamp': timestamp,
77361
- 'datetime': this.iso8601(timestamp),
77362
- });
77416
+ position['timestamp'] = timestamp;
77417
+ position['datetime'] = this.iso8601(timestamp);
77418
+ return position;
77363
77419
  }
77364
77420
  async fetchUsdcPositions(symbols = undefined, params = {}) {
77365
77421
  await this.loadMarkets();
@@ -77434,7 +77490,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
77434
77490
  }
77435
77491
  results.push(this.parsePosition(rawPosition, market));
77436
77492
  }
77437
- return this.filterByArray(results, 'symbol', symbols, false);
77493
+ return this.filterByArrayPositions(results, 'symbol', symbols, false);
77438
77494
  }
77439
77495
  async fetchPositions(symbols = undefined, params = {}) {
77440
77496
  /**
@@ -99905,7 +99961,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
99905
99961
  const marketInner = this.safeMarket(marketId, undefined, undefined, 'contract');
99906
99962
  result.push(this.parsePosition(entry, marketInner));
99907
99963
  }
99908
- return this.filterByArray(result, 'symbol', undefined, false);
99964
+ return this.filterByArrayPositions(result, 'symbol', undefined, false);
99909
99965
  }
99910
99966
  parsePosition(position, market = undefined) {
99911
99967
  //
@@ -103708,7 +103764,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
103708
103764
  side = 'sell';
103709
103765
  }
103710
103766
  }
103711
- return {
103767
+ return this.safePosition({
103712
103768
  'info': position,
103713
103769
  'id': undefined,
103714
103770
  'symbol': symbol,
@@ -103734,7 +103790,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
103734
103790
  'marginRatio': undefined,
103735
103791
  'stopLossPrice': undefined,
103736
103792
  'takeProfitPrice': undefined,
103737
- };
103793
+ });
103738
103794
  }
103739
103795
  parseOrderStatus(status) {
103740
103796
  const statuses = {
@@ -135134,10 +135190,9 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
135134
135190
  }
135135
135191
  const timestamp = this.safeInteger(response, 'ts');
135136
135192
  const parsed = this.parsePosition(this.extend(position, omitted));
135137
- return this.extend(parsed, {
135138
- 'timestamp': timestamp,
135139
- 'datetime': this.iso8601(timestamp),
135140
- });
135193
+ parsed['timestamp'] = timestamp;
135194
+ parsed['datetime'] = this.iso8601(timestamp);
135195
+ return parsed;
135141
135196
  }
135142
135197
  parseLedgerEntryType(type) {
135143
135198
  const types = {
@@ -179261,6 +179316,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
179261
179316
  }
179262
179317
  }
179263
179318
  else if (price === 'index') {
179319
+ request['instId'] = market['info']['instFamily']; // okx index candles require instFamily instead of instId
179264
179320
  if (isHistoryCandles) {
179265
179321
  response = await this.publicGetMarketHistoryIndexCandles(this.extend(request, params));
179266
179322
  }
@@ -189399,6 +189455,7 @@ class poloniex extends _abstract_poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
189399
189455
  '21352': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol,
189400
189456
  '21353': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
189401
189457
  '21354': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.PermissionDenied,
189458
+ '21359': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.OrderNotFound,
189402
189459
  '21360': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder,
189403
189460
  '24106': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
189404
189461
  '24201': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeNotAvailable,
@@ -262181,6 +262238,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262181
262238
  'fetchMarginMode': false,
262182
262239
  'fetchMarkets': true,
262183
262240
  'fetchMarkOHLCV': false,
262241
+ 'fetchMyTrades': true,
262184
262242
  'fetchOHLCV': true,
262185
262243
  'fetchOpenInterestHistory': false,
262186
262244
  'fetchOpenOrders': true,
@@ -276555,7 +276613,7 @@ SOFTWARE.
276555
276613
 
276556
276614
  //-----------------------------------------------------------------------------
276557
276615
  // this is updated by vss.js when building
276558
- const version = '4.1.11';
276616
+ const version = '4.1.12';
276559
276617
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
276560
276618
  //-----------------------------------------------------------------------------
276561
276619