Package com.opengamma.financial.currency

Examples of com.opengamma.financial.currency.CurrencyPair


        public CurrencyAmount visitFXOptionSecurity(final FXOptionSecurity security) {
          final Currency currency1 = security.getPutCurrency();
          final double amount1 = security.getPutAmount();
          final Currency currency2 = security.getCallCurrency();
          final double amount2 = security.getCallAmount();
          final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(currency1, currency2);
          if (currencyPair.getBase().equals(currency1)) {
            return CurrencyAmount.of(currency1, amount1);
          }
          return CurrencyAmount.of(currency2, amount2);
        }

        @Override
        public CurrencyAmount visitFXBarrierOptionSecurity(final FXBarrierOptionSecurity security) {
          final Currency currency1 = security.getPutCurrency();
          final double amount1 = security.getPutAmount();
          final Currency currency2 = security.getCallCurrency();
          final double amount2 = security.getCallAmount();
          final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(currency1, currency2);
          if (currencyPair.getBase().equals(currency1)) {
            return CurrencyAmount.of(currency1, amount1);
          }
          return CurrencyAmount.of(currency2, amount2);
        }

        @Override
        public CurrencyAmount visitNonDeliverableFXOptionSecurity(final NonDeliverableFXOptionSecurity security) {
          final Currency currency = security.getDeliveryCurrency();
          final double amount = security.getCallCurrency().equals(currency) ? security.getCallAmount() : security.getPutAmount();
          return CurrencyAmount.of(currency, amount);
        }

        @Override
        public CurrencyAmount visitFXDigitalOptionSecurity(final FXDigitalOptionSecurity security) {
          final Currency currency1 = security.getPutCurrency();
          final double amount1 = security.getPutAmount();
          final Currency currency2 = security.getCallCurrency();
          final double amount2 = security.getCallAmount();
          final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(currency1, currency2);
          if (currencyPair.getBase().equals(currency1)) {
            return CurrencyAmount.of(currency1, amount1);
          }
          return CurrencyAmount.of(currency2, amount2);
        }

        @Override
        public CurrencyAmount visitNonDeliverableFXDigitalOptionSecurity(final NonDeliverableFXDigitalOptionSecurity security) {
          final Currency currency = security.getPaymentCurrency();
          final double amount = security.getCallCurrency().equals(currency) ? security.getCallAmount() : security.getPutAmount();
          return CurrencyAmount.of(currency, amount);
        }

        @Override
        public CurrencyAmount visitFXForwardSecurity(final FXForwardSecurity security) {
          final Currency currency1 = security.getPayCurrency();
          final double amount1 = security.getPayAmount();
          final Currency currency2 = security.getReceiveCurrency();
          final double amount2 = security.getReceiveAmount();
          final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(currency1, currency2);
          if (currencyPair.getBase().equals(currency1)) {
            return CurrencyAmount.of(currency1, amount1);
          }
          return CurrencyAmount.of(currency2, amount2);
        }
View Full Code Here


  @GET
  @Path("currencyPairs/{name}/{currency1}/{currency2}")
  public Response getPair(@PathParam("name") String name, @PathParam("currency1") String currency1Str, @PathParam("currency2") String currency2Str) {
    Currency currency1 = Currency.parse(currency1Str);
    Currency currency2 = Currency.parse(currency2Str);
    CurrencyPair result = getCurrencyPairsSource().getCurrencyPair(name, currency1, currency2);
    return responseOkFudge(result);
  }
View Full Code Here

    final ZonedDateTime settlementDate = fxDigitalOptionSecurity.getSettlementDate();
    final boolean isLong = fxDigitalOptionSecurity.isLong();
    final ForexDefinition underlying;
    final Currency payCurrency = fxDigitalOptionSecurity.getPaymentCurrency();
    final boolean payDomestic;
    final CurrencyPair baseQuotePair = _currencyPairs.getCurrencyPair(putCurrency, callCurrency);
    if (baseQuotePair == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote order for currency pair (" + putCurrency + ", " + callCurrency + ")");
    }
    // Implementation note: To get Base/quote in market standard order.
    if (baseQuotePair.getBase().equals(putCurrency)) {
      underlying = ForexDefinition.fromAmounts(putCurrency, callCurrency, settlementDate, putAmount, -callAmount);
      payDomestic = (payCurrency.equals(callCurrency));
      return new ForexOptionDigitalDefinition(underlying, expiry, false, isLong, payDomestic);
    }
    underlying = ForexDefinition.fromAmounts(callCurrency, putCurrency, settlementDate, callAmount, -putAmount);
View Full Code Here

    final double callAmount = fxNDFDigitalOptionSecurity.getCallAmount();
    final ZonedDateTime expiry = fxNDFDigitalOptionSecurity.getExpiry().getExpiry();
    final ZonedDateTime settlementDate = fxNDFDigitalOptionSecurity.getSettlementDate();
    final boolean isLong = fxNDFDigitalOptionSecurity.isLong();
    final ForexDefinition underlying;
    final CurrencyPair baseQuotePair = _currencyPairs.getCurrencyPair(putCurrency, callCurrency);
    if (baseQuotePair == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote order for currency pair (" + putCurrency + ", " + callCurrency + ")");
    }
    // TODO: Review this part (see digital options)
    if (baseQuotePair.getBase().equals(putCurrency)) { // To get Base/quote in market standard order.
      final double fxRate = callAmount / putAmount;
      underlying = new ForexDefinition(putCurrency, callCurrency, settlementDate, putAmount, fxRate);
      return new ForexOptionDigitalDefinition(underlying, expiry, false, isLong);
    }
    final double fxRate = putAmount / callAmount;
