Package com.opengamma.engine.marketdata

Examples of com.opengamma.engine.marketdata.OverrideOperation.apply()


    }
    s_logger.debug("Applying {} to {}", shift, marketData);
    final OverrideOperation operation = compiler.compile(shift, executionContext.getComputationTargetResolver());
    for (final Map.Entry<ExternalIdBundle, Double> dataPoint : marketData.getDataPointSet()) {
      s_logger.debug("Applying to {}", dataPoint);
      final Object result = operation.apply(new ValueRequirement(MarketDataRequirementNames.MARKET_VALUE, ComputationTargetType.PRIMITIVE, dataPoint.getKey()),
          dataPoint.getValue());
      s_logger.debug("Got result {}", result);
      if (result instanceof Number) {
        dataPoint.setValue(((Number) result).doubleValue());
      } else {
View Full Code Here


  public void testConstantMultiplier() {
    final MarketDataELCompiler compiler = new MarketDataELCompiler();
    final OverrideOperation operation = compiler.compile("x * 0.9", new DefaultComputationTargetResolver().atVersionCorrection(VersionCorrection.LATEST));
    assertNotNull(operation);
    final ValueRequirement req = new ValueRequirement("Foo", ComputationTargetSpecification.of(UniqueId.of("Test", "Bar")));
    final Object result = operation.apply(req, 42d);
    assertEquals(result, 42d * 0.9);
  }

  public void testConstantAddition() {
    final MarketDataELCompiler compiler = new MarketDataELCompiler();
View Full Code Here

  public void testConstantAddition() {
    final MarketDataELCompiler compiler = new MarketDataELCompiler();
    final OverrideOperation operation = compiler.compile("x + 0.42", new DefaultComputationTargetResolver().atVersionCorrection(VersionCorrection.LATEST));
    assertNotNull(operation);
    final ValueRequirement req = new ValueRequirement("Foo", ComputationTargetSpecification.of(UniqueId.of("Test", "Bar")));
    final Object result = operation.apply(req, 0.9d);
    assertEquals(result, 0.9 + 0.42);
  }

  public void testConditionalExpression() {
    final InMemorySecuritySource securities = new InMemorySecuritySource();
View Full Code Here

    securities.addSecurity(_fooEquity);
    securities.addSecurity(_swap);
    final MarketDataELCompiler compiler = new MarketDataELCompiler();
    final OverrideOperation operation = compiler.compile("if (security.type == \"EQUITY\") x * 0.9", new DefaultComputationTargetResolver(securities).atVersionCorrection(VersionCorrection.LATEST));
    assertNotNull(operation);
    Object result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_fooEquity)), 42d);
    assertEquals (result, 42d * 0.9);
    result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_swap)), 42d);
    assertEquals (result, 42d);
  }

View Full Code Here

    final MarketDataELCompiler compiler = new MarketDataELCompiler();
    final OverrideOperation operation = compiler.compile("if (security.type == \"EQUITY\") x * 0.9", new DefaultComputationTargetResolver(securities).atVersionCorrection(VersionCorrection.LATEST));
    assertNotNull(operation);
    Object result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_fooEquity)), 42d);
    assertEquals (result, 42d * 0.9);
    result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_swap)), 42d);
    assertEquals (result, 42d);
  }

  public void testMultipleConditionalExpression() {
    final InMemorySecuritySource securities = new InMemorySecuritySource();
View Full Code Here

    final OverrideOperation operation = compiler.compile(
        "if (security.type == \"EQUITY\" && security.name == \"Foo\") x * 0.9; if (security.type == \"EQUITY\") x * 1.1; if (security.cow == 42) x * 0", new DefaultComputationTargetResolver(
            securities).atVersionCorrection(VersionCorrection.LATEST));
    assertNotNull(operation);
    // First rule should match
    Object result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_fooEquity)), 42d);
    assertEquals (result, 42d * 0.9);
    // Second rule should match
    result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_barEquity)), 42d);
    assertEquals(result, 42d * 1.1);
    // Third rule won't match but won't throw an error
View Full Code Here

    assertNotNull(operation);
    // First rule should match
    Object result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_fooEquity)), 42d);
    assertEquals (result, 42d * 0.9);
    // Second rule should match
    result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_barEquity)), 42d);
    assertEquals(result, 42d * 1.1);
    // Third rule won't match but won't throw an error
    result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_swap)), 42d);
    assertEquals(result, 42d);
  }
View Full Code Here

    assertEquals (result, 42d * 0.9);
    // Second rule should match
    result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_barEquity)), 42d);
    assertEquals(result, 42d * 1.1);
    // Third rule won't match but won't throw an error
    result = operation.apply(new ValueRequirement("Foo", ComputationTargetSpecification.of(_swap)), 42d);
    assertEquals(result, 42d);
  }

  public void testValueExpression() {
    final MarketDataELCompiler compiler = new MarketDataELCompiler();
View Full Code Here

      for (ValueSpecification marketDataSpec : marketDataRequirements) {
        Object marketDataValue = marketDataValues.get(marketDataSpec);
        ComputedValueResult computedValueResult;
        if (operation != null) {
          if (marketDataValue != null) {
            marketDataValue = operation.apply(marketDataSpec.toRequirementSpecification(), marketDataValue);
            if (marketDataValue == null) {
              s_logger.debug("Market data {} discarded by override operation", marketDataSpec);
            }
          }
        }
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.