View Javadoc
1   package org.oxerr.chbtc.service.polling;
2   
3   import java.io.IOException;
4   
5   import org.oxerr.chbtc.CHBTCAdapters;
6   import org.oxerr.chbtc.dto.Trade;
7   
8   import com.xeiam.xchange.Exchange;
9   import com.xeiam.xchange.currency.CurrencyPair;
10  import com.xeiam.xchange.dto.marketdata.OrderBook;
11  import com.xeiam.xchange.dto.marketdata.Ticker;
12  import com.xeiam.xchange.dto.marketdata.Trades;
13  import com.xeiam.xchange.exceptions.ExchangeException;
14  import com.xeiam.xchange.exceptions.NotAvailableFromExchangeException;
15  import com.xeiam.xchange.exceptions.NotYetImplementedForExchangeException;
16  import com.xeiam.xchange.service.polling.marketdata.PollingMarketDataService;
17  
18  public class CHBTCMarketDataService extends CHBTCMarketDataServiceRaw implements
19  		PollingMarketDataService {
20  
21  	public CHBTCMarketDataService(Exchange exchange) {
22  		super(exchange);
23  	}
24  
25  	/**
26  	 * {@inheritDoc}
27  	 */
28  	@Override
29  	public Ticker getTicker(CurrencyPair currencyPair, Object... args)
30  			throws ExchangeException, NotAvailableFromExchangeException,
31  			NotYetImplementedForExchangeException, IOException {
32  		return CHBTCAdapters.adaptTicker(getTicker(currencyPair), currencyPair);
33  	}
34  
35  	/**
36  	 * {@inheritDoc}
37  	 */
38  	@Override
39  	public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args)
40  			throws ExchangeException, NotAvailableFromExchangeException,
41  			NotYetImplementedForExchangeException, IOException {
42  		return CHBTCAdapters.adaptOrderBook(getDepth(currencyPair), currencyPair);
43  	}
44  
45  	/**
46  	 * {@inheritDoc}
47  	 */
48  	@Override
49  	public Trades getTrades(CurrencyPair currencyPair, Object... args)
50  			throws ExchangeException, NotAvailableFromExchangeException,
51  			NotYetImplementedForExchangeException, IOException {
52  		final Trade[] trades;
53  		if (args.length == 0) {
54  			trades = getTrades(currencyPair);
55  		} else {
56  			trades = getTrades(currencyPair, (Long) args[0]);
57  		}
58  		return CHBTCAdapters.adaptTrades(trades, currencyPair);
59  	}
60  
61  }