View Full Code Here

    final double callAmount = fxOptionSecurity.getCallAmount();
    final ZonedDateTime expiry = fxOptionSecurity.getExpiry().getExpiry();
    final ZonedDateTime settlementDate = fxOptionSecurity.getSettlementDate();
    final boolean isLong = fxOptionSecurity.isLong();
    ForexDefinition underlying;
    final CurrencyPair baseQuotePair = _currencyPairs.getCurrencyPair(putCurrency, callCurrency);
    if (baseQuotePair == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote order for currency pair (" + putCurrency + ", " + callCurrency + ")");
    }
    if (baseQuotePair.getBase().equals(putCurrency)) {
      underlying = ForexDefinition.fromAmounts(putCurrency, callCurrency, settlementDate, putAmount, -callAmount);
      return new ForexOptionVanillaDefinition(underlying, expiry, false, isLong);
    }
    underlying = ForexDefinition.fromAmounts(callCurrency, putCurrency, settlementDate, callAmount, -putAmount);
    return new ForexOptionVanillaDefinition(underlying, expiry, true, isLong);
View Full Code Here

    final double callAmount = fxOptionSecurity.getCallAmount();
    final ZonedDateTime expiry = fxOptionSecurity.getExpiry().getExpiry();
    final ZonedDateTime settlementDate = fxOptionSecurity.getSettlementDate();
    final boolean isLong = fxOptionSecurity.isLong();
    ForexDefinition underlying;
    final CurrencyPair baseQuotePair = _currencyPairs.getCurrencyPair(putCurrency, callCurrency);
    if (baseQuotePair == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote order for currency pair (" + putCurrency + ", " + callCurrency + ")");
    }
    if (baseQuotePair.getBase().equals(putCurrency)) {
      underlying = ForexDefinition.fromAmounts(putCurrency, callCurrency, settlementDate, putAmount, -callAmount);
      return new ForexOptionVanillaDefinition(underlying, expiry, false, isLong);
    }
    underlying = ForexDefinition.fromAmounts(callCurrency, putCurrency, settlementDate, callAmount, -putAmount);
    return new ForexOptionVanillaDefinition(underlying, expiry, true, isLong);
View Full Code Here

    final double putAmount = barrierOptionSecurity.getPutAmount();
    final double callAmount = barrierOptionSecurity.getCallAmount();
    final Barrier barrier = new Barrier(getKnockType(barrierOptionSecurity.getBarrierDirection()), getBarrierType(barrierOptionSecurity.getBarrierType()),
        getObservationType(barrierOptionSecurity.getMonitoringType()), barrierOptionSecurity.getBarrierLevel());
    // Compose underlying FXOption s.t. strike is quoted using market convention, as defined in _currencyPairs
    final CurrencyPair baseQuotePair = _currencyPairs.getCurrencyPair(putCurrency, callCurrency);
    if (baseQuotePair == null) {
      throw new OpenGammaRuntimeException("Could not get base/quote order for currency pair (" + putCurrency + ", " + callCurrency + ")");
    }
    ForexDefinition underlying;
    boolean isCall;
    if (baseQuotePair.getBase().equals(putCurrency)) {
      underlying = ForexDefinition.fromAmounts(putCurrency, callCurrency, settlementDate, putAmount, -callAmount);
      isCall = false;
    } else {
      underlying = ForexDefinition.fromAmounts(callCurrency, putCurrency, settlementDate, callAmount, -putAmount);
      isCall = true;
View Full Code Here

    final Object spotObject = inputs.getValue(ValueRequirementNames.SPOT_RATE);
    if (spotObject == null) {
      throw new OpenGammaRuntimeException("Could not get spot requirement");
    }
    final 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 };
      spot = (Double) spotObject;
View Full Code Here

      throw new OpenGammaRuntimeException("Empty price series for " + security);
    }
    // TODO: If we know which way up we want the time series, don't request it in "convention order" and then lookup the convention again here, request it in
    // the desired order in getRequirements using a CurrencyPair
    final CurrencyPairs currencyPairs = OpenGammaExecutionContext.getCurrencyPairsSource(executionContext).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
    final CurrencyPair currencyPair = currencyPairs.getCurrencyPair(security.getNumerator(), security.getDenominator());
    if (!payCurrency.equals(currencyPair.getBase()) && receiveCurrency.equals(security.getCurrency())) {
      ts = ts.reciprocal();
    }
    final Object pvObject = inputs.getValue(new ValueRequirement(ValueRequirementNames.PRESENT_VALUE, ComputationTargetType.SECURITY, security.getUniqueId()));
    if (pvObject == null) {
      throw new OpenGammaRuntimeException("Present value was null");
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 ValueSpecification resultSpec = new ValueSpecification(getValueRequirementName(), target.toSpecification(), getResultProperties(target,
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.