Key Concepts
Glossary
alpha
The excess return of an algorithm relative to its benchmark after adjusting for risk. Alpha measures the value added by the algorithm's strategy beyond what could be explained by exposure to market movements.
It is calculated as
$$ \alpha = R_p - \left[ R_f + \beta \left( R_b - R_f \right) \right] $$where $R_p$ is the portfolio return, $R_f$ is the risk-free rate, $\beta$ is the portfolio's beta, and $R_b$ is the benchmark return. A positive alpha indicates the algorithm outperformed its risk-adjusted benchmark.
annual standard deviation
A statistical measure that describes the dispersion of annual returns relative to the mean annual return. It is the square root of the annual variance. Assuming independent and identically distributed daily returns, it is calculated as
$$ \sigma_{\text{annual}} = \sigma_{\text{daily}} \times \sqrt{252} $$where $\sigma_{\text{daily}}$ is the standard deviation of daily returns and 252 is the typical number of trading days in a year.
annual variance
A statistical measure that describes the dispersion of annual returns relative to the mean annual return. Assuming independent and identically distributed daily returns, it is calculated as
$$ \sigma^2_{\text{annual}} = \sigma^2_{\text{daily}} \times 252 $$where $\sigma^2_{\text{daily}}$ is the variance of daily returns and 252 is the typical number of trading days in a year.
beta
The scale and direction of an algorithm's returns relative to movements in the underlying benchmark.
It is calculated as
$$ \beta = \frac{\text{Cov}(R_p,\, R_b)}{\text{Var}(R_b)} $$where $R_p$ is the portfolio return and $R_b$ is the benchmark return. A beta of 1 indicates the algorithm moves in lockstep with the benchmark, a beta greater than 1 indicates amplified movements, and a negative beta indicates inverse movements.
compounding annual return
The annual percentage return that would be required to grow a portfolio from its starting value to its ending value.
It is calculated as
$$ \text{CAGR} = \left(\frac{e}{s}\right)^{\frac{1}{y}} - 1 $$where $s$ is starting equity, $e$ is ending equity, and $y$ is the number of years in the backtest period.
drawdown
The largest peak to trough decline in an algorithm's equity curve.
It is calculated as
$$ 1 - \frac{v^{t \ge s}_{\text{min}}}{v^s_{\text{max}}} $$where $v^s_{\text{max}}$ is the maximum equity value up to time $s$ and $v^{t \ge s}_{\text{min}}$ is the minimum equity value at time $t$ where $t \ge s$.
expectancy
The expected return per trade.
It is calculated as
$$ E = (W_r \times \bar{W}) + (L_r \times \bar{L}) $$where $W_r$ is the win rate, $\bar{W}$ is the average win, $L_r$ is the loss rate, and $\bar{L}$ is the average loss. A positive expectancy indicates the algorithm is expected to be profitable over time.
implied volatility
The volatility of an Option's underlying asset that, when input into an Options pricing model, returns a theoretical value equal to the current market price of the Option.
An initial estimate can be calculated as
$$ \sigma \approx \frac{P}{S} \sqrt{\frac{2\pi}{T}} $$where $P$ is the Option price, $S$ is the underlying asset price, and $T$ is the time to expiration in years. For more information, see Brenner and Subrahmanyam (1988).
information ratio
The amount of excess return relative to the benchmark per unit of tracking error.
It is calculated as
$$ IR = \frac{R_p - R_b}{\sigma_{R_p - R_b}} $$where $R_p$ is the portfolio return, $R_b$ is the benchmark return, and $\sigma_{R_p - R_b}$ is the tracking error (the standard deviation of the difference between the portfolio and benchmark returns). A higher information ratio indicates more consistent outperformance.
intrinsic value
(Call Option) The price of an asset minus the strike price if the price is above the strike price, otherwise zero.
It is calculated as
$$ IV_{\text{call}} = \max(S - K,\, 0) $$(Put Option) The strike price minus the price of an asset if the price is below the strike price, otherwise zero.
It is calculated as
$$ IV_{\text{put}} = \max(K - S,\, 0) $$where $S$ is the current price of the underlying asset and $K$ is the strike price of the Option contract.
net profit
(Percent) The rate of return across the entire trading period.
It is calculated as
$$ \text{Net Profit (\%)} = \frac{e - s}{s} \times 100 $$(Dollar-value) The dollar-value return across the entire trading period.
It is calculated as
$$ \text{Net Profit (\$)} = e - s $$where $s$ is starting equity and $e$ is ending equity.
out of the money amount
(Call Option) The strike price minus the price of an asset if the price is below the strike price, otherwise zero.
It is calculated as
$$ OTM_{\text{call}} = \max(K - S,\, 0) $$(Put Option) The price of an asset minus the strike price if the price is above the strike price, otherwise zero.
It is calculated as
$$ OTM_{\text{put}} = \max(S - K,\, 0) $$where $S$ is the current price of the underlying asset and $K$ is the strike price of the Option contract.
Pearson correlation
A measure of the linear relationship between two variables, ranging from -1 to 1.
It is calculated as
$$ \rho_{XY} = \frac{\text{Cov}(X,\, Y)}{\sigma_X \sigma_Y} $$where $\text{Cov}(X, Y)$ is the covariance of the two variables and $\sigma_X$, $\sigma_Y$ are their standard deviations. A value of 1 indicates a perfect positive linear relationship, -1 indicates a perfect negative linear relationship, and 0 indicates no linear relationship.
Probabilistic Sharpe ratio
The probability that the estimated Sharpe ratio of an algorithm is greater than a benchmark.
It is calculated as
\[ P\left(\hat{SR} > SR^{\ast}\right) = CDF\left(\frac{(\hat{SR} - SR^{\ast})\sqrt{n-1}}{\sqrt{1 - \hat{\gamma}_{3}\hat{SR} + \frac{\hat{\gamma}_{4}-1}{4}\hat{SR}^{2}}}\right) \]where $SR^{\ast}$ is the Sharpe ratio of the benchmark, $\hat{SR}$ is the Sharpe ratio of the algorithm, $n$ is the number of trading days, $\hat{\gamma}_{3}$ is the skewness of the algorithm's returns, $\hat{\gamma}_{4}$ is the kurtosis of the algorithm's returns, and $CDF$ is the normal cumulative distribution function. For more information about the PSR, see Bailey and López de Prado (2012).
profit loss ratio
The ratio of the average win rate to the average loss rate.
It is calculated as
$$ PLR = \frac{\bar{W}}{|\bar{L}|} $$where $\bar{W}$ is the average win and $\bar{L}$ is the average loss. A profit-loss ratio greater than 1 indicates that the average winning trade is larger than the average losing trade.
put call parity
A relationship between the prices of a European call Option, a European put Option, the underlying asset, and the risk-free rate.
It is defined as
$$ C(t,K) - P(t,K) = e^{(q-r)t}(S_T - K) $$where $C$ is the call price, $P$ is the put price, $K$ is the strike price, $S_T$ is the underlying asset price, $r$ is the risk-free rate, $q$ is the dividend yield, and $t$ is the time to expiration.
Sharpe ratio
A measure of the risk-adjusted return, developed by William Sharpe.
It is calculated as
$$ SR = \frac{E[R_p - R_b]}{\sigma_p} $$where $R_p$ is the return of the portfolio, $R_b$ is the return of the benchmark, and $\sigma_p$ is the standard deviation of the portfolio's excess returns. By default, LEAN uses a 0% risk-free rate, so $R_b = 0$. For more information about the Sharpe ratio, see Sharpe (1994).
Sortino ratio
A measure of the risk-adjusted return, developed by Frank Sortino. Unlike the Sharpe ratio, the Sortino ratio only penalizes returns falling below a user-specified target or required rate of return.
It is calculated as
$$ S = \frac{R_p - R_f}{\sigma_d} $$where $R_p$ is the portfolio return, $R_f$ is the risk-free rate, and $\sigma_d$ is the downside deviation (the standard deviation of negative returns only). By using downside deviation, the Sortino ratio does not penalize upside volatility.
tail value at risk
The expected loss of a portfolio beyond the Value at Risk threshold, also known as Conditional Value at Risk (CVaR).
Assuming normally distributed returns, it is calculated as
$$ \text{TVaR}_{\alpha} = \mu + \sigma \times \frac{\phi[\Phi^{-1}(\alpha)]}{1 - \alpha} $$where $\mu$ is the mean return, $\sigma$ is the standard deviation, $\alpha$ is the confidence level, $\phi$ is the standard normal density function, and $\Phi^{-1}$ is the inverse of the standard normal cumulative distribution function.
tracking error
A measure of how closely a portfolio follows the index to which it is benchmarked.
It is calculated as
$$ TE = \sigma(R_p - R_b) $$where $R_p$ is the portfolio return, $R_b$ is the benchmark return, and $\sigma$ denotes the standard deviation. A tracking error of 0 indicates a perfect match with the benchmark.
Treynor ratio
A measurement of the returns earned in excess of the risk-free rate per unit of benchmark risk, developed by Jack Treynor.
It is calculated as
$$ T = \frac{R_p - R_f}{\beta} $$where $R_p$ is the portfolio return, $R_f$ is the risk-free rate, and $\beta$ is the portfolio's beta. Unlike the Sharpe ratio, which uses total risk (standard deviation), the Treynor ratio uses systematic risk (beta).
z score
The number of standard deviations a data point is from the mean of a dataset.
It is calculated as
$$ Z = \frac{x - \mu}{\sigma} $$where $x$ is the data point, $\mu$ is the mean, and $\sigma$ is the standard deviation. A z-score of 0 indicates the data point equals the mean. Values beyond $\pm 3$ are commonly considered outliers.