Package com.opengamma.financial.security.swap

Source Code of com.opengamma.financial.security.swap.SwapSecurityFudgeBuilderTest

/**
* Copyright (C) 2013 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.financial.security.swap;

import org.testng.annotations.Test;
import org.threeten.bp.ZonedDateTime;

import com.opengamma.financial.convention.businessday.BusinessDayConvention;
import com.opengamma.financial.convention.businessday.BusinessDayConventionFactory;
import com.opengamma.financial.convention.daycount.DayCount;
import com.opengamma.financial.convention.daycount.DayCountFactory;
import com.opengamma.financial.convention.frequency.Frequency;
import com.opengamma.financial.convention.frequency.SimpleFrequency;
import com.opengamma.id.ExternalId;
import com.opengamma.util.money.Currency;
import com.opengamma.util.test.AbstractFudgeBuilderTestCase;
import com.opengamma.util.test.TestGroup;
import com.opengamma.util.time.DateUtils;
import com.opengamma.util.time.Tenor;

/**
*
*/
@Test(groups = TestGroup.UNIT)
public class SwapSecurityFudgeBuilderTest extends AbstractFudgeBuilderTestCase {
  private static final ZonedDateTime TRADE_DATE = DateUtils.getUTCDate(2013, 7, 1);
  private static final ZonedDateTime EFFECTIVE_DATE = DateUtils.getUTCDate(2013, 7, 1);
  private static final ZonedDateTime MATURITY = DateUtils.getUTCDate(2023, 7, 1);
  private static final String COUNTERPARTY = "OG";
  private static final DayCount DC = DayCountFactory.INSTANCE.getDayCount("Act/360");
  private static final Frequency FREQUENCY = SimpleFrequency.SEMI_ANNUAL;
  private static final ExternalId REGION_ID = ExternalId.of("Test", "US");
  private static final BusinessDayConvention BDC = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following");
  private static final Notional NOTIONAL = new InterestRateNotional(Currency.USD, 10000);
  private static final boolean EOM = true;

  @Test
  public void testSwapSecurity() {
    final ExternalId referenceId = ExternalId.of("Test", "ASD");
    final SwapLeg payLeg = new FixedInterestRateLeg(DC, FREQUENCY, REGION_ID, BDC, NOTIONAL, EOM, 0.05);
    final SwapLeg receiveLeg = new FloatingInterestRateLeg(DC, FREQUENCY, REGION_ID, BDC, NOTIONAL, EOM, referenceId, FloatingRateType.OIS);
    final SwapSecurity security = new SwapSecurity(TRADE_DATE, EFFECTIVE_DATE, MATURITY, COUNTERPARTY, payLeg, receiveLeg);
    assertEncodeDecodeCycle(SwapSecurity.class, security);
  }

  @Test
  public void testZeroCouponInflationSwapSecurity() {
    final FixedInflationSwapLeg payLeg = new FixedInflationSwapLeg(DC, FREQUENCY, REGION_ID, BDC, NOTIONAL, EOM, 0.002);
    final InflationIndexSwapLeg receiveLeg = new InflationIndexSwapLeg(DC, FREQUENCY, REGION_ID, BDC, NOTIONAL, EOM, ExternalId.of("Test", "SDF"),
        2, 3, InterpolationMethod.MONTH_START_LINEAR);
    final ZeroCouponInflationSwapSecurity security = new ZeroCouponInflationSwapSecurity(TRADE_DATE, EFFECTIVE_DATE, MATURITY, COUNTERPARTY, payLeg, receiveLeg);
    assertEncodeDecodeCycle(ZeroCouponInflationSwapSecurity.class, security);
  }

  @Test
  public void testYearOnYearInflationSwapSecurity() {
    final FixedInflationSwapLeg payLeg = new FixedInflationSwapLeg(DC, FREQUENCY, REGION_ID, BDC, NOTIONAL, EOM, 0.002);
    final InflationIndexSwapLeg receiveLeg = new InflationIndexSwapLeg(DC, FREQUENCY, REGION_ID, BDC, NOTIONAL, EOM, ExternalId.of("Test", "SDF"),
        2, 3, InterpolationMethod.MONTH_START_LINEAR);
    final YearOnYearInflationSwapSecurity security = new YearOnYearInflationSwapSecurity(TRADE_DATE, EFFECTIVE_DATE, MATURITY, COUNTERPARTY, payLeg, receiveLeg,
        true, true, Tenor.TEN_YEARS);
    assertEncodeDecodeCycle(YearOnYearInflationSwapSecurity.class, security);
  }

}
TOP

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

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.