Package com.xeiam.xchange.dto.trade

Examples of com.xeiam.xchange.dto.trade.LimitOrder$Builder


  public static LimitOrder adaptOrder(CryptoTradeOrder order) {

    Date timestamp = new Date(order.getOrderDate());
    OrderType orderType = adaptOrderType(order.getType());

    return new LimitOrder(orderType, order.getRemainingAmount(), order.getCurrencyPair(), String.valueOf(order.getId()), timestamp, order.getRate());
  }
View Full Code Here


    List<LimitOrder> orderList = new ArrayList<LimitOrder>();
    for (CryptoTradeOrder cryptoTradeOrder : cryptoTradeOrders.getOrders()) {
      // TODO Change to check cryptoTradeOrder.getStatus() once all statuses are known.
      if (cryptoTradeOrder.getRemainingAmount().compareTo(BigDecimal.ZERO) > 0) {
        LimitOrder adaptedOrder = adaptOrder(cryptoTradeOrder);
        orderList.add(adaptedOrder);
      }
    }

    return new OpenOrders(orderList);
View Full Code Here

    // place a limit order
    OrderType orderType = SIDE_BID.equalsIgnoreCase(orderTypeString) ? OrderType.BID : OrderType.ASK;
    CurrencyPair currencyPair = adaptCurrencyPair(tradedCurrency, transactionCurrency);

    LimitOrder limitOrder = new LimitOrder(orderType, amount, currencyPair, id, timestamp, price);

    return limitOrder;

  }
View Full Code Here

  public void testAdaptOrders() throws IOException {

    BTCChinaGetOrdersResponse response = mapper.readValue(getClass().getResource("dto/trade/response/getOrders-single-market-2-orders.json"), BTCChinaGetOrdersResponse.class);
    List<LimitOrder> limitOrders = BTCChinaAdapters.adaptOrders(response.getResult(), null);
    assertEquals(2, limitOrders.size());
    LimitOrder order = limitOrders.get(0);
    assertEquals("13942927", order.getId());
    assertEquals(OrderType.BID, order.getType());
    assertEquals(new BigDecimal("2000.00"), order.getLimitPrice());
    assertEquals(CurrencyPair.BTC_CNY, order.getCurrencyPair());
    assertEquals(new BigDecimal("0.00100000"), order.getTradableAmount());
    assertEquals(1396255376000L, order.getTimestamp().getTime());
  }
View Full Code Here

  private OrderBook orderBook;

  @Before
  public void setUp() throws Exception {

    LimitOrder askOrder = new LimitOrder(OrderType.ASK, BigDecimal.ONE, CurrencyPair.BTC_USD, "", null, BigDecimal.TEN.add(BigDecimal.ONE));
    LimitOrder bidOrder = new LimitOrder(OrderType.BID, BigDecimal.ONE, CurrencyPair.BTC_USD, "", null, BigDecimal.TEN);

    List<LimitOrder> asks = new ArrayList<LimitOrder>(Arrays.asList(askOrder));
    List<LimitOrder> bids = new ArrayList<LimitOrder>(Arrays.asList(bidOrder));
    Date timeStamp = new Date(0);
    orderBook = new OrderBook(timeStamp, asks, bids);
View Full Code Here

  /**
   * Adapts a BTCChinaOrder to a LimitOrder
   */
  public static LimitOrder adaptOrder(BigDecimal amount, BigDecimal price, CurrencyPair currencyPair, OrderType orderType) {

    return new LimitOrder(orderType, amount, currencyPair, "", null, price);

  }
View Full Code Here

    List<LimitOrder> limitOrders = new ArrayList<LimitOrder>(orders == null ? 0 : orders.size());

    if (orders != null) {
      for (BTCChinaOrder order : orders) {
        if (order.getStatus().equals("open")) {
          LimitOrder limitOrder = adaptLimitOrder(order);
          if (limitOrder != null) {
            limitOrders.add(limitOrder);
          }
        }
      }
View Full Code Here

  public static List<LimitOrder> adaptOrders(BTCChinaOrder[] orders, CurrencyPair currencyPair) {

    List<LimitOrder> limitOrders = new ArrayList<LimitOrder>(orders.length);

    for (BTCChinaOrder order : orders) {
      LimitOrder limitOrder = adaptLimitOrder(order, currencyPair);
      limitOrders.add(limitOrder);
    }

    return limitOrders;
  }
View Full Code Here

    BigDecimal amount = order.getAmount();
    String id = Long.toString(order.getId());
    Date date = adaptDate(order.getDate());
    BigDecimal price = order.getPrice();

    return new LimitOrder(orderType, amount, currencyPair, id, date, price);
  }
View Full Code Here

  private static List<LimitOrder> transformArrayToLimitOrders(BigDecimal[][] orders, OrderType orderType, CurrencyPair currencyPair) {

    List<LimitOrder> limitOrders = new ArrayList<LimitOrder>();

    for (BigDecimal[] order : orders) {
      limitOrders.add(new LimitOrder(orderType, order[1], currencyPair, null, new Date(), order[0]));
    }

    return limitOrders;
  }
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.dto.trade.LimitOrder$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.