UnThreaded | Threaded | Whole Thread (7) | Ignore Thread Prev Thread | Next Thread
Author: DrBob2 Big funky green star, 20000 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: of 250360  
Subject: ER hedge Date: 10/1/2012 12:11 PM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 18
In his encyclopedic book, Trading Systems and Methods, Perry Kaufman introduces his efficiency ratio, ER, also called fractal efficiency. It is the absolute value of the price change over n periods divided by the sum of the absolute price change for each period. It has value of 1 when prices have moved in the same direction for each period. When prices move in opposite swings during the n periods the ER approaches zero. Kaufman uses the ER to calculate an adaptive moving average based on the trendiness of the market.

Having a collection of monthly SIPro data disks I looked at a monthly ER based on monthly price moves over the last nine months. Thus my ER is

ABS(Price-Price M010)/[ABS(Price-Price M002)+ABS(Price M002-Price M003)+ .... +ABS(Price M009-Price M010)]

In general, a final sort by 4wk return is unstable, sometimes mean-reverting and other times not. I looked at a 4wk sort for stocks with high ERs and low ERs to see if there was a predictive ability. In general, a low ER with a high 4-week sort made a good short screen, and a high ER with a 4-week sort made a decent long screen, albeit volatile.

We thus have the makings of an ER hedge. The long screen is

Price > 5
Price * Volume--Average Daily 10d > 500
ADR/ADS Stock = False
Exchange <> Over the Counter
Industry <> 0721-Misc.FinancialServices

Price M010 > 0

Create [EffRatio]: ABS([SI Price]-[SI Price M010]) / (ABS([SI Price]-[SI Price M002]) + ABS([SI Price M002]-[SI Price M003]) + ABS([SI Price M003]-[SI Price M004]) + ABS([SI Price M004]-[SI Price M005]) + ABS([SI Price M005]-[SI Price M006]) + ABS([SI Price M006]-[SI Price M007]) + ABS([SI Price M007]-[SI Price M008]) + ABS([SI Price M008]-[SI Price M009]) + ABS([SI Price M009]-[SI Price M010]))

EffRatio < 0.9
EffRatio >= 0.7

Sort Descending Price Change 4 week

And the short screen is the same except that

EffRatio < 0.2
EffRatio >= 0

The results for the long and short screens up to 2003 can be found in Keelix jobs 312341 and 312342. Early in 2003 the Keelix backtester switched to weekly data and a 4-week hold rather than monthly. Thus the dates began to drift and introduce a lag. The results from 2003 on are based on monthly data disks.

So, how has the hedge performed over the last 14 years? Not bad, considering most hedges are lucky to yield a CAGR of 10%. (Well, actually any method that yields 10% a year has beaten the S&P500 by 6 percentage points and done quite well.)

The results for a monthly hold of five long stocks and five short; the only disappointing year was 2006.

Hedge S&P500
CAGR 26% 4%
GSD 27 20
Ratio 0.96 0.20
.
1997 38% (4 months)
1998 72
1999 18
2000 82
2001 38
2002 41
2003 27
2004 27
2005 70
2006 -24
2007 8
2008 - 3
2009 50
2010 - 2
2011 3

For someone with facility with Robbie's GTR1 backtester, it would be very interesting to see this approach tested with daily data and different look-back periods.

DB2
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Print the post Back To Top
Author: ww4321 Big red star, 1000 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: 239751 of 250360
Subject: Re: ER hedge Date: 10/1/2012 2:32 PM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 0
what are the current stocks on this screen?

Print the post Back To Top
Author: DrBob2 Big funky green star, 20000 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: 239775 of 250360
Subject: Re: ER hedge Date: 10/4/2012 7:14 AM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 1
What are the current stocks on this screen?

ER long
LEDR NIHD GNMK CBB SPNC

ER short
UDRL VTNC ROSG ENOC HALO

DB2

