Search in sources :

Example 1 with BitstampBalance

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

the class BitstampAccountDemo method raw.

private static void raw(BitstampAccountServiceRaw accountService) throws IOException {
    // Get the account information
    BitstampBalance bitstampBalance = accountService.getBitstampBalance();
    System.out.println("BitstampBalance: " + bitstampBalance);
    BitstampDepositAddress depositAddress = accountService.getBitstampBitcoinDepositAddress();
    System.out.println("BitstampDepositAddress address: " + depositAddress);
    final List<DepositTransaction> unconfirmedDeposits = accountService.getUnconfirmedDeposits();
    System.out.println("Unconfirmed deposits:");
    for (DepositTransaction unconfirmedDeposit : unconfirmedDeposits) {
        System.out.println(unconfirmedDeposit);
    }
    final List<WithdrawalRequest> withdrawalRequests = accountService.getWithdrawalRequests(50000000l);
    System.out.println("Withdrawal requests:");
    for (WithdrawalRequest unconfirmedDeposit : withdrawalRequests) {
        System.out.println(unconfirmedDeposit);
    }
    BitstampWithdrawal withdrawResult = accountService.withdrawBitstampFunds(Currency.BTC, new BigDecimal(1).movePointLeft(4), "XXX");
    System.out.println("BitstampBooleanResponse = " + withdrawResult);
}
Also used : BitstampDepositAddress(org.knowm.xchange.bitstamp.dto.account.BitstampDepositAddress) DepositTransaction(org.knowm.xchange.bitstamp.dto.account.DepositTransaction) BitstampWithdrawal(org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal) BitstampBalance(org.knowm.xchange.bitstamp.dto.account.BitstampBalance) WithdrawalRequest(org.knowm.xchange.bitstamp.dto.account.WithdrawalRequest) BigDecimal(java.math.BigDecimal)

Example 2 with BitstampBalance

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

the class BitstampFiatWithdrawal method raw.

private static void raw(BitstampAccountServiceRaw accountService) throws IOException {
    // Get the account information
    BitstampBalance bitstampBalance = accountService.getBitstampBalance();
    System.out.println("BitstampBalance: " + bitstampBalance);
    BitstampDepositAddress depositAddress = accountService.getBitstampBitcoinDepositAddress();
    System.out.println("BitstampDepositAddress address: " + depositAddress);
    accountService.withdrawSepa(new BigDecimal("150"), "Test User", "BY13NBRB3600900000002Z00AB00", "DABAIE2D", "Minsk, Belarus, Main street 2", "197372", "Minsk", Country.Belarus.alpha2);
    accountService.withdrawInternational(new BigDecimal("150"), "Test User", "BY13NBRB3600900000002Z00AB00", "DABAIE2D", "Minsk, Belarus, Main street 2", "197372", "Minsk", Country.Belarus.alpha2, "Great Bank", "Great Bank Address", "Great Bank Postal Code", "Great Bank City", "Bank Country Alpha 2 code", BankCurrency.AUD);
}
Also used : BitstampDepositAddress(org.knowm.xchange.bitstamp.dto.account.BitstampDepositAddress) BitstampBalance(org.knowm.xchange.bitstamp.dto.account.BitstampBalance) BigDecimal(java.math.BigDecimal)

Example 3 with BitstampBalance

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

the class BitstampAdapterTest method testAccountInfoAdapter.

