Search in sources :

Example 1 with OrderQueryParams

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

the class BinanceTradeService method getOrder.

@Override
public Collection<Order> getOrder(OrderQueryParams... params) throws IOException {
    try {
        Collection<Order> orders = new ArrayList<>();
        for (OrderQueryParams param : params) {
            if (!(param instanceof OrderQueryParamCurrencyPair)) {
                throw new ExchangeException("Parameters must be an instance of OrderQueryParamCurrencyPair");
            }
            OrderQueryParamCurrencyPair orderQueryParamCurrencyPair = (OrderQueryParamCurrencyPair) param;
            if (orderQueryParamCurrencyPair.getCurrencyPair() == null || orderQueryParamCurrencyPair.getOrderId() == null) {
                throw new ExchangeException("You need to provide the currency pair and the order id to query an order.");
            }
            orders.add(BinanceAdapters.adaptOrder(super.orderStatus(orderQueryParamCurrencyPair.getCurrencyPair(), BinanceAdapters.id(orderQueryParamCurrencyPair.getOrderId()), null)));
        }
        return orders;
    } catch (BinanceException e) {
        throw BinanceErrorAdapter.adapt(e);
    }
}
Also used : StopOrder(org.knowm.xchange.dto.trade.StopOrder) BinanceNewOrder(org.knowm.xchange.binance.dto.trade.BinanceNewOrder) BinanceOrder(org.knowm.xchange.binance.dto.trade.BinanceOrder) Order(org.knowm.xchange.dto.Order) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) BinanceException(org.knowm.xchange.binance.dto.BinanceException) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) ArrayList(java.util.ArrayList) NotAvailableFromExchangeException(org.knowm.xchange.exceptions.NotAvailableFromExchangeException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) OrderQueryParams(org.knowm.xchange.service.trade.params.orders.OrderQueryParams)

Example 2 with OrderQueryParams

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

the class CoinmateTradeService method getOrder.

@Override
public Collection<Order> getOrder(OrderQueryParams... orderQueryParams) throws IOException {
    ArrayList<Order> result = new ArrayList<>(orderQueryParams.length);
    for (OrderQueryParams orderQueryParam : orderQueryParams) {
        CoinmateOrders response = this.getCoinmateOrderById(orderQueryParam.getOrderId());
        Order order = CoinmateAdapters.adaptOrder(response.getData(), orderId -> {
            try {
                return this.getCoinmateOrderById(orderId).getData();
            } catch (IOException ex) {
                return null;
            }
        });
        result.add(order);
    }
    return result;
}
Also used : StopOrder(org.knowm.xchange.dto.trade.StopOrder) Order(org.knowm.xchange.dto.Order) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) ArrayList(java.util.ArrayList) CoinmateOrders(org.knowm.xchange.coinmate.dto.trade.CoinmateOrders) IOException(java.io.IOException) OrderQueryParams(org.knowm.xchange.service.trade.params.orders.OrderQueryParams)

Example 3 with OrderQueryParams

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

the class Bl3pTradeService method getOrder.

@Override
public Collection<Order> getOrder(OrderQueryParams... orderQueryParams) throws IOException {
    Collection<Order> result = new ArrayList<>(orderQueryParams.length);
    for (OrderQueryParams p : orderQueryParams) {
        Bl3pOrderQueryParams bp = (Bl3pOrderQueryParams) p;
        Bl3pGetOrder order = this.bl3p.getOrder(apiKey, signatureCreator, nonceFactory, Bl3pUtils.toPairString(bp.getCurrencyPair()), bp.getOrderId());
        result.add(Bl3pAdapters.adaptGetOrder(bp.getCurrencyPair(), order.getData()));
    }
    return result;
}
Also used : StopOrder(org.knowm.xchange.dto.trade.StopOrder) Bl3pNewOrder(org.knowm.xchange.bl3p.dto.trade.Bl3pNewOrder) Order(org.knowm.xchange.dto.Order) Bl3pGetOrder(org.knowm.xchange.bl3p.dto.trade.Bl3pGetOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) ArrayList(java.util.ArrayList) Bl3pGetOrder(org.knowm.xchange.bl3p.dto.trade.Bl3pGetOrder) OrderQueryParams(org.knowm.xchange.service.trade.params.orders.OrderQueryParams)

Example 4 with OrderQueryParams

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

the class TradeService method toOrderQueryParams.

static OrderQueryParams[] toOrderQueryParams(String... orderIds) {
    OrderQueryParams[] res = new OrderQueryParams[orderIds.length];
    for (int i = 0; i < orderIds.length; i++) {
        String orderId = orderIds[i];
        res[i] = new DefaultQueryOrderParam(orderId);
    }
    return res;
}
Also used : DefaultQueryOrderParam(org.knowm.xchange.service.trade.params.orders.DefaultQueryOrderParam) OrderQueryParams(org.knowm.xchange.service.trade.params.orders.OrderQueryParams)

