class BitfinexExchange extends BaseExchange implements Exchange {

  private static ResilienceRegistries RESILIENCE_REGISTRIES;

  private SynchronizedValueFactory<Long> nonceFactory =
      new AtomicLongIncrementalTime2013NonceFactory();

  @Override
  protected void initServices() {
    this.marketDataService = new BitfinexMarketDataService(this, getResilienceRegistries());
    this.accountService = new BitfinexAccountService(this, getResilienceRegistries());
    this.tradeService = new BitfinexTradeService(this, getResilienceRegistries());
  }

  @Override
  public ResilienceRegistries getResilienceRegistries() {
    if (RESILIENCE_REGISTRIES == null) {
      RESILIENCE_REGISTRIES = BitfinexResilience.createRegistries();
    }
    return RESILIENCE_REGISTRIES;
  }

  @Override
  public ExchangeSpecification getDefaultExchangeSpecification() {

    ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
    exchangeSpecification.setSslUri("https://api.bitfinex.com/");
    exchangeSpecification.setHost("api.bitfinex.com");
    exchangeSpecification.setPort(80);
    exchangeSpecification.setExchangeName("BitFinex");
    exchangeSpecification.setExchangeDescription("BitFinex is a bitcoin exchange.");
    exchangeSpecification.getResilience().setRateLimiterEnabled(true);
    exchangeSpecification.getResilience().setRetryEnabled(true);

    return exchangeSpecification;
  }

  @Override
  public SynchronizedValueFactory<Long> getNonceFactory() {

    return nonceFactory;
  }

  @Override
  public void remoteInit() throws IOException, ExchangeException {<FILL_FUNCTION_BODY>}
}


    try {
      BitfinexMarketDataServiceRaw dataService =
          (BitfinexMarketDataServiceRaw) this.marketDataService;
      List<CurrencyPair> currencyPairs = dataService.getExchangeSymbols();
      exchangeMetaData = BitfinexAdapters.adaptMetaData(currencyPairs, exchangeMetaData);

      // Get the last-price of each pair. It is needed to infer XChange's priceScale out of
      // Bitfinex's pricePercision

      Map<CurrencyPair, BigDecimal> lastPrices =
          Arrays.stream(dataService.getBitfinexTickers(null))
              .map(BitfinexAdapters::adaptTicker)
              .collect(Collectors.toMap(t -> t.getCurrencyPair(), t -> t.getLast()));

      final List<BitfinexSymbolDetail> symbolDetails = dataService.getSymbolDetails();
      exchangeMetaData =
          BitfinexAdapters.adaptMetaData(exchangeMetaData, symbolDetails, lastPrices);

      if (exchangeSpecification.getApiKey() != null
          && exchangeSpecification.getSecretKey() != null) {
        // Bitfinex does not provide any specific wallet health info
        // So instead of wallet status, fetch platform status to get wallet health
        Integer bitfinexPlatformStatusData = dataService.getBitfinexPlatformStatus()[0];
        boolean bitfinexPlatformStatusPresent = bitfinexPlatformStatusData != null;
        int bitfinexPlatformStatus = bitfinexPlatformStatusPresent ? bitfinexPlatformStatusData : 0;
        // Additional remoteInit configuration for authenticated instances
        BitfinexAccountService accountService = (BitfinexAccountService) this.accountService;
        final BitfinexAccountFeesResponse accountFees = accountService.getAccountFees();
        exchangeMetaData =
            BitfinexAdapters.adaptMetaData(
                accountFees,
                bitfinexPlatformStatus,
                bitfinexPlatformStatusPresent,
                exchangeMetaData);

        BitfinexTradeService tradeService = (BitfinexTradeService) this.tradeService;
        final BitfinexAccountInfosResponse[] bitfinexAccountInfos =
            tradeService.getBitfinexAccountInfos();

        exchangeMetaData = BitfinexAdapters.adaptMetaData(bitfinexAccountInfos, exchangeMetaData);
      }
    } catch (BitfinexException e) {
      throw BitfinexErrorAdapter.adapt(e);
    }
  
<methods>public non-sealed void <init>() ,public void applySpecification(org.knowm.xchange.ExchangeSpecification) ,public org.knowm.xchange.service.account.AccountService getAccountService() ,public List<org.knowm.xchange.instrument.Instrument> getExchangeInstruments() ,public org.knowm.xchange.dto.meta.ExchangeMetaData getExchangeMetaData() ,public org.knowm.xchange.ExchangeSpecification getExchangeSpecification() ,public org.knowm.xchange.service.marketdata.MarketDataService getMarketDataService() ,public java.lang.String getMetaDataFileName(org.knowm.xchange.ExchangeSpecification) ,public SynchronizedValueFactory<java.lang.Long> getNonceFactory() ,public org.knowm.xchange.service.trade.TradeService getTradeService() ,public void remoteInit() throws java.io.IOException, org.knowm.xchange.exceptions.ExchangeException,public java.lang.String toString() <variables>protected org.knowm.xchange.service.account.AccountService accountService,protected org.knowm.xchange.dto.meta.ExchangeMetaData exchangeMetaData,protected org.knowm.xchange.ExchangeSpecification exchangeSpecification,protected final Logger logger,protected org.knowm.xchange.service.marketdata.MarketDataService marketDataService,private final SynchronizedValueFactory<java.lang.Long> nonceFactory,protected org.knowm.xchange.service.trade.TradeService tradeService