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.
Merge pull request #12 from knowm/develop
Pull request
- Loading branch information
Showing
70 changed files
with
4,256 additions
and
109 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
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
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
3 changes: 2 additions & 1 deletion
3
...e-examples/src/main/java/org/knowm/xchange/examples/kucoin/account/KucoinAccountDemo.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
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
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
13 changes: 13 additions & 0 deletions
13
...ge-examples/src/main/java/org/knowm/xchange/examples/simulated/SimulatedExchangeDemo.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,13 @@ | ||
package org.knowm.xchange.examples.simulated; | ||
|
||
import java.io.IOException; | ||
|
||
public class SimulatedExchangeDemo { | ||
|
||
public static void main(String[] args) throws IOException { | ||
|
||
System.out.println("See SimulatedExchangeExample in the xchange-simulated module's test tree."); | ||
|
||
} | ||
|
||
} |
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
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
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
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
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
61 changes: 46 additions & 15 deletions
61
xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/KucoinBaseService.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 |
---|---|---|
@@ -1,27 +1,58 @@ | ||
package org.knowm.xchange.kucoin; | ||
|
||
import com.kucoin.sdk.KucoinClientBuilder; | ||
import com.kucoin.sdk.KucoinRestClient; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.knowm.xchange.ExchangeSpecification; | ||
import com.google.common.base.Strings; | ||
import org.knowm.xchange.kucoin.service.AccountAPI; | ||
import org.knowm.xchange.kucoin.service.FillAPI; | ||
import org.knowm.xchange.kucoin.service.HistoryAPI; | ||
import org.knowm.xchange.kucoin.service.KucoinApiException; | ||
import org.knowm.xchange.kucoin.service.KucoinDigest; | ||
import org.knowm.xchange.kucoin.service.OrderAPI; | ||
import org.knowm.xchange.kucoin.service.OrderBookAPI; | ||
import org.knowm.xchange.kucoin.service.SymbolAPI; | ||
import org.knowm.xchange.service.BaseExchangeService; | ||
import org.knowm.xchange.service.BaseService; | ||
import si.mazi.rescu.RestProxyFactory; | ||
import si.mazi.rescu.SynchronizedValueFactory; | ||
|
||
public class KucoinBaseService extends BaseExchangeService<KucoinExchange> implements BaseService { | ||
|
||
protected final KucoinRestClient kucoinRestClient; | ||
protected final SymbolAPI symbolApi; | ||
protected final OrderBookAPI orderBookApi; | ||
protected final HistoryAPI historyApi; | ||
protected final AccountAPI accountApi; | ||
protected final OrderAPI orderApi; | ||
protected final FillAPI fillApi; | ||
|
||
protected KucoinDigest digest; | ||
protected String apiKey; | ||
protected String passphrase; | ||
protected SynchronizedValueFactory<Long> nonceFactory; | ||
|
||
protected KucoinBaseService(KucoinExchange exchange) { | ||
super(exchange); | ||
ExchangeSpecification spec = exchange.getExchangeSpecification(); | ||
KucoinClientBuilder builder = new KucoinClientBuilder().withBaseUrl(spec.getSslUri()); | ||
if (StringUtils.isNotEmpty(spec.getApiKey())) { | ||
builder.withApiKey( | ||
spec.getApiKey(), | ||
spec.getSecretKey(), | ||
(String) | ||
exchange.getExchangeSpecification().getExchangeSpecificParametersItem("passphrase")); | ||
} | ||
kucoinRestClient = builder.buildRestClient(); | ||
this.symbolApi = service(exchange, SymbolAPI.class); | ||
this.orderBookApi = service(exchange, OrderBookAPI.class); | ||
this.historyApi = service(exchange, HistoryAPI.class); | ||
this.accountApi = service(exchange, AccountAPI.class); | ||
this.orderApi = service(exchange, OrderAPI.class); | ||
this.fillApi = service(exchange, FillAPI.class); | ||
|
||
this.digest = KucoinDigest.createInstance(exchange.getExchangeSpecification().getSecretKey()); | ||
this.apiKey = exchange.getExchangeSpecification().getApiKey(); | ||
this.passphrase = | ||
(String) | ||
exchange.getExchangeSpecification().getExchangeSpecificParametersItem("passphrase"); | ||
this.nonceFactory = exchange.getNonceFactory(); | ||
} | ||
|
||
private <T> T service(KucoinExchange exchange, Class<T> clazz) { | ||
return RestProxyFactory.createProxy( | ||
clazz, exchange.getExchangeSpecification().getSslUri(), getClientConfig()); | ||
} | ||
|
||
protected void checkAuthenticated() { | ||
if (Strings.isNullOrEmpty(this.apiKey)) throw new KucoinApiException("Missing API key"); | ||
if (this.digest == null) throw new KucoinApiException("Missing secret key"); | ||
if (Strings.isNullOrEmpty(this.passphrase)) throw new KucoinApiException("Missing passphrase"); | ||
} | ||
} |
18 changes: 8 additions & 10 deletions
18
xchange-kucoin/src/main/java/org/knowm/xchange/kucoin/KucoinExceptionClassifier.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
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
Oops, something went wrong.