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);
}
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations