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

Commit

Permalink
Fix UserDataStream
Browse files Browse the repository at this point in the history
  • Loading branch information
mah454 committed Apr 3, 2021
1 parent 751820c commit cb01952
Show file tree
Hide file tree
Showing 21 changed files with 796 additions and 224 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,16 @@ client.onUserDataUpdateEvent(listenKey, response -> {
// Print new balances of every available asset
System.out.println(accountUpdateEvent.getBalances());
} else {
OrderTradeUpdateEvent orderTradeUpdateEvent = response.getOrderTradeUpdateEvent();
OrderTradeUpdateEvent executionReport = response.getOrderTradeUpdateEvent();

// Print details about an order/trade
System.out.println(orderTradeUpdateEvent);
System.out.println(executionReport);

// Print original quantity
System.out.println(orderTradeUpdateEvent.getOriginalQuantity());
System.out.println(executionReport.getOriginalQuantity());

// Or price
System.out.println(orderTradeUpdateEvent.getPrice());
System.out.println(executionReport.getPrice());
}
});
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ Call<List<Trade>> getMyMarginTrades(@Query("symbol") String symbol, @Query("limi
@PUT("/sapi/v1/userDataStream")
Call<Void> keepAliveMarginUserDataStream(@Query("listenKey") String listenKey);

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

@Headers(BinanceApiConstants.ENDPOINT_SECURITY_TYPE_APIKEY_HEADER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,34 @@ public interface BinanceApiFuturesRestClient extends BinanceApiGeneralRestClient
*/
LeverageResponse changeInitialLeverage(LeverageRequest leverageRequest);

/**
* Change type of margin CROSSED/ISOLATED
*
* @param marginTypeRequest
*/
void changeMarginType(MarginTypeRequest marginTypeRequest);

// User stream endpoints

/**
* Start a new user data stream.
*
* @return a listen key that can be used with data streams
*/
String startUserDataStream();

/**
* PING a user data stream to prevent a time out.
*
* @param listenKey listen key that identifies a data stream
*/
void keepAliveUserDataStream(String listenKey);

/**
* Close out a new user data stream.
*
* @param listenKey listen key that identifies a data stream
*/
void closeUserDataStream(String listenKey);

}
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,4 @@ public interface BinanceApiGeneralRestClient {
* @return a list of all account open orders on a symbol.
*/
List<Order> getOpenOrders(OrderRequest orderRequest);

// User stream endpoints
/**
* Start a new user data stream.
*
* @return a listen key that can be used with data streams
*/
String startUserDataStream();

/**
* PING a user data stream to prevent a time out.
*
* @param listenKey listen key that identifies a data stream
*/
void keepAliveUserDataStream(String listenKey);

/**
* Close out a new user data stream.
*
* @param listenKey listen key that identifies a data stream
*/
void closeUserDataStream(String listenKey);
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,26 @@ public interface BinanceApiMarginRestClient {
* @return loan records
*/
LoanQueryResult queryLoan(String asset, String txId);

// User stream endpoints
/**
* Start a new user data stream.
*
* @return a listen key that can be used with data streams
*/
String startUserDataStream();

/**
* PING a user data stream to prevent a time out.
*
* @param listenKey listen key that identifies a data stream
*/
void keepAliveUserDataStream(String listenKey);

/**
* Close out a new user data stream.
*
* @param listenKey listen key that identifies a data stream
*/
void closeUserDataStream(String listenKey);
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,26 @@ public interface BinanceApiSpotRestClient extends BinanceApiGeneralRestClient {
* @return deposit address for a given asset.
*/
DepositAddress getDepositAddress(String asset);

// User stream endpoints
/**
* Start a new user data stream.
*
* @return a listen key that can be used with data streams
*/
String startUserDataStream();

/**
* PING a user data stream to prevent a time out.
*
* @param listenKey listen key that identifies a data stream
*/
void keepAliveUserDataStream(String listenKey);

/**
* Close out a new user data stream.
*
* @param listenKey listen key that identifies a data stream
*/
void closeUserDataStream(String listenKey);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Configuration used for Binance operations.
*/

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

}
2 changes: 1 addition & 1 deletion src/main/java/com/binance/api/client/domain/OrderType.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public enum OrderType {
LIMIT_MAKER,
STOP_MARKET,
TRAILING_STOP_MARKET,
TAKE_PROFIT_MARKET,
TAKE_PROFIT_MARKET;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @see UserDataUpdateEvent
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class OrderTradeUpdateEvent {
public class ExecutionReport {

@JsonProperty("e")
private String eventType;
Expand Down
Loading

0 comments on commit cb01952

Please sign in to comment.