StockFetcher Forums · Filter Exchange · Kevin's Sharpe Allocation<< >>Post Follow-up
davesaint86
510 posts
msg #135200
Ignore davesaint86
3/30/2017 11:40:39 AM

I think the strategy below is different from your Sharpe Ratio Allocation filter. Can the one below be built in SF?


For my SPY/TLT adaptive allocation strategy I tweaked the Sharpe formula a little bit. Normally the Sharpe ratio is calculated by Sharpe = rd/sd with rd=mean daily return and sd= standard deviation of daily returns. I don’t use the risk free rate, as I only use the Sharpe ratio to do a ranking. My algorithm uses the modified Sharpe formula Sharpe = rd/(sd^f) with f=volatility factor. The f factor allows me to change the importance of volatility.
If f=0, then sd^0=1 and the ranking algorithm will choose the composition with the highest performance without considering volatility.
If f=1, then I have the normal Sharpe formula.
If f>1, then I rather want to find SPY-TLT combinations with a low volatility. With high f values, the algorithm becomes a “minimum variance” or “minimum volatility” algorithm.
To get good results, the f factor should normally be higher than 1. This way you do not need to rebalance too much. In a whipsaw market, rebalancing also has the negative effect of selling low and buying high on small intermediate market corrections. This is why a system which considers only performance will not do well.
The good f factor for a system can be found by “walk forward” optimization iterations of your backtests. Normally a good value for f is about 2, but the factor changes slightly, adapting to the current market conditions.

SYMLIST(spy, tlt)
SET{perf1A, ma(3) 60 days ago}
SET{perf1b, MA(3) / perf1a}
SET{perf, perf1b - 1}
SET{var1, perf*100}
SET{rfr, ind(^irx,close)}
SET{RISKFREERETURN, rfr/100}
SET{perf63, perf - RISKFREERETURN}
SET{STD63, CSTDDEV(CLOSE,63)}
SET{VOL63a, STD63 / MA(63)}
SET{vol63, vol63a * 100}
/*CALCULATION OF SHARPE RATIO - ANNUALIZED*/
SET{SHARPE1a, perf63 / VOL63a}
set{sharpe, sharpe1a * 0.5}
set{var1a, IND(spy, var1)}
set{var1b, IND(tlt, var1)}
SET{RANK1A, COUNT(var1 is above var1a,1)}
SET{RANK1B, COUNT(var1 is above var1b,1)}
SET{RANK1C, RANK1A + RANK1B}
SET{RANK, 2 - RANK1C}
set{var2a, IND(spy, sharpe)}
set{var2b, IND(tlt, sharpe)}
SET{var3a, COUNT(var2a is above 0,1)}
SET{var3b, COUNT(var2b is above 0,1)}
SET{var4a, var2A * var3a}
SET{var4b, var2b * var3b}
set{var5a, var4a + var4b}
SET{allocation1, sharpe / var5a}
set{allocation2, allocation1 * count(sharpe above 0,1)}
set{allocation, allocation2 *100}


scvidar
77 posts
msg #135342
Ignore scvidar
4/8/2017 2:23:18 PM

I like it, thanks!!

StockFetcher Forums · Filter Exchange · Kevin's Sharpe Allocation<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2018 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus