Archive

Archive for the ‘performance analysis’ Category

Inverting Stupid

January 22nd, 2008

I can vouch for this

Honda made a clever marketing campaign based on the old motorcycling insight that “Stupid hurts.” Like many keen observations, it’s applicable in many domains including trading and algorithm development. As a seasoned practitioner recently quipped to me: “The opposite of artificial intelligence is genuine stupidity.” If you’re trying to write smart systems, it may be worthwhile to spend some time reflecting on stupid.

I’ve recently had the opportunity to work with a brilliant mathematician. One of the first techniques he wanted to apply to our strategy development process is the mathematician’s old trick of inversion – instead of being clever and looking for smart algorithms, let’s see if we can happen across a dumb algorithm and invert it! This is a sound idea, but experience with algorithmic trading yields the unhappy result:

The opposite of stupid is not (necessarily) smart.

Read more…

performance analysis, strategy development

Engineering Randomness

January 6th, 2008


It turns out that one can actually sculpt or engineer randomness. Further, this ability can shed remarkable light on otherwise mysterious phenomena – like the value of an option or the performance of a complex trading strategy. The applet above is governed by the equation (for Geometric Brownian Motion) below. It provides you with the ability to produce a random stream with three modifiable characteristics: an initial value (in this case fixed at 100), volatility (or ‘diffusion’) and expected return (or ‘drift’ or slope). Every five seconds it will generate a new path based on the current settings. path generator Hopefully, this applet provides a little insight into the machinery of a powerful algorithmic trading tool: monte-carlo methods. Read more…

EMS Internals, monte-carlo methods, open-source software, performance analysis

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

redistribution

October 7th, 2007

redistribution The behaviour of the two strategies we described last time are easy to describe intuitively and they are furthermore in-line with what one might expect from mean-reverting and trend-following strategies.

A mean reverting strategy will tend to make many, reasonably frequent, constrained-size successful trades and then suffer a big loser.

A trend-following strategy will tend to suffer many, reasonably frequent, constrained-size losses and then celebrate a home run.

The two strategies we described last time have these characteristics and the only constraint we’ve put on them wrt to their big loser/winner event is that they’re both deployed with day-trading schedulers so that they start trading at a fixed time in the morning and flatten themselves at some fixed time later in the day. The same basic characteristics would emerge for other such fixed periods of time as well.

Read more…

performance analysis, strategy development

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