private static double GetValue(ValueRequirement req) { if (req.TargetSpecification.Type != ComputationTargetType.Primitive) throw new NotImplementedException(); using (var remoteClient = Context.CreateFinancialClient()) { var viewDefinition = new ViewDefinition(TestUtils.GetUniqueName()); var viewCalculationConfiguration = new ViewCalculationConfiguration("Default", new List<ValueRequirement> { req }, new Dictionary<string, HashSet<Tuple<string, ValueProperties>>>()); viewDefinition.CalculationConfigurationsByName.Add("Default", viewCalculationConfiguration); var uid = remoteClient.ViewDefinitionRepository.AddViewDefinition(new AddViewDefinitionRequest(viewDefinition)); viewDefinition.UniqueID = uid; try { using (var viewClient = Context.ViewProcessor.CreateClient()) { var viewComputationResultModel = viewClient.GetResults(viewDefinition.UniqueID, ExecutionOptions.SingleCycle).First(); return (double)viewComputationResultModel["Default", req].Value; } } finally { remoteClient.ViewDefinitionRepository.RemoveViewDefinition(viewDefinition.Name); } } }
public ComputedValue this[string calculationConfiguration, ValueRequirement valueRequirement] { get { ComputedValue ret; if (!TryGetComputedValue(calculationConfiguration, valueRequirement, out ret)) { throw new KeyNotFoundException(); } return ret; } }
public ViewDefinition CreateViewDefinition(RemoteEngineContext context, ValueRequirement valueRequirement) { var viewDefinition = new ViewDefinition(TestUtils.GetUniqueName()); viewDefinition.CalculationConfigurationsByName.Add("Default", new ViewCalculationConfiguration("Default", new List<ValueRequirement> { valueRequirement }, new Dictionary<string, HashSet<Tuple<string, ValueProperties>>>())); using (var remoteClient = context.CreateFinancialClient()) { var uid = remoteClient.ViewDefinitionRepository.AddViewDefinition(new AddViewDefinitionRequest(viewDefinition)); viewDefinition.UniqueID = uid; } _createdViews.Enqueue(Tuple.Create(context, viewDefinition.Name)); return viewDefinition; }
public bool TryGetComputedValue(string calculationConfiguration, ValueRequirement valueRequirement, out ComputedValue result) { result = null; ViewCalculationResultModel model; if (!_configurationMap.TryGetValue(calculationConfiguration, out model)) { return false; } ISet<ComputedValue> values; if (!model.TryGetAllValues(valueRequirement.TargetSpecification, out values)) { return false; } var computedValues = values.Where(v => valueRequirement.IsSatisfiedBy(v.Specification)); result = computedValues.FirstOrDefault(); return result != null; }
public void RemoveChangesResults() { var valueRequirement = new ValueRequirement("Market_Value", new ComputationTargetSpecification(ComputationTargetType.Primitive, BloombergUid)); var defn = GetViewDefinition(); using (var remoteClient = Context.ViewProcessor.CreateClient()) { var liveDataOverrideInjector = remoteClient.LiveDataOverrideInjector; const double newValue = 1234.5678; ManualResetEvent mre = new ManualResetEvent(false); IViewComputationResultModel results = null; var listener = new EventViewResultListener(); listener.CycleCompleted += delegate(object sender, CycleCompletedArgs e) { results = e.FullResult; mre.Set(); }; remoteClient.SetResultListener(listener); remoteClient.AttachToViewProcess(defn.UniqueID, ExecutionOptions.RealTime); liveDataOverrideInjector.AddValue(valueRequirement, newValue); liveDataOverrideInjector.RemoveValue(valueRequirement); mre.WaitOne(); mre.Reset(); var result = results.AllResults.Where(r => valueRequirement.IsSatisfiedBy(r.ComputedValue.Specification)).First(); Assert.NotEqual(newValue, (double)result.ComputedValue.Value); } }
public void RemoveValue(ValueRequirement valueRequirement) { ArgumentChecker.NotNull(valueRequirement, "valueRequirement"); RemoveValue(new RemoveValueRequest { ValueRequirement = valueRequirement }); }
public void AddValue(ValueRequirement valueRequirement, object value) { ArgumentChecker.NotNull(valueRequirement, "valueRequirement"); var addValueRequest = new AddValueRequest { Value = value, ValueRequirement = valueRequirement }; AddValue(addValueRequest); }