use of org.knowm.xchange.bitfinex.v1.dto.trade.BitfinexAccountInfosResponse 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.v1.dto.trade.BitfinexAccountInfosResponse in project XChange by knowm.
the class BitfinexAdapters method adaptMetaData.
public static ExchangeMetaData adaptMetaData(BitfinexAccountInfosResponse[] bitfinexAccountInfos, ExchangeMetaData exchangeMetaData) {
final Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchangeMetaData.getCurrencyPairs();
// lets go with the assumption that the trading fees are common across all trading pairs for
// now.
// also setting the taker_fee as the trading_fee for now.
final CurrencyPairMetaData metaData = new CurrencyPairMetaData(bitfinexAccountInfos[0].getTakerFees().movePointLeft(2), null, null, null, null);
currencyPairs.keySet().parallelStream().forEach(currencyPair -> currencyPairs.merge(currencyPair, metaData, (oldMetaData, newMetaData) -> new CurrencyPairMetaData(newMetaData.getTradingFee(), oldMetaData.getMinimumAmount(), oldMetaData.getMaximumAmount(), oldMetaData.getPriceScale(), oldMetaData.getFeeTiers())));
return exchangeMetaData;
}
Aggregations