Ejemplo n.º 1
0
  public TuningResDTO buildTuningRes(
      Stock stock,
      Date startDate,
      Date endDate,
      Date endCalcRes,
      String analyseName,
      SortedMap<Date, double[]> calcOutput,
      Collection<EventValue> eventListForEvtDef,
      String noResMsg,
      String evtDefInfo,
      Observer observer)
      throws IOException, NoQuotationsException, NotEnoughDataException,
          InvalidAlgorithmParameterException {

    LOGGER.info(
        "Building Tuning res for "
            + stock.getFriendlyName()
            + " and "
            + evtDefInfo
            + " between "
            + startDate
            + " and "
            + endDate
            + ", end calculation res is "
            + endCalcRes);

    Quotations quotations =
        QuotationsFactories.getFactory()
            .getQuotationsInstance(
                stock,
                startDate,
                endCalcRes,
                true,
                stock.getMarketValuation().getCurrency(),
                1,
                ValidityFilter.CLOSE);
    SortedMap<Date, Number> mapFromQuotationsClose =
        QuotationsFactories.getFactory()
            .buildExactBMapFromQuotations(
                quotations, QuotationDataType.CLOSE, 0, quotations.size() - 1);
    LOGGER.info(
        "Quotations map for "
            + stock.getFriendlyName()
            + " ranges from "
            + mapFromQuotationsClose.firstKey()
            + " to "
            + mapFromQuotationsClose.lastKey()
            + " while requested from "
            + startDate
            + " to "
            + endCalcRes);

    List<PeriodRatingDTO> periods =
        validPeriods(
            mapFromQuotationsClose,
            stock,
            startDate,
            endDate,
            endCalcRes,
            analyseName,
            calcOutput,
            eventListForEvtDef,
            noResMsg,
            evtDefInfo);

    return buildResOnValidPeriods(
        periods,
        mapFromQuotationsClose,
        quotations,
        stock,
        startDate,
        endDate,
        analyseName,
        calcOutput,
        evtDefInfo,
        observer);
  }