Statistics calculated by TradePad

Introduction

To improve your custom strategy diagnosis TradePad provides calculation of market statistics. These are divided into sections and described below.

Empirica Suite is able to calculate statistics in SIMULATED EXCHANGE and BACKTEST modes. To obtain them you have to run any strategy and then open the Statistics tab in Strategy Frame.

Statistics calculated during strategy simulation

Note

Statistics can be calculated and will be visible after your strategy has finished.

View of statistics consist of initial values’ adjusters - see Initial values. Moreover, by clicking Export... button you can export statistics’ results as CSV file to open it by any spreadsheet program.

Below, you will see all available statistic’s values which were feasible to calculate. Statistics are divided into hideable domains to help you browse them. Strategy frame will remember which domains of statistics you are interested in – so it will always show by default these which were last time observed.

Definitions

Position
Strategy’s position on given instrument can be established by a trade. Depending on portfolio’s shares balance, position can be long (after opening it by shares acquirement, buy action) or short (after opening it by shares borrow, sell action).
Transaction
Single buy/sell action in some moment i.
Trade
Is a sequence of transactions, finished with position’s close.
Portfolio value
Sum of the initial capital and balance of all already made transactions.
Portfolio i-th intraday value
Value of portfolio at the moment i.
Portfolio i-th end of day value
Value of portfolio in the at the end of i-th day.

Initial values

These parameters should be defined by user before start of strategy test. These parameters are essential to calculate some of statistics.

Strategy Statistic tab where Initial capital and Risk free rate can be set
Initial capital
It is an initial value of a portfolio. Has to be set before strategy’s start and is denoted by IC.
Risk free rate of return
Expresses investor’s expected profit on zero-risk investment. The risk free rate is defined as a percent value and is denoted by R_{f_r}.

Portfolio end of day statistics

It is a profit or lose of a strategy computed at the end of a day i. To compute this statistics we treat all quotes from one day as a one big quote and on this base we compute the open, close, highest and lowest price of an instrument for a particular day.

CLOSED.PL_i
The sum of profit/loss of all trades up to day i. Concerns only already closed position at last at day i.
ESTIMATED.PL_i
The estimated value of all open positions at the end of the day i.
PL_i
Profit/Loss: PL_i = CLOSED.PL_i + ESTIMATED.PL_i.
PV_i
Portfolio value at the end of day i: PV_i = IC + PL_i.
R_i
The return of the portfolio at the end of the day: R_i = \begin{cases} 0 & \text{if } i = 1 \text{ or } PV_{i - 1} = 0 \\ \frac{PV_{i} - PV_{i - 1}}{PV_{i - 1}} & \text{if } PV_{i - 1} \neq 0 \end{cases}.
C.R_{i}
The cumulative portfolio return at the end of the day: C.R_{i} = \begin{cases} (1 + R_{i})*(1 + C.R_{i - 1}) - 1&  \text{if } i \neq 1 \\ R_{1}& \text{if } i = 1 \end{cases}.
A.R_{i}
The annualized portfolio return: A.R_{i} = \begin{cases} 252 * \frac{C.R_{i}}{i} & \text{if } i \neq 1 \\ 0 & \text{if } i = 1 \end{cases}.
A.R.ST.DEV

The annualized portfolio standard deviation estimator: A.R.ST.DEV = \sqrt{252} * \sqrt{\frac{\sum_{i = 1}^{N^{EOD}} (R_i - \bar{R})}{N^{EOD} - 1}}

where \bar{R} = \frac{\sum_{i = 1}^{N^{EOD}} R_i}{N^{EOD}}.

