Search in sources :

Example 6 with Currency

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);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) Currency(org.knowm.xchange.currency.Currency) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Test(org.junit.Test)

Example 7 with Currency

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());
        }
    }
}
Also used : Wallet(org.knowm.xchange.dto.account.Wallet) Currency(org.knowm.xchange.currency.Currency) Balance(org.knowm.xchange.dto.account.Balance) Test(org.junit.Test)

Example 8 with Currency

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());
}
Also used : Currency(org.knowm.xchange.currency.Currency) ArrayList(java.util.ArrayList) Balance(org.knowm.xchange.dto.account.Balance) BitbayBalance(org.knowm.xchange.bitbay.dto.acount.BitbayBalance) Map(java.util.Map) AccountInfo(org.knowm.xchange.dto.account.AccountInfo) BitbayBalance(org.knowm.xchange.bitbay.dto.acount.BitbayBalance)

Example 9 with Currency

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);
}
Also used : TradeHistoryParamCurrency(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency) Currency(org.knowm.xchange.currency.Currency) TradeHistoryParamCurrency(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrency) TradeHistoryParamLimit(org.knowm.xchange.service.trade.params.TradeHistoryParamLimit)

Example 10 with Currency

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);
}
Also used : CurrencyPairMetaData(org.knowm.xchange.dto.meta.CurrencyPairMetaData) CurrencyMetaData(org.knowm.xchange.dto.meta.CurrencyMetaData) HashMap(java.util.HashMap) ExchangeMetaData(org.knowm.xchange.dto.meta.ExchangeMetaData) Currency(org.knowm.xchange.currency.Currency) CCEXMarket(org.knowm.xchange.ccex.dto.marketdata.CCEXMarket) FeeTier(org.knowm.xchange.dto.meta.FeeTier) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

Currency (org.knowm.xchange.currency.Currency)159 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)75 BigDecimal (java.math.BigDecimal)67 ArrayList (java.util.ArrayList)60 Balance (org.knowm.xchange.dto.account.Balance)38 CurrencyMetaData (org.knowm.xchange.dto.meta.CurrencyMetaData)35 CurrencyPairMetaData (org.knowm.xchange.dto.meta.CurrencyPairMetaData)32 HashMap (java.util.HashMap)28 Test (org.junit.Test)27 Map (java.util.Map)22 Date (java.util.Date)21 AccountInfo (org.knowm.xchange.dto.account.AccountInfo)19 FundingRecord (org.knowm.xchange.dto.account.FundingRecord)19 IOException (java.io.IOException)18 ExchangeMetaData (org.knowm.xchange.dto.meta.ExchangeMetaData)18 List (java.util.List)17 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)15 OrderType (org.knowm.xchange.dto.Order.OrderType)14 UserTrade (org.knowm.xchange.dto.trade.UserTrade)14 Collectors (java.util.stream.Collectors)11