Please read the disclaimer at the bottom of this page

Tuesday, August 7, 2007

Approximate Entropy

Many traders and investors prefer an equity curve as smooth as possible. It gives a sense of predictability, i.e. in our minds we extend the curve in the future and the smoother it is, the more confident we feel about our prediction. In many cases the Sharpe ratio is capable of summarizing the smoothness of the curve in a simple number, and the higher its absolute value, the smoother the curve.

Now, think about the Sharpe ratio of a sine wave for a moment...

Even though it's zero, we would be extremely happy to find a trading system with an equity curve represented by an exact sine wave. We would simply get into any open positions at the bottom of the wave and get out at the top, and repeat this over and over again for a huge profit.

Although this is an extreme example, it nicely shows that we might not only be interested in the smoothness of an equity curve, but also in the amount of randomness. I.e. it is possible that two systems have the same Sharpe ratios, while one system is less random than the other due to some much more subtle patterns not captured by the mean or standard deviation.

An interesting measure to quantify "randomness" in financial time series was published in the Proceedings of the National Academy of Sciences by Pincus and Kalman(*) about 3 years ago, based on a mathematical approach and formula called Approximate Entropy introduced in the early nineties by Pincus.

I won't go into all the details of this measure except for noting that it is rooted in the concept of information entropy developed by Shannon in 1948 as part of information theory (Wikipedia is a good first start for those who want to investigate further). Outside the world of finance, it has also found its application in the medical world (e.g. irregularity of heart rate). Approximate Entropy (ApEn) is a number, and the higher it is the more irregular (random) a time series. Thus, when applying ApEn to the daily returns of a C2 system, we would prefer a lower number over a higher number. ApEn requires 2 parameters: a block or run length (usually 1 or 2) and tolerance window (usually 20% of the standard deviation). In all figures below I use a block length of 1 and 20% of the standard deviation as tolerance windows, denoted as ApEn(1, 20% SD). The daily log-returns are used as inputs.

Over the entire history of a system, I got the following figures for the systems in my portfolio:
Trend Plays #1: 1.74
Weekend Trader: 1.95
ARS: 1.77

We can also do a rolling ApEn, estimated over 100 trading days:



This figure suggests that the equity curve of Trend Plays #1 has become more irregular (random) over time.



For Weekend Trader no such trend exists. Note that around the 400th trading day, ApEn was at its lowest point, suggesting relatively high regularity. This is reflected in the steady pattern of peaks and troughs in the equity curve during the preceding 100 trading days.



Finally, for ARS, we see yet a different curve. ApEn increased gradually over the past year, somewhat similar to what happened for Trend Plays #1.

These numbers and figures don't give an immediate clue how to improve returns and they also seem to be quite close across the systems. Pincus and Kalman show an example where a strong increase in ApEn preceded the Nov 1997 crash in the Hang Seng Index (HSI). I'll look for a C2 system that crashed and see if I can relate the crash to the system's ApEn in a future blog post.

(*) Pincus S, Kalman R E. Irregularity, volatility, risk, and financial market time series. Proceedings of the National Academy of Sciences 2004; 101(38): 13709-13714.

4 comments:

Anonymous said...

Hi Science Trader,
what a great blog!
I am especially fascinated to see the development of "alpha" over time for various C2 trading systems.
What is the simplest way to produce such a plot for my own system?
Did you suggest to MK to add such an analysis (alpha/beta) on the C2 server?

Science Trader said...

Hi Rene,
Thanks for your nice words! It's always good to see that the blog is informative. Calculating a rolling alpha basically involves the following steps:
1. Constructing an equity curve for your systems based on end-of-day closing equity.
2. Calculating the daily returns from this equity curve (Y)
3. Calculating daily returns for a benchmark of interest (X, e.g. S&P 500)
4. Regressing Y on X for the first k trading days (the resulting intercept of this regression is your first dot of the rolling alpha curve
5. Repeating step 4 for day 2 to day (k+1), day 3 to day (k+2) etc.

Step 1 is easiest by downloading the data from C2 (using the C2 data api), or writing your own code to construct an equity curve using exits and entries for your trades, together with historical end-of-date quotes for the stocks you traded (I do the latter)

Step 2 and 3 are straightforward.
Step 4 and 5 are easily realized in Excel or some statistical software package like Stata or R.

I'd be happy to send you a plot for Ruby NQ100M or other systems you have, if you e-mail me at sciencetrader@aol.com

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

Anonymous said...

[u][b]Xrumer[/b][/u]

[b]Xrumer SEO Professionals

As Xrumer experts, we have been using [url=http://www.xrumer-seo.com]Xrumer[/url] for a large time for the time being and know how to harness the titanic power of Xrumer and turn it into a Spondulix machine.

We also provender the cheapest prices on the market. Diverse competitors will charge 2x or temperate 3x and a lot of the opportunity 5x what we charge you. But we maintain in providing prominent help at a low affordable rate. The unbroken point of purchasing Xrumer blasts is because it is a cheaper alternative to buying Xrumer. So we aim to keep that bit in recollection and afford you with the cheapest standing possible.

Not simply do we be suffering with the unexcelled prices but our turnaround in the good old days b simultaneously for the treatment of your Xrumer posting is super fast. We intention secure your posting done before you discern it.

We also cater you with a roundish log of affluent posts on different forums. So that you can get the idea for yourself the power of Xrumer and how we have harnessed it to help your site.[/b]


[b]Search Engine Optimization

Using Xrumer you can trust to apprehend thousands upon thousands of backlinks over the extent of your site. Scads of the forums that your Install you intent be posted on get exalted PageRank. Having your tie-in on these sites can truly mitigate build up some top-grade grade help links and uncommonly aid your Alexa Rating and Google PageRank rating owing to the roof.

This is making your position more and more popular. And with this developing in celebrity as familiarly as PageRank you can expect to lead your place absolutely superiority gamy in those Search Locomotive Results.
Traffic

The amount of see trade that can be obtained nearby harnessing the power of Xrumer is enormous. You are publishing your site to tens of thousands of forums. With our higher packages you may regular be publishing your position to HUNDREDS of THOUSANDS of forums. Create 1 post on a in demand forum will by get 1000 or so views, with announce ' 100 of those people visiting your site. At once imagine tens of thousands of posts on popular forums all getting 1000 views each. Your freight ordain withdraw at the end of one's tether with the roof.

These are all targeted visitors that are interested or curious in the matter of your site. Imagine how divers sales or leads you can fulfil with this great loads of targeted visitors. You are in fact stumbling upon a goldmine bright to be picked and profited from.

Retain, Traffic is Money.
[/b]

BECOME ENTHUSIASTIC ABOUT YOUR CHEAPLY BLAST TODAY:


http://www.xrumer-seo.com