Examples of FXOptionSecurity


Examples of com.opengamma.financial.security.option.FXOptionSecurity

     * @param target The computation target, not null
     * @param fxMatrix The FX matrix, not null
     * @return The Black surface and curve data
     */
    protected BlackForexSmileProvider getBlackSurface(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final FXMatrix fxMatrix) {
      final FXOptionSecurity security = (FXOptionSecurity) target.getTrade().getSecurity();
      final MulticurveProviderInterface data = getMergedProviders(inputs, fxMatrix);
      final SmileDeltaTermStructureParametersStrikeInterpolation volatilitySurface = (SmileDeltaTermStructureParametersStrikeInterpolation) inputs.getValue(STANDARD_VOLATILITY_SURFACE_DATA);
      final Pair<Currency, Currency> currencyPair = Pair.of(security.getPutCurrency(), security.getCallCurrency());
      final BlackForexSmileProvider blackData = new BlackForexSmileProvider(data, volatilitySurface, currencyPair);
      return blackData;
    }
View Full Code Here

Examples of com.opengamma.financial.security.option.FXOptionSecurity

  private Collection<FXOptionSecurity> createRandomFXOptions() {
    fetch(CCYS);
    final Collection<FXOptionSecurity> fxOptions = new ArrayList<>();
    final Random random = new Random(1235);
    for (int i = 0; i < SIZE; i++) {
      FXOptionSecurity fxOption = null;
      try {
        final UnorderedCurrencyPair ccys = CCYS[random.nextInt(CCYS.length)];
        final LocalDate tradeDate = getTradeDate(random, ccys.getFirstCurrency());
        final Tenor tenor = TENORS[random.nextInt(TENORS.length)];
        fxOption = makeFXOption(random, ccys, tradeDate, tenor);
      } catch (final Exception e) {
        e.printStackTrace();
      }
      if (fxOption != null) {
        fxOptions.add(fxOption);
      }
    }
    final StringBuilder sb = new StringBuilder();
    sb.append("Parsed ").append(fxOptions.size()).append(" FX options:\n");
    for (final FXOptionSecurity fxOption : fxOptions) {
      sb.append("\t").append(fxOption.getName()).append("\n");
    }
    s_logger.info(sb.toString());
    return fxOptions;
  }
View Full Code Here

Examples of com.opengamma.financial.security.option.FXOptionSecurity

    sb.append(putCurrency);
    sb.append("/");
    sb.append(callCurrency);
    sb.append(" @ ");
    sb.append(FORMATTER.format(strike));
    final FXOptionSecurity fxOption = new FXOptionSecurity(putCurrency, callCurrency, putAmount, callAmount, new Expiry(expiryDate), expiryDate.plusDays(2),
        random.nextBoolean(), new EuropeanExerciseType());
    fxOption.addExternalId(ExternalId.of(ID_SCHEME, GUIDGenerator.generate().toString()));
    fxOption.setName(sb.toString());
    return fxOption;
  }
View Full Code Here

Examples of com.opengamma.financial.security.option.FXOptionSecurity

    return FinancialSecurityTypes.FX_OPTION_SECURITY;
  }

  @Override
  protected ComputationTargetReference getTargetForUnderlyings(final ComputationTarget target) {
    final FXOptionSecurity fxOption = (FXOptionSecurity) target.getSecurity();
    return ComputationTargetType.UNORDERED_CURRENCY_PAIR.specification(UnorderedCurrencyPair.of(fxOption.getCallCurrency(), fxOption.getPutCurrency()));
  }
View Full Code Here

Examples of com.opengamma.financial.security.option.FXOptionSecurity

  }

  @Override
  public boolean canApplyTo(final FunctionCompilationContext context, final ComputationTarget target) {
    final Security security = target.getSecurity();
    final FXOptionSecurity fxOption = (FXOptionSecurity) security;
    final String callCurrency = fxOption.getCallCurrency().getCode();
    return _currencyCurveConfigAndDiscountingCurveNames.containsKey(callCurrency);
  }
View Full Code Here

Examples of com.opengamma.financial.security.option.FXOptionSecurity

    return ComputationTargetType.UNORDERED_CURRENCY_PAIR.specification(UnorderedCurrencyPair.of(fxOption.getCallCurrency(), fxOption.getPutCurrency()));
  }

  @Override
  protected EuropeanVanillaOption getOption(final FinancialSecurity security, final ZonedDateTime date, final CurrencyPair currencyPair) {
    final FXOptionSecurity fxOption = (FXOptionSecurity) security;
    final Currency putCurrency = fxOption.getPutCurrency();
    double strike;
    if (putCurrency.equals(currencyPair.getBase())) {
      strike = fxOption.getCallAmount() / fxOption.getPutAmount();
    } else {
      strike = fxOption.getPutAmount() / fxOption.getCallAmount();
    }
    final DayCount actAct = DayCountFactory.INSTANCE.getDayCount("Actual/Actual ISDA");
    final double t = actAct.getDayCountFraction(date, fxOption.getExpiry().getExpiry());
    return new EuropeanVanillaOption(strike, t, true); //TODO this shouldn't be hard coded to a call
  }
View Full Code Here

Examples of com.opengamma.financial.security.option.FXOptionSecurity

    }
  }

  @Override
  protected Set<String> getDefaultValue(final FunctionCompilationContext context, final ComputationTarget target, final ValueRequirement desiredValue, final String propertyName) {
    final FXOptionSecurity security = (FXOptionSecurity) target.getSecurity();
    final String callCurrency = security.getCallCurrency().getCode();
    if (!_currencyCurveConfigAndDiscountingCurveNames.containsKey(callCurrency)) {
      s_logger.error("Could not get config for call currency " + callCurrency + "; should never happen");
      return null;
    }
    final Pair<String, String> pair = _currencyCurveConfigAndDiscountingCurveNames.get(callCurrency);
View Full Code Here

Examples of com.opengamma.financial.security.option.FXOptionSecurity

    ExternalId forwardId = ExternalId.of("sec", "fx");
    EquitySecurity equity = new EquitySecurity("exch", "excd", "ACME", Currency.USD);
    ExternalId region = ExternalId.of("regionScheme", "regionValue");
    ZonedDateTime now = ZonedDateTime.now();
    FXForwardSecurity fxForward = new FXForwardSecurity(Currency.AUD, 123, Currency.CAD, 321, now, region);
    FXOptionSecurity fxOption = new FXOptionSecurity(Currency.AUD, Currency.CAD, 123, 321, new Expiry(now),
                                                     now, true, new AmericanExerciseType());
    SelectorResolver resolver = mock(SelectorResolver.class);
    when(resolver.resolveSecurity(equityId)).thenReturn(equity);
    when(resolver.resolveSecurity(forwardId)).thenReturn(fxForward);
    when(resolver.resolveSecurity(optionId)).thenReturn(fxOption);
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.