use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class AccountServiceIntegration method testMetaData.
@Test
public void testMetaData() throws Exception {
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = exchange.getExchangeMetaData().getCurrencyPairs();
Map<Currency, CurrencyMetaData> currencies = exchange.getExchangeMetaData().getCurrencies();
CurrencyPair currPair;
Currency curr;
currPair = currencyPairs.keySet().stream().filter(cp -> "ETH/BTC".equals(cp.toString())).collect(StreamUtils.singletonCollector());
Assert.assertNotNull(currPair);
curr = currencies.keySet().stream().filter(c -> Currency.BTC.equals(c)).collect(StreamUtils.singletonCollector());
Assert.assertNotNull(curr);
Assert.assertNotNull(curr);
}
use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class AccountServiceIntegration method testBalances.
@Test
public void testBalances() throws Exception {
Wallet wallet = accountService.getAccountInfo().getWallet();
Assert.assertNotNull(wallet);
Map<Currency, Balance> balances = wallet.getBalances();
for (Entry<Currency, Balance> entry : balances.entrySet()) {
Currency curr = entry.getKey();
Balance bal = entry.getValue();
if (0 < bal.getAvailable().doubleValue()) {
Assert.assertSame(curr, bal.getCurrency());
Assert.assertSame(Currency.getInstance(curr.getCurrencyCode()), bal.getCurrency());
}
}
}
use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class BitbayAdapters method adaptAccountInfo.
public static AccountInfo adaptAccountInfo(String userName, BitbayAccountInfoResponse bitbayAccountInfo) {
List<Balance> balances = new ArrayList<>(bitbayAccountInfo.getBitbayBalances().size());
for (Map.Entry<String, BitbayBalance> entry : bitbayAccountInfo.getBitbayBalances().entrySet()) {
Currency currency = Currency.getInstance(entry.getKey());
BitbayBalance balance = entry.getValue();
balances.add(new Balance(currency, balance.getAvailable().add(balance.getLocked()), balance.getAvailable(), balance.getLocked()));
}
return new AccountInfo(userName, Wallet.Builder.from(balances).build());
}
use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class BitbayAccountService method getFundingHistory.
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
Currency currency = null;
if (params instanceof TradeHistoryParamCurrency) {
TradeHistoryParamCurrency tradeHistoryParamCurrency = (TradeHistoryParamCurrency) params;
currency = tradeHistoryParamCurrency.getCurrency();
}
Integer limit = 1000;
if (params instanceof TradeHistoryParamLimit) {
limit = ((TradeHistoryParamLimit) params).getLimit();
}
return history(currency, limit);
}
use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class CCEXAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(ExchangeMetaData exchangeMetaData, List<CCEXMarket> products) {
Map<CurrencyPair, CurrencyPairMetaData> currencyPairs = new HashMap<>();
Map<CurrencyPair, CurrencyPairMetaData> existingCurrencyPairMetadata = exchangeMetaData.getCurrencyPairs();
Map<Currency, CurrencyMetaData> currencies = new HashMap<>();
for (CCEXMarket product : products) {
BigDecimal minSize = product.getMinTradeSize();
CurrencyPair pair = adaptCurrencyPair(product);
CurrencyPairMetaData existingMetaForPair = existingCurrencyPairMetadata.get(pair);
FeeTier[] existingFeeTiers = null;
if (existingMetaForPair != null) {
existingFeeTiers = existingMetaForPair.getFeeTiers();
}
CurrencyPairMetaData cpmd = new CurrencyPairMetaData(null, minSize, null, 0, existingFeeTiers);
currencyPairs.put(pair, cpmd);
currencies.put(pair.base, null);
currencies.put(pair.counter, null);
}
return new ExchangeMetaData(currencyPairs, currencies, null, null, true);
}
Aggregations