Package com.opengamma.id

Examples of com.opengamma.id.ExternalId


    for (final Currency currency : currencies) {
      for (final String swapType : new String[]{"SWAP", "3M_SWAP", "6M_SWAP"}) {
        final String product = currency.getCode() + "_" + swapType;
        final ConventionBundle convention = cbs.getConventionBundle(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, product));
        if (convention != null) {
          final ExternalId initialRate = convention.getSwapFloatingLegInitialRate();
          final ConventionBundle realIdConvention = cbs.getConventionBundle(initialRate);
          externalInitialRateId.add(realIdConvention.getIdentifiers().getExternalId(ExternalSchemes.BLOOMBERG_TICKER));
        } else {
          s_logger.info("No convention for {} product", product);
        }
View Full Code Here


  private ExternalId getUnderlying(final Currency ccy, final LocalDate tradeDate, final Tenor tenor) {
    final CurveSpecificationBuilderConfiguration curveSpecConfig = getCurrencyCurveConfig(ccy);
    if (curveSpecConfig == null) {
      return null;
    }
    final ExternalId swapSecurity;
    if (ccy.equals(Currency.USD)) {
      // Standard (i.e. matches convention) floating leg tenor for USD is 3M
      swapSecurity = curveSpecConfig.getSwap3MSecurity(tradeDate, tenor);
    } else {
      // Standard (i.e. matches convention) floating leg tenor for CHF, JPY, GBP, EUR is 6M
View Full Code Here

      tenor1 = getRandom(SHORT_TENORS);
      tenor2 = getRandom(LONG_TENORS);
    } while (tenor1.compareTo(tenor2) >= 0);
    final int length = getRandom(tenor2.getPeriod().getYears() - 5) + 3;
    final ZonedDateTime maturityDate = nextWorkingDay(startDate.plusYears(length), currency);
    final ExternalId shortIdentifier = getUnderlying(currency, startDate.toLocalDate(), tenor1);
    final ExternalId longIdentifier = getUnderlying(currency, startDate.toLocalDate(), tenor2);
    final double strike = getRandom(STRIKES);
    final Frequency frequency = getRandom(FREQUENCY);
    final DayCount dayCount = getRandom(DAY_COUNT);
    CapFloorCMSSpreadSecurity security = null;
    if (shortIdentifier != null && longIdentifier != null) {
View Full Code Here

      try {
        Security security = position.getSecurityLink().getTarget();
        if (security == null) {
          security = position.getSecurityLink().resolve(_secSource);
        }
        ExternalId id = FinancialSecurityUtils.getRegion(security);
        if (_regionSource != null) {
          if (id != null) {
            Region highestLevelRegion = _regionSource.getHighestLevelRegion(id);
            if (highestLevelRegion != null) {
              return highestLevelRegion.getName();
            } else {
              return id.getValue();
            }
          } else if (_exchangeSource != null) {
            ExternalId exchangeId = FinancialSecurityUtils.getExchange(security);
            if (exchangeId != null) {
              Exchange exchange = _exchangeSource.getSingle(exchangeId);
              if (exchange == null) {
                s_logger.info("No exchange could be found with ID {}", exchangeId);
                return NO_REGION;
View Full Code Here

      final int years = 1 + random.nextInt(30);
      final ZonedDateTime maturityDate = tradeDate.plusYears(years);
      final double rate = years * 0.001 + random.nextDouble() / 5000;
      final FixedInterestRateLeg fixedLeg = new FixedInterestRateLeg(ACT_360, SEMI_ANNUAL, REGION, MODIFIED_FOLLOWING, notional, false, rate);
      final Frequency frequency;
      final ExternalId euribor;
      final String frequencyLabel;
      if (random.nextBoolean()) {
        frequency = QUARTERLY;
        euribor = EURIBOR_3M;
        frequencyLabel = "3m Euribor";
View Full Code Here

      final InterestRateNotional notional = new InterestRateNotional(CURRENCY, 10000000 * (1 + random.nextInt(9)));
      final int years = 1 + random.nextInt(30);
      final ZonedDateTime maturityDate = tradeDate.plusYears(years);
      final double spread = years * 0.002 + random.nextDouble() / 1000.;
      final Frequency payFrequency, receiveFrequency;
      final ExternalId payRate, receiveRate;
      final FloatingInterestRateLeg payLeg, receiveLeg;
      final String frequencyLabel;
      if (random.nextBoolean()) {
        payFrequency = QUARTERLY;
        receiveFrequency = SEMI_ANNUAL;
View Full Code Here

    ExternalIdBundle bundle = null;
    if (security.getExternalIdBundle().size() > 0) {
      final Iterator<ExternalId> iterator = security.getExternalIdBundle().iterator();
      bundle = ExternalIdBundle.EMPTY;
      // retrieve with one identifier
      ExternalId id = iterator.next();
      bundle = bundle.withExternalId(id);
      sec = getSecurity(bundle);
      normalizeSecurity(sec);
      assertEquals(security, sec);
      // retrieve with one valid and one incorrect identifier
View Full Code Here

    return getFixedRate(security.getReceiveLeg());
  }

  private static String getUnderlying(final SwapSecurity security) {
    if (SwapSecurityUtils.isFloatFloat(security)) {
      final ExternalId payRefRate = getReferenceRate(security.getPayLeg());
      final ExternalId receiveRefRate = getReferenceRate(security.getReceiveLeg());
      return payRefRate.getValue() + "/" + receiveRefRate.getValue();
    } else {
      final SwapLeg floatingLeg = isFixedLeg(security.getPayLeg()) ? security.getReceiveLeg() : security.getPayLeg();
      return getReferenceRate(floatingLeg).getValue();
    }
  }
View Full Code Here

   * Simple security
   */
  @Test
  public void fxForward() throws JSONException {
    ZonedDateTime forwardDate = zdt(2012, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC);
    ExternalId regionId = ExternalId.of(ExternalSchemes.FINANCIAL, "GB");
    FXForwardSecurity fxForward = new FXForwardSecurity(Currency.USD, 150, Currency.GBP, 100, forwardDate, regionId);
    fxForward.setName("GBP/USD forward");

    JsonDataSink sink = new JsonDataSink(BlotterUtils.getJsonBuildingConverters());
    BeanVisitor<JSONObject> writingVisitor = new BuildingBeanVisitor<>(fxForward, sink);
View Full Code Here

    assertEquals(BigDecimal.ONE, position.getQuantity());
    SwaptionSecurity security = (SwaptionSecurity) _securityMaster.get(trade.getSecurityLink().getObjectId(),
                                                                       VersionCorrection.LATEST).getSecurity();
    assertNotNull(security);
    // check this later
    ExternalId underlyingId = security.getUnderlyingId();
    security.setUniqueId(null); // so it can be tested for equality against the unsaved version
    security.setUnderlyingId(BlotterTestUtils.SWAPTION.getUnderlyingId()); // will need this later
    assertEquals(BlotterTestUtils.SWAPTION, security);
    assertEquals(COUNTERPARTY_ID, trade.getCounterpartyExternalId());
    assertEquals(PREMIUM, trade.getPremium());
View Full Code Here

TOP

Related Classes of com.opengamma.id.ExternalId

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.