symbol
.
- *
+ *
* @param symbol ticker symbol (e.g. ETHBTC)
*/
TickerPrice getPrice(String symbol);
@@ -176,7 +171,7 @@ public interface BinanceApiRestClient {
*
* @param cancelOrderRequest order status request parameters
*/
- void cancelOrder(CancelOrderRequest cancelOrderRequest);
+ CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest);
/**
* Get all open orders on a symbol.
@@ -194,6 +189,38 @@ public interface BinanceApiRestClient {
*/
Listquantity
.
+ *
+ * @return a new order which is pre-configured with MARKET as the order type and BUY as the order side.
+ */
+ public static MarginNewOrder marketBuy(String symbol, String quantity) {
+ return new MarginNewOrder(symbol, OrderSide.BUY, OrderType.MARKET, null, quantity);
+ }
+
+ /**
+ * Places a MARKET sell order for the given quantity
.
+ *
+ * @return a new order which is pre-configured with MARKET as the order type and SELL as the order side.
+ */
+ public static MarginNewOrder marketSell(String symbol, String quantity) {
+ return new MarginNewOrder(symbol, OrderSide.SELL, OrderType.MARKET, null, quantity);
+ }
+
+ /**
+ * Places a LIMIT buy order for the given quantity
and price
.
+ *
+ * @return a new order which is pre-configured with LIMIT as the order type and BUY as the order side.
+ */
+ public static MarginNewOrder limitBuy(String symbol, TimeInForce timeInForce, String quantity, String price) {
+ return new MarginNewOrder(symbol, OrderSide.BUY, OrderType.LIMIT, timeInForce, quantity, price);
+ }
+
+ /**
+ * Places a LIMIT sell order for the given quantity
and price
.
+ *
+ * @return a new order which is pre-configured with LIMIT as the order type and SELL as the order side.
+ */
+ public static MarginNewOrder limitSell(String symbol, TimeInForce timeInForce, String quantity, String price) {
+ return new MarginNewOrder(symbol, OrderSide.SELL, OrderType.LIMIT, timeInForce, quantity, price);
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
+ .append("symbol", symbol)
+ .append("side", side)
+ .append("type", type)
+ .append("timeInForce", timeInForce)
+ .append("quantity", quantity)
+ .append("quoteOrderQty", quoteOrderQty)
+ .append("price", price)
+ .append("newClientOrderId", newClientOrderId)
+ .append("stopPrice", stopPrice)
+ .append("icebergQty", icebergQty)
+ .append("newOrderRespType", newOrderRespType)
+ .append("sideEffectType", sideEffectType)
+ .append("recvWindow", recvWindow)
+ .append("timestamp", timestamp)
+ .toString();
+ }
+}
diff --git a/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java b/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java
new file mode 100755
index 000000000..0d65d82ea
--- /dev/null
+++ b/src/main/java/com/binance/api/client/domain/account/MarginNewOrderResponse.java
@@ -0,0 +1,210 @@
+package com.binance.api.client.domain.account;
+
+import com.binance.api.client.constant.BinanceApiConstants;
+import com.binance.api.client.domain.OrderSide;
+import com.binance.api.client.domain.OrderStatus;
+import com.binance.api.client.domain.OrderType;
+import com.binance.api.client.domain.TimeInForce;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * Response returned when placing a new order on the system.
+ *
+ * @see NewOrder for the request
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class MarginNewOrderResponse {
+
+ /**
+ * Order symbol.
+ */
+ private String symbol;
+
+ /**
+ * Order id.
+ */
+ private Long orderId;
+
+ /**
+ * This will be either a generated one, or the newClientOrderId parameter
+ * which was passed when creating the new order.
+ */
+ private String clientOrderId;
+
+ private String price;
+
+ private String origQty;
+
+ private String executedQty;
+
+ private String cummulativeQuoteQty;
+
+ private OrderStatus status;
+
+ private TimeInForce timeInForce;
+
+ private OrderType type;
+
+ private String marginBuyBorrowAmount;
+
+ private String marginBuyBorrowAsset;
+
+ private OrderSide side;
+
+ // @JsonSetter(nulls = Nulls.AS_EMPTY)
+ private List
+ * This event is embedded as part of a user data update event.
+ *
+ * @see UserDataUpdateEvent
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class BalanceUpdateEvent {
+
+ @JsonProperty("e")
+ private String eventType;
+
+ @JsonProperty("E")
+ private long eventTime;
+
+ @JsonProperty("a")
+ private String asset;
+
+ @JsonProperty("d")
+ private String balanceDelta;
+
+ @JsonProperty("T")
+ private Long clearTime;
+
+ public String getEventType() {
+ return eventType;
+ }
+
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ public long getEventTime() {
+ return eventTime;
+ }
+
+ public void setEventTime(long eventTime) {
+ this.eventTime = eventTime;
+ }
+
+ public String getAsset() {
+ return asset;
+ }
+
+ public void setAsset(String asset) {
+ this.asset = asset;
+ }
+
+ public String getBalanceDelta() {
+ return balanceDelta;
+ }
+
+ public void setBalanceDelta(String balanceDelta) {
+ this.balanceDelta = balanceDelta;
+ }
+
+ public Long getClearTime() {
+ return clearTime;
+ }
+
+ public void setClearTime(Long clearTime) {
+ this.clearTime = clearTime;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
+ .append("eventType", eventType)
+ .append("eventTime", eventTime)
+ .append("balances", asset)
+ .append("balanceDelta", balanceDelta)
+ .append("clearTime", clearTime)
+ .toString();
+ }
+}
diff --git a/src/main/java/com/binance/api/client/domain/event/BookTickerEvent.java b/src/main/java/com/binance/api/client/domain/event/BookTickerEvent.java
new file mode 100755
index 000000000..d3612194f
--- /dev/null
+++ b/src/main/java/com/binance/api/client/domain/event/BookTickerEvent.java
@@ -0,0 +1,112 @@
+package com.binance.api.client.domain.event;
+
+import com.binance.api.client.constant.BinanceApiConstants;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * BookTickerEvent event for a symbol. Pushes any update to the best bid or
+ * ask's price or quantity in real-time for a specified symbol.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class BookTickerEvent {
+
+ @JsonProperty("u")
+ private long updateId;
+
+ @JsonProperty("s")
+ private String symbol;
+
+ @JsonProperty("b")
+ private String bidPrice;
+
+ @JsonProperty("B")
+ private String bidQuantity;
+
+ @JsonProperty("a")
+ private String askPrice;
+
+ @JsonProperty("A")
+ private String askQuantity;
+
+ public BookTickerEvent() {
+ super();
+ }
+
+ public BookTickerEvent(long updateId, String symbol, String bidPrice, String bidQuantity, String askPrice,
+ String askQuantity) {
+ super();
+ this.updateId = updateId;
+ this.symbol = symbol;
+ this.bidPrice = bidPrice;
+ this.bidQuantity = bidQuantity;
+ this.askPrice = askPrice;
+ this.askQuantity = askQuantity;
+ }
+
+ public BookTickerEvent(String symbol, String bidPrice, String bidQuantity, String askPrice, String askQuantity) {
+ super();
+ this.symbol = symbol;
+ this.bidPrice = bidPrice;
+ this.bidQuantity = bidQuantity;
+ this.askPrice = askPrice;
+ this.askQuantity = askQuantity;
+ }
+
+ public long getUpdateId() {
+ return updateId;
+ }
+
+ public void setUpdateId(long updateId) {
+ this.updateId = updateId;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+ public String getBidPrice() {
+ return bidPrice;
+ }
+
+ public void setBidPrice(String bidPrice) {
+ this.bidPrice = bidPrice;
+ }
+
+ public String getBidQuantity() {
+ return bidQuantity;
+ }
+
+ public void setBidQuantity(String bidQuantity) {
+ this.bidQuantity = bidQuantity;
+ }
+
+ public String getAskPrice() {
+ return askPrice;
+ }
+
+ public void setAskPrice(String askPrice) {
+ this.askPrice = askPrice;
+ }
+
+ public String getAskQuantity() {
+ return askQuantity;
+ }
+
+ public void setAskQuantity(String askQuantity) {
+ this.askQuantity = askQuantity;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("eventType", "BookTicker")
+ .append("updateId", updateId).append("symbol", symbol).append("bidPrice", bidPrice)
+ .append("bidQuantity", bidQuantity).append("askPrice", askPrice).append("askQuantity", askQuantity)
+ .toString();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/binance/api/client/domain/event/CandlestickEvent.java b/src/main/java/com/binance/api/client/domain/event/CandlestickEvent.java
old mode 100644
new mode 100755
index 31cbe1e4f..f7c04b3df
--- a/src/main/java/com/binance/api/client/domain/event/CandlestickEvent.java
+++ b/src/main/java/com/binance/api/client/domain/event/CandlestickEvent.java
@@ -1,219 +1,221 @@
-package com.binance.api.client.domain.event;
-
-import com.binance.api.client.constant.BinanceApiConstants;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
-/**
- * An interval candlestick for a symbol providing informations on price that can be used to produce candlestick charts.
- */
-@JsonDeserialize(using = CandlestickEventDeserializer.class)
-@JsonSerialize(using = CandlestickEventSerializer.class)
-public class CandlestickEvent {
-
- private String eventType;
-
- private long eventTime;
-
- private String symbol;
-
- private Long openTime;
-
- private String open;
-
- private String high;
-
- private String low;
-
- private String close;
-
- private String volume;
-
- private Long closeTime;
-
- private String intervalId;
-
- private Long firstTradeId;
-
- private Long lastTradeId;
-
- private String quoteAssetVolume;
-
- private Long numberOfTrades;
-
- private String takerBuyBaseAssetVolume;
-
- private String takerBuyQuoteAssetVolume;
-
- private Boolean isBarFinal;
-
- public String getEventType() {
- return eventType;
- }
-
- public void setEventType(String eventType) {
- this.eventType = eventType;
- }
-
- public long getEventTime() {
- return eventTime;
- }
-
- public void setEventTime(long eventTime) {
- this.eventTime = eventTime;
- }
-
- public String getSymbol() {
- return symbol;
- }
-
- public void setSymbol(String symbol) {
- this.symbol = symbol;
- }
-
- public Long getOpenTime() {
- return openTime;
- }
-
- public void setOpenTime(Long openTime) {
- this.openTime = openTime;
- }
-
- public String getOpen() {
- return open;
- }
-
- public void setOpen(String open) {
- this.open = open;
- }
-
- public String getHigh() {
- return high;
- }
-
- public void setHigh(String high) {
- this.high = high;
- }
-
- public String getLow() {
- return low;
- }
-
- public void setLow(String low) {
- this.low = low;
- }
-
- public String getClose() {
- return close;
- }
-
- public void setClose(String close) {
- this.close = close;
- }
-
- public String getVolume() {
- return volume;
- }
-
- public void setVolume(String volume) {
- this.volume = volume;
- }
-
- public Long getCloseTime() {
- return closeTime;
- }
-
- public void setCloseTime(Long closeTime) {
- this.closeTime = closeTime;
- }
-
- public String getIntervalId() {
- return intervalId;
- }
-
- public void setIntervalId(String intervalId) {
- this.intervalId = intervalId;
- }
-
- public Long getFirstTradeId() {
- return firstTradeId;
- }
-
- public void setFirstTradeId(Long firstTradeId) {
- this.firstTradeId = firstTradeId;
- }
-
- public Long getLastTradeId() {
- return lastTradeId;
- }
-
- public void setLastTradeId(Long lastTradeId) {
- this.lastTradeId = lastTradeId;
- }
-
- public String getQuoteAssetVolume() {
- return quoteAssetVolume;
- }
-
- public void setQuoteAssetVolume(String quoteAssetVolume) {
- this.quoteAssetVolume = quoteAssetVolume;
- }
-
- public Long getNumberOfTrades() {
- return numberOfTrades;
- }
-
- public void setNumberOfTrades(Long numberOfTrades) {
- this.numberOfTrades = numberOfTrades;
- }
-
- public String getTakerBuyBaseAssetVolume() {
- return takerBuyBaseAssetVolume;
- }
-
- public void setTakerBuyBaseAssetVolume(String takerBuyBaseAssetVolume) {
- this.takerBuyBaseAssetVolume = takerBuyBaseAssetVolume;
- }
-
- public String getTakerBuyQuoteAssetVolume() {
- return takerBuyQuoteAssetVolume;
- }
-
- public void setTakerBuyQuoteAssetVolume(String takerBuyQuoteAssetVolume) {
- this.takerBuyQuoteAssetVolume = takerBuyQuoteAssetVolume;
- }
-
- public Boolean getBarFinal() {
- return isBarFinal;
- }
-
- public void setBarFinal(Boolean barFinal) {
- isBarFinal = barFinal;
- }
-
- @Override
- public String toString() {
- return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
- .append("eventType", eventType)
- .append("eventTime", eventTime)
- .append("symbol", symbol)
- .append("openTime", openTime)
- .append("open", open)
- .append("high", high)
- .append("low", low)
- .append("close", close)
- .append("volume", volume)
- .append("closeTime", closeTime)
- .append("intervalId", intervalId)
- .append("firstTradeId", firstTradeId)
- .append("lastTradeId", lastTradeId)
- .append("quoteAssetVolume", quoteAssetVolume)
- .append("numberOfTrades", numberOfTrades)
- .append("takerBuyBaseAssetVolume", takerBuyBaseAssetVolume)
- .append("takerBuyQuoteAssetVolume", takerBuyQuoteAssetVolume)
- .append("isBarFinal", isBarFinal)
- .toString();
- }
+package com.binance.api.client.domain.event;
+
+import com.binance.api.client.constant.BinanceApiConstants;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * An interval candlestick for a symbol providing informations on price that can be used to produce candlestick charts.
+ */
+@JsonDeserialize(using = CandlestickEventDeserializer.class)
+@JsonSerialize(using = CandlestickEventSerializer.class)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CandlestickEvent {
+
+ private String eventType;
+
+ private long eventTime;
+
+ private String symbol;
+
+ private Long openTime;
+
+ private String open;
+
+ private String high;
+
+ private String low;
+
+ private String close;
+
+ private String volume;
+
+ private Long closeTime;
+
+ private String intervalId;
+
+ private Long firstTradeId;
+
+ private Long lastTradeId;
+
+ private String quoteAssetVolume;
+
+ private Long numberOfTrades;
+
+ private String takerBuyBaseAssetVolume;
+
+ private String takerBuyQuoteAssetVolume;
+
+ private Boolean isBarFinal;
+
+ public String getEventType() {
+ return eventType;
+ }
+
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ public long getEventTime() {
+ return eventTime;
+ }
+
+ public void setEventTime(long eventTime) {
+ this.eventTime = eventTime;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+ public Long getOpenTime() {
+ return openTime;
+ }
+
+ public void setOpenTime(Long openTime) {
+ this.openTime = openTime;
+ }
+
+ public String getOpen() {
+ return open;
+ }
+
+ public void setOpen(String open) {
+ this.open = open;
+ }
+
+ public String getHigh() {
+ return high;
+ }
+
+ public void setHigh(String high) {
+ this.high = high;
+ }
+
+ public String getLow() {
+ return low;
+ }
+
+ public void setLow(String low) {
+ this.low = low;
+ }
+
+ public String getClose() {
+ return close;
+ }
+
+ public void setClose(String close) {
+ this.close = close;
+ }
+
+ public String getVolume() {
+ return volume;
+ }
+
+ public void setVolume(String volume) {
+ this.volume = volume;
+ }
+
+ public Long getCloseTime() {
+ return closeTime;
+ }
+
+ public void setCloseTime(Long closeTime) {
+ this.closeTime = closeTime;
+ }
+
+ public String getIntervalId() {
+ return intervalId;
+ }
+
+ public void setIntervalId(String intervalId) {
+ this.intervalId = intervalId;
+ }
+
+ public Long getFirstTradeId() {
+ return firstTradeId;
+ }
+
+ public void setFirstTradeId(Long firstTradeId) {
+ this.firstTradeId = firstTradeId;
+ }
+
+ public Long getLastTradeId() {
+ return lastTradeId;
+ }
+
+ public void setLastTradeId(Long lastTradeId) {
+ this.lastTradeId = lastTradeId;
+ }
+
+ public String getQuoteAssetVolume() {
+ return quoteAssetVolume;
+ }
+
+ public void setQuoteAssetVolume(String quoteAssetVolume) {
+ this.quoteAssetVolume = quoteAssetVolume;
+ }
+
+ public Long getNumberOfTrades() {
+ return numberOfTrades;
+ }
+
+ public void setNumberOfTrades(Long numberOfTrades) {
+ this.numberOfTrades = numberOfTrades;
+ }
+
+ public String getTakerBuyBaseAssetVolume() {
+ return takerBuyBaseAssetVolume;
+ }
+
+ public void setTakerBuyBaseAssetVolume(String takerBuyBaseAssetVolume) {
+ this.takerBuyBaseAssetVolume = takerBuyBaseAssetVolume;
+ }
+
+ public String getTakerBuyQuoteAssetVolume() {
+ return takerBuyQuoteAssetVolume;
+ }
+
+ public void setTakerBuyQuoteAssetVolume(String takerBuyQuoteAssetVolume) {
+ this.takerBuyQuoteAssetVolume = takerBuyQuoteAssetVolume;
+ }
+
+ public Boolean getBarFinal() {
+ return isBarFinal;
+ }
+
+ public void setBarFinal(Boolean barFinal) {
+ isBarFinal = barFinal;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
+ .append("eventType", eventType)
+ .append("eventTime", eventTime)
+ .append("symbol", symbol)
+ .append("openTime", openTime)
+ .append("open", open)
+ .append("high", high)
+ .append("low", low)
+ .append("close", close)
+ .append("volume", volume)
+ .append("closeTime", closeTime)
+ .append("intervalId", intervalId)
+ .append("firstTradeId", firstTradeId)
+ .append("lastTradeId", lastTradeId)
+ .append("quoteAssetVolume", quoteAssetVolume)
+ .append("numberOfTrades", numberOfTrades)
+ .append("takerBuyBaseAssetVolume", takerBuyBaseAssetVolume)
+ .append("takerBuyQuoteAssetVolume", takerBuyQuoteAssetVolume)
+ .append("isBarFinal", isBarFinal)
+ .toString();
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/binance/api/client/domain/event/CandlestickEventDeserializer.java b/src/main/java/com/binance/api/client/domain/event/CandlestickEventDeserializer.java
old mode 100644
new mode 100755
index b8665e448..7792fc73a
--- a/src/main/java/com/binance/api/client/domain/event/CandlestickEventDeserializer.java
+++ b/src/main/java/com/binance/api/client/domain/event/CandlestickEventDeserializer.java
@@ -1,50 +1,50 @@
-package com.binance.api.client.domain.event;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.ObjectCodec;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonNode;
-
-import java.io.IOException;
-
-/**
- * Custom deserializer for a candlestick stream event, since the structure of the candlestick json differ from the one in the REST API.
- *
- * @see CandlestickEvent
- */
-public class CandlestickEventDeserializer extends JsonDeserializer
* This event is embedded as part of a user data update event.
*
* @see UserDataUpdateEvent
@@ -25,7 +20,7 @@ public class OrderTradeUpdateEvent {
private String eventType;
@JsonProperty("E")
- private long eventTime;
+ private Long eventTime;
@JsonProperty("s")
private String symbol;
@@ -129,6 +124,30 @@ public class OrderTradeUpdateEvent {
@JsonProperty("t")
private Long tradeId;
+ /**
+ * Order creation time.
+ */
+ @JsonProperty("O")
+ private Long orderCreationTime;
+
+ /**
+ * Cumulative quote asset transacted quantity.
+ */
+ @JsonProperty("Z")
+ private String cumulativeQuoteQty;
+
+ /**
+ * Last quote asset transacted quantity (i.e. lastPrice * lastQty).
+ */
+ @JsonProperty("Y")
+ private String lastQuoteQty;
+
+ /**
+ * Quote Order Qty.
+ */
+ @JsonProperty("Q")
+ private String quoteOrderQty;
+
public String getEventType() {
return eventType;
}
@@ -137,11 +156,11 @@ public void setEventType(String eventType) {
this.eventType = eventType;
}
- public long getEventTime() {
+ public Long getEventTime() {
return eventTime;
}
- public void setEventTime(long eventTime) {
+ public void setEventTime(Long eventTime) {
this.eventTime = eventTime;
}
@@ -225,7 +244,7 @@ public void setOrderRejectReason(OrderRejectReason orderRejectReason) {
this.orderRejectReason = orderRejectReason;
}
- public long getOrderId() {
+ public Long getOrderId() {
return orderId;
}
@@ -273,22 +292,53 @@ public void setCommissionAsset(String commissionAsset) {
this.commissionAsset = commissionAsset;
}
- public long getOrderTradeTime() {
+ public Long getOrderTradeTime() {
return orderTradeTime;
}
- public void setOrderTradeTime(long orderTradeTime) {
+ public void setOrderTradeTime(Long orderTradeTime) {
this.orderTradeTime = orderTradeTime;
}
- public long getTradeId() {
+ public Long getTradeId() {
return tradeId;
}
- public void setTradeId(long tradeId) {
+ public void setTradeId(Long tradeId) {
this.tradeId = tradeId;
}
+ public Long getOrderCreationTime() {
+ return orderCreationTime;
+ }
+
+ public void setOrderCreationTime(Long orderCreationTime) {
+ this.orderCreationTime = orderCreationTime;
+ }
+
+ public String getCumulativeQuoteQty() {
+ return cumulativeQuoteQty;
+ }
+
+ public void setCumulativeQuoteQty(String cumulativeQuoteQty) {
+ this.cumulativeQuoteQty = cumulativeQuoteQty;
+ }
+
+ public String getLastQuoteQty() {
+ return lastQuoteQty;
+ }
+
+ public void setLastQuoteQty(String lastQuoteQty) {
+ this.lastQuoteQty = lastQuoteQty;
+ }
+
+ public String getQuoteOrderQty() {
+ return quoteOrderQty;
+ }
+
+ public void setQuoteOrderQty(String quoteOrderQty) {
+ this.quoteOrderQty = quoteOrderQty;
+ }
@Override
public String toString() {
@@ -313,6 +363,10 @@ public String toString() {
.append("commissionAsset", commissionAsset)
.append("orderTradeTime", orderTradeTime)
.append("tradeId", tradeId)
+ .append("orderCreationTime", orderCreationTime)
+ .append("cumulativeQuoteQty", cumulativeQuoteQty)
+ .append("lastQuoteQty", lastQuoteQty)
+ .append("quoteOrderQty", quoteOrderQty)
.toString();
}
}
diff --git a/src/main/java/com/binance/api/client/domain/event/TickerEvent.java b/src/main/java/com/binance/api/client/domain/event/TickerEvent.java
new file mode 100755
index 000000000..c0c7e97f1
--- /dev/null
+++ b/src/main/java/com/binance/api/client/domain/event/TickerEvent.java
@@ -0,0 +1,295 @@
+package com.binance.api.client.domain.event;
+
+import com.binance.api.client.constant.BinanceApiConstants;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class TickerEvent {
+
+ @JsonProperty("e")
+ private String eventType;
+
+ @JsonProperty("E")
+ private long eventTime;
+
+ @JsonProperty("s")
+ private String symbol;
+
+ @JsonProperty("p")
+ private String priceChange;
+
+ @JsonProperty("P")
+ private String priceChangePercent;
+
+ @JsonProperty("w")
+ private String weightedAveragePrice;
+
+ @JsonProperty("x")
+ private String previousDaysClosePrice;
+
+ @JsonProperty("c")
+ private String currentDaysClosePrice;
+
+ @JsonProperty("Q")
+ private String closeTradesQuantity;
+
+ @JsonProperty("b")
+ private String bestBidPrice;
+
+ @JsonProperty("B")
+ private String bestBidQuantity;
+
+ @JsonProperty("a")
+ private String bestAskPrice;
+
+ @JsonProperty("A")
+ private String bestAskQuantity;
+
+ @JsonProperty("o")
+ private String openPrice;
+
+ @JsonProperty("h")
+ private String highPrice;
+
+ @JsonProperty("l")
+ private String lowPrice;
+
+ @JsonProperty("v")
+ private String totalTradedBaseAssetVolume;
+
+ @JsonProperty("q")
+ private String totalTradedQuoteAssetVolume;
+
+ @JsonProperty("O")
+ private long statisticsOpenTime;
+
+ @JsonProperty("C")
+ private long statisticsCloseTime;
+
+ @JsonProperty("F")
+ private long firstTradeId;
+
+ @JsonProperty("L")
+ private long lastTradeId;
+
+ @JsonProperty("n")
+ private long totalNumberOfTrades;
+
+ public String getEventType() {
+ return eventType;
+ }
+
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ public long getEventTime() {
+ return eventTime;
+ }
+
+ public void setEventTime(long eventTime) {
+ this.eventTime = eventTime;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+ public String getPriceChange() {
+ return priceChange;
+ }
+
+ public void setPriceChange(String priceChange) {
+ this.priceChange = priceChange;
+ }
+
+ public String getPriceChangePercent() {
+ return priceChangePercent;
+ }
+
+ public void setPriceChangePercent(String priceChangePercent) {
+ this.priceChangePercent = priceChangePercent;
+ }
+
+ public String getWeightedAveragePrice() {
+ return weightedAveragePrice;
+ }
+
+ public void setWeightedAveragePrice(String weightedAveragePrice) {
+ this.weightedAveragePrice = weightedAveragePrice;
+ }
+
+ public String getPreviousDaysClosePrice() {
+ return previousDaysClosePrice;
+ }
+
+ public void setPreviousDaysClosePrice(String previousDaysClosePrice) {
+ this.previousDaysClosePrice = previousDaysClosePrice;
+ }
+
+ public String getCurrentDaysClosePrice() {
+ return currentDaysClosePrice;
+ }
+
+ public void setCurrentDaysClosePrice(String currentDaysClosePrice) {
+ this.currentDaysClosePrice = currentDaysClosePrice;
+ }
+
+ public String getCloseTradesQuantity() {
+ return closeTradesQuantity;
+ }
+
+ public void setCloseTradesQuantity(String closeTradesQuantity) {
+ this.closeTradesQuantity = closeTradesQuantity;
+ }
+
+ public String getBestBidPrice() {
+ return bestBidPrice;
+ }
+
+ public void setBestBidPrice(String bestBidPrice) {
+ this.bestBidPrice = bestBidPrice;
+ }
+
+ public String getBestBidQuantity() {
+ return bestBidQuantity;
+ }
+
+ public void setBestBidQuantity(String bestBidQuantity) {
+ this.bestBidQuantity = bestBidQuantity;
+ }
+
+ public String getBestAskPrice() {
+ return bestAskPrice;
+ }
+
+ public void setBestAskPrice(String bestAskPrice) {
+ this.bestAskPrice = bestAskPrice;
+ }
+
+ public String getBestAskQuantity() {
+ return bestAskQuantity;
+ }
+
+ public void setBestAskQuantity(String bestAskQuantity) {
+ this.bestAskQuantity = bestAskQuantity;
+ }
+
+ public String getOpenPrice() {
+ return openPrice;
+ }
+
+ public void setOpenPrice(String openPrice) {
+ this.openPrice = openPrice;
+ }
+
+ public String getHighPrice() {
+ return highPrice;
+ }
+
+ public void setHighPrice(String highPrice) {
+ this.highPrice = highPrice;
+ }
+
+ public String getLowPrice() {
+ return lowPrice;
+ }
+
+ public void setLowPrice(String lowPrice) {
+ this.lowPrice = lowPrice;
+ }
+
+ public String getTotalTradedBaseAssetVolume() {
+ return totalTradedBaseAssetVolume;
+ }
+
+ public void setTotalTradedBaseAssetVolume(String totalTradedBaseAssetVolume) {
+ this.totalTradedBaseAssetVolume = totalTradedBaseAssetVolume;
+ }
+
+ public String getTotalTradedQuoteAssetVolume() {
+ return totalTradedQuoteAssetVolume;
+ }
+
+ public void setTotalTradedQuoteAssetVolume(String totalTradedQuoteAssetVolume) {
+ this.totalTradedQuoteAssetVolume = totalTradedQuoteAssetVolume;
+ }
+
+ public long getStatisticsOpenTime() {
+ return statisticsOpenTime;
+ }
+
+ public void setStatisticsOpenTime(long statisticsOpenTime) {
+ this.statisticsOpenTime = statisticsOpenTime;
+ }
+
+ public long getStatisticsCloseTime() {
+ return statisticsCloseTime;
+ }
+
+ public void setStatisticsCloseTime(long statisticsCloseTime) {
+ this.statisticsCloseTime = statisticsCloseTime;
+ }
+
+ public long getFirstTradeId() {
+ return firstTradeId;
+ }
+
+ public void setFirstTradeId(long firstTradeId) {
+ this.firstTradeId = firstTradeId;
+ }
+
+ public long getLastTradeId() {
+ return lastTradeId;
+ }
+
+ public void setLastTradeId(long lastTradeId) {
+ this.lastTradeId = lastTradeId;
+ }
+
+ public long getTotalNumberOfTrades() {
+ return totalNumberOfTrades;
+ }
+
+ public void setTotalNumberOfTrades(long totalNumberOfTrades) {
+ this.totalNumberOfTrades = totalNumberOfTrades;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
+ .append("eventType", eventType)
+ .append("eventTime", eventTime)
+ .append("symbol", symbol)
+ .append("priceChange", priceChange)
+ .append("priceChangePercent", priceChangePercent)
+ .append("weightedAveragePrice", weightedAveragePrice)
+ .append("previousDaysClosePrice", previousDaysClosePrice)
+ .append("currentDaysClosePrice", currentDaysClosePrice)
+ .append("closeTradesQuantity", closeTradesQuantity)
+ .append("bestBidPrice", bestBidPrice)
+ .append("bestBidQuantity", bestBidQuantity)
+ .append("bestAskPrice", bestAskPrice)
+ .append("bestAskQuantity", bestAskQuantity)
+ .append("openPrice", openPrice)
+ .append("highPrice", highPrice)
+ .append("lowPrice", lowPrice)
+ .append("totalTradedBaseAssetVolume", totalTradedBaseAssetVolume)
+ .append("totalTradedQuoteAssetVolume", totalTradedQuoteAssetVolume)
+ .append("statisticsOpenTime", statisticsOpenTime)
+ .append("statisticsCloseTime", statisticsCloseTime)
+ .append("firstTradeId", firstTradeId)
+ .append("lastTradeId", lastTradeId)
+ .append("totalNumberOfTrades", totalNumberOfTrades)
+ .toString();
+ }
+}
diff --git a/src/main/java/com/binance/api/client/domain/event/TopOrdersEvent.java b/src/main/java/com/binance/api/client/domain/event/TopOrdersEvent.java
new file mode 100755
index 000000000..a9a0a3c78
--- /dev/null
+++ b/src/main/java/com/binance/api/client/domain/event/TopOrdersEvent.java
@@ -0,0 +1,51 @@
+package com.binance.api.client.domain.event;
+
+import com.binance.api.client.constant.BinanceApiConstants;
+import com.binance.api.client.domain.market.OrderBookEntry;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.util.List;
+
+/**
+ * Top bids and asks from Partial Book Depth event
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class TopOrdersEvent {
+ private Long lastUpdateId;
+ private List
* 1) outboundAccountInfo, whenever there is a change in the account (e.g. balance of an asset)
- * 2) executionReport, whenever there is a trade or an order
+ * 2) outboundAccountPosition, the change in account balances caused by an event.
+ * 3) executionReport, whenever there is a trade or an order
+ * 4) balanceUpdate, the change in account balance (delta).
+ *
+ * Deserialization could fail with UnsupportedEventException in case of unsupported eventType.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(using = UserDataUpdateEventDeserializer.class)
@@ -19,7 +24,9 @@ public class UserDataUpdateEvent {
private long eventTime;
- private AccountUpdateEvent accountUpdateEvent;
+ private AccountUpdateEvent outboundAccountPositionUpdateEvent;
+
+ private BalanceUpdateEvent balanceUpdateEvent;
private OrderTradeUpdateEvent orderTradeUpdateEvent;
@@ -39,12 +46,28 @@ public void setEventTime(long eventTime) {
this.eventTime = eventTime;
}
+ /**
+ * @Deprecated: left in for backwards compatibility. Use getOutboundAccountPositionUpdateEvent() instead, as that is what the Binance API documentation calls it.
+ */
+ @Deprecated
public AccountUpdateEvent getAccountUpdateEvent() {
- return accountUpdateEvent;
+ return outboundAccountPositionUpdateEvent;
+ }
+
+ public AccountUpdateEvent getOutboundAccountPositionUpdateEvent() {
+ return outboundAccountPositionUpdateEvent;
+ }
+
+ public void setOutboundAccountPositionUpdateEvent(AccountUpdateEvent accountUpdateEvent) {
+ this.outboundAccountPositionUpdateEvent = accountUpdateEvent;
+ }
+
+ public BalanceUpdateEvent getBalanceUpdateEvent() {
+ return balanceUpdateEvent;
}
- public void setAccountUpdateEvent(AccountUpdateEvent accountUpdateEvent) {
- this.accountUpdateEvent = accountUpdateEvent;
+ public void setBalanceUpdateEvent(BalanceUpdateEvent balanceUpdateEvent) {
+ this.balanceUpdateEvent = balanceUpdateEvent;
}
public OrderTradeUpdateEvent getOrderTradeUpdateEvent() {
@@ -60,8 +83,10 @@ public String toString() {
ToStringBuilder sb = new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
.append("eventType", eventType)
.append("eventTime", eventTime);
- if (eventType == UserDataUpdateEventType.ACCOUNT_UPDATE) {
- sb.append("accountUpdateEvent", accountUpdateEvent);
+ if (eventType == UserDataUpdateEventType.ACCOUNT_POSITION_UPDATE) {
+ sb.append("outboundAccountPositionUpdateEvent", outboundAccountPositionUpdateEvent);
+ } else if (eventType == UserDataUpdateEventType.BALANCE_UPDATE) {
+ sb.append("balanceUpdateEvent", balanceUpdateEvent);
} else {
sb.append("orderTradeUpdateEvent", orderTradeUpdateEvent);
}
@@ -69,8 +94,13 @@ public String toString() {
}
public enum UserDataUpdateEventType {
- ACCOUNT_UPDATE("outboundAccountInfo"),
- ORDER_TRADE_UPDATE("executionReport");
+ /** Corresponds to "outboundAccountPosition" events. */
+ ACCOUNT_POSITION_UPDATE("outboundAccountPosition"),
+ /** Corresponds to "balanceUpdate" events. */
+ BALANCE_UPDATE("balanceUpdate"),
+ /** Corresponds to "executionReport" events. */
+ ORDER_TRADE_UPDATE("executionReport"),
+ ;
private final String eventTypeId;
@@ -83,12 +113,14 @@ public String getEventTypeId() {
}
public static UserDataUpdateEventType fromEventTypeId(String eventTypeId) {
- if (ACCOUNT_UPDATE.eventTypeId.equals(eventTypeId)) {
- return ACCOUNT_UPDATE;
- } else if (ORDER_TRADE_UPDATE.eventTypeId.equals(eventTypeId)) {
+ if (ORDER_TRADE_UPDATE.eventTypeId.equals(eventTypeId)) {
return ORDER_TRADE_UPDATE;
+ } else if (ACCOUNT_POSITION_UPDATE.eventTypeId.equals(eventTypeId)) {
+ return ACCOUNT_POSITION_UPDATE;
+ } else if (BALANCE_UPDATE.eventTypeId.equals(eventTypeId)) {
+ return BALANCE_UPDATE;
}
- throw new IllegalArgumentException("Unrecognized user data update event type id: " + eventTypeId);
+ throw new UnsupportedEventException("Unrecognized user data update event type id: " + eventTypeId);
}
}
}
diff --git a/src/main/java/com/binance/api/client/domain/event/UserDataUpdateEventDeserializer.java b/src/main/java/com/binance/api/client/domain/event/UserDataUpdateEventDeserializer.java
old mode 100644
new mode 100755
index afc584636..9e0031efc
--- a/src/main/java/com/binance/api/client/domain/event/UserDataUpdateEventDeserializer.java
+++ b/src/main/java/com/binance/api/client/domain/event/UserDataUpdateEventDeserializer.java
@@ -12,7 +12,8 @@
import java.io.IOException;
/**
- * Custom deserializer for a User Data stream event, since the API can return two different responses in this stream.
+ * Custom deserializer for a User Data stream event, since the API can return four different responses in this stream.
+ *
* @see UserDataUpdateEvent
*/
public class UserDataUpdateEventDeserializer extends JsonDeserializer> callback) {
+ binanceApiService.getOpenMarginOrders(orderRequest.getSymbol(), orderRequest.getRecvWindow(),
+ orderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback));
+ }
+
+ @Override
+ public void newOrder(MarginNewOrder order, BinanceApiCallback
> callback) {
+ binanceApiService.getMyTrades(symbol, null, null, BinanceApiConstants.DEFAULT_RECEIVING_WINDOW, System.currentTimeMillis()).enqueue(new BinanceApiCallbackAdapter<>(callback));
+ }
+
+ // user stream endpoints
+
+ @Override
+ public void startUserDataStream(BinanceApiCallback
> callback) {
+ binanceApiService.getAllAssets(BinanceApiConfig.getAssetInfoApiBaseUrl() + "assetWithdraw/getAllAsset.html")
+ .enqueue(new BinanceApiCallbackAdapter<>(callback));
+ }
+
// Market Data endpoints
@Override
@@ -100,7 +110,7 @@ public void getCandlestickBars(String symbol, CandlestickInterval interval, Bina
public void get24HrPriceStatistics(String symbol, BinanceApiCallback
> callback) {
binanceApiService.getAll24HrPriceStatistics().enqueue(new BinanceApiCallbackAdapter<>(callback));
@@ -110,7 +120,7 @@ public void getAll24HrPriceStatistics(BinanceApiCallback
>
public void getAllPrices(BinanceApiCallback
> callback) {
binanceApiService.getLatestPrices().enqueue(new BinanceApiCallbackAdapter<>(callback));
}
-
+
@Override
public void getPrice(String symbol , BinanceApiCallback
> callback) {
@Override
public void newOrder(NewOrder order, BinanceApiCallback
> callback)
}
@Override
- public void withdraw(String asset, String address, String amount, String name, BinanceApiCallback