Package com.opengamma.financial.analytics.timeseries

Examples of com.opengamma.financial.analytics.timeseries.HistoricalTimeSeriesBundle


    final LocalDateLabelledMatrix1D bucketedCS01 = (LocalDateLabelledMatrix1D) bucketedCS01Object;
    final Object htsObject = inputs.getValue(ValueRequirementNames.CREDIT_SPREAD_CURVE_HISTORICAL_TIME_SERIES);
    if (htsObject == null) {
      throw new OpenGammaRuntimeException("Could not get credit spread curve historical time series");
    }
    final HistoricalTimeSeriesBundle hts = (HistoricalTimeSeriesBundle) htsObject;
    final NavigableSet<CurveNodeWithIdentifier> nodes = getNodes(now, security, curveSpecification.getNodes());
    DoubleTimeSeries<?> pnlSeries = getPnLSeries(nodes, bucketedCS01, hts, schedule, samplingFunction, fxSeries, isInverse);
    if (pnlSeries == null) {
      throw new OpenGammaRuntimeException("Could not get any values for security " + position.getSecurity());
    }
View Full Code Here


      final Object volatilityHTSObject = inputs.getValue(ValueRequirementNames.VOLATILITY_SURFACE_HISTORICAL_TIME_SERIES);
      if (volatilityHTSObject == null) {
        throw new OpenGammaRuntimeException("Could not get historical time series for volatilities");
      }
      final DoubleLabelledMatrix2D vegaMatrix = (DoubleLabelledMatrix2D) vegaMatrixObject;
      final HistoricalTimeSeriesBundle timeSeriesBundle = (HistoricalTimeSeriesBundle) volatilityHTSObject;
      final Clock snapshotClock = executionContext.getValuationClock();
      final LocalDate now = ZonedDateTime.now(snapshotClock).toLocalDate();
      final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
      final String surfaceName = desiredValue.getConstraint(ValuePropertyNames.SURFACE);
      final ConfigSource configSource = OpenGammaExecutionContext.getConfigSource(executionContext);
