Package com.opengamma.financial.currency

Examples of com.opengamma.financial.currency.CurrencyPair


    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 callCurrencyCurve = desiredValue.getConstraint(FXOptionBlackFunction.CALL_CURVE);
    final String resultCurrency = getResultCurrency(target, baseQuotePair);
View Full Code Here


    }
    final CurrencyPairs baseQuotePairs = OpenGammaCompilationContext.getCurrencyPairsSource(context).getCurrencyPairs(currencyPairConfigName);
    final FinancialSecurity security = (FinancialSecurity) target.getSecurity();
    final Currency putCurrency = security.accept(ForexVisitors.getPutCurrencyVisitor());
    final Currency callCurrency = security.accept(ForexVisitors.getCallCurrencyVisitor());
    final CurrencyPair baseQuotePair = baseQuotePairs.getCurrencyPair(putCurrency, callCurrency);
    if (baseQuotePair == null) {
      s_logger.error("Could not get base/quote pair for currency pair (" + putCurrency + ", " + callCurrency + ")");
      return null;
    }
    final String resultCurrency = getResultCurrency(target, baseQuotePair);
View Full Code Here

  private final ZonedDateTime _settlementDate;
  private final boolean _long;

  public FxOptionCalculator(AbstractFxOptionTrade trade, BigDecimal amount, Currency currency) {

    CurrencyPair cp = CurrencyPair.parse(trade.getCurrencyPair());

    Currency optionCurrency = trade.getOptionCurrency();
    Currency notionalCurrency = currency;

    if (!cp.contains(optionCurrency)) {
      throw new PortfolioParsingException("Option currency must appear in the currency pair");
    }
    if (!cp.contains(notionalCurrency)) {
      throw new PortfolioParsingException("Notional currency must appear in the currency pair");
    }

    boolean isCall = trade.getOptionType() == OptionType.CALL;
    Currency other = cp.getComplement(optionCurrency);
    _callCurrency = isCall ? optionCurrency : other;
    _putCurrency = isCall ? other : optionCurrency;

    BigDecimal strike = trade.getStrike();
View Full Code Here

    @Override
    public Set<ValueSpecification> getResults(final FunctionCompilationContext context, final ComputationTarget target) {
      final FinancialSecurity security = (FinancialSecurity) target.getPosition().getSecurity();
      final Currency putCurrency = security.accept(ForexVisitors.getPutCurrencyVisitor());
      final Currency callCurrency = security.accept(ForexVisitors.getCallCurrencyVisitor());
      final CurrencyPair currencyPair = _currencyPairs.getCurrencyPair(putCurrency, callCurrency);
      final String currencyBase = currencyPair.getBase().getCode(); // The base currency
      final ValueProperties properties = createValueProperties()
          .with(ValuePropertyNames.CALCULATION_METHOD, CalculationPropertyNamesAndValues.BLACK_METHOD)
          .withAny(FXOptionBlackFunction.PUT_CURVE)
          .withAny(FXOptionBlackFunction.PUT_CURVE_CALC_CONFIG)
          .withAny(FXOptionBlackFunction.CALL_CURVE)
View Full Code Here

      final Currency putCurrency = security.accept(ForexVisitors.getPutCurrencyVisitor());
      final Currency callCurrency = security.accept(ForexVisitors.getCallCurrencyVisitor());
      final UnorderedCurrencyPair currencies = UnorderedCurrencyPair.of(putCurrency, callCurrency);
      final String surfaceName = Iterables.getOnlyElement(surfaceNames);
      final String samplingPeriod = Iterables.getOnlyElement(samplingPeriods);
      final CurrencyPair currencyPair = _currencyPairs.getCurrencyPair(putCurrency, callCurrency);
      final String vegaResultCurrency = getResultCurrency(target, currencyPair);
      final String currencyBase = currencyPair.getBase().getCode(); // The base currency
      final ValueRequirement vegaMatrixRequirement = new ValueRequirement(ValueRequirementNames.VEGA_QUOTE_MATRIX, ComputationTargetSpecification.of(security),
          ValueProperties.builder()
              .with(ValuePropertyNames.CALCULATION_METHOD, CalculationPropertyNamesAndValues.BLACK_METHOD)
              .with(FXOptionBlackFunction.PUT_CURVE, Iterables.getOnlyElement(putCurveNames))
              .with(FXOptionBlackFunction.PUT_CURVE_CALC_CONFIG, Iterables.getOnlyElement(putCurveCalculationConfigs))
View Full Code Here

      final TimeSeriesSamplingFunction samplingFunction = getSamplingFunction(samplingFunctionName);
      final LocalDate[] schedule = HOLIDAY_REMOVER.getStrippedSchedule(scheduleCalculator.getSchedule(startDate, now, true, false), WEEKEND_CALENDAR);
      DoubleTimeSeries<?> vegaPnL = getPnLSeries(definition, specification, timeSeriesBundle, vegaMatrix, now, schedule, samplingFunction);
      vegaPnL = vegaPnL.multiply(position.getQuantity().doubleValue());
      final CurrencyPairs currencyPairs = OpenGammaExecutionContext.getCurrencyPairsSource(executionContext).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
      final CurrencyPair baseCounterPair = currencyPairs.getCurrencyPair(putCurrency, callCurrency);
      final String vegaResultCurrency = getResultCurrency(target, baseCounterPair);
      final String currencyBase = baseCounterPair.getBase().getCode();
      if (!currencyBase.equals(vegaResultCurrency)) {
        final Object spotFXObject = inputs.getValue(ValueRequirementNames.HISTORICAL_FX_TIME_SERIES);
        if (spotFXObject == null) {
          throw new OpenGammaRuntimeException("Could not get spot FX time series");
        }
View Full Code Here

    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);
    final String[] allCurveNames;
    if (baseQuotePair.getBase().equals(putCurrency)) { // To get Base/quote in market standard order.
      allCurveNames = new String[] {fullPutCurveName, fullCallCurveName };
    } else {
      allCurveNames = new String[] {fullCallCurveName, fullPutCurveName };
    }
    final InstrumentDefinition<?> definition = security.accept(new ForexSecurityConverter(baseQuotePairs));
View Full Code Here

    final Object spotObject = inputs.getValue(ValueRequirementNames.SPOT_RATE);
    if (spotObject == null) {
      throw new OpenGammaRuntimeException("Could not get spot requirement");
    }
    double spot = (Double) spotObject;
    final CurrencyPair baseQuotePair = baseQuotePairs.getCurrencyPair(putCurrency, callCurrency);
    if (baseQuotePair == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote pair for currency pair (" + putCurrency + ", " + callCurrency + ")");
    }
    if (baseQuotePair.getBase().equals(putCurrency)) { // To get Base/quote in market standard order.
      ccy1 = putCurrency;
      ccy2 = callCurrency;
      curves = new YieldAndDiscountCurve[] {putFundingCurve, callFundingCurve};
      allCurveNames = new String[] {fullPutCurveName, fullCallCurveName};
    } else {
View Full Code Here

      final Set<String> resultCurrencies = constraints.getValues(CURRENCY);
      final Currency payCurrency = security.accept(ForexVisitors.getPayCurrencyVisitor());
      final Currency receiveCurrency = security.accept(ForexVisitors.getReceiveCurrencyVisitor());
      String resultCurrency;
      if (resultCurrencies == null || resultCurrencies.size() != 1) {
        final CurrencyPair baseQuotePair = _currencyPairs.getCurrencyPair(payCurrency, receiveCurrency);
        final Currency baseCurrency = baseQuotePair.getBase();
        resultCurrency = baseCurrency.getCode();
      } else {
        resultCurrency = Iterables.getOnlyElement(resultCurrencies);
      }
      final ComputationTargetSpecification targetSpec = target.toSpecification();
View Full Code Here

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

      final CurrencyPair currencyPair = _currencyPairs.getCurrencyPair(payCurrency, receiveCurrency);
      final Currency currencyBase = currencyPair.getBase();
      LocalDateDoubleTimeSeries payPnLSeries = null;
      LocalDateDoubleTimeSeries receivePnLSeries = null;
      for (final ComputedValue input : inputs.getAllValues()) {
        if (!ValueRequirementNames.PNL_SERIES.equals(input.getSpecification().getValueName())) {
          continue;
View Full Code Here

TOP

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

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.