Package com.xeiam.xchange.coinfloor.dto.streaming

Examples of com.xeiam.xchange.coinfloor.dto.streaming.CoinfloorOrder


  public Map<String, Object> adaptOrderOpened(String data) {

    Map<String, Object> resultMap = new HashMap<String, Object>();

    CoinfloorOrder rawRetObj;
    try {
      rawRetObj = streamObjectMapper.readValue(data, CoinfloorOrder.class);
    } catch (IOException e) {
      throw new ExchangeException("JSON parse error", e);
    }

    synchronized (cachedDataSynchronizationObject) {
      List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
      List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
      if (rawRetObj.getBaseQty().doubleValue() > 0) {
        bidList.add(adaptOrder(rawRetObj));
      }
      else {
        askList.add(adaptOrder(rawRetObj));
      }
View Full Code Here


  public Map<String, Object> adaptOrderClosed(String data) {

    Map<String, Object> resultMap = new HashMap<String, Object>();

    CoinfloorOrder rawRetObj;
    try {
      rawRetObj = streamObjectMapper.readValue(data, CoinfloorOrder.class);
    } catch (IOException e) {
      throw new ExchangeException("JSON parse error", e);
    }

    synchronized (cachedDataSynchronizationObject) {
      List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
      List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
      if (rawRetObj.getBaseQty().doubleValue() > 0) {
        for (int i = 0; i < bidList.size(); i++) {
          if (bidList.get(i).getId().equals(String.valueOf(rawRetObj.getId()))) {
            bidList.remove(i);
            break;
          }
        }
      }
      else {
        for (int i = 0; i < askList.size(); i++) {
          if (askList.get(i).getId().equals(String.valueOf(rawRetObj.getId()))) {
            askList.remove(i);
            break;
          }
        }
      }
View Full Code Here

  public Map<String, Object> adaptOrdersMatched(String data) {

    Map<String, Object> resultMap = new HashMap<String, Object>();

    CoinfloorOrder rawRetObj;
    try {
      rawRetObj = streamObjectMapper.readValue(data, CoinfloorOrder.class);
    } catch (IOException e) {
      throw new ExchangeException("JSON parse error", e);
    }

    Trade trade;

    synchronized (cachedDataSynchronizationObject) {
      List<LimitOrder> bidList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getBids());
      List<LimitOrder> askList = (cachedOrderBook == null ? new ArrayList<LimitOrder>() : cachedOrderBook.getAsks());
      if (rawRetObj.getBidId() != 0) {
        for (int i = 0; i < bidList.size(); i++) {
          if (bidList.get(i).getId().equals(String.valueOf(rawRetObj.getBidId()))) {
            bidList.remove(i);
            break;
          }
        }
      }
      if (rawRetObj.getAskId() != 0) {
        for (int i = 0; i < askList.size(); i++) {
          if (askList.get(i).getId().equals(String.valueOf(rawRetObj.getAskId()))) {
            askList.remove(i);
            break;
          }
        }
      }
      cachedOrderBook = new OrderBook(new Date(), askList, bidList);

      OrderType type = (rawRetObj.getBidId() > rawRetObj.getAskId() ? OrderType.BID : OrderType.ASK);
      BigDecimal limitPrice = rawRetObj.getPrice();

      trade =
          new Trade(type, rawRetObj.getBaseQty(), new CurrencyPair(rawRetObj.getBase().toString(), rawRetObj.getCounter().toString()), limitPrice, new Date(), String.valueOf(rawRetObj.getId()));

      List<Trade> newTradesList = (cachedTrades == null ? new ArrayList<Trade>() : cachedTrades.getTrades());
      newTradesList.add(trade);

      Trades newCachedTrades = new Trades(newTradesList, TradeSortType.SortByID);
View Full Code Here

TOP

Related Classes of com.xeiam.xchange.coinfloor.dto.streaming.CoinfloorOrder

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.