Package com.xeiam.xchange.dto.trade

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


  public static OpenOrders adaptOpenOrders(BTCTradeOrder[] btcTradeOrders) {

    List<LimitOrder> openOrders = new ArrayList<LimitOrder>(btcTradeOrders.length);
    for (BTCTradeOrder order : btcTradeOrders) {
      LimitOrder limitOrder = adaptLimitOrder(order);
      if (limitOrder != null) {
        openOrders.add(limitOrder);
      }
    }
    return new OpenOrders(openOrders);
View Full Code Here


  private static LimitOrder adaptLimitOrder(BTCTradeOrder order) {

    CurrencyPair currencyPair = adaptCurrencyPair(order.getCoin());

    final LimitOrder limitOrder;
    if (currencyPair == null) {
      // Unknown currency pair
      limitOrder = null;
    }
    else {
      limitOrder = new LimitOrder(adaptOrderType(order.getType()), order.getAmountOutstanding(), currencyPair, order.getId(), adaptDatetime(order.getDatetime()), order.getPrice());
    }

    return limitOrder;
  }
View Full Code Here

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

    if (sellOrders != null) {
      for (CryptsySellOrder order : sellOrders) {

        limitOrders.add(new LimitOrder(OrderType.ASK, order.getQuantity(), currencyPair, null, null, order.getSellPrice()));
      }
    }

    return limitOrders;
  }
View Full Code Here

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

    if (buyOrders != null) {
      for (CryptsyBuyOrder order : buyOrders) {

        limitOrders.add(new LimitOrder(OrderType.BID, order.getQuantity(), currencyPair, null, null, order.getBuyPrice()));
      }
    }

    return limitOrders;
  }
View Full Code Here

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

    if (orders != null) {
      for (CryptsyPublicOrder order : orders) {

        limitOrders.add(new LimitOrder(orderType, order.getQuantity(), currencyPair, null, null, order.getPrice()));
      }
    }

    return limitOrders;
  }
View Full Code Here

    if (cryptsyOpenOrders != null) {
      for (CryptsyOpenOrders order : cryptsyOpenOrders) {

        OrderType orderType = order.getTradeType() == CryptsyOrderType.Buy ? OrderType.BID : OrderType.ASK;

        limitOrders.add(new LimitOrder(orderType, order.getQuantityRemaining(), CryptsyCurrencyUtils.convertToCurrencyPair(order.getMarketId()), String.valueOf(order.getOrderId()), order
            .getTimestamp(), order.getPrice()));

      }
    }
    return new OpenOrders(limitOrders);
View Full Code Here

    PollingTradeService tradeService = campbx.getPollingTradeService();

    printOpenOrders(tradeService);

    LimitOrder lo = new LimitOrder((OrderType.ASK), new BigDecimal("0.1"), CurrencyPair.BTC_USD, "", null, new BigDecimal("28.99"));
    String rv = tradeService.placeLimitOrder(lo);
    System.out.println("Limit Order return value: " + rv);
    // place a limit sell order
    LimitOrder limitOrder = new LimitOrder((OrderType.ASK), new BigDecimal("0.1"), CurrencyPair.BTC_USD, "", null, new BigDecimal("110"));
    String limitOrderReturnValue = tradeService.placeLimitOrder(limitOrder);
    System.out.println("Limit Order return value: " + limitOrderReturnValue);

    printOpenOrders(tradeService);
