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

Add FilterType.TRAILING_DELTA #430

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.binance.api</groupId>
<artifactId>binance-api-client</artifactId>
<version>1.0.1</version>
<version>1.0.9</version>
<licenses>
<license>
<name>The MIT License</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ public interface BinanceApiAsyncRestClient {
*/
void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback<CancelOrderResponse> callback);

void cancelOpenOrders(CancelOrderRequest cancelOrderRequest, BinanceApiCallback<List<CancelOrderResponse>> callback);

/**
* Get all open orders on a symbol (asynchronous).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ public interface BinanceApiRestClient {
*/
CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest);

List<CancelOrderResponse> cancelOpenOrders(CancelOrderRequest cancelOrderRequest);

/**
* Get all open orders on a symbol.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ public enum FilterType {
MARKET_LOT_SIZE,
MAX_NUM_ICEBERG_ORDERS,
MAX_POSITION,
PERCENT_PRICE_BY_SIDE,

// Exchange
EXCHANGE_MAX_NUM_ORDERS,
EXCHANGE_MAX_ALGO_ORDERS
EXCHANGE_MAX_ALGO_ORDERS,
TRAILING_DELTA,

NOTIONAL
}
248 changes: 126 additions & 122 deletions src/main/java/com/binance/api/client/domain/general/SymbolInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,167 +5,171 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Symbol information (base/quote).
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class SymbolInfo {

private String symbol;
private String symbol;

private SymbolStatus status;
private SymbolStatus status;

private String baseAsset;
private String baseAsset;

private Integer baseAssetPrecision;
private Integer baseAssetPrecision;

private String quoteAsset;
private String quoteAsset;

private Integer quotePrecision;
private Integer quotePrecision;

private List<OrderType> orderTypes;
private List<OrderType> orderTypes;

private boolean icebergAllowed;
private boolean icebergAllowed;

private boolean ocoAllowed;
private boolean ocoAllowed;

private boolean quoteOrderQtyMarketAllowed;
private boolean quoteOrderQtyMarketAllowed;

private boolean isSpotTradingAllowed;
private boolean isSpotTradingAllowed;

private boolean isMarginTradingAllowed;
private boolean isMarginTradingAllowed;

private List<SymbolFilter> filters;
private List<SymbolFilter> filtersList;
private Map<FilterType, SymbolFilter> filtersMap;

public String getSymbol() {
return symbol;
}
public String getSymbol() {
return symbol;
}

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

public SymbolStatus getStatus() {
return status;
}
public SymbolStatus getStatus() {
return status;
}

public void setStatus(SymbolStatus status) {
this.status = status;
}
public void setStatus(SymbolStatus status) {
this.status = status;
}

public String getBaseAsset() {
return baseAsset;
}
public String getBaseAsset() {
return baseAsset;
}

public void setBaseAsset(String baseAsset) {
this.baseAsset = baseAsset;
}
public void setBaseAsset(String baseAsset) {
this.baseAsset = baseAsset;
}

public Integer getBaseAssetPrecision() {
return baseAssetPrecision;
}
public Integer getBaseAssetPrecision() {
return baseAssetPrecision;
}

public void setBaseAssetPrecision(Integer baseAssetPrecision) {
this.baseAssetPrecision = baseAssetPrecision;
}
public void setBaseAssetPrecision(Integer baseAssetPrecision) {
this.baseAssetPrecision = baseAssetPrecision;
}

public String getQuoteAsset() {
return quoteAsset;
}
public String getQuoteAsset() {
return quoteAsset;
}

public void setQuoteAsset(String quoteAsset) {
this.quoteAsset = quoteAsset;
}
public void setQuoteAsset(String quoteAsset) {
this.quoteAsset = quoteAsset;
}

public Integer getQuotePrecision() {
return quotePrecision;
}
public Integer getQuotePrecision() {
return quotePrecision;
}

public void setQuotePrecision(Integer quotePrecision) {
this.quotePrecision = quotePrecision;
}
public void setQuotePrecision(Integer quotePrecision) {
this.quotePrecision = quotePrecision;
}

public List<OrderType> getOrderTypes() {
return orderTypes;
}
public List<OrderType> getOrderTypes() {
return orderTypes;
}

public void setOrderTypes(List<OrderType> orderTypes) {
this.orderTypes = orderTypes;
}
public void setOrderTypes(List<OrderType> orderTypes) {
this.orderTypes = orderTypes;
}

public boolean isIcebergAllowed() {
return icebergAllowed;
}
public boolean isIcebergAllowed() {
return icebergAllowed;
}

public void setIcebergAllowed(boolean icebergAllowed) {
this.icebergAllowed = icebergAllowed;
}
public void setIcebergAllowed(boolean icebergAllowed) {
this.icebergAllowed = icebergAllowed;
}

public boolean isOcoAllowed() {
return ocoAllowed;
}
public boolean isOcoAllowed() {
return ocoAllowed;
}

public void setOcoAllowed(boolean ocoAllowed) {
this.ocoAllowed = ocoAllowed;
}
public void setOcoAllowed(boolean ocoAllowed) {
this.ocoAllowed = ocoAllowed;
}

public boolean isQuoteOrderQtyMarketAllowed() {
return quoteOrderQtyMarketAllowed;
}
public boolean isQuoteOrderQtyMarketAllowed() {
return quoteOrderQtyMarketAllowed;
}

public void setQuoteOrderQtyMarketAllowed(boolean quoteOrderQtyMarketAllowed) {
this.quoteOrderQtyMarketAllowed = quoteOrderQtyMarketAllowed;
}
public void setQuoteOrderQtyMarketAllowed(boolean quoteOrderQtyMarketAllowed) {
this.quoteOrderQtyMarketAllowed = quoteOrderQtyMarketAllowed;
}

public boolean isSpotTradingAllowed() {
return isSpotTradingAllowed;
}

public void setIsSpotTradingAllowed(boolean isSpotTradingAllowed) {
this.isSpotTradingAllowed = isSpotTradingAllowed;
}

public boolean isMarginTradingAllowed() {
return isMarginTradingAllowed;
}

public void setIsMarginTradingAllowed(boolean isMarginTradingAllowed) {
this.isMarginTradingAllowed = isMarginTradingAllowed;
}

public List<SymbolFilter> getFilters() {
return filters;
}

public void setFilters(List<SymbolFilter> filters) {
this.filters = filters;
}

/**
* @param filterType filter type to filter for.
* @return symbol filter information for the provided filter type.
*/
public SymbolFilter getSymbolFilter(FilterType filterType) {
return filters.stream()
.filter(symbolFilter -> symbolFilter.getFilterType() == filterType)
.findFirst()
.get();
}

