Search in sources :

Example 1 with BithumbException

use of org.knowm.xchange.bithumb.BithumbException in project XChange by knowm.

the class BithumbTradeService method cancelOrder.

@Override
public boolean cancelOrder(CancelOrderParams orderParams) throws IOException {
    try {
        if (!(orderParams instanceof CancelOrderByIdParams && orderParams instanceof CancelOrderByCurrencyPair)) {
            throw new NotYetImplementedForExchangeException("Only CancelOrderByPairAndIdParams || (CancelOrderByIdParams && CancelOrderByCurrencyPair) supported");
        }
        String orderId = ((CancelOrderByIdParams) orderParams).getOrderId();
        CurrencyPair pair = ((CancelOrderByCurrencyPair) orderParams).getCurrencyPair();
        return cancelBithumbOrder(orderId, pair);
    } catch (BithumbException e) {
        throw BithumbErrorAdapter.adapt(e);
    }
}
Also used : BithumbException(org.knowm.xchange.bithumb.BithumbException) CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Example 2 with BithumbException

use of org.knowm.xchange.bithumb.BithumbException in project XChange by knowm.

the class BithumbTradeDemo method raw.

private static void raw(BithumbTradeServiceRaw tradeServiceRaw) throws IOException, InterruptedException {
    log.debug("{}", "----------RAW----------");
    final OpenOrdersParams openOrders = new DefaultOpenOrdersParamCurrencyPair(CURRENCY_PAIR);
    try {
        log.debug("{}", tradeServiceRaw.getBithumbOrders(CURRENCY_PAIR));
    } catch (BithumbException e) {
        log.debug("", e);
    }
    log.debug("{}", tradeServiceRaw.getBithumbUserTransactions(CURRENCY_PAIR));
    final LimitOrder limitOrderBuy = new LimitOrder.Builder(Order.OrderType.BID, CURRENCY_PAIR).originalAmount(BigDecimal.valueOf(10)).limitPrice(BigDecimal.valueOf(100)).build();
    log.debug("{}", tradeServiceRaw.placeBithumbLimitOrder(limitOrderBuy));
    // wait for order to propagate
    Thread.sleep(3000);
    final LimitOrder limitOrderSell = new LimitOrder.Builder(Order.OrderType.ASK, CURRENCY_PAIR).originalAmount(BigDecimal.valueOf(10)).limitPrice(BigDecimal.valueOf(600)).build();
    log.debug("{}", tradeServiceRaw.placeBithumbLimitOrder(limitOrderSell));
    // wait for order to propagate
    Thread.sleep(3000);
    tradeServiceRaw.getBithumbOrders(CURRENCY_PAIR).getData().stream().map(BithumbOrder::getOrderId).forEach(orderId -> {
        try {
            log.debug("{}", tradeServiceRaw.cancelBithumbOrder(orderId, CURRENCY_PAIR));
        } catch (IOException ignored) {
        }
    });
// log.debug("{}", tradeServiceRaw.placeBithumbMarketOrder(new
// MarketOrder(Order.OrderType.ASK, BigDecimal.valueOf(10), CURRENCY_PAIR)));
}
Also used : BithumbException(org.knowm.xchange.bithumb.BithumbException) IOException(java.io.IOException) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OpenOrdersParams(org.knowm.xchange.service.trade.params.orders.OpenOrdersParams) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)

Aggregations

BithumbException (org.knowm.xchange.bithumb.BithumbException)2 IOException (java.io.IOException)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 NotYetImplementedForExchangeException (org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)1 CancelOrderByCurrencyPair (org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair)1 CancelOrderByIdParams (org.knowm.xchange.service.trade.params.CancelOrderByIdParams)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 OpenOrdersParams (org.knowm.xchange.service.trade.params.orders.OpenOrdersParams)1 OrderQueryParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair)1