Package com.opengamma.financial.security.swap

Examples of com.opengamma.financial.security.swap.SwapSecurity


          SwapLegBeanOperation.createSwapLeg(bean.getReceiveLeg()), zonedDateTimeBeanToDateTimeWithZone(bean.getForwardStartDate()));
      }

      @Override
      public SwapSecurity visitSwapSecurity(SwapSecurity ignore) {
        return new SwapSecurity(zonedDateTimeBeanToDateTimeWithZone(bean.getTradeDate()), zonedDateTimeBeanToDateTimeWithZone(bean.getEffectiveDate()), zonedDateTimeBeanToDateTimeWithZone(bean
          .getMaturityDate()), bean.getCounterparty(), SwapLegBeanOperation.createSwapLeg(bean.getPayLeg()), SwapLegBeanOperation.createSwapLeg(bean.getReceiveLeg()));
      }

      @Override
      public SwapSecurity visitYearOnYearInflationSwapSecurity(YearOnYearInflationSwapSecurity security) {
View Full Code Here


    final InterestRateNotional notional = new InterestRateNotional(Currency.USD, 1000000 * (1 + random.nextInt(50)));
    final FloatingInterestRateLeg iborLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, FOLLOWING, notional, true,
        iborReferenceRate, FloatingRateType.IBOR);
    final FloatingInterestRateLeg cmsLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, FOLLOWING, notional, true,
        cmsId, FloatingRateType.CMS);
    SwapSecurity security;
    boolean payIbor;
    if (random.nextBoolean()) {
      security = new SwapSecurity(tradeDate, tradeDate, maturityDate, COUNTERPARTY, iborLeg, cmsLeg);
      payIbor = true;
    } else {
      security = new SwapSecurity(tradeDate, tradeDate, maturityDate, COUNTERPARTY, cmsLeg, iborLeg);
      payIbor = false;
    }
    security.setName(CURRENCY.getCode() + " " + FORMAT.format(notional.getAmount() / 1000000) + "MM Swap, pay " +
        (payIbor ? frequency.getPeriod().getMonths() + "M Libor, receive " + tenor.getPeriod().getYears() + "Y ISDA fixing (" :
          tenor.getPeriod().getYears() + "Y ISDA fixing, receive " + frequency.getPeriod().getMonths() + "M Libor (") +
          tradeDate.toLocalDate().toString() + " - " + maturityDate.toLocalDate().toString() + ")");
    security.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return security;
  }
View Full Code Here

  protected SecurityPersister getSecurityPersister() {
    return _securityPersister;
  }

  protected SwapSecurity createUnderlying(final ZonedDateTime earliestMaturity, final ZonedDateTime swaptionExpiry) {
    SwapSecurity security;
    do {
      do {
        getUnderlyingGenerator().setSwationExpiry(swaptionExpiry.toLocalDate());
        security = getUnderlyingGenerator().createSecurity();
      } while (security == null);
    } while ((FinancialSecurityUtils.getCurrency(security) == null) || security.getMaturityDate().isBefore(earliestMaturity));
    return security;
  }
View Full Code Here

  @Override
  public SwaptionSecurity createSecurity() {
    final int optionLength = getRandom(OPTION_LENGTH);
    ZonedDateTime expiry = ZonedDateTime.now().plusMonths(optionLength);
    final SwapSecurity underlying = createUnderlying(expiry.plusMonths(2), expiry);
    final Currency currency = FinancialSecurityUtils.getCurrency(underlying);
    expiry = nextWorkingDay(expiry, currency);
    final boolean isPayer = getRandom().nextBoolean();
    final boolean isLong = getRandom().nextBoolean();
    final boolean isCashSettled = getRandom().nextBoolean();
    final ZonedDateTime settlementDate = nextWorkingDay(expiry.plusDays(2), currency);
    final Double notional = underlying.getPayLeg().getNotional().accept(new NotionalVisitor<Double>() {

      @Override
      public Double visitCommodityNotional(final CommodityNotional notional) {
        return null;
      }

      @Override
      public Double visitInterestRateNotional(final InterestRateNotional notional) {
        return notional.getAmount();
      }

      @Override
      public Double visitSecurityNotional(final SecurityNotional notional) {
        return null;
      }

      @Override
      public Double visitVarianceSwapNotional(final VarianceSwapNotional notional) {
        return notional.getAmount();
      }

    });
    if (notional == null) {
      return null;
    }
    Double rate = getRate(underlying.getPayLeg());
    if (rate == null) {
      rate = getRate(underlying.getReceiveLeg());
      if (rate == null) {
        return null;
      }
    }
    final SwaptionSecurity security = new SwaptionSecurity(isPayer, getSecurityPersister().storeSecurity(underlying).iterator().next(), isLong, new Expiry(expiry), isCashSettled, currency, notional,
        new EuropeanExerciseType(), settlementDate);
    security.setName(createName(currency, optionLength, (int) MONTHS.between(underlying.getEffectiveDate(), underlying.getMaturityDate()), notional, rate));
    return security;
  }
