use of org.knowm.xchange.binance.dto.BinanceException in project XChange by knowm.
the class BinanceTradeService method cancelOrder.
@Override
public boolean cancelOrder(CancelOrderParams params) throws IOException {
try {
if (!(params instanceof CancelOrderByCurrencyPair) && !(params instanceof CancelOrderByIdParams)) {
throw new ExchangeException("You need to provide the currency pair and the order id to cancel an order.");
}
CancelOrderByCurrencyPair paramCurrencyPair = (CancelOrderByCurrencyPair) params;
CancelOrderByIdParams paramId = (CancelOrderByIdParams) params;
super.cancelOrder(paramCurrencyPair.getCurrencyPair(), BinanceAdapters.id(paramId.getOrderId()), null, null);
return true;
} catch (BinanceException e) {
throw BinanceErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.binance.dto.BinanceException in project XChange by knowm.
the class BinanceTradeService method getOrder.
@Override
public Collection<Order> getOrder(OrderQueryParams... params) throws IOException {
try {
Collection<Order> orders = new ArrayList<>();
for (OrderQueryParams param : params) {
if (!(param instanceof OrderQueryParamCurrencyPair)) {
throw new ExchangeException("Parameters must be an instance of OrderQueryParamCurrencyPair");
}
OrderQueryParamCurrencyPair orderQueryParamCurrencyPair = (OrderQueryParamCurrencyPair) param;
if (orderQueryParamCurrencyPair.getCurrencyPair() == null || orderQueryParamCurrencyPair.getOrderId() == null) {
throw new ExchangeException("You need to provide the currency pair and the order id to query an order.");
}
orders.add(BinanceAdapters.adaptOrder(super.orderStatus(orderQueryParamCurrencyPair.getCurrencyPair(), BinanceAdapters.id(orderQueryParamCurrencyPair.getOrderId()), null)));
}
return orders;
} catch (BinanceException e) {
throw BinanceErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.binance.dto.BinanceException in project XChange by knowm.
the class BinanceTradeService method placeTestOrder.
public void placeTestOrder(OrderType type, Order order, BigDecimal limitPrice, BigDecimal stopPrice) throws IOException {
try {
TimeInForce tif = timeInForceFromOrder(order).orElse(null);
Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow");
testNewOrder(order.getCurrencyPair(), BinanceAdapters.convert(order.getType()), type, tif, order.getOriginalAmount(), limitPrice, getClientOrderId(order), stopPrice, null);
} catch (BinanceException e) {
throw BinanceErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.binance.dto.BinanceException in project XChange by knowm.
the class BinanceErrorAdapterTest method testBinanceExceptionWithCode1013MsgLotSize.
@Test
public void testBinanceExceptionWithCode1013MsgLotSize() {
final ExchangeException adaptedException = BinanceErrorAdapter.adapt(new BinanceException(-1013, "LOT_SIZE"));
assertThat(adaptedException).isInstanceOf(OrderNotValidException.class);
}
use of org.knowm.xchange.binance.dto.BinanceException in project XChange by knowm.
the class BinanceErrorAdapterTest method testBinanceExceptionWithCode1013MsgMinNotional.
@Test
public void testBinanceExceptionWithCode1013MsgMinNotional() {
final ExchangeException adaptedException = BinanceErrorAdapter.adapt(new BinanceException(-1013, "MIN_NOTIONAL"));
assertThat(adaptedException).isInstanceOf(OrderAmountUnderMinimumException.class);
}
Aggregations