public void CanGetAllKindsOfValues(ViewDefinition defn) { WithViewCycle( delegate(ViewDefinitionCompiledArgs compiled, IViewCycle cycle, RemoteViewClient client) { var compiledViewDefinition = cycle.GetCompiledViewDefinition(); foreach (var kvp in compiledViewDefinition.ViewDefinition.CalculationConfigurationsByName) { var viewCalculationConfiguration = kvp.Key; var dependencyGraphExplorer = compiledViewDefinition.GetDependencyGraphExplorer(viewCalculationConfiguration); Assert.NotNull(dependencyGraphExplorer); var wholeGraph = dependencyGraphExplorer.GetWholeGraph(); var distinctKindsOfSpec = wholeGraph.DependencyNodes.SelectMany(n => n.OutputValues) .ToLookup(s => s.ValueName).Select(g => g.First()); var specs = new HashSet <ValueSpecification>(distinctKindsOfSpec); if (!specs.Any()) { continue; } var computationCacheResponse = cycle.QueryComputationCaches(new ComputationCacheQuery(viewCalculationConfiguration, specs)); Assert.InRange(computationCacheResponse.Results.Count, 0, specs.Count()); foreach (var result in computationCacheResponse.Results) { Assert.Contains(result.First, specs); Assert.NotNull(result.Second); ValueAssertions.AssertSensibleValue(result.Second); } } }, defn.Name); }
public void ViewResultsHaveSaneValues(ViewDefinition definition) { var viewComputationResultModel = GetOneResultCache.Get(definition.UniqueID); foreach (var viewResultEntry in viewComputationResultModel.AllResults) { ValueAssertions.AssertSensibleValue(viewResultEntry.ComputedValue.Value); } }
private static void AssertSaneValue(ManageableYieldCurveSnapshot yieldCurveSnapshot) { Assert.NotNull(yieldCurveSnapshot); Assert.InRange(yieldCurveSnapshot.Values.Values.Count(), 2, 200); foreach (var valueSnapshot in yieldCurveSnapshot.Values) { foreach (var snapshot in valueSnapshot.Value) { ValueAssertions.AssertSensibleValue(snapshot.Value.MarketValue); Assert.Null(snapshot.Value.OverrideValue); } } }
public void CanGetDefinition() { using (var remoteViewClient = Context.ViewProcessor.CreateClient()) { var options = ExecutionOptions.RealTime; remoteViewClient.AttachToViewProcess("Equity Option Test View 1", options); for (int i = 0; i < 30; i++) { var viewDefinition = remoteViewClient.GetViewDefinition(); if (viewDefinition != null) { ValueAssertions.AssertSensibleValue(viewDefinition); return; } Thread.Sleep(TimeSpan.FromSeconds(1)); } Assert.True(false, "Failed to get view definition"); } }
public void CanCreateFromView(ViewDefinition viewDefinition) { var snapshotManager = Context.MarketDataSnapshotManager; using (var proc = snapshotManager.CreateFromViewDefinition(viewDefinition)) { var manageableMarketDataSnapshot = proc.Snapshot; Assert.Null(manageableMarketDataSnapshot.Name); Assert.Null(manageableMarketDataSnapshot.UniqueId); Assert.True(manageableMarketDataSnapshot.Values.Any() || manageableMarketDataSnapshot.YieldCurves.Any(c => c.Value.Values.Values.Any()) || manageableMarketDataSnapshot.VolatilityCubes.Any(v => v.Value.Values.Any())); foreach (var valueSnapshot in manageableMarketDataSnapshot.Values) { foreach (var snapshot in valueSnapshot.Value) { ValueAssertions.AssertSensibleValue(snapshot.Value.MarketValue); Assert.Null(snapshot.Value.OverrideValue); } } if (viewDefinition.Name != "GlobeOp Bond View Implied" /* LAP-38 */ && viewDefinition.Name != "Simple Cash Test View 2" /* LAP-82 */) { Assert.InRange(manageableMarketDataSnapshot.YieldCurves.Count, ExpectedYieldCurves(viewDefinition), int.MaxValue); } if (viewDefinition.Name == "Equity Option Test View 1") { Assert.Equal(2, manageableMarketDataSnapshot.YieldCurves.Count); var yieldCurveSnapshot = manageableMarketDataSnapshot.YieldCurves.First(); Assert.NotNull(yieldCurveSnapshot); Assert.NotEmpty(yieldCurveSnapshot.Value.Values.Values); } foreach (var curve in manageableMarketDataSnapshot.YieldCurves.Values) { AssertSaneValue(curve); Assert.True(curve.Values.Values.Keys.Any(s => !manageableMarketDataSnapshot.GlobalValues.Values.ContainsKey(s))); //LAP-37 } foreach (var cube in manageableMarketDataSnapshot.VolatilityCubes.Values) { Assert.True(cube.Values.Any(v => v.Value.MarketValue == null)); } } }
private static HashSet <Tuple <string, ValueSpecification> > GetAllSpecs(IViewCycle cycle) { var specSet = new HashSet <Tuple <string, ValueSpecification> >(); var compiledViewDefinition = cycle.GetCompiledViewDefinition(); foreach (var kvp in compiledViewDefinition.ViewDefinition.CalculationConfigurationsByName) { var viewCalculationConfiguration = kvp.Key; var dependencyGraphExplorer = compiledViewDefinition.GetDependencyGraphExplorer(viewCalculationConfiguration); Assert.NotNull(dependencyGraphExplorer); var wholeGraph = dependencyGraphExplorer.GetWholeGraph(); IEnumerable <ValueSpecification> allSpecs = wholeGraph.DependencyNodes.SelectMany(n => n.OutputValues); var distinctKindsOfSpec = allSpecs .ToLookup(s => s.ValueName).Select(g => g.First()); var specs = new HashSet <ValueSpecification>(distinctKindsOfSpec); if (!specs.Any()) { continue; } var computationCacheResponse = cycle.QueryComputationCaches(new ComputationCacheQuery(viewCalculationConfiguration, specs)); Assert.InRange(computationCacheResponse.Results.Count, 0, specs.Count()); foreach (var result in computationCacheResponse.Results) { Assert.Contains(result.First, specs); Assert.NotNull(result.Second); ValueAssertions.AssertSensibleValue(result.Second); } var newSpecs = computationCacheResponse.Results.Select(p => Tuple.Create(viewCalculationConfiguration, p.First)); foreach (var newSpec in newSpecs) { Assert.True(specSet.Add(newSpec)); } } return(specSet); }
public void CanGetVersionCorrection(string versionAsOf, string correctedTo) { VersionCorrection vc = versionAsOf == null ? VersionCorrection.Latest : new VersionCorrection(DateTimeOffset.Parse(versionAsOf), DateTimeOffset.Parse(correctedTo)); using (var remoteViewClient = Context.ViewProcessor.CreateClient()) { var options = new ExecutionOptions(new InfiniteViewCycleExecutionSequence(), ViewExecutionFlags.CompileOnly, versionCorrection: vc); remoteViewClient.AttachToViewProcess("Equity Option Test View 1", options); for (int i = 0; i < 30; i++) { var viewDefinition = remoteViewClient.GetViewDefinition(); if (viewDefinition != null) { ValueAssertions.AssertSensibleValue(viewDefinition); var roundTripped = remoteViewClient.GetProcessVersionCorrection(); Assert.Equal(vc, roundTripped); return; } Thread.Sleep(TimeSpan.FromSeconds(1)); } Assert.True(false, "Failed to get view definition"); } }
public void CanGetCompilationResults(ViewDefinition definition) { using (var remoteViewClient = Context.ViewProcessor.CreateClient()) { var compilationResult = new BlockingCollection <object>(); var eventViewResultListener = new EventViewResultListener(); eventViewResultListener.ViewDefinitionCompiled += (sender, e) => compilationResult.Add(e.CompiledViewDefinition); eventViewResultListener.ViewDefinitionCompilationFailed += (sender, e) => compilationResult.Add(e.Exception); remoteViewClient.SetResultListener(eventViewResultListener); remoteViewClient.AttachToViewProcess(definition.UniqueID, ExecutionOptions.GetCompileOnly()); var result = compilationResult.Take(); Assert.IsNotType(typeof(Exception), result); Debug.WriteLine(definition.UniqueID); Assert.IsAssignableFrom(typeof(ICompiledViewDefinition), result); var viewDefin = (ICompiledViewDefinition)result; ValueAssertions.AssertSensibleValue(viewDefin); } }
public void CanUpdateFromView() { var snapshotManager = Context.MarketDataSnapshotManager; using (var proc = snapshotManager.CreateFromViewDefinition(RemoteViewClientBatchTests.ViewName)) { var updated = proc.Snapshot; var beforeCount = updated.Values.Count; var targetChanged = updated.Values.Keys.First(); var valueChanged = updated.Values[targetChanged].Keys.First(); updated.Values[targetChanged][valueChanged].OverrideValue = 12; long updatesSeen = 0; long yieldCurveUpdatesSeen = 0; foreach (var value in updated.GlobalValues.Values.SelectMany(v => v.Value.Values)) { value.PropertyChanged += delegate { Interlocked.Increment(ref updatesSeen); }; } foreach (var value in updated.YieldCurves.Values.SelectMany(v => v.Values.Values.SelectMany(vv => vv.Value.Select(vvv => vvv.Value)))) { value.PropertyChanged += delegate { Interlocked.Increment(ref yieldCurveUpdatesSeen); }; } for (int i = 0; i < 10; i++) { Thread.Sleep(TimeSpan.FromSeconds(3)); var action = proc.PrepareUpdate(); Assert.Empty(action.Warnings); Assert.Equal(0, Interlocked.Read(ref updatesSeen)); Assert.Equal(0, Interlocked.Read(ref yieldCurveUpdatesSeen)); action.Execute(updated); if (Interlocked.Read(ref updatesSeen) + Interlocked.Read(ref yieldCurveUpdatesSeen) > 0) { break; } } var afterCount = updated.Values.Count; Assert.Equal(beforeCount, afterCount); Console.Out.WriteLine(Interlocked.Read(ref updatesSeen) + " - " + Interlocked.Read(ref yieldCurveUpdatesSeen)); Assert.NotEqual(0, Interlocked.Read(ref updatesSeen) + Interlocked.Read(ref yieldCurveUpdatesSeen)); Assert.Null(updated.Name); Assert.Null(updated.UniqueId); Assert.NotEmpty(updated.Values); foreach (var valueSnapshot in updated.Values) { foreach (var snapshot in valueSnapshot.Value) { ValueAssertions.AssertSensibleValue(snapshot.Value.MarketValue); if (targetChanged == valueSnapshot.Key && valueChanged == snapshot.Key) { Assert.Equal(12, snapshot.Value.OverrideValue); } else { Assert.Null(snapshot.Value.OverrideValue); } } } } }
public void CanGetDefaultDefn(string cubeName) { var defn = Context.VolatilityCubeDefinitionSource.GetDefinition(Currency.USD, cubeName); ValueAssertions.AssertSensibleValue(defn); }