use of org.knowm.xchange.okcoin.dto.trade.OkCoinTradeResult in project XChange by knowm.
the class OkCoinTradeService 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.");
}
long id = Long.valueOf(((CancelOrderByIdParams) orderParams).getOrderId());
String symbol = OkCoinAdapters.adaptSymbol(((CancelOrderByCurrencyPair) orderParams).getCurrencyPair());
OkCoinTradeResult cancelResult = cancelOrder(id, symbol);
return id == cancelResult.getOrderId();
}
use of org.knowm.xchange.okcoin.dto.trade.OkCoinTradeResult in project XChange by knowm.
the class OkCoinFuturesTradeService method cancelOrder.
@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
OkCoinFuturesCancelOrderParams myParams = (OkCoinFuturesCancelOrderParams) orderParams;
CurrencyPair currencyPair = myParams.getCurrencyPair();
FuturesContract reqFuturesContract = myParams.futuresContract;
long orderId = myParams.getOrderId() != null ? Long.valueOf(myParams.getOrderId()) : -1;
boolean ret = false;
try {
OkCoinTradeResult cancelResult = futuresCancelOrder(orderId, OkCoinAdapters.adaptSymbol(currencyPair), reqFuturesContract);
if (orderId == cancelResult.getOrderId()) {
ret = true;
}
} catch (ExchangeException e) {
if (e.getMessage().equals(OkCoinUtils.getErrorMessage(1009)) || e.getMessage().equals(OkCoinUtils.getErrorMessage(20015))) {
// order not found.
} else
throw e;
}
return ret;
}
Aggregations