use of org.knowm.xchange.latoken.dto.trade.LatokenOrder in project XChange by knowm.
the class LatokenTradeService method getOpenOrders.
@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {
try {
if (params instanceof OpenOrdersParamCurrencyPair == false) {
throw new ExchangeException("CurrencyPair is must be provided to get open orders.");
}
OpenOrdersParamCurrencyPair pairParams = (OpenOrdersParamCurrencyPair) params;
CurrencyPair pair = pairParams.getCurrencyPair();
if (pair == null) {
throw new ExchangeException("CurrencyPair is must be provided to get open orders.");
}
List<LatokenOrder> latokenOpenOrders = getLatokenOpenOrders(pair, Integer.MAX_VALUE);
return LatokenAdapters.adaptOpenOrders(this.exchange, latokenOpenOrders);
} catch (LatokenException e) {
throw LatokenErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.latoken.dto.trade.LatokenOrder 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