Search in sources :

Example 1 with UserOrder

use of org.knowm.xchange.dragonex.dto.trade.UserOrder 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)

Example 2 with UserOrder

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

the class DragonexTradeService method placeLimitOrder.

@Override
public String placeLimitOrder(LimitOrder limitOrder) throws IOException {
    OrderPlacement orderPlacement = new OrderPlacement(exchange.symbolId(limitOrder.getCurrencyPair()), limitOrder.getLimitPrice(), limitOrder.getOriginalAmount());
    UserOrder newOrder = limitOrder.getType() == OrderType.BID ? super.orderBuy(exchange.getOrCreateToken().token, orderPlacement) : super.orderSell(exchange.getOrCreateToken().token, orderPlacement);
    return Long.toString(newOrder.orderId);
}
Also used : OrderPlacement(org.knowm.xchange.dragonex.dto.trade.OrderPlacement) UserOrder(org.knowm.xchange.dragonex.dto.trade.UserOrder)

Aggregations

UserOrder (org.knowm.xchange.dragonex.dto.trade.UserOrder)2 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 OrderPlacement (org.knowm.xchange.dragonex.dto.trade.OrderPlacement)1 OrderReference (org.knowm.xchange.dragonex.dto.trade.OrderReference)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