Search in sources :

Example 1 with OrderReference

use of org.knowm.xchange.dragonex.dto.trade.OrderReference in project XChange by knowm.

the class DragonexTradeService method cancelOrder.

@Override
public boolean cancelOrder(CancelOrderParams params) throws IOException {
    if (!(params instanceof CancelOrderByCurrencyPair)) {
        throw new ExchangeException("You need to provide the currency pair.");
    }
    if (!(params instanceof CancelOrderByIdParams)) {
        throw new ExchangeException("You need to provide the order id.");
    }
    CurrencyPair pair = ((CancelOrderByCurrencyPair) params).getCurrencyPair();
    if (pair == null) {
        throw new ExchangeException("You need to provide the currency pair.");
    }
    long orderId;
    try {
        orderId = Long.valueOf(((CancelOrderByIdParams) params).getOrderId());
    } catch (Throwable e) {
        throw new ExchangeException("You need to provide the order id as a number.", e);
    }
    OrderReference ref = new OrderReference(exchange.symbolId(pair), orderId);
    UserOrder order = super.orderCancel(exchange.getOrCreateToken().token, ref);
    return order.status == 3;
}
Also used : CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) OrderReference(org.knowm.xchange.dragonex.dto.trade.OrderReference) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) DefaultTradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair) UserOrder(org.knowm.xchange.dragonex.dto.trade.UserOrder)

Aggregations

CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 OrderReference (org.knowm.xchange.dragonex.dto.trade.OrderReference)1 UserOrder (org.knowm.xchange.dragonex.dto.trade.UserOrder)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1 CancelOrderByCurrencyPair (org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair)1 CancelOrderByIdParams (org.knowm.xchange.service.trade.params.CancelOrderByIdParams)1 DefaultTradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair)1 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)1 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)1 OpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)1