@Test
public void testAccountInfoAdapter() throws IOException {
    // Read in the JSON from the example resources
    InputStream is = BitstampAdapterTest.class.getResourceAsStream("/org/knowm/xchange/bitstamp/dto/account/example-accountinfo-data.json");
    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    BitstampBalance bitstampBalance = mapper.readValue(is, BitstampBalance.class);
    AccountInfo accountInfo = BitstampAdapters.adaptAccountInfo(bitstampBalance, "Joe Mama");
    assertThat(accountInfo.getUsername()).isEqualTo("Joe Mama");
    assertThat(accountInfo.getTradingFee()).isEqualTo(new BigDecimal("0.5000"));
    assertThat(accountInfo.getWallet().getBalance(Currency.USD).getCurrency()).isEqualTo(Currency.USD);
    assertThat(accountInfo.getWallet().getBalance(Currency.USD).getTotal()).isEqualTo("172.87");
    assertThat(accountInfo.getWallet().getBalance(Currency.USD).getAvailable()).isEqualTo("0.00");
    assertThat(accountInfo.getWallet().getBalance(Currency.USD).getFrozen()).isEqualTo("172.87");
    assertThat(accountInfo.getWallet().getBalance(Currency.BTC).getCurrency()).isEqualTo(Currency.BTC);
    assertThat(accountInfo.getWallet().getBalance(Currency.BTC).getTotal()).isEqualTo("6.99990000");
    assertThat(accountInfo.getWallet().getBalance(Currency.BTC).getAvailable()).isEqualTo("6.99990000");
    assertThat(accountInfo.getWallet().getBalance(Currency.BTC).getFrozen()).isEqualTo("0");
    assertThat(accountInfo.getWallet().getBalance(Currency.XRP).getCurrency()).isEqualTo(Currency.XRP);
    assertThat(accountInfo.getWallet().getBalance(Currency.XRP).getTotal()).isEqualTo("7771.05654");
}
Also used : BitstampBalance(org.knowm.xchange.bitstamp.dto.account.BitstampBalance) InputStream(java.io.InputStream) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AccountInfo(org.knowm.xchange.dto.account.AccountInfo) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 4 with BitstampBalance

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

the class BitstampAdapters method adaptAccountInfo.

/**
 * Adapts a BitstampBalance to an AccountInfo
 *
 * @param bitstampBalance The Bitstamp balance
 * @param userName The user name
 * @return The account info
 */
public static AccountInfo adaptAccountInfo(BitstampBalance bitstampBalance, String userName) {
    // Adapt to XChange DTOs
    List<Balance> balances = new ArrayList<>();
    for (org.knowm.xchange.bitstamp.dto.account.BitstampBalance.Balance b : bitstampBalance.getBalances()) {
        Balance xchangeBalance = new Balance(Currency.getInstance(b.getCurrency().toUpperCase()), b.getBalance(), b.getAvailable(), b.getReserved(), ZERO, ZERO, b.getBalance().subtract(b.getAvailable()).subtract(b.getReserved()), ZERO);
        balances.add(xchangeBalance);
    }
    return new AccountInfo(userName, bitstampBalance.getFee(), Wallet.Builder.from(balances).build());
}
Also used : BitstampBalance(org.knowm.xchange.bitstamp.dto.account.BitstampBalance) ArrayList(java.util.ArrayList) BitstampBalance(org.knowm.xchange.bitstamp.dto.account.BitstampBalance) Balance(org.knowm.xchange.dto.account.Balance) AccountInfo(org.knowm.xchange.dto.account.AccountInfo)

Example 5 with BitstampBalance

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

the class BitstampSepaWithdrawal method raw.

private static void raw(BitstampAccountServiceRaw accountService) throws IOException {
    // Get the account information
    BitstampBalance bitstampBalance = accountService.getBitstampBalance();
    System.out.println("BitstampBalance: " + bitstampBalance);
    BitstampDepositAddress depositAddress = accountService.getBitstampBitcoinDepositAddress();
    System.out.println("BitstampDepositAddress address: " + depositAddress);
    accountService.withdrawSepa(new BigDecimal("150"), "Kovin Kostner", "BY13NBRB3600900000002Z00AB00", "DABAIE2D", "Minsk, Belarus, Main street 2", "197372", "Minsk", Country.Belarus.alpha2);
}
Also used : BitstampDepositAddress(org.knowm.xchange.bitstamp.dto.account.BitstampDepositAddress) BitstampBalance(org.knowm.xchange.bitstamp.dto.account.BitstampBalance) BigDecimal(java.math.BigDecimal)

Aggregations

BitstampBalance (org.knowm.xchange.bitstamp.dto.account.BitstampBalance)5 BigDecimal (java.math.BigDecimal)4 BitstampDepositAddress (org.knowm.xchange.bitstamp.dto.account.BitstampDepositAddress)3 AccountInfo (org.knowm.xchange.dto.account.AccountInfo)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 BitstampWithdrawal (org.knowm.xchange.bitstamp.dto.account.BitstampWithdrawal)1 DepositTransaction (org.knowm.xchange.bitstamp.dto.account.DepositTransaction)1 WithdrawalRequest (org.knowm.xchange.bitstamp.dto.account.WithdrawalRequest)1 Balance (org.knowm.xchange.dto.account.Balance)1