Skip to content

Commit

Permalink
Btce signals DASH as DSH
Browse files Browse the repository at this point in the history
Btce added eth and DASH. But dash is signaled as dsh which is a different coin. 
Translate the incorrect dsh in dash.
  • Loading branch information
Achterhoeker committed Apr 29, 2016
1 parent ad29429 commit 216ab8f
Showing 1 changed file with 25 additions and 10 deletions.
Expand Up @@ -160,9 +160,13 @@ public static Wallet adaptWallet(BTCEAccountInfo btceAccountInfo) {
Map<String, BigDecimal> funds = btceAccountInfo.getFunds();

for (String lcCurrency : funds.keySet()) {
Currency currency = Currency.getInstance(lcCurrency.toUpperCase());

balances.add(new Balance(currency, funds.get(lcCurrency)));
/* BTC-E signals DASH as DSH. This is a different coin. Translate in correct DASH name */
BigDecimal fund = funds.get(lcCurrency);
if (lcCurrency.equals("dsh")) {
lcCurrency = "dash";
}
Currency currency = Currency.getInstance(lcCurrency);
balances.add(new Balance(currency, fund));
}
return new Wallet(balances);
}
Expand All @@ -173,10 +177,9 @@ public static OpenOrders adaptOrders(Map<Long, BTCEOrder> btceOrderMap) {
for (Long id : btceOrderMap.keySet()) {
BTCEOrder bTCEOrder = btceOrderMap.get(id);
OrderType orderType = bTCEOrder.getType() == BTCEOrder.Type.buy ? OrderType.BID : OrderType.ASK;
String[] pair = bTCEOrder.getPair().split("_");
BigDecimal price = bTCEOrder.getRate();
Date timestamp = DateUtils.fromMillisUtc(bTCEOrder.getTimestampCreated() * 1000L);
CurrencyPair currencyPair = new CurrencyPair(pair[0].toUpperCase(), pair[1].toUpperCase());
CurrencyPair currencyPair = adaptCurrencyPair(bTCEOrder.getPair());

limitOrders.add(new LimitOrder(orderType, bTCEOrder.getAmount(), currencyPair, Long.toString(id), timestamp, price));
}
Expand All @@ -203,13 +206,16 @@ public static UserTrades adaptTradeHistory(Map<Long, BTCETradeHistoryResult> tra
public static CurrencyPair adaptCurrencyPair(String btceCurrencyPair) {

String[] currencies = btceCurrencyPair.split("_");
/* BTC-E signals DASH as DSH. This is a different coin. Translate in correct DASH name */
if (currencies[0].equals("dsh")) {
currencies[0] = "dash";
}
if (currencies[1].equals("dsh")) {
currencies[1] = "dash";
}
return new CurrencyPair(currencies[0].toUpperCase(), currencies[1].toUpperCase());
}

public static String adaptCurrencyPair(CurrencyPair currencyPair) {
return (currencyPair.base.getCurrencyCode() + "_" + currencyPair.counter.getCurrencyCode()).toLowerCase();
}

public static List<CurrencyPair> adaptCurrencyPairs(Iterable<String> btcePairs) {

List<CurrencyPair> pairs = new ArrayList<CurrencyPair>();
Expand Down Expand Up @@ -266,7 +272,16 @@ private static BigDecimal withScale(BigDecimal value, int priceScale) {
}

public static String getPair(CurrencyPair currencyPair) {
return currencyPair.base.getCurrencyCode().toLowerCase() + "_" + currencyPair.counter.getCurrencyCode().toLowerCase();
/* BTC-E signals DASH as DSH. This is a different coin. Translate in correct DASH name */
String base = currencyPair.base.getCurrencyCode();
String counter = currencyPair.counter.getCurrencyCode();
if (base.equals("DASH")) {
base = "DSH";
}
else if (counter.equals("DASH")) {
counter = "DSH";
}
return (base + "_" + counter).toLowerCase();
}

public static LimitOrder createLimitOrder(MarketOrder marketOrder, BTCEExchangeInfo btceExchangeInfo) {
Expand Down

0 comments on commit 216ab8f

Please sign in to comment.