Skip to content

Commit fad7597

Browse files
author
NITRO5\Corey
committed
Merge branch 'develop'
# Conflicts: # xchange-cryptopia/src/main/java/org/knowm/xchange/cryptopia/service/CryptopiaMarketDataService.java
2 parents 6e51f7a + 667cded commit fad7597

File tree

3 files changed

+49
-11
lines changed

3 files changed

+49
-11
lines changed

xchange-core/src/main/java/org/knowm/xchange/currency/CurrencyPair.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,17 @@ public class CurrencyPair implements Comparable<CurrencyPair>, Serializable {
8080
public static final CurrencyPair BCH_BTC = new CurrencyPair(Currency.BCH, Currency.BTC);
8181
public static final CurrencyPair BCH_ETH = new CurrencyPair(Currency.BCH, Currency.ETH);
8282

83+
public static final CurrencyPair BCA_USD = new CurrencyPair(Currency.BCA, Currency.USD);
84+
public static final CurrencyPair BCA_EUR = new CurrencyPair(Currency.BCA, Currency.EUR);
85+
public static final CurrencyPair BCA_CNY = new CurrencyPair(Currency.BCA, Currency.CNY);
86+
public static final CurrencyPair BCA_JPY = new CurrencyPair(Currency.BCA, Currency.JPY);
87+
public static final CurrencyPair BCA_BTC = new CurrencyPair(Currency.BCA, Currency.BTC);
88+
public static final CurrencyPair BCA_ETH = new CurrencyPair(Currency.BCA, Currency.ETH);
89+
8390
public static final CurrencyPair ETH_BTC = new CurrencyPair(Currency.ETH, Currency.BTC);
8491
public static final CurrencyPair ETH_GBP = new CurrencyPair(Currency.ETH, Currency.GBP);
8592
public static final CurrencyPair ETH_USD = new CurrencyPair(Currency.ETH, Currency.USD);
93+
public static final CurrencyPair ETH_USDT = new CurrencyPair(Currency.ETH, Currency.USDT);
8694
public static final CurrencyPair ETH_EUR = new CurrencyPair(Currency.ETH, Currency.EUR);
8795
public static final CurrencyPair ETH_JPY = new CurrencyPair(Currency.ETH, Currency.JPY);
8896
public static final CurrencyPair ETH_CNY = new CurrencyPair(Currency.ETH, Currency.CNY);
@@ -211,6 +219,14 @@ public class CurrencyPair implements Comparable<CurrencyPair>, Serializable {
211219
public static final CurrencyPair OMG_USD = new CurrencyPair(Currency.OMG, Currency.USD);
212220
public static final CurrencyPair OMG_BTC = new CurrencyPair(Currency.OMG, Currency.BTC);
213221
public static final CurrencyPair OMG_ETH = new CurrencyPair(Currency.OMG, Currency.ETH);
222+
// end
223+
224+
// NEO
225+
public static final CurrencyPair NEO_USD = new CurrencyPair(Currency.NEO, Currency.USD);
226+
public static final CurrencyPair NEO_USDT = new CurrencyPair(Currency.NEO, Currency.USDT);
227+
public static final CurrencyPair NEO_BTC = new CurrencyPair(Currency.NEO, Currency.BTC);
228+
public static final CurrencyPair NEO_ETH = new CurrencyPair(Currency.NEO, Currency.ETH);
229+
// end
214230

215231
// not real currencies, but tradable commodities (GH/s)
216232
public static final CurrencyPair GHs_BTC = new CurrencyPair(Currency.GHs, Currency.BTC);
@@ -250,6 +266,9 @@ public class CurrencyPair implements Comparable<CurrencyPair>, Serializable {
250266
public static final CurrencyPair ZEC_USD = new CurrencyPair(Currency.ZEC, Currency.USD);
251267
public static final CurrencyPair ZEC_BTC = new CurrencyPair(Currency.ZEC, Currency.BTC);
252268

269+
public static final CurrencyPair ZEN_USD = new CurrencyPair(Currency.ZEN, Currency.USD);
270+
public static final CurrencyPair ZEN_BTC = new CurrencyPair(Currency.ZEN, Currency.BTC);
271+
253272
public static final CurrencyPair GNO_ETH = new CurrencyPair(Currency.GNO, Currency.ETH);
254273
public static final CurrencyPair GNO_BTC = new CurrencyPair(Currency.GNO, Currency.BTC);
255274

xchange-cryptopia/src/main/java/org/knowm/xchange/cryptopia/service/CryptopiaMarketDataService.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.knowm.xchange.cryptopia.service;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.stream.Collectors;
36
import org.knowm.xchange.Exchange;
47
import org.knowm.xchange.cryptopia.CryptopiaAdapters;
58
import org.knowm.xchange.cryptopia.CryptopiaExchange;
@@ -9,9 +12,10 @@
912
import org.knowm.xchange.dto.marketdata.Ticker;
1013
import org.knowm.xchange.dto.marketdata.Trades;
1114
import org.knowm.xchange.service.marketdata.MarketDataService;
15+
import org.knowm.xchange.service.marketdata.params.CurrencyPairsParam;
1216
import org.knowm.xchange.service.marketdata.params.Params;
1317
import org.knowm.xchange.utils.Assert;
14-
18+
import org.knowm.xchange.utils.jackson.CurrencyPairDeserializer;
1519
import java.io.IOException;
1620
import java.util.ArrayList;
1721
import java.util.List;
@@ -37,15 +41,21 @@ public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws IOExce
3741
return CryptopiaAdapters.adaptTicker(getCryptopiaTicker(currencyPair));
3842
}
3943

40-
@Override
41-
public List<Ticker> getTickers(Params params) throws IOException {
42-
return getCryptopiaMarkets().stream()
43-
.map(CryptopiaAdapters::adaptTicker)
44-
.collect(Collectors.toList());
44+
@Override
45+
public List<Ticker> getTickers(Params params) throws IOException {
46+
final List<CurrencyPair> currencyPairs = new ArrayList<>();
47+
if (params instanceof CurrencyPairsParam) {
48+
currencyPairs.addAll(((CurrencyPairsParam) params).getCurrencyPairs());
4549
}
46-
47-
private CryptopiaExchange getCryptopiaExchange() {
48-
return (CryptopiaExchange) exchange;
50+
return getCryptopiaMarkets()
51+
.stream()
52+
.map(
53+
cryptopiaTicker ->
54+
CryptopiaAdapters.adaptTicker(
55+
cryptopiaTicker))
56+
.filter(
57+
ticker -> currencyPairs.size() == 0 || currencyPairs.contains(ticker.getCurrencyPair()))
58+
.collect(Collectors.toList());
4959
}
5060

5161
@Override

xchange-livecoin/src/main/java/org/knowm/xchange/livecoin/LivecoinAdapters.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,24 @@ public static List<Wallet> adaptWallets(List<Map> data) {
273273
String ccy = balance.get("currency").toString();
274274
String value = balance.get("value").toString();
275275

276+
// Livecoin has a currency Bricktox (XBT) which is different from XChange Bitcoin (XBT). See
277+
// Currency.XBT.
278+
// The "get all currencies" call to Livecoin returns all currencies including those with 0
279+
// balance.
280+
// As a result, XBT overrides BTC, so BTC becomes 0 (in most cases).
281+
// Excluding XBT.
282+
if (ccy.equals("XBT")) {
283+
continue;
284+
}
285+
276286
Currency curr = getInstance(ccy);
277287

278288
WalletBuilder builder = wallets.get(curr);
279289
if (builder == null) {
280290
builder = new WalletBuilder(curr);
291+
wallets.put(curr, builder);
281292
}
282293
builder.add(type, value);
283-
284-
wallets.put(curr, builder);
285294
}
286295

287296
List<Wallet> res = new ArrayList<>();

0 commit comments

Comments
 (0)