Пример #1
0
 public LocalDate getTradeDate(Earning earning) {
   ANNCMT_TIME anncmtTime = earning.getAnncmtTime();
   switch (anncmtTime) {
     case AFTER_CLOSE:
       return earning.getDate();
     case BEFORE_OPEN:
       return getPreviousTradingDate(earning);
     case DURING_MKT_HRS:
       return getPreviousTradingDate(earning);
     default:
       return null;
   }
 }
Пример #2
0
 private LocalDate getPreviousTradingDate(Earning earning) {
   LocalDate checkDate = earning.getDate().minusDays(1);
   PriceHistory previousPrice = null;
   int daysToGoBack = 5;
   int start = 0;
   while (start <= daysToGoBack && previousPrice == null) {
     start++;
     previousPrice = priceHistoryRepo.findBySymbolAndDate(earning.getSymbol(), checkDate);
     if (previousPrice != null && previousPrice.getDate() != null) {
       return previousPrice.getDate();
     }
     checkDate = checkDate.minusDays(1);
   }
   return null;
 }
  @Override
  protected TaskMetaData process() {
    List<String> allSymb = earnRepo.getAllUniqueSymbol();
    List<String> unCleanSymb = new ArrayList<String>();

    for (String sym : allSymb) {
      List<Earning> allEarningsForSymbol = earnRepo.findBySymbolOrderByDateDesc(sym);
      int i = 0;
      for (Earning earning : allEarningsForSymbol) {

        // Only concerned with earnings for NASDAQ AND NYSE
        if (earning.getSymbol().contains(".")) {
          break;
        }

        if (i == 0) {
          i++;
          continue;
        }

        String currentCompanyName = allEarningsForSymbol.get(i - 1).getCompanyName();
        LocalDate currentEarningDate = allEarningsForSymbol.get(i - 1).getDate();
        i++;

        String historicalCompanyName = earning.getCompanyName();
        LocalDate historicalEarningDate = earning.getDate();

        if (!areEquivalent(currentCompanyName, historicalCompanyName)
            && signDifferenceBetweenEarnings(currentEarningDate, historicalEarningDate)) {
          unCleanSymb.add(earning.getSymbol());
          break;
        }
      }
    }
    return null;
  }