Examples of SwapSecurity


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

                                  true,
                                  ExternalId.of("Rate", "1234"),
                                  FloatingRateType.IBOR);

  private static SwapSecurity createSwap() {
    return new SwapSecurity(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), "cpty", PAY_LEG, RECEIVE_LEG);
  }
View Full Code Here

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

  @Test
  public void swapWithNoExternalId() {
    SecurityMaster securityMaster = mock(SecurityMaster.class);
    ExternalIdVisitor visitor = new ExternalIdVisitor(securityMaster);
    SwapSecurity swap = createSwap();
    UniqueId uid = UniqueId.of("test", "123");
    swap.setUniqueId(uid);
    assertTrue(swap.getExternalIdBundle().isEmpty());
    swap.accept(visitor);
    assertEquals(ExternalId.of(ObjectId.EXTERNAL_SCHEME, uid.getObjectId().toString()),
                 swap.getExternalIdBundle().getExternalId(ObjectId.EXTERNAL_SCHEME));
    verify(securityMaster).update(new SecurityDocument(swap));
  }
View Full Code Here

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

  @Test
  public void swapWithExternalId() {
    SecurityMaster securityMaster = mock(SecurityMaster.class);
    ExternalIdVisitor visitor = new ExternalIdVisitor(securityMaster);
    SwapSecurity swap = createSwap();
    UniqueId uid = UniqueId.of("test", "123");
    swap.setUniqueId(uid);
    ExternalId externalId = ExternalId.of(UniqueId.EXTERNAL_SCHEME, "345");
    swap.setExternalIdBundle(ExternalIdBundle.of(externalId));
    swap.accept(visitor);
    assertEquals(externalId, swap.getExternalIdBundle().getExternalId(UniqueId.EXTERNAL_SCHEME));
    verify(securityMaster, never()).update(any(SecurityDocument.class));
  }
View Full Code Here

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

  @Test(expectedExceptions = IllegalStateException.class)
  public void swapWithNoUniqueId() {
    SecurityMaster securityMaster = mock(SecurityMaster.class);
    ExternalIdVisitor visitor = new ExternalIdVisitor(securityMaster);
    SwapSecurity swap = createSwap();
    swap.accept(visitor);
  }
View Full Code Here

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

    return identifier != null ? identifier : NOT_APPLICABLE;
  }

  @Override
  public String visitSwaptionSecurity(SwaptionSecurity security) {
    SwapSecurity underlying = (SwapSecurity) _securitySource.getSingle(ExternalIdBundle.of(security.getUnderlyingId()));
    String name = underlying.getName();
    return (name != null && name.length() > 0) ? name : NOT_APPLICABLE;
  }
View Full Code Here

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

      receiveLeg = fixedLeg;
      swapName = swapString + " receive " + ccy + " " + notional.getAmount() + " @ " + STRIKE_FORMATTER.format(rate);
      swaptionName = (isLong ? "Long " : "Short ") + swaptionString + " x " + swapString + " receive " + ccy + " " + notional.getAmount() + " @ " + STRIKE_FORMATTER.format(rate);
      payer = false;
    }
    final SwapSecurity swap = new SwapSecurity(swaptionExpiry, swaptionExpiry.plusDays(2), swapMaturity, COUNTERPARTY, payLeg, receiveLeg);
    swap.setName(swapName);
    final ExternalId underlyingId = ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString());
    swap.addExternalId(underlyingId);
    final SwaptionSecurity swaption = new SwaptionSecurity(payer, underlyingId, isLong, new Expiry(swaptionExpiry), isCashSettled, ccy);
    swaption.setName(swaptionName);
    swaption.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    return Pair.of(swaption, swap);
  }
