Search in sources :

Example 1 with CancelOrderByIdParams

use of org.knowm.xchange.service.trade.params.CancelOrderByIdParams in project XChange by knowm.

the class LatokenTradeService method cancelOrder.

@Override
public boolean cancelOrder(CancelOrderParams params) throws IOException {
    if (params instanceof CancelOrderByIdParams == false) {
        throw new ExchangeException("OrderId must be provided to cancel an order.");
    }
    CancelOrderByIdParams paramId = (CancelOrderByIdParams) params;
    String orderId = paramId.getOrderId();
    if (orderId == null) {
        throw new ExchangeException("OrderId must be provided to cancel an order.");
    }
    return cancelOrder(orderId);
}
Also used : CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) ExchangeException(org.knowm.xchange.exceptions.ExchangeException)

Example 2 with CancelOrderByIdParams

use of org.knowm.xchange.service.trade.params.CancelOrderByIdParams 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);
    }
}
Also used : BinanceException(org.knowm.xchange.binance.dto.BinanceException) CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) NotAvailableFromExchangeException(org.knowm.xchange.exceptions.NotAvailableFromExchangeException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair)

Example 3 with CancelOrderByIdParams

use of org.knowm.xchange.service.trade.params.CancelOrderByIdParams 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;
}
Also used : OrderCancellationRequest(org.knowm.xchange.okcoin.v3.dto.trade.OrderCancellationRequest) OrderCancellationResponse(org.knowm.xchange.okcoin.v3.dto.trade.OrderCancellationResponse) CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair)

Example 4 with CancelOrderByIdParams

use of org.knowm.xchange.service.trade.params.CancelOrderByIdParams in project XChange by knowm.

the class ExmoTradeService method cancelOrder.

@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
    if (orderParams instanceof CancelOrderByIdParams) {
        CancelOrderByIdParams params = (CancelOrderByIdParams) orderParams;
        String orderId = params.getOrderId();
        Map map = exmo.orderCancel(signatureCreator, apiKey, exchange.getNonceFactory(), orderId);
        return (boolean) map.get("result");
    }
    return false;
}
Also used : CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) Map(java.util.Map)

Example 5 with CancelOrderByIdParams

use of org.knowm.xchange.service.trade.params.CancelOrderByIdParams 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);
    }
}
Also used : BithumbException(org.knowm.xchange.bithumb.BithumbException) CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Aggregations

CancelOrderByIdParams (org.knowm.xchange.service.trade.params.CancelOrderByIdParams)12 CancelOrderByCurrencyPair (org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair)8 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)5 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)4 OpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)4 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)3 NotAvailableFromExchangeException (org.knowm.xchange.exceptions.NotAvailableFromExchangeException)2 OrderQueryParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 BinanceException (org.knowm.xchange.binance.dto.BinanceException)1 BithumbException (org.knowm.xchange.bithumb.BithumbException)1 OrderReference (org.knowm.xchange.dragonex.dto.trade.OrderReference)1 UserOrder (org.knowm.xchange.dragonex.dto.trade.UserOrder)1 NotYetImplementedForExchangeException (org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)1 LivecoinException (org.knowm.xchange.livecoin.dto.LivecoinException)1 OkCoinTradeResult (org.knowm.xchange.okcoin.dto.trade.OkCoinTradeResult)1 OrderCancellationRequest (org.knowm.xchange.okcoin.v3.dto.trade.OrderCancellationRequest)1 OrderCancellationResponse (org.knowm.xchange.okcoin.v3.dto.trade.OrderCancellationResponse)1