use of org.knowm.xchange.coingi.dto.trade.CoingiOrder in project XChange by knowm.
the class CoingiAdapters method adaptOpenOrders.
public static OpenOrders adaptOpenOrders(CoingiOrdersList orders) {
List<LimitOrder> list = new ArrayList<>();
for (CoingiOrder order : orders) {
LimitOrder limitOrder = new LimitOrder(order.getType() == 0 ? OrderType.BID : OrderType.ASK, order.getOriginalBaseAmount(), adaptCurrency(order.getCurrencyPair()), order.getId(), new Date(order.getTimestamp()), order.getPrice());
limitOrder.setOrderStatus(adaptOrderStatus(order.getStatus()));
list.add(limitOrder);
}
return new OpenOrders(list);
}
use of org.knowm.xchange.coingi.dto.trade.CoingiOrder in project XChange by knowm.
the class CoingiAdapters method adaptTradeHistory.
public static UserTrades adaptTradeHistory(CoingiOrdersList ordersList) {
List<UserTrade> trades = new ArrayList<>();
for (CoingiOrder o : ordersList.getList()) {
final OrderType orderType = o.getType() == 0 ? OrderType.BID : OrderType.ASK;
final CurrencyPair pair = new CurrencyPair(o.getCurrencyPair().get("base").toUpperCase(), o.getCurrencyPair().get("counter").toUpperCase());
UserTrade trade = new UserTrade.Builder().type(orderType).originalAmount(o.getOriginalBaseAmount()).currencyPair(pair).price(o.getPrice()).timestamp(new Date(o.getTimestamp())).id(o.getId()).orderId(o.getId()).feeAmount(BigDecimal.ZERO).build();
trades.add(trade);
}
return new UserTrades(trades, TradeSortType.SortByID);
}
use of org.knowm.xchange.coingi.dto.trade.CoingiOrder in project XChange by knowm.
the class CoingiTradeService method getOrder.
@Override
public Collection<Order> getOrder(String... orderIds) throws IOException {
try {
Collection<Order> orders = new ArrayList<>();
for (String orderId : orderIds) {
CoingiGetOrderRequest request = new CoingiGetOrderRequest().setOrderId(orderId);
CoingiOrder coingiOrder;
coingiOrder = getCoingiOrder(request);
CurrencyPair currencyPair = CoingiAdapters.adaptCurrency(coingiOrder.getCurrencyPair());
Date date = new Date(coingiOrder.getTimestamp() * 1000);
Order order = new LimitOrder(coingiOrder.getType() == 0 ? Order.OrderType.BID : Order.OrderType.ASK, coingiOrder.getOriginalBaseAmount(), currencyPair, coingiOrder.getId(), date, coingiOrder.getPrice());
order.setOrderStatus(CoingiAdapters.adaptOrderStatus(coingiOrder.getStatus()));
orders.add(order);
}
return orders;
} catch (CoingiException e) {
throw CoingiErrorAdapter.adapt(e);
}
}
Aggregations