Package com.opengamma.financial.currency

Examples of com.opengamma.financial.currency.CurrencyPairs


      throw new OpenGammaRuntimeException("PDE grid was null");
    }
    final PDEFullResults1D pdeGrid = (PDEFullResults1D) pdeGridObject;
    final double[] gridTimes = pdeGrid.getGrid().getTimeNodes();
    final double[] gridMoneyness = pdeGrid.getGrid().getSpaceNodes();
    final CurrencyPairs currencyPairs = OpenGammaExecutionContext.getCurrencyPairsSource(executionContext).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
    final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(fxOption.getPutCurrency(), fxOption.getCallCurrency());
    //TODO interpolate
    ///////////////////////////////
    final double tau = getExpiry(fxOption, now);
    final UnorderedCurrencyPair currencies = UnorderedCurrencyPair.of(fxOption.getCallCurrency(), fxOption.getPutCurrency());
    final ValueRequirement forwardCurveRequirement = getForwardCurveRequirement(forwardCurveCalculationMethod, forwardCurveName, currencies);
View Full Code Here


    curveCurrency.put(fullReceiveCurveName, receiveCurrency);
    final Object baseQuotePairsObject = inputs.getValue(ValueRequirementNames.CURRENCY_PAIRS);
    if (baseQuotePairsObject == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote pair data");
    }
    final CurrencyPairs baseQuotePairs = (CurrencyPairs) baseQuotePairsObject;
    final YieldAndDiscountCurve[] curves;
    final String[] allCurveNames;
    curves = new YieldAndDiscountCurve[] {payCurve, receiveCurve };
    allCurveNames = new String[] {fullPayCurveName, fullReceiveCurveName };
    // Implementation note: The ForexSecurityConverter create the Forex with currency order pay/receive. The curve are passed in the same order.
    final ForexSecurityConverter converter = new ForexSecurityConverter(baseQuotePairs);
    final InstrumentDefinition<?> definition = security.accept(converter);
    final Forex forex = (Forex) definition.toDerivative(now, allCurveNames);
    final FXForwardCurveInstrumentProvider provider = forwardCurveSpecification.getCurveInstrumentProvider();
    final ValueRequirement spotRequirement = new ValueRequirement(provider.getDataFieldName(), ComputationTargetType.PRIMITIVE, provider.getSpotInstrument());
    final double spotFX;
    if (baseQuotePairs.getCurrencyPair(receiveCurrency, payCurrency).getBase().equals(receiveCurrency)) {
      spotFX = (Double) inputs.getValue(spotRequirement);
    } else {
      spotFX = 1. / (Double) inputs.getValue(spotRequirement);
    }
    final FXMatrix fxMatrix = new FXMatrix();
