From 1a254d7f0f9f82a05c147b13fee7a14b23ce4293 Mon Sep 17 00:00:00 2001 From: Aliaksandr Vashetsin Date: Fri, 9 Feb 2024 14:09:13 +0300 Subject: [PATCH 1/7] LT-4926: Potential corrupted snapshot --- .../Repositories/IOrdersHistoryRepository.cs | 2 +- .../Infrastructure/SnapshotValidationService.cs | 5 ++++- .../Repositories/OrdersHistoryRepository.cs | 6 +++--- .../Infrastructure/SnapshotValidationServiceTests.cs | 2 +- tests/MarginTradingTests/Modules/MockRepositoriesModule.cs | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs b/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs index 500154f82..326ddaa61 100644 --- a/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs +++ b/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs @@ -10,6 +10,6 @@ namespace MarginTrading.Backend.Core.Repositories { public interface IOrdersHistoryRepository { - Task> GetLastSnapshot(DateTime @from); + Task> GetLastSnapshot(DateTime @from, DateTime? @to = null); } } diff --git a/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs b/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs index cfb4253d5..d5f480b83 100644 --- a/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs +++ b/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs @@ -62,7 +62,10 @@ await _log.WriteInfoAsync(nameof(SnapshotValidationService), nameof(ValidateCurr var lastOrders = GetOrders(tradingEngineSnapshot); var lastPositions = GetPositions(tradingEngineSnapshot); - var ordersHistory = await _ordersHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp); + var latestLastModified = currentOrders.Any() + ? currentOrders.Max(x => x.LastModified) + : (DateTime?)null; + var ordersHistory = await _ordersHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp, latestLastModified); var positionsHistory = await _positionsHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp); var restoredOrders = RestoreOrdersCurrentStateFromHistory(lastOrders, ordersHistory); diff --git a/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs b/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs index 4977b17cd..b23e82f38 100644 --- a/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs +++ b/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs @@ -34,7 +34,7 @@ CASE [Status] ELSE 99 END as StatusOrder FROM [{0}] oh (NOLOCK) - WHERE oh.ModifiedTimestamp > @Timestamp + WHERE oh.ModifiedTimestamp > @From AND (@To IS NULL OR oh.ModifiedTimestamp <= @To) ), filteredOrderHistWithRowNumber AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY Id ORDER BY @@ -54,11 +54,11 @@ public OrdersHistoryRepository(string connectionString, string tableName, int ge _getLastSnapshotTimeoutS = getLastSnapshotTimeoutS; } - public async Task> GetLastSnapshot(DateTime @from) + public async Task> GetLastSnapshot(DateTime @from, DateTime? @to = null) { using (var conn = new SqlConnection(_connectionString)) { - var data = await conn.QueryAsync(_select, new { Timestamp = @from }, commandTimeout: _getLastSnapshotTimeoutS); + var data = await conn.QueryAsync(_select, new { From = @from, To = @to }, commandTimeout: _getLastSnapshotTimeoutS); return data.Cast().ToList(); } diff --git a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs index 33dccad2e..f389aad46 100644 --- a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs +++ b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs @@ -62,7 +62,7 @@ public void SetUp() _orderCacheMock.Setup(o => o.GetPositions()) .Returns(() => _currentPositions.ToImmutableArray()); - _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) + _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny(), It.IsAny())) .ReturnsAsync((DateTime date) => _ordersHistory); _positionsHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) diff --git a/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs b/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs index 9cfd403a4..22fd9eede 100644 --- a/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs +++ b/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs @@ -29,7 +29,7 @@ protected override void Load(ContainerBuilder builder) blobRepository.Setup(s => s.ReadWithTimestampAsync>(It.IsAny(), It.IsAny())) .ReturnsAsync((new List(), DateTime.UtcNow)); var orderHistoryRepository = new Mock(); - orderHistoryRepository.Setup(s => s.GetLastSnapshot(It.IsAny())) + orderHistoryRepository.Setup(s => s.GetLastSnapshot(It.IsAny(), It.IsAny())) .ReturnsAsync(new List()); var positionHistoryRepository = new Mock(); var accountHistoryRepository = new Mock(); From 88d3f894c001b8a2a651d1f7099a181ce73fae44 Mon Sep 17 00:00:00 2001 From: Aliaksandr Vashetsin Date: Fri, 9 Feb 2024 14:20:52 +0300 Subject: [PATCH 2/7] LT-4926: fix unit test --- .../Infrastructure/SnapshotValidationServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs index f389aad46..3b43f72ea 100644 --- a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs +++ b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs @@ -63,7 +63,7 @@ public void SetUp() .Returns(() => _currentPositions.ToImmutableArray()); _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny(), It.IsAny())) - .ReturnsAsync((DateTime date) => _ordersHistory); + .ReturnsAsync((DateTime from, DateTime? to) => _ordersHistory); _positionsHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) .ReturnsAsync((DateTime date) => _positionsHistory); From e7b905f0e64901f8965f3a5e7c06658e14bf8c35 Mon Sep 17 00:00:00 2001 From: Aliaksandr Vashetsin Date: Thu, 14 Mar 2024 12:22:01 +0100 Subject: [PATCH 3/7] Revert "LT-4926: fix unit test" This reverts commit 88d3f894c001b8a2a651d1f7099a181ce73fae44. --- .../Infrastructure/SnapshotValidationServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs index 3b43f72ea..f389aad46 100644 --- a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs +++ b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs @@ -63,7 +63,7 @@ public void SetUp() .Returns(() => _currentPositions.ToImmutableArray()); _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny(), It.IsAny())) - .ReturnsAsync((DateTime from, DateTime? to) => _ordersHistory); + .ReturnsAsync((DateTime date) => _ordersHistory); _positionsHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) .ReturnsAsync((DateTime date) => _positionsHistory); From ae9bac99db1b7863a2b9dc2adad59a9a80eef48e Mon Sep 17 00:00:00 2001 From: Aliaksandr Vashetsin Date: Thu, 14 Mar 2024 12:22:25 +0100 Subject: [PATCH 4/7] Revert "LT-4926: Potential corrupted snapshot" This reverts commit 1a254d7f0f9f82a05c147b13fee7a14b23ce4293. --- .../Repositories/IOrdersHistoryRepository.cs | 2 +- .../Infrastructure/SnapshotValidationService.cs | 5 +---- .../Repositories/OrdersHistoryRepository.cs | 6 +++--- .../Infrastructure/SnapshotValidationServiceTests.cs | 2 +- tests/MarginTradingTests/Modules/MockRepositoriesModule.cs | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs b/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs index 326ddaa61..500154f82 100644 --- a/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs +++ b/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs @@ -10,6 +10,6 @@ namespace MarginTrading.Backend.Core.Repositories { public interface IOrdersHistoryRepository { - Task> GetLastSnapshot(DateTime @from, DateTime? @to = null); + Task> GetLastSnapshot(DateTime @from); } } diff --git a/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs b/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs index d5f480b83..cfb4253d5 100644 --- a/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs +++ b/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs @@ -62,10 +62,7 @@ await _log.WriteInfoAsync(nameof(SnapshotValidationService), nameof(ValidateCurr var lastOrders = GetOrders(tradingEngineSnapshot); var lastPositions = GetPositions(tradingEngineSnapshot); - var latestLastModified = currentOrders.Any() - ? currentOrders.Max(x => x.LastModified) - : (DateTime?)null; - var ordersHistory = await _ordersHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp, latestLastModified); + var ordersHistory = await _ordersHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp); var positionsHistory = await _positionsHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp); var restoredOrders = RestoreOrdersCurrentStateFromHistory(lastOrders, ordersHistory); diff --git a/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs b/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs index b23e82f38..4977b17cd 100644 --- a/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs +++ b/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs @@ -34,7 +34,7 @@ CASE [Status] ELSE 99 END as StatusOrder FROM [{0}] oh (NOLOCK) - WHERE oh.ModifiedTimestamp > @From AND (@To IS NULL OR oh.ModifiedTimestamp <= @To) + WHERE oh.ModifiedTimestamp > @Timestamp ), filteredOrderHistWithRowNumber AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY Id ORDER BY @@ -54,11 +54,11 @@ public OrdersHistoryRepository(string connectionString, string tableName, int ge _getLastSnapshotTimeoutS = getLastSnapshotTimeoutS; } - public async Task> GetLastSnapshot(DateTime @from, DateTime? @to = null) + public async Task> GetLastSnapshot(DateTime @from) { using (var conn = new SqlConnection(_connectionString)) { - var data = await conn.QueryAsync(_select, new { From = @from, To = @to }, commandTimeout: _getLastSnapshotTimeoutS); + var data = await conn.QueryAsync(_select, new { Timestamp = @from }, commandTimeout: _getLastSnapshotTimeoutS); return data.Cast().ToList(); } diff --git a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs index f389aad46..33dccad2e 100644 --- a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs +++ b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs @@ -62,7 +62,7 @@ public void SetUp() _orderCacheMock.Setup(o => o.GetPositions()) .Returns(() => _currentPositions.ToImmutableArray()); - _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny(), It.IsAny())) + _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) .ReturnsAsync((DateTime date) => _ordersHistory); _positionsHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) diff --git a/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs b/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs index 22fd9eede..9cfd403a4 100644 --- a/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs +++ b/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs @@ -29,7 +29,7 @@ protected override void Load(ContainerBuilder builder) blobRepository.Setup(s => s.ReadWithTimestampAsync>(It.IsAny(), It.IsAny())) .ReturnsAsync((new List(), DateTime.UtcNow)); var orderHistoryRepository = new Mock(); - orderHistoryRepository.Setup(s => s.GetLastSnapshot(It.IsAny(), It.IsAny())) + orderHistoryRepository.Setup(s => s.GetLastSnapshot(It.IsAny())) .ReturnsAsync(new List()); var positionHistoryRepository = new Mock(); var accountHistoryRepository = new Mock(); From e9867c210afa2f7b785279d396c959bca178315b Mon Sep 17 00:00:00 2001 From: Aliaksandr Vashetsin Date: Thu, 14 Mar 2024 12:53:03 +0100 Subject: [PATCH 5/7] Revert "Revert "LT-4926: Potential corrupted snapshot"" This reverts commit ae9bac99db1b7863a2b9dc2adad59a9a80eef48e. --- .../Repositories/IOrdersHistoryRepository.cs | 2 +- .../Infrastructure/SnapshotValidationService.cs | 5 ++++- .../Repositories/OrdersHistoryRepository.cs | 6 +++--- .../Infrastructure/SnapshotValidationServiceTests.cs | 2 +- tests/MarginTradingTests/Modules/MockRepositoriesModule.cs | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs b/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs index 500154f82..326ddaa61 100644 --- a/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs +++ b/src/MarginTrading.Backend.Core/Repositories/IOrdersHistoryRepository.cs @@ -10,6 +10,6 @@ namespace MarginTrading.Backend.Core.Repositories { public interface IOrdersHistoryRepository { - Task> GetLastSnapshot(DateTime @from); + Task> GetLastSnapshot(DateTime @from, DateTime? @to = null); } } diff --git a/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs b/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs index cfb4253d5..d5f480b83 100644 --- a/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs +++ b/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs @@ -62,7 +62,10 @@ await _log.WriteInfoAsync(nameof(SnapshotValidationService), nameof(ValidateCurr var lastOrders = GetOrders(tradingEngineSnapshot); var lastPositions = GetPositions(tradingEngineSnapshot); - var ordersHistory = await _ordersHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp); + var latestLastModified = currentOrders.Any() + ? currentOrders.Max(x => x.LastModified) + : (DateTime?)null; + var ordersHistory = await _ordersHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp, latestLastModified); var positionsHistory = await _positionsHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp); var restoredOrders = RestoreOrdersCurrentStateFromHistory(lastOrders, ordersHistory); diff --git a/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs b/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs index 4977b17cd..b23e82f38 100644 --- a/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs +++ b/src/MarginTrading.SqlRepositories/Repositories/OrdersHistoryRepository.cs @@ -34,7 +34,7 @@ CASE [Status] ELSE 99 END as StatusOrder FROM [{0}] oh (NOLOCK) - WHERE oh.ModifiedTimestamp > @Timestamp + WHERE oh.ModifiedTimestamp > @From AND (@To IS NULL OR oh.ModifiedTimestamp <= @To) ), filteredOrderHistWithRowNumber AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY Id ORDER BY @@ -54,11 +54,11 @@ public OrdersHistoryRepository(string connectionString, string tableName, int ge _getLastSnapshotTimeoutS = getLastSnapshotTimeoutS; } - public async Task> GetLastSnapshot(DateTime @from) + public async Task> GetLastSnapshot(DateTime @from, DateTime? @to = null) { using (var conn = new SqlConnection(_connectionString)) { - var data = await conn.QueryAsync(_select, new { Timestamp = @from }, commandTimeout: _getLastSnapshotTimeoutS); + var data = await conn.QueryAsync(_select, new { From = @from, To = @to }, commandTimeout: _getLastSnapshotTimeoutS); return data.Cast().ToList(); } diff --git a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs index 33dccad2e..f389aad46 100644 --- a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs +++ b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs @@ -62,7 +62,7 @@ public void SetUp() _orderCacheMock.Setup(o => o.GetPositions()) .Returns(() => _currentPositions.ToImmutableArray()); - _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) + _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny(), It.IsAny())) .ReturnsAsync((DateTime date) => _ordersHistory); _positionsHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) diff --git a/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs b/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs index 9cfd403a4..22fd9eede 100644 --- a/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs +++ b/tests/MarginTradingTests/Modules/MockRepositoriesModule.cs @@ -29,7 +29,7 @@ protected override void Load(ContainerBuilder builder) blobRepository.Setup(s => s.ReadWithTimestampAsync>(It.IsAny(), It.IsAny())) .ReturnsAsync((new List(), DateTime.UtcNow)); var orderHistoryRepository = new Mock(); - orderHistoryRepository.Setup(s => s.GetLastSnapshot(It.IsAny())) + orderHistoryRepository.Setup(s => s.GetLastSnapshot(It.IsAny(), It.IsAny())) .ReturnsAsync(new List()); var positionHistoryRepository = new Mock(); var accountHistoryRepository = new Mock(); From 32b1f5882e06b127a2c79ebca4a508e128d817ee Mon Sep 17 00:00:00 2001 From: Aliaksandr Vashetsin Date: Thu, 14 Mar 2024 12:53:13 +0100 Subject: [PATCH 6/7] Revert "Revert "LT-4926: fix unit test"" This reverts commit e7b905f0e64901f8965f3a5e7c06658e14bf8c35. --- .../Infrastructure/SnapshotValidationServiceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs index f389aad46..3b43f72ea 100644 --- a/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs +++ b/tests/MarginTradingTests/Infrastructure/SnapshotValidationServiceTests.cs @@ -63,7 +63,7 @@ public void SetUp() .Returns(() => _currentPositions.ToImmutableArray()); _ordersHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny(), It.IsAny())) - .ReturnsAsync((DateTime date) => _ordersHistory); + .ReturnsAsync((DateTime from, DateTime? to) => _ordersHistory); _positionsHistoryRepositoryMock.Setup(o => o.GetLastSnapshot(It.IsAny())) .ReturnsAsync((DateTime date) => _positionsHistory); From 62d7a5b5cf29bd14a6596b234187099e73246472 Mon Sep 17 00:00:00 2001 From: Aliaksandr Vashetsin Date: Thu, 21 Mar 2024 10:29:35 +0100 Subject: [PATCH 7/7] LT-4926: suggested changes --- .../Infrastructure/SnapshotValidationService.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs b/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs index d5f480b83..edbaf2710 100644 --- a/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs +++ b/src/MarginTrading.Backend.Services/Infrastructure/SnapshotValidationService.cs @@ -62,10 +62,8 @@ await _log.WriteInfoAsync(nameof(SnapshotValidationService), nameof(ValidateCurr var lastOrders = GetOrders(tradingEngineSnapshot); var lastPositions = GetPositions(tradingEngineSnapshot); - var latestLastModified = currentOrders.Any() - ? currentOrders.Max(x => x.LastModified) - : (DateTime?)null; - var ordersHistory = await _ordersHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp, latestLastModified); + var latestOrder = currentOrders.MaxBy(x => x.LastModified); + var ordersHistory = await _ordersHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp, latestOrder?.LastModified); var positionsHistory = await _positionsHistoryRepository.GetLastSnapshot(tradingEngineSnapshot.Timestamp); var restoredOrders = RestoreOrdersCurrentStateFromHistory(lastOrders, ordersHistory);