Skip to main content
Version: 2.x

Spot

 License: MIT 

Installation

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

Client instantiation

SpotClient client = new SpotClient(key, secret);

Testnet client instantiation

TestnetSpotClient client = new TestnetSpotClient(testnetKey, testnetSecret);

Features

Send a Market order.

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

Send a Market Quote order.

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

Send a Limit order.

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

Send a Limit Maker order.

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

Send a Stop Loss order.

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

Send a Stop Loss Limit order.

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

Send a Take Profit order.

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

Send a Take Profit Limit order.

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

Test an order

newOrderTest works like newOrder.

try{
client.newOrderTest(MarketOrder.buy(symbol, quantity)).sync();
}catch(ApiException e){
//...
}
note

buyQuote and sellQuote let you buy the base asset by providing the quote asset amount.

Get open orders

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

Cancel open orders

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

Check an order's status

try{
OrderInfo res = client.getOrderStatus(new OrderStatusParams(symbol, orderId)).sync();
}catch(ApiException e){
//...
}

Cancel an active order

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

Displays the user's current order count usage for all intervals with default request

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

Get current account information

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

Get all orders on a symbol

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

Get trades for a specific account and symbol.

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

Send in an OCO order

try{
OCOResponse res = client.newOCO(NewOCOOrderParams(symbol, side, quantity, price, stopPrice, stopLimitPrice, stopLimitTimeInForce)).sync();
}catch(ApiException e){
//...
}

Cancel an entire order list

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

Retrieves all OCO

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