예제 #1
0
  public FinalRating calculateRating(TuningResDTO tuningRes) {

    int nbSuccess = 0;
    int nbFailure = 0;
    for (PeriodRatingDTO periodRatingDTO : tuningRes.getPeriods()) {
      Validity periodValidity =
          smoothedPeriodValidity(periodRatingDTO, tuningRes.getStockPriceChange());

      // nbSuccess = nbSuccess + ((periodValidity.equals(Validity.SUCCESS))?1:0);
      if (periodRatingDTO
          .getTrend()
          .equals(EventType.BULLISH.toString())) { // we tally only the bullish failures and success
        nbSuccess = nbSuccess + ((periodValidity.equals(Validity.SUCCESS)) ? 1 : 0);
        nbFailure = nbFailure + ((periodValidity.equals(Validity.FAILURE)) ? 1 : 0);
      }
    }

    FinalRating finalRating =
        tuningFinalizationRating(
            tuningRes.getFollowProfit(), tuningRes.getStockPriceChange(), nbSuccess, nbFailure);

    // Test
    // finalRating.validity = Validity.SUCCESS;

    return finalRating;
  }
예제 #2
0
  private void addFilteredPeriod(
      List<PeriodRatingDTO> periods, PeriodRatingDTO period, int sizeConstraint) {

    if ((periods.size() == 0) && EventType.valueOf(period.getTrend()).equals(EventType.BULLISH)) {
      LOGGER.info("First bullish period discarded : " + period);
      return;
    }

    if (sizeConstraint != -1 && period.getPeriodLenght() < sizeConstraint) {
      String invFlasePositiveTrend =
          (EventType.valueOf(period.getTrend()).equals(EventType.BULLISH))
              ? EventType.NONE.toString()
              : EventType.BULLISH.toString();
      LOGGER.info(
          "Period is too short (false positive) : "
              + period
              + ". Trend will be set as "
              + invFlasePositiveTrend);
      period.setTrend(invFlasePositiveTrend);
      if ((periods.size() == 0) && EventType.valueOf(period.getTrend()).equals(EventType.BULLISH)) {
        LOGGER.info("First bullish period discarded : " + period);
        return;
      }
    }

    PeriodRatingDTO previousPeriod;
    if (periods.size() > 0
        && (previousPeriod = periods.get(periods.size() - 1))
            .getTrend()
            .equals(period.getTrend())) {
      previousPeriod.setTo(period.getTo());
      previousPeriod.setPriceAtTo(period.getPriceAtTo());
      previousPeriod.setRealised(period.isRealised());
    } else {
      periods.add(period);
    }
  }