Package com.opengamma.financial.currency

Examples of com.opengamma.financial.currency.CurrencyPairs


  }

  @GET
  @Path("currencyPairs/{name}")
  public Response getPairs(@PathParam("name") String name) {
    CurrencyPairs result = getCurrencyPairsSource().getCurrencyPairs(name);
    return responseOkFudge(result);
  }
View Full Code Here


      @Override
      public CurrencyPair getCurrencyPair(final String name, final Currency currency1, final Currency currency2) {
        ArgumentChecker.notNull(currency1, "currency1");
        ArgumentChecker.notNull(currency2, "currency2");
        final CurrencyPairs currencyPairs = getCurrencyPairs(name);
        if (currencyPairs == null) {
          return null;
        }
        return currencyPairs.getCurrencyPair(currency1, currency2);
      }
    };
  }
View Full Code Here

      @Override
      public CurrencyPair getCurrencyPair(final String name, final Currency currency1, final Currency currency2) {
        ArgumentChecker.notNull(currency1, "currency1");
        ArgumentChecker.notNull(currency2, "currency2");
        final CurrencyPairs currencyPairs = getCurrencyPairs(name);
        if (currencyPairs == null) {
          return null;
        }
        return currencyPairs.getCurrencyPair(currency1, currency2);
      }
    };
  }
View Full Code Here

public class NotionalForTradeFunction extends AbstractFunction.NonCompiledInvoker {

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
      final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
    final CurrencyPairs currencyPairs = OpenGammaExecutionContext.getCurrencyPairsSource(executionContext).getCurrencyPairs(CurrencyPairs.DEFAULT_CURRENCY_PAIRS);
    final Trade trade = target.getTrade();
    final CurrencyAmount ca = FinancialSecurityUtils.getNotional(trade.getSecurity(), currencyPairs, executionContext.getSecuritySource()).multipliedBy(trade.getQuantity().doubleValue());
    final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.NOTIONAL, target.toSpecification(), createValueProperties().get());
    return Collections.singleton(new ComputedValue(spec, ca));
  }
View Full Code Here

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target,
      final Set<ValueRequirement> desiredValues) throws AsynchronousExecution {
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final CurrencyPairs currencyPairs = (CurrencyPairs) inputs.getValue(CURRENCY_PAIRS);
    SecuritySource securitySource = executionContext.getSecuritySource();
    final CurrencyAmount ca = FinancialSecurityUtils.getNotional(target.getSecurity(), currencyPairs, securitySource);
    final ValueSpecification spec = new ValueSpecification(ValueRequirementNames.NOTIONAL, target.toSpecification(), desiredValue.getConstraints().copy().get());
    if (desiredValue.getConstraint(PROPERTY_BUY).equals(NEGATIVE)) {
      return Collections.singleton(new ComputedValue(spec, ca.multipliedBy(-1)));
View Full Code Here

    final String rightExtrapolatorName = desiredValue.getConstraint(InterpolatedDataProperties.RIGHT_X_EXTRAPOLATOR_NAME);
    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 String fullPutCurveName = putCurveName + "_" + putCurrency.getCode();
    final String fullCallCurveName = callCurveName + "_" + callCurrency.getCode();
    final YieldAndDiscountCurve putFundingCurve = getCurve(inputs, putCurrency, putCurveName, putCurveConfig);
    final YieldAndDiscountCurve callFundingCurve = getCurve(inputs, callCurrency, callCurveName, callCurveConfig);
    final YieldAndDiscountCurve[] curves;
    final Map<String, Currency> curveCurrency = new HashMap<>();
    curveCurrency.put(fullPutCurveName, putCurrency);
    curveCurrency.put(fullCallCurveName, callCurrency);
    final InstrumentDefinition<?> definition = security.accept(new ForexSecurityConverter(baseQuotePairs));
    final String[] allCurveNames;
    final Currency ccy1;
    final Currency ccy2;
    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;
View Full Code Here

      final Map.Entry<UnorderedCurrencyPair, DoubleTimeSeries<?>> entry = Iterables.getOnlyElement(((Map<UnorderedCurrencyPair, DoubleTimeSeries<?>>) fxSeriesObject).entrySet());
      final Object currencyPairObject = inputs.getValue(ValueRequirementNames.CURRENCY_PAIRS);
      if (currencyPairObject == null) {
        throw new OpenGammaRuntimeException("Could not get currency pairs");
      }
      final CurrencyPairs currencyPairs = (CurrencyPairs) currencyPairObject;
      if (desiredCurrency.equals(currencyPairs.getCurrencyPair(Currency.of(desiredCurrency), Currency.of(currency)).getCounter().getCode())) {
        isInverse = false;
      }
      fxSeries = entry.getValue();
    }
    final Object bucketedCS01Object = inputs.getValue(ValueRequirementNames.BUCKETED_CS01);
View Full Code Here

    if (ts.isEmpty()) {
      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) {
View Full Code Here

    final String fullCallCurveName = callCurveName + "_" + callCurrency.getCode();
    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 };
View Full Code Here

      }
    }
    if (putCurveName == null || callCurveName == null || currencyPairConfigName == null) {
      return null;
    }
    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.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.