Examples of FXMatrix


Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

    new MultipleCurrencyParameterSensitivity().converted(null, EUR);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void testConvertNullCurrency() {
    new MultipleCurrencyParameterSensitivity().converted(new FXMatrix(), null);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

    assertEquals("Test multiplyBy, second name / currency pair: ", MATRIX.scale(SENSITIVITY_2_1, factor), sensi2.getSensitivity(NAME_2_EUR));
  }

  @Test
  public void converted() {
    final FXMatrix fxMatrix = new FXMatrix(EUR, USD, 1.25);
    MultipleCurrencyParameterSensitivity sensitivity = new MultipleCurrencyParameterSensitivity();
    sensitivity = sensitivity.plus(NAME_1_USD, SENSITIVITY_1_1);
    sensitivity = sensitivity.plus(NAME_1_EUR, SENSITIVITY_1_2);
    sensitivity = sensitivity.plus(NAME_2_EUR, SENSITIVITY_2_1);
    final MultipleCurrencyParameterSensitivity sensitivityUSDConverted = sensitivity.converted(fxMatrix, USD);
    MultipleCurrencyParameterSensitivity sensitivityUSDExpected = new MultipleCurrencyParameterSensitivity();
    sensitivityUSDExpected = sensitivityUSDExpected.plus(NAME_1_USD, SENSITIVITY_1_1);
    sensitivityUSDExpected = sensitivityUSDExpected.plus(NAME_1_USD, (DoubleMatrix1D) MATRIX.scale(SENSITIVITY_1_2, fxMatrix.getFxRate(EUR, USD)));
    sensitivityUSDExpected = sensitivityUSDExpected.plus(NAME_2_USD, (DoubleMatrix1D) MATRIX.scale(SENSITIVITY_2_1, fxMatrix.getFxRate(EUR, USD)));
    assertTrue("Test convert: ", AssertSensivityObjects.assertEquals("ParameterSensitivity: convert", sensitivityUSDExpected, sensitivityUSDConverted, TOLERANCE));
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

    final String forward6MCurveName = "Forward 6M";
    final HashMap<String, Currency> ccyMap = new HashMap<>();
    ccyMap.put(discountingCurvename, ccy);
    ccyMap.put(forward3MCurveName, ccy);
    ccyMap.put(forward6MCurveName, ccy);
    final FXMatrix fx = new FXMatrix(ccy);
    final InterpolatedDoublesCurve dscC = new InterpolatedDoublesCurve(new double[] {0.05, 1.0, 2.0, 5.0, 10.0, 20.0}, new double[] {0.0050, 0.0100, 0.0150, 0.0200, 0.0200, 0.0300},
        CombinedInterpolatorExtrapolatorFactory.getInterpolator(Interpolator1DFactory.DOUBLE_QUADRATIC, Interpolator1DFactory.LINEAR_EXTRAPOLATOR), true, "Curve dsc");
    final InterpolatedDoublesCurve fwd3C = new InterpolatedDoublesCurve(new double[] {0.05, 1.0, 2.0, 5.0, 10.0, 25.0}, new double[] {0.0070, 0.0120, 0.0165, 0.0215, 0.0210, 0.0310},
        CombinedInterpolatorExtrapolatorFactory.getInterpolator(Interpolator1DFactory.DOUBLE_QUADRATIC, Interpolator1DFactory.LINEAR_EXTRAPOLATOR), true, "Curve fwd3");
    final InterpolatedDoublesCurve fwd6C = new InterpolatedDoublesCurve(new double[] {0.05, 1.0, 2.0, 5.0, 10.0, 30.0}, new double[] {0.0075, 0.0125, 0.0170, 0.0220, 0.0212, 0.0312},
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

        valuationDate = valuationDate.plusDays(1);
        continue;
      }
      try {
        final MultipleYieldCurveFinderDataBundle data = new MultipleYieldCurveFinderDataBundle(derivatives, marketValues.toDoubleArray(), knownCurves, curveNodes, interpolators, useFiniteDifference,
            new FXMatrix(currency));
        final NewtonVectorRootFinder rootFinder = new BroydenVectorRootFinder(absoluteTolerance, relativeTolerance, iterations, decomposition);
        final Function1D<DoubleMatrix1D, DoubleMatrix1D> curveCalculator = new MultipleYieldCurveFinderFunction(data, PAR_SPREAD_RATE_CALCULATOR);
        final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianCalculator = new MultipleYieldCurveFinderIRSJacobian(data, PAR_SPREAD_RATE_SENSITIVITY_CALCULATOR);
        final double[] fittedYields = rootFinder.getRoot(curveCalculator, jacobianCalculator, new DoubleMatrix1D(initialRatesGuess.toDoubleArray())).getData();
        final DoubleMatrix2D jacobianMatrix = jacobianCalculator.evaluate(new DoubleMatrix1D(fittedYields));
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

      final boolean useFiniteDifference = Boolean.parseBoolean(useFiniteDifferenceName);
      final LinkedHashMap<String, double[]> curveNodes = new LinkedHashMap<>();
      final LinkedHashMap<String, Interpolator1D> interpolators = new LinkedHashMap<>();
      curveNodes.put(impliedDepositCurveName, t);
      interpolators.put(impliedDepositCurveName, interpolator);
      final FXMatrix fxMatrix = new FXMatrix();
      final YieldCurveBundle knownCurve = new YieldCurveBundle();
      final MultipleYieldCurveFinderDataBundle data = new MultipleYieldCurveFinderDataBundle(derivatives, r, knownCurve, curveNodes, interpolators, useFiniteDifference, fxMatrix);
      final NewtonVectorRootFinder rootFinder = new BroydenVectorRootFinder(absoluteTolerance, relativeTolerance, iterations, decomposition);
      final Function1D<DoubleMatrix1D, DoubleMatrix1D> curveCalculator = new MultipleYieldCurveFinderFunction(data, PAR_RATE_CALCULATOR);
      final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianCalculator = new MultipleYieldCurveFinderJacobian(data, PAR_RATE_SENSITIVITY_CALCULATOR);
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

      ccy2 = putCurrency;
      curveCurrency.put(allCurveNames[1], putCurrency);
      curveCurrency.put(allCurveNames[0], callCurrency);
    }
    final YieldCurveBundle yieldCurves = new YieldCurveBundle(allCurveNames, curves);
    final FXMatrix fxMatrix = new FXMatrix(ccy1, ccy2, spot);
    final YieldCurveBundle curvesWithFX = new YieldCurveBundle(fxMatrix, curveCurrency, yieldCurves.getCurvesMap());
    final Pair<Currency, Currency> ccyPair = Pair.of(ccy1, ccy2);
    return new SmileDeltaTermStructureVannaVolgaDataBundle(curvesWithFX, resultSmiles, ccyPair);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

      final LinkedHashMap<String, Interpolator1D> interpolators = new LinkedHashMap<>();
      final CombinedInterpolatorExtrapolator interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName, leftExtrapolatorName,
          rightExtrapolatorName);
      curveNodes.put(fullDomesticCurveName, nodeTimes.toDoubleArray());
      interpolators.put(fullDomesticCurveName, interpolator);
      final FXMatrix fxMatrix = new FXMatrix();
      fxMatrix.addCurrency(foreignCurrency, domesticCurrency, invertFXQuotes ? spotFX : 1 / spotFX);
      final MultipleYieldCurveFinderDataBundle data = new MultipleYieldCurveFinderDataBundle(derivatives, marketValues.toDoubleArray(), knownCurve, curveNodes,
          interpolators, useFiniteDifference, fxMatrix);
      final NewtonVectorRootFinder rootFinder = new BroydenVectorRootFinder(absoluteTolerance, relativeTolerance, iterations, decomposition);
      final Function1D<DoubleMatrix1D, DoubleMatrix1D> curveCalculator = new MultipleYieldCurveFinderFunction(data, PAR_RATE_CALCULATOR);
      final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianCalculator = new MultipleYieldCurveFinderJacobian(data, PAR_RATE_SENSITIVITY_CALCULATOR);
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

      final Clock snapshotClock = executionContext.getValuationClock();
      final ZonedDateTime now = ZonedDateTime.now(snapshotClock);
      final HistoricalTimeSeriesBundle timeSeries = HistoricalTimeSeriesFunctionUtils.getHistoricalTimeSeriesInputs(executionContext, inputs);
      final InstrumentDefinition<?> definition = getDefinitionFromTarget(target);
      final InstrumentDerivative derivative = getDerivative(target, now, timeSeries, definition);
      final FXMatrix fxMatrix = new FXMatrix();
      final SecuritySource securitySource = OpenGammaExecutionContext.getSecuritySource(executionContext);
      final Collection<Currency> currencies = FinancialSecurityUtils.getCurrencies(target.getTrade().getSecurity(), securitySource);
      final Iterator<Currency> iter = currencies.iterator();
      final Currency initialCurrency = iter.next();
      while (iter.hasNext()) {
        final Currency otherCurrency = iter.next();
        final double spotRate = (Double) inputs.getValue(new ValueRequirement(ValueRequirementNames.SPOT_RATE,
            CurrencyPair.TYPE.specification(CurrencyPair.of(otherCurrency, initialCurrency))));
        fxMatrix.addCurrency(otherCurrency, initialCurrency, spotRate);
      }
      return getValues(executionContext, inputs, target, desiredValues, derivative, fxMatrix);
    }
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

    final ZonedDateTime referenceDate = DateUtils.getUTCDate(2012, 7, 17);
    final Period tenor = Period.ofMonths(6);
    final double spread = -0.0050;
    final double notional = 12345;
    final double fxRateEURUSD = 1.25;
    final FXMatrix fxMatrix = new FXMatrix(EURIBOR3M.getCurrency(), USDLIBOR3M.getCurrency(), fxRateEURUSD);
    final GeneratorAttributeFX attribute = new GeneratorAttributeFX(tenor, fxMatrix);
    final SwapXCcyIborIborDefinition insGenerated = EURIBOR3MUSDLIBOR3M.generateInstrument(referenceDate, spread, notional, attribute);
    final ZonedDateTime settleDate = ScheduleCalculator.getAdjustedDate(referenceDate, EURIBOR3MUSDLIBOR3M.getSpotLag(), NYC);
    final SwapXCcyIborIborDefinition insExpected = SwapXCcyIborIborDefinition.from(settleDate, tenor, EURIBOR3MUSDLIBOR3M, notional, notional * fxRateEURUSD, spread, true, NYC, NYC);
    assertEquals("Generator Deposit: generate instrument", insExpected, insGenerated);
View Full Code Here

Examples of com.opengamma.analytics.financial.forex.method.FXMatrix

  /**
   * Tests the currency exposure with a FD rate shift.
   */
  public void currencyExposureForeign2() {
    final double shift = 0.000005;
    final FXMatrix fxMatrixP = new FXMatrix(EUR, USD, SPOT + shift);
    final MulticurveProviderDiscount multicurvesP = MULTICURVES.copy();
    multicurvesP.setForexMatrix(fxMatrixP);
    final BlackForexSmileProviderDiscount smileP = new BlackForexSmileProviderDiscount(multicurvesP, SMILE_TERM_FLAT, Pair.of(EUR, USD));
    final MultipleCurrencyAmount ce = METHOD_DIGITAL_SPREAD.currencyExposure(FOREX_DIGITAL_CALL_FOR, SMILE_FLAT_MULTICURVES);
    final MultipleCurrencyAmount pv = METHOD_DIGITAL_SPREAD.presentValue(FOREX_DIGITAL_CALL_FOR, SMILE_FLAT_MULTICURVES);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.