diff --git a/Algorithm/QCAlgorithm.Framework.cs b/Algorithm/QCAlgorithm.Framework.cs index 5ef6bb504cdd..1ce333c2d71c 100644 --- a/Algorithm/QCAlgorithm.Framework.cs +++ b/Algorithm/QCAlgorithm.Framework.cs @@ -31,6 +31,7 @@ public partial class QCAlgorithm { private readonly ISecurityValuesProvider _securityValuesProvider; private IAlphaModel _alpha; + private bool _isEmitWamrupInsightWarningSent; /// /// Enables additional logging of framework models including: @@ -379,6 +380,16 @@ public void AddRiskManagement(IRiskManagementModel riskManagement) /// The array of insights to be emitted public void EmitInsights(params Insight[] insights) { + if (IsWarmingUp) + { + if (!_isEmitWamrupInsightWarningSent) + { + Error("Warning: insights emitted during algorithm warmup are ignored."); + _isEmitWamrupInsightWarningSent = true; + } + return; + } + if (_autogeneratedOrderBasedInsightWasCalled) { throw new InvalidOperationException("EmitInsights should be called before placing an order." + @@ -400,18 +411,7 @@ public void EmitInsights(params Insight[] insights) /// The insight to be emitted public void EmitInsights(Insight insight) { - if (_autogeneratedOrderBasedInsightWasCalled) - { - throw new InvalidOperationException("EmitInsights should be called before placing an order." + - " Algorithms typically follow the classic design of simply placing trades, or they should" + - " follow our recommendation of emitting insights and letting the execution models handle" + - " the trading. To distinguish between these styles we monitor which comes first, and insight" + - " or a trade."); - } - _emitInsightWasCalled = true; - var insights = new[] {InitializeInsightFields(insight)}; - OnInsightsGenerated(insights); - ProcessInsights(insights); + EmitInsights(new []{insight}); } ///