Skip to main content
Version: 2.x

Margin

 License: MIT 

Installation

pom.xml
<dependency>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<version>{{version}}</version>
</dependency>

Client instantiation

MarginClient client = new MarginClient(key, secret);

Features

Execute transfer between spot account and cross margin account

try{
Transaction res = client.transfer(new TransferParams(asset, amount, TransferType.MAIN_TO_MARGIN)).sync();
}catch(ApiException e){
//...
}

Apply for a loan

try{
Transaction res = client.borrow(new BorrowParams(asset, amount, symbol, isIsolated)).sync();
}catch(ApiException e){
//...
}

Repay loan

try{
Transaction res = client.repay(new RepayParams(asset, amount, symbol, isIsolated)).sync();
}catch(ApiException e){
//...
}

Get info about an asset

try{
Asset res = client.getAsset(new AssetParams(asset)).sync();
}catch(ApiException e){
//...
}

Get info about all assets

try{
List<Asset> res = client.getAllAssets().sync();
}catch(ApiException e){
//...
}

Get info about a cross margin pair

try{
CrossSymbol res = client.getCrossMarginPair(new PairParams(symbol)).sync();
}catch(ApiException e){
//...
}

Gets the price Index of a symbol

try{
PriceIndex res = client.getPriceIndex(new PriceIndexParams(symbol)).sync();
}catch(ApiException e){
//...
}

Send a Market order.

try{
NewOrderRecord res = client.newOrder(MarketOrder.buy(symbol, quantity)).sync();
}catch(ApiException e){
//...
}

Send a Market Quote order.

try{
NewOrderRecord res = client.newOrder(MarketQuoteOrder.buy(symbol, quoteAssetQty)).sync();
}catch(ApiException e){
//...
}

Send a Limit order.

try{
NewOrderRecord res = client.newOrder(LimitOrder.buy(symbol, quantity, price, timeInForce)).sync();
}catch(ApiException e){
//...
}

Send a Limit Maker order.

try{
NewOrderRecord res = client.newOrder(LimitMakerOrder.buy(symbol, quantity, price)).sync();
}catch(ApiException e){
//...
}

Send a Stop Loss order.

try{
NewOrderRecord res = client.newOrder(StopLossOrder.buy(symbol, quantity, stopPrice)).sync();
}catch(ApiException e){
//...
}

Send a Stop Loss Limit order.

try{
NewOrderRecord res = client.newOrder(StopLossOrder.buy(symbol, quantity, price, stopPrice, timeInForce)).sync();
}catch(ApiException e){
//...
}

Send a Take Profit order.

try{
NewOrderRecord res = client.newOrder(TakeProfitOrder.buy(symbol, quantity, stopPrice)).sync();
}catch(ApiException e){
//...
}

Send a Take Profit Limit order.

try{
NewOrderRecord res = client.newOrder(TakeProfitLimitOrder.buy(symbol, quantity, price, stopPrice, timeInForce)).sync();
}catch(ApiException e){
//...
}

Cancel an active order

try{
CancelOrderResponse res = client.cancelOrder(new CancelOrderParams(symbol, orderId)).sync();
}catch(ApiException e){
//...
}

Cancel open orders

try{
List<CancelOrderResponse> res = client.cancelOpenOrders(new CancelOpenOrdersParams(symbol)).sync();
}catch(ApiException e){
//...
}

Get cross margin transfer history

try{
TransferRecords res = client.getTransferHistory().sync();
}catch(ApiException e){
//...
}

Get loan Record

try{
LoanRecord res = client.getLoanRecord(new TransactionHistoryParams(asset)).sync();
}catch(ApiException e){
//...
}

Get repay Record

try{
RepayRecords res = client.getRepayRecord(new TransactionHistoryParams(asset)).sync();
}catch(ApiException e){
//...
}

Get interest history

try{
InterestHistory res = client.getInterestHistory(new TransactionHistoryParams(asset)).sync();
}catch(ApiException e){
//...
}

Get force liquidation record

try{
ForceLiquidationRecords res = client.getForceLiquidationRecord(new ForceLiquidationRecordParams(isolatedSymbol)).sync();
}catch(ApiException e){
//...
}
note

Response in descending order.

Get Margin account details

try{
Account res = client.getAccount().sync();
}catch(ApiException e){
//...
}

Get order status.

try{
OrderInfo res = client.getOrder(new OrderParams(symbol, isIsolated)).sync();
}catch(ApiException e){
//...
}

Get open orders

try{
List<OrderInfo> res = client.getOpenOrders().sync();
}catch(ApiException e){
//...
}

Get all orders

