Skip to content

Commit d277674

Browse files
authored
Merge branch 'develop' into develop
2 parents e637017 + 4889a8f commit d277674

File tree

90 files changed

+7030
-1247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+7030
-1247
lines changed

xchange-abucoins/src/main/java/org/knowm/xchange/abucoins/AbucoinsAdapters.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static Trade adaptTrade(AbucoinsTrade trade, CurrencyPair currencyPair) {
111111
/**
112112
* Adapts a AbucoinsTrade[] to a Trades Object
113113
*
114-
* @param cexioTrades The Abucoins trade data returned by API
114+
* @param abucoinsTrades The Abucoins trade data returned by API
115115
* @param currencyPair trade currencies
116116
* @return The trades
117117
*/
@@ -149,7 +149,7 @@ public static Ticker adaptTicker(AbucoinsTicker ticker, CurrencyPair currencyPai
149149
/**
150150
* Adapts Cex.IO Depth to OrderBook Object
151151
*
152-
* @param depth Cex.IO order book
152+
* @param abucoinsOrderBook Cex.IO order book
153153
* @param currencyPair The currency pair (e.g. BTC/USD)
154154
* @return The XChange OrderBook
155155
*/
@@ -172,7 +172,7 @@ public static AccountInfo adaptAccountInfo(AbucoinsAccount[] accounts) {
172172
/**
173173
* Adapts AbucoinsBalanceInfo to Wallet
174174
*
175-
* @param cexIOBalanceInfo AbucoinsBalanceInfo balance
175+
* @param account Abucoins account
176176
* @return The account info
177177
*/
178178
public static Wallet adaptWallet(AbucoinsAccount account) {
@@ -196,7 +196,7 @@ public static List<LimitOrder> createOrders(CurrencyPair currencyPair, OrderType
196196

197197
public static LimitOrder createOrder(CurrencyPair currencyPair, AbucoinsOrderBook.LimitOrder priceAndAmount, OrderType orderType) {
198198

199-
return new LimitOrder(orderType, priceAndAmount.getPrice(), currencyPair, "", null, priceAndAmount.getSize()); //??
199+
return new LimitOrder(orderType, priceAndAmount.getSize(), currencyPair, "", null, priceAndAmount.getPrice()); //??
200200
}
201201

202202
public static OpenOrders adaptOpenOrders(AbucoinsOrder[] orders) {
@@ -322,10 +322,6 @@ public static AbucoinsCreateLimitOrderRequest adaptAbucoinsCreateLimitOrderReque
322322
}
323323

324324
public static String[] adaptToSetOfIDs(String resp) {
325-
StringTokenizer tok = new StringTokenizer(resp, "[], ");
326-
List<String> res = new ArrayList<>();
327-
while ( tok.hasMoreTokens() )
328-
res.add( tok.nextToken());
329-
return res.toArray(new String[ res.size()]);
325+
return resp.replaceAll("[\\[\\\"\\] ]", "").split(",");
330326
}
331327
}

xchange-abucoins/src/test/java/org/knowm/xchange/abucoins/AbucoinsAdaptersSplitIDsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public class AbucoinsAdaptersSplitIDsTest {
99

1010
@Test
1111
public void testSingleID() {
12-
String[] string = AbucoinsAdapters.adaptToSetOfIDs("[1111]");
12+
String[] string = AbucoinsAdapters.adaptToSetOfIDs("[\"1111\"]");
1313
assertNotNull("null response", string);
1414
assertEquals("wrong number of strings", 1, string.length);
1515
assertEquals("Wrong value", "1111", string[0]);
1616
}
1717

1818
@Test
1919
public void testMultipleIDs() {
20-
String[] string = AbucoinsAdapters.adaptToSetOfIDs("[1111,2222, 3333]");
20+
String[] string = AbucoinsAdapters.adaptToSetOfIDs("[\"1111\",\"2222\", \"3333\"]");
2121
assertNotNull("null response", string);
2222
assertEquals("wrong number of strings", 3, string.length);
2323
assertEquals("Wrong value", "1111", string[0]);

xchange-anx/src/main/resources/anxpro.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
"max_amount": 100000.00000000,
5656
"price_scale": 5
5757
},
58+
"ETH/USD": {
59+
"min_amount": 0.01000000,
60+
"max_amount": 100000.00000000,
61+
"price_scale": 5
62+
},
5863
"DOGE/BTC": {
5964
"min_amount": 10000.00000000,
6065
"max_amount": 10000000000.00000000,

xchange-binance/src/main/java/org/knowm/xchange/binance/service/BinanceAccountService.java

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
import java.util.stream.Collectors;
99

1010
import org.knowm.xchange.Exchange;
11-
import org.knowm.xchange.binance.BinanceAdapters;
12-
import org.knowm.xchange.binance.dto.BinanceException;
1311
import org.knowm.xchange.binance.dto.account.BinanceAccountInformation;
14-
import org.knowm.xchange.binance.dto.account.DepositAddress;
1512
import org.knowm.xchange.currency.Currency;
1613
import org.knowm.xchange.dto.account.AccountInfo;
1714
import org.knowm.xchange.dto.account.Balance;
@@ -41,53 +38,38 @@ public BinanceAccountService(Exchange exchange) {
4138
public AccountInfo getAccountInfo() throws IOException {
4239
Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow");
4340
BinanceAccountInformation acc = super.account(recvWindow, getTimestamp());
44-
List<Balance> balances = acc.balances.stream()
45-
.map(b -> new Balance(b.getCurrency(), b.getTotal(), b.getAvailable()))
41+
List<Balance> balances = acc.balances.stream().map(b -> new Balance(b.getCurrency(), b.getTotal(), b.getAvailable()))
4642
.collect(Collectors.toList());
4743
return new AccountInfo(new Wallet(balances));
4844
}
4945

5046
@Override
51-
public String withdrawFunds(Currency currency, BigDecimal amount, String address)
52-
throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {
53-
return withdraw0(currency.getCurrencyCode(), address, amount);
47+
public String withdrawFunds(Currency currency, BigDecimal amount,
48+
String address) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {
49+
return super.withdraw(currency.getCurrencyCode(), address, amount);
5450
}
5551

5652
@Override
57-
public String withdrawFunds(WithdrawFundsParams params)
58-
throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {
59-
if (!(params instanceof DefaultWithdrawFundsParams)) {
53+
public String withdrawFunds(
54+
WithdrawFundsParams params) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {
55+
if (!(params instanceof DefaultWithdrawFundsParams)) {
6056
throw new RuntimeException("DefaultWithdrawFundsParams must be provided.");
6157
}
6258
String id = null;
6359
if (params instanceof RippleWithdrawFundsParams) {
6460
RippleWithdrawFundsParams rippleParams = null;
65-
rippleParams = (RippleWithdrawFundsParams)params;
66-
id = withdraw0(rippleParams.currency.getCurrencyCode(), rippleParams.address, rippleParams.tag, rippleParams.amount);
61+
rippleParams = (RippleWithdrawFundsParams) params;
62+
id = super.withdraw(rippleParams.currency.getCurrencyCode(), rippleParams.address, rippleParams.tag, rippleParams.amount);
6763
} else {
6864
DefaultWithdrawFundsParams p = (DefaultWithdrawFundsParams) params;
69-
id = withdraw0(p.currency.getCurrencyCode(), p.address, p.amount);
65+
id = super.withdraw(p.currency.getCurrencyCode(), p.address, p.amount);
7066
}
7167
return id;
7268
}
7369

74-
private String withdraw0(String asset, String address, BigDecimal amount) throws IOException, BinanceException {
75-
// the name parameter seams to be mandatory
76-
String name = address.length() <= 10 ? address : address.substring(0, 10);
77-
return super.withdraw(asset, address, amount, name, null, getTimestamp());
78-
}
79-
private String withdraw0(String asset, String address, String addressTag, BigDecimal amount) throws IOException, BinanceException {
80-
// the name parameter seams to be mandatory
81-
String name = address.length() <= 10 ? address : address.substring(0, 10);
82-
Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow");
83-
return super.withdraw(asset, address, addressTag, amount, name, recvWindow, getTimestamp());
84-
}
85-
8670
@Override
8771
public String requestDepositAddress(Currency currency, String... args) throws IOException {
88-
Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow");
89-
DepositAddress depositAddress = binance.depositAddress(BinanceAdapters.toSymbol(currency), recvWindow, System.currentTimeMillis(), apiKey, super.signatureCreator);
90-
return depositAddress.address;
72+
return super.requestDepositAddress(currency).address;
9173
}
9274

9375
@Override
@@ -96,8 +78,7 @@ public TradeHistoryParams createFundingHistoryParams() {
9678
}
9779

9880
@Override
99-
public List<FundingRecord> getFundingHistory(TradeHistoryParams params)
100-
throws IOException {
81+
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
10182
String asset = null;
10283
if (params instanceof TradeHistoryParamCurrency) {
10384
TradeHistoryParamCurrency cp = (TradeHistoryParamCurrency) params;
@@ -133,13 +114,15 @@ public List<FundingRecord> getFundingHistory(TradeHistoryParams params)
133114
List<FundingRecord> result = new ArrayList<>();
134115
if (withdrawals) {
135116
super.withdrawHistory(asset, startTime, endTime, recvWindow, getTimestamp()).forEach(w -> {
136-
result.add(new FundingRecord(w.address, new Date(w.applyTime), Currency.getInstance(w.asset), w.amount, w.id, w.txId, Type.WITHDRAWAL, withdrawStatus(w.status), null, null, null));
117+
result.add(new FundingRecord(w.address, new Date(w.applyTime), Currency.getInstance(w.asset), w.amount, w.id, w.txId, Type.WITHDRAWAL,
118+
withdrawStatus(w.status), null, null, null));
137119
});
138120
}
139121

140122
if (deposits) {
141123
super.depositHistory(asset, startTime, endTime, recvWindow, getTimestamp()).forEach(d -> {
142-
result.add(new FundingRecord(d.address, new Date(d.insertTime), Currency.getInstance(d.asset), d.amount, null, d.txId, Type.DEPOSIT, depositStatus(d.status), null, null, null));
124+
result.add(new FundingRecord(d.address, new Date(d.insertTime), Currency.getInstance(d.asset), d.amount, null, d.txId, Type.DEPOSIT,
125+
depositStatus(d.status), null, null, null));
143126
});
144127
}
145128

xchange-binance/src/main/java/org/knowm/xchange/binance/service/BinanceAccountServiceRaw.java

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
import java.util.List;
66

77
import org.knowm.xchange.Exchange;
8+
import org.knowm.xchange.binance.BinanceAdapters;
89
import org.knowm.xchange.binance.dto.BinanceException;
910
import org.knowm.xchange.binance.dto.account.BinanceAccountInformation;
11+
import org.knowm.xchange.binance.dto.account.DepositAddress;
1012
import org.knowm.xchange.binance.dto.account.DepositList;
1113
import org.knowm.xchange.binance.dto.account.DepositList.BinanceDeposit;
1214
import org.knowm.xchange.binance.dto.account.WapiResponse;
1315
import org.knowm.xchange.binance.dto.account.WithdrawList;
1416
import org.knowm.xchange.binance.dto.account.WithdrawRequest;
17+
import org.knowm.xchange.currency.Currency;
1518

1619
import com.fasterxml.jackson.databind.ObjectMapper;
1720

@@ -27,31 +30,51 @@ public BinanceAccountInformation account(Long recvWindow, long timestamp) throws
2730

2831
// the /wapi endpoint of binance is not stable yet and can be changed in future, there is also a lack of current documentation
2932

30-
public String withdraw(String asset, String address, BigDecimal amount, String name, Long recvWindow
31-
, long timestamp) throws IOException, BinanceException {
33+
public String withdraw(String asset, String address, BigDecimal amount) throws IOException, BinanceException {
34+
// the name parameter seams to be mandatory
35+
String name = address.length() <= 10 ? address : address.substring(0, 10);
36+
return withdraw(asset, address, amount, name, null, getTimestamp());
37+
}
38+
39+
public String withdraw(String asset, String address, String addressTag, BigDecimal amount) throws IOException, BinanceException {
40+
// the name parameter seams to be mandatory
41+
String name = address.length() <= 10 ? address : address.substring(0, 10);
42+
Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow");
43+
return withdraw(asset, address, addressTag, amount, name, recvWindow, getTimestamp());
44+
}
45+
46+
private String withdraw(String asset, String address, BigDecimal amount, String name, Long recvWindow,
47+
long timestamp) throws IOException, BinanceException {
3248
WithdrawRequest result = binance.withdraw(asset, address, null, amount, name, recvWindow, timestamp, super.apiKey, super.signatureCreator);
3349
checkWapiResponse(result);
3450
return result.getData();
3551
}
3652

37-
public String withdraw(String asset, String address, String addressTag, BigDecimal amount, String name, Long recvWindow
38-
, long timestamp) throws IOException, BinanceException {
53+
private String withdraw(String asset, String address, String addressTag, BigDecimal amount, String name, Long recvWindow,
54+
long timestamp) throws IOException, BinanceException {
3955
WithdrawRequest result = binance.withdraw(asset, address, addressTag, amount, name, recvWindow, timestamp, super.apiKey, super.signatureCreator);
4056
checkWapiResponse(result);
4157
return result.getData();
4258
}
4359

44-
public List<BinanceDeposit> depositHistory(String asset, Long startTime, Long endTime, Long recvWindow, long timestamp) throws BinanceException, IOException {
60+
public DepositAddress requestDepositAddress(Currency currency) throws IOException {
61+
Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow");
62+
return binance.depositAddress(BinanceAdapters.toSymbol(currency), recvWindow, System.currentTimeMillis(), apiKey, super.signatureCreator);
63+
}
64+
65+
public List<BinanceDeposit> depositHistory(String asset, Long startTime, Long endTime, Long recvWindow,
66+
long timestamp) throws BinanceException, IOException {
4567
DepositList result = binance.depositHistory(asset, startTime, endTime, recvWindow, timestamp, super.apiKey, super.signatureCreator);
4668
return checkWapiResponse(result);
4769
}
4870

49-
public List<WithdrawList.BinanceWithdraw> withdrawHistory(String asset, Long startTime, Long endTime, Long recvWindow, long timestamp) throws BinanceException, IOException {
71+
public List<WithdrawList.BinanceWithdraw> withdrawHistory(String asset, Long startTime, Long endTime, Long recvWindow,
72+
long timestamp) throws BinanceException, IOException {
5073
WithdrawList result = binance.withdrawHistory(asset, startTime, endTime, recvWindow, timestamp, super.apiKey, super.signatureCreator);
5174
return checkWapiResponse(result);
5275
}
5376

54-
private <T> T checkWapiResponse(WapiResponse<T> result){
77+
private <T> T checkWapiResponse(WapiResponse<T> result) {
5578
if (!result.success) {
5679
BinanceException exception;
5780
try {

xchange-bitbay/src/main/java/org/knowm/xchange/bitbay/service/BitbayTradeService.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
import org.knowm.xchange.exceptions.NotAvailableFromExchangeException;
1717
import org.knowm.xchange.exceptions.NotYetImplementedForExchangeException;
1818
import org.knowm.xchange.service.trade.TradeService;
19-
import org.knowm.xchange.service.trade.params.CancelOrderByIdParams;
20-
import org.knowm.xchange.service.trade.params.CancelOrderParams;
21-
import org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair;
22-
import org.knowm.xchange.service.trade.params.TradeHistoryParams;
23-
import org.knowm.xchange.service.trade.params.TradeHistoryParamsZero;
19+
import org.knowm.xchange.service.trade.params.*;
2420
import org.knowm.xchange.service.trade.params.orders.OpenOrdersParams;
2521

2622
/**
@@ -95,7 +91,7 @@ public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException
9591

9692
@Override
9793
public TradeHistoryParams createTradeHistoryParams() {
98-
return new TradeHistoryParamsZero();
94+
return new TradeHistoryParamsAll();
9995
}
10096

10197
@Override

xchange-bitbay/src/main/java/org/knowm/xchange/bitbay/service/BitbayTradeServiceRaw.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public List<BitbayOrder> getBitbayOpenOrders() throws IOException, ExchangeExcep
2727
}
2828

2929
public List<Map> getBitbayTransactions(CurrencyPair currencyPair) throws IOException, ExchangeException {
30-
return bitbayAuthenticated.transactions(apiKey, sign, exchange.getNonceFactory(), currencyPair == null ? null : currencyPair.toString());
30+
return bitbayAuthenticated.transactions(apiKey, sign, exchange.getNonceFactory(), currencyPair == null ? null : currencyPair.base.toString()+"-"+currencyPair.counter.toString());
3131
}
3232

3333
public BitbayTradeResponse placeBitbayOrder(LimitOrder order) throws IOException {

xchange-bitfinex/src/main/java/org/knowm/xchange/bitfinex/v1/dto/marketdata/BitfinexTicker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class BitfinexTicker {
1313
private final BigDecimal low;
1414
private final BigDecimal last;
1515
private final BigDecimal volume;
16-
private final float timestamp;
16+
private final double timestamp;
1717

1818
/**
1919
* @param mid
@@ -27,7 +27,7 @@ public class BitfinexTicker {
2727
*/
2828
public BitfinexTicker(@JsonProperty("mid") BigDecimal mid, @JsonProperty("bid") BigDecimal bid, @JsonProperty("ask") BigDecimal ask,
2929
@JsonProperty("low") BigDecimal low, @JsonProperty("high") BigDecimal high, @JsonProperty("last_price") BigDecimal last,
30-
@JsonProperty("timestamp") float timestamp, @JsonProperty("volume") BigDecimal volume) {
30+
@JsonProperty("timestamp") double timestamp, @JsonProperty("volume") BigDecimal volume) {
3131

3232
this.mid = mid;
3333
this.bid = bid;
@@ -74,7 +74,7 @@ public BigDecimal getVolume() {
7474
return volume;
7575
}
7676

77-
public float getTimestamp() {
77+
public double getTimestamp() {
7878

7979
return timestamp;
8080
}

xchange-bitfinex/src/main/resources/bitfinex.json

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"price_scale": 2,
55
"min_amount": 0.01000000
66
},
7+
"BTC/EUR": {
8+
"price_scale": 2,
9+
"min_amount": 0.01000000
10+
},
711
"LTC/USD": {
812
"price_scale": 4,
913
"min_amount": 0.10000000
@@ -12,6 +16,10 @@
1216
"price_scale": 6,
1317
"min_amount": 0.10000000
1418
},
19+
"BTG/BTC": {
20+
"price_scale": 6,
21+
"min_amount": 0.10000000
22+
},
1523
"ETH/USD": {
1624
"price_scale": 4,
1725
"min_amount": 0.10000000
@@ -96,6 +104,14 @@
96104
"price_scale": 8,
97105
"min_amount": 0.10000000
98106
},
107+
"OMG/BTC": {
108+
"price_scale": 8,
109+
"min_amount": 0.10000000
110+
},
111+
"OMG/ETH": {
112+
"price_scale": 8,
113+
"min_amount": 0.1
114+
},
99115
"BCH/USD": {
100116
"price_scale": 4,
101117
"min_amount": 0.10000000
@@ -104,15 +120,15 @@
104120
"currencies": {
105121
"BTC": {
106122
"scale": 8,
107-
"withdrawal_fee": 0.0008
123+
"withdrawal_fee": 0.0005
108124
},
109125
"BCH": {
110126
"scale": 8,
111-
"withdrawal_fee": 0.0001
127+
"withdrawal_fee": 0.0005
112128
},
113129
"ETH": {
114130
"scale": 8,
115-
"withdrawal_fee": 0.00405
131+
"withdrawal_fee": 0.01
116132
},
117133
"ETC": {
118134
"scale": 8,
@@ -128,7 +144,11 @@
128144
},
129145
"USD": {
130146
"scale": 2,
131-
"withdrawal_fee": 20.0
147+
"withdrawal_fee": 0
148+
},
149+
"EUR": {
150+
"scale": 2,
151+
"withdrawal_fee": 0
132152
},
133153
"XMR": {
134154
"scale": 8,
@@ -142,6 +162,14 @@
142162
"scale": 8,
143163
"withdrawal_fee": 0.01
144164
},
165+
"OMG": {
166+
"scale": 8,
167+
"withdrawal_fee": 0.01
168+
},
169+
"BTG": {
170+
"scale": 8,
171+
"withdrawal_fee": 0.01
172+
},
145173
"EOS": {
146174
"scale": 8,
147175
"withdrawal_fee": 0.31641

0 commit comments

Comments
 (0)