//------------------------------------------------------------------------- public virtual void test_requirements() { CalculationFunctions functions = CalculationFunctions.of(ImmutableMap.of(typeof(TestTarget), new TestFunction())); CalculationRules calculationRules = CalculationRules.of(functions, USD); IList <TestTarget> targets = ImmutableList.of(TARGET1); IList <Column> columns = ImmutableList.of(Column.of(TestingMeasures.PRESENT_VALUE)); CalculationTasks test = CalculationTasks.of(calculationRules, targets, columns); MarketDataRequirements requirements = test.requirements(REF_DATA); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Set<? extends com.opengamma.strata.data.MarketDataId<?>> nonObservables = requirements.getNonObservables(); ISet <MarketDataId <object> > nonObservables = requirements.NonObservables; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.google.common.collect.ImmutableSet<? extends com.opengamma.strata.data.ObservableId> observables = requirements.getObservables(); ImmutableSet <ObservableId> observables = requirements.Observables; ImmutableSet <ObservableId> timeSeries = requirements.TimeSeries; assertThat(nonObservables).hasSize(1); assertThat(nonObservables.GetEnumerator().next()).isEqualTo(TestId.of("1")); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> observableId = com.opengamma.strata.calc.marketdata.TestObservableId.of("2", CalculationTaskTest.OBS_SOURCE); MarketDataId <object> observableId = TestObservableId.of("2", CalculationTaskTest.OBS_SOURCE); assertThat(observables).hasSize(1); assertThat(observables.GetEnumerator().next()).isEqualTo(observableId); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> timeSeriesId = com.opengamma.strata.calc.marketdata.TestObservableId.of("3", CalculationTaskTest.OBS_SOURCE); MarketDataId <object> timeSeriesId = TestObservableId.of("3", CalculationTaskTest.OBS_SOURCE); assertThat(timeSeries).hasSize(1); assertThat(timeSeries.GetEnumerator().next()).isEqualTo(timeSeriesId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public <T> com.opengamma.strata.data.scenario.MarketDataBox<T> getValue(com.opengamma.strata.data.MarketDataId<T> id) public override MarketDataBox <T> getValue <T>(MarketDataId <T> id) { // this code exists to ensure that the error messages from market data building // are exposed to users when the failures are not checked // a special case for FX rates containing the same currency twice if (id is FxRateId && ((FxRateId)id).Pair.Identity) { FxRateId fxRateId = (FxRateId)id; FxRate identityRate = FxRate.of(fxRateId.Pair, 1); return(MarketDataBox.ofSingleValue((T)identityRate)); } // find the data and check it against the failures Optional <MarketDataBox <T> > opt = underlying.findValue(id); if (!opt.Present) { Failure failure = valueFailures.get(id); if (failure != null) { throw new FailureException(failure); } throw new MarketDataNotFoundException(Messages.format("Market data not found for identifier '{}' of type '{}'", id, id.GetType().Name)); } return(opt.get()); }
/// <summary> /// Returns a child node representing an item of market data. /// </summary> /// <param name="id"> an ID identifying the market data represented by the node </param> /// <param name="dataType"> the type of market data represented by the node, either a single value or a time series of values </param> /// <param name="children"> the child nodes representing the market data dependencies of the node </param> /// <returns> a child node representing an item of market data </returns> internal static MarketDataNode child <T1>(MarketDataId <T1> id, DataType dataType, IList <MarketDataNode> children) { ArgChecker.notNull(id, "id"); ArgChecker.notNull(dataType, "dataType"); ArgChecker.notNull(children, "children"); return(new MarketDataNode(id, dataType, children)); }
public virtual void requirements() { CalculationTaskCell cell = CalculationTaskCell.of(0, 0, TestingMeasures.PRESENT_VALUE, NATURAL); CalculationTask task = CalculationTask.of(TARGET, new TestFunction(), cell); MarketDataRequirements requirements = task.requirements(REF_DATA); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Set<? extends com.opengamma.strata.data.MarketDataId<?>> nonObservables = requirements.getNonObservables(); ISet <MarketDataId <object> > nonObservables = requirements.NonObservables; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.google.common.collect.ImmutableSet<? extends com.opengamma.strata.data.ObservableId> observables = requirements.getObservables(); ImmutableSet <ObservableId> observables = requirements.Observables; ImmutableSet <ObservableId> timeSeries = requirements.TimeSeries; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> timeSeriesId = com.opengamma.strata.calc.marketdata.TestObservableId.of("3", OBS_SOURCE); MarketDataId <object> timeSeriesId = TestObservableId.of("3", OBS_SOURCE); assertThat(timeSeries).hasSize(1); assertThat(timeSeries.GetEnumerator().next()).isEqualTo(timeSeriesId); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> nonObservableId = new com.opengamma.strata.calc.marketdata.TestId("1"); MarketDataId <object> nonObservableId = new TestId("1"); assertThat(nonObservables).hasSize(1); assertThat(nonObservables.GetEnumerator().next()).isEqualTo(nonObservableId); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> observableId = com.opengamma.strata.calc.marketdata.TestObservableId.of("2", OBS_SOURCE); MarketDataId <object> observableId = TestObservableId.of("2", OBS_SOURCE); assertThat(observables).hasSize(1); assertThat(observables.GetEnumerator().next()).isEqualTo(observableId); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public <R> MarketDataBox<R> getValue(com.opengamma.strata.data.MarketDataId<R> id) public override MarketDataBox <R> getValue <R>(MarketDataId <R> id) { if (this.id.Equals(id)) { return((MarketDataBox <R>)value); } return(underlying.getValue(id)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public <R> java.util.Optional<MarketDataBox<R>> findValue(com.opengamma.strata.data.MarketDataId<R> id) public Optional <MarketDataBox <R> > findValue <R>(MarketDataId <R> id) { if (this.id.Equals(id)) { return((MarketDataBox <R>)value); } return(underlying.findValue(id)); }
public override bool containsValue <T1>(MarketDataId <T1> id) { if (this.id.Equals(id)) { return(true); } return(underlying.containsValue(id)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public <T> java.util.Optional<MarketDataBox<T>> findValue(com.opengamma.strata.data.MarketDataId<T> id) public Optional <MarketDataBox <T> > findValue <T>(MarketDataId <T> id) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") MarketDataBox<T> value = (MarketDataBox<T>) values.get(id); MarketDataBox <T> value = (MarketDataBox <T>)values.get(id); return(Optional.ofNullable(value)); }
private ExtendedMarketData(MarketDataId <T> id, T value, MarketData underlying) { JodaBeanUtils.notNull(id, "id"); JodaBeanUtils.notNull(value, "value"); JodaBeanUtils.notNull(underlying, "underlying"); this.id = id; this.value = value; this.underlying = underlying; }
public virtual MarketDataRequirements requirements(CurveId id, MarketDataConfig config) { CurveGroupDefinition groupDefn = config.get(typeof(CurveGroupDefinition), id.CurveGroupName); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<? extends com.opengamma.strata.market.curve.CurveGroup> groupId = groupDefn.createGroupId(id.getObservableSource()); MarketDataId <CurveGroup> groupId = groupDefn.createGroupId(id.ObservableSource); return(MarketDataRequirements.of(groupId)); }
private ExtendedScenarioMarketData(MarketDataId <T> id, MarketDataBox <T> value, ScenarioMarketData underlying) { JodaBeanUtils.notNull(id, "id"); JodaBeanUtils.notNull(value, "value"); JodaBeanUtils.notNull(underlying, "underlying"); this.id = id; this.value = value; this.underlying = underlying; validate(); }
// checks the value is an instance of the market data type of the id internal static void checkType <T1>(MarketDataId <T1> id, object value) { if (!id.MarketDataType.IsInstanceOfType(value)) { if (value == null) { throw new System.ArgumentException(Messages.format("Value for identifier '{}' must not be null", id)); } throw new System.InvalidCastException(Messages.format("Value for identifier '{}' does not implement expected type '{}': '{}'", id, id.MarketDataType.Name, value)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public <T> MarketDataBox<T> getValue(com.opengamma.strata.data.MarketDataId<T> id) public override MarketDataBox <T> getValue <T>(MarketDataId <T> id) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") MarketDataBox<T> value = (MarketDataBox<T>) values.get(id); MarketDataBox <T> value = (MarketDataBox <T>)values.get(id); if (value == null) { throw new MarketDataNotFoundException(msgValueNotFound(id)); } return(value); }
public virtual MarketDataBox <Curve> build(CurveId id, MarketDataConfig config, ScenarioMarketData marketData, ReferenceData refData) { // find curve CurveGroupDefinition groupDefn = config.get(typeof(CurveGroupDefinition), id.CurveGroupName); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<? extends com.opengamma.strata.market.curve.CurveGroup> groupId = groupDefn.createGroupId(id.getObservableSource()); MarketDataId <CurveGroup> groupId = groupDefn.createGroupId(id.ObservableSource); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.scenario.MarketDataBox<? extends com.opengamma.strata.market.curve.CurveGroup> curveGroupBox = marketData.getValue(groupId); MarketDataBox <CurveGroup> curveGroupBox = marketData.getValue(groupId); return(curveGroupBox.map(curveGroup => findCurve(id, curveGroup))); }
// checks the value is an instance of the market data type of the id internal static void checkType <T1, T2>(MarketDataId <T1> id, MarketDataBox <T2> box, int scenarioCount) { if (box == null) { throw new System.ArgumentException(Messages.format("Value for identifier '{}' must not be null", id)); } if (box.ScenarioValue && box.ScenarioCount != scenarioCount) { throw new System.ArgumentException(Messages.format("Value for identifier '{}' should have had {} scenarios but had {}", id, scenarioCount, box.ScenarioCount)); } if (box.ScenarioCount > 0 && !id.MarketDataType.IsInstanceOfType(box.getValue(0))) { throw new System.InvalidCastException(Messages.format("Value for identifier '{}' does not implement expected type '{}': '{}'", id, id.MarketDataType.Name, box)); } }
// semi-parallel gamma PV01 for one scenario private CurrencyParameterSensitivities pv01SemiParallelGammaBucketed(ResolvedSwapTrade trade, RatesMarketData marketData) { // find the curve identifiers and resolve to a single curve ResolvedSwap product = trade.Product; if (product.CrossCurrency) { throw new System.ArgumentException("Implementation only supports a single curve, but swap is cross-currency"); } Currency currency = product.Legs.get(0).Currency; ISet <Index> indices = product.allIndices(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.google.common.collect.ImmutableSet<com.opengamma.strata.data.MarketDataId<?>> discountIds = marketData.getLookup().getDiscountMarketDataIds(currency); ImmutableSet <MarketDataId <object> > discountIds = marketData.Lookup.getDiscountMarketDataIds(currency); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.google.common.collect.ImmutableSet<com.opengamma.strata.data.MarketDataId<?>> forwardIds = indices.stream().flatMap(idx -> marketData.getLookup().getForwardMarketDataIds(idx).stream()).collect(toImmutableSet()); ImmutableSet <MarketDataId <object> > forwardIds = indices.stream().flatMap(idx => marketData.Lookup.getForwardMarketDataIds(idx).stream()).collect(toImmutableSet()); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Set<com.opengamma.strata.data.MarketDataId<?>> allIds = com.google.common.collect.Sets.union(discountIds, forwardIds); ISet <MarketDataId <object> > allIds = Sets.union(discountIds, forwardIds); if (allIds.Count != 1) { throw new System.ArgumentException(Messages.format("Implementation only supports a single curve, but lookup refers to more than one: {}", allIds)); } //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> singleId = allIds.iterator().next(); MarketDataId <object> singleId = allIds.GetEnumerator().next(); if (!(singleId is CurveId)) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new System.ArgumentException(Messages.format("Implementation only supports a single curve, but lookup does not refer to a curve: {} {}", singleId.GetType().FullName, singleId)); } CurveId curveId = (CurveId)singleId; Curve curve = marketData.MarketData.getValue(curveId); // calculate gamma CurrencyParameterSensitivity gamma = CurveGammaCalculator.DEFAULT.calculateSemiParallelGamma(curve, currency, c => calculateCurveSensitivity(trade, marketData, curveId, c)); return(CurrencyParameterSensitivities.of(gamma).multipliedBy(ONE_BASIS_POINT * ONE_BASIS_POINT)); }
public override MarketDataBox <T> getValue <T>(MarketDataId <T> id) { Optional <MarketDataBox <T> > value1 = underlying1.findValue(id); return(value1.Present ? value1.get() : underlying2.getValue(id)); }
public override bool containsValue <T1>(MarketDataId <T1> id) { return(underlying1.containsValue(id) || underlying2.containsValue(id)); }
public Optional <MarketDataBox <T> > findValue <T>(MarketDataId <T> id) { Optional <MarketDataBox <T> > value1 = underlying1.findValue(id); return(value1.Present ? value1 : underlying2.findValue(id)); }
/// <summary> /// Returns a leaf node representing an item of market data with no dependencies on other market data. /// </summary> /// <param name="id"> an ID identifying the market data represented by the node </param> /// <param name="dataType"> the type of market data represented by the node, either a single value or a time series of values </param> /// <returns> a leaf node representing an item of market data with no dependencies on other market data </returns> internal static MarketDataNode leaf <T1>(MarketDataId <T1> id, DataType dataType) { ArgChecker.notNull(id, "id"); ArgChecker.notNull(dataType, "dataType"); return(new MarketDataNode(id, dataType, ImmutableList.of())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public <T> java.util.Optional<T> findValue(MarketDataId<T> id) public Optional <T> findValue <T>(MarketDataId <T> id) { return(id.Equals(ID1) ? ((T)VAL1) : null); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public <T> T getValue(com.opengamma.strata.data.MarketDataId<T> id) public override T getValue <T>(MarketDataId <T> id) { return(underlying.getValue(id).SingleValue); }
public bool matches(MarketDataId <T> marketDataId, MarketDataBox <T> marketData, ReferenceData refData) { return(true); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance that decorates the underlying market data. /// <para> /// The specified identifier can be queried in the result, returning the specified value. /// All other identifiers are queried in the underlying market data. /// /// </para> /// </summary> /// <param name="id"> the additional market data identifier </param> /// <param name="value"> the additional market data value </param> /// <param name="underlying"> the underlying market data </param> /// <returns> a market data instance that decorates the original adding/overriding the specified identifier </returns> public static ExtendedScenarioMarketData <T> of <T>(MarketDataId <T> id, MarketDataBox <T> value, ScenarioMarketData underlying) { return(new ExtendedScenarioMarketData <T>(id, value, underlying)); }
//------------------------------------------------------------------------- public override bool containsValue <T1>(MarketDataId <T1> id) { // overridden for performance return(values.containsKey(id)); }
public bool matches(MarketDataId <T> marketDataId, MarketDataBox <T> marketData, ReferenceData refData) { return(marketDataId.Equals(id)); }
/// <summary> /// Creates an instance. </summary> /// <param name="id"> the value of the property, not null </param> internal IdFilter(MarketDataId <T> id) { JodaBeanUtils.notNull(id, "id"); this.id = id; }
public Optional <T> findValue <T>(MarketDataId <T> id) { return(underlying.findValue(id).map(v => v.SingleValue)); }
//------------------------------------------------------------------------- public T data <T>(MarketDataId <T> key) { throw new System.NotSupportedException(); }
// extracted to aid inlining performance private string msgValueNotFound <T1>(MarketDataId <T1> id) { return(Messages.format("Market data not found for identifier '{}' of type '{}'", id, id.GetType().Name)); }