Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit cb01952

Browse files
committed
Fix UserDataStream
1 parent 751820c commit cb01952

21 files changed

+796
-224
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,16 +420,16 @@ client.onUserDataUpdateEvent(listenKey, response -> {
420420
// Print new balances of every available asset
421421
System.out.println(accountUpdateEvent.getBalances());
422422
} else {
423-
OrderTradeUpdateEvent orderTradeUpdateEvent = response.getOrderTradeUpdateEvent();
423+
OrderTradeUpdateEvent executionReport = response.getOrderTradeUpdateEvent();
424424

425425
// Print details about an order/trade
426-
System.out.println(orderTradeUpdateEvent);
426+
System.out.println(executionReport);
427427

428428
// Print original quantity
429-
System.out.println(orderTradeUpdateEvent.getOriginalQuantity());
429+
System.out.println(executionReport.getOriginalQuantity());
430430

431431
// Or price
432-
System.out.println(orderTradeUpdateEvent.getPrice());
432+
System.out.println(executionReport.getPrice());
433433
}
434434
});
435435
```

src/main/java/com/binance/api/client/api/BinanceApiService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ Call<List<Trade>> getMyMarginTrades(@Query("symbol") String symbol, @Query("limi
228228
@PUT("/sapi/v1/userDataStream")
229229
Call<Void> keepAliveMarginUserDataStream(@Query("listenKey") String listenKey);
230230

231+
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER)
232+
@DELETE("/sapi/v1/userDataStream")
233+
Call<Void> closeAliveMarginUserDataStream(@Query("listenKey") String listenKey);
231234
// Binance Liquidity Swap Pool endpoints
232235

233236
@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER)

src/main/java/com/binance/api/client/api/sync/BinanceApiFuturesRestClient.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,34 @@ public interface BinanceApiFuturesRestClient extends BinanceApiGeneralRestClient
2626
*/
2727
LeverageResponse changeInitialLeverage(LeverageRequest leverageRequest);
2828

29+
/**
30+
* Change type of margin CROSSED/ISOLATED
31+
*
32+
* @param marginTypeRequest
33+
*/
2934
void changeMarginType(MarginTypeRequest marginTypeRequest);
3035

36+
// User stream endpoints
37+
38+
/**
39+
* Start a new user data stream.
40+
*
41+
* @return a listen key that can be used with data streams
42+
*/
43+
String startUserDataStream();
44+
45+
/**
46+
* PING a user data stream to prevent a time out.
47+
*
48+
* @param listenKey listen key that identifies a data stream
49+
*/
50+
void keepAliveUserDataStream(String listenKey);
51+
52+
/**
53+
* Close out a new user data stream.
54+
*
55+
* @param listenKey listen key that identifies a data stream
56+
*/
57+
void closeUserDataStream(String listenKey);
58+
3159
}

src/main/java/com/binance/api/client/api/sync/BinanceApiGeneralRestClient.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,4 @@ public interface BinanceApiGeneralRestClient {
142142
* @return a list of all account open orders on a symbol.
143143
*/
144144
List<Order> getOpenOrders(OrderRequest orderRequest);
145-
146-
// User stream endpoints
147-
/**
148-
* Start a new user data stream.
149-
*
150-
* @return a listen key that can be used with data streams
151-
*/
152-
String startUserDataStream();
153-
154-
/**
155-
* PING a user data stream to prevent a time out.
156-
*
157-
* @param listenKey listen key that identifies a data stream
158-
*/
159-
void keepAliveUserDataStream(String listenKey);
160-
161-
/**
162-
* Close out a new user data stream.
163-
*
164-
* @param listenKey listen key that identifies a data stream
165-
*/
166-
void closeUserDataStream(String listenKey);
167145
}

src/main/java/com/binance/api/client/api/sync/BinanceApiMarginRestClient.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,26 @@ public interface BinanceApiMarginRestClient {
105105
* @return loan records
106106
*/
107107
LoanQueryResult queryLoan(String asset, String txId);
108+
109+
// User stream endpoints
110+
/**
111+
* Start a new user data stream.
112+
*
113+
* @return a listen key that can be used with data streams
114+
*/
115+
String startUserDataStream();
116+
117+
/**
118+
* PING a user data stream to prevent a time out.
119+
*
120+
* @param listenKey listen key that identifies a data stream
121+
*/
122+
void keepAliveUserDataStream(String listenKey);
123+
124+
/**
125+
* Close out a new user data stream.
126+
*
127+
* @param listenKey listen key that identifies a data stream
128+
*/
129+
void closeUserDataStream(String listenKey);
108130
}

src/main/java/com/binance/api/client/api/sync/BinanceApiSpotRestClient.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,26 @@ public interface BinanceApiSpotRestClient extends BinanceApiGeneralRestClient {
127127
* @return deposit address for a given asset.
128128
*/
129129
DepositAddress getDepositAddress(String asset);
130+
131+
// User stream endpoints
132+
/**
133+
* Start a new user data stream.
134+
*
135+
* @return a listen key that can be used with data streams
136+
*/
137+
String startUserDataStream();
138+
139+
/**
140+
* PING a user data stream to prevent a time out.
141+
*
142+
* @param listenKey listen key that identifies a data stream
143+
*/
144+
void keepAliveUserDataStream(String listenKey);
145+
146+
/**
147+
* Close out a new user data stream.
148+
*
149+
* @param listenKey listen key that identifies a data stream
150+
*/
151+
void closeUserDataStream(String listenKey);
130152
}

src/main/java/com/binance/api/client/config/SpotApiConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Configuration used for Binance operations.
55
*/
66

7-
@ApiConfig(apiUrl = "https://api.binance.com", webSocketUrl = "wss://stream.binance.com:9443/ws")
7+
@ApiConfig(apiUrl = "https://api.binance.com", webSocketUrl = "wss://stream.binance.com/ws")
88
public class SpotApiConfig implements BinanceApiConfig {
99

1010
}

src/main/java/com/binance/api/client/domain/OrderType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ public enum OrderType {
1717
LIMIT_MAKER,
1818
STOP_MARKET,
1919
TRAILING_STOP_MARKET,
20-
TAKE_PROFIT_MARKET,
20+
TAKE_PROFIT_MARKET;
2121
}

src/main/java/com/binance/api/client/domain/event/OrderTradeUpdateEvent.java renamed to src/main/java/com/binance/api/client/domain/event/ExecutionReport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @see UserDataUpdateEvent
1515
*/
1616
@JsonIgnoreProperties(ignoreUnknown = true)
17-
public class OrderTradeUpdateEvent {
17+
public class ExecutionReport {
1818

1919
@JsonProperty("e")
2020
private String eventType;

0 commit comments

Comments
 (0)