示例#1
0
  public void insertHistoricalQuotes(String fromDate, String toDate) {
    ArrayList<String> lists = new ArrayList<String>();
    HashSet<String> processed_symbols = new HashSet<String>();
    lists.add("SNP.csv");
    lists.add("DOW.csv");
    lists.add("NASDAQ_TOP200.csv");
    File listRoot = new File(ListRoot);
    YahooDataPuller quotePuller = new YahooDataPuller();

    for (String listFile : lists) {
      File full = new File(listRoot, listFile);

      Path path = Paths.get(full.getPath());
      logger.info("------------ Pulling Data From List File: " + listFile + " -------------------");
      try {
        BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
        String line = null;

        while ((line = reader.readLine()) != null) {
          String symbol = line.trim();
          if (processed_symbols.contains(symbol)) continue;
          logger.info(
              "--------- Inserting Historical Quotes for [" + symbol + "]------------------");
          quotePuller.importDataIntoDB(fromDate, toDate, symbol, TickDataRoot);
          processed_symbols.add(symbol);
        }

        reader.close();
        logger.info("Finished inserting all historical quotes");
      } catch (IOException e) {
        e.printStackTrace();
        logger.warning("Failed to read file: " + listFile);
      }
    }
  }
示例#2
0
  public void pullAllHistoricalData(String fromDate, String toDate) {
    ArrayList<String> lists = new ArrayList<String>();
    lists.add("SNP.csv");
    lists.add("DOW.csv");
    lists.add("NASDAQ_TOP200.csv");
    File listRoot = new File(ListRoot);
    YahooDataPuller quotePuller = new YahooDataPuller();
    EarningsDataPuller earningPuller = new EarningsDataPuller();

    for (String listFile : lists) {
      File full = new File(listRoot, listFile);

      Path path = Paths.get(full.getPath());
      logger.info("------------ Pulling Data From List File: " + listFile + " -------------------");
      try {
        BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
        String line = null;

        while ((line = reader.readLine()) != null) {
          String symbol = line.trim();
          logger.info(
              "--------- Pulling All Historical Data for [" + symbol + "]------------------");
          quotePuller.pullData(fromDate, toDate, symbol, TickDataRoot);
          earningPuller.pullEarningsForSymbol(symbol, EarningsRoot);

          try {
            Thread.sleep(PullIntervalMs);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
        }

        reader.close();
      } catch (IOException e) {
        e.printStackTrace();
        logger.warning("Failed to read file: " + listFile);
      }
    }
  }