forked from knowm/XChange
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
xchange-coinmate/src/main/java/com/xeiam/xchange/coinmate/CoinmateUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.xeiam.xchange.coinmate; | ||
|
||
import com.xeiam.xchange.currency.CurrencyPair; | ||
|
||
/** | ||
* | ||
* @author Martin Stachon | ||
*/ | ||
public class CoinmateUtils { | ||
|
||
public static String getPair(CurrencyPair currencyPair) { | ||
|
||
return currencyPair.baseSymbol.toUpperCase() + "_" + currencyPair.counterSymbol.toUpperCase(); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
.../src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateBasePollingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.xeiam.xchange.coinmate.service.polling; | ||
|
||
import com.xeiam.xchange.Exchange; | ||
import com.xeiam.xchange.currency.CurrencyPair; | ||
import com.xeiam.xchange.service.polling.BasePollingExchangeService; | ||
import com.xeiam.xchange.service.polling.BasePollingService; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author Martin Stachon | ||
*/ | ||
public class CoinmateBasePollingService extends BasePollingExchangeService implements BasePollingService { | ||
|
||
public CoinmateBasePollingService(Exchange exchange) { | ||
super(exchange); | ||
} | ||
|
||
@Override | ||
public List<CurrencyPair> getExchangeSymbols() throws IOException { | ||
return exchange.getMetaData().getCurrencyPairs(); | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...e/src/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateMarketDataService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
package com.xeiam.xchange.coinmate.service.polling; | ||
|
||
import com.xeiam.xchange.Exchange; | ||
import com.xeiam.xchange.coinmate.CoinmateAdapters; | ||
import com.xeiam.xchange.coinmate.CoinmateUtils; | ||
import com.xeiam.xchange.currency.CurrencyPair; | ||
import com.xeiam.xchange.dto.marketdata.OrderBook; | ||
import com.xeiam.xchange.dto.marketdata.Ticker; | ||
import com.xeiam.xchange.dto.marketdata.Trades; | ||
import com.xeiam.xchange.exceptions.ExchangeException; | ||
import com.xeiam.xchange.exceptions.NotAvailableFromExchangeException; | ||
import com.xeiam.xchange.exceptions.NotYetImplementedForExchangeException; | ||
import com.xeiam.xchange.service.polling.marketdata.PollingMarketDataService; | ||
import java.io.IOException; | ||
|
||
/** | ||
* | ||
* @author Martin Stachon | ||
*/ | ||
public class CoinmateMarketDataService extends CoinmateMarketDataServiceRaw implements PollingMarketDataService { | ||
|
||
public CoinmateMarketDataService(Exchange exchange) { | ||
super(exchange); | ||
} | ||
|
||
@Override | ||
public Ticker getTicker(CurrencyPair currencyPair, Object... args) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException { | ||
|
||
return CoinmateAdapters.adaptTicker(getCoinmateTicker(CoinmateUtils.getPair(currencyPair)), currencyPair); | ||
} | ||
|
||
@Override | ||
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException { | ||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | ||
} | ||
|
||
@Override | ||
public Trades getTrades(CurrencyPair currencyPair, Object... args) throws ExchangeException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException { | ||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...rc/main/java/com/xeiam/xchange/coinmate/service/polling/CoinmateMarketDataServiceRaw.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.xeiam.xchange.coinmate.service.polling; | ||
|
||
import com.xeiam.xchange.Exchange; | ||
import com.xeiam.xchange.coinmate.Coinmate; | ||
import com.xeiam.xchange.coinmate.dto.marketdata.CoinmateTicker; | ||
import java.io.IOException; | ||
import si.mazi.rescu.RestProxyFactory; | ||
|
||
/** | ||
* | ||
* @author Martin Stachon | ||
*/ | ||
public class CoinmateMarketDataServiceRaw extends CoinmateBasePollingService { | ||
|
||
private final Coinmate coinmate; | ||
|
||
public CoinmateMarketDataServiceRaw(Exchange exchange) { | ||
super(exchange); | ||
this.coinmate = RestProxyFactory.createProxy(Coinmate.class, exchange.getExchangeSpecification().getSslUri()); | ||
} | ||
|
||
public CoinmateTicker getCoinmateTicker(String currencyPair) throws IOException { | ||
|
||
return coinmate.getTicker(currencyPair); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"currency_pairs":[ | ||
"BTC/USD" | ||
] | ||
} |
27 changes: 27 additions & 0 deletions
27
.../test/java/com/xeiam/xchange/coinmate/service/polling/CoinmateBasePollingServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.xeiam.xchange.coinmate.service.polling; | ||
|
||
import com.xeiam.xchange.Exchange; | ||
import com.xeiam.xchange.ExchangeFactory; | ||
import com.xeiam.xchange.coinmate.CoinmateExchange; | ||
import com.xeiam.xchange.currency.CurrencyPair; | ||
import com.xeiam.xchange.dto.marketdata.Ticker; | ||
import com.xeiam.xchange.service.polling.marketdata.PollingMarketDataService; | ||
import static org.fest.assertions.api.Assertions.assertThat; | ||
import org.junit.Test; | ||
|
||
/** | ||
* | ||
* @author Martin Stachon | ||
*/ | ||
public class CoinmateBasePollingServiceTest { | ||
|
||
@Test | ||
public void tickerFetchTest() throws Exception { | ||
|
||
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CoinmateExchange.class.getName()); | ||
PollingMarketDataService marketDataService = exchange.getPollingMarketDataService(); | ||
Ticker ticker = marketDataService.getTicker(new CurrencyPair("BTC", "USD")); | ||
System.out.println(ticker.toString()); | ||
assertThat(ticker).isNotNull(); | ||
} | ||
} |