Package com.xeiam.xchange.dto.trade

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


    String ipAddress = args[2];

    Exchange coinsetter = CoinsetterExamplesUtils.getExchange(username, password, ipAddress);
    PollingTradeService tradeService = coinsetter.getPollingTradeService();

    String orderId = tradeService.placeLimitOrder(new LimitOrder(OrderType.BID, new BigDecimal("0.01"), CurrencyPair.BTC_USD, null, null, new BigDecimal("0.01")));
    log.info("limit order id: {}", orderId);

    OpenOrders openOrders = tradeService.getOpenOrders();
    log.info("open orders: {}", openOrders);
View Full Code Here


  public static void raw() throws IOException, InterruptedException {

    printOpenOrdersRaw();

    // place a limit buy order
    LimitOrder limitOrder = new LimitOrder((OrderType.BID), BigDecimal.ONE, CurrencyPair.BTC_CNY, "", null, new BigDecimal("0.01"));
    BTCChinaIntegerResponse limitOrderReturnValue = ((BTCChinaTradeServiceRaw) tradeService).buy(new BigDecimal("0.01"), BigDecimal.ONE, "BTCCNY");
    System.out.println("Limit Order return value: " + limitOrderReturnValue);

    Thread.sleep(1500);
    BTCChinaResponse<BTCChinaOrders> openOrders = printOpenOrdersRaw();

    long result = -1;
    for (int i = 0; i < openOrders.getResult().getOrders().size(); i++) {
      BTCChinaOrder order = openOrders.getResult().getOrders().get(i);
      int orderId = order.getId();
      if (order.getType().equals(limitOrder.getType().toString()) && order.getPrice().compareTo(limitOrder.getLimitPrice()) == 0 && orderId > result) {
        result = orderId;
      }
    }

    // Cancel the added order
View Full Code Here

    raw((BTERPollingTradeServiceRaw) tradeService);
  }

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

    LimitOrder limitOrder = new LimitOrder(OrderType.ASK, new BigDecimal("0.384"), CurrencyPair.LTC_BTC, "", null, new BigDecimal("0.0265"));
    String orderId = tradeService.placeLimitOrder(limitOrder);
    System.out.println(orderId); // Returned order id is currently broken for BTER, rely on open orders instead for demo :(

    Thread.sleep(2000); // wait for BTER's back-end to propagate the order
View Full Code Here

    // place a limit order for a random amount of BTC at USD 1.25
    OrderType orderType = (OrderType.ASK);
    BigDecimal tradeableAmount = new BigDecimal("2");
    BigDecimal limitPrice = new BigDecimal("921");

    LimitOrder limitOrder = new LimitOrder(orderType, tradeableAmount, CurrencyPair.BTC_USD, "", null, limitPrice);

    String orderID = tradeService.placeLimitOrder(limitOrder);
    System.out.println("Limit Order ID: " + orderID);

    // get open orders
View Full Code Here

  }

  private static void raw(Exchange bfx) throws IOException {

    BitfinexTradeServiceRaw tradeService = (BitfinexTradeServiceRaw) bfx.getPollingTradeService();
    LimitOrder limitOrder = new LimitOrder.Builder(OrderType.BID, CurrencyPair.BTC_USD).limitPrice(new BigDecimal("481.69")).tradableAmount(new BigDecimal("0.001")).build();
    tradeService.placeBitfinexLimitOrder(limitOrder, BitfinexOrderType.LIMIT, false);
  }
View Full Code Here

    OrderBook adaptedOrderBook = BitKonanAdapters.adaptOrderBook(orderBook);

    List<LimitOrder> asks = adaptedOrderBook.getAsks();
    assertThat(asks.size()).isEqualTo(10);
    LimitOrder order = asks.get(0);
    assertThat(order.getLimitPrice()).isEqualTo("347.89");
    assertThat(order.getTradableAmount()).isEqualTo("0.46557");
    assertThat(order.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_USD);
  }
View Full Code Here

    List<LimitOrder> limitOrders = new ArrayList<LimitOrder>();
    for (BitstampOrder bitstampOrder : openOrders) {
      OrderType orderType = bitstampOrder.getType() == 0 ? OrderType.BID : OrderType.ASK;
      String id = Integer.toString(bitstampOrder.getId());
      BigDecimal price = bitstampOrder.getPrice();
      limitOrders.add(new LimitOrder(orderType, bitstampOrder.getAmount(), CurrencyPair.BTC_USD, id, bitstampOrder.getTime(), price));
    }
    return new OpenOrders(limitOrders);
  }
View Full Code Here

    OpenOrders openOrders = BTCTradeAdapters.adaptOpenOrders(btcTradeOrders);
    List<LimitOrder> openOrderList = openOrders.getOpenOrders();
    assertEquals(2, openOrderList.size());

    LimitOrder order = openOrderList.get(0);
    assertEquals(CurrencyPair.LTC_CNY, order.getCurrencyPair());
    assertEquals("16636810", order.getId());
    assertEquals(new BigDecimal("1.01"), order.getLimitPrice());
    // 2014-09-14 12:48:53 Asia/Shanghai
    assertEquals(1410670133000L, order.getTimestamp().getTime());
    assertEquals(new BigDecimal("0.1"), order.getTradableAmount());
    assertEquals(OrderType.BID, order.getType());

    order = openOrderList.get(1);
    assertEquals(CurrencyPair.BTC_CNY, order.getCurrencyPair());
    assertEquals("16634460", order.getId());
    assertEquals(new BigDecimal("10.01"), order.getLimitPrice());
    // 2014-09-14 12:31:46 Asia/Shanghai
    assertEquals(1410669106000L, order.getTimestamp().getTime());
    assertEquals(new BigDecimal("0.01"), order.getTradableAmount());
    assertEquals(OrderType.BID, order.getType());
  }
View Full Code Here

    OrderBook adaptedOrderBook = HitbtcAdapters.adaptOrderBook(orderBook, CurrencyPair.BTC_USD);

    List<LimitOrder> asks = adaptedOrderBook.getAsks();
    assertThat(asks.size()).isEqualTo(3);
    LimitOrder order = asks.get(0);
    assertThat(order.getLimitPrice()).isEqualTo("609.58");
    assertThat(order.getTradableAmount()).isEqualTo("1.23");
    assertThat(order.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_USD);
  }
View Full Code Here

public class HitbtcTradeServiceRawTest {

  @Test
  public void testReadSymbol() throws Exception {

    String id = HitbtcTradeServiceRawPublic.createId(new LimitOrder(Order.OrderType.ASK, BigDecimal.ONE, CurrencyPair.BTC_EUR, null, null, BigDecimal.ONE), 0);
    assertEquals("BTCEUR", HitbtcTradeServiceRawPublic.readSymbol(id));
    assertEquals(Order.OrderType.ASK, HitbtcTradeServiceRawPublic.readOrderType(id));
  }
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.