Skip to content

Commit

Permalink
Ignore insight emitted during warmup
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero committed Oct 18, 2019
1 parent 7ac11ae commit 298d751
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Algorithm/QCAlgorithm.Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public partial class QCAlgorithm
{
private readonly ISecurityValuesProvider _securityValuesProvider;
private IAlphaModel _alpha;
private bool _isEmitWamrupInsightWarningSent;

/// <summary>
/// Enables additional logging of framework models including:
Expand Down Expand Up @@ -379,6 +380,16 @@ public void AddRiskManagement(IRiskManagementModel riskManagement)
/// <param name="insights">The array of insights to be emitted</param>
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." +
Expand All @@ -400,18 +411,7 @@ public void EmitInsights(params Insight[] insights)
/// <param name="insight">The insight to be emitted</param>
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});
}

/// <summary>
Expand Down

0 comments on commit 298d751

Please sign in to comment.