Package com.opengamma.util.time

Examples of com.opengamma.util.time.Tenor


    final double[] deltas = new double[nDeltas];
    final double[] atms = new double[nExpiries];
    final double[][] riskReversals = new double[nDeltas][nExpiries];
    final double[][] strangle = new double[nDeltas][nExpiries];
    for (int i = 0; i < nExpiries; i++) {
      final Tenor tenor = (Tenor) tenors[i];
      final double t = getTime(tenor);
      final Double atm = fxVolatilitySurface.getVolatility(tenor, ObjectsPair.of(deltaValues[0], FXVolQuoteType.ATM));
      if (atm == null) {
        throw new OpenGammaRuntimeException("Could not get ATM volatility data for surface");
      }
View Full Code Here


      shiftMultiplier = 1 + Double.parseDouble(shift);
    } else {
      shiftMultiplier = 1;
    }
    for (int i = 0; i < tenors.length; i++) {
      final Tenor tenor = tenors[i];
      final double t = getTime(tenor);
      final DoubleArrayList deltas = new DoubleArrayList();
      final DoubleArrayList volatilities = new DoubleArrayList();
      for (int j = 0; j < nSmileValues; j++) {
        final Double delta = deltaValues[j];
View Full Code Here

        if (specification == null) {
          throw new OpenGammaRuntimeException("Couldn't find a forward swap curve specification called " + curveName + " with target " + target);
        }
        final Set<ValueRequirement> requirements = new HashSet<ValueRequirement>();
        final ForwardSwapCurveInstrumentProvider provider = (ForwardSwapCurveInstrumentProvider) specification.getCurveInstrumentProvider();
        final Tenor forwardTenor = Tenor.of(Period.parse(forwardTenorName));
        for (final Tenor tenor : definition.getTenors()) {
          final ExternalId identifier = provider.getInstrument(atZDT.toLocalDate(), tenor, forwardTenor);
          requirements.add(new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, identifier));
        }
        requirements.add(new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, provider.getSpotInstrument(forwardTenor)));
        return requirements;
      }

      @Override
      public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
        final Clock snapshotClock = executionContext.getValuationClock();
        final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
        final ValueRequirement desiredValue = desiredValues.iterator().next();
        final String curveName = desiredValue.getConstraint(ValuePropertyNames.CURVE);
        final String forwardTenorName = desiredValue.getConstraint(PROPERTY_FORWARD_TENOR);
        final Currency currencyPair = target.getValue(PrimitiveComputationTargetType.CURRENCY);
        final ForwardSwapCurveDefinition definition = curveDefinitionSource.getDefinition(curveName, currencyPair.toString());
        if (definition == null) {
          throw new OpenGammaRuntimeException("Couldn't find a forward swap curve definition called " + curveName + " for target " + target);
        }
        final ForwardSwapCurveSpecification specification = curveSpecificationSource.getSpecification(curveName, currencyPair.toString());
        if (specification == null) {
          throw new OpenGammaRuntimeException("Couldn't find FX forward curve specification called " + curveName + " for target " + target);
        }
        final ForwardSwapCurveInstrumentProvider provider = (ForwardSwapCurveInstrumentProvider) specification.getCurveInstrumentProvider();
        final Tenor forwardTenor = Tenor.of(Period.parse(forwardTenorName));
        final ValueRequirement spotRequirement = new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, provider.getSpotInstrument(forwardTenor));
        if (inputs.getValue(spotRequirement) == null) {
          throw new OpenGammaRuntimeException("Could not get value for spot; requirement was " + spotRequirement);
        }
        final Double spot = (Double) inputs.getValue(spotRequirement);
View Full Code Here

          } else {
            throw new OpenGammaRuntimeException("Can only handle discount factor or continuously-compounded rate nodes; have " + node.getCurveNode());
          }
          //TODO add check to make sure it's only discounting or rate curve nodes
          final Double marketValue = marketData.getDataPoint(node.getIdentifier());
          final Tenor maturity = node.getCurveNode().getResolvedMaturity();
          if (marketValue == null) {
            throw new OpenGammaRuntimeException("Could not get market data for " + node);
          }
          times[i] = DateUtils.estimatedDuration(maturity.getPeriod()).toDays() / 365.0; //TODO check if this is correct
          yields[i] = marketValue;
          jacobian[i][i] = 1;
          i++;
        }
        final String interpolatorName = specification.getInterpolatorName();
