Package com.opengamma.financial.analytics

Examples of com.opengamma.financial.analytics.CurrencyLabelledMatrix1D


      final Currency[] keysArray = new Currency[matrixSize];
      keys.toArray(keysArray);
      final Object[] labelsArray = new Object[matrixSize];
      labels.toArray(labelsArray);
      final double[] valuesArray = Doubles.toArray(values);
      return new CurrencyLabelledMatrix1D(keysArray, labelsArray, labelsTitle, valuesArray, valuesTitle);
    }
View Full Code Here


    final FinancialSecurity security = (FinancialSecurity) target.getSecurity();
    final Currency payCurrency = getPayCurrency(security);
    final Currency receiveCurrency = getReceiveCurrency(security);
    final ComputedValue input = inputs.getComputedValue(ValueRequirementNames.FX_PRESENT_VALUE);
    final ValueSpecification inputSpec = input.getSpecification();
    final CurrencyLabelledMatrix1D fxPresentValue = (CurrencyLabelledMatrix1D) input.getValue();
    if (fxPresentValue.size() != 2) {
      throw new OpenGammaRuntimeException("Expected " + ValueRequirementNames.FX_PRESENT_VALUE + " input to contain 2 currency values, but found " + fxPresentValue.size());
    }
    int payIndex = -1;
    int receiveIndex = -1;
    for (int i = 0; i < 2; i++) {
      final Currency currency = fxPresentValue.getKeys()[i];
      if (payCurrency.equals(currency)) {
        payIndex = i;
      } else if (receiveCurrency.equals(currency)) {
        receiveIndex = i;
      } else {
        throw new OpenGammaRuntimeException(ValueRequirementNames.FX_PRESENT_VALUE + " contains unexpected currency " + currency + ". Expected " + payCurrency + " or " + receiveCurrency + ".");
      }
    }

    final double payValue = fxPresentValue.getValues()[payIndex];
    final double receiveValue = fxPresentValue.getValues()[receiveIndex];

    final double spot = (Double) inputs.getValue(ValueRequirementNames.SPOT_RATE);
    final double pv = payValue + spot * receiveValue;
    return ImmutableSet.of(new ComputedValue(getResultSpec(target, inputSpec.getProperties().copy()), pv));
  }
View Full Code Here

    int i = 0;
    for (final CurrencyAmount ca : mca) {
      keys[i] = ca.getCurrency();
      values[i++] = ca.getAmount();
    }
    return new CurrencyLabelledMatrix1D(keys, values);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.CurrencyLabelledMatrix1D

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.