Examples of SwapLeg


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

    final ZonedDateTime effectiveDate = ZonedDateTime.now().plusMonths(23);
    final ZonedDateTime maturityDate = ZonedDateTime.now().plusMonths(25);
    final String counterparty = "counterparty";
    final Notional notional = interestRateNotional();
    final boolean payLegFixed = bool();
    final SwapLeg payLeg = payLegFixed ? fixedInterestRateLeg(notional) : floatingInterestRateLeg(notional);
    final SwapLeg receiveLeg = payLegFixed ? floatingInterestRateLeg(notional) : fixedInterestRateLeg(notional);
    final ZonedDateTime forwardStartDate = ZonedDateTime.now().plusMonths(12);
    final ForwardSwapSecurity security = new ForwardSwapSecurity(tradeDate, effectiveDate, maturityDate, counterparty, payLeg, receiveLeg, forwardStartDate);
    store(security);
    return security;
  }
View Full Code Here

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

    final ZonedDateTime effectiveDate = ZonedDateTime.now().plusMonths(23);
    final ZonedDateTime maturityDate = ZonedDateTime.now().plusMonths(25);
    final String counterparty = "counterparty";
    final Notional notional = interestRateNotional();
    final boolean payLegFixed = bool();
    final SwapLeg payLeg = payLegFixed ? fixedInterestRateLeg(notional) : floatingInterestRateLeg(notional);
    final SwapLeg receiveLeg = payLegFixed ? floatingInterestRateLeg(notional) : fixedInterestRateLeg(notional);
    final SwapSecurity security = new SwapSecurity(tradeDate, effectiveDate, maturityDate, counterparty, payLeg, receiveLeg);
    store(security);
    return security;
  }