View Full Code Here

        frequency = SEMI_ANNUAL;
        euribor = EURIBOR_6M;
        frequencyLabel = "6m Euribor";
      }
      final FloatingInterestRateLeg floatingLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, MODIFIED_FOLLOWING, notional, false, euribor, FloatingRateType.IBOR);
      final SwapSecurity swap;
      final String name;
      if (random.nextBoolean()) {
        swap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, fixedLeg, floatingLeg);
        name = years + "Y EUR " + FORMATTER.format(notional.getAmount() / 1000000) + "MM, pay " + FORMATTER.format(rate * 100) + "% vs " + frequencyLabel;
      } else {
        swap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, floatingLeg, fixedLeg);
        name = years + "Y EUR " + FORMATTER.format(notional.getAmount() / 1000000) + "MM, receive " + FORMATTER.format(rate * 100) + "% vs " + frequencyLabel;
      }
      swap.setName(name);
      swap.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
      securities.add(swap);
    }
    return securities;
  }
View Full Code Here

        frequency = QUARTERLY;
      } else {
        frequency = SEMI_ANNUAL;
      }
      final FloatingInterestRateLeg floatingLeg = new FloatingInterestRateLeg(ACT_360, frequency, REGION, MODIFIED_FOLLOWING, notional, false, EONIA, FloatingRateType.OIS);
      final SwapSecurity swap;
      final String name;
      if (random.nextBoolean()) {
        swap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, fixedLeg, floatingLeg);
        name = years + "Y EUR " + FORMATTER.format(notional.getAmount() / 1000000) + "MM, pay " + FORMATTER.format(rate * 100) + "% vs EONIA";
      } else {
        swap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, floatingLeg, fixedLeg);
        name = years + "Y EUR " + FORMATTER.format(notional.getAmount() / 1000000) + "MM, receive " + FORMATTER.format(rate * 100) + "% vs EONIA";
      }
      swap.setName(name);
      swap.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
      securities.add(swap);
    }
    return securities;
  }
View Full Code Here

        receiveRate = EURIBOR_3M;
        payLeg = new FloatingInterestRateLeg(ACT_360, payFrequency, REGION, MODIFIED_FOLLOWING, notional, false, payRate, FloatingRateType.IBOR);
        receiveLeg = new FloatingSpreadIRLeg(ACT_360, receiveFrequency, REGION, MODIFIED_FOLLOWING, notional, false, receiveRate, FloatingRateType.IBOR, spread);
        frequencyLabel = "receive 3M Euribor + " + FORMATTER.format((int) (spread * 1000)) + "bp, pay 6M Euribor";
      }
      final SwapSecurity swap = new SwapSecurity(tradeDate, effectiveDate, maturityDate, COUNTERPARTY, payLeg, receiveLeg);
      final String name = years + "Y EUR " + FORMATTER.format(notional.getAmount() / 1000000) + "MM, " + frequencyLabel;
      swap.setName(name);
      swap.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
      securities.add(swap);
    }
    return securities;
  }
View Full Code Here

        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following"),
        new InterestRateNotional(Currency.GBP, 234),
        false,
        ExternalId.of("Rate", "asdf"),
        FloatingRateType.IBOR);
    SwapSecurity security = new SwapSecurity(tradeDate, effectiveDate, maturityDate, "cpty", payLeg, receiveLeg);
    security.setName("Test swap");

    JsonDataSink sink = new JsonDataSink(BlotterUtils.getJsonBuildingConverters());
    BeanTraverser traverser = new BeanTraverser(s_propertyFilter);
    BeanVisitor<JSONObject> writingVisitor = new BuildingBeanVisitor<>(security, sink);
    JSONObject json = (JSONObject) traverser.traverse(SwapSecurity.meta(), writingVisitor);
    assertNotNull(json);
//    System.out.println(json);

    JsonBeanDataSource dataSource = new JsonBeanDataSource(new JSONObject(json.toString()));
    MetaBeanFactory metaBeanFactory = new MapMetaBeanFactory(ImmutableSet.<MetaBean>of(
        SwapSecurity.meta(),
        FixedInterestRateLeg.meta(),
        FloatingInterestRateLeg.meta(),
        InterestRateNotional.meta()));
    BeanVisitor<BeanBuilder<SwapSecurity>> readingVisitor =
        new BeanBuildingVisitor<>(dataSource, metaBeanFactory, BlotterUtils.getBeanBuildingConverters());
    BeanBuilder<SwapSecurity> beanBuilder =
        (BeanBuilder<SwapSecurity>) traverser.traverse(SwapSecurity.meta(), readingVisitor);
    SwapSecurity security2 = beanBuilder.build();
    assertEquals(security, security2);
  }
View Full Code Here

    ExternalId underlyingId = updatedSecurity.getUnderlyingId();
    SecuritySearchRequest searchRequest = new SecuritySearchRequest();
    searchRequest.setExternalIdSearch(new ExternalIdSearch(underlyingId));
    SecuritySearchResult searchResult = _securityMaster.search(searchRequest);
    SwapSecurity updatedUnderlying = (SwapSecurity) searchResult.getSingleSecurity();
    ZonedDateTime tradeDate = ZonedDateTime.of(LocalDateTime.of(2013, 1, 1, 11, 0), ZoneOffset.UTC);
    assertEquals(tradeDate, updatedUnderlying.getTradeDate());
  }
View Full Code Here

    return SwaptionSecurity.SECURITY_TYPE;
  }

  @Override
  public Summary getSummary(SwaptionSecurity security) {
    SwapSecurity underlyingSecurity = (SwapSecurity) _securitySource.getSingle(ExternalIdBundle.of(security.getUnderlyingId()));
    return SwapSummaryFactory.append(SummaryBuilder.create(security), underlyingSecurity)
        .with(SummaryField.MATURITY, security.getExpiry()).build();
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.security.swap.SwapSecurity

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.