D.R_{i}
The daily return of a portfolio at the end of a day i: D.R_{i} = \begin{cases} \frac{C.R_{i}}{i} & \text{if } i \neq 1 \\ 0 & \text{if } i = 1 \end{cases}.
DD_{i}
The downside difference between a portfolio return at the end of a day i and the daily return for a day i: DD_{i} = \begin{cases} R_{i} - D.R_{i} & \text{if } R_{i} < 0 \\ 0 & \text{if } R_{i} \geq 0 \end{cases}.
N^{DD}
The number of DD_i which has a value smaller then zero: N^{DD} = \sum_{i = 1}^{N^{EOD}} [\![ DD_{i} < 0 ]\!].
OMEGA.UP
The Omega upside ratio for portfolio at the end of the day: OMEGA.UP = \sum\limits_{i = 1}^{N^{EOD}} (R_{fr} - R_{i}) [\![ R_{fr} - R_{i} > 0 ]\!].
OMEGA.DOWN
The Omega downside ratio for portfolio at the end of the day: OMEGA.DOWN = \sum\limits_{i = 1}^{N^{EOD}} (R_{i} - R_{fr}) [\![ R_{fr} - R_{i} < 0 ]\!].

Simple statistics

Number of portfolio end of day values
It is a number of the days in which strategy was executed. It symbol is N^{EOD}.
Portfolio EOD Sum
It is a sum of a values of the portfolio. It is computed when the strategy is done and it takes to the account all days in which the strategy was active. It defined as follows:

SUM_{EOD} = \sum\limits_{i=1}^{N^{EOD}} PV_{i}

Portfolio EOD Mean
It is average value of a portfolio during the execution of a strategy. Its is defined as follows:

MEAN_{EOD} = \frac{SUM}{N^{EOD}}

Portfolio EOD Variance
It is an estimator of a variance of all portfolio values achieved at the end of the days in which strategy was active. Its is defined as follows, the denominator of the below fractional is N^{EOD} - 1 because this estimator is unbiased.

VAR_{EOD} = \frac{\sum_{i = 1}^{N^{EOD}} (PV_i - MEAN_{EOD})^2}{N^{EOD} - 1}

Portfolio EOD Stddev
It is a standard deviation estimator of all portfolio values achieved at the end of the days in which strategy was active. It is defined as follows

STDDEV_{EOD} = \sqrt{VAR_{EOD}}

Portfolio EOD Skewness
It is a measure of a asymmetry of the distribution of all portfolio values at the end of the days in which strategy was active. It shows in which direction this distribution is moved. Its estimator is defined as follows

SKEW_{EOD} = \frac{\frac{\sum_{i = 1}^{N^{EOD}} (PV_i - MEAN_{EOD})^3}{N^{EOD}}}
                     {[\frac{\sum_{i = 1}^{N^{EOD}} (PV_i - MEAN_{EOD})^2}{N^{EOD} - 1}]^{3/2}}

Portfolio EOD Kurtosis
It is a measure of a “tailedness” of the distribution of all portfolio values at the end of the days in which strategy was active. Its estimator is defined as follows

KURT_{EOD} = \frac{\frac{\sum_{i = 1}^{N^{EOD}} (PV_i - MEAN_{EOD})^4}{N^{EOD}}}
                     {[\frac{\sum_{i = 1}^{N^{EOD}} (PV_i - MEAN_{EOD})^2}{N^{EOD}}]^{2}}

Sharpe ratios

Sharpe ratio
This standard statistic is computed in the following way

SHARPE_{EOD} = \frac{A.R_{N^{EOD}} - R_{fr}}{A.R.ST.DEV}

Sharpe ratio Israelsen modification
It the sharpe ratio is negative then it is reasonable to use its modified variant, the Israelsen modification.

SHARPE_{EOD}^{ISR} =
\begin{cases}
SHARPE_{EOD} & \text{if } A.R_{N^{EOD}} - R_{fr} \geq 0 \\
SHARPE_{EOD} * A.R.ST.DEV^2 & \text{if }A.R_{N^{EOD}} - R_{fr} < 0
\end{cases}

Sortino ratios

Annualized downside risk
Annualized downside risk is computed in the following way, where \bar{DD} = \frac{\sum_{i = 1}^{N^{EOD}} DD_i}{N^{DD}}

DOWN.RISK = \sqrt{252 * \frac{\sum_{i = 1}^{N^{DD}} (DD_i - \bar{DD})}{N^{DD} - 1}}

