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

Added TRAILING_DELTA into FilterType #426

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
50 changes: 43 additions & 7 deletions src/main/java/com/binance/api/client/BinanceApiRestClient.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
package com.binance.api.client;

import com.binance.api.client.domain.account.*;
import com.binance.api.client.domain.account.request.*;
import com.binance.api.client.domain.general.ExchangeInfo;
import java.util.List;

import com.binance.api.client.domain.account.Account;
import com.binance.api.client.domain.account.DepositAddress;
import com.binance.api.client.domain.account.DepositHistory;
import com.binance.api.client.domain.account.DustConvertableResponse;
import com.binance.api.client.domain.account.DustTransferResponse;
import com.binance.api.client.domain.account.NewOCO;
import com.binance.api.client.domain.account.NewOCOResponse;
import com.binance.api.client.domain.account.NewOrder;
import com.binance.api.client.domain.account.NewOrderResponse;
import com.binance.api.client.domain.account.Order;
import com.binance.api.client.domain.account.OrderList;
import com.binance.api.client.domain.account.SubAccountTransfer;
import com.binance.api.client.domain.account.Trade;
import com.binance.api.client.domain.account.TradeHistoryItem;
import com.binance.api.client.domain.account.WithdrawHistory;
import com.binance.api.client.domain.account.WithdrawResult;
import com.binance.api.client.domain.account.request.AllOrderListRequest;
import com.binance.api.client.domain.account.request.AllOrdersRequest;
import com.binance.api.client.domain.account.request.CancelOrderListRequest;
import com.binance.api.client.domain.account.request.CancelOrderListResponse;
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.OrderListStatusRequest;
import com.binance.api.client.domain.account.request.OrderRequest;
import com.binance.api.client.domain.account.request.OrderStatusRequest;
import com.binance.api.client.domain.general.Asset;
import com.binance.api.client.domain.general.ExchangeInfo;
import com.binance.api.client.domain.market.AggTrade;
import com.binance.api.client.domain.market.BookTicker;
import com.binance.api.client.domain.market.Candlestick;
Expand All @@ -12,8 +37,6 @@
import com.binance.api.client.domain.market.TickerPrice;
import com.binance.api.client.domain.market.TickerStatistics;

import java.util.List;

