Search in sources :

Example 1 with LatokenOrderStatus

use of org.knowm.xchange.latoken.dto.trade.LatokenOrderStatus in project XChange by knowm.

the class LatokenTradeService method getOrder.

@Override
public Collection<Order> getOrder(OrderQueryParams... params) throws IOException {
    try {
        Collection<Order> orders = new ArrayList<>();
        // pair/status (via LatokenQueryOrderParams)
        for (OrderQueryParams param : params) {
            if (param instanceof OrderQueryParamCurrencyPair) {
                OrderQueryParamCurrencyPair orderQueryParamCurrencyPair = (OrderQueryParamCurrencyPair) param;
                CurrencyPair pair = orderQueryParamCurrencyPair.getCurrencyPair();
                if (pair == null) {
                    throw new ExchangeException("CurrencyPair must be provided to query an order.");
                }
                LatokenOrderStatus status = LatokenOrderStatus.active;
                Integer limit = null;
                if (param instanceof LatokenQueryOrderParams) {
                    LatokenQueryOrderParams latokenParam = (LatokenQueryOrderParams) param;
                    status = latokenParam.getStatus();
                    limit = latokenParam.getLimit();
                }
                List<LatokenOrder> latokenOrders = getLatokenOrders(pair, status, limit);
                latokenOrders.forEach(latokenOrder -> orders.add(LatokenAdapters.adaptOrder(this.exchange, latokenOrder)));
            } else {
                if (param.getOrderId() == null) {
                    throw new ExchangeException("OrderId must be provided to query an order.");
                }
                LatokenOrder latokenOrder = getLatokenOrder(param.getOrderId());
                orders.add(LatokenAdapters.adaptOrder(this.exchange, latokenOrder));
            }
        }
        return orders;
    } catch (LatokenException e) {
        throw LatokenErrorAdapter.adapt(e);
    }
}
Also used : LatokenNewOrder(org.knowm.xchange.latoken.dto.trade.LatokenNewOrder) Order(org.knowm.xchange.dto.Order) LatokenTestOrder(org.knowm.xchange.latoken.dto.trade.LatokenTestOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) LatokenOrder(org.knowm.xchange.latoken.dto.trade.LatokenOrder) LatokenException(org.knowm.xchange.latoken.dto.LatokenException) LatokenOrder(org.knowm.xchange.latoken.dto.trade.LatokenOrder) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) ArrayList(java.util.ArrayList) LatokenOrderStatus(org.knowm.xchange.latoken.dto.trade.LatokenOrderStatus) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) OrderQueryParams(org.knowm.xchange.service.trade.params.orders.OrderQueryParams) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Aggregations

ArrayList (java.util.ArrayList)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 Order (org.knowm.xchange.dto.Order)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1 LatokenException (org.knowm.xchange.latoken.dto.LatokenException)1 LatokenNewOrder (org.knowm.xchange.latoken.dto.trade.LatokenNewOrder)1 LatokenOrder (org.knowm.xchange.latoken.dto.trade.LatokenOrder)1 LatokenOrderStatus (org.knowm.xchange.latoken.dto.trade.LatokenOrderStatus)1 LatokenTestOrder (org.knowm.xchange.latoken.dto.trade.LatokenTestOrder)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 OrderQueryParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair)1 OrderQueryParams (org.knowm.xchange.service.trade.params.orders.OrderQueryParams)1