Examples of IOHLCPoint


Examples of com.quantcomponents.marketdata.IOHLCPoint

    List<IOHLCPoint> points = new LinkedList<IOHLCPoint>();
    DateFormat dateFormat = new SimpleDateFormat(YAHOO_STOCK_PRICES_DATE_FORMAT);
    for (int lineNo = lines.length - 1; lineNo > 0; lineNo--) { // Yahoo! returns prices in reverse chronological order
      try {
        logger.log(Level.INFO, "Processing line " + lineNo + ": " + lines[lineNo]);
        IOHLCPoint point = parsePriceLine(lines[lineNo], barSize, dateFormat);
        logger.log(Level.INFO, "Adding point" + point);
        points.add(point);
      } catch (ParseException e) {
        throw new RequestFailedException("Error while parsing line: " + lineNo, e);
      }
View Full Code Here

Examples of com.quantcomponents.marketdata.IOHLCPoint

    int currentPeriod = 0;
    for (ISeriesPoint<Date, Double> point : timeSeries) {
      if (currentPeriod >= actualNumberOfPeriods) {
        break;
      }
      IOHLCPoint bar = (IOHLCPoint) point;
      totalSum += bar.getClose();
      currentPeriod++;
    }
    result = totalSum / currentPeriod;
    return result; // it must never be called with 0 periods
  }
View Full Code Here

Examples of com.quantcomponents.marketdata.IOHLCPoint

      @Override
      public void run() {
        Random random = new Random();
        double lastClose = AVERAGE_PRICE;
        while (activated) {
          IOHLCPoint point = generateRandomPoint(random, lastClose, VOL_PRICE, AVERAGE_VOLUME, VOL_VOLUME, new Date());
          lastClose = point.getClose();
          if (notifyBarListener) {
            try {
              barListener.onRealTimeBar(point);
            } 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.IOHLCPoint

    cal.setTime(startDateTime);
    Random random = new Random();
    List<IOHLCPoint> points = new LinkedList<IOHLCPoint>();
    double lastClose = AVERAGE_PRICE;
    for (Date t = cal.getTime(); t.before(endDateTime); t = new Date(t.getTime() + barSize.getDurationInMs())) {
      IOHLCPoint point = generateRandomPoint(random, lastClose, VOL_PRICE, AVERAGE_VOLUME, VOL_VOLUME, t);
      points.add(point);
      lastClose = point.getClose();
    }
    return points;
  }
View Full Code Here

Examples of com.quantcomponents.marketdata.IOHLCPoint

    }

    logger.log(Level.INFO, "All data downloaded. Create time series: " + new Date()); // TODO: remove
    List<IOHLCPoint> result = new ArrayList<IOHLCPoint>();

    IOHLCPoint lastBarAdded = null;
    Date dateOfLastBarAdded = new Date(0L);
    for (List<IOHLCPoint> partialResult : tmpResults) {

      if (taskMonitor != null && taskMonitor.isCancelled()) {
        throw new RequestFailedException("Request cancelled by user");
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.