public void CanRemoveAllOverrides() { var manageableUnstructuredMarketDataSnapshot = new ManageableUnstructuredMarketDataSnapshot(new Dictionary<MarketDataValueSpecification, IDictionary<string, ValueSnapshot>>()); var manageableVolatilitySurfaceSnapshots = GetManageableVolatilitySurfaceSnapshots(); var manageableYieldCurveSnapshots = GetManageableYieldCurveSnapshots(); var manageableVolatilityCubeSnapshots = GetManageableVolatilityCubeSnapshots(); var manageableMarketDataSnapshot = new ManageableMarketDataSnapshot("SomeView", manageableUnstructuredMarketDataSnapshot, manageableYieldCurveSnapshots, manageableVolatilityCubeSnapshots, manageableVolatilitySurfaceSnapshots); var valueSpec = new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("ID", "1")); const string valueName = "Value"; manageableMarketDataSnapshot.Values.Add(valueSpec, new Dictionary<string, ValueSnapshot> {{valueName, new ValueSnapshot(12){OverrideValue = 13}}}); Assert.True(manageableMarketDataSnapshot.HaveOverrides()); Assert.True(manageableMarketDataSnapshot.YieldCurves.Single().Value.HaveOverrides()); Assert.True(manageableMarketDataSnapshot.VolatilityCubes.Single().Value.HaveOverrides()); Assert.True(manageableMarketDataSnapshot.VolatilitySurfaces.Single().Value.HaveOverrides()); manageableMarketDataSnapshot.RemoveAllOverrides(); var valueSnapshot = manageableMarketDataSnapshot.Values[valueSpec][valueName]; CheckOverrideCleared(valueSnapshot); CheckOverrideCleared(manageableMarketDataSnapshot.YieldCurves.Values.Single().Values.Values.Single().Value.Single().Value); CheckOverrideCleared(manageableMarketDataSnapshot.VolatilityCubes.Values.Single().OtherValues.Values.Single().Value.Values.Single()); CheckOverrideCleared(manageableMarketDataSnapshot.VolatilitySurfaces.Values.Single().Values.Values.Single()); Assert.Equal(1, manageableMarketDataSnapshot.Values.Count); Assert.False(manageableMarketDataSnapshot.HaveOverrides()); Assert.False(manageableMarketDataSnapshot.YieldCurves.Single().Value.HaveOverrides()); Assert.False(manageableMarketDataSnapshot.VolatilityCubes.Single().Value.HaveOverrides()); Assert.False(manageableMarketDataSnapshot.VolatilitySurfaces.Single().Value.HaveOverrides()); }
public void VersionedSecuritiesUpdateCorrectlyBasic() //LAP-30 { var before = new ManageableUnstructuredMarketDataSnapshot( new Dictionary <MarketDataValueSpecification, IDictionary <string, ValueSnapshot> >()); var update = new ManageableUnstructuredMarketDataSnapshot( new Dictionary <MarketDataValueSpecification, IDictionary <string, ValueSnapshot> >()); before.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("A", "A", "1")), new Dictionary <string, ValueSnapshot> { { "A", new ValueSnapshot(null) } }); update.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("A", "A", "2")), new Dictionary <string, ValueSnapshot> { { "A", new ValueSnapshot(null) } }); UpdateAction <ManageableUnstructuredMarketDataSnapshot> prepareUpdateFrom = before.PrepareUpdateFrom(update); Assert.Equal(0, prepareUpdateFrom.Warnings.Count()); prepareUpdateFrom.Execute(before); List <UniqueId> updatedIds = before.Values.Keys.Select(m => m.UniqueId).OrderBy(u => u).ToList(); List <UniqueId> expected = new[] { UniqueId.Create("A", "A", "2"), }.OrderBy(u => u).ToList(); Assert.Equal(expected.Count, updatedIds.Count); for (int i = 0; i < expected.Count; i++) { Assert.Equal(expected[i], updatedIds[i]); } }
public void CanSubtract() { var manageableUnstructuredMarketDataSnapshot = new ManageableUnstructuredMarketDataSnapshot(new Dictionary<MarketDataValueSpecification, IDictionary<string, ValueSnapshot>>()); var manageableVolatilitySurfaceSnapshots = GetManageableVolatilitySurfaceSnapshots(); var manageableYieldCurveSnapshots = GetManageableYieldCurveSnapshots(); var manageableVolatilityCubeSnapshots = GetManageableVolatilityCubeSnapshots(); var manageableMarketDataSnapshot = new ManageableMarketDataSnapshot("SomeView", manageableUnstructuredMarketDataSnapshot, manageableYieldCurveSnapshots, manageableVolatilityCubeSnapshots, manageableVolatilitySurfaceSnapshots); var marketDataSnapshot = manageableMarketDataSnapshot.Substract(manageableMarketDataSnapshot); var valueSnapshot = marketDataSnapshot.YieldCurves.Values.Single().Values.Values.Single().Value.Single().Value; Assert.Equal(0.0, valueSnapshot.MarketValue); Assert.Equal(0.0, valueSnapshot.OverrideValue); //TODO the rest }
public void CanSubtract() { var manageableUnstructuredMarketDataSnapshot = new ManageableUnstructuredMarketDataSnapshot(new Dictionary <MarketDataValueSpecification, IDictionary <string, ValueSnapshot> >()); var manageableVolatilitySurfaceSnapshots = GetManageableVolatilitySurfaceSnapshots(); var manageableYieldCurveSnapshots = GetManageableYieldCurveSnapshots(); var manageableVolatilityCubeSnapshots = GetManageableVolatilityCubeSnapshots(); var manageableMarketDataSnapshot = new ManageableMarketDataSnapshot("SomeView", manageableUnstructuredMarketDataSnapshot, manageableYieldCurveSnapshots, manageableVolatilityCubeSnapshots, manageableVolatilitySurfaceSnapshots); var marketDataSnapshot = manageableMarketDataSnapshot.Substract(manageableMarketDataSnapshot); var valueSnapshot = marketDataSnapshot.YieldCurves.Values.Single().Values.Values.Single().Value.Single().Value; Assert.Equal(0.0, valueSnapshot.MarketValue); Assert.Equal(0.0, valueSnapshot.OverrideValue); //TODO the rest }
public void VersionedSecuritiesUpdateCorrectly() { var before = new ManageableUnstructuredMarketDataSnapshot( new Dictionary<MarketDataValueSpecification, IDictionary<string, ValueSnapshot>>()); var update = new ManageableUnstructuredMarketDataSnapshot( new Dictionary<MarketDataValueSpecification, IDictionary<string, ValueSnapshot>>()); before.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("A", "A", "1")), new Dictionary<string, ValueSnapshot>{{"A", new ValueSnapshot(null)}}); update.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("A", "A", "2")), new Dictionary<string, ValueSnapshot> { { "A", new ValueSnapshot(null) } }); before.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("B", "B", "1")), new Dictionary<string, ValueSnapshot> { { "B", new ValueSnapshot(null) } }); update.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("B", "B", "1")), new Dictionary<string, ValueSnapshot> { { "B", new ValueSnapshot(null) } }); before.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("B", "B", "2")), new Dictionary<string, ValueSnapshot> { { "B", new ValueSnapshot(null) } }); update.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("B", "B", "2")), new Dictionary<string, ValueSnapshot> { { "B", new ValueSnapshot(null) } }); before.Values.Add(new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("C", "C", "1")), new Dictionary<string, ValueSnapshot> { { "C", new ValueSnapshot(null) { OverrideValue = 12 } } }); UpdateAction<ManageableUnstructuredMarketDataSnapshot> prepareUpdateFrom = before.PrepareUpdateFrom(update); Assert.Equal(1, prepareUpdateFrom.Warnings.Count()); prepareUpdateFrom.Execute(before); List<UniqueId> updatedIds = before.Values.Keys.Select(m => m.UniqueId).OrderBy(u => u).ToList(); List<UniqueId> expected = new[] { UniqueId.Create("A", "A", "2"), UniqueId.Create("B", "B", "1"), UniqueId.Create("B", "B", "2"), }.OrderBy(u => u).ToList(); Assert.Equal(expected.Count, updatedIds.Count); for (int i = 0; i < expected.Count; i++) { Assert.Equal(expected[i], updatedIds[i]); } }
public void CanRemoveAllOverrides() { var manageableUnstructuredMarketDataSnapshot = new ManageableUnstructuredMarketDataSnapshot(new Dictionary <MarketDataValueSpecification, IDictionary <string, ValueSnapshot> >()); var manageableVolatilitySurfaceSnapshots = GetManageableVolatilitySurfaceSnapshots(); var manageableYieldCurveSnapshots = GetManageableYieldCurveSnapshots(); var manageableVolatilityCubeSnapshots = GetManageableVolatilityCubeSnapshots(); var manageableMarketDataSnapshot = new ManageableMarketDataSnapshot("SomeView", manageableUnstructuredMarketDataSnapshot, manageableYieldCurveSnapshots, manageableVolatilityCubeSnapshots, manageableVolatilitySurfaceSnapshots); var valueSpec = new MarketDataValueSpecification(MarketDataValueType.Primitive, UniqueId.Create("ID", "1")); const string valueName = "Value"; manageableMarketDataSnapshot.Values.Add(valueSpec, new Dictionary <string, ValueSnapshot> { { valueName, new ValueSnapshot(12) { OverrideValue = 13 } } }); Assert.True(manageableMarketDataSnapshot.HaveOverrides()); Assert.True(manageableMarketDataSnapshot.YieldCurves.Single().Value.HaveOverrides()); Assert.True(manageableMarketDataSnapshot.VolatilityCubes.Single().Value.HaveOverrides()); Assert.True(manageableMarketDataSnapshot.VolatilitySurfaces.Single().Value.HaveOverrides()); manageableMarketDataSnapshot.RemoveAllOverrides(); var valueSnapshot = manageableMarketDataSnapshot.Values[valueSpec][valueName]; CheckOverrideCleared(valueSnapshot); CheckOverrideCleared(manageableMarketDataSnapshot.YieldCurves.Values.Single().Values.Values.Single().Value.Single().Value); CheckOverrideCleared(manageableMarketDataSnapshot.VolatilityCubes.Values.Single().OtherValues.Values.Single().Value.Values.Single()); CheckOverrideCleared(manageableMarketDataSnapshot.VolatilitySurfaces.Values.Single().Values.Values.Single()); Assert.Equal(1, manageableMarketDataSnapshot.Values.Count); Assert.False(manageableMarketDataSnapshot.HaveOverrides()); Assert.False(manageableMarketDataSnapshot.YieldCurves.Single().Value.HaveOverrides()); Assert.False(manageableMarketDataSnapshot.VolatilityCubes.Single().Value.HaveOverrides()); Assert.False(manageableMarketDataSnapshot.VolatilitySurfaces.Single().Value.HaveOverrides()); }
private static void AssertEqual(ManageableUnstructuredMarketDataSnapshot a, ManageableUnstructuredMarketDataSnapshot b) { AssertEqual(a.Values, b.Values, AssertEqual); }
private static Dictionary <YieldCurveKey, ManageableYieldCurveSnapshot> GetYieldCurves(ManageableUnstructuredMarketDataSnapshot manageableUnstructuredMarketDataSnapshot) { return(new Dictionary <YieldCurveKey, ManageableYieldCurveSnapshot> { { new YieldCurveKey(Currency.USD, "Default"), new ManageableYieldCurveSnapshot(manageableUnstructuredMarketDataSnapshot, DateTimeOffset.Now) } }); }