Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge from official #3

Open
wants to merge 128 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
0c9354f
Add reconnect & close logic
big-andy-coates Feb 25, 2018
6f53a88
Merge pull request #83 from big-andy-coates/reconnect
joaopsilva Feb 26, 2018
8571a99
Add support for AllAssets
TobCar Mar 14, 2018
91dd28f
Expose getAllAssets JSON call
TobCar Mar 25, 2018
00cb268
Merge pull request #98 from TobCar/master
joaopsilva Mar 25, 2018
69f56f5
Fixes #103: Add support for fetching all assets.
joaopsilva Mar 26, 2018
97a08b0
Route exceptions via onFailure callback rather than throwing them
nilswx Apr 25, 2018
1c90686
Add support for newOrderRespType (v3 API)
nilswx Apr 29, 2018
7b92e7a
Demonstrate use of newOrderRespType in OrdersExample
nilswx Apr 29, 2018
ce38cb8
Parse both 'id' and 'tradeId' into Trade#id to deal with inconsistent…
nilswx Apr 29, 2018
d7835f5
Add NewOrderResponse#origQty
nilswx Apr 29, 2018
16e94f3
Demonstrate use of newOrderRespType in README.md
nilswx Apr 29, 2018
6067b08
withdrawal status added, conflicts resolved
May 4, 2018
db200f2
Merge pull request #126 from igorustinov/master
joaopsilva May 4, 2018
bf55921
Fix #125: Avoid 301 redirect for asset info API.
joaopsilva May 4, 2018
eb1ff5c
Merge pull request #122 from nilswxa/master
joaopsilva May 4, 2018
ff7db64
Fix #127 Remove meta header.
joaopsilva May 6, 2018
a00fa6e
Merge branch 'master' of github.com:binance-exchange/binance-java-api
joaopsilva May 6, 2018
aebcf15
Cleanup the client/interceptor and errorBody converter mess in Binanc…
nilswx May 15, 2018
bed23c0
Improve web socket creation: use the process-wide shared HTTP client …
nilswx May 15, 2018
95ab6bf
Upgrade Retrofit, which upgrades OkHttp, which now properly honors pi…
nilswx May 15, 2018
a10a0e9
Cannot deserialize value of type `com.binance.api.client.domain.gener…
Jul 19, 2018
25e008e
Merge pull request #156 from jinxxik/master
joaopsilva Jul 19, 2018
84adddb
Add support for ICEBERG_PARTS and MAX_NUM_ALGO_ORDERS filter.
joaopsilva Jul 19, 2018
9dd2477
ignore properties add for avoiding new fields deserialization exception
gungoren Jul 20, 2018
fcee5de
Merge branch 'master' of https://github.com/binance-exchange/binance-…
gungoren Jul 20, 2018
137cfd4
Issue 157: Exception when getting all trades of a symbol
Jul 20, 2018
59bf8ff
Merge pull request #159 from pahgo/master
joaopsilva Jul 20, 2018
505a4a0
Merge pull request #158 from evhar002/master
joaopsilva Jul 20, 2018
bb8a3b6
binance api change 2018-07-18: added param cummulativeQuoteQty to the…
brintal Jul 20, 2018
6b4de68
binance api change 2018-07-18: updated javadoc to reflect the new lim…
brintal Jul 20, 2018
29f603e
Merge pull request #160 from brintal/master
joaopsilva Jul 20, 2018
dff4c70
Merge latest remote changes into this fork to maintain API compatility
nilswx Jul 23, 2018
9a6cd16
fixed market ticker event
Jul 23, 2018
abe4e31
Fix for ORDER_WOULD_TRIGGER_IMMEDIATELY
Aug 20, 2018
fd76377
Merge pull request #170 from Moskitek/master
joaopsilva Aug 23, 2018
f0cf925
multi-channel subscription on single websocket
mironbalcerzak Aug 26, 2018
429c704
Preventing NPE while boxing/unboxing
mironbalcerzak Sep 2, 2018
8055ac1
Preventing NPE while boxing/unboxing - JUnit fix
mironbalcerzak Sep 2, 2018
4363070
Add support for cancel order response.
joaopsilva Sep 12, 2018
8f2bff1
Merge pull request #133 from nilswxa/master
joaopsilva Sep 13, 2018
15489f0
Merge branch 'master' into master
joaopsilva Sep 13, 2018
e31ad64
Merge pull request #163 from Krasks/master
joaopsilva Sep 13, 2018
2da9453
Make fills toString null-safe.
joaopsilva Sep 13, 2018
e7995c0
Add unit tests for NewOrderResponse.
joaopsilva Sep 13, 2018
7a1fc4f
Merge pull request #178 from mironbalcerzak/master
joaopsilva Sep 13, 2018
d39139a
configure custom dispatcher for sharedClient to allow for more parall…
brintal Nov 14, 2018
d74588f
Merge pull request #190 from brintal/master
joaopsilva Dec 3, 2018
d6801c2
adds new filter type values
igorustinov Dec 4, 2018
0a5624b
Merge pull request #194 from igorustinov/pr_new_filtertypes
joaopsilva Dec 4, 2018
7c2a4f4
Add bid price and quantity to AllMarketTickersEvent
Gtofig Jan 12, 2019
1d0eef8
Merge pull request #198 from Gtofig/AllMarketTickersEventBidPricePatch
joaopsilva Jan 14, 2019
dd121ac
Cache ObjectMapper.
joaopsilva Mar 10, 2019
96bbbd1
Use ObjectReader instance for processing JSON.
joaopsilva Mar 10, 2019
5c4451c
add status and executedQty to CancelOrderResponse
mdvx Mar 31, 2019
0d47038
Merge branch 'master' of github.com:binance-exchange/binance-java-api
mdvx Mar 31, 2019
e038355
Merge pull request #207 from mdvx/master
joaopsilva May 21, 2019
22df744
Add license to POM for license-maven-plugin compatibility
benalexau Jun 14, 2019
54bc694
Add Cummulative Quote Quantity
putraxor Aug 12, 2019
25a23ce
Fixed parsing of UserDataUpdateEvents with regard to the new 'outboun…
mcourteaux Aug 16, 2019
9aabc01
Merge pull request #224 from mcourteaux/fix-outboundAccountPosition
joaopsilva Aug 17, 2019
a15902a
Adjusted recvWindow to 60000.
joaopsilva Aug 17, 2019
84752f1
Merge pull request #220 from putraxor/patch-1
joaopsilva Aug 17, 2019
9e6cfca
Merge pull request #213 from benalexau/master
joaopsilva Aug 17, 2019
787d106
Add TotalAccountBalanceExample
puzatin Dec 19, 2019
e97c006
add turkish lira (TRY)
puzatin Dec 20, 2019
64d121b
add comments
puzatin Dec 20, 2019
4c3e521
removing meaningless code from a private constructor
puzatin Dec 21, 2019
8aebad5
Merge pull request #246 from puzatin/TotalAccountBalanceExample
joaopsilva Dec 21, 2019
3a8dbff
Allow the base domain to be customized so that binance.us can be used…
davemx Feb 27, 2020
720dabf
Cleaned out an unused testing variable.
davemx Feb 27, 2020
ab6bef0
replace symbol `ç` to `c`
Mar 15, 2020
877d2ca
updated model according to the latest Binance api spec, custom except…
xnetz Apr 3, 2020
956cb15
Merge pull request #257 from petrovma92/very_little_fix_in_comments
joaopsilva Apr 7, 2020
7ff4dbf
Merge pull request #253 from davemx/master
joaopsilva Apr 7, 2020
120aff0
Merge pull request #261 from xnetz/master
joaopsilva Apr 7, 2020
108b877
Clone
truonghatsts Apr 30, 2020
0992dae
Merge branch 'master' into margin-master
truonghatsts Apr 30, 2020
f3e35be
Updated constants and services for margin endpoints
truonghatsts Apr 30, 2020
229060c
Fixed issue with repay
truonghatsts May 1, 2020
6b1a42f
Added endpoint to get max borrowable
truonghatsts May 1, 2020
2b6eaf1
Add WebSocket BookTickerEvent
jomires May 2, 2020
53d81ca
Add Method
yaniferhaoui Jul 31, 2020
c0867fb
add MAX_POSITION in FilterType
yaniferhaoui Sep 3, 2020
8dea186
Add filter MAX_POSITIION
Sep 3, 2020
a7189e2
Binance Liquid Swap endpoints
truonghatsts Sep 27, 2020
8524e77
Fixed issue with status value
truonghatsts Sep 27, 2020
c9ff0d9
no message
truonghatsts Oct 3, 2020
c916c2c
Merge pull request #285 from truonghatsts/features/bswap
joaopsilva Oct 4, 2020
8d38e8e
Merge pull request #264 from jmresendiz/feat/onBookTickerEvent
joaopsilva Oct 4, 2020
dee5567
Merge branch 'master' of https://github.com/binance-exchange/binance-…
yaniferhaoui Oct 21, 2020
a3c0625
Add ws allBookTickersEvent and tickerEvent
eugenpodaru Nov 12, 2020
26638f2
Fix onAllBookTickersEvent
eugenpodaru Nov 12, 2020
22dc5e5
Add side-effect type to the margin new order
eugenpodaru Nov 14, 2020
86b16b8
Add side-effect type to the margin new order
eugenpodaru Nov 14, 2020
81a9be7
Merge pull request #291 from eugenpodaru/feature/add-side-effect-to-m…
joaopsilva Nov 16, 2020
60eebc2
Merge pull request #290 from eugenpodaru/master
joaopsilva Nov 16, 2020
2c70077
Merge pull request #1 from binance-exchange/master
yaniferhaoui Jan 9, 2021
20f58b5
Add GET getSubAccountTransfers request
yaniferhaoui Jan 9, 2021
e3ad8ef
fix UnrecognizedPropertyException for loan/repay/transfer endpoints
SanekTNT Jan 15, 2021
2ae2a3b
Add SymbolInfo attributs
yaniferhaoui Feb 24, 2021
b8b9f6f
Add SymbolInfo attributs
yaniferhaoui Feb 24, 2021
531ab8f
Merge pull request #308 from SanekTNT/fix-unrecognized-property-execp…
joaopsilva Feb 28, 2021
7781ee0
Merge pull request #305 from yaniferhaoui/master
joaopsilva Feb 28, 2021
ef91aab
Add stopLimitPrice
yaniferhaoui Mar 21, 2021
3d47c86
Add stopLimitPrice
yaniferhaoui Mar 21, 2021
1633433
Implementation of OCO order
yaniferhaoui Mar 25, 2021
825c39f
Implementation of OCO order
yaniferhaoui Mar 25, 2021
32cea2c
Add connectivity to Binance Exchange Spot Test Network endpoints.
Mar 26, 2021
c9d52af
Convert file from UNIX format to DOS for compatibility with master br…
Apr 12, 2021
e37c287
FIxed to FIAT_CURRENCY list
erenmeren Apr 13, 2021
7d0a20b
Implementation of OCO order
yaniferhaoui Apr 22, 2021
d63938b
Implementation of OCO order
yaniferhaoui Apr 24, 2021
9337694
Update README.md
aldov500 May 3, 2021
23a003c
Merge pull request #362 from aldov500/patch-1
joaopsilva Jun 10, 2021
daeab32
Merge pull request #349 from erenmeren/patch-1
joaopsilva Jun 10, 2021
239f15c
Merge pull request #347 from georgesoler/master
joaopsilva Jun 10, 2021
97a37b4
Merge pull request #341 from yaniferhaoui/master
joaopsilva Jun 10, 2021
c8d9e7d
latest
Jun 11, 2021
d3262e1
attempting to improve testnet streaming
Jun 19, 2021
dc6b4bc
Merge pull request #380 from microjasa/master
joaopsilva Jun 19, 2021
00f6d72
Fix deserialization issue for RateLimitType
oleksiilogvin Jun 24, 2021
bedf20b
Merge pull request #384 from oleksiilogvin/master
joaopsilva Jun 24, 2021
49eef34
Fix non-existent 'outboundAccountInfo' event. Replaced by 'outboundAc…
mcourteaux Jun 24, 2021
6403409
Merge pull request #386 from mcourteaux/fix_user_data_update_event
joaopsilva Jun 24, 2021
8aa6fb5
Fix examples now too. Deprecated the usage of the old naming. The enu…
mcourteaux Jun 25, 2021
08d52a4
Merge pull request #388 from mcourteaux/fix_user_data_update_event
joaopsilva Jun 25, 2021
2c9d284
update readme
2pd Oct 27, 2023
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
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
489 changes: 3 additions & 486 deletions README.md
100644 → 100755

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@

<groupId>com.binance.api</groupId>
<artifactId>binance-api-client</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<licenses>
<license>
<name>The MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>

<properties>
<com.squareup.retrofit2.version>2.3.0</com.squareup.retrofit2.version>
<com.squareup.retrofit2.version>2.4.0</com.squareup.retrofit2.version>
</properties>

<dependencies>
Expand All @@ -26,17 +32,17 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
<version>1.15</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -54,4 +60,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package com.binance.api.client;

import com.binance.api.client.domain.TransferType;
import com.binance.api.client.domain.account.*;
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.event.ListenKey;

import java.util.List;

/**
* Binance API façade, supporting asynchronous/non-blocking access Binance's Margin REST API.
*/
public interface BinanceApiAsyncMarginRestClient {

// Account endpoints

/**
* Get current margin account information (async).
*/
void getAccount(Long recvWindow, Long timestamp, BinanceApiCallback<MarginAccount> callback);

/**
* Get current margin account information using default parameters (async).
*/
void getAccount(BinanceApiCallback<MarginAccount> callback);

/**
* Get all open orders on margin account for a symbol (async).
*
* @param orderRequest order request parameters
* @param callback the callback that handles the response
*/
void getOpenOrders(OrderRequest orderRequest, BinanceApiCallback<List<Order>> callback);

/**
* Send in a new margin order (async).
*
* @param order the new order to submit.
* @return a response containing details about the newly placed order.
*/
void newOrder(MarginNewOrder order, BinanceApiCallback<MarginNewOrderResponse> callback);

/**
* Cancel an active margin order (async).
*
* @param cancelOrderRequest order status request parameters
*/
void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback<CancelOrderResponse> callback);

/**
* Check margin order's status (async).
*
* @param orderStatusRequest order status request options/filters
* @return an order
*/
void getOrderStatus(OrderStatusRequest orderStatusRequest, BinanceApiCallback<Order> callback);

/**
* Get margin trades for a specific symbol (async).
*
* @param symbol symbol to get trades from
* @return a list of trades
*/
void getMyTrades(String symbol, BinanceApiCallback<List<Trade>> callback);

// User stream endpoints

/**
* Start a new user data stream (async).
*
* @return a listen key that can be used with data streams
*/
void startUserDataStream(BinanceApiCallback<ListenKey> callback);

/**
* PING a user data stream to prevent a time out (async).
*
* @param listenKey listen key that identifies a data stream
*/
void keepAliveUserDataStream(String listenKey, BinanceApiCallback<Void> callback);

/**
* Execute transfer between spot account and margin account
* @param asset asset to repay
* @param amount amount to repay
* @return transaction id
*/
void transfer(String asset, String amount, TransferType type, BinanceApiCallback<MarginTransaction> callback);

/**
* Apply for a loan
* @param asset asset to repay
* @param amount amount to repay
* @return transaction id
*/
void borrow(String asset, String amount, BinanceApiCallback<MarginTransaction> callback);

/**
* Repay loan for margin account
* @param asset asset to repay
* @param amount amount to repay
* @return transaction id
*/
void repay(String asset, String amount, BinanceApiCallback<MarginTransaction> callback);

}
27 changes: 18 additions & 9 deletions src/main/java/com/binance/api/client/BinanceApiAsyncRestClient.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
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.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.event.ListenKey;
import com.binance.api.client.domain.general.Asset;
import com.binance.api.client.domain.general.ExchangeInfo;
import com.binance.api.client.domain.general.ServerTime;
import com.binance.api.client.domain.market.AggTrade;
Expand All @@ -27,7 +30,7 @@
import java.util.List;

/**
* Binance API façade, supporting asynchronous/non-blocking access Binance's REST API.
* Binance API facade, supporting asynchronous/non-blocking access Binance's REST API.
*/
public interface BinanceApiAsyncRestClient {

Expand All @@ -48,6 +51,11 @@ public interface BinanceApiAsyncRestClient {
*/
void getExchangeInfo(BinanceApiCallback<ExchangeInfo> callback);

/**
* ALL supported assets and whether or not they can be withdrawn.
*/
void getAllAssets(BinanceApiCallback<List<Asset>> callback);

// Market Data endpoints

/**
Expand All @@ -63,7 +71,7 @@ public interface BinanceApiAsyncRestClient {
* Get recent trades (up to last 500). Weight: 1
*
* @param symbol ticker symbol (e.g. ETHBTC)
* @param limit of last trades (Default 500; max 500.)
* @param limit of last trades (Default 500; max 1000.)
* @param callback the callback that handles the response
*/
void getTrades(String symbol, Integer limit, BinanceApiCallback<List<TradeHistoryItem>> callback);
Expand All @@ -72,7 +80,7 @@ public interface BinanceApiAsyncRestClient {
* Get older trades. Weight: 5
*
* @param symbol ticker symbol (e.g. ETHBTC)
* @param limit of last trades (Default 500; max 500.)
* @param limit of last trades (Default 500; max 1000.)
* @param fromId TradeId to fetch from. Default gets most recent trades.
* @param callback the callback that handles the response
*/
Expand All @@ -87,7 +95,7 @@ public interface BinanceApiAsyncRestClient {
*
* @param symbol symbol to aggregate (mandatory)
* @param fromId ID to get aggregate trades from INCLUSIVE (optional)
* @param limit Default 500; max 500 (optional)
* @param limit Default 500; max 1000 (optional)
* @param startTime Timestamp in ms to get aggregate trades from INCLUSIVE (optional).
* @param endTime Timestamp in ms to get aggregate trades until INCLUSIVE (optional).
* @param callback the callback that handles the response
Expand All @@ -107,7 +115,7 @@ public interface BinanceApiAsyncRestClient {
*
* @param symbol symbol to aggregate (mandatory)
* @param interval candlestick interval (mandatory)
* @param limit Default 500; max 500 (optional)
* @param limit Default 500; max 1000 (optional)
* @param startTime Timestamp in ms to get candlestick bars from INCLUSIVE (optional).
* @param endTime Timestamp in ms to get candlestick bars until INCLUSIVE (optional).
* @param callback the callback that handles the response containing a candlestick bar for the given symbol and interval
Expand Down Expand Up @@ -190,7 +198,7 @@ public interface BinanceApiAsyncRestClient {
* @param cancelOrderRequest order status request parameters
* @param callback the callback that handles the response
*/
void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback<Void> callback);
void cancelOrder(CancelOrderRequest cancelOrderRequest, BinanceApiCallback<CancelOrderResponse> callback);

/**
* Get all open orders on a symbol (asynchronous).
Expand Down Expand Up @@ -222,7 +230,7 @@ public interface BinanceApiAsyncRestClient {
* Get trades for a specific account and symbol.
*
* @param symbol symbol to get trades from
* @param limit default 500; max 500
* @param limit default 500; max 1000
* @param fromId TradeId to fetch from. Default gets most recent trades.
* @param callback the callback that handles the response with a list of trades
*/
Expand All @@ -232,7 +240,7 @@ public interface BinanceApiAsyncRestClient {
* Get trades for a specific account and symbol.
*
* @param symbol symbol to get trades from
* @param limit default 500; max 500
* @param limit default 500; max 1000
* @param callback the callback that handles the response with a list of trades
*/
void getMyTrades(String symbol, Integer limit, BinanceApiCallback<List<Trade>> callback);
Expand All @@ -254,8 +262,9 @@ public interface BinanceApiAsyncRestClient {
* @param address address to withdraw to
* @param amount amount to withdraw
* @param name description/alias of the address
* @param addressTag Secondary address identifier for coins like XRP,XMR etc.
*/
void withdraw(String asset, String address, String amount, String name, BinanceApiCallback<Void> callback);
void withdraw(String asset, String address, String amount, String name, String addressTag, BinanceApiCallback<WithdrawResult> callback);

/**
* Fetch account deposit history.
Expand Down
46 changes: 23 additions & 23 deletions src/main/java/com/binance/api/client/BinanceApiCallback.java
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.binance.api.client;

/**
* BinanceApiCallback is a functional interface used together with the BinanceApiAsyncClient to provide a non-blocking REST client.
*
* @param <T> the return type from the callback
*/
@FunctionalInterface
public interface BinanceApiCallback<T> {

/**
* Called whenever a response comes back from the Binance API.
*
* @param response the expected response object
*/
void onResponse(T response);

/**
* Called whenever an error occurs.
*
* @param cause the cause of the failure
*/
default void onFailure(Throwable cause) {}
package com.binance.api.client;
/**
* BinanceApiCallback is a functional interface used together with the BinanceApiAsyncClient to provide a non-blocking REST client.
*
* @param <T> the return type from the callback
*/
@FunctionalInterface
public interface BinanceApiCallback<T> {
/**
* Called whenever a response comes back from the Binance API.
*
* @param response the expected response object
*/
void onResponse(T response);
/**
* Called whenever an error occurs.
*
* @param cause the cause of the failure
*/
default void onFailure(Throwable cause) {}
}
Loading