[R-SIG-Finance] Sullivan, Timmerman and White 1999: TA rules, and R

Brian G. Peterson brian at braverock.com
Tue Mar 29 13:50:39 CEST 2011

On 03/28/2011 04:33 PM, Worik wrote:
> [Apologies if I have sent this multiple times. I have been struggling
> with SMTP sewrvers and I have not seen my message appear on the list]
> Friends
> I am trying to save myself some tedious work.
> I am processing a paper from "The Journal Of Finance * Vol. LIV, No. 5
> October 1999" by Sullivan, Timmerman and White. "Data-Snooping,
> Technical Trading Rule Performance, and the Bootstrap"
> I am aiming to reproduce their results using the same TA rules as they
> used.
> They describe the rules they use in English and I am in the process of
> trying to programme them into R. But if some one has already done this
> it would save me a pile of work.
> It would be nice to just grab some rules from the TTR package, but
> because of the way STW describe the rules it is quite a lot of work to
> calculate what parameters to use.
> So I am clutching at a straw here: If anybody could point me in a better
> direction than slogging through the English text and trying to match
> that with the TTR docs I would be grateful
> cheers
> Worik
> PS Here is an example of their text. Not that it is bad, just quite a
> bit of work....
> A. Filter Rules
> Filter rules are used in Alexander (1961) to assess the efficiency of stock
> price movements. Fama and Blume (1966) explain the standard filter rule:
> An x per cent filter is defined as follows: If the daily closing price of a
> particular security moves up at least x per cent, buy and hold the se-
> curity until its price moves down at least x per cent from a subsequent
> high, at which time simultaneously sell and go short. The short position
> is maintained until the daily closing price rises at least x per cent above
> a subsequent low at which time one covers and buys. Moves less than x
> per cent in either direction are ignored. (p. 227)
> The first item of consideration is how to define subsequent lows and highs.
> We will do this in two ways. As the above excerpt suggests, a subsequent
> high is the highest closing price achieved while holding a particular long
> position. Likewise, a subsequent low is the lowest closing price achieved
> while holding a particular short position. Alternatively, a low (high)
> can be defined as the most recent closing
> price that is less (greater) than the e
> previous closing prices. Next, we will expand the universe of filter
> rules by allowing a neutral position to be imposed.
> This is accomplished by liquidating a long position when
> the price decreases y percent from the previous
> high, and covering a short position when the price increases y percent from
> the previous low. Following BLL, we also consider holding a given long or
> short position for a prespecified number of days, c, effectively
> ignoring all other signals generated during that time.

I've read this paper, though it's been quite a while, and considered 
replicating parts of it.  I don't recall there being anything there that 
would really be taken out of TTR though.  As I recall, and as your 
example shows, the paper is really more concerned with pattern 
recognition and then having simple entry/exit signals and rules.  I 
would probably use quantstrat to program each signal/rule pair.

Again, assuming my recollection of the paper is correct, you would not 
need any indicators (which is predominantly what TTR provides), but 
rather need to construct signal generating procedures for entry and 
exit.  For the example above, you'd need to convert the price series 
into a return series as well, and I think this is your only 'indicator' 
(i.e. transformation of the data required before you may generate signals).

So, for example, you would use the signal generator functions 
sigCrossover sigThreshold, sigPeak, and maybe sigFormula to generate 
your entry and exit signals.  Then, rule generation for entry and exit 
rules proceeds as normal using ruleSignal.


    - Brian

Brian G. Peterson
Ph: 773-459-4973
IM: bgpbraverock

More information about the R-SIG-Finance mailing list