/**
* Binance API facade, supporting synchronous/blocking access Binance's REST API.
*/
Expand Down Expand Up @@ -173,6 +196,8 @@ public interface BinanceApiRestClient {
*/
CancelOrderResponse cancelOrder(CancelOrderRequest cancelOrderRequest);

List<CancelOrderResponse> cancelAllOpenOrders(OrderRequest order);

/**
* Get all open orders on a symbol.
*
Expand Down Expand Up @@ -239,7 +264,8 @@ public interface BinanceApiRestClient {
* @param fromId TradeId to fetch from. Default gets most recent trades.
* @return a list of trades
*/
List<Trade> getMyTrades(String symbol, Integer limit, Long fromId, Long recvWindow, Long timestamp);
List<Trade> getMyTrades(String symbol, Long orderId, Long startTime, Long endTime, Integer limit, Long fromId,
Long recvWindow, Long timestamp);

/**
* Get trades for a specific account and symbol.
Expand Down Expand Up @@ -277,7 +303,16 @@ public interface BinanceApiRestClient {
* Conver a list of assets to BNB
* @param asset the list of assets to convert
*/
DustTransferResponse dustTranfer(List<String> asset);
DustTransferResponse dustTransfer(List<String> asset);

/**
* Get Assets That Can Be Converted Into BNB.
*
* @param recvWindow
* @param timestamp
* @return
*/
DustConvertableResponse dustConvertable();

/**
* Fetch account deposit history.
Expand Down Expand Up @@ -329,4 +364,5 @@ public interface BinanceApiRestClient {
* @param listenKey listen key that identifies a data stream
*/
void closeUserDataStream(String listenKey);

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.binance.api.client;

import com.binance.api.client.domain.SwapRemoveType;
import com.binance.api.client.domain.account.*;
import retrofit2.Call;
import retrofit2.http.Query;

import java.util.List;

import com.binance.api.client.domain.SwapRemoveType;
import com.binance.api.client.domain.account.Liquidity;
import com.binance.api.client.domain.account.LiquidityOperationRecord;
import com.binance.api.client.domain.account.Pool;
import com.binance.api.client.domain.account.SwapHistory;
import com.binance.api.client.domain.account.SwapQuote;
import com.binance.api.client.domain.account.SwapRecord;

public interface BinanceApiSwapRestClient {

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

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 DustConvertableDetailsResponse {

private String asset;
private String assetFullName;
private String amountFree;
private String toBTC;
private String toBNB;
private String toBNBOffExchange;
private String exchange;

public String getAsset() {
return asset;
}

public void setAsset(String asset) {
this.asset = asset;
}

public String getAssetFullName() {
return assetFullName;
}

public void setAssetFullName(String assetFullName) {
this.assetFullName = assetFullName;
}

public String getAmountFree() {
return amountFree;
}

public void setAmountFree(String amountFree) {
this.amountFree = amountFree;
}

public String getToBTC() {
return toBTC;
}

public void setToBTC(String toBTC) {
this.toBTC = toBTC;
}

public String getToBNB() {
return toBNB;
}

public void setToBNB(String toBNB) {
this.toBNB = toBNB;
}

public String getToBNBOffExchange() {
return toBNBOffExchange;
}

public void setToBNBOffExchange(String toBNBOffExchange) {
this.toBNBOffExchange = toBNBOffExchange;
}

public String getExchange() {
return exchange;
}

public void setExchange(String exchange) {
this.exchange = exchange;
}

@Override
public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("asset", asset)
.append("assetFullName", assetFullName).append("amountFree", amountFree).append("toBTC", toBTC)
.append("toBNB", toBNB).append("toBNBOffExchange", toBNBOffExchange).append("exchange", exchange)
.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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 DustConvertableResponse {

private List<DustConvertableDetailsResponse> details;
private String totalTransferBtc;
private String totalTransferBNB;
private String dribbletPercentage;

@Override
public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE).append("details", details)
.append("totalTransferBtc", totalTransferBtc).append("totalTransferBNB", totalTransferBNB)
.append("dribbletPercentage", dribbletPercentage).toString();
}

public List<DustConvertableDetailsResponse> getDetails() {
return details;
}

public void setDetails(List<DustConvertableDetailsResponse> details) {
this.details = details;
}

public String getTotalTransferBtc() {
return totalTransferBtc;
}

public void setTotalTransferBtc(String totalTransferBtc) {
this.totalTransferBtc = totalTransferBtc;
}

public String getTotalTransferBNB() {
return totalTransferBNB;
}

public void setTotalTransferBNB(String totalTransferBNB) {
this.totalTransferBNB = totalTransferBNB;
}

public String getDribbletPercentage() {
return dribbletPercentage;
}

public void setDribbletPercentage(String dribbletPercentage) {
this.dribbletPercentage = dribbletPercentage;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

/**
* Max Borrow Query Result
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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.OrderType;
import com.binance.api.client.domain.TimeInForce;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
* A trade order to enter or exit a position.
Expand Down Expand Up @@ -267,6 +268,37 @@ public static NewOrder limitSell(String symbol, TimeInForce timeInForce, String
return new NewOrder(symbol, OrderSide.SELL, OrderType.LIMIT, timeInForce, quantity, price);
}

/**
* Places a STOP buy order for the given <code>quantity</code> and
* <code>price</code>.
*
* @return a new order which is pre-configured with STOP as the order type and
* BUY as the order side.
*/
public static NewOrder stopBuy(String symbol, String quantity, String stopPrice, String stopLimitPrice,
TimeInForce timeInForce) {
NewOrder newOrder = new NewOrder(symbol, OrderSide.BUY, OrderType.STOP_LOSS_LIMIT, timeInForce, quantity, null);
newOrder.stopPrice = stopPrice;
newOrder.price = stopLimitPrice;
return newOrder;
}

/**
* Places a STOP sell order for the given <code>quantity</code> and
* <code>price</code>.
*
* @return a new order which is pre-configured with STOP as the order type and
* SELL as the order side.
*/
public static NewOrder stopSell(String symbol, String quantity, String stopPrice, String stopLimitPrice,
TimeInForce timeInForce) {
NewOrder newOrder = new NewOrder(symbol, OrderSide.SELL, OrderType.STOP_LOSS_LIMIT, timeInForce, quantity,
null);
newOrder.stopPrice = stopPrice;
newOrder.price = stopLimitPrice;
return newOrder;
}

@Override
public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/com/binance/api/client/domain/account/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class Order {
*/
private Long orderId;

/**
* Order id.
*/
private Long orderListId;

/**
* Client order id.
*/
Expand Down Expand Up @@ -70,11 +75,6 @@ public class Order {
*/
private String stopPrice;

/**
* Used with stop orders.
*/
private String stopLimitPrice;

/**
* Used with iceberg orders.
*/
Expand Down Expand Up @@ -194,14 +194,6 @@ public void setStopPrice(String stopPrice) {
this.stopPrice = stopPrice;
}

public String getStopLimitPrice() {
return stopLimitPrice;
}

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

public String getIcebergQty() {
return icebergQty;
}
Expand Down Expand Up @@ -255,6 +247,7 @@ public String toString() {
return new ToStringBuilder(this, BinanceApiConstants.TO_STRING_BUILDER_STYLE)
.append("symbol", symbol)
.append("orderId", orderId)
.append("orderListId", orderId)
.append("clientOrderId", clientOrderId)
.append("price", price)
.append("origQty", origQty)
Expand All @@ -264,7 +257,6 @@ public String toString() {
.append("type", type)
.append("side", side)
.append("stopPrice", stopPrice)
.append("stopLimitPrice", stopLimitPrice)
.append("icebergQty", icebergQty)
.append("time", time)
.append("cummulativeQuoteQty", cummulativeQuoteQty)
Expand All @@ -273,4 +265,12 @@ public String toString() {
.append("origQuoteOrderQty", origQuoteOrderQty)
.toString();
}

public Long getOrderListId() {
return orderListId;
}

public void setOrderListId(Long orderListId) {
this.orderListId = orderListId;
}
}
Loading