1 package org.oxerr.chbtc;
2
3 import java.util.Arrays;
4 import java.util.List;
5
6 import org.oxerr.chbtc.service.polling.CHBTCAccountService;
7 import org.oxerr.chbtc.service.polling.CHBTCMarketDataService;
8 import org.oxerr.chbtc.service.polling.CHBTCTradeService;
9
10 import si.mazi.rescu.SynchronizedValueFactory;
11
12 import com.xeiam.xchange.BaseExchange;
13 import com.xeiam.xchange.ExchangeSpecification;
14 import com.xeiam.xchange.currency.CurrencyPair;
15
16 public class CHBTCExchange extends BaseExchange {
17
18
19
20
21 public static final String SYMBOLS_PARAMETER = "symbols";
22
23 public static final String SOCKET_TIMEOUT_PARAMETER = "socketTimeout";
24 public static final String CONNECT_TIMEOUT_PARAMETER = "connectTimeout";
25 public static final String CONNECTION_REQUEST_TIMEOUT_PARAMETER = "connectionRequestTimeout";
26
27 public static final String PRICE_SCALE_PARAMETER = "priceScale";
28
29 private static final List<CurrencyPair> SYMBOLS = Arrays.asList(
30 CurrencyPair.BTC_CNY,
31 CurrencyPair.LTC_CNY);
32
33 @Override
34 public void applySpecification(ExchangeSpecification exchangeSpecification) {
35 super.applySpecification(exchangeSpecification);
36 this.pollingMarketDataService = new CHBTCMarketDataService(this);
37 if (exchangeSpecification.getApiKey() != null) {
38 this.pollingAccountService = new CHBTCAccountService(this);
39 this.pollingTradeService = new CHBTCTradeService(this);
40 }
41 }
42
43
44
45
46 @Override
47 public ExchangeSpecification getDefaultExchangeSpecification() {
48 ExchangeSpecification exchangeSpecification = new ExchangeSpecification(this.getClass());
49 exchangeSpecification.setSslUri("https://trade.chbtc.com/api");
50 exchangeSpecification.setPlainTextUri("http://api.chbtc.com/data");
51 exchangeSpecification.setExchangeName("CHBTC");
52 exchangeSpecification.setExchangeSpecificParametersItem(
53 SYMBOLS_PARAMETER, SYMBOLS);
54 exchangeSpecification.setExchangeSpecificParametersItem(
55 PRICE_SCALE_PARAMETER, 8);
56 return exchangeSpecification;
57 }
58
59
60
61
62 @Override
63 public SynchronizedValueFactory<Long> getNonceFactory() {
64 return null;
65 }
66
67 }