当前位置: 首页>>代码示例>>Java>>正文


Java Clock类代码示例

本文整理汇总了Java中org.threeten.bp.Clock的典型用法代码示例。如果您正苦于以下问题:Java Clock类的具体用法?Java Clock怎么用?Java Clock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Clock类属于org.threeten.bp包,在下文中一共展示了Clock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDialog

import org.threeten.bp.Clock; //导入依赖的package包/类
/**
 * Creates a {@link TimePickerDialog} instance.
 *
 * @param context   to retrieve the time format (12 or 24 hour)
 * @param localTime the initial localTime
 * @param listener  to listen for a localTime selection
 * @param clock     to retrieve the calendar from
 * @return a new instance of {@link TimePickerDialog}
 */
@NonNull
public static TimePickerDialog createDialog(@NonNull Context context, @Nullable LocalTime localTime,
                                            @Nullable Consumer<LocalTime> listener, @NonNull Clock clock) {
  TimePickerDialog.OnTimeSetListener dialogCallBack = (view, hourOfDay, minute, second) -> {
    LocalTime time = LocalTime.of(hourOfDay, minute, second);
    Optional.ofNullable(listener)
        .ifPresent(theListener -> theListener.accept(time));
  };

  localTime = Optional.ofNullable(localTime)
      .orElse(LocalTime.now(clock));
  TimePickerDialog timePickerDialog = TimePickerDialog.newInstance(
      dialogCallBack,
      localTime.getHour(),
      localTime.getMinute(),
      localTime.getSecond(),
      DateFormat.is24HourFormat(context)
  );
  timePickerDialog.dismissOnPause(true);
  return timePickerDialog;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:31,代码来源:TimePickerDialogHelper.java

示例2: createDialog

import org.threeten.bp.Clock; //导入依赖的package包/类
/**
 * Creates a {@link DatePickerDialog} instance with the <code>localDate</code> selected.
 *
 * @param localDate the selected start localDate
 * @param listener to be triggered when the user selects a localDate
 * @param clock to get the current date
 * @return the {@link DatePickerDialog} created instance
 */
@NonNull
public static DatePickerDialog createDialog(@Nullable LocalDate localDate, @Nullable Consumer<LocalDate> listener,
                                            @NonNull Clock clock) {
  localDate = Optional.ofNullable(localDate)
      .orElse(LocalDate.now(clock));

  DatePickerDialog.OnDateSetListener dialogCallBack = (view, year, monthOfYear, dayOfMonth) -> {
    LocalDate date = LocalDate.of(year, monthOfYear + 1, dayOfMonth);
    Optional.ofNullable(listener)
        .ifPresent(theListener -> theListener.accept(date));
  };

  DatePickerDialog datePickerDialog = DatePickerDialog.newInstance(
      dialogCallBack,
      localDate.getYear(),
      localDate.getMonthValue() - 1,
      localDate.getDayOfMonth()
  );
  datePickerDialog.dismissOnPause(true);
  return datePickerDialog;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:30,代码来源:DatePickerDialogHelper.java

示例3: execute

import org.threeten.bp.Clock; //导入依赖的package包/类
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
  final ZonedDateTime now = ZonedDateTime.now(Clock.systemUTC());
  final EquityOptionSecurity option = (EquityOptionSecurity) target.getSecurity();
  final ValueRequirement underlyingPriceRequirement = getPriceRequirement(option.getUnderlyingId());
  final ValueRequirement discountCurveDataRequirement = getDiscountCurveMarketDataRequirement(option.getCurrency());
  final YieldAndDiscountCurve discountCurve = (YieldAndDiscountCurve) inputs.getValue(discountCurveDataRequirement);
  final double spotPrice = (Double) inputs.getValue(underlyingPriceRequirement);
  final Expiry expiry = option.getExpiry();
  final double t = DateUtils.getDifferenceInYears(now, expiry.getExpiry());
  final double b = discountCurve.getInterestRate(t); // TODO cost-of-carry model
  @SuppressWarnings("unused")
  final StandardOptionDataBundle data = new StandardOptionDataBundle(discountCurve, b, null, spotPrice, now);
  // TODO Map<OptionDefinition, Double> of options that will be used to form surface
  final VolatilitySurface surface = null; // TODO
  final ValueSpecification specification = createResultSpecification(target);
  final ComputedValue result = new ComputedValue(specification, surface);
  return Collections.singleton(result);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:20,代码来源:PractitionerBlackScholesVolatilitySurfaceFunction.java

示例4: execute

import org.threeten.bp.Clock; //导入依赖的package包/类
@Override
public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
  final ValueRequirement desiredValue = desiredValues.iterator().next();
  final Clock snapshotClock = executionContext.getValuationClock();
  final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
  final HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
  final InstrumentDefinition<InstrumentDerivative> irFutureOptionDefinition = (InstrumentDefinition<InstrumentDerivative>) getConverter(executionContext).convert(target.getTrade());
  final String surfaceName = desiredValue.getConstraint(ValuePropertyNames.SURFACE);
  final String curveCalculationConfigName = desiredValue.getConstraint(ValuePropertyNames.CURVE_CALCULATION_CONFIG);
  final MultiCurveCalculationConfig curveCalculationConfig = _curveCalculationConfigSource.getConfig(curveCalculationConfigName);
  if (curveCalculationConfig == null) {
    throw new OpenGammaRuntimeException("Could not find curve calculation configuration named " + curveCalculationConfigName);
  }
  final String[] curveNames = curveCalculationConfig.getYieldCurveNames();
  final YieldCurveBundle curves = YieldCurveFunctionUtils.getYieldCurves(inputs, curveCalculationConfig);
  final InstrumentDerivative irFutureOption = _dataConverter.convert(target.getTrade().getSecurity(), irFutureOptionDefinition, now, curveNames, timeSeries);
  final double price = irFutureOption.accept(new MyDerivativeVisitor(target, inputs, curves));
  final ValueSpecification valueSpecification = new ValueSpecification(ValueRequirementNames.PRESENT_VALUE, target.toSpecification(), createValueProperties()
      .with(ValuePropertyNames.CURRENCY, FinancialSecurityUtils.getCurrency(target.getTrade().getSecurity()).getCode())
      .with(ValuePropertyNames.CURVE_CALCULATION_CONFIG, curveCalculationConfigName).with(ValuePropertyNames.SURFACE, surfaceName).with(ValuePropertyNames.SMILE_FITTING_METHOD, "Heston")
      .with(ValuePropertyNames.CALCULATION_METHOD, "Fourier").get());
  return Sets.newHashSet(new ComputedValue(valueSpecification, price));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:InterestRateFutureOptionHestonPresentValueFunction.java

示例5: getDataBundle

import org.threeten.bp.Clock; //导入依赖的package包/类
@Override
protected SkewKurtosisOptionDataBundle getDataBundle(final Clock relevantTime, final EquityOptionSecurity option, final FunctionInputs inputs) {
  final StandardOptionDataBundle standardData = super.getDataBundle(relevantTime, option, inputs);
  final UniqueId uid = option.getUniqueId();
  final Object skewObject = inputs.getValue(ValueRequirementNames.SKEW);
  if (skewObject == null) {
    throw new NullPointerException("Could not get skew");
  }
  final Object kurtosisObject = inputs.getValue(ValueRequirementNames.PEARSON_KURTOSIS);
  if (kurtosisObject == null) {
    throw new NullPointerException("Could not get Pearson kurtosis");
  }
  final double skew = (Double) skewObject;
  final double kurtosis = (Double) kurtosisObject;
  return new SkewKurtosisOptionDataBundle(standardData, skew, kurtosis);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:SkewKurtosisDataOptionModelFunction.java

示例6: getDataBundle

import org.threeten.bp.Clock; //导入依赖的package包/类
@Override
protected StandardOptionDataBundle getDataBundle(final Clock relevantTime, final EquityOptionSecurity option, final FunctionInputs inputs) {
  //REVIEW yomi 03-06-2011 Elaine needs to confirm what needs to go here because we cannot deal with FXOptionSecurity here
  /*
  final ZonedDateTime now = relevantTime.zonedDateTime();
  final FXOptionSecurity fxOption = (FXOptionSecurity) option;
  final Security underlying = secMaster.getSecurity(ExternalIdBundle.of(option.getUnderlyingIdentifier())); //TODO make sure spot FX rate is right way up
  final Double spotAsObject = (Double) inputs.getValue(getUnderlyingMarketDataRequirement(underlying.getUniqueId()));
  if (spotAsObject == null) {
    throw new NullPointerException("No spot value for underlying instrument.");
  }
  final double spot = spotAsObject;
  final VolatilitySurface volatilitySurface = (VolatilitySurface) inputs.getValue(getVolatilitySurfaceMarketDataRequirement(option));
  //TODO check call / put are actually the right way around
  final YieldAndDiscountCurve domesticCurve = (YieldAndDiscountCurve) inputs.getValue(getYieldCurveMarketDataRequirement(fxOption.getCallCurrency().getUniqueId()));
  final YieldAndDiscountCurve foreignCurve = (YieldAndDiscountCurve) inputs.getValue(getYieldCurveMarketDataRequirement(fxOption.getPutCurrency().getUniqueId()));
  final Expiry expiry = option.getExpiry();
  final double t = DateUtil.getDifferenceInYears(now, expiry.getExpiry().toInstant());
  final double b = foreignCurve.getInterestRate(t); //TODO not great but needs an analytics refactor
  return new StandardOptionDataBundle(domesticCurve, b, volatilitySurface, spot, now);
   */
  throw new UnsupportedOperationException();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:GarmanKohlhagenFXOptionModelFunction.java

示例7: execute

import org.threeten.bp.Clock; //导入依赖的package包/类
@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 HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
  final Trade trade = target.getTrade();
  final ValueRequirement desiredValue = desiredValues.iterator().next();
  final String curveCalculationConfigName = desiredValue.getConstraint(ValuePropertyNames.CURVE_CALCULATION_CONFIG);
  final MultiCurveCalculationConfig curveCalculationConfig = _curveConfigSource.getConfig(curveCalculationConfigName);
  if (curveCalculationConfig == null) {
    throw new OpenGammaRuntimeException("Could not find curve calculation configuration named " + curveCalculationConfigName);
  }
  final String currency = FinancialSecurityUtils.getCurrency(trade.getSecurity()).getCode();
  final String[] curveNames = curveCalculationConfig.getYieldCurveNames();
  final String[] yieldCurveNames = curveNames.length == 1 ? new String[] {curveNames[0], curveNames[0] } : curveNames;
  final String[] fullYieldCurveNames = new String[yieldCurveNames.length];
  for (int i = 0; i < yieldCurveNames.length; i++) {
    fullYieldCurveNames[i] = yieldCurveNames[i] + "_" + currency;
  }
  final YieldCurveBundle data = YieldCurveFunctionUtils.getAllYieldCurves(inputs, curveCalculationConfig, _curveConfigSource);
  final InstrumentDefinition<InstrumentDerivative> irFutureDefinition = _converter.convert(trade);
  final InstrumentDerivative irFuture = _dataConverter.convert(trade.getSecurity(), irFutureDefinition, now, fullYieldCurveNames, timeSeries);
  final ValueSpecification spec = getSpecification(target, curveCalculationConfigName);
  return getResults(irFuture, data, spec);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:InterestRateFutureFunction.java

示例8: getValues

import org.threeten.bp.Clock; //导入依赖的package包/类
@Override
public void getValues(final Collection<PayoffStyle> values) {
  values.add(new AssetOrNothingPayoffStyle());
  values.add(new AsymmetricPoweredPayoffStyle(s_random.nextDouble()));
  values.add(new BarrierPayoffStyle());
  values.add(new CappedPoweredPayoffStyle(s_random.nextDouble(), s_random.nextDouble()));
  values.add(new CashOrNothingPayoffStyle(s_random.nextDouble()));
  values.add(new FadeInPayoffStyle(s_random.nextDouble(), s_random.nextDouble()));
  values.add(new FixedStrikeLookbackPayoffStyle());
  values.add(new FloatingStrikeLookbackPayoffStyle());
  values.add(new GapPayoffStyle(s_random.nextDouble()));
  values.add(new PoweredPayoffStyle(s_random.nextDouble()));
  values.add(new SupersharePayoffStyle(s_random.nextDouble(), s_random.nextDouble()));
  values.add(new VanillaPayoffStyle());
  values.add(new ExtremeSpreadPayoffStyle(ZonedDateTime.now().withNano(0), s_random.nextBoolean()));
  values.add(new SimpleChooserPayoffStyle(ZonedDateTime.now().withNano(0), s_random.nextDouble(),
      new Expiry(ZonedDateTime.now(Clock.systemDefaultZone()), ExpiryAccuracy.MONTH_YEAR)));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:19,代码来源:SecurityTestCase.java

示例9: runOneCycle

import org.threeten.bp.Clock; //导入依赖的package包/类
@Override
protected void runOneCycle() {
  s_logger.debug("queueSize {} ", _writerQueue.size());
  for (String security : _securities) {
    int msgSize = _messageSizeGenerator.nextInt(MAX_MESSAGE_SIZE);
    for (int i = 0; i < msgSize; i++) {
      try {
        MutableFudgeMsg msg = getRandomMessage();
        Instant instant = Clock.systemUTC().instant();
        long epochMillis = instant.toEpochMilli();
        msg.add(RECEIVED_TS_KEY, epochMillis);
        msg.add(SECURITY_KEY, security);
        s_logger.debug("generating {}", msg);
        _writerQueue.put(msg);
      } catch (InterruptedException e) {
        Thread.interrupted();
        s_logger.warn("interrupted exception while putting ticks message on queue");
      }
    }
  }
  
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:RandomTicksGeneratorJob.java

示例10: test_ReplaceVersion_noUid

import org.threeten.bp.Clock; //导入依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_ReplaceVersion_noUid() {
  Clock origClock = _cfgMaster.getClock();
  try {
    Instant now = Instant.now();

    ObjectId baseOid = setupTestData(now);
    _cfgMaster.setClock(Clock.fixed(now.plus(2, HOURS), ZoneOffset.UTC));


    List<ConfigDocument> replacement = newArrayList();
    for (int i = 0; i <= 2; i++) {
      String val = "replace_" + i;
      ConfigDocument doc = new ConfigDocument(ConfigItem.of(val));
      doc.setVersionFromInstant(now.plus(1, MINUTES).plus(i * 20, SECONDS));
      replacement.add(doc);
    }

    _cfgMaster.replaceVersion(baseOid.atVersion("no such uid"), replacement);
  } finally {
    _cfgMaster.setClock(origClock);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:ModifyConfigDbConfigMasterWorkerReplaceVersionTest.java

示例11: provideClock

import org.threeten.bp.Clock; //导入依赖的package包/类
@Provides
@Singleton
public Clock provideClock() {
  Instant instant = Instant.parse("2016-05-06T10:15:30.00Z");
  ZoneId zoneId = ZoneId.of(DEFAULT_TIME_ZONE_STRING);
  return Clock.fixed(instant, zoneId);
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:8,代码来源:MockClockModule.java

示例12: getCalendarFromClock

import org.threeten.bp.Clock; //导入依赖的package包/类
/**
 * Retrieves a {@link Calendar} instance from the {@code clock}.
 *
 * @param clock to be used to retrieve the {@link Calendar} instance.
 * @return a new {@link Calendar} instance representing the clock's time.
 */
@NonNull
public static Calendar getCalendarFromClock(Clock clock) {
  Calendar calendar = Calendar.getInstance();
  calendar.setTimeInMillis(clock.millis());
  return calendar;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:13,代码来源:DateHelper.java

示例13: execute

import org.threeten.bp.Clock; //导入依赖的package包/类
@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 Object volatilitySurfaceDataObject = inputs.getValue(_requirement);
  if (volatilitySurfaceDataObject == null) {
    throw new OpenGammaRuntimeException("Could not get " + _requirement);
  }
  @SuppressWarnings("unchecked")
  final VolatilitySurfaceData<LocalDate, Double> volatilitySurfaceData = (VolatilitySurfaceData<LocalDate, Double>) volatilitySurfaceDataObject;
  final int n = volatilitySurfaceData.getXs().length;
  final int m = volatilitySurfaceData.getYs().length;
  final DoubleArrayList t = new DoubleArrayList();
  final DoubleArrayList k = new DoubleArrayList();
  final DoubleArrayList sigma = new DoubleArrayList();
  final LocalDate[] xDates = volatilitySurfaceData.getXs();
  final Double[] y = volatilitySurfaceData.getYs();
  for (int i = 0; i < n; i++) {
    final Double time = DateUtils.getDifferenceInYears(now.toLocalDate(), xDates[i]);
    for (int j = 0; j < m; j++) {
      final Double strike = y[j];
      final Double vol = volatilitySurfaceData.getVolatility(xDates[i], y[j]);
      if (time != null && strike != null && vol != null) {
        t.add(time);
        k.add(strike);
        sigma.add(vol);
      }
    }
  }
  final Surface<Double, Double, Double> surface = InterpolatedDoublesSurface.from(t.toDoubleArray(), k.toDoubleArray(), sigma.toDoubleArray(), _interpolator);
  final VolatilitySurface volatilitySurface = new VolatilitySurface(surface);
  return Collections.singleton(new ComputedValue(_result, volatilitySurface));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:34,代码来源:Grid2DInterpolatedVolatilitySurfaceFunctionDeprecated.java

示例14: execute

import org.threeten.bp.Clock; //导入依赖的package包/类
@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 FinancialSecurity security = (FinancialSecurity) target.getSecurity();
  final ValueRequirement desiredValue = desiredValues.iterator().next();
  final double theta = Double.parseDouble(desiredValue.getConstraint(PROPERTY_THETA));
  final int nTimeSteps = Integer.parseInt(desiredValue.getConstraint(PROPERTY_NUMBER_TIME_STEPS));
  final int nSpaceSteps = Integer.parseInt(desiredValue.getConstraint(PROPERTY_NUMBER_SPACE_STEPS));
  final double timeStepBunching = Double.parseDouble(desiredValue.getConstraint(PROPERTY_TIME_STEP_BUNCHING));
  final double spaceStepBunching = Double.parseDouble(desiredValue.getConstraint(PROPERTY_SPACE_STEPS_BUNCHING));
  final double maxProxyDelta = Double.parseDouble(desiredValue.getConstraint(PROPERTY_MAX_PROXY_DELTA));
  final double centreMoneyness = Double.parseDouble(desiredValue.getConstraint(PROPERTY_CENTRE_MONEYNESS));
  final String interpolatorName = desiredValue.getConstraint(PROPERTY_SPACE_DIRECTION_INTERPOLATOR);
  final Interpolator1D interpolator = Interpolator1DFactory.getInterpolator(interpolatorName);
  final PDELocalVolatilityCalculator<?> pdeCalculator =
      getPDECalculator(new LocalVolatilityForwardPDECalculator(theta, nTimeSteps, nSpaceSteps, timeStepBunching, spaceStepBunching, maxProxyDelta, centreMoneyness), interpolator);
  final Object localVolatilityObject = inputs.getValue(ValueRequirementNames.LOCAL_VOLATILITY_SURFACE);
  if (localVolatilityObject == null) {
    throw new OpenGammaRuntimeException("Could not get local volatility surface");
  }
  final Object forwardCurveObject = inputs.getValue(ValueRequirementNames.FORWARD_CURVE);
  if (forwardCurveObject == null) {
    throw new OpenGammaRuntimeException("Could not get forward curve");
  }
  final Object discountingCurveObject = inputs.getValue(ValueRequirementNames.YIELD_CURVE);
  if (discountingCurveObject == null) {
    throw new OpenGammaRuntimeException("Could not get discounting curve");
  }
  final LocalVolatilitySurfaceMoneyness localVolatility = (LocalVolatilitySurfaceMoneyness) localVolatilityObject;
  final ForwardCurve forwardCurve = (ForwardCurve) forwardCurveObject;
  final EuropeanVanillaOption option = getOption(security, now);
  final YieldAndDiscountCurve discountingCurve = (YieldAndDiscountCurve) discountingCurveObject;
  final Object result = getResult(pdeCalculator, localVolatility, forwardCurve, option, discountingCurve);
  final ValueProperties properties = getResultProperties(desiredValue);
  final ValueSpecification spec = new ValueSpecification(getRequirementName(), target.toSpecification(), properties);
  return Collections.singleton(new ComputedValue(spec, result));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:39,代码来源:LocalVolatilityForwardPDEFunction.java

示例15: execute

import org.threeten.bp.Clock; //导入依赖的package包/类
@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 FinancialSecurity security = (FinancialSecurity) target.getSecurity();
  final ValueRequirement desiredValue = desiredValues.iterator().next();
  final double theta = Double.parseDouble(desiredValue.getConstraint(PROPERTY_THETA));
  final int nTimeSteps = Integer.parseInt(desiredValue.getConstraint(PROPERTY_NUMBER_TIME_STEPS));
  final int nSpaceSteps = Integer.parseInt(desiredValue.getConstraint(PROPERTY_NUMBER_SPACE_STEPS));
  final double timeStepBunching = Double.parseDouble(desiredValue.getConstraint(PROPERTY_TIME_STEP_BUNCHING));
  final double spaceStepBunching = Double.parseDouble(desiredValue.getConstraint(PROPERTY_SPACE_STEPS_BUNCHING));
  final double maxMoneyness = Double.parseDouble(desiredValue.getConstraint(PROPERTY_MAX_MONEYNESS));
  final String interpolatorName = desiredValue.getConstraint(PROPERTY_SPACE_DIRECTION_INTERPOLATOR);
  final Interpolator1D interpolator = Interpolator1DFactory.getInterpolator(interpolatorName);
  final PDELocalVolatilityCalculator<?> pdeCalculator =
      getPDECalculator(new LocalVolatilityBackwardPDECalculator(theta, nTimeSteps, nSpaceSteps, timeStepBunching, spaceStepBunching, maxMoneyness), interpolator);
  final Object localVolatilityObject = inputs.getValue(getVolatilitySurfaceRequirement(target, desiredValue));
  if (localVolatilityObject == null) {
    throw new OpenGammaRuntimeException("Could not get local volatility surface");
  }
  final Object forwardCurveObject = inputs.getValue(getForwardCurveRequirement(target, desiredValue));
  if (forwardCurveObject == null) {
    throw new OpenGammaRuntimeException("Could not get forward curve");
  }
  final Object discountingCurveObject = inputs.getValue(getDiscountingCurveRequirement(target, desiredValue));
  if (discountingCurveObject == null) {
    throw new OpenGammaRuntimeException("Could not get discounting curve");
  }
  final LocalVolatilitySurfaceMoneyness localVolatility = (LocalVolatilitySurfaceMoneyness) localVolatilityObject;
  final ForwardCurve forwardCurve = (ForwardCurve) forwardCurveObject;
  final EuropeanVanillaOption option = getOption(security, now);
  final YieldAndDiscountCurve discountingCurve = (YieldAndDiscountCurve) discountingCurveObject;
  final Object result = getResult(pdeCalculator, localVolatility, forwardCurve, option, discountingCurve);
  final ValueProperties properties = getResultProperties(desiredValue);
  final ValueSpecification spec = new ValueSpecification(getRequirementName(), target.toSpecification(), properties);
  return Collections.singleton(new ComputedValue(spec, result));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:38,代码来源:LocalVolatilityBackwardPDEFunction.java


注:本文中的org.threeten.bp.Clock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。