public static List<LimitOrder> adaptPoloniexPublicOrders( List<List<BigDecimal>> rawLevels, OrderType orderType, CurrencyPair currencyPair) { List<PoloniexLevel> levels = new ArrayList<>(); for (List<BigDecimal> rawLevel : rawLevels) { levels.add(adaptRawPoloniexLevel(rawLevel)); } List<LimitOrder> orders = new ArrayList<>(); for (PoloniexLevel level : levels) { LimitOrder limitOrder = new LimitOrder.Builder(orderType, currencyPair) .originalAmount(level.getAmount()) .limitPrice(level.getLimit()) .build(); orders.add(limitOrder); } return orders; }
public static Order adaptLiquiOrderInfo(final LiquiOrderInfo orderInfo) { final OrderType type = adaptOrderType(orderInfo.getType()); final Optional<BigDecimal> originalAmount = Optional.ofNullable(orderInfo.getStartAmount()); final Optional<BigDecimal> cumulativeAmount = originalAmount.map(startAmount -> startAmount.subtract(orderInfo.getAmount())); final Date timestamp = new Date(orderInfo.getTimestampCreated() * 1000L); final Order.OrderStatus status = adaptOrderStatus(orderInfo.getStatus()); return new LimitOrder.Builder(type, orderInfo.getPair()) .originalAmount(originalAmount.orElse(orderInfo.getAmount())) .timestamp(timestamp) .limitPrice(orderInfo.getRate()) .cumulativeAmount(cumulativeAmount.orElse(null)) .orderStatus(status) .build(); }
public static OpenOrders convertOpenOrders( List<EXXOrder> exxOpenOrders, CurrencyPair currencyPair) { List<LimitOrder> openOrders = new LinkedList<>(); for (EXXOrder exxOrder : exxOpenOrders) { openOrders.add( new LimitOrder.Builder(convertType(exxOrder.getType()), currencyPair) .id(exxOrder.getId()) .timestamp(new Date(exxOrder.getTradeDate())) .limitPrice(exxOrder.getPrice()) .originalAmount(exxOrder.getTotalAmount()) .build()); } return new OpenOrders(openOrders); }
protected LimitOrder mapKunaOrder2LimitOrder(KunaOrder kunaOrder, CurrencyPair currencyPair) { Order.OrderType orderType = kunaOrder.getOrderType() == KunaOrderType.LIMIT ? Order.OrderType.ASK : Order.OrderType.BID; LimitOrder.Builder builder = new LimitOrder.Builder(orderType, currencyPair); builder .id(String.valueOf(kunaOrder.getId())) .currencyPair(currencyPair) .timestamp(kunaOrder.getCreatedAt()) .orderStatus(Order.OrderStatus.NEW) .orderType(orderType) .averagePrice(kunaOrder.getAveragePrice()) .limitPrice(kunaOrder.getPrice()) .originalAmount(kunaOrder.getVolume()) .remainingAmount(kunaOrder.getRemainingVolume()) .cumulativeAmount(kunaOrder.getExecutedVolume()); return builder.build(); }
public static LimitOrder adaptOrder(BithumbOrder order) { final CurrencyPair currencyPair = new CurrencyPair(order.getOrderCurrency(), order.getPaymentCurrency()); final Order.OrderType orderType = adaptOrderType(order.getType()); return new LimitOrder.Builder(orderType, currencyPair) .id(String.valueOf(order.getOrderId())) .limitPrice(order.getPrice()) .originalAmount(order.getUnits()) .remainingAmount(order.getUnitsRemaining()) .orderStatus( StringUtils.equals(order.getStatus(), "placed") ? Order.OrderStatus.NEW : Order.OrderStatus.UNKNOWN) .timestamp(new Date(order.getOrderDate() / 1000L)) .build(); }
public static Order adaptGetOrder( CurrencyPair currencyPair, Bl3pGetOrder.Bl3pGetOrderData bl3pOrder) { Order.OrderType orderType = Bl3pUtils.fromBl3pOrderType(bl3pOrder.getStatus()); BigDecimal limitPrice = bl3pOrder.getPrice().value; BigDecimal originalAmount = bl3pOrder.getTotalAmount().value; BigDecimal executedAmount = bl3pOrder.getTotalSpent().value; BigDecimal remainingAmount = originalAmount.subtract(executedAmount); return new LimitOrder.Builder(orderType, currencyPair) .cumulativeAmount(executedAmount) .id("" + bl3pOrder.getOrderId()) .limitPrice(limitPrice) .originalAmount(originalAmount) .remainingAmount(remainingAmount) .timestamp(bl3pOrder.getTimestamp()) .build(); }
public static OpenOrders adaptBleutradeOpenOrders(List<BleutradeOpenOrder> bleutradeOpenOrders) { List<LimitOrder> openOrders = new ArrayList<>(); for (BleutradeOpenOrder bleuTradeOpenOrder : bleutradeOpenOrders) { OrderType type = bleuTradeOpenOrder.getType().equals("BUY") ? OrderType.BID : OrderType.ASK; CurrencyPair currencyPair = BleutradeUtils.toCurrencyPair(bleuTradeOpenOrder.getExchange()); LimitOrder.Builder builder = new LimitOrder.Builder(type, currencyPair); builder.id(bleuTradeOpenOrder.getOrderId()); builder.limitPrice(bleuTradeOpenOrder.getPrice()); builder.remainingAmount(bleuTradeOpenOrder.getQuantityRemaining()); builder.originalAmount(bleuTradeOpenOrder.getQuantity()); builder.timestamp(BleutradeUtils.toDate(bleuTradeOpenOrder.getCreated())); openOrders.add(builder.build()); } return new OpenOrders(openOrders); }
private static LimitOrder adaptOrder(CobinhoodOrder order) { return new LimitOrder.Builder( order.getSide().getOrderType(), adaptSymbol(order.getTradingPair())) .id(order.getId()) .timestamp(new Date(order.getTimestamp())) .orderType(order.getSide().getOrderType()) .orderStatus(order.getState().getStatus()) .limitPrice(order.getPrice()) .cumulativeAmount(order.getFilled()) .originalAmount(order.getSize()) .build(); } }
private static LimitOrder adaptLimitOpenOrder(BiboxOrder biboxOrder) { CurrencyPair currencyPair = new CurrencyPair(biboxOrder.getCoinSymbol(), biboxOrder.getCurrencySymbol()); return new LimitOrder.Builder(biboxOrder.getOrderSide().getOrderType(), currencyPair) .id(String.valueOf(biboxOrder.getId())) .timestamp(new Date(biboxOrder.getCreatedAt())) .limitPrice(biboxOrder.getPrice()) .originalAmount(biboxOrder.getAmount()) .cumulativeAmount(biboxOrder.getDealAmount()) .remainingAmount(biboxOrder.getUnexecuted()) .orderStatus(biboxOrder.getStatus().getOrderStatus()) .build(); }
private static LimitOrder adaptActiveOrder(CurrencyPair currencyPair, KucoinActiveOrder order) { return new LimitOrder.Builder(order.getOrderType().getOrderType(), currencyPair) .timestamp(order.getTimestamp()) .id(order.getOrderOid()) .limitPrice(order.getPrice()) .originalAmount(order.getAmount()) // this might be the remaining amount, not sure .cumulativeAmount(order.getDealAmount()) .orderStatus( order.getDealAmount().compareTo(BigDecimal.ZERO) == 0 ? OrderStatus.NEW : OrderStatus.PARTIALLY_FILLED) .build(); }
public static LimitOrder adaptPoloniexOpenOrder( PoloniexOpenOrder openOrder, CurrencyPair currencyPair) { OrderType type = openOrder.getType().equals("buy") ? OrderType.BID : OrderType.ASK; Date timestamp = PoloniexUtils.stringToDate(openOrder.getDate()); return new LimitOrder.Builder(type, currencyPair) .limitPrice(openOrder.getRate()) .originalAmount(openOrder.getStartingAmount()) .cumulativeAmount(openOrder.getStartingAmount().subtract(openOrder.getAmount())) .id(openOrder.getOrderNumber()) .timestamp(timestamp) .build(); }
public static LimitOrder createOrder( CurrencyPair currencyPair, AbucoinsOrderBook.LimitOrder priceAndAmount, OrderType orderType) { return new LimitOrder.Builder(orderType, currencyPair) .averagePrice(priceAndAmount.getPrice()) .limitPrice(priceAndAmount.getPrice()) .orderStatus(OrderStatus.NEW) .originalAmount(priceAndAmount.getSize()) .build(); }
private LimitOrder mapOrder(CurrencyPair currencyPair, AcxOrder order) { OrderType type = mapOrderType(order); return new LimitOrder.Builder(type, currencyPair) .id(order.id) .limitPrice(order.price) .averagePrice(order.avgPrice) .timestamp(order.createdAt) .originalAmount(order.volume) .remainingAmount(order.remainingVolume) .cumulativeAmount(order.executedVolume) .orderStatus(mapOrderStatus(order.state)) .build(); }
public static LimitOrder adaptLimitOrder(AbucoinsOrder order) { return new LimitOrder.Builder( adaptOrderType(order.getSide()), adaptCurrencyPair(order.getProductID())) .averagePrice(order.getPrice()) .cumulativeAmount(order.getFilledSize()) .id(order.getId()) .limitPrice(order.getPrice()) .orderStatus(adaptOrderStatus(order.getStatus())) .originalAmount(order.getSize()) .remainingAmount(order.getSize().subtract(order.getFilledSize())) .timestamp(parseDate(order.getCreatedAt())) .build(); }
public static LimitOrder adaptOrderBookOrder( BiboxOrderBookEntry entry, OrderType orderType, CurrencyPair currencyPair) { return new LimitOrder.Builder(orderType, currencyPair) .limitPrice(entry.getPrice()) .originalAmount(entry.getVolume()) .build(); }
public static LimitOrder adaptVaultoroOrder(VaultoroOpenOrder o, OrderType orderType) { return new LimitOrder.Builder(orderType, new CurrencyPair("GLD", "BTC")) .id(o.getOrderID()) .limitPrice(o.getGoldPrice()) .originalAmount(o.getGoldAmount()) .build(); } }
private static LimitOrder adaptBid( CurrencyPair currencyPair, Order.OrderType orderType, TheRockBid theRockBid, Date timestamp) { return new LimitOrder.Builder(orderType, currencyPair) .limitPrice(theRockBid.getPrice()) .originalAmount(theRockBid.getAmount()) .timestamp(timestamp) .build(); }
private static LimitOrder adaptBitcointoyouSingleOpenOrder( BitcointoyouOrderInfo orderInfo, CurrencyPair currencyPair, Date orderDate) { OrderType type = orderInfo.getAction().equals("buy") ? OrderType.BID : OrderType.ASK; return new LimitOrder.Builder(type, currencyPair) .limitPrice(orderInfo.getPrice()) .originalAmount(orderInfo.getAmount()) .id(orderInfo.getId()) .timestamp(orderDate) .build(); }
public static LimitOrder adaptLimitOrder(CoinbeneLimitOrder order) { return new LimitOrder.Builder(null, adaptSymbol(order.getSymbol())) .id(order.getOrderId()) .timestamp(new Date(order.getCreateTime())) .orderStatus(order.getOrderStatus().getStatus()) .limitPrice(order.getPrice()) .cumulativeAmount(order.getFilledQuantity()) .originalAmount(order.getOrderQuantity()) .build(); }
public static LimitOrder adaptOrder( CoinEggOrder order, OrderType type, CurrencyPair currencyPair) { BigDecimal quantity = order.getQuantity(); BigDecimal price = order.getPrice(); LimitOrder limitOrder = new LimitOrder.Builder(type, currencyPair) .originalAmount(quantity) .limitPrice(price) .build(); return limitOrder; }