diff --git a/xchange-bitstamp/src/main/java/org/knowm/xchange/bitstamp/BitstampAdapters.java b/xchange-bitstamp/src/main/java/org/knowm/xchange/bitstamp/BitstampAdapters.java index 20b2266932..dfa74b213b 100644 --- a/xchange-bitstamp/src/main/java/org/knowm/xchange/bitstamp/BitstampAdapters.java +++ b/xchange-bitstamp/src/main/java/org/knowm/xchange/bitstamp/BitstampAdapters.java @@ -242,7 +242,7 @@ public static UserTrades adaptTradeHistory(BitstampUserTransaction[] bitstampUse .timestamp(t.getDatetime()) .id(Long.toString(tradeId)) .orderId(Long.toString(t.getOrderId())) - .feeAmount(t.getFee()) + .feeAmount(getFeeFromString(t.getFee())) .feeCurrency(Currency.getInstance(t.getFeeCurrency().toUpperCase())) .build(); trades.add(trade); @@ -250,6 +250,17 @@ public static UserTrades adaptTradeHistory(BitstampUserTransaction[] bitstampUse return new UserTrades(trades, lastTradeId, TradeSortType.SortByID); } + private static BigDecimal getFeeFromString(String value) { + if("None".equals(value)) { + return BigDecimal.ZERO; + } + try { + return new BigDecimal(value); + } catch (NumberFormatException e) { + return BigDecimal.ZERO; + } + } + public static Map.Entry findNonzeroAmount(BitstampUserTransaction transaction) throws ExchangeException { for (Map.Entry entry : transaction.getAmounts().entrySet()) { @@ -294,7 +305,7 @@ public static List adaptFundingHistory( type, FundingRecord.Status.COMPLETE, null, - trans.getFee(), + getFeeFromString(trans.getFee()), null); fundingRecords.add(record); } diff --git a/xchange-bitstamp/src/main/java/org/knowm/xchange/bitstamp/dto/trade/BitstampUserTransaction.java b/xchange-bitstamp/src/main/java/org/knowm/xchange/bitstamp/dto/trade/BitstampUserTransaction.java index 03a4c6572f..a625afa198 100644 --- a/xchange-bitstamp/src/main/java/org/knowm/xchange/bitstamp/dto/trade/BitstampUserTransaction.java +++ b/xchange-bitstamp/src/main/java/org/knowm/xchange/bitstamp/dto/trade/BitstampUserTransaction.java @@ -20,7 +20,7 @@ public final class BitstampUserTransaction { private final long id; private final long order_id; private final TransactionType type; - private final BigDecimal fee; + private final String fee; private final Map amounts = new HashMap<>(); // possible pairs at the moment: btcusd, btceur, eurusd, xrpusd, xrpeur, xrpbtc private String base; // btc, eur, xrp @@ -41,7 +41,7 @@ public BitstampUserTransaction( @JsonProperty("id") long id, @JsonProperty("order_id") long order_id, @JsonProperty("type") TransactionType type, - @JsonProperty("fee") BigDecimal fee) { + @JsonProperty("fee") String fee) { this.datetime = BitstampUtils.parseDate(datetime); this.id = id; @@ -123,7 +123,7 @@ public String getBaseCurrency() { return base; } - public BigDecimal getFee() { + public String getFee() { return fee; } @@ -169,7 +169,9 @@ public enum TransactionType { sentAssetsToStaking, stakingReward, referralReward, - interAccountTransfer; + interAccountTransfer, + settlementTransfer, + unknown; @JsonCreator public static TransactionType fromString(int type) { @@ -194,10 +196,12 @@ public static TransactionType fromString(int type) { return stakingReward; case 32: return referralReward; + case 33: + return settlementTransfer; case 35: return interAccountTransfer; default: - throw new IllegalArgumentException(type + " has no corresponding value"); + return unknown; } } } diff --git a/xchange-bitstamp/src/test/java/org/knowm/xchange/bitstamp/BitstampCliTester.java b/xchange-bitstamp/src/test/java/org/knowm/xchange/bitstamp/BitstampCliTester.java new file mode 100644 index 0000000000..b9f9d89e7d --- /dev/null +++ b/xchange-bitstamp/src/test/java/org/knowm/xchange/bitstamp/BitstampCliTester.java @@ -0,0 +1,38 @@ +package org.knowm.xchange.bitstamp; + +import java.util.Date; +import java.util.List; +import org.knowm.xchange.Exchange; +import org.knowm.xchange.ExchangeFactory; +import org.knowm.xchange.dto.account.AccountInfo; +import org.knowm.xchange.dto.account.FundingRecord; +import org.knowm.xchange.dto.trade.UserTrades; +import org.knowm.xchange.service.account.AccountService; +import org.knowm.xchange.service.trade.TradeService; +import org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamsTimeSpan; + +public class BitstampCliTester { + public static void main(String[] args) throws Exception{ + Exchange exchange = ExchangeFactory.INSTANCE.createExchange(BitstampExchange.class, System.getenv("BITSTAMP_API_KEY"), System.getenv("BITSTAMP_SECRET_KEY")); + + AccountService accountService = exchange.getAccountService(); + + DefaultTradeHistoryParamsTimeSpan defaultTradeHistoryParamsTimeSpan = new DefaultTradeHistoryParamsTimeSpan(); + defaultTradeHistoryParamsTimeSpan.setStartTime(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24)); + + List fundingRecordList= accountService.getFundingHistory(defaultTradeHistoryParamsTimeSpan); + + System.out.println(fundingRecordList); + + + AccountInfo accountInfo = accountService.getAccountInfo(); + + System.out.println(accountInfo); + + TradeService tradeService = exchange.getTradeService(); + + UserTrades userTrades = tradeService.getTradeHistory(tradeService.createTradeHistoryParams()); + + System.out.println(userTrades); + } +}