Sortino ratio

SORTINO_{EOD} = \frac{A.R_{{N}^{EOD}} - R_{fr}}{DOWN.RISK}

Other ratios

Omega ratio
The Omega ratio for the portfolio at the end of the day. It is computed in the following way.

OMEGA =
\begin{cases}
\frac{OMEGA.UP}{OMEGA.DOWN} & \text{if } OMEGA.DOWN \neq 0 \\
NULL & \text{if } OMEGA.DOWN = 0
\end{cases}

Portfolio intraday statistics

CLOSED.PL_i^{INT}
The sum of profit/loss of all trades up to i-th quote. Concerns only already closed position at last at moment of i-th quote.
ESTIMATED.PL_i^{INT}
The estimated value of all open positions at the i-th moment.
PL_i^{INT}
Profit/Loss: PL_i = CLOSED.PL_i + ESTIMATED.PL_i.
PV_i^{INT}
Portfolio value at the end of day i: PV_i^{INT} = IC + PL_i^{INT}.
R_i
The return of the portfolio at the time when the i-th stock quote is received: R_{i}^{INT} = \begin{cases} 0 & \text{if } i = 1 \text{ or } PV_{i - 1}^{INT} = 0 \\ \frac{PV_{i}^{INT} - PV_{i - 1}^{INT}}{PV_{i - 1}^{INT}} & \text{if } PV_{i - 1}^{INT} \neq 0 \end{cases}.
N^{R+}
The number all of positive returns: N^{R+} = \sum\limits_{i = 1}^{N^{INT}} [\![ R_{i}^{INT} > 0 ]\!].
N^{R-}
The number all of negative returns: N^{R-} = \sum\limits_{i = 1}^{N^{INT}} [\![ R_{i}^{INT} < 0 ]\!].

Simple statistics

Number of Portfolio Intraday Values
The number of all intraday values (stock quotes) is denoted by N^{INT}.
Portfolio Intraday Sum
It is a sum of all intraday portfolio values.

SUM_{INT} = \sum\limits_{i = 1}^{N^{INT}} PV_{i}^{INT}

Portfolio Intraday Mean
The mean of PV_i^{INT} values is computed as follows:

MEAN_{INT} = \frac{SUM_{INT}}{N^{INT}}

Portfolio Intraday Variance
The estimator of a variance of a portfolio values PV_i^{INT} is computed as follows, the denominator of the below fractional is N^{INT} - 1 because this estimator is unbiased.

VAR_{INT} = \frac{\sum_{i = 1}^{N^{INT}} (PV_i^{INT} - MEAN_{INT})^2}{N^{INT} - 1}

Portfolio Intraday Standard Deviation
The standard deviation estimator of a portfolio values PV_i^{INT} is computed as follows:

STDDEV_{INT} = \sqrt{VAR_{INT}}

Portfolio Intraday Skewness
The estimator of a skewness of a portfolio values PV_i^{INT} is computed as follows:

SKEW_{INT} = \frac{\frac{1}{N^{INT}} \sum_{i = 1}^{N^{INT}} (PV^{INT}_{i} - MEAN_{INT})^3}
                     {[\frac{1}{N^{INT} - 1} \sum_{i = 1}^{N^{INT}} (PV^{INT}_{i} - MEAN_{INT})^2]^{3/2}}

Portfolio Intraday Kurtosis
The estimator of a kurtosis of a portfolio values PV_i^{INT} is computed as follows:

KURT_{INT} = \frac{\frac{1}{N^{INT}} \sum_{i = 1}^{N^{INT}} (PV^{INT}_{i} - MEAN_{INT})^4}
                     {[\frac{1}{N^{INT}} \sum_{i = 1}^{N^{INT}} (PV^{INT}_{i} - MEAN_{INT})^2]^{2}}

Returns statistics

Highest Period Return
It is the maximum of all portfolio returns. It is defined as follows:

HIGHEST.RETURN = MAX_{i \in \{1, ..., N^{INT}\}} R_{i}^{INT}

