Archive

Archive for the ‘back-testing’ Category

multiverse

October 18th, 2007

turtles all the way down

There are many conceptions of our world and its underlying nature, each seemingly more creative than the last. One of my favorites – adopted by all serious fans of Star Trek as well as some physicists who’ve run rather far afoul of friar Occam’s good rule - posits the existence of a multiverse. There are various such stories, but the basic idea is that at every quanta in time the universe partitions itself off into an infinitude of parallel instances of itself, each representing a different branch of realized possibilities. In this one, I decided to become a surfer while in that one I went into finance and in that one I led the US to its first-ever world cup victory. While we only experience the particular universe we happen to be situated in, the multiverse represents the simultaneous execution of all possible universes. Under this view, we really do live in the best of all possible worlds.

This idea has surprising utility. While its cosmological implications might represent the extreme psychedelic fringe of the continuum, at the other ends lies actuarial science, the foundations of risk management and, yes, a variety of option pricing techniques.

Read more…

EMS Internals, back-testing, options pricing

A trading strategy is an option

October 10th, 2007

options, options, ...

The best way to reason about a trading strategy’s performance, that is valuing it, is as an option.

Or perhaps as a collection or portfolio of them.

I have to assume that people reading this have a working idea of what an option is, so I’m not going to provide definitions that can be readily found elsewhere. I will note that my favorite book on the trading of options is by Allen Jan Baird.

Let’s consider the three illustrative trading strategies we’ve looked at up until now. The trend-following strategy suffered many little losses and then enjoyed a big win. Sounds like buying options. The mean-reverting strategy made lots of little profits and then risked getting clobbered with a big loss. Sounds like someone who’s writing options. And the first strategy we looked at, the morning range breakout, had a payoff which looked like a long straddle or strangle where the break-evens were near the observed high and lows for the session (where we set our entry stops).

straddle payoff

Now, there’s obvious differences between the trading strategies’ payoff structures as compared to the similar options strategies. There’s no premium, for instance, and that’s clearly significant. The morning range breakout seems to exhibit a sort of knockout effect when a position has been entered but then the market reverses and you’re “knocked-out” of your position. You just take a loss and do not collect even if the market turns back in your direction. With a straddle you don’t have this behavior. There are differences and they are worth keeping in mind. But the reasons for viewing trading strategies as options portfolios are many and compelling.

The superficial reason, as I mentioned, is that the basic payout structures are potentially similar. The deep reason is that ultimately the problems are the same – how to value complex instruments with engineered payouts. And the pragmatic reason is that many many very smart people have applied their considerable brains and diverse skill-sets to advancing options pricing techniques. There’s also a great deal of high quality software available out there which can be used to adapt these time-proven techniques to your own algorithmic trading strategy valuations.

The techniques which we’ve seen up until now, back-testing and parameter optimization, are sort of weak cousins of a family of techniques long used for options pricing: Monte-Carlo (MC) methods. MC simulation can clearly be used to assess a trading strategy’s performance.

In subsequent posts, we’ll talk about some of the details of each of these techniques and about some of their respective trade-offs. That should keep my pump primed for a bit, but in the meanwhile I leave you with a parting inquiry: what other options pricing techniques might we apply to our algorithmic trading practices?

back-testing, books, monte-carlo methods, open-source software, options pricing, performance analysis, strategy development, technology

distribution

October 5th, 2007

misleading, eh?I’ll make a few more comments on the last strategy we looked at before we move on. Although I’ve panned it, it’s actually a nice strategy for consideration as it’s very simple to implement, efficient to run, has a plausible-ish sounding premise and can be permuted in many directions. It has the unfortunate characteristic of being a loser, but nothing is perfect. It might offset that characteristic by providing us with a means of seeing interesting phenomena or learning. For example, all of the futures exchanges I ran it against – ICE, CME and NYX performed very well. Might be something there. Or not. If we look at the distribution of the *best* performing of each of the 4 strategies we ran by instrument, we get a pretty clear picture:

gimme an R-...

Read more…

back-testing, books, performance analysis, strategy development

anatomy of a knockout

October 2nd, 2007

Contrary to what I’d written last time, I ran the test across some
1,190 equities yielding some 4,760 resultant strategies. Naturally,
when you look at a good number of cases like this, you’re going to
find some real doozies. Maybe there’s a good reason why some should
really yield above average returns with this strategy over some period of
time. I’ll leave that as the proverbial exercise for the reader…

If we look at some of the really good results like, say, this
humdinger for BID, we might think we’re onto something.

just look at dem curves

Read more…

back-testing, performance analysis, strategy development

Sucker punch! (an example)

September 26th, 2007

To illustrate what I was talking about last time, I introduce a simple example: the morning breakout strategy. Variations on this strategy have been discussed in a variety of sources from Perry Kaufman’s encyclopedic tome to a recent copy of Futures Magazine.

The rationale behind this strategy is based on the premise that the first n minutes of a trading session will frequently see the entire movement for the session and that thus breakouts from this range will prove to be decisive for the day. One can take this basic idea and create a bewildering array of strategies by adding pre-trade filters and all sorts of exits.

They all have the same basic feature: they’re losers.

Sucker punch!

We’ll stay simple and assume that our strategy will set stops at the observed max & min of the session after n minutes of the session have passed. At the end of the day, we’ll exit any position the strategy has
initiated. And for maximal simplicity (and perhaps some psychological sense of “safety”) we’ll allow the stops to stay in the market all day so they act as stop-losses for each other when positions are entered.

Thus our strategy has two optimizable parameters: what to trade and when to set the stops. The first is of type contract and the second is an integer. Finally, we have some fixed parameters (i.e., it doesn’t make sense to try to optimize them) denoting when the session starts and how much money to risk or how many shares or contracts to trade.

If we do a parameter optimization on this strategy using, say, the s&p 500 components as values for the first parameter and setting the n breakout range to values { 20, 40, 60, 80 } we end up with 500 X 4 distinct strategies which each get back-tested to produce our results.

In the next post, we’ll review the results and consider how to reason about them.

back-testing, books, performance analysis, strategy development

Fool’s gold

September 26th, 2007

One of the biggest issues facing algorithmic traders is recognizing and avoiding the data-mining / back-testing phenomenon of fool’s gold.

The problem is that the evidently improbable becomes incredibly less so when many instances are considered. One of the inevitable first reactions a would-be algorithmic trader has when first putting together a strategy and running it through a parameter-based optimizer is:

“I’m going to be rich!”

Fool's gold

“How could it be otherwise? There’s no way such an improbable result could indicate anything but that my strategy is predictive – I have placed my finger on one of those oft-mentioned market inefficiencies and thereby created a little money machine!”

Happily, ours is an experimental practice, so it’s quite easy to test our hypothesis and (assuming you have a reasonable environment in which your back-tested strategy can be placed – unchanged – onto some real financial exchange) place our money where our mouth is…

And this is where it gets tricky – because you might even make some money! Maybe a lot. But unless you’re really really lucky, at some point your fortunes will turn and that strategy which over the past n months has been a demonstrable goldmine will suddenly start misbehaving. Your elation will turn to confusion and then chagrin and then – for the obstinate – pain and horror.

What is going on here? How did we happy miners find ourselves grasping bitter buckets filled with fool’s gold? This will be the subject of our initial series of posts…

back-testing, performance analysis, strategy development