View Full Code Here

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

    final PortfolioDocument portfolioDoc = new PortfolioDocument();
    portfolioDoc.setPortfolio(portfolio);

    for (final Map.Entry<SwaptionSecurity, SwapSecurity> entry : securities.entrySet()) {
      final SecurityDocument swapToAddDoc = new SecurityDocument();
      final SwapSecurity swap = entry.getValue();
      swapToAddDoc.setSecurity(swap);
      final SecurityDocument swaptionToAddDoc = new SecurityDocument();
      final SwaptionSecurity swaption = entry.getKey();
      swaptionToAddDoc.setSecurity(swaption);
      securityMaster.add(swaptionToAddDoc);
View Full Code Here

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

  @Override
  protected void doRun() {
    final FloatingInterestRateLeg payLeg1 = new FloatingInterestRateLeg(ACT_365, QUARTERLY, REGION, FOLLOWING, NOTIONAL, true, AUD_LIBOR_3M, FloatingRateType.IBOR);
    final FixedInterestRateLeg receiveLeg1 = new FixedInterestRateLeg(ACT_365, QUARTERLY, REGION, FOLLOWING, NOTIONAL, true, 0.04);
    final SwapSecurity swap1 = new SwapSecurity(TRADE_DATE, TRADE_DATE, MATURITY, COUNTERPARTY, payLeg1, receiveLeg1);
    swap1.setName("Swap AUD Bank Bill 3m");
    swap1.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    final FloatingInterestRateLeg payLeg2 = new FloatingInterestRateLeg(ACT_365, SEMI_ANNUAL, REGION, FOLLOWING, NOTIONAL, true, AUD_LIBOR_6M, FloatingRateType.IBOR);
    final FixedInterestRateLeg receiveLeg2 = new FixedInterestRateLeg(ACT_365, SEMI_ANNUAL, REGION, FOLLOWING, NOTIONAL, true, 0.04);
    final SwapSecurity swap2 = new SwapSecurity(TRADE_DATE, TRADE_DATE, MATURITY, COUNTERPARTY, payLeg2, receiveLeg2);
    swap2.setName("Swap AUD Bank Bill 6m");
    swap2.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    final FloatingInterestRateLeg payLeg3 = new FloatingInterestRateLeg(ACT_365, QUARTERLY, REGION, FOLLOWING, NOTIONAL, true, AUD_LIBOR_3M, FloatingRateType.IBOR);
    final FixedInterestRateLeg receiveLeg3 = new FixedInterestRateLeg(ACT_365, QUARTERLY, REGION, FOLLOWING, NOTIONAL, true, 0.0365);
    final SwapSecurity swap3 = new SwapSecurity(TRADE_DATE, TRADE_DATE, MATURITY, COUNTERPARTY, payLeg3, receiveLeg3);
    swap3.setName("Swap: receive 3.65% fixed ACT/365 vs 3m Bank Bill");
    swap3.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    final FloatingInterestRateLeg receiveLeg4 = new FloatingInterestRateLeg(ACT_365, QUARTERLY, REGION, FOLLOWING, NOTIONAL, true, AUD_LIBOR_3M, FloatingRateType.IBOR);
    final FixedInterestRateLeg payLeg4 = new FixedInterestRateLeg(ACT_360, QUARTERLY, REGION, FOLLOWING, NOTIONAL, true, 0.036);
    final SwapSecurity swap4 = new SwapSecurity(TRADE_DATE, TRADE_DATE, MATURITY, COUNTERPARTY, payLeg4, receiveLeg4);
    swap4.setName("Swap: receive 3.60% fixed ACT/360 vs 3m Bank Bill");
    swap4.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    final Collection<SwapSecurity> swaps = new HashSet<>();
    swaps.add(swap1);
    swaps.add(swap2);
    swaps.add(swap3);
    swaps.add(swap4);
View Full Code Here

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

    assertEquals(ExternalId.of(SCHEME, "EQUITY VARIANCE SWAP"), ids.get(0));
  }

  @Test
  public void testFixedFloatSwapSecurity() {
    final SwapSecurity security = ExposureFunctionTestHelper.getPayFixedFloatSwapSecurity();
    final List<ExternalId> ids = security.accept(EXPOSURE_FUNCTION);
    assertEquals(1, ids.size());
    assertEquals(ExternalId.of(SCHEME, "SWAP"), ids.get(0));
  }
View Full Code Here

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

    assertEquals(ExternalId.of(SCHEME, "SWAP"), ids.get(0));
  }

  @Test
  public void testFloatFloatSwapSecurity() {
    final SwapSecurity security = ExposureFunctionTestHelper.getFloatFloatSwapSecurity();
    final List<ExternalId> ids = security.accept(EXPOSURE_FUNCTION);
    assertEquals(1, ids.size());
    assertEquals(ExternalId.of(SCHEME, "SWAP"), ids.get(0));
  }
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.