Package com.opengamma.financial.security.swap

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


  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


    _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

    if (!payLeg.getSecond().getThird().equals(receiveLeg.getSecond().getThird())) {
      throw new OpenGammaRuntimeException(
          "Both, pay and receive legs should resolve equal maturity dates, but instead there were: payleg(" + payLeg.getSecond().getThird() + "), " +
              "receiveLeg(" + receiveLeg.getSecond().getThird() + ")");
    }
    return new SwapSecurity(payLeg.getSecond().getFirst(),
                            payLeg.getSecond().getSecond(),
                            payLeg.getSecond().getThird(),
                            "counterparty",
                            payLeg.getFirst(),
                            receiveLeg.getFirst());
View Full Code Here

  @Test
  public void payFixed() {
    final Frequency annual = SimpleFrequency.ANNUAL;
    final Frequency quarterly = SimpleFrequency.QUARTERLY;
    final SwapSecurity swap = swap(fixedLeg(annual), floatingLeg(quarterly));
    final Pair<Frequency, Frequency> frequencies = new FrequencyVisitor().visit(swap);
    final Pair<Frequency, Frequency> expected = Pair.of(annual, quarterly);
    assertEquals(expected, frequencies);
  }
View Full Code Here

  @Test
  public void receiveFixed() {
    final Frequency annual = SimpleFrequency.ANNUAL;
    final Frequency quarterly = SimpleFrequency.QUARTERLY;
    final SwapSecurity swap = swap(floatingLeg(quarterly), fixedLeg(annual));
    final Pair<Frequency, Frequency> frequencies = new FrequencyVisitor().visit(swap);
    final Pair<Frequency, Frequency> expected = Pair.of(annual, quarterly);
    assertEquals(expected, frequencies);
  }
View Full Code Here

  @Test
  public void floatFloat() {
    final Frequency annual = SimpleFrequency.ANNUAL;
    final Frequency quarterly = SimpleFrequency.QUARTERLY;
    final SwapSecurity swap = swap(floatingLeg(annual), floatingLeg(quarterly));
    final Pair<Frequency, Frequency> frequencies = new FrequencyVisitor().visit(swap);
    final Pair<Frequency, Frequency> expected = Pair.of(annual, quarterly);
    assertEquals(expected, frequencies);
  }
View Full Code Here

    final Pair<Frequency, Frequency> expected = Pair.of(annual, quarterly);
    assertEquals(expected, frequencies);
  }

  private static SwapSecurity swap(final SwapLeg payLeg, final SwapLeg receiveLeg) {
    return new SwapSecurity(ZonedDateTime.now(), ZonedDateTime.now(), ZonedDateTime.now(), "cpty", payLeg, receiveLeg);
  }
View Full Code Here

  @SuppressWarnings("unused")
  public InstrumentDerivative convert(final SwaptionSecurity security, final InstrumentDefinition<?> definition, final ZonedDateTime now, final String[] curveNames,
      final HistoricalTimeSeriesSource dataSource) {
    if (definition instanceof SwaptionCashFixedIborDefinition) {
      final SwaptionCashFixedIborDefinition cashSettled = (SwaptionCashFixedIborDefinition) definition;
      final SwapSecurity swapSecurity = null; //TODO
      //final DoubleTimeSeries<ZonedDateTime> swapFixingSeries = _swapConverter.convert(swapSecurity, definition, now, curveNames, dataSource);
      //return cashSettled.toDerivative(now, new DoubleTimeSeries[] {swapFixingTS}, curveNames);
    }
    if (definition instanceof SwaptionPhysicalFixedIborDefinition) {
      final SwaptionPhysicalFixedIborDefinition physicallySettled = (SwaptionPhysicalFixedIborDefinition) definition;
      final SwapSecurity swapSecurity = null; //TODO
      //final DoubleTimeSeries<ZonedDateTime> swapFixingSeries = _swapConverter.convert(swapSecurity, definition, now, curveNames, dataSource);
      //return physicallySettled.toDerivative(now, new DoubleTimeSeries[] {swapFixingTS}, curveNames);
    }
    throw new OpenGammaRuntimeException("This converter can only handle SwaptionCashFixedIborDefinition and SwaptionPhysicalFixedIborDefinition");
  }
View Full Code Here

      if (_withCurrency) {
        final Security security = target.getTrade().getSecurity();
        if (security instanceof SwapSecurity
            && InterestRateInstrumentType.isFixedIncomeInstrumentType((SwapSecurity) security)
            && (InterestRateInstrumentType.getInstrumentTypeFromSecurity((SwapSecurity) security) == InterestRateInstrumentType.SWAP_CROSS_CURRENCY)) {
          final SwapSecurity swapSecurity = (SwapSecurity) security;
          if (swapSecurity.getPayLeg().getNotional() instanceof InterestRateNotional) {
            final String currency = ((InterestRateNotional) swapSecurity.getPayLeg().getNotional()).getCurrency().getCode();
            properties.with(CURRENCY, currency);
            return properties;
          }
        } else if (security instanceof FXForwardSecurity || security instanceof NonDeliverableFXForwardSecurity) {
          properties.with(CURRENCY, ((FinancialSecurity) security).accept(ForexVisitors.getPayCurrencyVisitor()).getCode());
View Full Code Here

      if (_withCurrency) {
        final Security security = target.getTrade().getSecurity();
        if (security instanceof SwapSecurity
            && InterestRateInstrumentType.isFixedIncomeInstrumentType((SwapSecurity) security)
            && (InterestRateInstrumentType.getInstrumentTypeFromSecurity((SwapSecurity) security) == InterestRateInstrumentType.SWAP_CROSS_CURRENCY)) {
          final SwapSecurity swapSecurity = (SwapSecurity) security;
          if (swapSecurity.getPayLeg().getNotional() instanceof InterestRateNotional) {
            final String currency = ((InterestRateNotional) swapSecurity.getPayLeg().getNotional()).getCurrency().getCode();
            properties.with(CURRENCY, currency);
            return properties;
          }
        } else if (security instanceof FXForwardSecurity || security instanceof NonDeliverableFXForwardSecurity) {
          properties.with(CURRENCY, ((FinancialSecurity) security).accept(ForexVisitors.getPayCurrencyVisitor()).getCode());
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.