Skip to content

Commit

Permalink
version 2.0.0 (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
aisling-2 authored May 1, 2023
1 parent 8c4ac91 commit 030d31e
Show file tree
Hide file tree
Showing 579 changed files with 3,138 additions and 2,031 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2.0.0 - 2023-05-01

### Changed
- Improved naming consistency by renaming all areas containing `Websocket` to `WebSocket`.
- Move signature generator classes under new utils subpath `utils/signaturegenerator`.

## 2.0.0rc2 - 2023-02-16

### Added
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ try {
}
```

### Websocket Stream
### WebSocket Stream

```java
WebsocketStreamClientImpl wsStreamClient = new WebsocketStreamClientImpl(); // defaults to live exchange unless stated.
WebSocketStreamClientImpl wsStreamClient = new WebSocketStreamClientImpl(); // defaults to live exchange unless stated.

// Single stream
int streamID1 = wsStreamClient.aggTradeStream("btcusdt",((event) -> {
Expand All @@ -255,11 +255,11 @@ wsStreamClient.closeAllConnections();

More examples are available at `test/examples/websocketstream` folder

### Websocket API
### WebSocket API

```java
RsaSignatureGenerator signatureGenerator = new RsaSignatureGenerator("PRIVATE_KEY_PATH");
WebsocketApiClientImpl wsApiClient = new WebsocketApiClientImpl("API_KEY", signatureGenerator); // defaults to live exchange unless stated.
WebSocketApiClientImpl wsApiClient = new WebSocketApiClientImpl("API_KEY", signatureGenerator); // defaults to live exchange unless stated.

// Open connection with a callback as parameter
wsApiClient.connect(((message) -> {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.binance</groupId>
<artifactId>binance-connector-java</artifactId>
<version>2.0.0rc2</version>
<version>2.0.0</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>lightweight connector to API</description>
Expand Down Expand Up @@ -40,7 +40,7 @@
<scm>
<connection>scm:git:git://github.com/binance/binance-connector-java.git</connection>
<developerConnection>scm:git:ssh://github.com:binance/binance-connector-java.git</developerConnection>
<url>https://github.com/biance/binance-connector-java</url>
<url>https://github.com/binance/binance-connector-java</url>
</scm>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.binance.connector.client.impl.websocketapi.WebSocketApiUserDataStream;
import com.binance.connector.client.utils.WebSocketCallback;

public interface WebsocketApiClient {
public interface WebSocketApiClient {
void connect(WebSocketCallback onMessageCallback);
void connect(WebSocketCallback onOpenCallback, WebSocketCallback onMessageCallback, WebSocketCallback onClosingCallback, WebSocketCallback onFailureCallback);
void close();
Expand All @@ -16,4 +16,4 @@ public interface WebsocketApiClient {
WebSocketApiTrade trade();
WebSocketApiAccount account();
WebSocketApiUserDataStream userDataStream();
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.binance.connector.client;

import com.binance.connector.client.utils.WebSocketCallback;
import java.util.ArrayList;

public interface WebsocketStreamClient {
import com.binance.connector.client.utils.WebSocketCallback;

public interface WebSocketStreamClient {
int aggTradeStream(String symbol, WebSocketCallback callback);
int aggTradeStream(String symbol, WebSocketCallback onOpenCallback, WebSocketCallback onMessageCallback, WebSocketCallback onClosingCallback, WebSocketCallback onFailureCallback);
int tradeStream(String symbol, WebSocketCallback callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.binance.connector.client.impl.spot.BSwap;
import com.binance.connector.client.impl.spot.Blvt;
import com.binance.connector.client.impl.spot.C2C;
import com.binance.connector.client.impl.spot.CryptoLoans;
import com.binance.connector.client.impl.spot.Convert;
import com.binance.connector.client.impl.spot.CryptoLoans;
import com.binance.connector.client.impl.spot.Fiat;
import com.binance.connector.client.impl.spot.Futures;
import com.binance.connector.client.impl.spot.GiftCard;
Expand All @@ -23,9 +23,9 @@
import com.binance.connector.client.impl.spot.Trade;
import com.binance.connector.client.impl.spot.UserData;
import com.binance.connector.client.impl.spot.Wallet;
import com.binance.connector.client.utils.HmacSignatureGenerator;
import com.binance.connector.client.utils.ProxyAuth;
import com.binance.connector.client.utils.SignatureGenerator;
import com.binance.connector.client.utils.signaturegenerator.HmacSignatureGenerator;
import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator;

public class SpotClientImpl implements SpotClient {
private final String apiKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.binance.connector.client.impl;

import com.binance.connector.client.WebsocketApiClient;
import com.binance.connector.client.WebSocketApiClient;
import com.binance.connector.client.enums.DefaultUrls;
import com.binance.connector.client.exceptions.BinanceConnectorException;
import com.binance.connector.client.impl.websocketapi.WebSocketApiAccount;
Expand All @@ -9,16 +9,16 @@
import com.binance.connector.client.impl.websocketapi.WebSocketApiTrade;
import com.binance.connector.client.impl.websocketapi.WebSocketApiUserDataStream;
import com.binance.connector.client.utils.RequestBuilder;
import com.binance.connector.client.utils.SignatureGenerator;
import com.binance.connector.client.utils.WebSocketCallback;
import com.binance.connector.client.utils.WebSocketConnection;
import com.binance.connector.client.utils.httpclient.WebSocketApiHttpClientSingleton;
import com.binance.connector.client.utils.signaturegenerator.SignatureGenerator;
import com.binance.connector.client.utils.websocketapi.WebSocketApiRequestHandler;

import okhttp3.OkHttpClient;
import okhttp3.Request;

public class WebsocketApiClientImpl implements WebsocketApiClient {
public class WebSocketApiClientImpl implements WebSocketApiClient {
private static final OkHttpClient client = WebSocketApiHttpClientSingleton.getHttpClient();
private final SignatureGenerator signatureGenerator;
private final String apiKey;
Expand All @@ -32,27 +32,27 @@ public class WebsocketApiClientImpl implements WebsocketApiClient {
private WebSocketApiAccount wsApiAccount;
private WebSocketApiUserDataStream wsApiUserDataStream;

public WebsocketApiClientImpl() {
public WebSocketApiClientImpl() {
this("", null);
}

public WebsocketApiClientImpl(String baseUrl) {
public WebSocketApiClientImpl(String baseUrl) {
this("", null, baseUrl);
}

public WebsocketApiClientImpl(String apiKey, SignatureGenerator signatureGenerator) {
public WebSocketApiClientImpl(String apiKey, SignatureGenerator signatureGenerator) {
this(apiKey, signatureGenerator, DefaultUrls.WS_API_URL);
}

public WebsocketApiClientImpl(String apiKey, SignatureGenerator signatureGenerator, String baseUrl) {
public WebSocketApiClientImpl(String apiKey, SignatureGenerator signatureGenerator, String baseUrl) {
this.apiKey = apiKey;
this.signatureGenerator = signatureGenerator;
this.baseUrl = baseUrl;
}

private void checkRequestHandler() {
if (this.requestHandler == null) {
throw new BinanceConnectorException("No Websocket API connection to submit request. Please connect first.");
throw new BinanceConnectorException("No WebSocket API connection to submit request. Please connect first.");
}
}

Expand All @@ -78,7 +78,7 @@ public void connect(WebSocketCallback onMessageCallback) {
}

public void connect(WebSocketCallback onOpenCallback, WebSocketCallback onMessageCallback, WebSocketCallback onClosingCallback, WebSocketCallback onFailureCallback) {
Request request = RequestBuilder.buildWebsocketRequest(baseUrl);
Request request = RequestBuilder.buildWebSocketRequest(baseUrl);

this.connection = new WebSocketConnection(onOpenCallback, onMessageCallback, onClosingCallback, onFailureCallback, request, client);
this.requestHandler = new WebSocketApiRequestHandler(this.connection, this.apiKey, this.signatureGenerator);
Expand Down
Loading

0 comments on commit 030d31e

Please sign in to comment.