@Override
public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
.append("symbol", symbol)
.append("status", status)
.append("baseAsset", baseAsset)
.append("baseAssetPrecision", baseAssetPrecision)
.append("quoteAsset", quoteAsset)
.append("quotePrecision", quotePrecision)
.append("orderTypes", orderTypes)
.append("icebergAllowed", icebergAllowed)
.append("filters", filters)
.toString();
}
public boolean isSpotTradingAllowed() {
return isSpotTradingAllowed;
}

public void setIsSpotTradingAllowed(boolean isSpotTradingAllowed) {
this.isSpotTradingAllowed = isSpotTradingAllowed;
}

public boolean isMarginTradingAllowed() {
return isMarginTradingAllowed;
}

public void setIsMarginTradingAllowed(boolean isMarginTradingAllowed) {
this.isMarginTradingAllowed = isMarginTradingAllowed;
}

public List<SymbolFilter> getFilters() {
return filtersList;
}

public void setFilters(List<SymbolFilter> filters) {
filtersList = filters;
filtersMap = new HashMap<>();
for (SymbolFilter filter : filters) {
filtersMap.put(filter.getFilterType(), filter);
}
}

/**
* @param filterType filter type to filter for.
* @return symbol filter information for the provided filter type.
*/
public SymbolFilter getSymbolFilter(FilterType filterType) {
return filtersMap.get(filterType);
}

@Override
public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
.append("symbol", symbol)
.append("status", status)
.append("baseAsset", baseAsset)
.append("baseAssetPrecision", baseAssetPrecision)
.append("quoteAsset", quoteAsset)
.append("quotePrecision", quotePrecision)
.append("orderTypes", orderTypes)
.append("icebergAllowed", icebergAllowed)
.append("filters", filtersList)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ public void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallbac
cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback));
}

@Override
public void cancelOpenOrders(CancelOrderRequest cancelOrderRequest, BinanceApiCallback<List<CancelOrderResponse>> callback) {
binanceApiService.cancelOpenOrders(cancelOrderRequest.getSymbol(),
cancelOrderRequest.getRecvWindow(), cancelOrderRequest.getTimestamp()).enqueue(new BinanceApiCallbackAdapter<>(callback));
}

@Override
public void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback<List<Order>> callback) {
binanceApiService.getOpenOrders(orderRequest.getSymbol(),
Expand Down
Loading