A Simple Framework to Quantify your trading - Part.2
A Simple Framework to Quantify your trading - Part.2
Continuing from Part.1 where code was provided for a simple 3Day High-Low system, goes long after 3 days of lower lows and lower highs - and shorts in reverse.
Looking at basic stats - running the system on SPY over a 25 year period of end of day data (from roughly 1995 to today): note the winner percent at 72% - first indication that there could be something of interest here. Then the average pnl - about 44 bucks. This particular run is with 100% of account applied to this one strategy - so that does not indicate how many shares are traded per trade (its not fixed size per trade). We will look at that shortly.
Other thing to note is the average bars held - about 7 in the report below. To get a better understanding of this average we will have to look at the raw data and see how the days held is spread across the spectrum. You are better off with a low deviation from mean (always) - that gives you a better indication of when the exit is going to be even before you get into the trade.

Profit distribution as a histogram also shows how spread out the results of each trade would be. I would like to see a bell shaped curve generally clustered to the center and with thin tails - generally this type of a trade would suit better if you are an option seller betting on a range in general. If the system has the opposite characteristics, not that it would be un-interesting but the strategy of choice to trade it coming from a derivative perspective would need to be changed. In that case you will want to do more like buying premium for example, or strangely buying a condor instead of selling one, or selling a fly instead of buying one (with the many ways you can structure an option trade, the world is your playground).
Looking at some more stats, particularly note the Sharpe ratio of 0.54 for both shorts and longs. Nothing to write home about. But if you look at just the long trades - a shape of above 2. Pretty good compared to plain vanilla long the market which would probably give a shape of around 0.6-0.7 ish.
General note: generally even though we are looking at quite a large chunk of data over multiple bull and bear cycles, markets do generally have an upward bias and trading on the short side is generally much harder than the long side.
Another thing I like to see is the list of raw trades sorted by various metrics. For example, if you sort by percent pnl, I see that the break-even is reached in the top page of results with breakeven or positive results for most of the trades. This in addition to the histogram data above where the tails of the distribution were not significant, indicates a range-based trade might have some teeth for these entry and exit signals.
Now let's look at pnl again when only 1 share is traded. Average pnl of 0.59 cents per share. This should be important to a pure stock trader whether from a short-term perspective and commissions and slippage perspective, to decide if it makes sense in venturing to trade signals based on this system.
Now the trade count itself - this system when run on one ticket will give about only a handful (around 10) trades per year. Easy problem to fix - here is how it would look like on a basket of stocks (I just ran it on a basket of stocks I have data for. Start with a better set of tickers you would like to trade to get a better picture).
You also want to see the summary for each individual tickers within the list. It gives you an idea of whether the system is curve fitted to run on the one instrument you built the system with - a bad sign, or is it generic enough to work on a wider set of instruments. It indicates whether there is a fundamental/core reason why the system works or it's a fluke - an experiment in data mining.
Picture below indicates a run over the past 20 years again for all the tickers I have data collected on my machine sorted by shape ratio (please note that I made very little effort to see how much data I really have for each of these tickers. Just ran on all data - whatever is here - most possibly some of these tickers don't have data all the way back to 2000). Nice to note that most tickers show a decent pnl with decent enough sharpe ratios.
Note that we have only scratched the surface of system trading (i would like to think an important surface). There is much more to it - you can for example look at maximum favorable and adverse excursions, you could try optimizing some of the key parameters in the system (not that many in our example system) - but be careful, the more you optimize the more data mined your system can be. And the further away your real live trade pnl will be from the backtests.
You could also look at multi-dimensional plots for various metrics like pnl and sharpe ratios while varying key parameters of the system within certain ranges, trying to not pick local maximums. Again, it's better to not over-optimize the system but analyzing the system as such will give you a better understanding of how robust the system is for slight or larger variations/perturbations in the key parameters.
Plot below shows such a 3D visualization of a different system, where the key parameters space being studied are profit targets and hold days.
With that, I think I will wrap this post. Now that you have a good basis to entering and exiting trades - we can in the next part look at how to structure an option trade around the system entries and exits.
So until we meet next time.. adios.
Good Trading!
-Gariki