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/dist/cjs/ccxt.js CHANGED
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
180
180
 
181
181
  //-----------------------------------------------------------------------------
182
182
  // this is updated by vss.js when building
183
- const version = '4.1.11';
183
+ const version = '4.1.12';
184
184
  Exchange["default"].ccxtVersion = version;
185
185
  const exchanges = {
186
186
  'ace': ace,
@@ -1807,14 +1807,16 @@ class binance extends binance$1 {
1807
1807
  const query = this.omit(params, 'type');
1808
1808
  let subType = undefined;
1809
1809
  [subType, params] = this.handleSubTypeAndParams('fetchTime', undefined, params);
1810
- let method = 'publicGetTime';
1810
+ let response = undefined;
1811
1811
  if (this.isLinear(type, subType)) {
1812
- method = 'fapiPublicGetTime';
1812
+ response = await this.fapiPublicGetTime(query);
1813
1813
  }
1814
1814
  else if (this.isInverse(type, subType)) {
1815
- method = 'dapiPublicGetTime';
1815
+ response = await this.dapiPublicGetTime(query);
1816
+ }
1817
+ else {
1818
+ response = await this.publicGetTime(query);
1816
1819
  }
1817
- const response = await this[method](query);
1818
1820
  return this.safeInteger(response, 'serverTime');
1819
1821
  }
1820
1822
  async fetchCurrencies(params = {}) {
@@ -2800,17 +2802,19 @@ class binance extends binance$1 {
2800
2802
  if (limit !== undefined) {
2801
2803
  request['limit'] = limit; // default 100, max 5000, see https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book
2802
2804
  }
2803
- let method = 'publicGetDepth';
2805
+ let response = undefined;
2804
2806
  if (market['option']) {
2805
- method = 'eapiPublicGetDepth';
2807
+ response = await this.eapiPublicGetDepth(this.extend(request, params));
2806
2808
  }
2807
2809
  else if (market['linear']) {
2808
- method = 'fapiPublicGetDepth';
2810
+ response = await this.fapiPublicGetDepth(this.extend(request, params));
2809
2811
  }
2810
2812
  else if (market['inverse']) {
2811
- method = 'dapiPublicGetDepth';
2813
+ response = await this.dapiPublicGetDepth(this.extend(request, params));
2814
+ }
2815
+ else {
2816
+ response = await this.publicGetDepth(this.extend(request, params));
2812
2817
  }
2813
- const response = await this[method](this.extend(request, params));
2814
2818
  //
2815
2819
  // future
2816
2820
  //
@@ -3044,17 +3048,19 @@ class binance extends binance$1 {
3044
3048
  const request = {
3045
3049
  'symbol': market['id'],
3046
3050
  };
3047
- let method = 'publicGetTicker24hr';
3051
+ let response = undefined;
3048
3052
  if (market['option']) {
3049
- method = 'eapiPublicGetTicker';
3053
+ response = await this.eapiPublicGetTicker(this.extend(request, params));
3050
3054
  }
3051
3055
  else if (market['linear']) {
3052
- method = 'fapiPublicGetTicker24hr';
3056
+ response = await this.fapiPublicGetTicker24hr(this.extend(request, params));
3053
3057
  }
3054
3058
  else if (market['inverse']) {
3055
- method = 'dapiPublicGetTicker24hr';
3059
+ response = await this.dapiPublicGetTicker24hr(this.extend(request, params));
3060
+ }
3061
+ else {
3062
+ response = await this.publicGetTicker24hr(this.extend(request, params));
3056
3063
  }
3057
- const response = await this[method](this.extend(request, params));
3058
3064
  if (Array.isArray(response)) {
3059
3065
  const firstTicker = this.safeValue(response, 0, {});
3060
3066
  return this.parseTicker(firstTicker, market);
@@ -3084,17 +3090,16 @@ class binance extends binance$1 {
3084
3090
  let subType = undefined;
3085
3091
  [subType, params] = this.handleSubTypeAndParams('fetchBidsAsks', market, params);
3086
3092
  [type, params] = this.handleMarketTypeAndParams('fetchBidsAsks', market, params);
3087
- let method = undefined;
3093
+ let response = undefined;
3088
3094
  if (this.isLinear(type, subType)) {
3089
- method = 'fapiPublicGetTickerBookTicker';
3095
+ response = await this.fapiPublicGetTickerBookTicker(params);
3090
3096
  }
3091
3097
  else if (this.isInverse(type, subType)) {
3092
- method = 'dapiPublicGetTickerBookTicker';
3098
+ response = await this.dapiPublicGetTickerBookTicker(params);
3093
3099
  }
3094
3100
  else {
3095
- method = 'publicGetTickerBookTicker';
3101
+ response = await this.publicGetTickerBookTicker(params);
3096
3102
  }
3097
- const response = await this[method](params);
3098
3103
  return this.parseTickers(response, symbols);
3099
3104
  }
3100
3105
  async fetchLastPrices(symbols = undefined, params = {}) {
@@ -3116,9 +3121,9 @@ class binance extends binance$1 {
3116
3121
  let subType = undefined;
3117
3122
  [subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
3118
3123
  [type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
3119
- let method = undefined;
3124
+ let response = undefined;
3120
3125
  if (this.isLinear(type, subType)) {
3121
- method = 'fapiPublicGetTickerPrice';
3126
+ response = await this.fapiPublicGetTickerPrice(params);
3122
3127
  //
3123
3128
  // [
3124
3129
  // {
@@ -3131,7 +3136,7 @@ class binance extends binance$1 {
3131
3136
  //
3132
3137
  }
3133
3138
  else if (this.isInverse(type, subType)) {
3134
- method = 'dapiPublicGetTickerPrice';
3139
+ response = await this.dapiPublicGetTickerPrice(params);
3135
3140
  //
3136
3141
  // [
3137
3142
  // {
@@ -3144,7 +3149,7 @@ class binance extends binance$1 {
3144
3149
  //
3145
3150
  }
3146
3151
  else if (type === 'spot') {
3147
- method = 'publicGetTickerPrice';
3152
+ response = await this.publicGetTickerPrice(params);
3148
3153
  //
3149
3154
  // [
3150
3155
  // {
@@ -3158,7 +3163,6 @@ class binance extends binance$1 {
3158
3163
  else {
3159
3164
  throw new errors.NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
3160
3165
  }
3161
- const response = await this[method](params);
3162
3166
  return this.parseLastPrices(response, symbols);
3163
3167
  }
3164
3168
  parseLastPrice(info, market = undefined) {
@@ -6478,10 +6482,20 @@ class binance extends binance$1 {
6478
6482
  }
6479
6483
  parseTradingFee(fee, market = undefined) {
6480
6484
  //
6485
+ // spot
6486
+ // [
6487
+ // {
6488
+ // "symbol": "BTCUSDT",
6489
+ // "makerCommission": "0.001",
6490
+ // "takerCommission": "0.001"
6491
+ // }
6492
+ // ]
6493
+ //
6494
+ // swap
6481
6495
  // {
6482
- // "symbol": "ADABNB",
6483
- // "makerCommission": 0.001,
6484
- // "takerCommission": 0.001
6496
+ // "symbol": "BTCUSD_PERP",
6497
+ // "makerCommissionRate": "0.00015", // 0.015%
6498
+ // "takerCommissionRate": "0.00040" // 0.040%
6485
6499
  // }
6486
6500
  //
6487
6501
  const marketId = this.safeString(fee, 'symbol');
@@ -6489,8 +6503,8 @@ class binance extends binance$1 {
6489
6503
  return {
6490
6504
  'info': fee,
6491
6505
  'symbol': symbol,
6492
- 'maker': this.safeNumber(fee, 'makerCommission'),
6493
- 'taker': this.safeNumber(fee, 'takerCommission'),
6506
+ 'maker': this.safeNumber2(fee, 'makerCommission', 'makerCommissionRate'),
6507
+ 'taker': this.safeNumber2(fee, 'takerCommission', 'takerCommissionRate'),
6494
6508
  };
6495
6509
  }
6496
6510
  async fetchTradingFee(symbol, params = {}) {
@@ -6499,17 +6513,37 @@ class binance extends binance$1 {
6499
6513
  * @name binance#fetchTradingFee
6500
6514
  * @description fetch the trading fees for a market
6501
6515
  * @see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
6516
+ * @see https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
6517
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
6502
6518
  * @param {string} symbol unified market symbol
6503
6519
  * @param {object} [params] extra parameters specific to the binance api endpoint
6504
6520
  * @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
6505
6521
  */
6506
6522
  await this.loadMarkets();
6507
6523
  const market = this.market(symbol);
6524
+ const defaultType = this.safeString2(this.options, 'fetchTradingFee', 'defaultType', 'linear');
6525
+ const type = this.safeString(params, 'type', defaultType);
6526
+ params = this.omit(params, 'type');
6527
+ let subType = undefined;
6528
+ [subType, params] = this.handleSubTypeAndParams('fetchTradingFee', market, params);
6529
+ const isSpotOrMargin = (type === 'spot') || (type === 'margin');
6530
+ const isLinear = this.isLinear(type, subType);
6531
+ const isInverse = this.isInverse(type, subType);
6508
6532
  const request = {
6509
6533
  'symbol': market['id'],
6510
6534
  };
6511
- const response = await this.sapiGetAssetTradeFee(this.extend(request, params));
6535
+ let response = undefined;
6536
+ if (isSpotOrMargin) {
6537
+ response = await this.sapiGetAssetTradeFee(this.extend(request, params));
6538
+ }
6539
+ else if (isLinear) {
6540
+ response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
6541
+ }
6542
+ else if (isInverse) {
6543
+ response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
6544
+ }
6512
6545
  //
6546
+ // spot
6513
6547
  // [
6514
6548
  // {
6515
6549
  // "symbol": "BTCUSDT",
@@ -6518,8 +6552,18 @@ class binance extends binance$1 {
6518
6552
  // }
6519
6553
  // ]
6520
6554
  //
6521
- const first = this.safeValue(response, 0, {});
6522
- return this.parseTradingFee(first);
6555
+ // swap
6556
+ // {
6557
+ // "symbol": "BTCUSD_PERP",
6558
+ // "makerCommissionRate": "0.00015", // 0.015%
6559
+ // "takerCommissionRate": "0.00040" // 0.040%
6560
+ // }
6561
+ //
6562
+ let data = response;
6563
+ if (Array.isArray(data)) {
6564
+ data = this.safeValue(data, 0, {});
6565
+ }
6566
+ return this.parseTradingFee(data);
6523
6567
  }
6524
6568
  async fetchTradingFees(params = {}) {
6525
6569
  /**
@@ -6534,11 +6578,10 @@ class binance extends binance$1 {
6534
6578
  */
6535
6579
  await this.loadMarkets();
6536
6580
  let method = undefined;
6537
- const defaultType = this.safeString2(this.options, 'fetchTradingFees', 'defaultType', 'linear');
6538
- const type = this.safeString(params, 'type', defaultType);
6539
- params = this.omit(params, 'type');
6581
+ let type = undefined;
6582
+ [type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
6540
6583
  let subType = undefined;
6541
- [subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params);
6584
+ [subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params, 'linear');
6542
6585
  const isSpotOrMargin = (type === 'spot') || (type === 'margin');
6543
6586
  const isLinear = this.isLinear(type, subType);
6544
6587
  const isInverse = this.isInverse(type, subType);
@@ -1573,7 +1573,7 @@ class bitget extends bitget$1 {
1573
1573
  }
1574
1574
  const currency = this.currency(code);
1575
1575
  if (since === undefined) {
1576
- since = this.milliseconds() - 31556952000; // 1yr
1576
+ since = this.milliseconds() - 7776000000; // 90 days
1577
1577
  }
1578
1578
  let request = {
1579
1579
  'coin': currency['code'],
@@ -1729,7 +1729,7 @@ class bitget extends bitget$1 {
1729
1729
  }
1730
1730
  const currency = this.currency(code);
1731
1731
  if (since === undefined) {
1732
- since = this.milliseconds() - 31556952000; // 1yr
1732
+ since = this.milliseconds() - 7776000000; // 90 days
1733
1733
  }
1734
1734
  let request = {
1735
1735
  'coin': currency['code'],
@@ -4042,10 +4042,17 @@ class bitget extends bitget$1 {
4042
4042
  response = await this.privateSpotPostTradeFills(this.extend(request, params));
4043
4043
  }
4044
4044
  else {
4045
+ const orderId = this.safeString(params, 'orderId'); // when order id is not defined, startTime and endTime are required
4045
4046
  if (since !== undefined) {
4046
4047
  request['startTime'] = since;
4047
4048
  }
4049
+ else if (orderId === undefined) {
4050
+ request['startTime'] = 0;
4051
+ }
4048
4052
  [request, params] = this.handleUntilOption('endTime', params, request);
4053
+ if (!('endTime' in request) && (orderId === undefined)) {
4054
+ request['endTime'] = this.milliseconds();
4055
+ }
4049
4056
  response = await this.privateMixGetOrderFills(this.extend(request, params));
4050
4057
  }
4051
4058
  //
@@ -1750,6 +1750,7 @@ class bybit extends bybit$1 {
1750
1750
  'max': this.safeNumber(lotSizeFilter, 'maxOrderAmt'),
1751
1751
  },
1752
1752
  },
1753
+ 'created': undefined,
1753
1754
  'info': market,
1754
1755
  });
1755
1756
  }
@@ -1924,6 +1925,7 @@ class bybit extends bybit$1 {
1924
1925
  'max': undefined,
1925
1926
  },
1926
1927
  },
1928
+ 'created': this.safeInteger(market, 'launchTime'),
1927
1929
  'info': market,
1928
1930
  });
1929
1931
  }
@@ -2056,6 +2058,7 @@ class bybit extends bybit$1 {
2056
2058
  'max': undefined,
2057
2059
  },
2058
2060
  },
2061
+ 'created': this.safeInteger(market, 'launchTime'),
2059
2062
  'info': market,
2060
2063
  });
2061
2064
  }
@@ -3510,10 +3513,14 @@ class bybit extends bybit$1 {
3510
3513
  // }
3511
3514
  //
3512
3515
  const marketId = this.safeString(order, 'symbol');
3513
- let marketType = 'contract';
3516
+ const isContract = ('tpslMode' in order);
3517
+ let marketType = undefined;
3514
3518
  if (market !== undefined) {
3515
3519
  marketType = market['type'];
3516
3520
  }
3521
+ else {
3522
+ marketType = isContract ? 'contract' : 'spot';
3523
+ }
3517
3524
  market = this.safeMarket(marketId, market, undefined, marketType);
3518
3525
  const symbol = market['symbol'];
3519
3526
  const timestamp = this.safeInteger2(order, 'createdTime', 'createdAt');
@@ -5690,10 +5697,9 @@ class bybit extends bybit$1 {
5690
5697
  const timestamp = this.safeInteger(response, 'time');
5691
5698
  const first = this.safeValue(positions, 0, {});
5692
5699
  const position = this.parsePosition(first, market);
5693
- return this.extend(position, {
5694
- 'timestamp': timestamp,
5695
- 'datetime': this.iso8601(timestamp),
5696
- });
5700
+ position['timestamp'] = timestamp;
5701
+ position['datetime'] = this.iso8601(timestamp);
5702
+ return position;
5697
5703
  }
5698
5704
  async fetchUsdcPositions(symbols = undefined, params = {}) {
5699
5705
  await this.loadMarkets();
@@ -5768,7 +5774,7 @@ class bybit extends bybit$1 {
5768
5774
  }
5769
5775
  results.push(this.parsePosition(rawPosition, market));
5770
5776
  }
5771
- return this.filterByArray(results, 'symbol', symbols, false);
5777
+ return this.filterByArrayPositions(results, 'symbol', symbols, false);
5772
5778
  }
5773
5779
  async fetchPositions(symbols = undefined, params = {}) {
5774
5780
  /**
@@ -2953,7 +2953,7 @@ class cryptocom extends cryptocom$1 {
2953
2953
  const marketInner = this.safeMarket(marketId, undefined, undefined, 'contract');
2954
2954
  result.push(this.parsePosition(entry, marketInner));
2955
2955
  }
2956
- return this.filterByArray(result, 'symbol', undefined, false);
2956
+ return this.filterByArrayPositions(result, 'symbol', undefined, false);
2957
2957
  }
2958
2958
  parsePosition(position, market = undefined) {
2959
2959
  //
@@ -1672,7 +1672,7 @@ class delta extends delta$1 {
1672
1672
  side = 'sell';
1673
1673
  }
1674
1674
  }
1675
- return {
1675
+ return this.safePosition({
1676
1676
  'info': position,
1677
1677
  'id': undefined,
1678
1678
  'symbol': symbol,
@@ -1698,7 +1698,7 @@ class delta extends delta$1 {
1698
1698
  'marginRatio': undefined,
1699
1699
  'stopLossPrice': undefined,
1700
1700
  'takeProfitPrice': undefined,
1701
- };
1701
+ });
1702
1702
  }
1703
1703
  parseOrderStatus(status) {
1704
1704
  const statuses = {
@@ -7215,10 +7215,9 @@ class huobi extends huobi$1 {
7215
7215
  }
7216
7216
  const timestamp = this.safeInteger(response, 'ts');
7217
7217
  const parsed = this.parsePosition(this.extend(position, omitted));
7218
- return this.extend(parsed, {
7219
- 'timestamp': timestamp,
7220
- 'datetime': this.iso8601(timestamp),
7221
- });
7218
+ parsed['timestamp'] = timestamp;
7219
+ parsed['datetime'] = this.iso8601(timestamp);
7220
+ return parsed;
7222
7221
  }
7223
7222
  parseLedgerEntryType(type) {
7224
7223
  const types = {
@@ -2112,6 +2112,7 @@ class okx extends okx$1 {
2112
2112
  }
2113
2113
  }
2114
2114
  else if (price === 'index') {
2115
+ request['instId'] = market['info']['instFamily']; // okx index candles require instFamily instead of instId
2115
2116
  if (isHistoryCandles) {
2116
2117
  response = await this.publicGetMarketHistoryIndexCandles(this.extend(request, params));
2117
2118
  }
@@ -288,6 +288,7 @@ class poloniex extends poloniex$1 {
288
288
  '21352': errors.BadSymbol,
289
289
  '21353': errors.PermissionDenied,
290
290
  '21354': errors.PermissionDenied,
291
+ '21359': errors.OrderNotFound,
291
292
  '21360': errors.InvalidOrder,
292
293
  '24106': errors.BadRequest,
293
294
  '24201': errors.ExchangeNotAvailable,
@@ -57,6 +57,7 @@ class whitebit extends whitebit$1 {
57
57
  'fetchMarginMode': false,
58
58
  'fetchMarkets': true,
59
59
  'fetchMarkOHLCV': false,
60
+ 'fetchMyTrades': true,
60
61
  'fetchOHLCV': true,
61
62
  'fetchOpenInterestHistory': false,
62
63
  'fetchOpenOrders': true,
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.10";
7
+ declare const version = "4.1.11";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.11';
41
+ const version = '4.1.12';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';