try{
List<OrderInfo> res = client.getAllOrders(new AllOrdersParams(symbol, orderId, isIsolated)).sync();
}catch(ApiException e){
//...
}

Send OCO order

try{
NewOCOOrderRecord res = client.newOCO(new NewOCOOrderParams(symbol, OrderSide.BUY, quantity, price, stopPrice, stopPrice, TimeInForce.GTC)).sync();
}catch(ApiException e){
//...
}

Cancel OCO order

try{
NewOCOOrderRecord res = client.cancelOCO(new CancelOCOParams(symbol, isIsolated)).sync();
}catch(ApiException e){
//...
}

Get OCO order

try{
OCOOrderRecord res = client.getOCO(new GetOCOParams(symbol, isIsolated)).sync();
}catch(ApiException e){
//...
}

Get all OCO

try{
List<OCOOrderRecord> res = client.getAllOCO(new GetAllOCOParams(symbol, isIsolated)).sync();
}catch(ApiException e){
//...
}

get open OCO

try{
List<OCOOrderRecord> res = client.getOpenOCO().sync();
}catch(ApiException e){
//...
}

Get trades

try{
List<Trade> res = client.getTrades(new TradeParams(symbol, isIsolated)).sync();
}catch(ApiException e){
//...
}

Query Max Borrow

try{
MaxBorrowable res = client.getMaxBorrowable(new MaxBorrowable(amount, borrowLimit)).sync();
}catch(ApiException e){
//...
}

Query Max Transfer-Out Amount

try{
MaxTransferable res = client.getMaxTransferable(new MaxTransferableParams(asset, isolatedSymbol)).sync();
}catch(ApiException e){
//...
}

Make an isolated margin account transfer

try{
IsolatedTransferRecords res = client.newIsolatedTransfer(new NewIsolatedTransferParams(asset, symbol, amount, transFrom, transTo)).sync();
}catch(ApiException e){
//...
}

Get isolated margin transfer history

try{
IsolatedTransferRecords res = client.getIsolatedTransferHistory(new IsolatedTransferHistoryParams(symbol)).sync();
}catch(ApiException e){
//...
}

Query isolated margin account info

try{
IsolatedAccount res = client.getIsolatedAccount().sync();
}catch(ApiException e){
//...
}

Enable isolated margin account for a specific symbol

try{
ToogleAccountResponse res = client.enableIsolatedAccount(new ToogleAccountParams(symbol)).sync();
}catch(ApiException e){
//...
}

Disable isolated margin account for a specific symbol

try{
ToogleAccountResponse res = client.disableIsolatedAccount(new ToogleAccountParams(symbol)).sync();
}catch(ApiException e){
//...
}

Query enabled isolated margin account limit

try{
IsolatedAccountLimit res = client.getEnabledIsolatedAccountLimit().sync();
}catch(ApiException e){
//...
}

Get info about an isolated symbol

try{
IsolatedSymbol res = client.getIsolatedSymbol(new PairParams(symbol)).sync();
}catch(ApiException e){
//...
}

Get info about all the isolated symbols.

try{
List<IsolatedSymbol> res = client.getAllIsolatedSymbols().sync();
}catch(ApiException e){
//...
}

Toggle BNB Burn On Spot Trade And Margin Interest

try{
BNBBurnStatus res = client.toggleBNBBurnOnSpotTradeAndMarginInterest(new ToggleBurnParams(spotBNBBurn, interestBNBBurn)).sync();
}catch(ApiException e){
//...
}

Get BNB Burn Status

try{
BNBBurnStatus res = client.getBNBBurnStatus().sync();
}catch(ApiException e){
//...
}

Query Margin Interest Rate History

try{
List<InterestRate> res = client.getInterestRateHistory(new InterestRateHistoryParams(asset)).sync();
}catch(ApiException e){
//...
}

Get cross margin fee data

try{
List<CrossFee> res = client.getMarginFeeData().sync();
}catch(ApiException e){
//...
}

Get isolated margin fee data

try{
List<IsolatedFee> res = client.getIsolatedFeeData().sync();
}catch(ApiException e){
//...
}

Get isolated margin tier data

try{
List<IsolatedTierData> res = client.getIsolatedMarginTierData(new IsolatedTierDataParams(symbol)).sync();
}catch(ApiException e){
//...
}

Get order rate limit

try{
List<OrderRateLimit> res = client.getOrderRateLimit().sync();
}catch(ApiException e){
//...
}

Get dust log (conversions into BNB of dust assets)

try{
DustLogRecord res = client.getDustLog().sync();
}catch(ApiException e){
//...
}