View Full Code Here

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

    return Collections.singleton(_conventionBundleSource.getConventionBundle(security.getUnderlyingId()).getIdentifiers());
  }

  @Override
  public Set<ExternalIdBundle> visitSwapSecurity(final SwapSecurity security) {
    final SwapLeg payLeg = security.getPayLeg();
    final SwapLeg receiveLeg = security.getReceiveLeg();
    final Set<ExternalIdBundle> idBundles = new HashSet<>();
    if (payLeg instanceof FloatingInterestRateLeg) {
      final FloatingInterestRateLeg floatLeg = (FloatingInterestRateLeg) payLeg;
      idBundles.add(_conventionBundleSource.getConventionBundle(floatLeg.getFloatingReferenceRateId()).getIdentifiers());
    }
View Full Code Here

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

    Double fixedRate = (fixedRateSeries.getTimeSeries().getEarliestValue() + getRandom().nextDouble()) / 100d;
    Double notional = (double) (getRandom(99999) + 1) * 1000;
    ZonedDateTime tradeDateTime = tradeDate.atStartOfDay(ZoneOffset.UTC);
    ZonedDateTime maturityDateTime = tradeDate.plus(maturity.getPeriod()).atStartOfDay(ZoneOffset.UTC);
    String counterparty = "CParty";
    SwapLeg fixedLeg = new FixedInterestRateLeg(swapConvention.getSwapFixedLegDayCount(),
        swapConvention.getSwapFixedLegFrequency(),
        swapConvention.getSwapFixedLegRegion(),
        swapConvention.getSwapFixedLegBusinessDayConvention(),
        new InterestRateNotional(ccy, notional),
        false, fixedRate);
    FloatingInterestRateLeg floatingLeg = new FloatingInterestRateLeg(swapConvention.getSwapFloatingLegDayCount(),
        swapConvention.getSwapFloatingLegFrequency(),
        swapConvention.getSwapFloatingLegRegion(),
        swapConvention.getSwapFloatingLegBusinessDayConvention(),
        new InterestRateNotional(ccy, notional),
        false, tsIdentifier,
        FloatingRateType.IBOR);
    floatingLeg.setInitialFloatingRate(initialRate);
    String fixedLegDescription = RATE_FORMATTER.format(fixedRate);
    String floatingLegDescription = swapConvention.getSwapFloatingLegInitialRate().getValue();
    boolean isPayFixed = getRandom().nextBoolean();
    SwapLeg payLeg;
    String payLegDescription;
    SwapLeg receiveLeg;
    String receiveLegDescription;
    if (isPayFixed) {
      payLeg = fixedLeg;
      payLegDescription = fixedLegDescription;
      receiveLeg = floatingLeg;
View Full Code Here

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

    final ZonedDateTime tradeDateTime = tradeDate.atStartOfDay(ZoneOffset.UTC);
    final ZonedDateTime maturityDateTime = tradeDate.plus(maturity.getPeriod()).atStartOfDay(ZoneOffset.UTC);
    final String counterparty = "CParty";

    final SwapLeg fixedLeg = new FixedInterestRateLeg(swapConvention.getSwapFixedLegDayCount(),
      swapConvention.getSwapFixedLegFrequency(),
      swapConvention.getSwapFixedLegRegion(),
      swapConvention.getSwapFixedLegBusinessDayConvention(),
      new InterestRateNotional(ccy, notional),
      false, fixedRate);

    final FloatingInterestRateLeg floatingLeg = new FloatingInterestRateLeg(swapConvention.getSwapFloatingLegDayCount(),
      swapConvention.getSwapFloatingLegFrequency(),
      swapConvention.getSwapFloatingLegRegion(),
      swapConvention.getSwapFloatingLegBusinessDayConvention(),
      new InterestRateNotional(ccy, notional),
      false, ExternalId.of(liborIdentifier.getScheme().toString(), liborIdentifier.getValue()),
      FloatingRateType.IBOR);
    // look up the value on our chosen trade date
    final Double initialRate = getInitialRate(tradeDate, liborIdentifier);
    floatingLeg.setInitialFloatingRate(initialRate);

    final String fixedLegDescription = PortfolioLoaderHelper.RATE_FORMATTER.format(fixedRate);
    final String floatingLegDescription = swapConvention.getSwapFloatingLegInitialRate().getValue();
    SwapLeg payLeg;
    String payLegDescription;
    SwapLeg receiveLeg;
    String receiveLegDescription;
    if (isPayFixed) {
      payLeg = fixedLeg;
      payLegDescription = fixedLegDescription;
      receiveLeg = floatingLeg;
View Full Code Here

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

      final ZonedDateTime swapMaturity = swaptionExpiry.plusMonths(swapYears);
      final double amount = 100000 * (1 + rng.nextInt(30));
      final InterestRateNotional notional = new InterestRateNotional(currency, amount);
      final double rate = swapYears * rng.nextDouble() / 500;
      final Frequency frequency = currency.equals(Currency.USD) ? PeriodFrequency.QUARTERLY : PeriodFrequency.SEMI_ANNUAL;
      final SwapLeg fixedLeg = new FixedInterestRateLeg(DAY_COUNT, PeriodFrequency.SEMI_ANNUAL, region, BDC, notional, false, rate);
      final SwapLeg floatLeg = new FloatingInterestRateLeg(DAY_COUNT, frequency, region, BDC, notional, false, floatingRate, FloatingRateType.IBOR);
      final SwapLeg payLeg, receiveLeg;
      final String swapName, swaptionName;
      final boolean isLong = rng.nextBoolean();
      final boolean isCashSettled = rng.nextBoolean();
      final boolean payer;
      if (rng.nextBoolean()) {
View Full Code Here

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

  }

  private SecuritySource createSecuritySource() {
    final InMemorySecuritySource securities = new InMemorySecuritySource();
    final ZonedDateTime zdt = ZonedDateTime.now();
    final SwapLeg leg = new FixedInterestRateLeg(DayCountFactory.INSTANCE.getDayCount("ACT/365"), SimpleFrequency.ANNUAL, ExternalId.of("Test", "Region"),
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"), new InterestRateNotional(Currency.USD, 0d), false, 0d);
    final SwapSecurity security = new SwapSecurity(zdt, zdt, zdt, "Counterparty", leg, leg);
    security.addExternalId(ExternalId.of("Security", "Swap"));
    securities.addSecurity(security);
    return securities;
View Full Code Here

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

    _fooEquity.addExternalId(ExternalId.of("Test", "FooEquity"));
    _fooEquity.setName("Foo");
    _barEquity = new EquitySecurity("exchange", "exchangeCode", "Bar", Currency.USD);
    _barEquity.addExternalId(ExternalId.of("Test", "BarEquity"));
    _barEquity.setName("Bar");
    final SwapLeg swapLeg = new FixedInterestRateLeg(DayCountFactory.INSTANCE.getDayCount("ACT/365"), SimpleFrequency.SEMI_ANNUAL,
        ExternalId.of("Financial", "US"), BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"), new InterestRateNotional(Currency.USD, 10e6), false, 0.01);
    _swap = new SwapSecurity(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), "counterParty", swapLeg, swapLeg);
    _swap.addExternalId(ExternalId.of("Test", "Swap"));
  }
View Full Code Here

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

*
*/
public class SwapSecurityUtils {

  public static InterestRateInstrumentType getSwapType(final SwapSecurity security) {
    final SwapLeg payLeg = security.getPayLeg();
    final SwapLeg receiveLeg = security.getReceiveLeg();
    if (payLeg.getNotional() instanceof InterestRateNotional && receiveLeg.getNotional() instanceof InterestRateNotional) {
      final InterestRateNotional payNotional = (InterestRateNotional) payLeg.getNotional();
      final InterestRateNotional receiveNotional = (InterestRateNotional) receiveLeg.getNotional();
      if (!payNotional.getCurrency().equals(receiveNotional.getCurrency())) {
        return InterestRateInstrumentType.SWAP_CROSS_CURRENCY;
      }
    }
    if (!payLeg.getRegionId().equals(receiveLeg.getRegionId())) {
      throw new OpenGammaRuntimeException("Pay and receive legs must be from same region; have " + payLeg.getRegionId() + " and " + receiveLeg.getRegionId());
    }
    if (payLeg instanceof FixedInterestRateLeg && receiveLeg instanceof FloatingInterestRateLeg) {

      final FloatingInterestRateLeg floatingLeg = (FloatingInterestRateLeg) receiveLeg;
      if (floatingLeg instanceof FloatingSpreadIRLeg) {
View Full Code Here

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

    }
    throw new OpenGammaRuntimeException("Can only handle fixed-floating (pay and receive) swaps and floating-floating swaps");
  }

  public static boolean payFixed(final SwapSecurity security) {
    final SwapLeg payLeg = security.getPayLeg();
    final SwapLeg receiveLeg = security.getReceiveLeg();
    if (payLeg instanceof FixedInterestRateLeg && receiveLeg instanceof FloatingInterestRateLeg) {
      return true;
    }
    if (payLeg instanceof FloatingInterestRateLeg && receiveLeg instanceof FixedInterestRateLeg) {
      return false;
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.