View Full Code Here

    }

    @Override
    public IborCurveTypeConfiguration buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final ExternalId convention = deserializer.fieldValueToObject(ExternalId.class, message.getByName(CONVENTION_FIELD));
      final Tenor tenor = Tenor.of(Period.parse(message.getString(TENOR_FIELD)));
      return new IborCurveTypeConfiguration(convention, tenor);
    }
View Full Code Here

    for (int i = 0; i < SIZE; i++) {
      FXOptionSecurity fxOption = null;
      try {
        final UnorderedCurrencyPair ccys = CCYS[random.nextInt(CCYS.length)];
        final LocalDate tradeDate = getTradeDate(random, ccys.getFirstCurrency());
        final Tenor tenor = TENORS[random.nextInt(TENORS.length)];
        fxOption = makeFXOption(random, ccys, tradeDate, tenor);
      } catch (final Exception e) {
        e.printStackTrace();
      }
      if (fxOption != null) {
View Full Code Here

    final ZonedDateTime startDate = previousWorkingDay(ZonedDateTime.now().minusDays(getRandom(365) + 7), currency);
    final int length = getRandom(22) + 3;
    final ZonedDateTime maturityDate = nextWorkingDay(startDate.plusYears(length), currency);
    final double notional = (double) getRandom(100000) * 1000;
    ExternalId underlyingIdentifier = null;
    Tenor tenor = ibor ? getRandom(IBOR_TENORS) : getRandom(TENORS);
    try {
      underlyingIdentifier = getUnderlying(currency, startDate.toLocalDate(), tenor, ibor);
      if (underlyingIdentifier == null) {
        return null;
      }
View Full Code Here

    @Override
    public CMSLegConvention buildObject(final FudgeDeserializer deserializer, final FudgeMsg message) {
      final String name = message.getString(NAME_FIELD);
      final ExternalIdBundle externalIdBundle = deserializer.fieldValueToObject(ExternalIdBundle.class, message.getByName(EXTERNAL_ID_BUNDLE_FIELD));
      final ExternalId swapIndexConvention = deserializer.fieldValueToObject(ExternalId.class, message.getByName(SWAP_INDEX_ID_FIELD));
      final Tenor paymentTenor = Tenor.of(Period.parse(message.getString(PAYMENT_TENOR_FIELD)));
      final boolean isAdvanceFixing = message.getBoolean(ADVANCE_FIXING_FIELD);
      final UniqueId uniqueId = deserializer.fieldValueToObject(UniqueId.class, message.getByName(UNIQUE_ID_FIELD));
      final CMSLegConvention convention = new CMSLegConvention(name, externalIdBundle, swapIndexConvention, paymentTenor, isAdvanceFixing);
      convention.setUniqueId(uniqueId);
      return convention;
View Full Code Here

    return _nodeIdMapper;
  }

  @Override
  public CurveNodeWithIdentifier visitCashNode(final CashNode node) {
    final Tenor tenor = node.getMaturityTenor();
    final ExternalId identifier = _nodeIdMapper.getCashNodeId(_curveDate, tenor);
    final String dataField = _nodeIdMapper.getCashNodeDataField(tenor);
    final DataFieldType fieldType = _nodeIdMapper.getCashNodeDataFieldType(tenor);
    return new CurveNodeWithIdentifier(node, identifier, dataField, fieldType);
  }
View Full Code Here

    return new CurveNodeWithIdentifier(node, identifier, dataField, fieldType);
  }

  @Override
  public CurveNodeWithIdentifier visitContinuouslyCompoundedRateNode(final ContinuouslyCompoundedRateNode node) {
    final Tenor tenor = node.getTenor();
    final ExternalId identifier = _nodeIdMapper.getContinuouslyCompoundedRateNodeId(_curveDate, tenor);
    final String dataField = _nodeIdMapper.getContinuouslyCompoundedRateNodeDataField(tenor);
    final DataFieldType fieldType = _nodeIdMapper.getContinuouslyCompoundedRateDataFieldType(tenor);
    return new CurveNodeWithIdentifier(node, identifier, dataField, fieldType);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.util.time.Tenor

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.