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 SnapshotLiveDataStreamInvalidater(ManageableMarketDataSnapshot snapshot, RemoteEngineContext remoteEngineContext) { _snapshot = snapshot; _remoteEngineContext = remoteEngineContext; snapshot.PropertyChanged += PropertyChanged; //TODO: weak ref _constructedEvent.Set(); }
private static Tuple <ManageableMarketDataSnapshot, ManageableMarketDataSnapshot> Halve(ManageableMarketDataSnapshot snapshot) { var structured = new ManageableMarketDataSnapshot(snapshot.BasisViewName, new ManageableUnstructuredMarketDataSnapshot(new Dictionary <MarketDataValueSpecification, IDictionary <string, ValueSnapshot> >()), snapshot.YieldCurves, snapshot.VolatilityCubes, snapshot.VolatilitySurfaces); var unstructured = new ManageableMarketDataSnapshot(snapshot.BasisViewName, snapshot.GlobalValues, new Dictionary <YieldCurveKey, ManageableYieldCurveSnapshot>(), new Dictionary <VolatilityCubeKey, ManageableVolatilityCubeSnapshot>(), new Dictionary <VolatilitySurfaceKey, ManageableVolatilitySurfaceSnapshot>()); return(Tuple.Create(structured, unstructured)); }
internal static MarketDataSnapshotProcessor Create(RemoteEngineContext context, ViewDefinition definition, CancellationToken ct) { using (var liveDataStream = new LiveDataStream(definition.Name, context)) { ManageableMarketDataSnapshot snapshot = liveDataStream.GetNewSnapshotForUpdate(ct); //NOTE: we could consider reusing the LiveDataStream, but server side will share the processer return(new MarketDataSnapshotProcessor(context, snapshot)); } }
private MarketDataSnapshotProcessor(ManageableMarketDataSnapshot snapshot, RemoteEngineContext remoteEngineContext, SnapshotLiveDataStreamInvalidater liveDataStream) { _snapshot = snapshot; _financialClient = remoteEngineContext.CreateFinancialClient(); _marketDataSnapshotMaster = _financialClient.MarketDataSnapshotMaster; _liveDataStream = liveDataStream; _temporarySnapshotUid = new Lazy<UniqueId>(() => _marketDataSnapshotMaster.Add(new MarketDataSnapshotDocument(null, GetShallowCloneSnapshot())).UniqueId); _snapshotDataStream = new Lazy<SnapshotDataStreamInvalidater>(() => new SnapshotDataStreamInvalidater(_liveDataStream, remoteEngineContext, _temporarySnapshotUid.Value)); }
private MarketDataSnapshotProcessor(ManageableMarketDataSnapshot snapshot, RemoteEngineContext remoteEngineContext, SnapshotLiveDataStreamInvalidater liveDataStream) { _snapshot = snapshot; _financialClient = remoteEngineContext.CreateFinancialClient(); _marketDataSnapshotMaster = _financialClient.MarketDataSnapshotMaster; _liveDataStream = liveDataStream; _temporarySnapshotUid = new Lazy <UniqueId>(() => _marketDataSnapshotMaster.Add(new MarketDataSnapshotDocument(null, GetShallowCloneSnapshot())).UniqueId); _snapshotDataStream = new Lazy <SnapshotDataStreamInvalidater>(() => new SnapshotDataStreamInvalidater(_liveDataStream, remoteEngineContext, _temporarySnapshotUid.Value)); }
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 }
private static void AssertEqual(ManageableMarketDataSnapshot retSnapshot, ManageableMarketDataSnapshot mSnapshot) { Assert.NotNull(retSnapshot); Assert.Equal(mSnapshot.Name, retSnapshot.Name); Assert.NotNull(retSnapshot.Values); Assert.Equal(mSnapshot.BasisViewName, retSnapshot.BasisViewName); AssertEqual(mSnapshot.GlobalValues, retSnapshot.GlobalValues); AssertEqual(mSnapshot.YieldCurves, retSnapshot.YieldCurves, AssertEqual); AssertEqual(mSnapshot.VolatilityCubes, retSnapshot.VolatilityCubes, AssertEqual); // TODO volatility surfaces etc. }
public Dictionary <YieldCurveKey, Tuple <YieldCurve, InterpolatedYieldCurveSpecificationWithSecurities, NodalDoublesCurve> > GetYieldCurves(CancellationToken ct = default(CancellationToken)) { CheckDisposed(); DateTimeOffset waitFor; ManageableMarketDataSnapshot shallowClone = GetShallowCloneSnapshot(); lock (_snapshotUidLock) { shallowClone.UniqueId = _temporarySnapshotUid.Value; var snapshot = _marketDataSnapshotMaster.Update(new MarketDataSnapshotDocument(_temporarySnapshotUid.Value, shallowClone)); _temporarySnapshotUid = new Lazy <UniqueId>(() => snapshot.UniqueId); waitFor = _marketDataSnapshotMaster.Get(_temporarySnapshotUid.Value).CorrectionFromInstant; } return(_snapshotDataStream.Value.With(ct, s => s.GetYieldCurves(waitFor, ct))); }
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()); }
internal MarketDataSnapshotProcessor(RemoteEngineContext remoteEngineContext, ManageableMarketDataSnapshot snapshot) : this(snapshot, remoteEngineContext, new SnapshotLiveDataStreamInvalidater(snapshot, remoteEngineContext)) { }
private MarketDataSnapshotDocument(UniqueId uniqueId, ManageableMarketDataSnapshot snapshot, DateTimeOffset versionFromInstant, DateTimeOffset versionToInstant, DateTimeOffset correctionFromInstant, DateTimeOffset correctionToInstant) : base(versionFromInstant, versionToInstant, correctionFromInstant, correctionToInstant) { _uniqueId = uniqueId; _snapshot = snapshot; }
public MarketDataSnapshotDocument(UniqueId uniqueId, ManageableMarketDataSnapshot snapshot) { _uniqueId = uniqueId; _snapshot = snapshot; }
public MarketDataSnapshotProcessor GetProcessor(ManageableMarketDataSnapshot snapshot) { return new MarketDataSnapshotProcessor(_remoteEngineContext, snapshot); }
public MarketDataSnapshotProcessor GetProcessor(ManageableMarketDataSnapshot snapshot) { return(new MarketDataSnapshotProcessor(_remoteEngineContext, snapshot)); }
private static Tuple<ManageableMarketDataSnapshot, ManageableMarketDataSnapshot> Halve(ManageableMarketDataSnapshot snapshot) { var structured = new ManageableMarketDataSnapshot(snapshot.BasisViewName, new ManageableUnstructuredMarketDataSnapshot(new Dictionary<MarketDataValueSpecification, IDictionary<string, ValueSnapshot>>()), snapshot.YieldCurves, snapshot.VolatilityCubes, snapshot.VolatilitySurfaces); var unstructured = new ManageableMarketDataSnapshot(snapshot.BasisViewName, snapshot.GlobalValues, new Dictionary<YieldCurveKey, ManageableYieldCurveSnapshot>(), new Dictionary<VolatilityCubeKey, ManageableVolatilityCubeSnapshot>(), new Dictionary<VolatilitySurfaceKey, ManageableVolatilitySurfaceSnapshot>()); return Tuple.Create(structured, unstructured); }