Examples of OptionDefinition


Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

  private static final double EPS = 2e-2;

  @Test
  public void testEuropeanOption() {
    final int n = 1001;
    final OptionDefinition call1 = new EuropeanVanillaOptionDefinition(SPOT * .9, EXPIRY, true);
    final OptionDefinition put1 = new EuropeanVanillaOptionDefinition(SPOT * .9, EXPIRY, false);
    final OptionDefinition call2 = new EuropeanVanillaOptionDefinition(SPOT * 1.1, EXPIRY, true);
    final OptionDefinition put2 = new EuropeanVanillaOptionDefinition(SPOT * 1.1, EXPIRY, false);
    final AnalyticOptionModel<OptionDefinition, StandardOptionDataBundle> bsm = new BlackScholesMertonModel();
    TreeOptionModel<OptionDefinition, StandardOptionDataBundle> treeModel = new BinomialOptionModel<>(CRR, n, 5);
    assertGreeks(call1, treeModel, bsm);
    assertGreeks(put1, treeModel, bsm);
    assertGreeks(call2, treeModel, bsm);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

    //double impVol = BlackImpliedVolFormula.impliedVol(optionPriceTree.getNode(0, 0).getValue(), FORWARD, FORWARD, YIELD_CURVE.getDiscountFactor(T), T, true);
    assertEquals(ATM_VOL, impVol, 1e-3);
    for (int i = 0; i < 10; i++) {
      final double m = -1.5 + 3.0 * i / 10.0;
      final double strike = FORWARD * Math.exp(ATM_VOL * Math.sqrt(T) * m);
      final OptionDefinition option = new EuropeanVanillaOptionDefinition(strike, OPTION.getExpiry(), OPTION.isCall());
      o = new EuropeanVanillaOption(strike, T, OPTION.isCall());
      optionPriceTree = BUILDER.buildOptionPriceTree(option, DATA, assetPriceTree);
      impVol = BLACK_IMPLIED_VOL.getImpliedVolatility(data, o, optionPriceTree.getNode(0, 0).getValue());
      //impVol = BlackImpliedVolFormula.impliedVol(optionPriceTree.getNode(0, 0).getValue(), FORWARD, strike, YIELD_CURVE.getDiscountFactor(T), T, true);
      // System.out.println(strike+"\t"+impVol);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

    //    double impVol = BlackImpliedVolFormula.impliedVol(optionPriceTree.getNode(0, 0).getValue(), FORWARD, FORWARD, df, T, true);
    assertEquals(vol, impVol, 1e-3);
    for (int i = 0; i < 10; i++) {
      final double m = -1.5 + 3.0 * i / 10.0;
      final double strike = FORWARD * Math.exp(ATM_VOL * Math.sqrt(T) * m);
      final OptionDefinition option = new EuropeanVanillaOptionDefinition(strike, OPTION.getExpiry(), OPTION.isCall());
      optionPriceTree = BUILDER.buildOptionPriceTree(option, data, assetPriceTree);
      o = new EuropeanVanillaOption(strike, T, OPTION.isCall());
      optionPriceTree = BUILDER.buildOptionPriceTree(option, DATA, assetPriceTree);
      impVol = BLACK_IMPLIED_VOL.getImpliedVolatility(bfd, o, optionPriceTree.getNode(0, 0).getValue());
      //impVol = BlackImpliedVolFormula.impliedVol(optionPriceTree.getNode(0, 0).getValue(), FORWARD, strike, df, T, true);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

    final RecombiningBinomialTree<BinomialTreeNode<Double>> assetPriceTree = BUILDER.buildAssetTree(T, data, 200);
    RecombiningBinomialTree<BinomialTreeNode<Double>> optionPriceTree = BUILDER.buildOptionPriceTree(OPTION, data, assetPriceTree);
    for (int i = 0; i < 10; i++) {
      final double m = -1.5 + 3.0 * i / 10.0;
      final double strike = FORWARD * Math.exp(ATM_VOL * Math.sqrt(T) * m);
      final OptionDefinition option = new EuropeanVanillaOptionDefinition(strike, OPTION.getExpiry(), OPTION.isCall());
      optionPriceTree = BUILDER.buildOptionPriceTree(option, data, assetPriceTree);
      final EuropeanVanillaOption o = new EuropeanVanillaOption(strike, T, true);
      final CEVFunctionData cfd = new CEVFunctionData(FORWARD, YIELD_CURVE.getDiscountFactor(T), SIGMA_BETA, BETA);
      final double cevPrice = CEV_PRICE.getPriceFunction(o).evaluate(cfd);
      final double cevVol = BLACK_IMPLIED_VOL.getImpliedVolatility(new BlackFunctionData(FORWARD, YIELD_CURVE.getDiscountFactor(T), SIGMA_BETA), o, cevPrice);
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

  private static final AnalyticOptionModel<OptionDefinition, StandardOptionDataBundle> MODEL = new BlackScholesMertonModel();
  private static final double EPS = 1e-4;

  @Test
  public void testInputs() {
    final OptionDefinition definition = new EuropeanVanillaOptionDefinition(1., EIGHT_DAYS, true);
    super.assertInputs(MODEL, definition);
  }
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

    // Perform the calculation:
    final Expiry expiry = optionSec.getExpiry();
    final double years = DateUtils.getDifferenceInYears(today, expiry.getExpiry());
    final double b = discountCurve.getInterestRate(years); // TODO
    final OptionDefinition europeanVanillaOptionDefinition = new EuropeanVanillaOptionDefinition(optionSec.getStrike(), expiry, (optionSec.getOptionType() == OptionType.CALL));
    final Map<OptionDefinition, Double> prices = new HashMap<OptionDefinition, Double>();
    prices.put(europeanVanillaOptionDefinition, optionPrice);
    final VolatilitySurface volatilitySurface = _volatilitySurfaceModel.getSurface(prices, new StandardOptionDataBundle(discountCurve, b, null, underlyingPrice, today));

    //This is so cheap no need to check desired values
View Full Code Here

Examples of com.opengamma.analytics.financial.model.option.definition.OptionDefinition

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext executionContext, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final EquityOptionSecurity option = (EquityOptionSecurity) target.getSecurity();
    final StandardOptionDataBundle data = getDataBundle(executionContext.getValuationClock(), option, inputs);
    final OptionDefinition definition = getOptionDefinition(option);
    final Set<Greek> requiredGreeks = new HashSet<Greek>();
    for (final ValueRequirement dV : desiredValues) {
      final Greek desiredGreek = AvailableGreeks.getGreekForValueRequirement(dV);
      if (desiredGreek == null) {
        throw new IllegalArgumentException("Told to produce " + dV + " but couldn't be mapped to a Greek.");
View Full Code Here

Examples of de.innovationgate.wga.modules.options.OptionDefinition

            try {
                return getWgaConfiguration().getCachingOptionReader().readOptionValueOrDefault(options, optionName, modDef);
            }
            catch (OptionConversionException e) {
                getLog().error("Exception reading server option '" + optionName + "'. Falling back to default", e);
                OptionDefinition optDef = modDef.getOptionDefinitions().get(optionName);
                if (optDef != null) {
                    try {
                        return OptionReader.unconvertOptionValue(optDef, optDef.getDefaultValue());
                    }
                    catch (OptionConversionException e1) {
                        getLog().error("Exception unconverting default value of server option '" + optionName + "'. Falling back to null", e);
                    }
                }
View Full Code Here

Examples of de.innovationgate.wga.modules.options.OptionDefinition

    }
   
    public Object readPublisherOptionOrDefault(WGDatabase db, String name) {

        // Fetch option definition
        OptionDefinition optionDef = null;
       
        Class typeClass = ContentDatabasePublisherOptionsModuleType.class;
        Class collectorClass = ContentDatabasePublisherOptionsCollector.class;
        if (db.hasFeature(WGDatabase.FEATURE_FULLCONTENTFEATURES)) {
            typeClass = ContentStorePublisherOptionsModuleType.class;
            collectorClass = ContentStorePublisherOptionsCollector.class;
        }
       
        if (getModuleRegistry() != null) {
            ModuleDefinition pOptionDefs = getModuleRegistry().getModuleDefinition(typeClass, collectorClass);
            optionDef = pOptionDefs.getOptionDefinitions().get(name);
        }
       

        // Read the option value, default it if neccessary
        Object value = db.getAttribute(name);
        if (value == null && optionDef != null && optionDef.getDefaultValue() != null) {
            value = optionDef.getDefaultValue();
        }
       
        if (optionDef != null) {
            try {
                return OptionReader.unconvertOptionValue(optionDef, value);
View Full Code Here

Examples of de.innovationgate.wga.modules.options.OptionDefinition

                        Map<String,String> options = (Map<String, String>) desc.getReadMethod().invoke(configBean);
                        Iterator<Map.Entry<String,String>> optionsIt = options.entrySet().iterator();
                       
                        while (optionsIt.hasNext()) {
                            Map.Entry option = optionsIt.next();
                            OptionDefinition optionDef = optionDefs.get(option.getKey());
                            if (optionDef != null && optionDef.isOptional() && optionDef.getDefaultValue() != null && optionDef.getDefaultValue().equals(option.getValue())) {
                                LOG.info("Removing option '" + option.getKey() + "' on default value '" + optionDef.getDefaultValue() + "' from configuration object '" + configBean.getClass().getName());
                                optionsIt.remove();
                            }
                        }
                       
                    }
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.