Statistics
Algorithm Statistics
Introduction
The StatisticsResults
object tracks all the statistics of your algorithm. You can access the statistics anywhere in your algorithm where you have a reference to the algorithm class. Some of these statistics are a function of the risk free interest rate and the number of trading days per year.
Get Values
To get the StatisticsResults
, use the Statistics
statistics
member of the algorithm class.
var sharpe = Statistics.TotalPerformance.PortfolioStatistics.SharpeRatio;
sharpe = self.statistics.total_performance.portfolio_statistics.sharpe_ratio
To get the value of a custom statistic while your algorithm runs, index the Summary
summary
member with the statistic name. The values in the Summary
summary
dictionary are strings, so you may need to cast the value that returns to a different data type.
var value = Statistics.Summary["name"];
value = self.statistics.summary["name"]
The following table describe other ways to get the statistics after your backtest completes:
Deployment Target | Access Tools |
---|---|
QuantConnect Cloud |
|
Local |
|