Skip to content

Commit

Permalink
resolved merge conflcts
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCookieLab committed Jun 12, 2018
2 parents 21c2116 + c064c18 commit 8cfbe6e
Show file tree
Hide file tree
Showing 19 changed files with 452 additions and 240 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# poloniex-api-java
Java API client for the Poloniex exchange with focus on simplicity and usability.

### Maven configuration

PoloniexClient is available on [Maven Central](http://search.maven.org/#search). You just have to add the following repository to your `pom.xml` file.

```xml
<repository>
<id>sonatype snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
```
The current snapshot version is `1.1.1-SNAPSHOT` from the [master](https://github.com/TheCookieLab/poloniex-api-java) branch.
```xml
<dependency>
<groupId>com.github.thecookielab</groupId>
<artifactId>PoloniexClient</artifactId>
<version>1.1.1-SNAPSHOT</version>
</dependency>
```

Using this client is as simple as instantiating a new PoloniexExchangeService with your Poloniex API Key and API Secret as constructor parameters:

```java
Expand Down Expand Up @@ -92,6 +111,15 @@ PoloniexExchangeService service = new PoloniexExchangeService(apiKey, apiSecret)
List<PoloniexTradeHistory> UsdtBtcTradeHistory = service.returnTradeHistory("USDT_BTC");
```

### Return order trades
```java
String apiKey = "foo";
String apiSecret = "bar";
PoloniexExchangeService service = new PoloniexExchangeService(apiKey, apiSecret);
String orderNumber = "12345678";
List<PoloniexOrderTrade> orderTrades = service.returnOrderTrades(orderNumber);
```

### Buy
```java
String apiKey = "foo";
Expand Down
102 changes: 100 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cf</groupId>
<groupId>com.github.thecookielab</groupId>
<artifactId>PoloniexClient</artifactId>
<version>1.1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<developers>
<developer>
<name>David Pang</name>
</developer>
<developer>
<name>Cheolhee Han</name>
</developer>
</developers>

<licenses>
<license>
<name>MIT License</name>
<comments>All source code is under the MIT license.</comments>
</license>
</licenses>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<profiles>

<!-- Only when performing a release (i.e. not for snapshots) -->
<profile>
<id>sonatype-oss-release</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Artifact signing -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</profile>

</profiles>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down Expand Up @@ -33,7 +131,7 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.9.1</version>
</dependency>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
Expand Down
24 changes: 13 additions & 11 deletions src/main/java/com/cf/ExchangeService.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.cf;


import com.cf.data.model.poloniex.PoloniexActiveLoanTypes;
import com.cf.data.model.poloniex.PoloniexChartData;
import com.cf.data.model.poloniex.PoloniexCompleteBalance;
import com.cf.data.model.poloniex.PoloniexFeeInfo;
import com.cf.data.model.poloniex.PoloniexOpenOrder;
import com.cf.data.model.poloniex.PoloniexOrderResult;
import com.cf.data.model.poloniex.PoloniexOrderTrade;
import com.cf.data.model.poloniex.PoloniexTicker;
import com.cf.data.model.poloniex.PoloniexTradeHistory;
import java.math.BigDecimal;
Expand All @@ -17,8 +17,8 @@
*
* @author David
*/
public interface ExchangeService
{
public interface ExchangeService {

public final static String USDT_BTC_CURRENCY_PAIR = "USDT_BTC";
public final static String USDT_ETH_CURRENCY_PAIR = "USDT_ETH";
public final static String BTC_CURRENCY_TYPE = "BTC";
Expand All @@ -29,9 +29,9 @@ public interface ExchangeService
public final static Long TWO_HOUR_TIME_PERIOD = 7_200L;
public final static Long DAILY_TIME_PERIOD = 86_400L;
public final static Long LONG_LONG_AGO = 1_439_000_000L;

public List<PoloniexChartData> returnChartData(String currencyPair, Long periodInSeconds, Long startEpochInSeconds);

public Map<String, PoloniexTicker> returnTicker();

public PoloniexTicker returnTicker(String currencyName);
Expand All @@ -43,19 +43,21 @@ public interface ExchangeService
public PoloniexCompleteBalance returnCurrencyBalance(String currencyName);

public PoloniexFeeInfo returnFeeInfo();

public List<PoloniexOpenOrder> returnOpenOrders(String currencyName);

public List<PoloniexTradeHistory> returnTradeHistory(String currencyPair);


public List<PoloniexOrderTrade> returnOrderTrades(String orderNumber);

public boolean cancelOrder(String orderNumber);

public PoloniexOrderResult moveOrder(String orderNumber, BigDecimal rate, Boolean immediateOrCancel, Boolean postOnly);

public PoloniexOrderResult sell(String currencyPair, BigDecimal sellPrice, BigDecimal amount, boolean fillOrKill, boolean immediateOrCancel, boolean postOnly);

public PoloniexOrderResult buy(String currencyPair, BigDecimal buyPrice, BigDecimal amount, boolean fillOrKill, boolean immediateOrCancel, boolean postOnly);

public PoloniexActiveLoanTypes returnActiveLoans();
public PoloniexActiveLoanTypes returnActiveLoans();

}
2 changes: 2 additions & 0 deletions src/main/java/com/cf/TradingAPIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public interface TradingAPIClient
public String returnOpenOrders(String currencyPair);

public String returnTradeHistory(String currencyPair);

public String returnOrderTrades(String orderNumber);

public String cancelOrder(String orderNumber);

Expand Down
15 changes: 0 additions & 15 deletions src/main/java/com/cf/client/WSSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,10 @@ public WSSClient(String url) throws Exception {
subscriptions = new HashMap<>();
}

/**
* *
*
* @param subscription
* @param subscriptionMessageHandler
*/
public void addSubscription(PoloniexWSSSubscription subscription, IMessageHandler subscriptionMessageHandler) {
this.subscriptions.put(subscription, subscriptionMessageHandler);
}

/**
* *
*
* @param runTimeInMillis The subscription time expressed in milliseconds.
* The minimum runtime is 1 minute.
* @throws InterruptedException
* @throws IOException
* @throws java.net.URISyntaxException
*/
public void run(long runTimeInMillis) throws InterruptedException, IOException, URISyntaxException {

final PoloniexWSSClientRouter router = new PoloniexWSSClientRouter(uri, subscriptions.entrySet().stream()
Expand Down
Loading

0 comments on commit 8cfbe6e

Please sign in to comment.