예제 #1
0
  public List<StockInfo> findStockInfoBtw(StockInfo stock, int previousDays, int followingDays) {
    LinkedList<StockInfo> selected = new LinkedList<>();
    int beginIndex = 0;
    List<StockInfo> stocks = getStocks(stock.getTicker());
    for (int i = 0; i < stocks.size(); i++) {
      if (stocks.get(i).getTradeDate().equals(stock.getTradeDate())) {
        beginIndex = i;
        selected.add(stocks.get(beginIndex));
        break;
      }
    }

    for (int i = 1; i <= previousDays; i++) {
      StockInfo addingStock = null;
      try {
        addingStock = stocks.get(beginIndex + i);
        selected.addFirst(addingStock);
      } catch (Exception e) {

      }
    }
    for (int i = 1; i <= followingDays; i++) {
      StockInfo addingStock = null;
      try {
        addingStock = stocks.get(beginIndex - i);
      } catch (Exception e) {

      }
      selected.addLast(addingStock);
    }
    return selected;
  }
예제 #2
0
 public List<StockInfo> findLimitUpStocksOn(String date) {
   List<StockInfo> list = new ArrayList<>();
   for (Map.Entry<String, List<StockInfo>> entry : cache.entrySet()) {
     for (StockInfo stock : entry.getValue()) {
       if (stock.getTradeDate().equals(date) && stock.isLimitUp()) {
         list.add(stock);
       }
     }
   }
   return list;
 }