private ValueRequirement getIndexTimeSeriesRequirement( final InterestRateInstrumentType type, final SwapLeg leg, final ZonedDateTime swapEffectiveDate) { if (leg instanceof FloatingInterestRateLeg) { final FloatingInterestRateLeg floatingLeg = (FloatingInterestRateLeg) leg; final ExternalIdBundle id = getIndexIdForSwap(floatingLeg); final LocalDate startDate = swapEffectiveDate.toLocalDate().minusDays(360); // Implementation note: To catch first fixing. SwapSecurity does not have this date. final HistoricalTimeSeriesResolutionResult ts = getTimeSeriesResolver() .resolve(id, null, null, null, MarketDataRequirementNames.MARKET_VALUE, null); if (ts == null) { return null; } return HistoricalTimeSeriesFunctionUtils.createHTSRequirement( ts, MarketDataRequirementNames.MARKET_VALUE, DateConstraint.of(startDate), true, DateConstraint.VALUATION_TIME, true); } return null; }
@Override public Set<ValueRequirement> getTimeSeriesRequirements( final FRASecurity security, final String[] curveNames) { final ExternalId indexId = security.getUnderlyingId(); final ConventionBundle indexConvention = getConventionSource().getConventionBundle(indexId); if (indexConvention == null) { throw new OpenGammaRuntimeException( "No conventions found for floating reference rate " + indexId); } final ExternalIdBundle indexIdBundle = indexConvention.getIdentifiers(); final HistoricalTimeSeriesResolutionResult timeSeries = getTimeSeriesResolver() .resolve( indexIdBundle, null, null, null, MarketDataRequirementNames.MARKET_VALUE, null); if (timeSeries == null) { return null; } return Collections.singleton( HistoricalTimeSeriesFunctionUtils.createHTSRequirement( timeSeries, MarketDataRequirementNames.MARKET_VALUE, DateConstraint.VALUATION_TIME.minus(Period.ofDays(7)).previousWeekDay(), true, DateConstraint.VALUATION_TIME, false)); }
private ValueRequirement getIndexTimeSeriesRequirement( final ExternalIdBundle id, final LocalDate startDate) { final HistoricalTimeSeriesResolutionResult timeSeries = getTimeSeriesResolver() .resolve(id, null, null, null, MarketDataRequirementNames.MARKET_VALUE, null); if (timeSeries == null) { return null; } return HistoricalTimeSeriesFunctionUtils.createHTSRequirement( timeSeries, MarketDataRequirementNames.MARKET_VALUE, DateConstraint.of(startDate), true, DateConstraint.VALUATION_TIME, true); }
protected ValueRequirement getSensitivityRequirement(final ExternalId externalId) { final HistoricalTimeSeriesResolutionResult resolutionResult = _htsResolver.resolve(ExternalIdBundle.of(externalId), null, null, null, "EXPOSURE", null); final ValueRequirement htsRequirement = HistoricalTimeSeriesFunctionUtils.createHTSRequirement( resolutionResult, "EXPOSURE", DateConstraint.VALUATION_TIME, true, DateConstraint.VALUATION_TIME, true); return htsRequirement; // return new ValueRequirement(); // return new ValueRequirement(/*ExternalDataRequirementNames.SENSITIVITY*/"EXPOSURE", // ComputationTargetType.PRIMITIVE, UniqueId.of(externalId.getScheme().getName(), // externalId.getValue())); }
@Override public Set<ValueRequirement> getTimeSeriesRequirements( final IRFutureOptionSecurity security, final String[] curveNames) { final HistoricalTimeSeriesResolutionResult timeSeries = getTimeSeriesResolver() .resolve( security.getExternalIdBundle(), null, null, null, MarketDataRequirementNames.MARKET_VALUE, null); if (timeSeries == null) { return null; } return Collections.singleton( HistoricalTimeSeriesFunctionUtils.createHTSRequirement( timeSeries, MarketDataRequirementNames.MARKET_VALUE, DateConstraint.VALUATION_TIME.minus(Period.ofMonths(1)).previousWeekDay(), true, DateConstraint.VALUATION_TIME, false)); }
@Override public Set<ValueRequirement> getRequirements( final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue) { final Object positionOrNode = getTarget(target); final Set<ValueRequirement> result = new HashSet<ValueRequirement>(); final ValueProperties constraints = desiredValue.getConstraints(); final Set<String> samplingPeriodNames = constraints.getValues(ValuePropertyNames.SAMPLING_PERIOD); if (samplingPeriodNames == null || samplingPeriodNames.size() != 1) { return null; } final Set<String> scheduleCalculatorNames = constraints.getValues(ValuePropertyNames.SCHEDULE_CALCULATOR); if (scheduleCalculatorNames == null || scheduleCalculatorNames.size() != 1) { return null; } final Set<String> samplingFunctionNames = constraints.getValues(ValuePropertyNames.SAMPLING_FUNCTION); if (samplingFunctionNames == null || samplingFunctionNames.size() != 1) { return null; } final Set<String> returnCalculatorNames = constraints.getValues(ValuePropertyNames.RETURN_CALCULATOR); if (returnCalculatorNames == null || returnCalculatorNames.size() != 1) { return null; } final Set<String> stdDevCalculatorNames = constraints.getValues(ValuePropertyNames.STD_DEV_CALCULATOR); if (stdDevCalculatorNames == null || stdDevCalculatorNames.size() != 1) { return null; } final Set<String> covarianceCalculatorNames = constraints.getValues(ValuePropertyNames.COVARIANCE_CALCULATOR); if (covarianceCalculatorNames == null || covarianceCalculatorNames.size() != 1) { return null; } final Set<String> varianceCalculatorNames = constraints.getValues(ValuePropertyNames.VARIANCE_CALCULATOR); if (varianceCalculatorNames == null || varianceCalculatorNames.size() != 1) { return null; } final String samplingPeriodName = samplingPeriodNames.iterator().next(); final String scheduleCalculatorName = scheduleCalculatorNames.iterator().next(); final String samplingFunctionName = samplingFunctionNames.iterator().next(); final String returnCalculatorName = returnCalculatorNames.iterator().next(); final ValueProperties pnlSeriesProperties = ValueProperties.builder() .withAny(ValuePropertyNames.CURRENCY) .with(ValuePropertyNames.SAMPLING_PERIOD, samplingPeriodName) .with(ValuePropertyNames.SCHEDULE_CALCULATOR, scheduleCalculatorName) .with(ValuePropertyNames.SAMPLING_FUNCTION, samplingFunctionName) .with(ValuePropertyNames.RETURN_CALCULATOR, returnCalculatorName) .get(); final ValueProperties betaProperties = ValueProperties.builder() .with(ValuePropertyNames.SAMPLING_PERIOD, samplingPeriodName) .with(ValuePropertyNames.SCHEDULE_CALCULATOR, scheduleCalculatorName) .with(ValuePropertyNames.SAMPLING_FUNCTION, samplingFunctionName) .with(ValuePropertyNames.RETURN_CALCULATOR, returnCalculatorName) .with( ValuePropertyNames.COVARIANCE_CALCULATOR, covarianceCalculatorNames.iterator().next()) .with(ValuePropertyNames.VARIANCE_CALCULATOR, varianceCalculatorNames.iterator().next()) .get(); result.add( new ValueRequirement( ValueRequirementNames.PNL_SERIES, positionOrNode, pnlSeriesProperties)); result.add(new ValueRequirement(ValueRequirementNames.FAIR_VALUE, positionOrNode)); result.add( new ValueRequirement(ValueRequirementNames.CAPM_BETA, positionOrNode, 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 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, DateConstraint.VALUATION_TIME.minus(samplingPeriodName), true, DateConstraint.VALUATION_TIME, true)); return result; }