use of org.knowm.xchange.cexio.dto.trade.CexIOFullOrder 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));
}
use of org.knowm.xchange.cexio.dto.trade.CexIOFullOrder in project XChange by knowm.
the class CexIOAdapters method adaptOrder.
public static LimitOrder adaptOrder(CexIOFullOrder 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;
if (cexIOOrder.remains != null) {
BigDecimal remains = new BigDecimal(cexIOOrder.remains);
cumulativeAmount = originalAmount.subtract(remains);
}
BigDecimal totalAmountMaker = cexIOOrder.totalAmountMaker != null ? new BigDecimal(cexIOOrder.totalAmountMaker) : BigDecimal.ZERO;
BigDecimal totalAmountTaker = cexIOOrder.totalAmountTaker != null ? new BigDecimal(cexIOOrder.totalAmountTaker) : BigDecimal.ZERO;
BigDecimal tradedAmount = totalAmountMaker.add(totalAmountTaker);
BigDecimal averagePrice = null;
if (cumulativeAmount != null && tradedAmount.compareTo(BigDecimal.ZERO) > 0) {
averagePrice = tradedAmount.divide(cumulativeAmount, 2, RoundingMode.HALF_UP);
}
BigDecimal feeMaker = cexIOOrder.feeMaker != null ? new BigDecimal(cexIOOrder.feeMaker) : BigDecimal.ZERO;
BigDecimal feeTaker = cexIOOrder.feeTaker != null ? new BigDecimal(cexIOOrder.feeTaker) : BigDecimal.ZERO;
BigDecimal fee = feeMaker.add(feeTaker);
return new LimitOrder(orderType, originalAmount, currencyPair, cexIOOrder.orderId, timestamp, limitPrice, averagePrice, cumulativeAmount, fee.compareTo(BigDecimal.ZERO) > 0 ? fee : null, status);
}
Aggregations