Trying to reproduce Sharpe Ratio Calculation
Author: edw9198
Creation Date: 6/25/2008 12:13 PM
profile picture

edw9198

#1
Hi!

I'm trying to reproduce the Sharpe Ratio calculation in WL. I know that there is a narrative description of this calculation in the manuals, but this description is incomplete. It doesn't, for example, specify whether "the number of days held per trade" is the number of CALENDAR days or the number of TRADING days.

I NEED FORMULAS OR CODE!!!
profile picture

Eugene

#2
Please no crossposting, thank you. Answered HERE.
profile picture

safwanvic

#3
Hi, I have been wondering about this as well. The link provided above does not seem to be working (clicking it directs me to the main page).

In WL user guide is says "The average return and average standard deviation are annualized by using the average number of days held per trade as a baseline." For the strategies I tested so far, however, the Sharpe Ratio from the standard Performance tab seems to perfectly correspond to the one which is based on the monthly returns (in the By Period tab).

Could you give the formulas or code, especially where/how the 'average number of days held per trade' is used in the equation? Many thanks.
profile picture

Eugene

#4
The link points to an area of the forum (WL4) that is no longer available.

For an example of Sharpe ratio calculation, log in to the Wiki and download the source code attachment:

Home - MS123 Visualizers

The code may not be actual but is still illustrative. The Sharpe routine is rooted somewhere in PerformanceEngine.cs. It's not equivalent to the built-in Wealth-Lab's Sharpe (which is annualized) - this version is monthly - but comes quite close.
profile picture

safwanvic

#5
Hi Eugene, thanks. Actually I understand that to annualize a Sharpe ratio using monthly returns one can multiply the numerator by 12, while the denominator is multiplied by SQRT(12). It will be the same rule for daily (e.g. using 252 days instead), weekly, etc.

But I don't quite understand why using the 'average number of days held per trade' (ANDPT) (for annualizing the Wealth-Lab Sharpe), the result is the same as the Sharpe using monthly returns? For instance, if the ANDPT is about 1 month, then we can use 12, and thus the result will be consistent with the MS123 ratio. But the ANDPT for a strategy may vary e.g. a few days or a few months. In that case, the annualization factor for Wealth-Lab Sharpe must be different, and the result should not be similar to the MS123 monthly Sharpe? However, it is the same.

It will be great if you could please show the equation on how the 'average number of days held per trade' is used in the built-in Wealth-Lab Sharpe ratio. Thanks again.
profile picture

Eugene

#6
Wealth-Lab is not an open source program. Consequently, the source code for the built-in tabs like Performance or By Period is not disclosed.
profile picture

safwanvic

#7
But is it possible for you to show a simple, illustrative equation only (and not the code itself)? For example, say the 'average number of days held per trade' is 57.2 days. Then what is the figure to SQRT, etc? Is the return based on the calendar period, or per trade basis? (Hopefully this one can be discussed or illustrated.)
profile picture

Cone

#8
'average number of days held per trade' is misleading or just plain wrong. The Sharpe calculation works only with the equity curve data, not trade data.

It's the [simple moving] average of the monthly percentage returns * 12 divided by the standard deviation of those returns, which is multiplied by Sqrt(12). i.e.,

avgAnnualReturn = SMA(monthly returns) * 12
stdDevAnnualReturns = StdDev(monthly returns) * Sqrt(12)

Sharpe = (avgAnnualReturn - CashReturnRate) / stdDevAnnualReturns
where CashReturnRate is the return rate for uninvested cash in preferences

Note: The monthly returns are calculated by calendar month, so the first monthly period could be less than 1 month.

profile picture

Cone

#9
WL's Sharpe ratio was originally (long ago) the "Sharpe ratio of trades", but was renovated several years ago in Wealth-Lab v5 to be the Sharpe ratio of returns. Unfortunately, the original description survived all this time, but I'll correct it for the next update. Thanks for pointing this out.
profile picture

safwanvic

#10
Glad to know that, thanks Cone.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).