Skip to content

Commit

Permalink
Merge pull request #989 from radumiron/develop
Browse files Browse the repository at this point in the history
Loading CoinbaseEx exchange symbols from the exchange itself
  • Loading branch information
timmolter committed Jun 17, 2015
2 parents 15c7ca7 + 876c98a commit 73759e7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
Expand Up @@ -9,11 +9,7 @@
import java.util.TimeZone;

import com.xeiam.xchange.coinbaseex.dto.account.CoinbaseExAccount;
import com.xeiam.xchange.coinbaseex.dto.marketdata.CoinbaseExProductBook;
import com.xeiam.xchange.coinbaseex.dto.marketdata.CoinbaseExProductBookEntry;
import com.xeiam.xchange.coinbaseex.dto.marketdata.CoinbaseExProductStats;
import com.xeiam.xchange.coinbaseex.dto.marketdata.CoinbaseExProductTicker;
import com.xeiam.xchange.coinbaseex.dto.marketdata.CoinbaseExTrade;
import com.xeiam.xchange.coinbaseex.dto.marketdata.*;
import com.xeiam.xchange.coinbaseex.dto.trade.CoinbaseExOrder;
import com.xeiam.xchange.currency.CurrencyPair;
import com.xeiam.xchange.dto.Order.OrderType;
Expand Down Expand Up @@ -126,4 +122,13 @@ public static Trades adaptTrades(CoinbaseExTrade[] coinbaseExTrades, CurrencyPai

return new Trades(trades, TradeSortType.SortByID);
}

public static List<CurrencyPair> adaptProductsToSupportedExchangeSymbols(List<CoinbaseExProduct> products) {
List<CurrencyPair> result = new ArrayList<CurrencyPair>();
for (CoinbaseExProduct product : products) {
result.add(new CurrencyPair(product.getBaseCurrency(), product.getTargetCurrency()));
}

return result;
}
}
Expand Up @@ -2,6 +2,7 @@

import com.xeiam.xchange.Exchange;
import com.xeiam.xchange.coinbaseex.CoinbaseEx;
import com.xeiam.xchange.coinbaseex.CoinbaseExAdapters;
import com.xeiam.xchange.coinbaseex.service.CoinbaseExDigest;
import com.xeiam.xchange.currency.CurrencyPair;
import com.xeiam.xchange.service.BaseExchangeService;
Expand Down Expand Up @@ -36,8 +37,7 @@ protected CoinbaseExBasePollingService(Class<T> type, Exchange exchange) {

@Override
public List<CurrencyPair> getExchangeSymbols() throws IOException {

return exchange.getMetaData().getCurrencyPairs();
return CoinbaseExAdapters.adaptProductsToSupportedExchangeSymbols(coinbaseEx.getProducts());
}

protected String getTimestamp() {
Expand Down
@@ -1,12 +1,18 @@
package com.xeiam.xchange.coinbaseex;

import com.xeiam.xchange.ExchangeFactory;
import com.xeiam.xchange.currency.CurrencyPair;
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;

import static org.fest.assertions.api.Assertions.assertThat;

public class CoinbaseExExchangeTest {

@Test
public void coinbaseShouldBeInstantiatedWithoutAnExceptionWhenUsingDefaultSpecification() {
ExchangeFactory.INSTANCE.createExchange(CoinbaseExExchange.class.getCanonicalName());
}
@Test
public void coinbaseShouldBeInstantiatedWithoutAnExceptionWhenUsingDefaultSpecification() {
ExchangeFactory.INSTANCE.createExchange(CoinbaseExExchange.class.getCanonicalName());
}
}
@@ -0,0 +1,26 @@
package com.xeiam.xchange.coinbaseex.service.marketdata;

import com.xeiam.xchange.coinbaseex.CoinbaseExExchange;
import com.xeiam.xchange.currency.CurrencyPair;
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;

import static org.fest.assertions.api.Assertions.assertThat;

/**
* Created by Radu on 6/17/2015.
*/
public class CoinbaseExAvailableProductsIntegration {

@Test
public void testCoinbaseCurrencies() throws IOException {
CoinbaseExExchange exchange = new CoinbaseExExchange();
exchange.applySpecification(exchange.getDefaultExchangeSpecification());

assertThat(exchange.getPollingMarketDataService().getExchangeSymbols()).containsAll(
Arrays.asList(new CurrencyPair("BTC/USD"), new CurrencyPair("BTC/GBP"), new CurrencyPair("BTC/EUR"))
);
}
}

0 comments on commit 73759e7

Please sign in to comment.