Package com.opengamma.financial.tool

Examples of com.opengamma.financial.tool.ToolContext


  }

  //-------------------------------------------------------------------------
  @Override
  protected void doRun() {
    ToolContext toolContext = getToolContext();
    ConfigMaster configMaster = toolContext.getConfigMaster();

    CommandLine commandLine = getCommandLine();
    final String name = commandLine.getOptionValue("name", WILDCARD_SEARCH);
    final boolean dryRun = commandLine.hasOption("do-not-persist");
    final boolean skipExisting = commandLine.hasOption("skip");
View Full Code Here


    System.exit(0);
  }

  @Override
  protected void doRun() throws Exception {
    ToolContext toolContext = getToolContext();
    OrphanedPositionRemover orphanedPositionRemover = new OrphanedPositionRemover(toolContext.getPortfolioMaster(), toolContext.getPositionMaster());
    s_logger.info("running orphanedPositionRemover");
    orphanedPositionRemover.run();
    toolContext.close();
  }
View Full Code Here

    }
    return portfolioId;
  }

  private UniqueId createReferencePortfolio() {
    ToolContext toolContext = getToolContext();
    BloombergReferencePortfolioMaker portfolioMaker = new BloombergReferencePortfolioMaker(toolContext.getPortfolioMaster(), toolContext.getPositionMaster(), toolContext.getSecurityMaster());
    portfolioMaker.run();
    return findPortfolioId(BloombergReferencePortfolioMaker.PORTFOLIO_NAME);
  }
View Full Code Here

  }
 
  @Override
  protected void doRun() throws Exception {
    CommandLine commandLine = getCommandLine();
    ToolContext toolContext = getToolContext();
    ConfigMaster configMaster = toolContext.getConfigMaster();

    MultiFileConfigSaver saver = new MultiFileConfigSaver();
    saver.setDestinationDirectory(commandLine.getOptionValue("d"));
    saver.setConfigMaster(configMaster);
    saver.run();
View Full Code Here

    _serverUrl = serverUrl;
  }

  @Override
  protected void doRun() throws Exception {
    ToolContext toolContext = getToolContext();
    loadSecurity(toolContext.getSecurityMaster());
    loadPortfolio(toolContext.getPortfolioMaster(), toolContext.getPositionMaster(), toolContext.getSecurityMaster(), toolContext.getSecuritySource());
    loadConfig(toolContext.getConfigMaster(), toolContext.getPortfolioMaster());
    loadHistoricalTimeSeries(toolContext.getHistoricalTimeSeriesMaster());
    loadSnapshot(toolContext.getMarketDataSnapshotMaster());
    loadFunctionConfiguration(toolContext.getConfigMaster());
    _executorService.shutdown();
  }
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Override
  protected void doRun() {
    ToolContext toolContext = getToolContext();
    ConfigMaster configMaster = toolContext.getConfigMaster();

    CommandLine commandLine = getCommandLine();
    final String name = commandLine.getOptionValue("name", WILDCARD_SEARCH);
    final boolean dryRun = commandLine.hasOption("do-not-persist");
    final boolean skipExisting = commandLine.hasOption("skip");
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Override
  protected void doRun() {
    ToolContext toolContext = getToolContext();
    ConfigMaster configMaster = toolContext.getConfigMaster();
    PortfolioMaster portfolioMaster = toolContext.getPortfolioMaster();
    CommandLine commandLine = getCommandLine();
    @SuppressWarnings("unchecked")
    List<String> fileList = commandLine.getArgList();
    boolean portPortfolioRefs = commandLine.hasOption("portable-portfolios");
    boolean verbose = commandLine.hasOption("verbose");
View Full Code Here

  }

  //-------------------------------------------------------------------------
  @Override
  protected void doRun() {
    ToolContext toolContext = getToolContext();
    CommandLine commandLine = getCommandLine();
    boolean verbose = commandLine.hasOption("verbose");
    if ((commandLine.hasOption("today") && commandLine.hasOption("yesterday")) ||
        (commandLine.hasOption("date") && commandLine.hasOption("today")) ||
        (commandLine.hasOption("date") && commandLine.hasOption("yesterday"))) {
      System.err.println("Can only return today OR yesterday OR date!");
      System.exit(2);
    }
    String ccyStr = commandLine.getOptionValue("ccy");
    try {
      Currency ccy = Currency.of(ccyStr);
      LocalDate date = null;
      if (commandLine.hasOption("yesterday")) {
        date = LocalDate.now().minusDays(1);
      } else if (commandLine.hasOption("today")) {
        date = LocalDate.now();
      } else if (commandLine.hasOption("date")) {
        try {
          date = (LocalDate) DateTimeFormatter.BASIC_ISO_DATE.parse(commandLine.getOptionValue("date"));
        } catch (Exception e) {
          System.err.println("Could not parse date, should be YYYYMMDD format");
          System.exit(2);
        }
      } else {
        System.err.println("Must specify either today or yesterday option");
        System.exit(2);
      }
      boolean isHoliday = toolContext.getHolidaySource().isHoliday(date, ccy);
      if (isHoliday) {
        if (verbose) {
          System.out.println("Day was a holiday");
        }
        System.exit(0);
View Full Code Here

    // Get the remote component server using the supplied URI
    RemoteComponentServer remoteComponentServer = new RemoteComponentServer(URI.create(configResourceLocation));
    ComponentServer componentServer = remoteComponentServer.getComponentServer();
   
    // Attempt to build a tool context of the specified type
    ToolContext toolContext;
    try {
      toolContext = toolContextClazz.newInstance();
    } catch (Throwable t) {
      return null;
    }
   
    // Populate the tool context from the remote component server
    for (MetaProperty<?> metaProperty : toolContext.metaBean().metaPropertyIterable()) {
      if (!metaProperty.name().equals("contextManager")) {
        try {
          ComponentInfo componentInfo = getComponentInfo(componentServer, classifierChain, metaProperty.propertyType());
          if (componentInfo == null) {
            s_logger.warn("Unable to populate tool context '" + metaProperty.name() +
                "', no appropriate component found on the server");
            continue;
          }
          if (ViewProcessor.class.equals(componentInfo.getType())) {
            final JmsConnector jmsConnector = createJmsConnector(componentInfo);
            final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("rvp"));
            ViewProcessor vp = new RemoteViewProcessor(componentInfo.getUri(), jmsConnector, scheduler);
            toolContext.setViewProcessor(vp);
            toolContext.setContextManager(new Closeable() {
              @Override
              public void close() throws IOException {
                scheduler.shutdownNow();
                jmsConnector.close();
              }
View Full Code Here

  private ViewProcessor _viewProcessor;

  //-------------------------------------------------------------------------
  @Override
  public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) {
    ToolContext context = createToolContext();
    Map<String, MetaProperty<?>> mapTarget = new HashMap<String, MetaProperty<?>>(context.metaBean().metaPropertyMap());
    mapTarget.keySet().retainAll(this.metaBean().metaPropertyMap().keySet());
    for (MetaProperty<?> mp : mapTarget.values()) {
      mp.set(context, mp.get(this));
    }
    context.setContextManager(repo);
    repo.registerComponent(ToolContext.class, getClassifier(), context);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.tool.ToolContext

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.