Skip to content

Commit

Permalink
Store/Send insights during/after backtest according to "store-insight…
Browse files Browse the repository at this point in the history
…s" setting in the config to be more time and disk space friendly.
  • Loading branch information
masq6r committed Nov 24, 2023
1 parent 579315e commit 6c88584
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Engine/Results/BacktestingResultHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ protected void SendFinalResult()
result.DateFinished = DateTime.Now;
result.Progress = 1;

StoreInsights();
var shouldStoreInsights = Config.GetBool("store-insights", true);
if(shouldStoreInsights)
{
StoreInsights();
}

//Place result into storage.
StoreResult(result);
Expand All @@ -390,14 +394,17 @@ protected void SendFinalResult()
MessagingHandler.Send(result);

// Send the complete list of Insights.
var insights =
Algorithm.Insights is null
? new List<Insight>()
: Algorithm.Insights.GetInsights()
.OrderBy(insight => insight.GeneratedTimeUtc)
.ToList();
var alphaPacket = new AlphaResultPacket(Algorithm.AlgorithmId, _job.UserId, insights);
MessagingHandler.Send(alphaPacket);
if(shouldStoreInsights)
{
var insights =
Algorithm.Insights is null
? new List<Insight>()
: Algorithm.Insights.GetInsights()
.OrderBy(insight => insight.GeneratedTimeUtc)
.ToList();
var alphaPacket = new AlphaResultPacket(Algorithm.AlgorithmId, _job.UserId, insights);
MessagingHandler.Send(alphaPacket);
}

Log.Trace("BacktestingResultHandler.SendAnalysisResult(): Processed final packet");
}
Expand Down

0 comments on commit 6c88584

Please sign in to comment.