Package com.quantcomponents.marketdata

Examples of com.quantcomponents.marketdata.TickPoint


    while (rs.next()) {
      Date date = new Date(rs.getTimestamp(1).getTime());
      DataType dataType = DataType.valueOf(rs.getString(2));
      Double price = rs.getDouble(3);
      Integer size = rs.getInt(4);
      TickPoint point = new TickPoint(date, dataType, price, size);
      result.add(point);
    }
    rs.close();
    return result;
  }
View Full Code Here


            } 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

            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;
View Full Code Here

TOP

Related Classes of com.quantcomponents.marketdata.TickPoint

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.