Lowest Period Return
It is the minimum of all portfolio returns. It is defined as follows:

LOWEST.RETURN = MIN_{i \in \{1, ..., N^{INT}\}} R_{i}^{INT}

Standard deviation negative returns
The estimator of a standard deviation of all negative returns is computed in the following way. Estimator is unbiased, so the denominator is N^{R-} - 1. Moreover, \bar{R}^{INT}_{-} = \frac{\sum_{i = 1}^{N^{INT}} R_i^{INT} [\![R_{i}^{INT} < 0]\!] }{N^{R+}}.

RETURNS^{-}.ST.DEV = \sqrt{\frac{\sum_{i = 1}^{N^{INT}} [\![R_{i}^{INT} < 0]\!] (R_i^{INT} - \bar{R}^{INT}_{-})^2}{N^{R-} - 1}}

Standard deviation positive returns
The estimator of a standard deviation of all positive returns is computed in the following way. Moreover, \bar{R}^{INT}_{+} = \frac{\sum_{i = 1}^{N^{INT}} R_i^{INT} [\![R_{i}^{INT} > 0]\!] }{N^{R+}}.

RETURNS^{+}.ST.DEV = \sqrt{\frac{\sum_{i = 1}^{N^{INT}} [\![R_{i}^{INT} > 0]\!] (R_i^{INT} - \bar{R}^{INT}_{+})^2}{N^{R+} - 1}}

Max Drawdown Portfolio Return
The maximum drawdown of a portfolio return is computed in the following way:

RETURNS.DRAWDOWN = MAX_{j \in \{1, ..., N^{INT}\}}(MAX_{i \in \{1, ..., j\}} R_{i} - R_{j})

Other statistics

Max Drawdown Portfolio
The maximum drawdown of a portfolio value is computed in the following way:

PV.DRAWDOWN = MAX_{j \in \{1, ..., N^{INT}\}} (MAX_{i \in \{1, ..., j\}} PV_{i} - PV_{j})

Calmar Ratio
The Calmar ratio of a portfolio is a risk index which presents a relation between a mean return and an absolute value of a return drawdown.

CALMAR =
\begin{cases}
\frac{RETURNS.MEAN}{|RETURNS.DRAWDOWN|} & \text{if } RETURNS.DRAWDOWN \neq 0\\
NULL & \text{if } RETURNS.DRAWDOWN = 0
\end{cases}

Instrument statistics

N
The number of trades which have been done between TESTPERION.FROM and TESTPERIOD.UNTIL.
T_i
The position closing price at moment i: T_i = \begin{cases} CLOSED.PL_i - CLOSED.PL_{i-1} & \text{ if } i > 1 \\ CLOSED.PL_1 & \text{ if } i = 1 \end{cases}.
N^{TRADE}
The number of closed positions during the life of a strategy.
SUM.TRADE
The sum of profit or loss of the strategy: SUM.TRADE = \sum_{i=1}^{N^{TRADE}} PL_{i}.
SUM.WINTRADE
The total sum of all closed positions with positive PL_{i} > 0: SUM.WINTRADE = \sum_{i = 1}^{N^{TRADE}} PL_{i} [\![ PL_{i} > 0 ]\!].
SUM.LOSETRADE
The total sum of all closed positions with negative PL_{i} < 0: SUM.LOSETRADE = \sum_{i = 1}^{N^{TRADE}} PL_{i} [\![ PL_{i} < 0 ]\!].
N^{PL+}
The number of closed positions with positive PL_i value: N^{PL+} = \sum_{i = 1}^{N^{TRADE}} [\![ PL_{i} > 0 ]\!].
N^{PL-}
The number of closed positions with negative PL_i value: N^{PL-} = \sum_{i = 1}^{N^{TRADE}} [\![ PL_{i} < 0 ]\!].
S_i
The price with which a trade was done at moment i, by the strategy.
Q_i
The quantity that strategy buys or sells at the moment i.
SIDE_i
In each step of a strategy can either buying or selling an asset. The value of SIDE_i \in \{\text{BUY}, \text{SELL}\} describes strategy’s position at moment:math:i.
S^{MAX}_{i}
The maximum price with which a trade was done by the strategy up to the moment i: S^{MAX}_{i} = MAX_{j \in \{1, \ldots i\}} S_j.
S^{MIN}_{i}
The minimum price with which a trade was done by the strategy up to the moment i: S^{MIN}_{i} = MIN_{j \in \{1, \ldots i\}} S_j..
MFE_{i}
The best possible trade at moment i: MFE_{i} = \begin{cases} S_{i} - S_{i}^{MIN} & SIDE_{i} = SELL \\ S_{i}^{MAX} - S_{i} & SIDE_{i} = BUY  \end{cases}.
SUM.MFE
The sum of the best possible trades: SUM.MFE = \sum_{i=1}^{N^{TRADE}} MFE_i \times Q_i.
MAE_i
The worst trade to be done at moment i: MAE_i = \begin{cases} S_{i} - S_{i}^{MAX}& \text{if } SIDE_{i} = SELL \\ S_{i}^{MIN} - S_{i}& \text{if } SIDE_{i} = BUY \end{cases}.
SUM.MAE
The sum of the worst possible trades: SUM.MAE = \sum_{i = 1}^{N} MAE_i \times Q_i.

