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

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


        send(jsonObjectMapper.writeValueAsString(requestObject));
      } catch (JsonProcessingException e) {
        throw new ExchangeException("Cannot convert Object to String", e);
      }

      CoinfloorExchangeEvent nextEvent = checkNextSystemEvent();
      while (!nextEvent.getEventType().equals(expectedEventType) || nextEvent.getTag() != requestObject.getTag()) {
        switch (nextEvent.getEventType()) {
        case USER_WALLET_UPDATE:
        case ORDER_ADDED:
        case TRADE:
        case ORDER_CANCELED:
        case TICKER:
View Full Code Here


    return (CoinfloorExchangeEvent) super.getNextEvent();
  }

  public CoinfloorExchangeEvent getNextSystemEvent() throws InterruptedException {

    CoinfloorExchangeEvent event = (CoinfloorExchangeEvent) systemEventQueue.take();
    return event;
  }
View Full Code Here

      synchronized (systemEventQueue) {
        if (systemEventQueue.isEmpty()) {
          systemEventQueue.wait();
        }
      }
      CoinfloorExchangeEvent event = (CoinfloorExchangeEvent) systemEventQueue.peek();
      if (event == null) {
        continue;
      }
      return event;
    }
View Full Code Here

    }
    CoinfloorUtils.checkSuccess(jsonData);
    if (jsonData.containsKey("tag")) {
      switch (((Integer) jsonData.get("tag") & (1 << 10) - 1)) {
      case 1:
        CoinfloorExchangeEvent authenticationEvent = new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.AUTHENTICATION, event.getData(), jsonData);
        addToEventQueue(authenticationEvent);
        break;
      case 101:
        CoinfloorExchangeEvent getBalancesEvent =
            new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_WALLET, event.getData(), coinfloorAdapters.adaptBalances(event.getData()));
        addToEventQueue(getBalancesEvent);
        break;
      case 102:
      case 103:
        CoinfloorExchangeEvent getTradeVolumeEvent =
            new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_TRADE_VOLUME, event.getData(), coinfloorAdapters.adaptTradeVolume(event.getData()));
        addToEventQueue(getTradeVolumeEvent);
        break;
      case 201:
        CoinfloorExchangeEvent watchOrdersReturn =
            new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.SUBSCRIBE_ORDERS, event.getData(), coinfloorAdapters.adaptOrders(event.getData()));
        addToEventQueue(watchOrdersReturn);
        break;
      case 202:
        CoinfloorExchangeEvent watchTickerReturn =
            new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.SUBSCRIBE_TICKER, event.getData(), coinfloorAdapters.adaptTicker(event.getData()));
        addToEventQueue(watchTickerReturn);
        break;
      case 301:
        CoinfloorExchangeEvent getOpenOrdersReturn =
            new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_ORDERS_LIST, event.getData(), coinfloorAdapters.adaptOpenOrders(event.getData()));
        addToEventQueue(getOpenOrdersReturn);
        break;
      case 302:
        CoinfloorExchangeEvent placeOrderReturn =
            new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_ORDER, event.getData(), coinfloorAdapters.adaptPlaceOrder(event.getData()));
        addToEventQueue(placeOrderReturn);
        break;
      case 303:
        CoinfloorExchangeEvent cancelOrderReturn =
            new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_ORDER_CANCELED, event.getData(), coinfloorAdapters.adaptCancelOrder(event.getData()));
        addToEventQueue(cancelOrderReturn);
        break;
      case 304:
        CoinfloorExchangeEvent estMarketOrderReturn =
            new CoinfloorExchangeEvent((Integer) jsonData.get("tag"), ExchangeEventType.USER_MARKET_ORDER_EST, event.getData(), coinfloorAdapters.adaptEstimateMarketOrder(event.getData()));
        addToEventQueue(estMarketOrderReturn);
        break;
      }
    }
    else if (jsonData.containsKey("notice")) {
      if (jsonData.get("notice").equals("Welcome")) {
        CoinfloorExchangeEvent welcomeEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.WELCOME, event.getData(), jsonData);
        addToEventQueue(welcomeEvent);

        serverNonce = (String) jsonData.get("nonce");
      }
      else if (jsonData.get("notice").equals("BalanceChanged")) {
        CoinfloorExchangeEvent balancesChangedEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.USER_WALLET_UPDATE, event.getData(), coinfloorAdapters.adaptBalancesChanged(event.getData()));
        addToEventQueue(balancesChangedEvent);
      }
      else if (jsonData.get("notice").equals("OrderOpened")) {
        CoinfloorExchangeEvent orderOpenedEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.ORDER_ADDED, event.getData(), coinfloorAdapters.adaptOrderOpened(event.getData()));
        addToEventQueue(orderOpenedEvent);
      }
      else if (jsonData.get("notice").equals("OrdersMatched")) {
        CoinfloorExchangeEvent tradeEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.TRADE, event.getData(), coinfloorAdapters.adaptOrdersMatched(event.getData()));
        addToEventQueue(tradeEvent);
      }
      else if (jsonData.get("notice").equals("OrderClosed")) {
        CoinfloorExchangeEvent orderClosedEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.ORDER_CANCELED, event.getData(), coinfloorAdapters.adaptOrderClosed(event.getData()));
        addToEventQueue(orderClosedEvent);
      }
      else if (jsonData.get("notice").equals("TickerChanged")) {
        CoinfloorExchangeEvent tickerChangedEvent = new CoinfloorExchangeEvent(0, ExchangeEventType.TICKER, event.getData(), coinfloorAdapters.adaptTickerUpdate(event.getData()));
        addToEventQueue(tickerChangedEvent);
      }
    }
    else {
      log.warn("Exchange returned unexpected event: " + event.toString());
View Full Code Here

      try {

        while (true) {

          CoinfloorExchangeEvent exchangeEvent = ((CoinfloorStreamingExchangeService) streamingExchangeService).getNextEvent();
          System.out.print("\n\n\n\n\n" + new Date() + ":\n");

          switch (exchangeEvent.getEventType()) {
          case AUTHENTICATION:
            System.out.println("Authentication Successful. Server's return: " + exchangeEvent.getData());
            break;

          case USER_WALLET:
            System.out.println("User balances returned: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case USER_TRADE_VOLUME:
            System.out.println("User's trade volume returned: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case SUBSCRIBE_ORDERS:
            System.out.println("Successfully subscribed/unsubscribed to order feed: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case SUBSCRIBE_TICKER:
            System.out.println("Successfully subscribed/unsubscribed to ticker feed: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case USER_ORDERS_LIST:
            System.out.println("User's open orders returned: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case USER_ORDER:
            System.out.println("Successfully placed a new order: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case USER_ORDER_CANCELED:
            System.out.println("Successfully canceled an order: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case USER_MARKET_ORDER_EST:
            System.out.println("Estimated market order result returned: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case USER_WALLET_UPDATE:
            System.out.println("User Balances updated: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case ORDER_ADDED:
            System.out.println("Order added to orderbook: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case TRADE:
            System.out.println("Trade occurred: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case ORDER_CANCELED:
            System.out.println("Order removed from orderbook: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          case TICKER:
            System.out.println("Ticker updated: ");
            System.out.println("Raw Object: " + exchangeEvent.getPayloadItem("raw"));
            System.out.println("Generic Object: " + exchangeEvent.getPayloadItem("generic"));
            break;

          default:
            break;
          }
View Full Code Here

TOP

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

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.