TRADING SYSTEMS
Using Least-Squares
Trading systems involve several components to make sure they perform as well as you would like them to. Here’s how you can apply these components using the least-squares cubic system.
Years ago, in a Stocks & Commodities article titled “The British Pound,Cubed,” I examined trading the British pound (BP) using a least-squares cubic polynomial to serve as a better proxy for the BP market trend. The cubic polynomial should respond faster to changes in the underlying trend and model the trend changes more accurately than the straight-line version. In that article, I used walk-forward optimization with an in-sample period of five years of daily prices and an out-of-sample (OOS) period of one year. I examined these in-sample and OOS periods:
In-Sample Period | Out-Of-Sample Period |
1/1/89 to 12/31/93 | 1/1/94 to 12/31/94 |
1/1/90 to 12/31/94 | 1/1/95 to 12/31/95 |
1/1/91 to 12/31/95 | 1/1/96 to 12/31/96 |
1/1/92 to 12/31/96 | 1/1/97 to 12/31/97 |
1/1/93 to 12/31/97 | 1/1/98 to 12/31/98 |
Computers were not as fast or powerful as they are today. In addition, the walk-forward software then was nowhere as sophisticated as it is now. Given today’s technology, I can bring the British pound cubed strategy up to date and use shorter in-sample and OOS periods so changing relationships in economic data and trading patterns in the currency world can be quickly mirrored in the in-sample data.
I will examine an in-sample period of one year of BP daily prices followed by an OOS period of three months of daily BP prices. Each walk-forward period will advance three months and I will examine 82 walk-forward in-sample and OOS periods from January 1, 1991, to June 30, 2012. In Figure 1, you see the 82 in-sample and OOS windows, the cubic strategy inputs, and the quarterly OOS profit/loss results using the performance metric filter I will describe.
The British pound (BP) is a major currency traded 24 hours per day, and most of the world’s largest banks make a two-sided market in the BP and its associated derivatives. Small traders, however, are constrained to trade the BP futures on the Chicago Mercantile Exchange (CME). While the CME BP futures trading volume is small compared to total worldwide bank and institutional trading volume, arbitrage keeps the future prices in line with the bigger markets.
Qtr # | In-Sample Dates | Out-Of-Sample Dates | osnp | ollt | odd | ont | avosnp | NetEq | pw | T | pup | pdn | pjup | pjdn |
1 | 1/1/91 to 12/31/91 | 1/1/92 to 3/31/92 | (5938) | -3525 | -7263 | 9 | (660) | (5938) | 3 | 28 | 0.4 | 0.6 | 0.4 | 0.4 |
2 | 4/1/91 to 3/31/92 | 4/1/92 to 6/30/92 | 6525 | -1513 | -2200 | 6 | 1088 | 587 | 3 | 28 | 0.8 | 0.8 | 0.2 | 0.8 |
3 | 7/1/91 to 6/30/92 | 7/1/92 to 9/30/92 | 22538 | -1750 | -4438 | 6 | 3756 | 23125 | 3 | 20 | 0.4 | 1.2 | 0.4 | 1 |
4 | 10/1/91 to 9/30/92 | 10/1/92 to 12/31/92 | 6738 | -4563 | -7575 | 6 | 1123 | 29863 | 3 | 60 | 0.6 | 0.4 | 0.2 | 0.2 |
5 | 1/1/92 to 12/31/92 | 1/1/93 to 3/31/93 | (1538) | -2438 | -5250 | 11 | (140) | 28325 | 3 | 20 | 0.6 | 1.2 | 0.6 | 0.8 |
6 | 4/1/92 to 3/31/93 | 4/1/93 to 6/30/93 | (513) | -2263 | -2263 | 6 | (86) | 27812 | 3 | 60 | 0.4 | 0.4 | 0.2 | 0.2 |
7 | 7/1/92 to 6/30/93 | 7/1/93 to 9/30/93 | (8700) | -3050 | -9538 | 12 | (725) | 19112 | 3 | 28 | 0.6 | 0.4 | 0.4 | 0.4 |
8 | 10/1/92 to 9/30/93 | 10/1/93 to 12/31/93 | (488) | -1225 | -3625 | 7 | (70) | 18624 | 3 | 28 | 0.4 | 1.2 | 0.4 | 1 |
9 | 1/1/93 to 12/31/93 | 1/1/94 to 3/31/94 | 1513 | -1000 | -1000 | 4 | 378 | 20137 | 3 | 44 | 0.6 | 0.4 | 0.2 | 0.2 |
10 | 4/1/93 to 3/31/94 | 4/1/94 to 6/30/94 | 3238 | -863 | -1025 | 5 | 648 | 23375 | 3 | 28 | 0.4 | 1 | 0.4 | 0.8 |
11 | 7/1/93 to 6/30/94 | 7/1/94 to 9/30/94 | (63) | -1038 | -1038 | 2 | (32) | 23312 | 3 | 56 | 0.4 | 1 | 0.2 | 0.8 |
12 | 10/1/93 to 9/30/94 | 10/1/94 to 12/31/94 | 6000 | 0 | 0 | 2 | 3000 | 29312 | 3 | 56 | 0.4 | 1 | 0.2 | 0.8 |
13 | 1/1/94 to 12/31/94 | 1/1/95 to 3/31/95 | (963) | -2038 | -2688 | 9 | (107) | 28349 | 3 | 20 | 0.4 | 0.8 | 0.4 | 0.6 |
14 | 4/1/94 to 3/31/95 | 4/1/95 to 6/30/95 | 2525 | -700 | -1350 | 7 | 361 | 30874 | 3 | 20 | 0.4 | 0.6 | 0.4 | 0.4 |
15 | 7/1/94 to 6/30/95 | 7/1/95 to 9/30/95 | 5438 | -613 | -1088 | 7 | 777 | 36312 | 3 | 20 | 0.4 | 0.6 | 0.4 | 0.4 |
16 | 10/1/94 to 9/30/95 | 10/1/95 to 12/31/95 | 1250 | -800 | -950 | 9 | 139 | 37562 | 3 | 20 | 1 | 0.6 | 0.2 | 0.4 |
17 | 1/1/95 to 12/31/95 | 1/1/96 to 3/31/96 | (2038) | -738 | -1300 | 3 | (679) | 35524 | 3 | 60 | 0.6 | 0.8 | 0.6 | 0.4 |
18 | 4/1/95 to 3/31/96 | 4/1/96 to 6/30/96 | (2125) | -1338 | -2125 | 3 | (708) | 33399 | 3 | 44 | 0.8 | 0.8 | 0.8 | 0.8 |
19 | 7/1/95 to 6/30/96 | 7/1/96 to 9/30/96 | (2013) | -1538 | -2488 | 4 | (503) | 31386 | 3 | 56 | 0.6 | 0.4 | 0.6 | 0.4 |
20 | 10/1/95 to 9/30/96 | 10/1/96 to 12/31/96 | 3138 | -1688 | -1688 | 10 | 314 | 34524 | 3 | 20 | 0.6 | 0.4 | 0.2 | 0.4 |
21 | 1/1/96 to 12/31/96 | 1/1/97 to 3/31/97 | 6038 | -1325 | -1475 | 6 | 1006 | 40562 | 3 | 24 | 0.6 | 0.4 | 0.6 | 0.2 |
22 | 4/1/96 to 3/31/97 | 4/1/97 to 6/30/97 | 425 | -738 | -2200 | 7 | 61 | 40987 | 3 | 24 | 0.4 | 0.4 | 0.2 | 0.2 |
23 | 7/1/96 to 6/30/97 | 7/1/97 to 9/30/97 | 2600 | -1738 | -2450 | 10 | 260 | 43587 | 3 | 24 | 0.4 | 0.4 | 0.2 | 0.2 |
24 | 10/1/96 to 9/30/97 | 10/1/97 to 12/31/97 | 4225 | -1125 | -2563 | 8 | 528 | 47812 | 3 | 24 | 0.4 | 0.4 | 0.2 | 0.4 |
25 | 1/1/97 to 12/31/97 | 1/1/98 to 3/31/98 | 1638 | -913 | -2538 | 8 | 205 | 49450 | 3 | 20 | 0.4 | 1.2 | 0.4 | 0.6 |
26 | 4/1/97 to 3/31/98 | 4/1/98 to 6/30/98 | 3900 | -1113 | -1113 | 8 | 488 | 53350 | 3 | 20 | 0.4 | 0.8 | 0.4 | 0.6 |
27 | 7/1/97 to 6/30/98 | 7/1/98 to 9/30/98 | 5500 | -1050 | -1050 | 5 | 1100 | 58850 | 3 | 28 | 1 | 0.4 | 0.6 | 0.2 |
28 | 10/1/97 to 9/30/98 | 10/1/98 to 12/31/98 | (1700) | -1775 | -2800 | 9 | (189) | 57150 | 3 | 28 | 0.6 | 0.4 | 0.2 | 0.2 |
29 | 1/1/98 to 12/31/98 | 1/1/99 to 3/31/99 | 2225 | -575 | -575 | 6 | 371 | 59375 | 3 | 28 | 1.2 | 0.4 | 0.6 | 0.2 |
30 | 4/1/98 to 3/31/99 | 4/1/99 to 6/30/99 | (2650) | -1750 | -3263 | 10 | (265) | 56725 | 3 | 24 | 0.4 | 0.4 | 0.4 | 0.2 |
31 | 7/1/98 to 6/30/99 | 7/1/99 to 9/30/99 | 5950 | 0 | 0 | 3 | 1983 | 62675 | 3 | 48 | 0.4 | 1 | 0.2 | 0.8 |
32 | 10/1/98 to 9/30/99 | 10/1/99 to 12/31/99 | (613) | -1163 | -1163 | 3 | (204) | 62062 | 3 | 48 | 1 | 1 | 0.4 | 0.6 |
33 | 1/1/99 to 12/31/99 | 1/1/00 to 3/31/00 | (288) | -1875 | -2325 | 5 | (58) | 61774 | 3 | 36 | 1.2 | 1 | 1 | 0.6 |
34 | 4/1/99 to 3/31/00 | 4/1/00 to 6/30/00 | 3488 | -1225 | -1225 | 3 | 1163 | 65262 | 3 | 56 | 0.6 | 0.8 | 0.6 | 0.4 |
35 | 7/1/99 to 6/30/00 | 7/1/00 to 9/30/00 | 2475 | -2913 | -2913 | 8 | 309 | 67737 | 3 | 20 | 0.4 | 1 | 0.2 | 1 |
36 | 10/1/99 to 9/30/00 | 10/1/00 to 12/31/00 | (2013) | -1750 | -7075 | 8 | (252) | 65724 | 3 | 20 | 0.6 | 1 | 0.2 | 1 |
37 | 1/1/00 to 12/31/00 | 1/1/01 to 3/31/01 | 1538 | -863 | -863 | 7 | 220 | 67262 | 3 | 20 | 0.8 | 1 | 0.2 | 1 |
38 | 4/1/00 to 3/31/01 | 4/1/01 to 6/30/01 | (2600) | -1750 | -5488 | 9 | (289) | 64662 | 3 | 20 | 1 | 0.6 | 0.6 | 0.4 |
39 | 7/1/00 to 6/30/01 | 7/1/01 to 9/30/01 | (963) | -2275 | -2275 | 2 | (482) | 63699 | 3 | 60 | 1.2 | 0.8 | 1 | 0.6 |
40 | 10/1/00 to 9/30/01 | 10/1/01 to 12/31/01 | (4338) | -1900 | -5238 | 10 | (434) | 59361 | 3 | 20 | 1.2 | 0.6 | 0.8 | 0.6 |
41 | 1/1/01 to 12/31/01 | 1/1/02 to 3/31/02 | 1050 | -413 | -650 | 3 | 350 | 60411 | 3 | 36 | 1 | 0.4 | 1 | 0.2 |
42 | 4/1/01 to 3/31/02 | 4/1/02 to 6/30/02 | 4738 | -925 | -925 | 2 | 2369 | 65149 | 3 | 40 | 1 | 1 | 1 | 1 |
FIGURE 1: WALK-FORWARD OUT-OF-SAMPLE PERFORMANCE SUMMARY FOR BP CUBIC STRATEGY (DAILY BARS JANUARY 1, 1991–JUNE 30, 2012). The strategy input values degree (pw), N, pup, pdn, pjup, pjdn are the values found from applying the filter to the in-sample section and applying the strategy inputs found in the out-of-sample section.