View Full Code Here

    // subscribe to orderbook
    ((CoinfloorStreamingExchangeService) streamingExchangeService).watchOrders("BTC", "GBP");
    TimeUnit.MILLISECONDS.sleep(1000);

    // send two orders, that will (partially) fulfill each other, to generate a trade.
    LimitOrder buyLimitOrder = new LimitOrder(OrderType.BID, new BigDecimal(1), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(320));
    ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(buyLimitOrder);
    TimeUnit.MILLISECONDS.sleep(1000);

    LimitOrder sellLimitOrder = new LimitOrder(OrderType.ASK, new BigDecimal(1.52321512784), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(319));
    ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(sellLimitOrder);
    TimeUnit.MILLISECONDS.sleep(1000);

    // then send another order, that will never be fulfilled
    LimitOrder bigLimitOrder = new LimitOrder(OrderType.ASK, new BigDecimal(1.152), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(500));
    ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(bigLimitOrder);
    TimeUnit.MILLISECONDS.sleep(1000);

    // request outcome of theoretical marketOrder
    MarketOrder estMarketOrder = new MarketOrder(OrderType.ASK, new BigDecimal(1), new CurrencyPair("BTC", "GBP"));
View Full Code Here

      System.out.println("Order " + o.getId() + " .. cancelling!");
      System.out.println(trades.cancelOrder(o.getId()));

    }

    String placeLimitOrder1 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(300)));
    String placeLimitOrder2 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(350)));
    String placeLimitOrder3 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(360)));
    String placeLimitOrder4 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(370)));

    System.out.println("limit order id " + placeLimitOrder1);
    System.out.println("limit order id " + placeLimitOrder2);
    System.out.println("limit order id " + placeLimitOrder3);
    System.out.println("limit order id " + placeLimitOrder4);

    trades.placeLimitOrder(new LimitOrder(OrderType.ASK, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(770)));

    System.out.println("Cancelling " + placeLimitOrder1);
    trades.cancelOrder(placeLimitOrder1);

    Trades tradeHistory = trades.getTradeHistory();
View Full Code Here

            TimeUnit.MILLISECONDS.sleep((startTime + 500) - System.currentTimeMillis());
          } catch (InterruptedException e) {
          }

          // send two orders, that will (partially) fulfill each other, to generate a trade.
          LimitOrder buyLimitOrder = new LimitOrder(OrderType.BID, new BigDecimal(1), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(3.20));
          resultMap = ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(buyLimitOrder).getPayload();
          System.out.println("\n\n\n\n\nBuy Limit Order Placed: ");
          System.out.println("Raw Object: " + resultMap.get("raw"));
          System.out.println("Generic Object: " + resultMap.get("generic"));
          try {
            TimeUnit.MILLISECONDS.sleep(1000);
          } catch (InterruptedException e) {
          }

          // check for new balance before submitting second order
          System.out.println("\n\n\n\n\nCached Account Info: ");
          System.out.println(((CoinfloorStreamingExchangeService) streamingExchangeService).getCachedAccountInfo());

          LimitOrder sellLimitOrder = new LimitOrder(OrderType.ASK, new BigDecimal(1.52321512784), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(3.19));
          resultMap = ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(sellLimitOrder).getPayload();
          System.out.println("\n\n\n\n\nSell Limit Order Placed: ");
          System.out.println("Raw Object: " + resultMap.get("raw"));
          System.out.println("Generic Object: " + resultMap.get("generic"));
          try {
            TimeUnit.MILLISECONDS.sleep(1000);
          } catch (InterruptedException e) {
          }

          // check for new balance again
          System.out.println("\n\n\n\n\nCached Account Info: ");
          System.out.println(((CoinfloorStreamingExchangeService) streamingExchangeService).getCachedAccountInfo());

          // then send another order, that will never be fulfilled
          LimitOrder bigLimitOrder = new LimitOrder(OrderType.ASK, new BigDecimal(1.152), new CurrencyPair("BTC", "GBP"), null, null, new BigDecimal(500));
          resultMap = ((CoinfloorStreamingExchangeService) streamingExchangeService).placeOrder(bigLimitOrder).getPayload();
          System.out.println("\n\n\n\n\nBig Limit Order Placed: ");
          System.out.println("Raw Object: " + resultMap.get("raw"));
          System.out.println("Generic Object: " + resultMap.get("generic"));
          try {
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.