ccxt 4.2.90 → 4.2.92

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
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
182
182
 
183
183
  //-----------------------------------------------------------------------------
184
184
  // this is updated by vss.js when building
185
- const version = '4.2.90';
185
+ const version = '4.2.92';
186
186
  Exchange["default"].ccxtVersion = version;
187
187
  const exchanges = {
188
188
  'ace': ace,
@@ -2095,7 +2095,7 @@ class Exchange {
2095
2095
  parseToInt(number) {
2096
2096
  // Solve Common parseInt misuse ex: parseInt ((since / 1000).toString ())
2097
2097
  // using a number as parameter which is not valid in ts
2098
- const stringifiedNumber = number.toString();
2098
+ const stringifiedNumber = this.numberToString(number);
2099
2099
  const convertedNumber = parseFloat(stringifiedNumber);
2100
2100
  return parseInt(convertedNumber);
2101
2101
  }
@@ -4588,13 +4588,6 @@ class Exchange {
4588
4588
  if (!this.substituteCommonCurrencyCodes) {
4589
4589
  return code;
4590
4590
  }
4591
- // if the provided code already exists as a value in commonCurrencies dict, then we should not again transform it
4592
- // more details at: https://github.com/ccxt/ccxt/issues/21112#issuecomment-2031293691
4593
- const commonCurrencies = Object.values(this.commonCurrencies);
4594
- const exists = this.inArray(code, commonCurrencies);
4595
- if (exists) {
4596
- return code;
4597
- }
4598
4591
  return this.safeString(this.commonCurrencies, code, code);
4599
4592
  }
4600
4593
  currency(code) {
@@ -5245,7 +5238,6 @@ class Exchange {
5245
5238
  * @returns {object} objects with withdraw and deposit fees, indexed by currency codes
5246
5239
  */
5247
5240
  const depositWithdrawFees = {};
5248
- codes = this.marketCodes(codes);
5249
5241
  const isArray = Array.isArray(response);
5250
5242
  let responseKeys = response;
5251
5243
  if (!isArray) {
@@ -5815,7 +5807,7 @@ class Exchange {
5815
5807
  return reconstructedDate;
5816
5808
  }
5817
5809
  convertMarketIdExpireDate(date) {
5818
- // parse 19JAN24 to 240119
5810
+ // parse 03JAN24 to 240103
5819
5811
  const monthMappping = {
5820
5812
  'JAN': '01',
5821
5813
  'FEB': '02',
@@ -5830,6 +5822,10 @@ class Exchange {
5830
5822
  'NOV': '11',
5831
5823
  'DEC': '12',
5832
5824
  };
5825
+ // if exchange omits first zero and provides i.e. '3JAN24' instead of '03JAN24'
5826
+ if (date.length === 6) {
5827
+ date = '0' + date;
5828
+ }
5833
5829
  const year = date.slice(0, 2);
5834
5830
  const monthName = date.slice(2, 5);
5835
5831
  const month = this.safeString(monthMappping, monthName);
@@ -370,6 +370,7 @@ class bybit extends bybit$1 {
370
370
  'v5/broker/earning-record': 5,
371
371
  'v5/broker/earnings-info': 5,
372
372
  'v5/broker/account-info': 5,
373
+ 'v5/broker/asset/query-sub-member-deposit-record': 10,
373
374
  },
374
375
  'post': {
375
376
  // Legacy option USDC
@@ -328,6 +328,7 @@ class coinbase extends coinbase$1 {
328
328
  'CGLD': 'CELO',
329
329
  },
330
330
  'options': {
331
+ 'brokerId': 'ccxt',
331
332
  'stablePairs': ['BUSD-USD', 'CBETH-ETH', 'DAI-USD', 'GUSD-USD', 'GYEN-USD', 'PAX-USD', 'PAX-USDT', 'USDC-EUR', 'USDC-GBP', 'USDT-EUR', 'USDT-GBP', 'USDT-USD', 'USDT-USDC', 'WBTC-BTC'],
332
333
  'fetchCurrencies': {
333
334
  'expires': 5000,
@@ -2338,8 +2339,9 @@ class coinbase extends coinbase$1 {
2338
2339
  */
2339
2340
  await this.loadMarkets();
2340
2341
  const market = this.market(symbol);
2342
+ const id = this.safeString(this.options, 'brokerId', 'ccxt');
2341
2343
  let request = {
2342
- 'client_order_id': this.uuid(),
2344
+ 'client_order_id': id + '-' + this.uuid(),
2343
2345
  'product_id': market['id'],
2344
2346
  'side': side.toUpperCase(),
2345
2347
  };
@@ -697,117 +697,130 @@ class deribit extends deribit$1 {
697
697
  * @name deribit#fetchMarkets
698
698
  * @description retrieves data on all markets for deribit
699
699
  * @see https://docs.deribit.com/#public-get_currencies
700
+ * @see https://docs.deribit.com/#public-get_instruments
700
701
  * @param {object} [params] extra parameters specific to the exchange API endpoint
701
702
  * @returns {object[]} an array of objects representing market data
702
703
  */
703
- const currenciesResponse = await this.publicGetGetCurrencies(params);
704
- //
705
- // {
706
- // "jsonrpc": "2.0",
707
- // "result": [
708
- // {
709
- // "withdrawal_priorities": [
710
- // { value: 0.15, name: "very_low" },
711
- // { value: 1.5, name: "very_high" },
712
- // ],
713
- // "withdrawal_fee": 0.0005,
714
- // "min_withdrawal_fee": 0.0005,
715
- // "min_confirmations": 1,
716
- // "fee_precision": 4,
717
- // "currency_long": "Bitcoin",
718
- // "currency": "BTC",
719
- // "coin_type": "BITCOIN"
720
- // }
721
- // ],
722
- // "usIn": 1583761588590479,
723
- // "usOut": 1583761588590544,
724
- // "usDiff": 65,
725
- // "testnet": false
726
- // }
727
- //
728
- const parsedMarkets = {};
729
- const currenciesResult = this.safeValue(currenciesResponse, 'result', []);
704
+ const instrumentsResponses = [];
730
705
  const result = [];
731
- for (let i = 0; i < currenciesResult.length; i++) {
732
- const currencyId = this.safeString(currenciesResult[i], 'currency');
733
- const request = {
734
- 'currency': currencyId,
735
- };
736
- const instrumentsResponse = await this.publicGetGetInstruments(this.extend(request, params));
706
+ const parsedMarkets = {};
707
+ let fetchAllMarkets = undefined;
708
+ [fetchAllMarkets, params] = this.handleOptionAndParams(params, 'fetchMarkets', 'fetchAllMarkets', true);
709
+ if (fetchAllMarkets) {
710
+ const instrumentsResponse = await this.publicGetGetInstruments(params);
711
+ instrumentsResponses.push(instrumentsResponse);
712
+ }
713
+ else {
714
+ const currenciesResponse = await this.publicGetGetCurrencies(params);
737
715
  //
738
716
  // {
739
- // "jsonrpc":"2.0",
740
- // "result":[
717
+ // "jsonrpc": "2.0",
718
+ // "result": [
741
719
  // {
742
- // "tick_size":0.0005,
743
- // "taker_commission":0.0003,
744
- // "strike":52000.0,
745
- // "settlement_period":"month",
746
- // "settlement_currency":"BTC",
747
- // "quote_currency":"BTC",
748
- // "option_type":"put", // put, call
749
- // "min_trade_amount":0.1,
750
- // "maker_commission":0.0003,
751
- // "kind":"option",
752
- // "is_active":true,
753
- // "instrument_name":"BTC-24JUN22-52000-P",
754
- // "expiration_timestamp":1656057600000,
755
- // "creation_timestamp":1648199543000,
756
- // "counter_currency":"USD",
757
- // "contract_size":1.0,
758
- // "block_trade_commission":0.0003,
759
- // "base_currency":"BTC"
760
- // },
761
- // {
762
- // "tick_size":0.5,
763
- // "taker_commission":0.0005,
764
- // "settlement_period":"month", // month, week
765
- // "settlement_currency":"BTC",
766
- // "quote_currency":"USD",
767
- // "min_trade_amount":10.0,
768
- // "max_liquidation_commission":0.0075,
769
- // "max_leverage":50,
770
- // "maker_commission":0.0,
771
- // "kind":"future",
772
- // "is_active":true,
773
- // "instrument_name":"BTC-27MAY22",
774
- // "future_type":"reversed",
775
- // "expiration_timestamp":1653638400000,
776
- // "creation_timestamp":1648195209000,
777
- // "counter_currency":"USD",
778
- // "contract_size":10.0,
779
- // "block_trade_commission":0.0001,
780
- // "base_currency":"BTC"
781
- // },
782
- // {
783
- // "tick_size":0.5,
784
- // "taker_commission":0.0005,
785
- // "settlement_period":"perpetual",
786
- // "settlement_currency":"BTC",
787
- // "quote_currency":"USD",
788
- // "min_trade_amount":10.0,
789
- // "max_liquidation_commission":0.0075,
790
- // "max_leverage":50,
791
- // "maker_commission":0.0,
792
- // "kind":"future",
793
- // "is_active":true,
794
- // "instrument_name":"BTC-PERPETUAL",
795
- // "future_type":"reversed",
796
- // "expiration_timestamp":32503708800000,
797
- // "creation_timestamp":1534242287000,
798
- // "counter_currency":"USD",
799
- // "contract_size":10.0,
800
- // "block_trade_commission":0.0001,
801
- // "base_currency":"BTC"
802
- // },
720
+ // "withdrawal_priorities": [
721
+ // { value: 0.15, name: "very_low" },
722
+ // { value: 1.5, name: "very_high" },
723
+ // ],
724
+ // "withdrawal_fee": 0.0005,
725
+ // "min_withdrawal_fee": 0.0005,
726
+ // "min_confirmations": 1,
727
+ // "fee_precision": 4,
728
+ // "currency_long": "Bitcoin",
729
+ // "currency": "BTC",
730
+ // "coin_type": "BITCOIN"
731
+ // }
803
732
  // ],
804
- // "usIn":1648691472831791,
805
- // "usOut":1648691472831896,
806
- // "usDiff":105,
807
- // "testnet":false
733
+ // "usIn": 1583761588590479,
734
+ // "usOut": 1583761588590544,
735
+ // "usDiff": 65,
736
+ // "testnet": false
808
737
  // }
809
738
  //
810
- const instrumentsResult = this.safeValue(instrumentsResponse, 'result', []);
739
+ const currenciesResult = this.safeValue(currenciesResponse, 'result', []);
740
+ for (let i = 0; i < currenciesResult.length; i++) {
741
+ const currencyId = this.safeString(currenciesResult[i], 'currency');
742
+ const request = {
743
+ 'currency': currencyId,
744
+ };
745
+ const instrumentsResponse = await this.publicGetGetInstruments(this.extend(request, params));
746
+ //
747
+ // {
748
+ // "jsonrpc":"2.0",
749
+ // "result":[
750
+ // {
751
+ // "tick_size":0.0005,
752
+ // "taker_commission":0.0003,
753
+ // "strike":52000.0,
754
+ // "settlement_period":"month",
755
+ // "settlement_currency":"BTC",
756
+ // "quote_currency":"BTC",
757
+ // "option_type":"put", // put, call
758
+ // "min_trade_amount":0.1,
759
+ // "maker_commission":0.0003,
760
+ // "kind":"option",
761
+ // "is_active":true,
762
+ // "instrument_name":"BTC-24JUN22-52000-P",
763
+ // "expiration_timestamp":1656057600000,
764
+ // "creation_timestamp":1648199543000,
765
+ // "counter_currency":"USD",
766
+ // "contract_size":1.0,
767
+ // "block_trade_commission":0.0003,
768
+ // "base_currency":"BTC"
769
+ // },
770
+ // {
771
+ // "tick_size":0.5,
772
+ // "taker_commission":0.0005,
773
+ // "settlement_period":"month", // month, week
774
+ // "settlement_currency":"BTC",
775
+ // "quote_currency":"USD",
776
+ // "min_trade_amount":10.0,
777
+ // "max_liquidation_commission":0.0075,
778
+ // "max_leverage":50,
779
+ // "maker_commission":0.0,
780
+ // "kind":"future",
781
+ // "is_active":true,
782
+ // "instrument_name":"BTC-27MAY22",
783
+ // "future_type":"reversed",
784
+ // "expiration_timestamp":1653638400000,
785
+ // "creation_timestamp":1648195209000,
786
+ // "counter_currency":"USD",
787
+ // "contract_size":10.0,
788
+ // "block_trade_commission":0.0001,
789
+ // "base_currency":"BTC"
790
+ // },
791
+ // {
792
+ // "tick_size":0.5,
793
+ // "taker_commission":0.0005,
794
+ // "settlement_period":"perpetual",
795
+ // "settlement_currency":"BTC",
796
+ // "quote_currency":"USD",
797
+ // "min_trade_amount":10.0,
798
+ // "max_liquidation_commission":0.0075,
799
+ // "max_leverage":50,
800
+ // "maker_commission":0.0,
801
+ // "kind":"future",
802
+ // "is_active":true,
803
+ // "instrument_name":"BTC-PERPETUAL",
804
+ // "future_type":"reversed",
805
+ // "expiration_timestamp":32503708800000,
806
+ // "creation_timestamp":1534242287000,
807
+ // "counter_currency":"USD",
808
+ // "contract_size":10.0,
809
+ // "block_trade_commission":0.0001,
810
+ // "base_currency":"BTC"
811
+ // },
812
+ // ],
813
+ // "usIn":1648691472831791,
814
+ // "usOut":1648691472831896,
815
+ // "usDiff":105,
816
+ // "testnet":false
817
+ // }
818
+ //
819
+ instrumentsResponses.push(instrumentsResponse);
820
+ }
821
+ }
822
+ for (let i = 0; i < instrumentsResponses.length; i++) {
823
+ const instrumentsResult = this.safeValue(instrumentsResponses[i], 'result', []);
811
824
  for (let k = 0; k < instrumentsResult.length; k++) {
812
825
  const market = instrumentsResult[k];
813
826
  const kind = this.safeString(market, 'kind');
@@ -443,7 +443,8 @@ class gemini extends gemini$1 {
443
443
  // '<td>0.01 USD', // quote currency price increment
444
444
  // '</tr>'
445
445
  // ]
446
- const marketId = cells[0].replace('<td>', '');
446
+ let marketId = cells[0].replace('<td>', '');
447
+ marketId = marketId.replace('*', '');
447
448
  // const base = this.safeCurrencyCode (baseId);
448
449
  const minAmountString = cells[1].replace('<td>', '');
449
450
  const minAmountParts = minAmountString.split(' ');
@@ -596,10 +596,7 @@ class kraken extends kraken$1 {
596
596
  if (currencyId !== undefined) {
597
597
  if (currencyId.length > 3) {
598
598
  if ((currencyId.indexOf('X') === 0) || (currencyId.indexOf('Z') === 0)) {
599
- if (currencyId.indexOf('.') > 0) {
600
- return super.safeCurrency(currencyId, currency);
601
- }
602
- else {
599
+ if (!(currencyId.indexOf('.') > 0)) {
603
600
  currencyId = currencyId.slice(1);
604
601
  }
605
602
  }
@@ -648,8 +645,13 @@ class kraken extends kraken$1 {
648
645
  // {
649
646
  // "error": [],
650
647
  // "result": {
651
- // "ADA": { "aclass": "currency", "altname": "ADA", "decimals": 8, "display_decimals": 6 },
652
- // "BCH": { "aclass": "currency", "altname": "BCH", "decimals": 10, "display_decimals": 5 },
648
+ // "BCH": {
649
+ // "aclass": "currency",
650
+ // "altname": "BCH",
651
+ // "decimals": 10,
652
+ // "display_decimals": 5
653
+ // "status": "enabled",
654
+ // },
653
655
  // ...
654
656
  // },
655
657
  // }
@@ -664,15 +666,15 @@ class kraken extends kraken$1 {
664
666
  // see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
665
667
  // to add support for multiple withdrawal/deposit methods and
666
668
  // differentiated fees for each particular method
667
- const code = this.safeCurrencyCode(this.safeString(currency, 'altname'));
669
+ const code = this.safeCurrencyCode(id);
668
670
  const precision = this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals')));
669
671
  // assumes all currencies are active except those listed above
670
- const active = !this.inArray(code, this.options['inactiveCurrencies']);
672
+ const active = this.safeString(currency, 'status') === 'enabled';
671
673
  result[code] = {
672
674
  'id': id,
673
675
  'code': code,
674
676
  'info': currency,
675
- 'name': code,
677
+ 'name': this.safeString(currency, 'altname'),
676
678
  'active': active,
677
679
  'deposit': undefined,
678
680
  'withdraw': undefined,
@@ -2701,15 +2703,15 @@ class kraken extends kraken$1 {
2701
2703
  * @name kraken#fetchPositions
2702
2704
  * @description fetch all open positions
2703
2705
  * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenPositions
2704
- * @param {string[]|undefined} symbols not used by kraken fetchPositions ()
2706
+ * @param {string[]} [symbols] not used by kraken fetchPositions ()
2705
2707
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2706
2708
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2707
2709
  */
2708
2710
  await this.loadMarkets();
2709
2711
  const request = {
2710
- // 'txid': 'comma delimited list of transaction ids to restrict output to',
2711
- // 'docalcs': false, // whether or not to include profit/loss calculations
2712
- // 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair
2712
+ // 'txid': 'comma delimited list of transaction ids to restrict output to',
2713
+ 'docalcs': 'true',
2714
+ 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair
2713
2715
  };
2714
2716
  const response = await this.privatePostOpenPositions(this.extend(request, params));
2715
2717
  //
@@ -2757,9 +2759,58 @@ class kraken extends kraken$1 {
2757
2759
  // ]
2758
2760
  // }
2759
2761
  //
2760
- const result = this.safeValue(response, 'result');
2761
- // todo unify parsePosition/parsePositions
2762
- return result;
2762
+ symbols = this.marketSymbols(symbols);
2763
+ const result = this.safeList(response, 'result');
2764
+ const results = this.parsePositions(result, symbols);
2765
+ return this.filterByArrayPositions(results, 'symbol', symbols, false);
2766
+ }
2767
+ parsePosition(position, market = undefined) {
2768
+ //
2769
+ // {
2770
+ // "pair": "ETHUSDT",
2771
+ // "positions": "1",
2772
+ // "type": "buy",
2773
+ // "leverage": "2.00000",
2774
+ // "cost": "28.49800",
2775
+ // "fee": "0.07979",
2776
+ // "vol": "0.02000000",
2777
+ // "vol_closed": "0.00000000",
2778
+ // "margin": "14.24900"
2779
+ // }
2780
+ //
2781
+ const marketId = this.safeString(position, 'pair');
2782
+ const rawSide = this.safeString(position, 'type');
2783
+ const side = (rawSide === 'buy') ? 'long' : 'short';
2784
+ return this.safePosition({
2785
+ 'info': position,
2786
+ 'id': undefined,
2787
+ 'symbol': this.safeSymbol(marketId, market),
2788
+ 'notional': undefined,
2789
+ 'marginMode': undefined,
2790
+ 'liquidationPrice': undefined,
2791
+ 'entryPrice': undefined,
2792
+ 'unrealizedPnl': this.safeNumber(position, 'net'),
2793
+ 'realizedPnl': undefined,
2794
+ 'percentage': undefined,
2795
+ 'contracts': this.safeNumber(position, 'vol'),
2796
+ 'contractSize': undefined,
2797
+ 'markPrice': undefined,
2798
+ 'lastPrice': undefined,
2799
+ 'side': side,
2800
+ 'hedged': undefined,
2801
+ 'timestamp': undefined,
2802
+ 'datetime': undefined,
2803
+ 'lastUpdateTimestamp': undefined,
2804
+ 'maintenanceMargin': undefined,
2805
+ 'maintenanceMarginPercentage': undefined,
2806
+ 'collateral': undefined,
2807
+ 'initialMargin': this.safeNumber(position, 'margin'),
2808
+ 'initialMarginPercentage': undefined,
2809
+ 'leverage': this.safeNumber(position, 'leverage'),
2810
+ 'marginRatio': undefined,
2811
+ 'stopLossPrice': undefined,
2812
+ 'takeProfitPrice': undefined,
2813
+ });
2763
2814
  }
2764
2815
  parseAccountType(account) {
2765
2816
  const accountByType = {