Examples of SwapLeg


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

      final FinancialSecurity finSec = (FinancialSecurity) security;
      final CurrencyAmount notional = finSec.accept(new FinancialSecurityVisitorAdapter<CurrencyAmount>() {

        @Override
        public CurrencyAmount visitSwapSecurity(final SwapSecurity security) {
          final SwapLeg payNotional = security.getPayLeg();
          final SwapLeg receiveNotional = security.getReceiveLeg();
          if (payNotional.getNotional() instanceof InterestRateNotional && receiveNotional.getNotional() instanceof InterestRateNotional) {
            final InterestRateNotional pay = (InterestRateNotional) payNotional.getNotional();
            final InterestRateNotional receive = (InterestRateNotional) receiveNotional.getNotional();
            if (Double.compare(pay.getAmount(), receive.getAmount()) == 0) {
              return CurrencyAmount.of(pay.getCurrency(), pay.getAmount());
            }
          }
          throw new OpenGammaRuntimeException("Can only handle interest rate notionals with the same amounts");
View Full Code Here

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

    if (SwapSecurityUtils.isFloatFloat(security)) {
      return security.getPayLeg().getNotional().accept(s_notionalVisitor);
    }

    final boolean isPayFixed = isFixedLeg(security.getPayLeg());
    final SwapLeg fixedLeg = isPayFixed ? security.getPayLeg() : security.getReceiveLeg();
    Double notional = fixedLeg.getNotional().accept(s_notionalVisitor);
    if (notional != null && !isPayFixed) {
      notional *= -1;
    }
    return notional;
  }
View Full Code Here

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

    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

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

  @Test
  public void swap() throws JSONException {
    ZonedDateTime tradeDate = zdt(2012, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC);
    ZonedDateTime effectiveDate = zdt(2013, 1, 21, 11, 0, 0, 0, ZoneOffset.UTC);
    ZonedDateTime maturityDate = zdt(2013, 12, 21, 11, 0, 0, 0, ZoneOffset.UTC);
    SwapLeg payLeg = new FixedInterestRateLeg(
        DayCountFactory.INSTANCE.getDayCount("Act/360"),
        SimpleFrequency.MONTHLY,
        ExternalId.of(ExternalSchemes.FINANCIAL, "123"),
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following"),
        new InterestRateNotional(Currency.GBP, 123),
        false,
        0.01);
    SwapLeg receiveLeg = new FloatingInterestRateLeg(
        DayCountFactory.INSTANCE.getDayCount("Act/Act"),
        SimpleFrequency.QUARTERLY,
        ExternalId.of(ExternalSchemes.FINANCIAL, "123"),
        BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following"),
        new InterestRateNotional(Currency.GBP, 234),
View Full Code Here

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

    final ZonedDateTime swapMaturity = swaptionExpiry.plus(maturity.getPeriod());
    final double amount = 100000 * (1 + random.nextInt(30));
    final InterestRateNotional notional = new InterestRateNotional(ccy, amount);
    final double rate = getSwapRate(ccy, tradeDate, maturity) * (1 + ((random.nextDouble() - 0.5) / 30.));
    final Frequency frequency = ccy.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 = random.nextBoolean();
    final boolean isCashSettled = random.nextBoolean();
    final boolean payer;
    if (random.nextBoolean()) {
View Full Code Here

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

    }
    Double fixedRate = (fixedRateSeries.getTimeSeries().getEarliestValue() + getRandom().nextDouble()) / 100d;
    Double notional = (double) getRandom(100000) * 1000;
    ZonedDateTime maturityDate = forwardDate.plus(maturity.getPeriod());
    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

    return security;
  }

  public static SwapSecurity getPayFixedFloatSwapSecurity() {
    final InterestRateNotional notional = new InterestRateNotional(EUR, 1000000);
    final SwapLeg payLeg = new FixedInterestRateLeg(DC, PeriodFrequency.SEMI_ANNUAL, DE, BDC, notional, false, 0.04);
    final SwapLeg receiveLeg = new FloatingInterestRateLeg(DC, PeriodFrequency.QUARTERLY, DE, BDC, notional, false, ExternalSchemes.syntheticSecurityId("3m Euribor"), FloatingRateType.IBOR);
    final SwapSecurity security = new SwapSecurity(DateUtils.getUTCDate(2013, 1, 1), DateUtils.getUTCDate(2013, 1, 1), DateUtils.getUTCDate(2023, 1, 1), "OG",
        payLeg, receiveLeg);
    security.setUniqueId(UniqueId.of(UniqueId.EXTERNAL_SCHEME.getName(), "65456"));
    return security;
  }
View Full Code Here

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

    return security;
  }

  public static SwapSecurity getReceiveFixedFloatSwapSecurity() {
    final InterestRateNotional notional = new InterestRateNotional(EUR, 1000000);
    final SwapLeg receiveLeg = new FixedInterestRateLeg(DC, PeriodFrequency.SEMI_ANNUAL, DE, BDC, notional, false, 0.04);
    final SwapLeg payLeg = new FloatingInterestRateLeg(DC, PeriodFrequency.QUARTERLY, DE, BDC, notional, false, ExternalSchemes.syntheticSecurityId("3m Euribor"), FloatingRateType.IBOR);
    final SwapSecurity security = new SwapSecurity(DateUtils.getUTCDate(2013, 1, 1), DateUtils.getUTCDate(2013, 1, 1), DateUtils.getUTCDate(2023, 1, 1), "OG",
        payLeg, receiveLeg);
    security.setUniqueId(UniqueId.of(UniqueId.EXTERNAL_SCHEME.getName(), "65456"));
    return security;
  }
View Full Code Here

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

    return security;
  }

  public static SwapSecurity getFloatFloatSwapSecurity() {
    final InterestRateNotional notional = new InterestRateNotional(EUR, 1000000);
    final SwapLeg payLeg = new FloatingInterestRateLeg(DC, PeriodFrequency.QUARTERLY, DE, BDC, notional, false, ExternalSchemes.syntheticSecurityId("6m Euribor"), FloatingRateType.IBOR);
    final SwapLeg receiveLeg = new FloatingInterestRateLeg(DC, PeriodFrequency.QUARTERLY, DE, BDC, notional, false, ExternalSchemes.syntheticSecurityId("3m Euribor"), FloatingRateType.IBOR);
    final SwapSecurity security = new SwapSecurity(DateUtils.getUTCDate(2013, 1, 1), DateUtils.getUTCDate(2013, 1, 1), DateUtils.getUTCDate(2023, 1, 1), "OG",
        payLeg, receiveLeg);
    security.setUniqueId(UniqueId.of(UniqueId.EXTERNAL_SCHEME.getName(), "874"));
    return security;
  }
View Full Code Here

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

    return security;
  }

  public static ForwardSwapSecurity getPayForwardFixedFloatSwapSecurity() {
    final InterestRateNotional notional = new InterestRateNotional(EUR, 1000000);
    final SwapLeg payLeg = new FixedInterestRateLeg(DC, PeriodFrequency.SEMI_ANNUAL, DE, BDC, notional, false, 0.04);
    final SwapLeg receiveLeg = new FloatingInterestRateLeg(DC, PeriodFrequency.QUARTERLY, DE, BDC, notional, false, ExternalSchemes.syntheticSecurityId("3m Euribor"), FloatingRateType.IBOR);
    final ForwardSwapSecurity security = new ForwardSwapSecurity(DateUtils.getUTCDate(2013, 1, 1), DateUtils.getUTCDate(2013, 1, 1), DateUtils.getUTCDate(2023, 1, 1), "OG",
        payLeg, receiveLeg, DateUtils.getUTCDate(2014, 1, 1));
    security.setUniqueId(UniqueId.of(UniqueId.EXTERNAL_SCHEME.getName(), "23498"));
    return security;
  }
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.