Esempio n. 1
0
  public void insertEarningForTag(String tag) {
    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);
    EarningsDataPuller puller = 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();
          if (processed_symbols.contains(symbol)) continue;
          logger.info("--------- Inserting Earning for [" + symbol + "]------------------");
          puller.importDataIntoDB(symbol, tag, EarningsRoot);
          processed_symbols.add(symbol);
        }

        reader.close();
        logger.info("Finished inserting all earning events");
      } catch (IOException e) {
        e.printStackTrace();
        logger.warning("Failed to read file: " + listFile);
      }
    }
  }
Esempio n. 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);
      }
    }
  }