Saturday, 19 of May of 2012

Tag » statistics

Sortino ratio

The Sortino ratio is closely related to the Sharpe ratio.

The Sharpe ratio is the ratio (rp-rb)/ sigmap. Where rp is the mean return from your trades, rb is the mean return from the benchmark, and sigmap is the standard deviation of returns from your trades. The benchmark series is typically either the risk free return or zero. The risk free returns could be the rate earned if the funds are in a short maturity note or money market fund, for example. Using zero for the comparison tests the returns from your trades against random (which has a mean of zero).

If you use zero, then: Sharpe Ratio = rp / sigmap. That is, the mean divided by the standard deviation.

High numbers are better. You want the mean to be greater than the standard deviation. But it seldom is. For most systems, the standard deviation is seldom as low as two times and more often four times the mean. Which causes the Sharpe ratio to be typically 0.25 to rarely 0.50.

I have a long-standing offer to buy dinner and drinks for a trader (and his or her best friend) who can demonstrate a trading system that trades a major US market index, is stable over the most recent several years, passes validation tests, trades at least 20 times a year, has a positive return after frictional costs, with the mean equal to or greater than the standard deviation. Such a system would have a Sharpe ratio of 1.00 or higher.

Prospective dinner companions are invited to either post their system to this forum or email me privately. During dinner, we will discuss our plans to take over the world’s economies and become the two richest people in the world.

No kidding — a trading system with a Sharpe ratio of 1.0 or better would be fantastically profitable.

————————–

Since the Sharpe ratio uses all trades to compute both the mean and the standard deviation, replacing a single trade that earned the mean with a trade that was a substantial winner (or any winner greater than the mean) penalizes the ratio. If two alternative systems are being ranked using Sharpe ratio, the system with the extra winner is viewed as poorer. Most traders would not penalize winning trades, hence the development of the Sortino ratio. Rather than using the standard deviation of all trades to compute the standard deviation, only losing trades are used. Winning trades are gladly accepted without penalty.

There are two approaches to computation of Sortino ratio. Say there are N trades, M of which are winners — which means that (N-M) are losers. The mean (or average) of all N trades is computed and used in both of the approaches.

One replaces every M winning trade with zero, then computes the standard deviation of the N values.

The other ignores all winning trades, then computes the standard deviation of the remaining (N-M) values, all of which are negative, but the standard deviation will still be positive (only probably a smaller value).

So ———

Use the code for computation of the Sharpe ratio and modify it so that winning trades are not penalized. Try both approaches and choose the one that works best for you. Whichever you use, the statistics police will not interfere.

———————————–

Continuing on with the calculations —

The t statistic is computed as (mean / standard deviation) * squareroot(number of trades). Van Tharp calls this the system quality number. (I wish people would not try to claim ownership of commonly used and widely known ideas.) A t statistic is significant (suggesting that the data used to compute it are probably more positive than random) if it is greater than about 2.0. The t statistic is essentially equivalent to the z score for large N (20 or 30 or greater), which means that a z score or t statistic of +2.0 reflects data where the mean is two standard deviations greater than the benchmark (which might be zero which represents random results), which happens less than 3% of the time. [The range from -2 sd to +2 sd contains about 95% of all data. Even though the day-to-day changes of the S&P do not follow the statistical Normal distribution, any sample of 20 or more are almost certainly Normal. Refer to the Law of Large Numbers and the Central Limit Theorem.]

To get a system that has a t score of 2.0 requires that the expression (mean / stdev) * sqrt (N) is greater than 2.0. If mean / stdev is 0.25, then N must be greater than 64 — that is, the data must be the result of 64 trades. If mean / stdev is 1.0, then 5 trades are sufficient. Do not be mislead by discussions of trading systems that are reported to have t scores greater than 2.0 — they are almost certainly hypothetical, or at best in-sample. Any competent trader who has a system with a t score of 2.0 based on actual trades could buy Manhattan, even starting from a small account. If it trades frequently, that would happen very quickly.


Standard deviation in a single pass

Many applications, including Excel and AmiBroker, have built-in functions that compute the standard deviation of a series of numeric values. The definition of standard deviation is square root of variance, where variance is the average of the squared deviation of each element in the series from the mean. (The Mean is the first moment of the distribution of the series, and Variance is the second moment of the distribution of the series.) The most common formula for variance is
Var = summation for all elements [(x[i] – xbar)^2]
where x[i] is the ith element of the series and xbar is the mean of the series.
This is straight forward, but requires that the mean be known before computing the summation of squared deviations.

When the data points are being received or processed sequentially, it may be inconvenient or even impossible to make the two passes necessary to compute the mean before computing the summation of squared deviations. By using a little algebra, it is possible to compute the mean and variance in a single pass. The AmiBroker code for doing this is provided on the Standard deviation in a single pass static page.