View Full Code Here

    DoubleTimeSeries<?> result = null;
    final MultiCurveCalculationConfig curveCalculationConfig = curveCalculationConfigSource.getConfig(curveCalculationConfigName);
    for (final String yieldCurveName : yieldCurveNames) {
      final ValueRequirement ycnsRequirement = getYCNSRequirement(currencyString, curveCalculationConfigName, yieldCurveName, surfaceName, target);
      final DoubleLabelledMatrix1D ycns = (DoubleLabelledMatrix1D) inputs.getValue(ycnsRequirement);
      final HistoricalTimeSeriesBundle ychts = (HistoricalTimeSeriesBundle) inputs.getValue(getYCHTSRequirement(currency, yieldCurveName, samplingPeriod.toString()));
      final DoubleTimeSeries<?> pnLSeries;
      if (curveCalculationConfig.getCalculationMethod().equals(FXImpliedYieldCurveFunction.FX_IMPLIED)) {
        pnLSeries = getPnLSeries(ycns, ychts, schedule, samplingFunction);
      } else {
        final ValueRequirement curveSpecRequirement = getCurveSpecRequirement(currency, yieldCurveName);
View Full Code Here

    final ComputationTargetSpecification targetSpec = target.toSpecification();
    final ConventionBundleSource conventionSource = OpenGammaExecutionContext.getConventionBundleSource(executionContext);
    final ConventionBundle bundle = conventionSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD_CAPM"));
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final ValueProperties constraints = desiredValue.getConstraints();
    final HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
    final HistoricalTimeSeries marketTS = timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, bundle.getCAPMMarket());
    if (marketTS == null) {
      throw new OpenGammaRuntimeException("Market value series was not availble");
    }
    final HistoricalTimeSeries riskFreeRateTS = timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, bundle.getCAPMRiskFreeRate());
    if (riskFreeRateTS == null) {
      throw new OpenGammaRuntimeException("Risk free rate series was not available");
    }
    final Object assetPnLObject = inputs.getValue(new ValueRequirement(ValueRequirementNames.PNL_SERIES, targetSpec)); //TODO replace with return series when portfolio weights are in
    if (assetPnLObject == null) {
View Full Code Here

      final DoubleArrayList initialRatesGuess = new DoubleArrayList();
      final LinkedHashMap<String, double[]> curveNodes = new LinkedHashMap<>();
      final LinkedHashMap<String, Interpolator1D> interpolators = new LinkedHashMap<>();
      final Map<String, Integer> nodesPerCurve = new HashMap<>();
      for (final String curveName : curveNames) {
        final HistoricalTimeSeriesBundle timeSeries = getTimeSeriesBundle(inputs, targetSpec, curveName);
        final InterpolatedYieldCurveSpecificationWithSecurities spec = getYieldCurveSpecification(inputs, targetSpec, curveName);
        int nInstruments = 0;
        final Interpolator1D interpolator = spec.getInterpolator();
        final HistoricalTimeSeriesBundle marketData = getHistoricalMarketData(inputs, targetSpec, curveName);
        final DoubleArrayList nodeTimes = new DoubleArrayList();
        FixedIncomeStripWithSecurity previousStrip = null;
        for (final FixedIncomeStripWithSecurity strip : spec.getStrips()) {
          //TODO a lot of this can be moved outside the date loop
          final HistoricalTimeSeries historicalTimeSeries = marketData.get(MarketDataRequirementNames.MARKET_VALUE, strip.getSecurityIdentifier());
          if (historicalTimeSeries == null) {
            throw new OpenGammaRuntimeException("Could not get historical time series for " + strip);
          }
          final LocalDateDoubleTimeSeries ts = historicalTimeSeries.getTimeSeries();
          final Double marketValue = ts.getValue(valuationDate);
View Full Code Here

      final ValueRequirement ychtsRequirement = getYCHTSRequirement(currency, yieldCurveName, samplingPeriod.toString());
      final Object ychtsObject = inputs.getValue(ychtsRequirement);
      if (ychtsObject == null) {
        throw new OpenGammaRuntimeException("Could not get yield curve historical time series; " + ychtsRequirement);
      }
      final HistoricalTimeSeriesBundle ychts = (HistoricalTimeSeriesBundle) ychtsObject;
      final DoubleTimeSeries<?> pnLSeries;
      if (curveCalculationConfig.getCalculationMethod().equals(FXImpliedYieldCurveFunction.FX_IMPLIED)) {
        pnLSeries = getPnLSeries(ycns, ychts, schedule, samplingFunction);
      } else {
        final ValueRequirement curveSpecRequirement = getCurveSpecRequirement(currency, yieldCurveName);
View Full Code Here

    final ComputationTargetSpecification targetSpec = target.toSpecification();
    final ConventionBundleSource conventionSource = OpenGammaExecutionContext.getConventionBundleSource(executionContext);
    final ConventionBundle bundle = conventionSource.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD_CAPM"));
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final ValueProperties constraints = desiredValue.getConstraints();
    final HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
    final HistoricalTimeSeries marketTSObject = timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, bundle.getCAPMMarket());
    if (marketTSObject == null) {
      throw new OpenGammaRuntimeException("Market value series was not available");
    }
    final HistoricalTimeSeries riskFreeTSObject = timeSeries.get(MarketDataRequirementNames.MARKET_VALUE, bundle.getCAPMRiskFreeRate());
    if (riskFreeTSObject == null) {
      throw new OpenGammaRuntimeException("Risk free series was not available");
    }
    final Object assetPnLObject = inputs.getValue(new ValueRequirement(ValueRequirementNames.PNL_SERIES, targetSpec)); //TODO replace with return series when portfolio weights are in
    if (assetPnLObject == null) {
View Full Code Here

    @Override
    public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
        final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
      final Clock snapshotClock = executionContext.getValuationClock();
      final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
      final HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
      final InstrumentDefinition<?> definition = getDefinitionFromTarget(target);
      final InstrumentDerivative derivative = getDerivative(target, now, timeSeries, definition);
      final FXMatrix fxMatrix = new FXMatrix();
      final SecuritySource securitySource = OpenGammaExecutionContext.getSecuritySource(executionContext);
      final Collection<Currency> currencies = FinancialSecurityUtils.getCurrencies(target.getTrade().getSecurity(), securitySource);
View Full Code Here

  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
      final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
    final FinancialSecurity security = (FinancialSecurity) target.getSecurity();
    final Clock snapshotClock = executionContext.getValuationClock();
    final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
    final HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    //TODO won't need to call into database again when calculation configurations are a requirement
    final ConfigSource configSource = OpenGammaExecutionContext.getConfigSource(executionContext);
    final ConfigDBCurveCalculationConfigSource curveCalculationConfigSource = new ConfigDBCurveCalculationConfigSource(configSource);
    final String payCurveCalculationConfigName = desiredValue.getConstraint(ValuePropertyNames.PAY_CURVE_CALCULATION_CONFIG);
View Full Code Here

    final FXForwardCurveSpecification specification = fxCurveSpecificationSource.getSpecification(domesticCurveName, currencyPair.toString());
    if (specification == null) {
      throw new OpenGammaRuntimeException("Couldn't find FX forward curve specification called " + domesticCurveName + " for target " + currencyPair);
    }
    final FXForwardCurveInstrumentProvider provider = specification.getCurveInstrumentProvider();
    final HistoricalTimeSeriesBundle timeSeriesBundle = getTimeSeriesBundle(inputs, ComputationTargetType.UNORDERED_CURRENCY_PAIR.specification(currencyPair), domesticCurveName);
    final HistoricalTimeSeries spotTimeSeries = timeSeriesBundle.get(provider.getMarketDataField(), provider.getSpotInstrument());
    if (spotTimeSeries == null) {
      throw new OpenGammaRuntimeException("Could not get spot FX time series");
    }
    final LocalDateDoubleTimeSeries spotTS = spotTimeSeries.getTimeSeries();
    final Map<LocalDate, YieldAndDiscountCurve> foreignCurves = (Map<LocalDate, YieldAndDiscountCurve>) foreignCurveObject;
    final Map<LocalDate, YieldAndDiscountCurve> domesticCurves = new LinkedHashMap<>();
    final Calendar calendar = CalendarUtils.getCalendar(holidaySource, domesticCurrency, foreignCurrency);
    final ConventionSource conventionSource = OpenGammaExecutionContext.getConventionSource(executionContext);
    final FXSpotConvention fxSpotConvention = (FXSpotConvention) conventionSource.getConvention(ExternalId.of("CONVENTION", "FX Spot"));
    final int spotLag = fxSpotConvention.getSettlementDays();
    final boolean isRegular = specification.isMarketQuoteConvention();
    final ExternalId conventionSettlementRegion = fxSpotConvention.getSettlementRegion();
    for (final Map.Entry<LocalDate, YieldAndDiscountCurve> entry : foreignCurves.entrySet()) {
      final LocalDate valuationDate = entry.getKey();
      final ZonedDateTime valuationDateTime = ZonedDateTime.of(valuationDate, now.toLocalTime(), now.getZone());
      final Double spotValue = spotTS.getValue(valuationDate);
      if (spotValue == null) {
        continue;
      }
      final double spotFX = invertFXQuotes ? 1 / spotValue : spotValue;
      final YieldAndDiscountCurve foreignCurve = entry.getValue();
      final DoubleArrayList marketValues = new DoubleArrayList();
      final DoubleArrayList nodeTimes = new DoubleArrayList();
      final DoubleArrayList initialRatesGuess = new DoubleArrayList();
      final String fullDomesticCurveName = domesticCurveName + "_" + domesticCurrency.getCode();
      final String fullForeignCurveName = foreignCurveName + "_" + foreignCurrency.getCode();
      final List<InstrumentDerivative> derivatives = new ArrayList<>();
      int nInstruments = 0;
      ZonedDateTime spotDate;
      if (spotLag == 0 && conventionSettlementRegion == null) {
        spotDate = valuationDateTime;
      } else {
        spotDate = ScheduleCalculator.getAdjustedDate(valuationDateTime, spotLag, calendar);
      }
      for (final Tenor tenor : definition.getTenors()) {
        final ExternalId identifier = provider.getInstrument(valuationDate, tenor);
        final HistoricalTimeSeries forwardFXTS = timeSeriesBundle.get(provider.getMarketDataField(), identifier);
        if (forwardFXTS == null) {
          throw new OpenGammaRuntimeException("Could not get time series for " + identifier);
        }
        final LocalDateDoubleTimeSeries forwardTS = forwardFXTS.getTimeSeries();
        final ZonedDateTime paymentDate;
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.timeseries.HistoricalTimeSeriesBundle

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.