Package com.opengamma.financial.analytics

Examples of com.opengamma.financial.analytics.DoubleLabelledMatrix2D


            xLabelsArray[j] = xLabels.get(j);
          }
          valuesArray[i][j] = values.get(i).get(j);
        }
      }
      return new DoubleLabelledMatrix2D(xKeysArray, xLabelsArray, xTitle, yKeysArray, yLabelsArray, yTitle, valuesArray, valuesTitle);
    }
View Full Code Here


  // FunctionInvoker

  @Override
  public Set<ComputedValue> execute(final FunctionExecutionContext context, final FunctionInputs inputs, final ComputationTarget target, final Set<ValueRequirement> desiredValues) {
    final ValueRequirement desiredValue = desiredValues.iterator().next();
    final DoubleLabelledMatrix2D input = (DoubleLabelledMatrix2D) inputs.getValue(ValueRequirementNames.COVARIANCE_MATRIX);
    final DoubleLabelledMatrix2D output = new DoubleLabelledMatrix2D(input.getXKeys(), input.getXLabels(), input.getYKeys(), input.getYLabels(), input.getValues());
    // TODO: This is a really dumb way to do this. There should be something in OG-Analytics or OG-Maths that will do this faster. This is a crude mechanism to
    // transform the covariance matrix to something that is more easily displayed
    final double[][] values = output.getValues();
    final double[] stddev = new double[values.length];
    for (int i = 0; i < values.length; i++) {
      stddev[i] = Math.sqrt(values[i][i]);
    }
    for (int i = 0; i < values.length; i++) {
View Full Code Here

      keys[i] = (double) i;
    }
    // Calculate the co-variance matrix
    final DoubleMatrix2D unlabelled = calculator.evaluate(timeSeries);
    // Label it
    return new DoubleLabelledMatrix2D(keys, labels, keys, labels, unlabelled.getData());
  }
View Full Code Here

      }
      final Object volatilityHTSObject = inputs.getValue(ValueRequirementNames.VOLATILITY_SURFACE_HISTORICAL_TIME_SERIES);
      if (volatilityHTSObject == null) {
        throw new OpenGammaRuntimeException("Could not get historical time series for volatilities");
      }
      final DoubleLabelledMatrix2D vegaMatrix = (DoubleLabelledMatrix2D) vegaMatrixObject;
      final HistoricalTimeSeriesBundle timeSeriesBundle = (HistoricalTimeSeriesBundle) volatilityHTSObject;
      final Clock snapshotClock = executionContext.getValuationClock();
      final LocalDate now = ZonedDateTime.now(snapshotClock).toLocalDate();
      final ValueRequirement desiredValue = Iterables.getOnlyElement(desiredValues);
      final String surfaceName = desiredValue.getConstraint(ValuePropertyNames.SURFACE);
View Full Code Here

    final Double[] xKeys = new Double[] {1., 2., 3., 4., 5.};
    final Double[] yKeys = new Double[] {1., 2., 3.};
    final Object[] xLabels = new String[] {"A", "B", "C", "D", "E"};
    final Object[] yLabels = new String[] {"A", "B", "C"};
    final double[][] values = new double[][] {new double[] {1, 2, 3, 4, 5}, new double[] {2, 4, 6, 8, 10}, new double[] {3, 6, 9, 12, 15}};
    DoubleLabelledMatrix2D m1 = new DoubleLabelledMatrix2D(xKeys, xLabels, yKeys, yLabels, values);
    assertEquals(m1, cycleObject(DoubleLabelledMatrix2D.class, m1));
    DoubleLabelledMatrix2D m2 = new DoubleLabelledMatrix2D(xKeys, xLabels, "x", yKeys, yLabels, "y", values, "values");
    assertEquals(m2, cycleObject(DoubleLabelledMatrix2D.class, m2));
  }
View Full Code Here

    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    final Set<ComputedValue> result = FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
    assertEquals(result.size(), 1);
    final ComputedValue value = result.iterator().next();
    assertEquals(value.getValue().getClass(), DoubleLabelledMatrix2D.class);
    final DoubleLabelledMatrix2D matrix = (DoubleLabelledMatrix2D) value.getValue();
    assertEquals(matrix.getXLabels().length, 5);
    assertEquals(matrix.getYLabels().length, 5);
  }
View Full Code Here

    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    final Set<ComputedValue> result = FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
    assertEquals(result.size(), 1);
    final ComputedValue value = result.iterator().next();
    assertEquals(value.getValue().getClass(), DoubleLabelledMatrix2D.class);
    final DoubleLabelledMatrix2D matrix = (DoubleLabelledMatrix2D) value.getValue();
    assertEquals(matrix.getXLabels().length, 3);
    assertEquals(matrix.getYLabels().length, 3);
  }
View Full Code Here

    final FunctionInputs inputs = new FunctionInputsImpl(null, new ComputedValue(INPUT_VALUE, input));
    final Set<ComputedValue> result = FUNCTION.execute(new FunctionExecutionContext(), inputs, ComputationTarget.NULL, Collections.singleton(DESIRED_VALUE));
    assertEquals(result.size(), 1);
    final ComputedValue value = result.iterator().next();
    assertEquals(value.getValue().getClass(), DoubleLabelledMatrix2D.class);
    final DoubleLabelledMatrix2D matrix = (DoubleLabelledMatrix2D) value.getValue();
    assertEquals(matrix.getXLabels().length, 5);
    assertEquals(matrix.getYLabels().length, 5);
  }
View Full Code Here

        }
        values[j++][i] = vega;
      }
      i++;
    }
    final DoubleLabelledMatrix2D matrix = new DoubleLabelledMatrix2D(uniqueX, expLabels, uniqueY, uniqueY, values);
    return Collections.singleton(new ComputedValue(resultSpec, matrix));
  }
View Full Code Here

            rowLabels[j] = VegaMatrixUtils.getFXVolatilityFormattedExpiry(expiries[j]);
          }
          values[i][j] = vega[j][i];
        }
      }
      return Collections.singleton(new ComputedValue(spec, new DoubleLabelledMatrix2D(rowValues, rowLabels, columnValues, columnLabels, values)));
    }
    throw new OpenGammaRuntimeException("Can only calculate vega matrix for surfaces with smiles");
  }
View Full Code Here

TOP

Related Classes of com.opengamma.financial.analytics.DoubleLabelledMatrix2D

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.