Package com.xeiam.xchange.dto.trade

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


    return limitOrders;
  }

  private static LimitOrder adaptLimitOrder(OrderType type, BigDecimal[] data, CurrencyPair currencyPair, String id, Date timestamp) {

    return new LimitOrder(type, data[1], currencyPair, id, timestamp, data[0]);
  }
View Full Code Here


    return new Trade(trade.getType().equals("buy") ? OrderType.BID : OrderType.ASK, trade.getAmount(), currencyPair, trade.getPrice(), trade.getDate(), "" + trade.getTid());
  }

  private static LimitOrder adaptOpenOrder(OkCoinOrder order) {

    return new LimitOrder(adaptOrderType(order.getType()), order.getAmount().subtract(order.getDealAmount()), adaptSymbol(order.getSymbol()), String.valueOf(order.getOrderId()),
        order.getCreateDate(), order.getRate());
  }
View Full Code Here

    assertEquals(new BigDecimal("760.98"), asks.get(0).getLimitPrice());

    List<LimitOrder> bids = BTCEAdapters.adaptOrders(depthRaw.getBids(), CurrencyPair.BTC_USD, "bid", "");

    // verify all fields filled
    LimitOrder bid1 = bids.get(0);
    assertThat(bid1.getType()).isEqualTo(OrderType.BID);
    assertThat(bid1.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_USD);
    assertThat(bid1.getTimestamp()).isNull();
    assertEquals(new BigDecimal("758.99"), bid1.getLimitPrice());

  }
View Full Code Here

    OpenOrders adaptedOpenOrders = BTERAdapters.adaptOpenOrders(openOrders, currencyPairs);

    List<LimitOrder> adaptedOrderList = adaptedOpenOrders.getOpenOrders();
    assertThat(adaptedOrderList).hasSize(1);

    LimitOrder adaptedOrder = adaptedOrderList.get(0);
    assertThat(adaptedOrder.getType()).isEqualTo(OrderType.ASK);
    assertThat(adaptedOrder.getTradableAmount()).isEqualTo("0.384");
    assertThat(adaptedOrder.getCurrencyPair()).isEqualTo(CurrencyPair.LTC_BTC);
    assertThat(adaptedOrder.getId()).isEqualTo("12941907");
    assertThat(adaptedOrder.getTimestamp()).isNull();
    assertThat(adaptedOrder.getLimitPrice().doubleValue()).isEqualTo(new BigDecimal("0.010176").divide(new BigDecimal("0.384"), RoundingMode.HALF_EVEN).doubleValue());
  }
View Full Code Here

  private static void generic(PollingTradeService tradeService) throws NotAvailableFromExchangeException, NotYetImplementedForExchangeException, IOException {

    printOpenOrders(tradeService);

    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder(Order.OrderType.BID, BigDecimal.ONE, new CurrencyPair(Currencies.GHs, Currencies.BTC), "", null, new BigDecimal("0.00015600"));
    System.out.println("Trying to place: " + limitOrder);
    String orderId = "0";
    try {
      orderId = tradeService.placeLimitOrder(limitOrder);
      System.out.println("New Limit Order ID: " + orderId);
View Full Code Here

  }

  @Test
  public void testAdapter() {

    final LimitOrder limitOrder = JustcoinAdapters.adaptLimitOrder(justcoinOrder);

    assertThat(limitOrder.getId()).isEqualTo(id);
    assertThat(limitOrder.getLimitPrice()).isEqualTo(price);
    assertThat(limitOrder.getTimestamp()).isEqualTo(orderCreatedAt);
    assertThat(limitOrder.getTradableAmount()).isEqualTo(amount);
    assertThat(limitOrder.getCurrencyPair().baseSymbol).isEqualTo(tradableIdentifier);
    assertThat(limitOrder.getCurrencyPair().counterSymbol).isEqualTo(transactionCurrency);
    assertThat(limitOrder.getType()).isEqualTo(OrderType.ASK);
  }
View Full Code Here

  @Test
  public void testAdapter() {

    final OrderBook orderBook = JustcoinAdapters.adaptOrderBook(CurrencyPair.BTC_USD, justcoinDepth);

    final LimitOrder ask = orderBook.getAsks().get(0);
    assertThat(ask.getTradableAmount()).isEqualTo(justcoinDepth.getAsks().get(0).get(1));
    assertThat(ask.getLimitPrice()).isEqualTo(justcoinDepth.getAsks().get(0).get(0));
    final LimitOrder bid = orderBook.getBids().get(0);
    assertThat(bid.getTradableAmount()).isEqualTo(justcoinDepth.getBids().get(0).get(1));
    assertThat(bid.getLimitPrice()).isEqualTo(justcoinDepth.getBids().get(0).get(0));
  }
View Full Code Here

    long startTime = (new Date().getTime() / 1000) - 8 * 60 * 60;
    System.out.println(tradeService.getTradeHistory(currencyPair, startTime));
    long endTime = startTime + 4 * 60 * 60;
    System.out.println(tradeService.getTradeHistory(currencyPair, startTime, endTime));

    LimitOrder order = new LimitOrder.Builder(OrderType.BID, currencyPair).tradableAmount(new BigDecimal(".01")).limitPrice(xmrBuyRate).build();
    String orderId = tradeService.placeLimitOrder(order);
    System.out.println("Placed order #" + orderId);

    Thread.sleep(3000); // wait for order to propagate

View Full Code Here

    long startTime = (new Date().getTime() / 1000) - 8 * 60 * 60;
    System.out.println(Arrays.asList(tradeService.returnTradeHistory(currencyPair, startTime, null)));
    long endTime = new Date().getTime() / 1000;
    System.out.println(Arrays.asList(tradeService.returnTradeHistory(currencyPair, startTime, endTime)));

    LimitOrder order = new LimitOrder.Builder(OrderType.BID, currencyPair).tradableAmount(new BigDecimal("1")).limitPrice(xmrBuyRate).build();
    String orderId = tradeService.buy(order).getOrderNumber().toString();
    System.out.println("Placed order #" + orderId);

    Thread.sleep(3000); // wait for order to propagate

View Full Code Here

    }
    else if (order.getBaseQty().doubleValue() <= 0) {
      type = OrderType.ASK;
    }

    return new LimitOrder(type, order.getBaseQty(), new CurrencyPair(baseCurrency, counterCurrency), String.valueOf(order.getId()), new Date(order.getTime()), order.getPrice());
  }
View Full Code Here

TOP

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

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.