Example 5 with OrderQueryParams

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

the class LivecoinTradeService method getOrder.

@Override
public Collection<Order> getOrder(OrderQueryParams... params) throws IOException {
    try {
        if (params == null || params.length == 0) {
            LivecoinPaginatedResponse<LivecoinUserOrder> response = clientOrders(null, null, null, null, null, null);
            return LivecoinAdapters.adaptUserOrders(response.getData());
        }
        List<Order> result = new ArrayList<>();
        for (OrderQueryParams param : params) {
            CurrencyPair pair = null;
            if (param instanceof OrderQueryParamCurrencyPair) {
                pair = ((OrderQueryParamCurrencyPair) param).getCurrencyPair();
            }
            LivecoinPaginatedResponse<LivecoinUserOrder> response = clientOrders(pair, null, null, null, null, null);
            if (param.getOrderId() == null) {
                result.addAll(LivecoinAdapters.adaptUserOrders(response.getData()));
            } else {
                response.getData().stream().filter(order -> order.getId().toString().equals(param.getOrderId())).findAny().map(LivecoinAdapters::adaptUserOrder).ifPresent(result::add);
            }
        }
        return result;
    } catch (LivecoinException e) {
        throw LivecoinErrorAdapter.adapt(e);
    }
}
Also used : Order(org.knowm.xchange.dto.Order) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) LivecoinUserOrder(org.knowm.xchange.livecoin.dto.marketdata.LivecoinUserOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) LivecoinErrorAdapter(org.knowm.xchange.livecoin.LivecoinErrorAdapter) TradeHistoryParams(org.knowm.xchange.service.trade.params.TradeHistoryParams) Date(java.util.Date) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) TradeHistoryParamOffset(org.knowm.xchange.service.trade.params.TradeHistoryParamOffset) NotAvailableFromExchangeException(org.knowm.xchange.exceptions.NotAvailableFromExchangeException) ArrayList(java.util.ArrayList) Order(org.knowm.xchange.dto.Order) LivecoinException(org.knowm.xchange.livecoin.dto.LivecoinException) LivecoinExchange(org.knowm.xchange.livecoin.LivecoinExchange) Livecoin(org.knowm.xchange.livecoin.Livecoin) CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) TradeHistoryParamLimit(org.knowm.xchange.service.trade.params.TradeHistoryParamLimit) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) OrderQueryParams(org.knowm.xchange.service.trade.params.orders.OrderQueryParams) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) ResilienceRegistries(org.knowm.xchange.client.ResilienceRegistries) LivecoinUserOrder(org.knowm.xchange.livecoin.dto.marketdata.LivecoinUserOrder) Collection(java.util.Collection) IOException(java.io.IOException) UserTrades(org.knowm.xchange.dto.trade.UserTrades) LivecoinAdapters(org.knowm.xchange.livecoin.LivecoinAdapters) Collectors(java.util.stream.Collectors) Trades(org.knowm.xchange.dto.marketdata.Trades) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) List(java.util.List) TradeService(org.knowm.xchange.service.trade.TradeService) TradeHistoryParamsTimeSpan(org.knowm.xchange.service.trade.params.TradeHistoryParamsTimeSpan) LivecoinPaginatedResponse(org.knowm.xchange.livecoin.dto.LivecoinPaginatedResponse) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) OpenOrdersParams(org.knowm.xchange.service.trade.params.orders.OpenOrdersParams) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) CancelOrderParams(org.knowm.xchange.service.trade.params.CancelOrderParams) Collections(java.util.Collections) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) LivecoinUserOrder(org.knowm.xchange.livecoin.dto.marketdata.LivecoinUserOrder) OrderQueryParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair) LivecoinException(org.knowm.xchange.livecoin.dto.LivecoinException) ArrayList(java.util.ArrayList) OrderQueryParams(org.knowm.xchange.service.trade.params.orders.OrderQueryParams) 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)

Aggregations

OrderQueryParams (org.knowm.xchange.service.trade.params.orders.OrderQueryParams)10 ArrayList (java.util.ArrayList)9 Order (org.knowm.xchange.dto.Order)9 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)9 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)7 StopOrder (org.knowm.xchange.dto.trade.StopOrder)5 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)4 OrderQueryParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair)4 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)3 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)3 IOException (java.io.IOException)2 Date (java.util.Date)2 NotAvailableFromExchangeException (org.knowm.xchange.exceptions.NotAvailableFromExchangeException)2 CancelOrderByCurrencyPair (org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair)2 OpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)2 BigDecimal (java.math.BigDecimal)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1