Search in sources :

Example 1 with CoingiGetOrderRequest

use of org.knowm.xchange.coingi.dto.trade.CoingiGetOrderRequest 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);
    }
}
Also used : CoingiOrder(org.knowm.xchange.coingi.dto.trade.CoingiOrder) Order(org.knowm.xchange.dto.Order) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) CoingiException(org.knowm.xchange.coingi.dto.CoingiException) CoingiGetOrderRequest(org.knowm.xchange.coingi.dto.trade.CoingiGetOrderRequest) ArrayList(java.util.ArrayList) CoingiOrder(org.knowm.xchange.coingi.dto.trade.CoingiOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) Date(java.util.Date) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Aggregations

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 CoingiException (org.knowm.xchange.coingi.dto.CoingiException)1 CoingiGetOrderRequest (org.knowm.xchange.coingi.dto.trade.CoingiGetOrderRequest)1 CoingiOrder (org.knowm.xchange.coingi.dto.trade.CoingiOrder)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 Order (org.knowm.xchange.dto.Order)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)1 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)1