Search in sources :

Example 1 with AccountInfo

use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.

the class CoinfloorBalanceIntegration method fetchBalanceTest.

@Test
public void fetchBalanceTest() throws IOException {
    final ExchangeSpecification specification = new ExchangeSpecification(CoinfloorExchange.class);
    String username = System.getProperty("xchange.coinfloor.username");
    String password = System.getProperty("xchange.coinfloor.password");
    if (username == null || password == null) {
        return;
    }
    specification.setUserName(username);
    specification.setPassword(password);
    Exchange exchange = ExchangeFactory.INSTANCE.createExchange(specification);
    AccountService service = exchange.getAccountService();
    AccountInfo info = service.getAccountInfo();
    logger.info("{}", info);
}
Also used : CoinfloorExchange(org.knowm.xchange.coinfloor.CoinfloorExchange) Exchange(org.knowm.xchange.Exchange) ExchangeSpecification(org.knowm.xchange.ExchangeSpecification) AccountService(org.knowm.xchange.service.account.AccountService) AccountInfo(org.knowm.xchange.dto.account.AccountInfo) Test(org.junit.Test)

Example 2 with AccountInfo

use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.

the class LatokenAccountService method getAccountInfo.

@Override
public AccountInfo getAccountInfo() throws IOException {
    try {
        List<LatokenBalance> latokenBalances = getLatokenBalances();
        List<Balance> balances = latokenBalances.stream().map(latokenBalance -> LatokenAdapters.adaptBalance(latokenBalance)).collect(Collectors.toList());
        Wallet wallet = Wallet.Builder.from(balances).build();
        return new AccountInfo(null, TRADING_FEE, Arrays.asList(wallet), new Date());
    } catch (LatokenException e) {
        throw LatokenErrorAdapter.adapt(e);
    }
}
Also used : AccountInfo(org.knowm.xchange.dto.account.AccountInfo) Arrays(java.util.Arrays) AccountService(org.knowm.xchange.service.account.AccountService) LatokenException(org.knowm.xchange.latoken.dto.LatokenException) Wallet(org.knowm.xchange.dto.account.Wallet) Date(java.util.Date) LatokenBalance(org.knowm.xchange.latoken.dto.account.LatokenBalance) IOException(java.io.IOException) Exchange(org.knowm.xchange.Exchange) Collectors(java.util.stream.Collectors) Balance(org.knowm.xchange.dto.account.Balance) BigDecimal(java.math.BigDecimal) List(java.util.List) LatokenErrorAdapter(org.knowm.xchange.latoken.LatokenErrorAdapter) LatokenAdapters(org.knowm.xchange.latoken.LatokenAdapters) LatokenException(org.knowm.xchange.latoken.dto.LatokenException) LatokenBalance(org.knowm.xchange.latoken.dto.account.LatokenBalance) Wallet(org.knowm.xchange.dto.account.Wallet) LatokenBalance(org.knowm.xchange.latoken.dto.account.LatokenBalance) Balance(org.knowm.xchange.dto.account.Balance) AccountInfo(org.knowm.xchange.dto.account.AccountInfo) Date(java.util.Date)

Example 3 with AccountInfo

use of org.knowm.xchange.dto.account.AccountInfo 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 4 with AccountInfo

use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.

the class BitbayAccountService method getAccountInfo.

@Override
public AccountInfo getAccountInfo() throws IOException {
    List<Wallet> wallets = new ArrayList<>();
    for (BitbayBalances.BitbayBalance balance : balances()) {
        Wallet wallet = Wallet.Builder.from(Arrays.asList(new Balance(Currency.getInstance(balance.getCurrency()), balance.getTotalFunds(), balance.getAvailableFunds(), balance.getLockedFunds()))).id(balance.getId()).build();
        wallets.add(wallet);
    }
    return new AccountInfo(wallets);
}
Also used : Wallet(org.knowm.xchange.dto.account.Wallet) BitbayBalances(org.knowm.xchange.bitbay.v3.dto.BitbayBalances) ArrayList(java.util.ArrayList) Balance(org.knowm.xchange.dto.account.Balance) AccountInfo(org.knowm.xchange.dto.account.AccountInfo)

Example 5 with AccountInfo

use of org.knowm.xchange.dto.account.AccountInfo in project XChange by knowm.

the class AccountDataFetchIntegration method testBalance.

@Test
public void testBalance() throws IOException, InterruptedException {
    if (!BTCTurkDemoUtilsTest.BTCTURK_APIKEY.isEmpty()) {
        // BTCTurkAccountBalance Test
        BTCTurkAccountBalance accountBalance = btcTurkAccountService.getBTCTurkBalance();
        assertThat(accountBalance).isNotEqualTo(null);
        assertThat(accountBalance.getBtctry_maker_fee_percentage()).isEqualTo(new BigDecimal("0.0012711860000000"));
        // AccountInfo Test
        Thread.sleep(1000);
        AccountInfo accountInfo = btcTurkAccountService.getAccountInfo();
        assertThat(accountInfo).isNotEqualTo(null);
    } else
        assertThat(accountService).isNotEqualTo(null);
}
Also used : BTCTurkAccountBalance(org.knowm.xchange.btcturk.dto.account.BTCTurkAccountBalance) BigDecimal(java.math.BigDecimal) AccountInfo(org.knowm.xchange.dto.account.AccountInfo) Test(org.junit.Test) BTCTurkDemoUtilsTest(org.knowm.xchange.btcturk.service.BTCTurkDemoUtilsTest)

Aggregations

AccountInfo (org.knowm.xchange.dto.account.AccountInfo)96 Balance (org.knowm.xchange.dto.account.Balance)50 Wallet (org.knowm.xchange.dto.account.Wallet)35 BigDecimal (java.math.BigDecimal)34 ArrayList (java.util.ArrayList)25 Test (org.junit.Test)23 Currency (org.knowm.xchange.currency.Currency)18 Date (java.util.Date)13 AccountService (org.knowm.xchange.service.account.AccountService)13 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 InputStream (java.io.InputStream)9 Exchange (org.knowm.xchange.Exchange)9 Map (java.util.Map)6 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Arrays (java.util.Arrays)3 FileNotFoundException (java.io.FileNotFoundException)2 ZERO (java.math.BigDecimal.ZERO)2 Collection (java.util.Collection)2