Simple statistics

Test Period From
This is the time when the first trade was done by the strategy, its symbol is TESTPERIOD.FROM.
Test Period Until
This is the time when the last trade was done by the strategy, its symbol is TESTPERIOD.UNTIL.
Best Trade
This is the best position closing price, it is defined as follows

T_{N}^{MAX} = MAX_{i \in \{1, 2, \ldots N\}} T_i

Worst Trade
This is the worst position closing price, it is defined as follows

T_{N}^{MIN} = MIN_{i \in \{1, 2, \ldots N\}} T_i

Average trade statistics

Average Trade
It is the average profit or loss of all the transactions made by the strategy. It is defined as follows

AVG.TRADE = \frac{SUM.TRADE}{N^{TRADE}}

Average Winning Trade
It is the average price of closed position with PL_i > 0, it is defined as follows:

AVG.WINTRADE = \frac{SUM.WINTRADE}{N^{PL+}}

Average Loosing Trade
It is the average price of closed position with PL_i < 0, it is defined as follows:

AVG.LOSETRADE = \frac{SUM.LOSETRADE}{N^{PL-}}

Ratio Average Win Average Loss
It is the ratio between the expected profitable trade and expected unprofitable trade. It is defined as follows:

RATIO.AVGWINAVGLOSS =
\begin{cases}
\frac{AVG.WINTRADE}{|AVG.LOSETRADE|} & \text{if } AVG.LOSETRADE \neq 0 \\
NULL & \text{if } AVG.LOSETRADE = 0
\end{cases}

Average maximum favorable excursion
It is the average of best possible trades. It is defined as follows

AVG.MFE = \frac{SUM.MFE}{N}

Average maximum adverse excursion
It is the average of the worst trades. It is defined as follows:

AVG.MAE = \frac{SUM.MAE}{N}

Average End Trade Drawdown
It is the difference between the maximum excursion average and the average trade. It is defined as follows:

AVG.ETD = AVG.MAE - AVG.TRADE

Number of trades

Total Number of TRADES
Total number of all trades done by the strategy is equal to N^{TRADE}.
Total Number of Short Trades
Total number of short trades done by the strategy. It is defined as follows:

N.SHORT = \sum_{i=1}^{N^{TRADE}} [\![ SIDE_i = SELL ]\!]

Total Number of Long Trades
Total number of long trades done by the strategy. It is defined as follows:

N.LONG = \sum_{i=1}^{N^{TRADE}} [\![ SIDE_i = BUY ]\!]

Total Number of Winning Trades
It is a number of closed positions which are profitable.

N.WINNING = \sum_{i = 1}^{N^{TRADE}} [\![ PL_i > 0 ]\!]

