Search in sources :

Example 1 with CancelOrderByInstrument

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

the class OkexTradeService method cancelOrder.

@Override
public boolean cancelOrder(CancelOrderParams params) throws IOException {
    if (params instanceof CancelOrderByIdParams && params instanceof CancelOrderByInstrument) {
        String id = ((CancelOrderByIdParams) params).getOrderId();
        String instrumentId = OkexAdapters.adaptInstrumentId(((CancelOrderByInstrument) params).getInstrument());
        OkexCancelOrderRequest req = OkexCancelOrderRequest.builder().instrumentId(instrumentId).orderId(id).build();
        return "0".equals(cancelOkexOrder(req).getData().get(0).getCode());
    } else {
        throw new IOException("CancelOrderParams must implement CancelOrderByIdParams and CancelOrderByInstrument interface.");
    }
}
Also used : OkexCancelOrderRequest(org.knowm.xchange.okex.v5.dto.trade.OkexCancelOrderRequest) CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) IOException(java.io.IOException) CancelOrderByInstrument(org.knowm.xchange.service.trade.params.CancelOrderByInstrument)

Aggregations

IOException (java.io.IOException)1 OkexCancelOrderRequest (org.knowm.xchange.okex.v5.dto.trade.OkexCancelOrderRequest)1 CancelOrderByIdParams (org.knowm.xchange.service.trade.params.CancelOrderByIdParams)1 CancelOrderByInstrument (org.knowm.xchange.service.trade.params.CancelOrderByInstrument)1