Search in sources :

Example 1 with CoingiOrder

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);
}
Also used : ArrayList(java.util.ArrayList) CoingiOrder(org.knowm.xchange.coingi.dto.trade.CoingiOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) Date(java.util.Date)

Example 2 with CoingiOrder

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);
}
Also used : UserTrades(org.knowm.xchange.dto.trade.UserTrades) OrderType(org.knowm.xchange.dto.Order.OrderType) ArrayList(java.util.ArrayList) CoingiOrder(org.knowm.xchange.coingi.dto.trade.CoingiOrder) UserTrade(org.knowm.xchange.dto.trade.UserTrade) Date(java.util.Date) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 3 with CoingiOrder

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);
    }
}
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)3 Date (java.util.Date)3 CoingiOrder (org.knowm.xchange.coingi.dto.trade.CoingiOrder)3 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)2 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)2 CoingiException (org.knowm.xchange.coingi.dto.CoingiException)1 CoingiGetOrderRequest (org.knowm.xchange.coingi.dto.trade.CoingiGetOrderRequest)1 Order (org.knowm.xchange.dto.Order)1 OrderType (org.knowm.xchange.dto.Order.OrderType)1 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)1 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)1 UserTrade (org.knowm.xchange.dto.trade.UserTrade)1 UserTrades (org.knowm.xchange.dto.trade.UserTrades)1 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)1