# 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.

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 .
**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 .
**Portfolio i-th end of day value**- Value of portfolio in the at the end of -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.

**Initial capital**- It is an initial value of a portfolio. Has to be set before strategy’s start and is denoted by .
**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 .

## Portfolio end of day statistics¶

It is a profit or lose of a strategy computed at the end of a day . 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.

- The sum of profit/loss of all trades up to day . Concerns only already closed position at last at day .
- The estimated value of all open positions at the end of the day .
- Profit/Loss: .
- Portfolio value at the end of day : .
- The return of the portfolio at the end of the day: .
- The cumulative portfolio return at the end of the day: .
- The annualized portfolio return: .
The annualized portfolio standard deviation estimator:

where .

- The daily return of a portfolio at the end of a day : .
- The downside difference between a portfolio return at the end of a day and the daily return for a day : .
- The number of which has a value smaller then zero: .
- The Omega upside ratio for portfolio at the end of the day: .
- The Omega downside ratio for portfolio at the end of the day: .

### Simple statistics¶

**Number of portfolio end of day values**- It is a number of the days in which strategy was executed. It symbol is .
**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:

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

**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 because this estimator is unbiased.

**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

**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

**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

### Sharpe ratios¶

**Sharpe ratio**- This standard statistic is computed in the following way

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

### Sortino ratios¶

**Annualized downside risk**- Annualized downside risk is computed in the following way, where

**Sortino ratio**

### Other ratios¶

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

## Portfolio intraday statistics¶

- The sum of profit/loss of all trades up to -th quote. Concerns only already closed position at last at moment of -th quote.
- The estimated value of all open positions at the -th moment.
- Profit/Loss: .
- Portfolio value at the end of day : .
- The return of the portfolio at the time when the i-th stock quote is received: .
- The number all of positive returns: .
- The number all of negative returns: .

### Simple statistics¶

**Number of Portfolio Intraday Values**- The number of all intraday values (stock quotes) is denoted by .
**Portfolio Intraday Sum**- It is a sum of all intraday portfolio values.

**Portfolio Intraday Mean**- The mean of values is computed as follows:

**Portfolio Intraday Variance**- The estimator of a variance of a portfolio values is computed as follows, the denominator of the below fractional is because this estimator is unbiased.

**Portfolio Intraday Standard Deviation**- The standard deviation estimator of a portfolio values is computed as follows:

**Portfolio Intraday Skewness**- The estimator of a skewness of a portfolio values is computed as follows:

**Portfolio Intraday Kurtosis**- The estimator of a kurtosis of a portfolio values is computed as follows:

### Returns statistics¶

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

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

**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 . Moreover, .

**Standard deviation positive returns**- The estimator of a standard deviation of all positive returns is computed in the following way. Moreover, .

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

### Other statistics¶

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

**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.

## Instrument statistics¶

- The number of trades which have been done between and .
- The position closing price at moment : .
- The number of closed positions during the life of a strategy.
- The sum of profit or loss of the strategy: .
- The total sum of all closed positions with positive : .

- The total sum of all closed positions with negative : .
- The number of closed positions with positive value: .
- The number of closed positions with negative value: .
- The price with which a trade was done at moment , by the strategy.
- The quantity that strategy buys or sells at the moment .
- In each step of a strategy can either buying or selling an asset. The value of describes strategy’s position at moment:math:i.
- The maximum price with which a trade was done by the strategy up to the moment : .
- The minimum price with which a trade was done by the strategy up to the moment : .
- The best possible trade at moment : .
- The sum of the best possible trades: .
- The worst trade to be done at moment : .
- The sum of the worst possible trades: .

### Simple statistics¶

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

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

### 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

**Average Winning Trade**- It is the average price of closed position with , it is defined as follows:

**Average Loosing Trade**- It is the average price of closed position with , it is defined as follows:

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

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

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

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

### Number of trades¶

**Total Number of TRADES**- Total number of all trades done by the strategy is equal to .
**Total Number of Short Trades**- Total number of short trades done by the strategy. It is defined as follows:

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

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

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

**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:

### Profit/loss statistics¶

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

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

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

**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:

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

**Last Price**- It is the last market price of an instrument when the strategy is done. Its symbol is .
**Closed PnL**- Overall profit reduced by loss of all closed positions. Expresses actual accounted revenue of strategy at some moment . Calculated basing on all actual transactions (the volume and price of transaction are known). Denoted as .
**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 .
**Total PnL**- This statistic is defined as a sum of the two previous statistics.

### 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¶

- The total number of all stock quotes which were registered by a strategy during it’s execution.
- The price of an instrument at the moment , 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 .
**Last Stock Date**- It is the price of an instrument just before the strategy has stopped. It is denoted by .
**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:

**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:

### 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:

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