Package com.opengamma.core.historicaltimeseries.impl

Examples of com.opengamma.core.historicaltimeseries.impl.RedisSimulationSeriesSource


  @Override
  protected void doRun() {
    if (!(getToolContext().getHistoricalTimeSeriesSource() instanceof RedisSimulationSeriesSource)) {
      throw new OpenGammaRuntimeException("HistoricalTimeSeriesSource from conrtext is not a RedisSimulationSeriesSource, got " + getToolContext().getHistoricalTimeSeriesSource() + ": note this tool must be run with a toolcontext config file not via -c http://localhost");
    }
    final RedisSimulationSeriesSource source = (RedisSimulationSeriesSource) getToolContext().getHistoricalTimeSeriesSource();

    String fileName = getCommandLine().getOptionValue(FILE_NAME_OPT);
    SheetFormat sheetFormat = SheetFormat.of(fileName);

    // most of these fields are dropped in redis - used here to allow us to use existing machinery
    String dataSource = getCommandLine().getOptionValue(TIME_SERIES_DATASOURCE_OPT);
    String dataProvider = getCommandLine().getOptionValue(TIME_SERIES_DATAPROVIDER_OPT);
    String dataField = getCommandLine().getOptionValue(TIME_SERIES_DATAFIELD_OPT);
    String observationTime = getCommandLine().getOptionValue(TIME_SERIES_OBSERVATIONTIME_OPT);
    String idScheme = getCommandLine().getOptionValue(TIME_SERIES_IDSCHEME_OPT);
    String dateFormat = getCommandLine().getOptionValue(TIME_SERIES_DATEFORMAT_OPT);
    boolean write = getCommandLine().hasOption(WRITE_OPT);
    try {
      InputStream portfolioFileStream = new BufferedInputStream(new FileInputStream(fileName));

      TimeSeriesReader timeSeriesReader = new SingleSheetMultiTimeSeriesReader(sheetFormat,
                                                                               portfolioFileStream,
                                                                               dataSource,
                                                                               dataProvider,
                                                                               dataField,
                                                                               observationTime,
                                                                               idScheme,
                                                                               dateFormat);

      timeSeriesReader.writeTo(new TimeSeriesWriter() {
        @Override
        public LocalDateDoubleTimeSeries writeDataPoints(ExternalId htsId,
                                                         String dataSource,
                                                         String dataProvider,
                                                         String dataField,
                                                         String observationTime,
                                                         LocalDateDoubleTimeSeries series) {
          final LocalDateDoubleEntryIterator iterator = series.iterator();
          while (iterator.hasNext()) {
            final Map.Entry<LocalDate, Double> entry = iterator.next();
            final UniqueId id = UniqueId.of(htsId.getScheme().getName(), htsId.getValue());
            source.updateTimeSeriesPoint(id, source.getCurrentSimulationExecutionDate(), entry.getKey(), entry.getValue());
          }
          return series;
        }

        @Override
View Full Code Here


  //-------------------------------------------------------------------------
  @Override
  public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
    final JedisPool jedisPool = getRedisConnector().getJedisPool();
    final RedisSimulationSeriesSource  instance = new RedisSimulationSeriesSource(jedisPool, getRedisPrefix());
    if (_simulationDate != null) {
      instance.setCurrentSimulationExecutionDate(_simulationDate);
    }
    HistoricalTimeSeriesResolver resolver = new RedisSimulationSeriesResolver(instance);

    ComponentInfo infoResolver = new ComponentInfo(HistoricalTimeSeriesResolver.class, getClassifier());
    infoResolver.addAttribute(ComponentInfoAttributes.LEVEL, 1);
View Full Code Here

TOP

Related Classes of com.opengamma.core.historicaltimeseries.impl.RedisSimulationSeriesSource

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.