Examples of ITickPoint


Examples of com.quantcomponents.marketdata.ITickPoint

            } catch (Throwable t) {
              // burp!
            }
          }
          if (notifyTickListener) {
            ITickPoint tick = new TickPoint(point.getIndex(), DATA_TYPES[0], point.getClose(), point.getVolume().intValue());
            try {
              tickListener.onTick(tick);;
            } catch (Throwable t) {
              // burp!
            }
View Full Code Here

Examples of com.quantcomponents.marketdata.ITickPoint

        @Override
        public void tickSize(int reqId, int field, int size) {
          if (reqId == getPendingReqId()) {
            Date timestamp = new Date();
            ITickPoint tick = null;
            switch (field) {
            case TickType.ASK_SIZE:
              if (lastAskPrice != null) {
                tick = new TickPoint(timestamp, DataType.ASK, lastAskPrice, size);
              }
              break;
            case TickType.BID_SIZE:
              if (lastBidPrice != null) {
                tick = new TickPoint(timestamp, DataType.BID, lastBidPrice, size);
              }
              break;
            case TickType.LAST_SIZE:
              if (lastTradePrice != null) {
                tick = new TickPoint(timestamp, DataType.TRADES, lastTradePrice, size);
              }
              break;
            case TickType.VOLUME:
              // not enough information to be useful
            }
            if (tick != null) {
              final ITickPoint constantTick = tick;
              threadPool.execute(new Runnable() {
                @Override
                public void run() {
                  for (ITickListener listener : currentListeners) {
                    try {
                      listener.onTick(constantTick);
                    } catch (Throwable t) {
                      logger.log(Level.SEVERE, "Excetion while dispatching size tick", t);
                    }
                  }
                }});
            }
          }
        }

        @Override
        public void tickPrice(int reqId, int field, double price, int canAutoExecute) {
          if (reqId == getPendingReqId()) {
            Date timestamp = new Date();
            ITickPoint tick = null;
            ITickPoint midTick = null;
            switch (field) {
            case TickType.ASK:
              lastAskPrice = price;
              tick = new TickPoint(timestamp, DataType.ASK, lastAskPrice, 0);
              midTick = new TickPoint(timestamp, DataType.MIDPOINT, lastBidPrice != null ? (lastBidPrice + lastAskPrice) / 2 : lastAskPrice, 0);
              break;
            case TickType.BID:
              lastBidPrice = price;
              tick = new TickPoint(timestamp, DataType.BID, lastBidPrice, 0);
              midTick = new TickPoint(timestamp, DataType.MIDPOINT, lastAskPrice != null ? (lastBidPrice + lastAskPrice) / 2 : lastBidPrice, 0);
              break;
            case TickType.LAST:
            case TickType.OPEN:
            case TickType.CLOSE:
              tick = new TickPoint(timestamp, DataType.TRADES, price, 0);
              lastTradePrice = price;
              break;
            }
            if (tick != null) {
              final ITickPoint constantTick = tick;
              final ITickPoint constantMidTick = midTick;
              threadPool.execute(new Runnable() {
                @Override
                public void run() {
                  for (ITickListener listener : currentListeners) {
                    listener.onTick(constantTick);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.