use of org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair 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.OrderQueryParamCurrencyPair 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);
}
}
use of org.knowm.xchange.service.trade.params.orders.OrderQueryParamCurrencyPair 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);
}
}
Aggregations