use of com.github.jnidzwetzki.bitfinex.v2.entity.ConnectionCapabilities in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class OrderManager method cancelOrderAndWaitForCompletion.
/**
* Cancel a order
* @param id
* @throws APIException, InterruptedException
*/
public void cancelOrderAndWaitForCompletion(final long id) throws APIException, InterruptedException {
final ConnectionCapabilities capabilities = bitfinexApiBroker.getCapabilities();
if (!capabilities.isHavingOrdersWriteCapability()) {
throw new APIException("Unable to cancel order " + id + " connection has not enough capabilities: " + capabilities);
}
final Callable<Boolean> orderCallable = () -> cancelOrderOnAPI(id);
// See comment in placeOrder()
final Retryer<Boolean> retryer = new Retryer<>(ORDER_RETRIES, RETRY_DELAY_IN_MS, orderCallable);
retryer.execute();
if (retryer.getNeededExecutions() > 1) {
logger.info("Nedded {} executions for canceling the order", retryer.getNeededExecutions());
}
if (!retryer.isSuccessfully()) {
final Exception lastException = retryer.getLastException();
if (lastException == null) {
throw new APIException("Unable to cancel order");
} else {
throw new APIException(lastException);
}
}
}
use of com.github.jnidzwetzki.bitfinex.v2.entity.ConnectionCapabilities in project bitfinex-v2-wss-api-java by jnidzwetzki.
the class OrderManager method cancelOrder.
/**
* Cancel the given order
* @param cid
* @param date
* @throws APIException
*/
public void cancelOrder(final long id) throws APIException {
final ConnectionCapabilities capabilities = bitfinexApiBroker.getCapabilities();
if (!capabilities.isHavingOrdersWriteCapability()) {
throw new APIException("Unable to cancel order " + id + " connection has not enough capabilities: " + capabilities);
}
logger.info("Cancel order with id {}", id);
final CancelOrderCommand cancelOrder = new CancelOrderCommand(id);
bitfinexApiBroker.sendCommand(cancelOrder);
}
Aggregations