@Override
 protected Set<ComputedValue> getResult(
     final ForexDerivative fxOption,
     final SmileDeltaTermStructureDataBundle data,
     final FunctionInputs inputs,
     final ComputationTarget target) {
   final MultipleCurrencyAmount result = CALCULATOR.visit(fxOption, data);
   final int n = result.size();
   final Currency[] keys = new Currency[n];
   final double[] values = new double[n];
   int i = 0;
   for (final CurrencyAmount ca : result) {
     keys[i] = ca.getCurrency();
     values[i++] = ca.getAmount();
   }
   final ValueProperties properties =
       createValueProperties()
           .with(ValuePropertyNames.PAY_CURVE, getPutCurveName())
           .with(ValuePropertyNames.RECEIVE_CURVE, getCallCurveName())
           .with(ValuePropertyNames.SURFACE, getSurfaceName())
           .get();
   final ValueSpecification spec =
       new ValueSpecification(getValueRequirementName(), target.toSpecification(), properties);
   return Collections.singleton(
       new ComputedValue(spec, new CurrencyLabelledMatrix1D(keys, values)));
 }
示例#2
0
 public static CurrencyLabelledMatrix1D getMultipleCurrencyAmountAsMatrix(
     final MultipleCurrencyAmount mca) {
   ArgumentChecker.notNull(mca, "multiple currency amount");
   final int n = mca.size();
   final Currency[] keys = new Currency[n];
   final double[] values = new double[n];
   int i = 0;
   for (final CurrencyAmount ca : mca) {
     keys[i] = ca.getCurrency();
     values[i++] = ca.getAmount();
   }
   return new CurrencyLabelledMatrix1D(keys, values);
 }
 @Override
 protected Set<ComputedValue> getResult(
     final FunctionInputs inputs,
     final BondCapitalIndexedTransaction<?> bond,
     final InflationIssuerProviderInterface provider,
     final double cleanPrice,
     final ValueSpecification spec) {
   final String expectedCurrency = spec.getProperty(CURRENCY);
   final MultipleCurrencyAmount pvBond =
       CALCULATOR.presentValueFromCleanRealPrice(bond.getBondTransaction(), provider, cleanPrice);
   final MultipleCurrencyAmount pvSettlement =
       bond.getBondTransaction()
           .getSettlement()
           .accept(PVIC, provider.getInflationProvider())
           .multipliedBy(
               bond.getQuantity()
                   * bond.getBondTransaction().getCoupon().getNthPayment(0).getNotional());
   final MultipleCurrencyAmount pv = pvBond.plus(pvSettlement);
   if (pv.size() != 1
       || !(expectedCurrency.equals(pv.getCurrencyAmounts()[0].getCurrency().getCode()))) {
     throw new OpenGammaRuntimeException("Expecting a single result in " + expectedCurrency);
   }
   return Collections.singleton(new ComputedValue(spec, pv.getCurrencyAmounts()[0].getAmount()));
 }