Total Number of Loosing Trades
It is a number of closed positions which are unprofitable.

N.LOSING = \sum_{i = 1}^{N^{TRADE}} [\![ PL_i < 0 ]\!]

Percent of Profitable Trades
It it the ratio, expressed in percents, between the number of winning trades and all trades. It is defined as follows:

PROFITABLE.TRADES = \frac{N.WINNING}{N^{TRADE}} \times 100

Profit/loss statistics

Gross Loss
It is a sum of all unprofitable closed positions. It is defined as follows:

GROSS.LOSS = \sum_{i = 1}^{N^{TRADE}} PL_{i} [\![ PL_i < 0 ]\!]

Gross Profit
It is a sum of all profitable closed positions. It is defined as follows:

GROSS.PROFIT = \sum_{i = 1}^{N^{TRADE}} PL_{i} [\![ PL_i > 0 ]\!]

PnL%
It is the precentage change in the portfolio value, when the strategy is finished. It is defined as follows:

PnL\% = \frac{GROSS.PROFIT + GROSS.LOSS}{IC} \times 100

Profit Factor
It is a ratio between the ratio between total profit of all closed positions and the total loss of all closed positions. It is defined as follows:

PROFIT.FACTOR =
\begin{cases}
\frac{GROSS.PROFIT}{|GROSS.LOSS|} & \text{if } GROSS.LOSS \neq 0 \\
NULL & \text{if } GROSS.LOSS = 0
\end{cases}

Net Profit
It is the difference between the gross profit and the gross loss. It is defined as follows:

NET.PROFIT = GROSS.PROFIT - |GROSS.LOSS|

Last Price
It is the last market price of an instrument when the strategy is done. Its symbol is LAST.PRICE.
Closed PnL
Overall profit reduced by loss of all closed positions. Expresses actual accounted revenue of strategy at some moment i. Calculated basing on all actual transactions (the volume and price of transaction are known). Denoted as CLOSED.PL.
Estimated PnL
Theoretical profit reduced by loss concerning only open positions, estimated basing on current market price and volume of instruments kept in strategy’s portfolio. Denoted as ESTIMATED.PL.
Total PnL
This statistic is defined as a sum of the two previous statistics.

TOTAL.PL = ESTIMATED.PL + CLOSED.PL

Other statistics

Trading Period
Length of period between strategy start and it’s finish.
Longest Flat Period
Length of longest period in which closing trades did not give any profit.
Average Time In Market
Average time of position being open, calculated among all already closed positions.

Stock statistics

N^{STOCK}
The total number of all stock quotes which were registered by a strategy during it’s execution.
S_i^{STOCK}
The price of an instrument at the moment i, was the strategy is running.

Simple statistics

First Stock Date
It is the price of an instrument just after the strategy has started. It is denoted by FIRST.STOCKDATE.
Last Stock Date
It is the price of an instrument just before the strategy has stopped. It is denoted by LAST.STOCKDATE.
Highest Price Stock Reached
It is the highest price of an instrument in a time when a strategy is running. It is defined in the following way:

S_N^{MAX} = MAX_{i \in \{1, 2, \ldots N\}} S_i^{STOCK}

Lowest Price Stock Reached
It is the lowest price of an instrument in a time when a strategy is running. It is defined in the following way:

S_N^{MIN} = MIN_{i \in \{1, 2, \ldots N\}} S_i^{STOCK}

Other statistics

Max Drowdown Stock
It is the maximum drowdown of a stock prices in a time when a strategy is running. It is defined in the following way:

STOCK.DRAWDOWN = MAX_{j \in \{1, 2, \ldots N^{STOCK}\}} MAX_{i \in \{1, \ldots j\}} S_i^{STOCK} - S_j^{STOCK}

Ulcer index
The Ulcer index is computed in the following way:

ULCER = \frac{\sqrt{\sum_{i=1}^{N^{STOCK}} (100 \times \frac{S_i^{STOCK} - S_N^{MAX}}{S_N^{MAX}})^2}}{N^{STOCK}}