Search in sources :

Example 1 with CexIOOpenOrder

use of org.knowm.xchange.cexio.dto.trade.CexIOOpenOrder in project XChange by knowm.

the class CexIOAdapters method adaptOrder.

public static Order adaptOrder(CexIOOpenOrder cexIOOrder) {
    OrderType orderType = cexIOOrder.type.equals("sell") ? OrderType.ASK : OrderType.BID;
    BigDecimal originalAmount = new BigDecimal(cexIOOrder.amount);
    CurrencyPair currencyPair = new CurrencyPair(cexIOOrder.symbol1, cexIOOrder.symbol2);
    Date timestamp = new Date(cexIOOrder.time);
    BigDecimal limitPrice = new BigDecimal(cexIOOrder.price);
    Order.OrderStatus status = adaptOrderStatus(cexIOOrder);
    BigDecimal cumulativeAmount = null;
    try {
        BigDecimal remains = new BigDecimal(cexIOOrder.remains);
        cumulativeAmount = originalAmount.subtract(remains);
    } catch (Exception e) {
    }
    return new LimitOrder(orderType, originalAmount, currencyPair, cexIOOrder.orderId, timestamp, limitPrice, null, cumulativeAmount, null, status);
}
Also used : CexIOArchivedOrder(org.knowm.xchange.cexio.dto.trade.CexIOArchivedOrder) Order(org.knowm.xchange.dto.Order) CexIOFullOrder(org.knowm.xchange.cexio.dto.trade.CexIOFullOrder) CexIOOpenOrder(org.knowm.xchange.cexio.dto.trade.CexIOOpenOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) CexIOOrder(org.knowm.xchange.cexio.dto.trade.CexIOOrder) OrderType(org.knowm.xchange.dto.Order.OrderType) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) BigDecimal(java.math.BigDecimal) Date(java.util.Date) InvalidFormatException(com.fasterxml.jackson.databind.exc.InvalidFormatException) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 2 with CexIOOpenOrder

use of org.knowm.xchange.cexio.dto.trade.CexIOOpenOrder in project XChange by knowm.

the class CexIOTradeService method getOrder.

@Override
public Collection<Order> getOrder(String... orderIds) throws IOException {
    List<Order> orders = new ArrayList<>();
    for (String orderId : orderIds) {
        CexIOOpenOrder cexIOOrder = getOrderDetail(orderId);
        orders.add(CexIOAdapters.adaptOrder(cexIOOrder));
    }
    return orders;
}
Also used : CexIOArchivedOrder(org.knowm.xchange.cexio.dto.trade.CexIOArchivedOrder) Order(org.knowm.xchange.dto.Order) CexIOOpenOrder(org.knowm.xchange.cexio.dto.trade.CexIOOpenOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) CexIOOrder(org.knowm.xchange.cexio.dto.trade.CexIOOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) CexIOOpenOrder(org.knowm.xchange.cexio.dto.trade.CexIOOpenOrder) ArrayList(java.util.ArrayList)

Example 3 with CexIOOpenOrder

use of org.knowm.xchange.cexio.dto.trade.CexIOOpenOrder in project XChange by knowm.

the class CexIOTradeServiceRaw method getOrderFullDetail.

public CexIOFullOrder getOrderFullDetail(String orderId) throws IOException {
    Map orderRaw = cexIOAuthenticated.getOrderRaw(signatureCreator, new CexioSingleOrderIdRequest(orderId));
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    CexIOOpenOrder order = objectMapper.convertValue(orderRaw, CexIOOpenOrder.class);
    return new CexIOFullOrder(order.user, order.type, order.symbol1, order.symbol2, order.amount, order.remains, order.price, order.time, order.lastTxTime, order.tradingFeeStrategy, order.tradingFeeTaker, order.tradingFeeMaker, order.tradingFeeUserVolumeAmount, order.lastTx, order.status, order.orderId, order.id, (String) orderRaw.get("ta:" + order.symbol2), (String) orderRaw.get("tta:" + order.symbol2), (String) orderRaw.get("fa:" + order.symbol2), (String) orderRaw.get("tfa:" + order.symbol2));
}
Also used : CexioSingleOrderIdRequest(org.knowm.xchange.cexio.dto.CexioSingleOrderIdRequest) CexIOOpenOrder(org.knowm.xchange.cexio.dto.trade.CexIOOpenOrder) Map(java.util.Map) CexIOFullOrder(org.knowm.xchange.cexio.dto.trade.CexIOFullOrder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

CexIOOpenOrder (org.knowm.xchange.cexio.dto.trade.CexIOOpenOrder)3 CexIOArchivedOrder (org.knowm.xchange.cexio.dto.trade.CexIOArchivedOrder)2 CexIOFullOrder (org.knowm.xchange.cexio.dto.trade.CexIOFullOrder)2 CexIOOrder (org.knowm.xchange.cexio.dto.trade.CexIOOrder)2 Order (org.knowm.xchange.dto.Order)2 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InvalidFormatException (com.fasterxml.jackson.databind.exc.InvalidFormatException)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Map (java.util.Map)1 CexioSingleOrderIdRequest (org.knowm.xchange.cexio.dto.CexioSingleOrderIdRequest)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 OrderType (org.knowm.xchange.dto.Order.OrderType)1 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)1