Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions src/main/java/com/binance/api/client/BinanceApiRestClient.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.binance.api.client;

import com.binance.api.client.domain.account.*;
import com.binance.api.client.domain.account.request.AllOrdersRequest;
import com.binance.api.client.domain.account.request.CancelOrderRequest;
import com.binance.api.client.domain.account.request.CancelOrderResponse;
import com.binance.api.client.domain.account.request.OrderRequest;
import com.binance.api.client.domain.account.request.OrderStatusRequest;
import com.binance.api.client.domain.account.request.*;
import com.binance.api.client.domain.general.ExchangeInfo;
import com.binance.api.client.domain.general.Asset;
import com.binance.api.client.domain.market.AggTrade;
Expand Down Expand Up @@ -193,6 +189,38 @@ public interface BinanceApiRestClient {
*/
List<Order> getAllOrders(AllOrdersRequest orderRequest);

/**
* Send in a new OCO;
*
* @param oco
* the OCO to submit
* @return a response containing details about the newly placed OCO.
*/
NewOCOResponse newOCO(NewOCO oco);

/**
* Cancel an entire Order List
*
* @return
*/
CancelOrderListResponse cancelOrderList(CancelOrderListRequest cancelOrderListRequest);

/**
* Check an order list status
*
* @param orderListStatusRequest
* @return an orderList
*/
OrderList getOrderListStatus(OrderListStatusRequest orderListStatusRequest);

/**
* Get all list os orders
*
* @param allOrderListRequest
* @return
*/
List<OrderList> getAllOrderList(AllOrderListRequest allOrderListRequest);

/**
* Get current account information.
*/
Expand Down Expand Up @@ -245,6 +273,12 @@ public interface BinanceApiRestClient {
*/
WithdrawResult withdraw(String asset, String address, String amount, String name, String addressTag);

/**
* Conver a list of assets to BNB
* @param asset the list of assets to convert
*/
DustTransferResponse dustTranfer(List<String> asset);

/**
* Fetch account deposit history.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.binance.api.client.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public enum ContingencyType {
OCO
}
10 changes: 10 additions & 0 deletions src/main/java/com/binance/api/client/domain/OCOOrderStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.binance.api.client.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public enum OCOOrderStatus {
EXECUTING,
ALL_DONE,
REJECT
}
10 changes: 10 additions & 0 deletions src/main/java/com/binance/api/client/domain/OCOStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.binance.api.client.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public enum OCOStatus {
RESPONSE,
EXEC_STARTED,
ALL_DONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.binance.api.client.domain.account;

import java.util.List;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.binance.api.client.constant.BinanceApiConstants;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class DustTransferResponse {

private String totalServiceCharge;

private String totalTransfered;

private List<TransferResult> transferResult;

public String getTotalServiceCharge() {
return totalServiceCharge;
}

public void setTotalServiceCharge(String totalServiceCharge) {
this.totalServiceCharge = totalServiceCharge;
}

public String getTotalTransfered() {
return totalTransfered;
}

public void setTotalTransfered(String totalTransfered) {
this.totalTransfered = totalTransfered;
}

public List<TransferResult> getTransferResult() {
return transferResult;
}

public void setTransferResult(List<TransferResult> transferResult) {
this.transferResult = transferResult;
}

@Override
public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
.append("totalServiceCharge", totalServiceCharge)
.append("totalTransfered", totalTransfered)
.append("transferResult", transferResult)
.toString();
}

}
241 changes: 241 additions & 0 deletions src/main/java/com/binance/api/client/domain/account/NewOCO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
package com.binance.api.client.domain.account;

import org.apache.commons.lang3.builder.ToStringBuilder;

import com.binance.api.client.constant.BinanceApiConstants;
import com.binance.api.client.domain.OrderSide;
import com.binance.api.client.domain.TimeInForce;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class NewOCO {

/**
* Symbol to place the order on.
*/
private String symbol;

/**
* A unique Id for the entire orderList
*/
private String listClientOrderId;

/**
* Buy/Sell order side.
*/
private OrderSide side;

/**
* Quantity.
*/
private String quantity;

/**
* A unique Id for the limit order
*/
private String limitClientOrderId;

/**
* Price.
*/
private String price;

/**
* Used to make the LIMIT_MAKER leg an iceberg order.
*/
private String limitIcebergQty;

/**
* A unique Id for the stop loss/stop loss limit leg
*/
private String stopClientOrderId;

/**
* Stop Price.
*/
private String stopPrice;

/**
* If provided, stopLimitTimeInForce is required.
*/
private String stopLimitPrice;

/**
* Used with STOP_LOSS_LIMIT leg to make an iceberg order.
*/
private String stopIcebergQty;

/**
* Valid values are GTC/FOK/IOC
*/
private TimeInForce stopLimitTimeInForce;

/**
* Set the response JSON. ACK, RESULT, or FULL; default: RESULT.
*/
private NewOrderResponseType newOrderRespType;

/**
* Receiving window.
*/
private Long recvWindow;

/**
* Order timestamp.
*/
private long timestamp;

/**
* Creates a new OCO with all required parameters.
*/
public NewOCO(String symbol, OrderSide side, String quantity, String price, String stopPrice) {
this.symbol = symbol;
this.side = side;
this.quantity = quantity;
this.price = price;
this.stopPrice = stopPrice;
this.timestamp = System.currentTimeMillis();
this.recvWindow = BinanceApiConstants.DEFAULT_RECEIVING_WINDOW;
}

public String getSymbol() {
return symbol;
}

public void setSymbol(String symbol) {
this.symbol = symbol;
}

public String getListClientOrderId() {
return listClientOrderId;
}

public void setListClientOrderId(String listClientOrderId) {
this.listClientOrderId = listClientOrderId;
}

public OrderSide getSide() {
return side;
}

public void setSide(OrderSide side) {
this.side = side;
}

public String getQuantity() {
return quantity;
}

public void setQuantity(String quantity) {
this.quantity = quantity;
}

public String getLimitClientOrderId() {
return limitClientOrderId;
}

public void setLimitClientOrderId(String limitClientOrderId) {
this.limitClientOrderId = limitClientOrderId;
}

public String getPrice() {
return price;
}

public void setPrice(String price) {
this.price = price;
}

public String getLimitIcebergQty() {
return limitIcebergQty;
}

public void setLimitIcebergQty(String limitIcebergQty) {
this.limitIcebergQty = limitIcebergQty;
}

public String getStopClientOrderId() {
return stopClientOrderId;
}

public void setStopClientOrderId(String stopClientOrderId) {
this.stopClientOrderId = stopClientOrderId;
}

public String getStopPrice() {
return stopPrice;
}

public void setStopPrice(String stopPrice) {
this.stopPrice = stopPrice;
}

public String getStopLimitPrice() {
return stopLimitPrice;
}

public void setStopLimitPrice(String stopLimitPrice) {
this.stopLimitPrice = stopLimitPrice;
}

public String getStopIcebergQty() {
return stopIcebergQty;
}

public void setStopIcebergQty(String stopIcebergQty) {
this.stopIcebergQty = stopIcebergQty;
}

public TimeInForce getStopLimitTimeInForce() {
return stopLimitTimeInForce;
}

public void setStopLimitTimeInForce(TimeInForce stopLimitTimeInForce) {
this.stopLimitTimeInForce = stopLimitTimeInForce;
}

public NewOrderResponseType getNewOrderRespType() {
return newOrderRespType;
}

public void setNewOrderRespType(NewOrderResponseType newOrderRespType) {
this.newOrderRespType = newOrderRespType;
}

public Long getRecvWindow() {
return recvWindow;
}

public void setRecvWindow(Long recvWindow) {
this.recvWindow = recvWindow;
}

public long getTimestamp() {
return timestamp;
}

public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}

@Override
public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("symbol", symbol)
.append("listClientOrderId", listClientOrderId)
.append("side", side)
.append("quantity", quantity)
.append("limitClientOrderId", limitClientOrderId)
.append("price", price)
.append("limitIcebergQty", limitIcebergQty)
.append("stopClientOrderId", stopClientOrderId)
.append("stopPrice", stopPrice)
.append("stopLimitPrice", stopLimitPrice)
.append("stopIcebergQty", stopIcebergQty)
.append("stopLimitTimeInForce", stopLimitTimeInForce)
.append("newOrderRespType", newOrderRespType)
.append("recvWindow", recvWindow)
.append("timestamp", timestamp)
.toString();
}

}
Loading