From 16c893deb6f63806c8642d729478a85d1bf9dcde Mon Sep 17 00:00:00 2001 From: Martin-Molinero Date: Mon, 7 Oct 2024 10:40:28 -0300 Subject: [PATCH] Fix history manager configuration assertion (#8361) --- Engine/HistoricalData/BrokerageHistoryProvider.cs | 3 --- Engine/HistoricalData/HistoryProviderManager.cs | 13 ++++++++++++- .../SubscriptionDataReaderHistoryProvider.cs | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Engine/HistoricalData/BrokerageHistoryProvider.cs b/Engine/HistoricalData/BrokerageHistoryProvider.cs index b143898746d1..cc89883cb620 100644 --- a/Engine/HistoricalData/BrokerageHistoryProvider.cs +++ b/Engine/HistoricalData/BrokerageHistoryProvider.cs @@ -78,9 +78,6 @@ public override IEnumerable GetHistory(IEnumerable reques continue; } var subscription = CreateSubscription(request, history); - - _dataPermissionManager.AssertConfiguration(subscription.Configuration, request.StartTimeLocal, request.EndTimeLocal); - subscriptions.Add(subscription); } diff --git a/Engine/HistoricalData/HistoryProviderManager.cs b/Engine/HistoricalData/HistoryProviderManager.cs index c96ebc0f1b2f..116ee3b6201f 100644 --- a/Engine/HistoricalData/HistoryProviderManager.cs +++ b/Engine/HistoricalData/HistoryProviderManager.cs @@ -17,6 +17,7 @@ using QuantConnect.Configuration; using QuantConnect.Data; using QuantConnect.Interfaces; +using QuantConnect.Lean.Engine.DataFeeds; using QuantConnect.Lean.Engine.DataFeeds.Enumerators; using QuantConnect.Logging; using QuantConnect.Util; @@ -33,6 +34,7 @@ namespace QuantConnect.Lean.Engine.HistoricalData /// public class HistoryProviderManager : HistoryProviderBase { + private IDataPermissionManager _dataPermissionManager; private IBrokerage _brokerage; private bool _initialized; @@ -75,6 +77,7 @@ public override void Initialize(HistoryProviderInitializeParameters parameters) dataProvidersList.AddRange(Config.Get("history-provider", "SubscriptionDataReaderHistoryProvider").DeserializeList()); } + _dataPermissionManager = parameters.DataPermissionManager; foreach (var historyProviderName in dataProvidersList) { IHistoryProvider historyProvider; @@ -129,7 +132,15 @@ public override void Initialize(HistoryProviderInitializeParameters parameters) public override IEnumerable GetHistory(IEnumerable requests, DateTimeZone sliceTimeZone) { List> historyEnumerators = new(_historyProviders.Count); - var historyRequets = requests.ToList(); + + var historyRequets = new List(); + foreach (var request in requests) + { + var config = request.ToSubscriptionDataConfig(); + _dataPermissionManager?.AssertConfiguration(config, request.StartTimeLocal, request.EndTimeLocal); + historyRequets.Add(request); + } + foreach (var historyProvider in _historyProviders) { try diff --git a/Engine/HistoricalData/SubscriptionDataReaderHistoryProvider.cs b/Engine/HistoricalData/SubscriptionDataReaderHistoryProvider.cs index de97829bddca..556d7f006aee 100644 --- a/Engine/HistoricalData/SubscriptionDataReaderHistoryProvider.cs +++ b/Engine/HistoricalData/SubscriptionDataReaderHistoryProvider.cs @@ -104,7 +104,6 @@ public override IEnumerable GetHistory(IEnumerable reques private Subscription CreateSubscription(HistoryRequest request) { var config = request.ToSubscriptionDataConfig(); - DataPermissionManager.AssertConfiguration(config, request.StartTimeLocal, request.EndTimeLocal); // this security is internal only we do not need to worry about a few of it's properties // TODO: we don't need fee/fill/BPM/etc either. Even better we should refactor & remove the need for the security