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:
Statistic | Description |
---|---|
Equity | The total portfolio value if all of the holdings were sold at current market rates. |
Fees | The total quantity of fees paid for all the transactions. |
Holdings | The absolute sum of the items in the portfolio. |
Net Profit | The dollar-value return across the entire trading period. |
PSR | The probability that the estimated Sharpe ratio of an algorithm is greater than a benchmark (1). |
Return | The rate of return across the entire trading period. |
Unrealized | The amount of profit a portfolio would capture if it liquidated all open positions and paid the fees for transacting and crossing the spread. |
Volume | The 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 Target | Execution Mode | Access Tools |
---|---|---|
QuantConnect Cloud | Backtest |
|
QuantConnect Cloud | Live Trading |
|
Local | Backtest |
|
Local | Live Trading |
|