Statistics

Runtime Statistics

Introduction

Runtime statistics show the performace of your algorithm at a single moment in time. Some of these statistics are a function of the risk free interest rate.

Default Statistics

The following table describes the default runtime statistics:

StatisticDescription
EquityThe total portfolio value if all of the holdings were sold at current market rates.
FeesThe total quantity of fees paid for all the transactions.
HoldingsThe absolute sum of the items in the portfolio.
Net ProfitThe dollar-value return across the entire trading period.
PSRThe probability that the estimated Sharpe ratio of an algorithm is greater than a benchmark (1).
ReturnThe rate of return across the entire trading period.
UnrealizedThe amount of profit a portfolio would capture if it liquidated all open positions and paid the fees for transacting and crossing the spread.
VolumeThe total value of assets traded for all of an algorithm's transactions.

Add Statistics

To add a custom runtime statistic, call the SetRuntimeStatistic method with a name and value. The value argument can be a string or a number.

SetRuntimeStatistic(name, value);
self.set_runtime_statistic(name, value)

Don't try to set a value for any of the preceding default runtime statistics. LEAN overwrites the value that you try to set.

Get Values

To get the value of a runtime statistic in an algorithm, index the RuntimeStatistics member of the algorithm class with the statistic name. The values of the RuntimeStatistics dictionary are strings, so you may need to cast the result to a different data type.

var value = RuntimeStatistics[name];
value = self.runtime_statistic[name]

The following table describe other ways to get the runtime statistics of your backtests and live algorithms:

Deployment TargetExecution ModeAccess Tools
QuantConnect CloudBacktest
QuantConnect CloudLive Trading
LocalBacktest
LocalLive Trading
  • Live results page on Local Platform
  • <organizationWorkspace> / <projectName> / live / <timeStamp> / / L-<deploymentId>.json

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: