/// <summary> /// Process the synchronous result events, sampling and message reading. /// This method is triggered from the algorithm manager thread. /// </summary> /// <remarks>Prime candidate for putting into a base class. Is identical across all result handlers.</remarks> public virtual void ProcessSynchronousEvents(bool forceProcess = false) { if (Algorithm == null) { return; } _capacityEstimate.UpdateMarketCapacity(forceProcess); var time = Algorithm.UtcTime; if (time > _nextSample || forceProcess) { //Set next sample time: 4000 samples per backtest _nextSample = time.Add(ResamplePeriod); //Sample the portfolio value over time for chart. SampleEquity(time, Math.Round(Algorithm.Portfolio.TotalPortfolioValue, 4)); //Also add the user samples / plots to the result handler tracking: SampleRange(Algorithm.GetChartUpdates()); } ProcessAlgorithmLogs(); //Set the running statistics: foreach (var pair in Algorithm.RuntimeStatistics) { RuntimeStatistic(pair.Key, pair.Value); } }
/// <summary> /// Process the synchronous result events, sampling and message reading. /// This method is triggered from the algorithm manager thread. /// </summary> /// <remarks>Prime candidate for putting into a base class. Is identical across all result handlers.</remarks> public virtual void ProcessSynchronousEvents(bool forceProcess = false) { if (Algorithm == null) { return; } _capacityEstimate.UpdateMarketCapacity(forceProcess); var time = Algorithm.UtcTime; try { //Recalculate the days processed. We use 'int' so it's thread safe _daysProcessed = (int)(Algorithm.Time - _initialTime).TotalDays; } catch (OverflowException) { } if (time > _nextSample || forceProcess) { //Set next sample time: 4000 samples per backtest _nextSample = time.Add(ResamplePeriod); //Sample the portfolio value over time for chart. SampleEquity(time, Math.Round(Algorithm.Portfolio.TotalPortfolioValue, 4)); //Also add the user samples / plots to the result handler tracking: SampleRange(Algorithm.GetChartUpdates()); } ProcessAlgorithmLogs(); //Set the running statistics: foreach (var pair in Algorithm.RuntimeStatistics) { RuntimeStatistic(pair.Key, pair.Value); } }