コード例 #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);
      }
    }
  }
コード例 #2
0
  public void insertSymbolList() {
    ArrayList<String> lists = new ArrayList<String>();
    lists.add("SNP.csv");
    lists.add("DOW.csv");
    lists.add("NASDAQ_TOP200.csv");
    File listRoot = new File(ListRoot);

    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 remark = listFile.split("\\.")[0];
        String line = null;
        ArrayList<String> symbols = new ArrayList<String>();
        while ((line = reader.readLine()) != null) {
          symbols.add(line.trim());
        }

        DatabaseAccessor.getInstance().importSymbolInfo(symbols, remark);

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

    System.out.println("Finished");
  }
コード例 #3
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);
      }
    }
  }