use of org.knowm.xchange.bitfinex.service.BitfinexAccountService in project XChange by knowm.
the class BitfinexExchange method remoteInit.
@Override
public void remoteInit() throws IOException, ExchangeException {
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);
}
}
use of org.knowm.xchange.bitfinex.service.BitfinexAccountService in project XChange by knowm.
the class BitfinexExchange method initServices.
@Override
protected void initServices() {
this.marketDataService = new BitfinexMarketDataService(this, getResilienceRegistries());
this.accountService = new BitfinexAccountService(this, getResilienceRegistries());
this.tradeService = new BitfinexTradeService(this, getResilienceRegistries());
}
Aggregations