View Full Code Here

        return Collections.singleton(new ComputedValue(_spec, new FXMatrix()));
      }
      final FXMatrix matrix = new FXMatrix();
      final Iterator<Currency> iter = _currencies.iterator();
      final Currency initialCurrency = iter.next();
      final CurrencyPairs pairs = (CurrencyPairs) inputs.getValue(CURRENCY_PAIRS);
      while (iter.hasNext()) {
        final Currency otherCurrency = iter.next();
        if (pairs.getCurrencyPair(initialCurrency, otherCurrency).getBase().equals(initialCurrency)) {
          final double spotRate = (Double) inputs.getValue(new ValueRequirement(ValueRequirementNames.SPOT_RATE,
              CurrencyPair.TYPE.specification(CurrencyPair.of(otherCurrency, initialCurrency))));
          matrix.addCurrency(otherCurrency, initialCurrency, spotRate);
        } else {
          final double spotRate = (Double) inputs.getValue(new ValueRequirement(ValueRequirementNames.SPOT_RATE,
View Full Code Here

        forwardCurveCalculationMethod, h, forwardCurveName, theta, timeSteps, spaceSteps, timeGridBunching, spaceGridBunching, maxMoneyness, pdeDirection);
    final Object gridGreeksObject = inputs.getValue(gridGreekRequirement);
    if (gridGreeksObject == null) {
      throw new OpenGammaRuntimeException("Grid greeks were null");
    }
    final CurrencyPairs currencyPairs = OpenGammaExecutionContext.getCurrencyPairsSource(executionContext).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
    final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(fxOption.getPutCurrency(), fxOption.getCallCurrency());
    final double strike = getStrike(fxOption, currencyPair);
    final PDEResultCollection gridGreeks = (PDEResultCollection) gridGreeksObject;
    final ComputationTargetSpecification spec = target.toSpecification();
    final Set<ComputedValue> result = new HashSet<ComputedValue>();
    for (final ValueRequirement value : desiredValues) {
View Full Code Here

    final FinancialSecurity security = (FinancialSecurity) target.getSecurity();
    final Currency payCurrency = security.accept(ForexVisitors.getPayCurrencyVisitor());
    final Currency receiveCurrency = security.accept(ForexVisitors.getReceiveCurrencyVisitor());

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    final CurrencyPairs currencyPairs = (CurrencyPairs) inputs.getValue(CURRENCY_PAIRS);
    final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(payCurrency, receiveCurrency);
    final double scale;
    if (payCurrency.equals(currencyPair.getBase())) {
      scale = 1;
    } else {
      scale = -1;
View Full Code Here

        final MulticurveProviderInterface data = getMergedProviders(inputs, fxMatrix);
        final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
        final ValueProperties properties = desiredValue.getConstraints().copy().get();
        final String fxForwardCurveName = desiredValue.getConstraint(FORWARD_CURVE_NAME);
        final DoublesCurve forwardPoints = getForwardPoints(inputs, fxForwardCurveName, now);
        final CurrencyPairs pairs = (CurrencyPairs) inputs.getValue(CURRENCY_PAIRS);
        final Pair<Currency, Currency> ccyPair;
        final Currency currency1 = forex.getCurrency1();
        final Currency currency2 = forex.getCurrency2();
        if (currency1.equals(pairs.getCurrencyPair(currency1, currency2).getBase())) {
          ccyPair = Pair.of(currency1, currency2);
        } else {
          ccyPair = Pair.of(currency2, currency1);
        }
        final MultipleCurrencyAmount mca = CALCULATOR.currencyExposure(forex, data, forwardPoints, ccyPair);
View Full Code Here

      @Override
      protected Set<ComputedValue> getValues(final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues,
          final Forex forex, final FXMatrix fxMatrix, final ZonedDateTime now) {
        final String fxForwardCurveName = desiredValues.iterator().next().getConstraint(FORWARD_CURVE_NAME);
        final DoublesCurve forwardPoints = getForwardPoints(inputs, fxForwardCurveName, now);
        final CurrencyPairs pairs = (CurrencyPairs) inputs.getValue(CURRENCY_PAIRS);
        final Pair<Currency, Currency> ccyPair;
        final Currency currency1 = forex.getCurrency1();
        final Currency currency2 = forex.getCurrency2();
        if (currency1.equals(pairs.getCurrencyPair(currency1, currency2).getBase())) {
          ccyPair = Pair.of(currency1, currency2);
        } else {
          ccyPair = Pair.of(currency2, currency1);
        }
        final MulticurveForwardPointsProviderInterface curves = new MulticurveForwardPointsProvider(getMergedProviders(inputs, fxMatrix), forwardPoints, ccyPair);
View Full Code Here

    curveCurrency.put(fullCallCurveName, callCurrency);
    final Object baseQuotePairsObject = inputs.getValue(ValueRequirementNames.CURRENCY_PAIRS);
    if (baseQuotePairsObject == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote pair data");
    }
    final CurrencyPairs baseQuotePairs = (CurrencyPairs) baseQuotePairsObject;
    final CurrencyPair baseQuotePair = baseQuotePairs.getCurrencyPair(putCurrency, callCurrency);
    if (baseQuotePair == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote pair for currency pair (" + putCurrency + ", " + callCurrency + ")");
    }
    final String[] allCurveNames;
    final Currency ccy1;
View Full Code Here

*/
public class FXForwardCurveFromYieldCurvesFunction extends AbstractFunction {

  @Override
  public CompiledFunctionDefinition compile(final FunctionCompilationContext context, final Instant atInstant) {
    final CurrencyPairs baseQuotePairs = OpenGammaCompilationContext.getCurrencyPairsSource(context).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
    return new Compiled(baseQuotePairs);
  }
View Full Code Here

    final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
    final FXForwardSecurity security = (FXForwardSecurity) position.getSecurity();
    final MultipleCurrencyAmount mca = (MultipleCurrencyAmount) inputs.getValue(FX_CURRENCY_EXPOSURE);
    final Currency payCurrency = security.getPayCurrency();
    final Currency receiveCurrency = security.getReceiveCurrency();
    final CurrencyPairs currencyPairs = (CurrencyPairs) inputs.getValue(CURRENCY_PAIRS);
    final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(payCurrency, receiveCurrency);
    final Currency currencyNonBase = currencyPair.getCounter(); // The non-base currency
    final double exposure = mca.getAmount(currencyNonBase);
    final LocalDateDoubleTimeSeries fxSpotReturnSeries = (LocalDateDoubleTimeSeries) inputs.getValue(RETURN_SERIES);
    final LocalDateDoubleTimeSeries pnlSeries = fxSpotReturnSeries.multiply(position.getQuantity().doubleValue() * exposure); // The P/L time series is in the base currency
    final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.PNL_SERIES, target.toSpecification(), desiredValue.getConstraints());
View Full Code Here

TOP

Related Classes of com.opengamma.financial.currency.CurrencyPairs

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.