use of org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair 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.service.trade.params.CancelOrderByCurrencyPair in project XChange by knowm.
the class OkexTradeService method cancelOrder.
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
if (!(orderParams instanceof CancelOrderByIdParams) || !(orderParams instanceof CancelOrderByCurrencyPair)) {
throw new UnsupportedOperationException("Cancelling an order is only available for a single market and a single id.");
}
String id = ((CancelOrderByIdParams) orderParams).getOrderId();
String instrumentId = OkexAdaptersV3.toSpotInstrument(((CancelOrderByCurrencyPair) orderParams).getCurrencyPair());
OrderCancellationRequest req = OrderCancellationRequest.builder().instrumentId(instrumentId).build();
OrderCancellationResponse o = spotCancelOrder(id, req);
return true;
}
use of org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair in project XChange by knowm.
the class BithumbTradeService method cancelOrder.
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
try {
if (!(orderParams instanceof CancelOrderByIdParams && orderParams instanceof CancelOrderByCurrencyPair)) {
throw new NotYetImplementedForExchangeException("Only CancelOrderByPairAndIdParams || (CancelOrderByIdParams && CancelOrderByCurrencyPair) supported");
}
String orderId = ((CancelOrderByIdParams) orderParams).getOrderId();
CurrencyPair pair = ((CancelOrderByCurrencyPair) orderParams).getCurrencyPair();
return cancelBithumbOrder(orderId, pair);
} catch (BithumbException e) {
throw BithumbErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair in project XChange by knowm.
the class TradeServiceIntegration method changeOrder.
@Test
public void changeOrder() throws IOException {
BigDecimal modifyPrice = new BigDecimal(302);
BigDecimal endPrice = new BigDecimal(304);
String orderId = tradeService.placeLimitOrder(order);
LimitOrder order2 = new LimitOrder(order.getType(), order.getOriginalAmount(), order.getCurrencyPair(), orderId, order.getTimestamp(), modifyPrice);
String orderId2 = tradeService.changeOrder(order2);
LimitOrder order3 = new LimitOrder(order.getType(), order.getOriginalAmount(), order.getCurrencyPair(), orderId2, order.getTimestamp(), endPrice);
String orderId3 = tradeService.changeOrder(order3);
List<Order> orders = (List<Order>) tradeService.getOrder(orderId, orderId2, orderId3);
Assert.assertEquals("Order response must contain 1 order", 3, orders.size());
Assert.assertSame("Order 1 must be canceled", orders.get(0).getStatus(), Order.OrderStatus.CANCELED);
Assert.assertSame("Order 2 must be canceled", orders.get(1).getStatus(), Order.OrderStatus.CANCELED);
Assert.assertSame("Order 3 must be placed", orders.get(2).getStatus(), Order.OrderStatus.PENDING_NEW);
Assert.assertEquals("Order 3 must have `endPrice` price", 0, ((LimitOrder) orders.get(2)).getLimitPrice().compareTo(endPrice));
tradeService.cancelOrder((CancelOrderByCurrencyPair) () -> new CurrencyPair("BCH/USD"));
}
use of org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair in project XChange by knowm.
the class CoinsuperTradeService method cancelOrder.
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
if (!(orderParams instanceof CancelOrderByCurrencyPair) && !(orderParams instanceof CancelOrderByIdParams)) {
throw new ExchangeException("You need to provide the currency pair and the order id to cancel an order.");
}
// CancelOrderByCurrencyPair currencyPair = (CancelOrderByCurrencyPair) orderParams;
CancelOrderByIdParams orderIdParam = (CancelOrderByIdParams) orderParams;
// String orderId =
// super.cancelOrder(
// CoinsuperAdapters.toMarket(currencyPair.getCurrencyPair()),
// orderIdParam.getOrderId());
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("orderNo", orderIdParam.getOrderId());
return cancelCoinsuperOrder(parameters);
}
Aggregations