Package com.opengamma.financial.analytics.timeseries

Examples of com.opengamma.financial.analytics.timeseries.DateConstraint$PlusMinusPeriodDateConstraint


  @Override
  public Set<ValueRequirement> getRequirements(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) {
    final ValueProperties constraints = desiredValue.getConstraints();
    final String lookbackPeriodString = anyConstraintOrNull(constraints, ValuePropertyNames.SAMPLING_PERIOD);
    final DateConstraint startDate;
    if (lookbackPeriodString == null) {
      if (!OpenGammaCompilationContext.isPermissive(context)) {
        return null;
      }
      startDate = DateConstraint.VALUATION_TIME.minus(DEFAULT_SAMPLING_PERIOD);
    } else {
      startDate = DateConstraint.VALUATION_TIME.minus(Period.parse(lookbackPeriodString));
    }
    final ViewDefinition viewDefinition = context.getViewCalculationConfiguration().getViewDefinition();
    final HistoricalViewEvaluationTarget tempTarget = new HistoricalViewEvaluationTarget(viewDefinition.getMarketDataUser(), startDate.toString(), true, DateConstraint.VALUATION_TIME.toString(),
        false, null, HistoricalViewEvaluationMarketDataMode.HISTORICAL);
    final ViewCalculationConfiguration calcConfig = createViewCalculationConfiguration(tempTarget.getViewDefinition(), context.getViewCalculationConfiguration().getName());
    addValueRequirements(context, target, calcConfig);
    tempTarget.getViewDefinition().addViewCalculationConfiguration(calcConfig);
    final TempTargetRepository targets = OpenGammaCompilationContext.getTempTargets(context);
View Full Code Here


    final TempTarget tempTargetObject = OpenGammaCompilationContext.getTempTargets(context).get(inputs.keySet().iterator().next().getTargetSpecification().getUniqueId());
    if (!(tempTargetObject instanceof HistoricalViewEvaluationTarget)) {
      return null;
    }
    final HistoricalViewEvaluationTarget historicalTarget = (HistoricalViewEvaluationTarget) tempTargetObject;
    final DateConstraint startDate = DateConstraint.parse(historicalTarget.getStartDate());
    final DateConstraint endDate = DateConstraint.parse(historicalTarget.getEndDate());
    final Period samplingPeriod = startDate.periodUntil(endDate);
    return Collections
        .singleton(new ValueSpecification(ValueRequirementNames.COVARIANCE_MATRIX, target.toSpecification(), createValueProperties()
            .with(ValuePropertyNames.SAMPLING_PERIOD, samplingPeriod.toString()).get()));
  }
View Full Code Here

    Set<String> samplingPeriods = desiredValue.getConstraints().getValues(ValuePropertyNames.SAMPLING_PERIOD);
    if (samplingPeriods == null || samplingPeriods.size() != 1) {
      return null;
    }
    String samplingPeriod = Iterables.getOnlyElement(samplingPeriods);
    DateConstraint start = DateConstraint.parse("-" + samplingPeriod);
    ValueProperties inputConstraints = desiredValue.getConstraints().copy()
        .withOptional(ValuePropertyNames.SAMPLING_PERIOD)
        .with(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY, start.toString())
        .with(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY, DateConstraint.VALUATION_TIME.toString())
        .get();
    return ImmutableSet.of(new ValueRequirement(_valueRequirementName, target.toSpecification(), inputConstraints));
  }
View Full Code Here

    result.add(new ValueRequirement(ValueRequirementNames.FAIR_VALUE, targetSpec));
    result.add(new ValueRequirement(ValueRequirementNames.CAPM_BETA, targetSpec, betaProperties));
    final HistoricalTimeSeriesResolver resolver = OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
    final ConventionBundleSource conventionSource = OpenGammaCompilationContext.getConventionBundleSource(context);
    final ConventionBundle bundle = conventionSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD_CAPM"));
    final DateConstraint startDate = DateConstraint.VALUATION_TIME.minus(samplingPeriodName);
    HistoricalTimeSeriesResolutionResult timeSeries = resolver.resolve(bundle.getCAPMMarket(), null, null, null, MarketDataRequirementNames.MARKET_VALUE, _resolutionKey);
    if (timeSeries == null) {
      return null;
    }
    result.add(HistoricalTimeSeriesFunctionUtils.createHTSRequirement(timeSeries, MarketDataRequirementNames.MARKET_VALUE, startDate, true,
View Full Code Here

        .with(ValuePropertyNames.RETURN_CALCULATOR, returnCalculatorName).get()));
    requirements.add(new ValueRequirement(ValueRequirementNames.FAIR_VALUE, targetSpec));
    final HistoricalTimeSeriesResolver resolver = OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
    final ConventionBundleSource conventionSource = OpenGammaCompilationContext.getConventionBundleSource(context);
    final ConventionBundle bundle = conventionSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD_CAPM"));
    final DateConstraint startDate = DateConstraint.VALUATION_TIME.minus(samplingPeriodName);
    HistoricalTimeSeriesResolutionResult timeSeries = resolver.resolve(bundle.getCAPMMarket(), null, null, null, MarketDataRequirementNames.MARKET_VALUE, _resolutionKey);
    if (timeSeries == null) {
      return null;
    }
    requirements.add(HistoricalTimeSeriesFunctionUtils.createHTSRequirement(timeSeries, MarketDataRequirementNames.MARKET_VALUE, startDate, true,
View Full Code Here

      // If a POSITION, request the POSITION's value and DON'T scale during the execute
      securityOrTradeValue = new ValueRequirement(ValueRequirementNames.VALUE, target.toSpecification(), getCurrencyProperty(security));
    }
    final HistoricalTimeSeriesResolver resolver = OpenGammaCompilationContext.getHistoricalTimeSeriesResolver(context);
    final ExternalIdBundle bundle = security.getExternalIdBundle();
    final DateConstraint startDate = getTimeSeriesStartDate(positionOrTrade);
    final DateConstraint endDate = getTimeSeriesEndDate(positionOrTrade);
    final ValueRequirement markToMarketValue = getMarkToMarketSeriesRequirement(resolver, bundle, startDate, endDate);
    final ValueRequirement costOfCarryValue = getCostOfCarrySeriesRequirement(resolver, bundle, endDate);

    if (markToMarketValue == null && costOfCarryValue == null) {
      return null;
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.timeseries.DateConstraint$PlusMinusPeriodDateConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.