Print the post Back To Top
Author: rgearyiii Three stars, 500 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: 239782 of 250360
Subject: Re: ER hedge Date: 10/4/2012 4:31 PM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 27
In light of all the re-coding I've been doing lately, I can't say for certain whether I've torpedoed DrBob2's blend or his blend has torpedoed my backtester (or I've just misinterpreted something), but taking my backtester's results at face value, the blend seems pretty well sunk.

The screens don't actually require any SI Pro data, so they can be tested from when Nasdaq started reporting daily volume in early 1983.

I could have constructed a formula for Efficiency Ratio out of monthly g-prices using the functions gprc, abs and linear (and that may be a good way for a highly motivated user to check what I've done) the way DrBob2 did in RadiScript, but it was probably faster to just whip up a dedicated Efficiency Ratio function within the backtester itself. I've added the field function er, which takes three parameterizable arguments like the functions beta, xret, vol and gsd. The first is lag, the second is number of periods, and the third is the length of periods in market days.

Here is my construction of the long screen:

http://backtest.org/gtr1/2011/?aprc%281%29gt5:product%28av63...
Translation:
Create [ER]: [Efficiency Ratio of 21-day g-price changes over 10 periods; lag=1 days]
step0: [Actual closing Price; share_lag=1 days; quote_lag=1 days] > 5
step1: [[Actual Average daily Vol 63d; lag=1 days]*[Actual closing Price; share_lag=1 days; quote_lag=1 days]] > 500000
step2: [Security Type] != 30,31,36
step3: [Fama/French Industry Code] != 48
step4: [mkt Days Since Investment Opened for purchase] > 210
step5: [ER] >= 0.7
step6: [ER] < 0.9
step7: [Total Return Multiplier over 20 days; lag=1 days] Top 5; Long, Cash When Fewer
Holding period = 20 mkt days; Fully rebalance every 1 periods

step2 eliminates ADRs and step3 eliminates the miscellaneous financial stocks.

The screen to be shorted is this:
http://backtest.org/gtr1/2011/?aprc%281%29gt5:product%28av63...

Neither Keelix nor DrBob2 are explicit about the weighting of long, short and cash positions in blends, but I've assumed 1 part long, -1 part short and 2 parts cash in the blend:
http://backtest.org/gtr1/2011/blend.cgi?-1:aprc(1)gt5:produc...

The results for 19830131 through yesterday are as follows:

                 Avg      Min      Max       SD
CAGR: 11.50 6.61 15.67 2.66
TR: 3017.96 564.79 7321.46 1972.49
GSD(20): 24.54 22.52 26.15 1.16
DD(20): 15.63 13.48 18.37 1.32
MDD: -54.87 -81.67 -43.50 10.39
UI(20): 19.14 10.97 35.91 5.65
Sharpe(20): 0.42 0.22 0.59 0.11
Beta(20): -0.14 -0.24 -0.03 0.06
TI(20): -83.97 -342.36 -25.35 67.08
AT: 12.13 12.04 12.20 0.04


I might as well reveal a new feature of the backtester: Putting -picks in the miscellaneous options box causes the backtester to run in screening mode, revealing the stock selections and all field values on the last market date of the backtest. Currently, only screens that do not use VL, VL+, SI Pro or WER data can reveal their screen selections, but conveniently, the screens above do not use any of this data. (All of the data that is currently displayed can be obtained from free sources online.) Here is a temporary direct link to the screening results for the long screen: http://backtest.org/gtr1/2011/csv/vmmnucstfo.csv

Thus, I encourage people to check my backtester's calculations of Efficiency Ratio and other price/volume-based metrics against what you come up with using your own data.

Robbie Geary

PS I'm working on a system for allowing VL, VL+ and SI Pro screening only for users who can prove they are subscribers by uploading the latest installation files. If the uploaded file matches what's on the server, then their browser gets a cookie that allows them to screen on that data until the next week's update. If there are any CGI Perl programmers who would like to help with this in the next week, send me an email.

Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Print the post Back To Top
Author: musselmant Three stars, 500 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: 239783 of 250360
Subject: Re: ER hedge Date: 10/4/2012 6:15 PM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 0
I tried the "-picks" command but get "The following lists all stocks eligible at step9, sorted in ascendingdescending order by field4, as of 20121003"

even though the screen I used uses no fields. What, if anything, can I do to get the picks for the last step of a screen, by the criterion of such last step?

Print the post Back To Top
Author: rgearyiii Three stars, 500 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: 239784 of 250360
Subject: Re: ER hedge Date: 10/4/2012 7:01 PM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 5
I tried the "-picks" command but get "The following lists all stocks eligible at step9, sorted in ascendingdescending order by field4, as of 20121003"

even though the screen I used uses no fields. What, if anything, can I do to get the picks for the last step of a screen, by the criterion of such last step?


Without a link, I can only guess what you were doing, but looking at the command logs, it sounds like what you ran produced one of these two results:

http://backtest.org/gtr1/2011/csv/f5nsspi9rd.csv
http://backtest.org/gtr1/2011/csv/lh2gpx0cin.csv

In both cases, you've used 8 fields (field0 through field7), with the final sort on field4, which is defined as tr(0,5). You defined 10 steps (step0 through step9). The list of 5,406 stocks that you see (in the second file) all passed the second to last step, step8, and they are sorted in ascending order (I've corrected the bug that produced that typo "ascendingdescending") by field 4, tr(0,5), in preparation for the last step, step9. If you're only interested in the bottom 5 by tr(0,5), then only look at the first 5 stocks in the list. But in case you were interested in more than 5, the backtester shows you everything that was eligible at the final step.

Robbie Geary

Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Print the post Back To Top
Author: musselmant Three stars, 500 posts Old School Fool Add to my Favorite Fools Ignore this person (you won't see their posts anymore) Number: 239788 of 250360
Subject: Re: ER hedge Date: 10/4/2012 8:15 PM
Post New | Post Reply | Reply Later | Create Poll . Report this Post | Recommend it!
Recommendations: 0
thanks.
I was confused by the use of the word "field" for "step".

Great addition!

Print the post Back To Top
UnThreaded | Threaded | Whole Thread (7) | Ignore Thread Prev Thread | Next Thread
Advertisement