- ago
In building blocks using the Transaction Weight block, how can I weigh by Sharpe Ratio? I didn't find an indicator that seem to be the Sharpe Ratio but probably missed it.
0
416
Solved
8 Replies

Reply

Bookmark

Sort
- ago
#1
You haven't missed it because there's never been a Sharpe ratio indicator. However, it occurred to me that one could probably assemble it with nested Transformer indicators (MathIndOpInd), accepting the built-in USTYield and PowerPack's Gain indicators like this?

CODE:
((Gain(History) - USTYield) / StdDev of Gain)
0
Glitch8
 ( 9.28% )
- ago
#2
I think you'd want to use AnnualizedReturn of the strategy equity curve, not Gain.
0
- ago
#3
So is the Gain indicator simply showing the buy-and-hold equity curve; whereas, the AnnualizedReturn (i.e. APR) is showing the "gain" as a result of the strategy trading over time?

Obviously, the APR won't be available until the backtest is over (BacktestComplete{...}) unless we are talking about computing a "running" APR based on the most recent past trades. Would one really want to steer their trading on the most recent couple of trades? (... say to compute a incomplete, partial Sharpe Ratio?)

You could write the "real" and complete Sharpe Ratio to disk in BacktestComplete, then read that disk file into the strategy constructor on the next run for trading. I think the easiest solution, however, is the printout the real Sharpe Ratio for each stock, then manually create a hand-picked best-Sharpe-Ratio dataset and trade from that.

I hand pick my datasets too, but not by Sharpe Ratio.
0
- ago
#4
I agree your approach would work best for building a dataset. However, here is what I'm trying to do. I have a dataset of sector and industry ETFs. I want to back test over 10 years. Each month, I want to rotate into the top 3 based on 20 day ROC. To do this I set the ROC into the transaction weight. However, instead of using ROC, I wanted to use the Sharpe Ratio. So, I am assuming, I would generate a Sharpe Ratio based on the last 20 days then set that into the transaction weight. I don't think it even needs to be annualized for this example. The Sharpe Ratio will change each month assuming 20 day of return.
0
Glitch8
 ( 9.28% )
- ago
#5
You can use MathIndOpInd like Eugene suggested.

The 1-bar return is ROC(1).
So you need SMA(ROC(1)) / StdDev(ROC(1))

Use the IndOnInd indicator to obtain the two terms within MathIndOpInd:

0
Best Answer
- ago
#6
I like the solution in Reply# 5 assuming you're taking the StdDev over 20 or more days. The problem with using the Sharpe Ratio is that it requires trading, and there's unlikely enough trades (especially for ETFs) to get enough trading cases over 20 days to even estimate a valid StdDev in the first place.

I appreciate you would like to factor in the behavior of the strategy (via trading and its success or failure), so you picked the Sharpe Ratio. But each Sharpe Ratio calculation needs to be based from a minimum of 5 trades, which you're not going to have over 20 days. And with so few trades, maybe dividing by the Standard Error instead of the Standard Deviation may make more sense. When we divide by the StdDev, we kind of assume about 15 trades or more.

But cherry picking a special dataset for higher Sharpe Ratio (say over a year or so) to reduce your risk makes sense to me.
1
Glitch8
 ( 9.28% )
- ago
#7
The intent is to base this on the performance of the ETFs themselves not any trading off them.
0
- ago
#8
Glitch is correct. Looking for sharpe on the ETF, not the trade.
0

Reply

Bookmark

Sort