Examples of MasterConfigSource


Examples of com.opengamma.master.config.impl.MasterConfigSource

    return security;
  }

  private Double getSwapRate(final Currency ccy, final LocalDate tradeDate, final Tenor maturity) {
    final HistoricalTimeSeriesSource historicalSource = getToolContext().getHistoricalTimeSeriesSource();
    final MasterConfigSource configSource = new MasterConfigSource(getToolContext().getConfigMaster());
    final ExternalId swapRateForMaturityIdentifier = getSwapRateFor(configSource, ccy, tradeDate, maturity);
    if (swapRateForMaturityIdentifier == null) {
      throw new OpenGammaRuntimeException("Couldn't get swap rate identifier for " + ccy + " [" + maturity + "]" + " from " + tradeDate);
    }
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

   * Synthetic currency matrix config name
   */
  public static final String SYNTHETIC_LIVE_DATA = "SyntheticLiveData";

  public static ConfigMaster populateCurrencyMatrixConfigMaster(final ConfigMaster cfgMaster) {
    final CurrencyPairs currencies = new MasterConfigSource(cfgMaster).getSingle(CurrencyPairs.class, CurrencyPairs.DEFAULT_CURRENCY_PAIRS, VersionCorrection.LATEST);
    storeCurrencyMatrix(cfgMaster, BLOOMBERG_LIVE_DATA, createBloombergConversionMatrix(currencies));
    storeCurrencyMatrix(cfgMaster, SYNTHETIC_LIVE_DATA, createSyntheticConversionMatrix(currencies));
    return cfgMaster;
  }
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

    return tradeDate;
  }

  private Double getSwapRate(final Currency ccy, final LocalDate tradeDate, final Tenor maturity) {
    final HistoricalTimeSeriesSource historicalSource = getToolContext().getHistoricalTimeSeriesSource();
    final MasterConfigSource configSource = new MasterConfigSource(getToolContext().getConfigMaster());
    final ExternalId swapRateForMaturityIdentifier = getSwapRateFor(configSource, ccy, tradeDate, maturity);
    if (swapRateForMaturityIdentifier == null) {
      throw new OpenGammaRuntimeException("Couldn't get swap rate identifier for " + ccy + " [" + maturity + "]" + " from " + tradeDate);
    }
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

  public void setUp() throws Exception {
    _uriInfo = new MockUriInfo();
    _trades = getTrades();
    _secMaster = new InMemorySecurityMaster(new ObjectIdSupplier("Mock"));
    _positionMaster = new InMemoryPositionMaster();
    final MasterConfigSource configSource = new MasterConfigSource(new InMemoryConfigMaster());
    final InMemoryHistoricalTimeSeriesMaster htsMaster = new InMemoryHistoricalTimeSeriesMaster();
    final HistoricalTimeSeriesResolver htsResolver = new DefaultHistoricalTimeSeriesResolver(new DefaultHistoricalTimeSeriesSelector(configSource), htsMaster);
    _htsSource = new MasterHistoricalTimeSeriesSource(htsMaster, htsResolver);
    _securitySource = new InMemorySecuritySource();
    _secLoader = new AbstractSecurityLoader() {
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

  private String _functionDefinitionName;
 
  //-------------------------------------------------------------------------
  @Override
  protected FunctionConfigurationSource initSource() {
    FunctionConfigurationDefinitionAggregator definitionAggregator = new FunctionConfigurationDefinitionAggregator(new MasterConfigSource(getConfigMaster()));
    List<FunctionConfigurationSource> underlying = Lists.newArrayList(definitionAggregator.aggregate(_functionDefinitionName));
    underlying.addAll(curveAndSurfaceSources());
   
    final FunctionConfigurationSource[] array = underlying.toArray(new FunctionConfigurationSource[underlying.size()]);
    return CombiningFunctionConfigurationSource.of(array);
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

    fixCDSOptionsStrike();
  }

  private void fixCDSOptionsStrike() {

    final MasterConfigSource configSource = new MasterConfigSource(getToolContext().getConfigMaster());
    final SecurityMaster securityMaster = getToolContext().getSecurityMaster();

    String snapshotName = "Sameday spread";
    MarketDataSnapshotSearchRequest marketDataSnapshotSearchRequest = new MarketDataSnapshotSearchRequest();
    marketDataSnapshotSearchRequest.setName(snapshotName);
    MarketDataSnapshotSearchResult marketDataSnapshotSearchResult = getToolContext().getMarketDataSnapshotMaster().search(marketDataSnapshotSearchRequest);
    ManageableMarketDataSnapshot snapshot = marketDataSnapshotSearchResult.getFirstSnapshot();

    PortfolioSearchRequest portfolioSearchRequest = new PortfolioSearchRequest();
    portfolioSearchRequest.setName("CDSOpts");
    //portfolioSearchRequest.setName("Standard CDS Portfolio");
    List<ManageablePortfolio> portfolios = getToolContext().getPortfolioMaster().search(portfolioSearchRequest).getPortfolios();
    for (ManageablePortfolio portfolio : portfolios) {

      List<ObjectId> positionIds = portfolio.getRootNode().getPositionIds();
      List<UniqueId> positionUids = newArrayList();
      for (ObjectId positionId : positionIds) {
        positionUids.add(positionId.atLatestVersion());
      }
      Map<UniqueId, PositionDocument> positions = getToolContext().getPositionMaster().get(positionUids);

      // Ticker, RedCode, Currency, Term, Seniority, RestructuringClause
      final List<ExternalId> cdsArgs = newArrayList();


      final SecureRandom random = new SecureRandom();
      for (PositionDocument positionDocument : positions.values()) {
        ManageablePosition position = positionDocument.getValue();

        ManageableSecurityLink link = position.getSecurityLink();
        SecuritySearchRequest ssr = new SecuritySearchRequest();
        ssr.addExternalIds(link.getExternalIds());
        SecuritySearchResult securitySearchResult = getToolContext().getSecurityMaster().search(ssr);
        Security security = securitySearchResult.getFirstSecurity();
        //Security security = position.getSecurity();
        if (security != null && security instanceof CreditDefaultSwapOptionSecurity) {
          CreditDefaultSwapOptionSecurity cdsOption = (CreditDefaultSwapOptionSecurity) security;
          CreditDefaultSwapSecurity cds = (CreditDefaultSwapSecurity) this.getToolContext().getSecuritySource().getSingle(
              cdsOption.getUnderlyingId().toBundle());

          String curveDefinitionID = "SAMEDAY_" + cds.getReferenceEntity().getValue() + "_" + cds.getNotional().getCurrency() + "_" +
              cds.getDebtSeniority().toString() + "_" + cds.getRestructuringClause();

          ConfigSearchRequest<CurveDefinition> curveDefinitionConfigSearchRequest = new ConfigSearchRequest<CurveDefinition>(CurveDefinition.class);
          curveDefinitionConfigSearchRequest.setName(curveDefinitionID);
          CurveDefinition curveDefinition = getToolContext().getConfigMaster().search(
              curveDefinitionConfigSearchRequest).getFirstValue().getValue();
        /*final CurveDefinition curveDefinition = configSource.getSingle(CurveDefinition.class,
                                                                       curveName,
                                                                       VersionCorrection.LATEST);

        if (curveDefinition == null) {
          throw new OpenGammaRuntimeException("No curve definition for " + curveName);
        }

        //Map<Tenor, CurveNode> curveNodesByTenors = new HashMap<Tenor, CurveNode>();
        //for (CurveNode curveNode : curveDefinition.getNodes()) {
        //  curveNodesByTenors.put(curveNode.getResolvedMaturity(), curveNode);
        //}
        Map<Tenor, CurveNode> curveNodesByTenors = functional(curveDefinition.getNodes()).groupBy(new Function1<CurveNode, Tenor>() {
          @Override
          public Tenor execute(CurveNode curveNode) {
            return curveNode.getResolvedMaturity();
          }
        });*/

          ZonedDateTime start = cds.getStartDate();
          ZonedDateTime maturity = cds.getMaturityDate();
          Period period = Period.between(start.toLocalDate(), maturity.toLocalDate());
          Tenor tenor = Tenor.of(period);


          final CurveNodeIdMapper curveNodeIdMapper = configSource.getSingle(CurveNodeIdMapper.class,
                                                                             curveDefinitionID,
                                                                             VersionCorrection.LATEST);


          try {
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

  private Double getFixedRate(final SecureRandom random,
                              final LocalDate tradeDate,
                              final ExternalId curveId) {
    final HistoricalTimeSeriesSource historicalSource = getToolContext().getHistoricalTimeSeriesSource();
    final MasterConfigSource configSource = new MasterConfigSource(getToolContext().getConfigMaster());

    final HistoricalTimeSeries fixedRateSeries = historicalSource.getHistoricalTimeSeries("PX_LAST",
                                                                                          curveId.toBundle(),
                                                                                          HistoricalTimeSeriesRatingFieldNames.DEFAULT_CONFIG_NAME,
                                                                                          tradeDate,
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

   *
   * @param repo  the component repository, only used to register secondary items like lifecycle, not null
   * @return the config source, not null
   */
  protected ConfigSource createConfigSource(ComponentRepository repo) {
    ConfigSource source = new MasterConfigSource(getConfigMaster());
    if (getCacheManager() != null) {
      source = new EHCachingMasterConfigSource(getConfigMaster(), getCacheManager());
    }
    return source;
  }
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

    s_logger.info(sb.toString());
    return swaps;
  }

  private void fetch(final List<Triple<Currency, LocalDate, Tenor>> swapsArgs) {
    final MasterConfigSource configSource = new MasterConfigSource(getToolContext().getConfigMaster());
    final Set<ExternalId> externalIds = newHashSet();
    for (final Triple<Currency, LocalDate, Tenor> swapArgs : swapsArgs) {
      final ExternalId swapRateForMaturityIdentifier = getSwapRateFor(configSource, swapArgs.getFirst(), swapArgs.getSecond(), swapArgs.getThird());
      externalIds.add(swapRateForMaturityIdentifier);
    }
View Full Code Here

Examples of com.opengamma.master.config.impl.MasterConfigSource

    return swap;
  }

  private Double getFixedRate(final SecureRandom random, final Currency ccy, final LocalDate tradeDate, final Tenor maturity) {
    final HistoricalTimeSeriesSource historicalSource = getToolContext().getHistoricalTimeSeriesSource();
    final MasterConfigSource configSource = new MasterConfigSource(getToolContext().getConfigMaster());
    final ExternalId swapRateForMaturityIdentifier = getSwapRateFor(configSource, ccy, tradeDate, maturity);
    if (swapRateForMaturityIdentifier == null) {
      throw new OpenGammaRuntimeException("Couldn't get swap rate identifier for " + ccy + " [" + maturity + "]" + " from " + tradeDate);
    }
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.