Examples of HistoricalTimeSeriesSource


Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

   
    ObjectId tsObjectId = null;
    Security security = doc.getPosition().getSecurityLink().resolveQuiet(data().getSecuritySource());
    if (security != null && !security.getExternalIdBundle().isEmpty()) {
      // Get the last price HTS for the security
      HistoricalTimeSeriesSource htsSource = data().getHistoricalTimeSeriesSource();
      HistoricalTimeSeries series = htsSource.getHistoricalTimeSeries(
          MarketDataRequirementNames.MARKET_VALUE, doc.getPosition().getSecurity().getExternalIdBundle(), null, null, false, null, false, 0);
      if (series != null) {
        tsObjectId = series.getUniqueId().getObjectId();
      }
    }
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

    }
    final ValueProperties additionalConstraints = (additionalConstraintsBuilder != null) ? additionalConstraintsBuilder.get() : ValueProperties.none();

    // Get security and its underlying's ExternalId.
    final FinancialSecurity security = (FinancialSecurity) target.getSecurity();
    final HistoricalTimeSeriesSource tsSource = OpenGammaCompilationContext.getHistoricalTimeSeriesSource(context); // TODO: Do we still require tsSource? Was used to access id bundles
    final SecuritySource securitySource = OpenGammaCompilationContext.getSecuritySource(context);
    final ExternalId underlyingId = getWeakUnderlyingId(FinancialSecurityUtils.getUnderlyingId(security), tsSource, securitySource, surfaceName);
    if (underlyingId == null) {
      return null;
    }
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

    return str;
  }

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final HistoricalTimeSeriesSource timeSeriesSource = OpenGammaExecutionContext.getHistoricalTimeSeriesSource(executionContext);
    final ConventionBundleSource conventionBundleSource = OpenGammaExecutionContext.getConventionBundleSource(executionContext);
    final YieldCurveFixingSeriesProvider provider = new YieldCurveFixingSeriesProvider(conventionBundleSource);
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final String dataField = desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY);
    final String resolutionKey = parseString(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY));
    final LocalDate startDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY));
    final boolean includeStart = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY));
    final LocalDate endDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY));
    final boolean includeEnd = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY));
    final InterpolatedYieldCurveSpecificationWithSecurities yieldCurve = (InterpolatedYieldCurveSpecificationWithSecurities) inputs.getAllValues().iterator().next().getValue();
    final HistoricalTimeSeriesBundle bundle = new HistoricalTimeSeriesBundle();
    for (final FixedIncomeStripWithSecurity strip : yieldCurve.getStrips()) {
      final Security security = strip.getSecurity();
      if (security instanceof FinancialSecurity) {
        final FinancialSecurity financialSecurity = (FinancialSecurity) security;
        final Set<ExternalIdBundle> idBundles = financialSecurity.accept(provider);
        for (final ExternalIdBundle id : idBundles) {
          final HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, id, resolutionKey, startDate, includeStart, endDate, includeEnd);
          if (timeSeries != null) {
            if (timeSeries.getTimeSeries().isEmpty()) {
              s_logger.warn("Time series for {} is empty", id);
            } else {
              bundle.add(dataField, id, timeSeries);
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

    ComponentInfo infoResolver = new ComponentInfo(HistoricalTimeSeriesResolver.class, getClassifier());
    infoResolver.addAttribute(ComponentInfoAttributes.LEVEL, 1);
    infoResolver.addAttribute(ComponentInfoAttributes.REMOTE_CLIENT_JAVA, RemoteHistoricalTimeSeriesResolver.class);
    repo.registerComponent(infoResolver, resolver);

    HistoricalTimeSeriesSource source = createSource(repo, resolver);

    ComponentInfo infoSource = new ComponentInfo(HistoricalTimeSeriesSource.class, getClassifier());
    infoSource.addAttribute(ComponentInfoAttributes.LEVEL, 1);
    infoSource.addAttribute(ComponentInfoAttributes.REMOTE_CLIENT_JAVA, RemoteHistoricalTimeSeriesSource.class);
    repo.registerComponent(infoSource, source);
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

   * @param repo the component repository, only used to register secondary items like lifecycle, not null
   * @param resolver the resolver, not null
   * @return the source, not null
   */
  protected HistoricalTimeSeriesSource createSource(ComponentRepository repo, HistoricalTimeSeriesResolver resolver) {
    HistoricalTimeSeriesSource source = createSourcePreCaching(repo, resolver);
    if (getCacheManager() != null) {
      source = new EHCachingHistoricalTimeSeriesSource(source, getCacheManager());
    }
    return source;
  }
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

    } while (holidaySource.isHoliday(tradeDate, ccy));
    return tradeDate;
  }

  private Double getSpotRate(final CurrencyPair ccys, final LocalDate tradeDate) {
    final HistoricalTimeSeriesSource historicalSource = getToolContext().getHistoricalTimeSeriesSource();
    final String ticker = ccys.getBase().getCode() + ccys.getCounter().getCode() + " Curncy";
    final ExternalIdBundle idBundle = ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId(ticker));
    final HistoricalTimeSeries spotSeries = historicalSource.getHistoricalTimeSeries("PX_LAST",
        idBundle, HistoricalTimeSeriesRatingFieldNames.DEFAULT_CONFIG_NAME, tradeDate.minusDays(30), true, tradeDate, true);
    if (spotSeries == null) {
      throw new OpenGammaRuntimeException("Could not get spot rate series for " + ticker);
    }
    if (spotSeries.getTimeSeries().isEmpty()) {
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

        .withAny(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY).get());
  }

  @Override
  protected Double apply(final FunctionExecutionContext context, final OverrideOperation operation, final Double value, final ValueSpecification valueSpec) {
    final HistoricalTimeSeriesSource htsSource = OpenGammaExecutionContext.getHistoricalTimeSeriesSource(context);
    final ExternalIdBundle ids = htsSource.getExternalIdBundle(valueSpec.getTargetSpecification().getUniqueId());
    return applyOverride(context, operation, valueSpec.getProperty(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY), ids, value);
  }
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

    return str;
  }

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final HistoricalTimeSeriesSource timeSeriesSource = OpenGammaExecutionContext.getHistoricalTimeSeriesSource(executionContext);
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final String dataField = desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY);
    final String resolutionKey = parseString(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY));
    final LocalDate startDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY));
    final boolean includeStart = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY));
    final LocalDate endDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY));
    final boolean includeEnd = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY));
    final InterpolatedYieldCurveSpecificationWithSecurities yieldCurve = (InterpolatedYieldCurveSpecificationWithSecurities) inputs.getAllValues().iterator().next().getValue();
    final HistoricalTimeSeriesBundle bundle = new HistoricalTimeSeriesBundle();
    for (final FixedIncomeStripWithSecurity strip : yieldCurve.getStrips()) {
      final ExternalIdBundle id = ExternalIdBundle.of(strip.getSecurityIdentifier());
      final HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, id, resolutionKey, startDate, includeStart, endDate, includeEnd);
      if (timeSeries != null) {
        if (timeSeries.getTimeSeries().isEmpty()) {
          s_logger.warn("Time series for {} is empty", id);
        } else {
          bundle.add(dataField, id, timeSeries);
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

  private static final Logger s_logger = LoggerFactory.getLogger(VolatilitySurfaceHistoricalTimeSeriesFunction.class);

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
      final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
    final HistoricalTimeSeriesSource timeSeriesSource = OpenGammaExecutionContext.getHistoricalTimeSeriesSource(executionContext);
    final ConfigSource configSource = OpenGammaExecutionContext.getConfigSource(executionContext);
    final ConfigDBVolatilitySurfaceDefinitionSource definitionSource = new ConfigDBVolatilitySurfaceDefinitionSource(configSource);
    final ConfigDBVolatilitySurfaceSpecificationSource specificationSource = new ConfigDBVolatilitySurfaceSpecificationSource(configSource);
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final String dataField = desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.DATA_FIELD_PROPERTY);
    final String resolutionKey;
    final Set<String> resolutionKeyConstraint = desiredValue.getConstraints().getValues(HistoricalTimeSeriesFunctionUtils.RESOLUTION_KEY_PROPERTY);
    if (resolutionKeyConstraint == null || resolutionKeyConstraint.size() != 1) {
      resolutionKey = "Null";
    } else {
      resolutionKey = Iterables.getOnlyElement(resolutionKeyConstraint);
    }
    final LocalDate startDate = DateConstraint.evaluate(executionContext, desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.START_DATE_PROPERTY));
    final boolean includeStart = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_START_PROPERTY));
    final Set<String> endDateConstraint = desiredValue.getConstraints().getValues(HistoricalTimeSeriesFunctionUtils.END_DATE_PROPERTY);
    final String endDateString;
    if (endDateConstraint == null || endDateConstraint.size() != 1) {
      endDateString = "Now";
    } else {
      endDateString = Iterables.getOnlyElement(endDateConstraint);
    }
    LocalDate endDate = DateConstraint.evaluate(executionContext, endDateString);
    final boolean includeEnd = HistoricalTimeSeriesFunctionUtils.parseBoolean(desiredValue.getConstraint(HistoricalTimeSeriesFunctionUtils.INCLUDE_END_PROPERTY));
    final String surfaceName = desiredValue.getConstraint(ValuePropertyNames.SURFACE);
    final VolatilitySurfaceDefinition<Object, Object> definition = getSurfaceDefinition(target, surfaceName, definitionSource);
    final VolatilitySurfaceSpecification specification = getSurfaceSpecification(target, surfaceName, specificationSource);
    final SurfaceInstrumentProvider<Object, Object> provider = (SurfaceInstrumentProvider<Object, Object>) specification.getSurfaceInstrumentProvider();
    final HistoricalTimeSeriesBundle bundle = new HistoricalTimeSeriesBundle();
    for (final Object x : definition.getXs()) {
      for (final Object y : definition.getYs()) {
        ExternalId id = provider.getInstrument(x, y, endDate);
        if (id.getScheme().equals(ExternalSchemes.BLOOMBERG_TICKER_WEAK)) {
          id = ExternalSchemes.bloombergTickerSecurityId(id.getValue());
        }
        final ExternalIdBundle identifier = ExternalIdBundle.of(id);
        final HistoricalTimeSeries timeSeries = timeSeriesSource.getHistoricalTimeSeries(dataField, identifier, resolutionKey, startDate, includeStart, endDate, includeEnd);
        if (timeSeries != null) {
          bundle.add(dataField, identifier, timeSeries);
        } else {
          s_logger.warn("Could not get time series for {}", identifier);
        }
View Full Code Here

Examples of com.opengamma.core.historicaltimeseries.HistoricalTimeSeriesSource

  private CacheManager _cacheManager;

  //-------------------------------------------------------------------------
  @Override
  public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
    HistoricalTimeSeriesSource source = initHistoricalTimeSeriesSource(repo);
    ComponentInfo info = new ComponentInfo(BloombergHistoricalTimeSeriesSource.class, getClassifier());
    repo.registerComponent(info, source);
    if (isPublishRest()) {
      repo.getRestComponents().publishResource(new DataHistoricalTimeSeriesSourceResource(source))// publish in old way
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.