Package com.opengamma.financial.convention

Examples of com.opengamma.financial.convention.Convention


        }
      }
      if (node.getCurveNode() instanceof ZeroCouponInflationNode) {
        final ZeroCouponInflationNode inflationNode = (ZeroCouponInflationNode) node.getCurveNode();
        final ConventionSource conventionSource = OpenGammaExecutionContext.getConventionSource(executionContext);
        Convention convention = conventionSource.getConvention(inflationNode.getInflationLegConvention());
        if (convention == null) {
          throw new OpenGammaRuntimeException("Convention with id " + inflationNode.getInflationLegConvention() + " was null");
        }
        if (!(convention instanceof InflationLegConvention)) {
          throw new OpenGammaRuntimeException("Cannot handle convention type " + convention.getClass());
        }
        final InflationLegConvention inflationLegConvention = (InflationLegConvention) convention;
        convention = conventionSource.getConvention(inflationLegConvention.getPriceIndexConvention());
        if (convention == null) {
          throw new OpenGammaRuntimeException("Convention with id " + inflationLegConvention.getPriceIndexConvention() + " was null");
        }
        if (!(convention instanceof PriceIndexConvention)) {
          throw new OpenGammaRuntimeException("Cannot handle convention type " + convention.getClass());
        }
        final String priceIndexField = MarketDataRequirementNames.MARKET_VALUE; //TODO
        final ExternalIdBundle priceIndexId = ExternalIdBundle.of(((PriceIndexConvention) convention).getPriceIndexId());
        final HistoricalTimeSeries priceIndexSeries = timeSeriesSource.getHistoricalTimeSeries(priceIndexField, priceIndexId, resolutionKey, startDate, includeStart, endDate, true);
        if (priceIndexSeries != null) {
View Full Code Here


            }
          }
          if (node.getCurveNode() instanceof ZeroCouponInflationNode) {
            final ZeroCouponInflationNode inflationNode = (ZeroCouponInflationNode) node.getCurveNode();
            final ConventionSource conventionSource = OpenGammaExecutionContext.getConventionSource(executionContext);
            Convention convention = conventionSource.getConvention(inflationNode.getInflationLegConvention());
            if (convention == null) {
              throw new OpenGammaRuntimeException("Convention with id " + inflationNode.getInflationLegConvention() + " was null");
            }
            if (!(convention instanceof InflationLegConvention)) {
              throw new OpenGammaRuntimeException("Cannot handle convention type " + convention.getClass());
            }
            final InflationLegConvention inflationLegConvention = (InflationLegConvention) convention;
            convention = conventionSource.getConvention(inflationLegConvention.getPriceIndexConvention());
            if (convention == null) {
              throw new OpenGammaRuntimeException("Convention with id " + inflationLegConvention.getPriceIndexConvention() + " was null");
            }
            if (!(convention instanceof PriceIndexConvention)) {
              throw new OpenGammaRuntimeException("Cannot handle convention type " + convention.getClass());
            }
            ids = ExternalIdBundle.of(((PriceIndexConvention) convention).getPriceIndexId());
            final HistoricalTimeSeries priceIndexSeries = bundleForCurve.get(dataField, ids);
            if (priceIndexSeries != null) {
              if (priceIndexSeries.getTimeSeries().isEmpty()) {
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Override
  public <T extends Convention> T getConvention(final Class<T> clazz, final ExternalId identifier) {
    final Convention convention = _conventions.get(identifier);
    if (convention == null) {
      return null;
    }
    if (clazz.isAssignableFrom(convention.getClass())) {
      return (T) convention;
    }
    throw new OpenGammaRuntimeException("Convention for " + identifier + " was not of expected type " + clazz);
  }
View Full Code Here

          throw new OpenGammaRuntimeException("Got 2 types of cash convention: " + cashConvention.getExternalIdBundle() + " " + cashConventionId);
        }
      } else if (node.getCurveNode() instanceof SwapNode) {
        instruments[k] = ISDAInstrumentTypes.Swap;
        final ExternalId payConventionId = ((SwapNode) node.getCurveNode()).getPayLegConvention();
        final Convention payConvention = conventionSource.getConvention(payConventionId);
        if (payConvention == null) {
          throw new OpenGammaRuntimeException("Convention '" + payConventionId + "' not found");
        }
        final ExternalId receiveConventionId = ((SwapNode) node.getCurveNode()).getReceiveLegConvention();
        final Convention receiveConvention = conventionSource.getConvention(receiveConventionId);
        if (receiveConvention == null) {
          throw new OpenGammaRuntimeException("Convention '" + receiveConventionId + "' not found");
        }
        if (payConvention instanceof VanillaIborLegConvention) {  // float leg
          if (floatLegConvention == null) {
            floatLegConvention = (VanillaIborLegConvention) payConvention;
          } else if (!floatLegConvention.getExternalIdBundle().contains(payConventionId)) {
            throw new OpenGammaRuntimeException("Got 2 types of float leg convention: " + payConvention.getExternalIdBundle() + " " + payConventionId);
          }
        } else if (payConvention instanceof SwapFixedLegConvention) {
          if (fixLegConvention == null) {
            fixLegConvention = (SwapFixedLegConvention) payConvention;
          } else if (!fixLegConvention.getExternalIdBundle().contains(payConventionId)) {
            throw new OpenGammaRuntimeException("Got 2 types of fixed leg convention: " + payConvention.getExternalIdBundle() + " " + payConventionId);
          }
        } else {
          throw new OpenGammaRuntimeException("Unexpected swap convention type: " + payConvention);
        }
        if (receiveConvention instanceof VanillaIborLegConvention) {  // float leg
          if (floatLegConvention == null) {
            floatLegConvention = (VanillaIborLegConvention) receiveConvention;
          } else if (!floatLegConvention.getExternalIdBundle().contains(receiveConventionId)) {
            throw new OpenGammaRuntimeException("Got 2 types of float leg convention: " + receiveConvention.getExternalIdBundle() + " " + receiveConventionId);
          }
        } else if (receiveConvention instanceof SwapFixedLegConvention) {
          if (fixLegConvention == null) {
            fixLegConvention = (SwapFixedLegConvention) receiveConvention;
          } else if (!fixLegConvention.getExternalIdBundle().contains(receiveConventionId)) {
            throw new OpenGammaRuntimeException("Got 2 types of fixed leg convention: " + receiveConvention.getExternalIdBundle() + " " + receiveConventionId);
          }
        } else {
          throw new OpenGammaRuntimeException("Unexpected swap convention type: " + receiveConvention);
        }
      } else {
View Full Code Here

              } catch (final IllegalArgumentException e) {
                throw new OpenGammaRuntimeException("Cannot handle reference type " + reference + " for discounting curves");
              }
            } else if (type instanceof IborCurveTypeConfiguration) {
              final IborCurveTypeConfiguration ibor = (IborCurveTypeConfiguration) type;
              final Convention convention = conventionSource.getConvention(ibor.getConvention());
              if (convention == null) {
                throw new OpenGammaRuntimeException("Convention " + ibor.getConvention() + " was null");
              }
              if (!(convention instanceof IborIndexConvention)) {
                throw new OpenGammaRuntimeException("Expecting convention of type IborIndexConvention; have " + convention.getClass());
              }
              final IborIndexConvention iborIndexConvention = (IborIndexConvention) convention;
              final int spotLag = iborIndexConvention.getSettlementDays();
              iborIndex.add(new IborIndex(iborIndexConvention.getCurrency(), ibor.getTenor().getPeriod(), spotLag, iborIndexConvention.getDayCount(),
                  iborIndexConvention.getBusinessDayConvention(), iborIndexConvention.isIsEOM(), iborIndexConvention.getName()));
            } else if (type instanceof OvernightCurveTypeConfiguration) {
              final OvernightCurveTypeConfiguration overnight = (OvernightCurveTypeConfiguration) type;
              final Convention convention = conventionSource.getConvention(overnight.getConvention());
              if (convention == null) {
                throw new OpenGammaRuntimeException("Convention " + overnight.getConvention() + " was null");
              }
              if (!(convention instanceof OvernightIndexConvention)) {
                throw new OpenGammaRuntimeException("Expecting convention of type OvernightIndexConvention; have " + convention.getClass());
              }
              final OvernightIndexConvention overnightConvention = (OvernightIndexConvention) convention;
              overnightIndex.add(new IndexON(overnightConvention.getName(), overnightConvention.getCurrency(), overnightConvention.getDayCount(), overnightConvention.getPublicationLag()));
            } else {
              throw new OpenGammaRuntimeException("Cannot handle " + type.getClass());
View Full Code Here

  private static final DayCount ACT_365 = DayCountFactory.INSTANCE.getDayCount("Actual/365");
  private static final ExternalId GB = ExternalSchemes.financialRegionId("GB");

  public static synchronized void addFixedIncomeInstrumentConventions(final InMemoryConventionMaster conventionMaster) {
    final String liborConventionName = getConventionName(Currency.GBP, LIBOR);
    final Convention liborIndex = new IborIndexConvention(liborConventionName, getIds(Currency.GBP, LIBOR), ACT_365, MODIFIED_FOLLOWING, 0, true, Currency.GBP,
        LocalTime.of(11, 00), "GB", GB, GB, "");
   
    // Convention add
    conventionMaster.add(liborIndex);
  }
View Full Code Here

    final String priceIndexName = getConventionName(Currency.USD, PRICE_INDEX);
    final String swapIndexConventionName = getConventionName(Currency.USD, SWAP_INDEX);
    final ExternalId liborConventionId = ExternalId.of(SCHEME_NAME, liborConventionName);
    final ExternalId overnightConventionId = ExternalId.of(SCHEME_NAME, overnightConventionName);
    final ExternalId priceIndexId = ExternalId.of(SCHEME_NAME, priceIndexName);
    final Convention liborConvention = new IborIndexConvention(liborConventionName, getIds(Currency.USD, LIBOR), ACT_360, MODIFIED_FOLLOWING, 2, true, Currency.USD,
        LocalTime.of(11, 00), "US", NYLON, US, "");
    final Convention overnightConvention = new OvernightIndexConvention(overnightConventionName, getIds(Currency.USD, OVERNIGHT), ACT_360, 1, Currency.USD, US);
   
    // Deposit
    final DepositConvention depositConvention = new DepositConvention(depositConventionName, getIds(Currency.USD, DEPOSIT), ACT_360, MODIFIED_FOLLOWING, 2, true, Currency.USD, US);
    final DepositConvention depositONConvention = new DepositConvention(depositONConventionName, getIds(Currency.USD, DEPOSIT_ON), ACT_360, FOLLOWING, 0, false, Currency.USD, US);
   
    // Fixed Leg
    final String fixedLeg1YPayLagConventionName = getConventionName(Currency.USD, TENOR_STR_1Y, PAY_LAG + FIXED_LEG);
    final Convention fixedLeg1YPayLagConvention = new SwapFixedLegConvention(fixedLeg1YPayLagConventionName, getIds(Currency.USD, TENOR_STR_1Y, PAY_LAG + FIXED_LEG),
        Tenor.ONE_YEAR, ACT_360, MODIFIED_FOLLOWING, Currency.USD, US, 2, true, StubType.SHORT_START, false, 2);
    final String fixedLegShortPayLagConventionName = getConventionName(Currency.USD, TENOR_STR_SHORT, PAY_LAG + FIXED_LEG);
    final Convention fixedLegShortPayLagConvention = new SwapFixedLegConvention(fixedLegShortPayLagConventionName, getIds(Currency.USD, TENOR_STR_SHORT, PAY_LAG + FIXED_LEG),
        Tenor.ONE_YEAR, ACT_360, FOLLOWING, Currency.USD, US, 2, false, StubType.SHORT_START, false, 2);
    // Fixed 1Y- ON compounded 1Y
    final String oisFixedLegConventionName = getConventionName(Currency.USD, OIS_FIXED_LEG);
    final String oisONLegConventionName = getConventionName(Currency.USD, OIS_ON_LEG);
    final Convention oisFixedLegConvention = new SwapFixedLegConvention(oisFixedLegConventionName, getIds(Currency.USD, OIS_FIXED_LEG),
        Tenor.ONE_YEAR, ACT_360, MODIFIED_FOLLOWING, Currency.USD, US, 2, true, StubType.SHORT_START, false, 2);
    final Convention oisONLegConvention = new OISLegConvention(oisONLegConventionName, getIds(Currency.USD, OIS_ON_LEG), overnightConventionId,
        Tenor.ONE_YEAR, MODIFIED_FOLLOWING, 2, false, StubType.NONE, false, 2);
   
    // ON Compounded 3M
    final String onCmp3MLegConventionName = getConventionName(Currency.USD, TENOR_STR_3M, ON_CMP_LEG);
    final Convention onCmp3MLegConvention = new OISLegConvention(onCmp3MLegConventionName, getIds(Currency.USD, TENOR_STR_3M, ON_CMP_LEG), overnightConventionId,
        Tenor.THREE_MONTHS, MODIFIED_FOLLOWING, 2, false, StubType.SHORT_START, false, 2);
   
    // Ibor legs - no payment delay
    final String irsFixedLegConventionName = getConventionName(Currency.USD, IRS_FIXED_LEG);
    final Convention irsFixedLegConvention = new SwapFixedLegConvention(irsFixedLegConventionName, getIds(Currency.USD, IRS_FIXED_LEG),
        Tenor.SIX_MONTHS, THIRTY_360, MODIFIED_FOLLOWING, Currency.USD, NYLON, 2, true, StubType.SHORT_START, false, 0);
   
    final String liborLeg1MConventionName = getConventionName(Currency.USD, TENOR_STR_1M, IRS_IBOR_LEG);
    final Convention liborLeg1MConvention = new VanillaIborLegConvention(liborLeg1MConventionName, getIds(Currency.USD, TENOR_STR_1M, IRS_IBOR_LEG),
        liborConventionId, true, Interpolator1DFactory.LINEAR, Tenor.ONE_MONTH, 2, true, StubType.SHORT_START, false, 0);
    final String liborLeg3MConventionName = getConventionName(Currency.USD, TENOR_STR_3M, IRS_IBOR_LEG);
    final Convention liborLeg3MConvention = new VanillaIborLegConvention(liborLeg3MConventionName, getIds(Currency.USD, TENOR_STR_3M, IRS_IBOR_LEG),
        liborConventionId, true, Interpolator1DFactory.LINEAR, Tenor.THREE_MONTHS, 2, true, StubType.SHORT_START, false, 0);
    final String liborLeg6MConventionName = getConventionName(Currency.USD, TENOR_STR_6M, IRS_IBOR_LEG);
    final Convention liborLeg6MConvention = new VanillaIborLegConvention(liborLeg6MConventionName, getIds(Currency.USD, TENOR_STR_6M, IRS_IBOR_LEG),
        liborConventionId, true, Interpolator1DFactory.LINEAR, Tenor.SIX_MONTHS, 2, true, StubType.SHORT_START, false, 0);
    final String liborLeg12MConventionName = getConventionName(Currency.USD, TENOR_STR_12M, IRS_IBOR_LEG);
    final Convention liborLeg12MConvention = new VanillaIborLegConvention(liborLeg12MConventionName, getIds(Currency.USD, TENOR_STR_12M, IRS_IBOR_LEG),
        liborConventionId, true, Interpolator1DFactory.LINEAR, Tenor.TWELVE_MONTHS, 2, true, StubType.SHORT_START, false, 0);

    // Ibor legs - with payment delay
    final String liborLeg3MPayLagConventionName = getConventionName(Currency.USD, TENOR_STR_3M, PAY_LAG + IBOR_LEG);
    final Convention liborLeg3MPayLagConvention = new VanillaIborLegConvention(liborLeg3MPayLagConventionName, getIds(Currency.USD, TENOR_STR_3M, PAY_LAG + IBOR_LEG),
        liborConventionId, true, Interpolator1DFactory.LINEAR, Tenor.THREE_MONTHS, 2, true, StubType.NONE, false, 2);

    // Ibor legs - compounded
    final String liborLeg1MComp3MConventionName = getConventionName(Currency.USD, TENOR_STR_1M + " x " + TENOR_STR_3M, IBOR_CMP_LEG); // "USD 1M x 3M Comp Ibor Leg" 
    final Convention liborLeg1MComp3MConvention = new CompoundingIborLegConvention(liborLeg1MComp3MConventionName, getIds(Currency.USD, TENOR_STR_1M + " x " + TENOR_STR_3M, IBOR_CMP_LEG),
        liborConventionId, Tenor.THREE_MONTHS, CompoundingType.FLAT_COMPOUNDING, Tenor.ONE_MONTH, StubType.SHORT_START, 2, false, StubType.LONG_START, false, 0);
   
    // Swaps
    final Convention swapConvention = new SwapConvention("USD Swap", ExternalIdBundle.of(ExternalId.of(SCHEME_NAME, "USD Swap")),
        ExternalId.of(SCHEME_NAME, getConventionName(Currency.USD, IRS_FIXED_LEG)),
        ExternalId.of(SCHEME_NAME, getConventionName(Currency.USD, TENOR_STR_3M, IRS_IBOR_LEG)));
    final Convention swapIndexConvention = new SwapIndexConvention(swapIndexConventionName, getIds(Currency.USD, SWAP_INDEX), LocalTime.of(11, 0), ExternalId.of(SCHEME_NAME, "USD Swap"));
   
    // Futures (for ED-LIBOR3M and EM-LIBOR1M)
    final String quartFutureConventionName = getConventionName(Currency.USD, STIR_FUTURES + QUARTERLY);
    final Convention quartSTIRFutureConvention = new InterestRateFutureConvention(quartFutureConventionName, ExternalIdBundle.of(ExternalId.of(SCHEME_NAME, quartFutureConventionName)),
        ExternalId.of(ExchangeTradedInstrumentExpiryCalculator.SCHEME, IMMFutureAndFutureOptionQuarterlyExpiryCalculator.NAME), US, liborConventionId);
    final String serialFutureConventionName = getConventionName(Currency.USD, STIR_FUTURES + SERIAL);
    final Convention serialSTIRFutureConvention = new InterestRateFutureConvention(serialFutureConventionName, ExternalIdBundle.of(ExternalId.of(SCHEME_NAME, serialFutureConventionName)),
        ExternalId.of(ExchangeTradedInstrumentExpiryCalculator.SCHEME, IMMFutureAndFutureOptionMonthlyExpiryCalculator.NAME), US, liborConventionId);
   
    final Convention fedFundsConvention = new FederalFundsFutureConvention(fedFundFutureConventionName, ExternalIdBundle.of(ExternalId.of(SCHEME_NAME, FED_FUNDS_FUTURE)),
        ExternalId.of(ExchangeTradedInstrumentExpiryCalculator.SCHEME, FedFundFutureAndFutureOptionMonthlyExpiryCalculator.NAME), US, overnightConventionId, 5000000);
    final Convention cmsDeliverableSwapFutureConvention = new DeliverablePriceQuotedSwapFutureConvention(cmeDeliverableSwapFutureConventionName,
        ExternalIdBundle.of(SCHEME_NAME, CME_DELIVERABLE_SWAP_FUTURE), ExternalId.of(ExchangeTradedInstrumentExpiryCalculator.SCHEME,
            IMMFutureAndFutureOptionQuarterlyExpiryCalculator.NAME), US, liborConventionId, 100000);
    // Inflation
    final PriceIndexConvention priceIndexConvention = new PriceIndexConvention(priceIndexName, getIds(Currency.USD, PRICE_INDEX), Currency.USD, US,
        ExternalSchemes.bloombergTickerSecurityId("CPURNSA Index"));
    final Convention inflationConvention = new InflationLegConvention(inflationConventionName, getIds(Currency.USD, INFLATION_LEG), MODIFIED_FOLLOWING, ACT_360, false, 3, 2,
        priceIndexId);
    // US Treasury: Synthetic swaps to represent bonds, using yield
    final String fixedLegGovtConventionName = getConventionName(Currency.USD, TENOR_STR_6M, GOVT + FIXED_LEG);
    final Convention fixedLegGovtConvention = new SwapFixedLegConvention(fixedLegGovtConventionName, getIds(Currency.USD, TENOR_STR_6M, GOVT + FIXED_LEG),
        Tenor.SIX_MONTHS, ACT_ACT, FOLLOWING, Currency.USD, US, 2, false, StubType.SHORT_START, false, 0);
    final String liborLegGovtConventionName = getConventionName(Currency.USD, TENOR_STR_3M, GOVT + IBOR_LEG);
    final Convention liborLegGovtConvention = new VanillaIborLegConvention(liborLegGovtConventionName, getIds(Currency.USD, TENOR_STR_3M, GOVT + IBOR_LEG),
        liborConventionId, true, Interpolator1DFactory.LINEAR, Tenor.THREE_MONTHS, 2, false, StubType.NONE, false, 0);

    // X-Ccy OIS
    final Convention oisXCcyJPYLegConvention = new OISLegConvention(OIS_USD_JPY_ON_LEG, getIds(OIS_USD_JPY_ON_LEG), overnightConventionId,
        Tenor.THREE_MONTHS, MODIFIED_FOLLOWING, 2, true, StubType.NONE, false, 2);
   
    // Convention add
    conventionMaster.add(depositConvention);
    conventionMaster.add(depositONConvention);
View Full Code Here

  public static synchronized void addFixedIncomeInstrumentConventions(final InMemoryConventionMaster conventionMaster) {
    // Index Overnight
    final String onIndexName = getConventionName(Currency.AUD, OVERNIGHT);
    final ExternalId onIndexId = ExternalId.of(SCHEME_NAME, onIndexName);
    final Convention onIndex = new OvernightIndexConvention(onIndexName, getIds(Currency.AUD, OVERNIGHT), ACT_365, 0, Currency.AUD, AU);
    // Index BBSW
    final String bbswConventionName = getConventionName(Currency.AUD, BBSW);
    final Convention bbswIndex = new IborIndexConvention(bbswConventionName, getIds(Currency.AUD, BBSW), ACT_365, MODIFIED_FOLLOWING, 2, true, Currency.AUD,
        LocalTime.of(11, 00), "AU", AU, AU, "");
    final ExternalId bbswConventionId = ExternalId.of(SCHEME_NAME, bbswConventionName);
    // Deposit
    final String depositONConventionName = getConventionName(Currency.AUD, DEPOSIT_ON);
    final DepositConvention depositONConvention = new DepositConvention(depositONConventionName, getIds(Currency.AUD, DEPOSIT_ON), ACT_365, FOLLOWING, 0, false, Currency.AUD, AU);
    // Fixed Legs
    final String fixedLeg3MConventionName = getConventionName(Currency.AUD, TENOR_STR_3M, FIXED_LEG);
    final Convention fixedLeg3MConvention = new SwapFixedLegConvention(fixedLeg3MConventionName, getIds(Currency.AUD, TENOR_STR_3M, FIXED_LEG),
        Tenor.THREE_MONTHS, ACT_365, MODIFIED_FOLLOWING, Currency.AUD, AU, 2, true, StubType.SHORT_START, false, 0);
    final String fixedLeg6MConventionName = getConventionName(Currency.AUD, TENOR_STR_6M, FIXED_LEG);
    final Convention fixedLeg6MConvention = new SwapFixedLegConvention(fixedLeg6MConventionName, getIds(Currency.AUD, TENOR_STR_6M, FIXED_LEG),
        Tenor.SIX_MONTHS, ACT_365, MODIFIED_FOLLOWING, Currency.AUD, AU, 2, true, StubType.SHORT_START, false, 0);
    final String fixedLeg1YPayLagConventionName = getConventionName(Currency.AUD, TENOR_STR_1Y, PAY_LAG + FIXED_LEG);
    final Convention fixedLeg1YPayLagConvention = new SwapFixedLegConvention(fixedLeg1YPayLagConventionName, getIds(Currency.AUD, TENOR_STR_1Y, PAY_LAG + FIXED_LEG),
        Tenor.ONE_YEAR, ACT_365, MODIFIED_FOLLOWING, Currency.AUD, AU, 2, true, StubType.SHORT_START, false, 2);
    // BBSW Legs
    final String bbsw3MLegConventionName = getConventionName(Currency.AUD, TENOR_STR_3M, BBSW_LEG);
    final Convention bbsw3MLegConvention = new VanillaIborLegConvention(bbsw3MLegConventionName, getIds(Currency.AUD, TENOR_STR_3M, BBSW_LEG),
        bbswConventionId, true, Interpolator1DFactory.LINEAR, Tenor.THREE_MONTHS, 2, true, StubType.SHORT_START, false, 0);
    final String bbsw6MLegConventionName = getConventionName(Currency.AUD, TENOR_STR_6M, BBSW_LEG);
    final Convention bbsw6MLegConvention = new VanillaIborLegConvention(bbsw6MLegConventionName, getIds(Currency.AUD, TENOR_STR_6M, BBSW_LEG),
        bbswConventionId, true, Interpolator1DFactory.LINEAR, Tenor.SIX_MONTHS, 2, true, StubType.SHORT_START, false, 0);
    // Overnight Legs
    final String onLegConventionName = getConventionName(Currency.AUD, ON_CMP_LEG);
    final Convention onLegConvention = new OISLegConvention(onLegConventionName, getIds(Currency.AUD, ON_CMP_LEG), onIndexId,
        Tenor.ONE_YEAR, MODIFIED_FOLLOWING, 2, true, StubType.SHORT_START, false, 2);
   
    // Convention add
    conventionMaster.add(onIndex);
    conventionMaster.add(bbswIndex);
View Full Code Here

    _valuationTime = valuationTime;
  }

  @Override
  public InstrumentDefinition<?> visitRateFutureNode(final RateFutureNode rateFuture) {
    final Convention futureConvention = _conventionSource.getConvention(rateFuture.getFutureConvention());
    final Double price = _marketData.getDataPoint(_dataId);
    if (price == null) {
      throw new OpenGammaRuntimeException("Could not get market data for " + _dataId);
    }
    if (futureConvention == null) {
      throw new OpenGammaRuntimeException("Future convention was null");
    }
    if (futureConvention instanceof InterestRateFutureConvention) {
      return getInterestRateFuture(rateFuture, (InterestRateFutureConvention) futureConvention, price);
    } else if (futureConvention instanceof FederalFundsFutureConvention) {
      return getFederalFundsFuture(rateFuture, (FederalFundsFutureConvention) futureConvention, price);
    }
    throw new OpenGammaRuntimeException("Could not handle future convention of type " + futureConvention.getClass());
  }
View Full Code Here

  }

  //TODO check calendars
  @Override
  public InstrumentDefinition<?> visitFRANode(final FRANode fraNode) {
    final Convention convention = _conventionSource.getConvention(fraNode.getConvention());
    final Double rate = _marketData.getDataPoint(_dataId);
    if (rate == null) {
      throw new OpenGammaRuntimeException("Could not get market data for " + _dataId);
    }
    final Period startPeriod = fraNode.getFixingStart().getPeriod();
    final Period endPeriod = fraNode.getFixingEnd().getPeriod();
    //TODO probably need a specific FRA convention to hold the reset tenor
    final long months = endPeriod.toTotalMonths() - startPeriod.toTotalMonths();
    final Period indexTenor = Period.ofMonths((int) months);
    final IborIndexConvention indexConvention;
    if (convention instanceof IborIndexConvention) {
      indexConvention = (IborIndexConvention) convention;
    } else {
      if (convention == null) {
        throw new OpenGammaRuntimeException("Convention with id " + fraNode.getConvention() + " was null");
      }
      throw new OpenGammaRuntimeException("Could not handle underlying convention of type " + convention.getClass());
    }
    final Currency currency = indexConvention.getCurrency();
    final Calendar fixingCalendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getFixingCalendar());
    final Calendar regionCalendar = CalendarUtils.getCalendar(_regionSource, _holidaySource, indexConvention.getRegionCalendar());
    final int spotLag = indexConvention.getSettlementDays();
    final BusinessDayConvention businessDayConvention = indexConvention.getBusinessDayConvention();
    final DayCount dayCount = indexConvention.getDayCount();
    final boolean eom = indexConvention.isIsEOM();
    final IborIndex iborIndex = new IborIndex(currency, indexTenor, spotLag, dayCount, businessDayConvention, eom, convention.getName());
    final ZonedDateTime spotDate = ScheduleCalculator.getAdjustedDate(_valuationTime, spotLag, regionCalendar);
    final ZonedDateTime accrualStartDate = ScheduleCalculator.getAdjustedDate(spotDate, startPeriod, businessDayConvention, regionCalendar, eom);
    final ZonedDateTime accrualEndDate = ScheduleCalculator.getAdjustedDate(spotDate, endPeriod, businessDayConvention, regionCalendar, eom);
    return ForwardRateAgreementDefinition.from(accrualStartDate, accrualEndDate, 1, iborIndex, rate, fixingCalendar);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.convention.Convention

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.