Portfolio Optimization

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
BARLI
Roundtable Knight
Roundtable Knight
Posts: 650
Joined: Sat Jan 17, 2004 6:01 pm
Location: USA

Portfolio Optimization

Post by BARLI »

[MODERATOR'S NOTE: The Subject has been changed to reflect the discussion that developed more closely.]

Forum Mgmnt, you once said that when you optimize, you usually do this on a portfolio and not on a single commodity. So my idea was to come to closer and more precise average results by optimizing each commodity seperately and then deriving the average of lets say 36 commodities (for fast and slow mov avgs). I immidately figured out that the results still would be not good because if we take Cotton 7/81 EMA crosses works good on it, while Bean Oil likes the combo of 12/142. From this 2 commodities we can see that the average of slow mov avgs 81 and 142: 112, wouldn't do good neaither for Cotton , nor for Bean Oil. Corn like 27/64. All tests run on 20 years of data. How do you solve such a problem?
Forum Mgmnt
Roundtable Knight
Roundtable Knight
Posts: 1842
Joined: Tue Apr 15, 2003 11:02 am
Contact:

Post by Forum Mgmnt »

Barli,

I don't think optimizing on single markets is a good idea. It represents curve fitting.

A method that works across many different markets over many years is much more likely to continue working across those markets.

It is very easy to come up with excellent results when optimizing one market. You just need to catch the few trends well. But how likely is it that the market will behave exactly the same?

The way I solve the "problem" you outline is to optimize using a single set of parameters across all markets.

- Forum Mgmnt
BARLI
Roundtable Knight
Roundtable Knight
Posts: 650
Joined: Sat Jan 17, 2004 6:01 pm
Location: USA

Post by BARLI »

doesn't it mean that you simply run an optimization on a portfolio of commodities? If that's the case then results are far from the truth, since optimization simulator would be taking trades according with the current signals generated and buying power left?
Forum Mgmnt
Roundtable Knight
Roundtable Knight
Posts: 1842
Joined: Tue Apr 15, 2003 11:02 am
Contact:

Post by Forum Mgmnt »

BARLI,

I'm not sure what you mean by "taking trades according with the current signals generated and buying power left", or how this would not represent the truth.
BARLI
Roundtable Knight
Roundtable Knight
Posts: 650
Joined: Sat Jan 17, 2004 6:01 pm
Location: USA

Post by BARLI »

how do you optimize on a portfolio? I run the optimization script on portfolio and it requests to indicate how much equity it should be run on and what risk percent so as I see it, according to those parameters it runs.
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

For those who trade as well as backtest, as the years roll by the lesson sinks in that backtesting, while useful (indeed essential) is only ever going to be a blunt instrument. A means of showing you broad, sweeping trends in profitability. A way of letting you make assumptions about how to proceed over the next few years based on what has transpired over the past few.

Just as optimisation on one particular counter makes no sense whatsoever, so does taking too much notice of anything but the broadest picture in a stepped parameter test over an entire portfolio. You learn to look for broad trends in profitability and its increase or decilne over given systems/parameters and portfolios and even then you recognise that when you come to review the same set in a few years time, it is likely that the goal posts will have shifted a little.

Take a look at past posts by some of the contributors to this forum. Trace back posts by those same traders in different forums over the years. Look at their proclamations then and compare it to their most recent thoughts. It is most instructive.

It also helps to answer the much asked question: if my bactested results are so good, how come no CTA has matched those results over the past 20 years?

Backtesting gives a static and idealised picture of the past. Some degree of curve fitting is always going to be present. Backtesting is life lived backwards and with hindsight. Life is, in reality, lived forward and is always going to be messy and to some degree muddled.

Living life forward teaches you to be careful about how you interpret a backtested picture of how you would LIKE to have traded over the past twenty years!
Old European
Roundtable Knight
Roundtable Knight
Posts: 144
Joined: Mon Apr 19, 2004 3:04 pm
Location: Old Europe

Post by Old European »

AFJ,

What you say is very very true.

The problem is that there is no real alternative for backtesting. It's the only thing one can do when researching a system. But indeed one better doesn't take the backtest results too literally (even after having invested lots of time and effort in research). And it is extremely important to manage one's own expectations. My personal performance goal for example when starting to real trade a thorougly researched system is to realize a MAR ratio that is 50% of the backtest MAR ratio. And I am well aware that for a long term trend following system, it will take at least 5 or even 10 years of patience, before I will know whether I'm going to reach this goal or not.

But I remain convinced that the whole research effort is more than worthwhile. Don't forget that there are several CTAs with outstanding track records that go back more than 10 year. They have MAR ratios of more than 1.5. They have been very decently renumerated for the risk they were prepared to accept.

Cheers,

Old European
Forum Mgmnt
Roundtable Knight
Roundtable Knight
Posts: 1842
Joined: Tue Apr 15, 2003 11:02 am
Contact:

Post by Forum Mgmnt »

BARLI,

I still don't understand the WealthLab-specific issue. Does it not let you run optimizations of parameter values over an entire portfolio at the same time?

I am attaching a simulation run from Trading Blox for the Dual MA system. This shows the results of running optimizations on a portfolio of liquid US markets over 25 years of data.

The optimization stepping is the Long MA from 25 to 50 in steps of 5 and the short MA from 4 to 20 in steps of 2.

There are 54 separate tests run. Each test uses the particular settings for the long MA and short MA for that test, i.e. it starts at 25 and 4, then 25 and 6, etc.

Those parameter values are used for each market in the portfolio and the test runs each day taking trades for all the markets so you can determine true portfolio-wide drawdowns, etc.

The results show that 35 long MA and 12 short MA system offers decent performance across all markets with a 46.9% return and a 43.7% drawdown. It also happens to be in the middle of the higher areas for both the attached parameter stepping graphs and in the middle of the higher area for the multi-parameter graph.

Since these values have been tested on the entire portfolio, I feel much more confident trading them than I would had they been optimized for only one market. It is clear that they work over a much broader variety of conditions.

I think it is instructive to look at the bands in the stepped parameter grapsh as these indicate all the data point values, the lower band is the worst test for that value the middle is the average and the pink band is one standard deviation up and down from the average.

I like this graph because it helps reinforce what AFJ said that you should not expect exact results but a range of values. This helps you set more realistic expectations. For example, from these tests I'd expect a strong possiblility of a MAR ratio in actual trading of as low as 0.6. instead of the 1.07 indicated for the parameter test.

Monte Carlo graphs also reinforce this idea. The future is a set of possible events with varying possibilities and a range of possible values. It is very unlikely you will do as well as the best test results would indicate.

I like to look at the bottom of the band and think that this might be what I get in actual trading. If you have enought spread in the other parameters this matches my historical experience pretty closely.

- Forum Mgmnt
Attachments
MultiParameter.png
MultiParameter.png (7.49 KiB) Viewed 20129 times
SteppedParameters_LMA.png
SteppedParameters_LMA.png (18.61 KiB) Viewed 20129 times
SteppedParameters_SMA.png
SteppedParameters_SMA.png (24.69 KiB) Viewed 20129 times
Forum Mgmnt
Roundtable Knight
Roundtable Knight
Posts: 1842
Joined: Tue Apr 15, 2003 11:02 am
Contact:

Post by Forum Mgmnt »

Section 6.4 of the WealthLab User's Guide 4.0 shows you how to do portfolio-level optimization BTW.

- Forum Mgmnt
RedRock
Roundtable Knight
Roundtable Knight
Posts: 944
Joined: Fri Jan 30, 2004 3:54 pm
Location: Arizona

Post by RedRock »

Barli,

Why not just set the starting capital high enough so that no trades would be dropped. Should eliminate your concern on missed trades skewing results. Good point btw. I suppose other trade limiters like a Min. volume filter could have a small influence as well.

rr
Last edited by RedRock on Thu Jul 20, 2006 2:04 am, edited 2 times in total.
Forum Mgmnt
Roundtable Knight
Roundtable Knight
Posts: 1842
Joined: Tue Apr 15, 2003 11:02 am
Contact:

Post by Forum Mgmnt »

How does WealthLab determine how much capital is required for futures trades? I assume it has some margin estimates on a per market basis somewhere.

When trading stocks there will be problems running out of cash but futures are much more highly leveraged so you don't run into this problem unless you run high risk percentages for fixed fractional betting or have very large portfolios.

So I don't think you will have the problem you are worried about unless you are looking at stocks.

- Forum Mgmnt
BARLI
Roundtable Knight
Roundtable Knight
Posts: 650
Joined: Sat Jan 17, 2004 6:01 pm
Location: USA

Post by BARLI »

yeah, it takes number of contracts according to the margin requirement. rr, I'll give it a try, but this method does not seem to be robust still, I believe there's something out there that's to be discovered yet about finding the best average for the entire portfolio.
RedRock
Roundtable Knight
Roundtable Knight
Posts: 944
Joined: Fri Jan 30, 2004 3:54 pm
Location: Arizona

Post by RedRock »

BARLI wrote: I believe there's something out there that's to be discovered yet about finding the best average for the entire portfolio.

One could set up a large set of tests to see if various portfolios walk forward better if they are optimized as a whole, or on a per instrument basis.

Adaptive indicators tuned using the dominant extracted cycle may be another venue to peruse.
Forum Mgmnt
Roundtable Knight
Roundtable Knight
Posts: 1842
Joined: Tue Apr 15, 2003 11:02 am
Contact:

Post by Forum Mgmnt »

This discussion is interesting because it revolves around one of the fundamental issues with backtesting in general: "the character of markets over time."

Some believe that various markets are different and should be treated as such.

While one could certainly find plenty of relatively short-term historical proof that certain markets are profitable for trading and others act diferently and are not good for trading particular styles, I think the reality is more complicated.

I believe that there are actually three classes of markets which behave distinctly differently:

1) Fundamental Driven Markets - These are markets like currencies and interest rates where the trading itself is not the primary force behind the movement. As time goes on this seems to be less and less true but I'd argue that the Fed or country-specific equivalent and a country's monetary policy still influence prices more than speculators. These markets have the greatest liquidity with the cleanest trends and are the easiest to trade.

2) Speculator Driven Markets - These are markets like stocks, futures such as coffee, gold, silver, crude oi, etc. where speculators influence the markets more than governments or large hedgers. The prices are perception driven. These markets are harder to trade.

3) Aggregated Derivative Markets - These are markets where the driving force is speculation but that speculation is diluted because the traded instruments are not what drives the price. A good example is the e-mini contract. It moves up and down but it's range is constrained by the underlying index which moves only indirectly because of speculators. It aggregates the purely speculative moves of many instruments so you get an averaging out and a dilution of momentum. These markets are the hardest ones to trade.

I think that markets in each of the classes behave the same. While you will certainly see periods, perhaps years even decades of differences, you will find that over the long run this is simply the reflection of trader memory and the relative rarity of underlying fundamental causes for large trends.

One good example is Gold and Silver. When I first started trading you couldn't make any money at all in Gold because the memory of the 1978 runup was still too fresh in people's heads. Everytime anything that looked like a runup started everyone and their brother would jump into Gold. This made it the price movements very choppy. It would run up and then run down and then run up and then run down again. In short, it was very hard to trade. Now 20 years later most people don't remember any more and so the recent move was much easier to trade than it had been earlier and if you looked at the charts you would say that Gold itself had changed its character.

My proposition is this:"markets within any of the above classes trade the same way." You should trade them or not according to liquidity and class only. As a Turtle I decided not to trade class 3 at all while many of the Turtles did trade index futures like the S&P. I decided not to because I felt our systems were not good for that market, not that you can't trade them, just that they just can't be traded as well with a breakout trend following system; so I didn't trade the S&P ever as a Turtle.

So I could see a justification for using different portfolio optimizations on the different classes perhaps but I don't think you can tell when Gold is going to change or when Cocoa is going to trend again. Just because it hasn't in the last 20 years does not make it a bad market to trade.

I remember in 1985 Rich told us we could no longer trade coffee. I think he felt it was too thin for how much he was getting chopped around. Later that year it ran up from 220 to 320. A perfect trend for our style.

I would have made 220% or $11 million on that single move the way we traded. It was an easy trend to ride because everyone had given up on coffee. My returns as a turtle would have been north of 140% per year had we not been told to stop trading coffee. I would have pehaps made Rich $100 million instead of $32 million. (See the below graph for a single unit's profit and remember that I traded 4 units) My personal take on that was 20% for 1985 so this cost me $2.2 million in incentive bonus.

So yes, I don't treat the markets differently. You can do what you wish but I advise you to have some well-thought-out rationale for doing so.

- Forum Mgmnt

NOTE: Edited to reflect error. I was trading $5,000,000 in 1985 not $2,000,000 the dollar amounts for the trade were higher and the percentage gain was lower.
Attachments
Coffee.gif
Coffee.gif (15.14 KiB) Viewed 19870 times
Last edited by Forum Mgmnt on Thu Jul 27, 2006 3:56 pm, edited 3 times in total.
daveineagan
Full Member
Full Member
Posts: 14
Joined: Mon Aug 30, 2004 11:44 am
Location: Minneapolis

Markets to trade

Post by daveineagan »

Forum Mgmnt,

just wanted to let you know how much I appreciate your posts. The above post regarding fundamental, specultator, and aggregated markets is an exteremely timely topic for me. This website has made a world of difference in how I view trading – in a very positive way. Thank you!! :D
Old European
Roundtable Knight
Roundtable Knight
Posts: 144
Joined: Mon Apr 19, 2004 3:04 pm
Location: Old Europe

Post by Old European »

Although I don't agree 100% with c.f.' market classification, I nevertheless agree completely that all markets (in the same category) should be treated the same way.

By doing so, one is better protected when the character of markets changes. And it is better for long term trend following to have a system that performs reasonably well over a long period of time than having a system that performs outstandingly over a short period of time and then breaks down completely. It's a question of robustness.

The way I usually look at this issue is the following.

My starting point is that I prefer to work with a long term system and a universe of about 30 futures markets that generate a few trades a week (without rolls) or about 100 trades a year (3000 trades over a period of 30 years or on average 100 trades per market over this period). Consider a typical triple moving average cross-over system that has 6 parameters or so. I usually use as a rule of thumb that one needs at least 250 trades for every parameter that one wants to optimize in order to avoid curve fitting and to get a result that is statistically significant. So a 6 parameter system requires at least 1500 trades or 15 markets that are treated the same way (exact same parameter values). To further build in some additional robustness I then trade 30 instead of 15 markets with this mechanical system.

To summarize, one needs easily 15 or even 30 markets treated exactly the same way, in order to generate enough statistics to come up with results that are meaningful and statistically significant.

Cheers,

Old European
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

In support of my contentions take a look at Salem Abraham's website. He now trades stock indices as part of his portfolio.

The disclosure documents of the trend following CTAs are littered with details of portfolio changes, system changes, bet size changes, parameter changes and so on.

As I say, real life is lived forwards and we all change our opinions and our strategies.
Forum Mgmnt
Roundtable Knight
Roundtable Knight
Posts: 1842
Joined: Tue Apr 15, 2003 11:02 am
Contact:

Post by Forum Mgmnt »

Leverage and asset-class issues aside, I think you'd be far better off trading sector ETFs, or two or three of the most liquid individual stocks as part of a trend-following portfolio rather than stock indices from a diversification perspective since they are much closer to speculative instruments.

Also on a really long-term perspective the indices trend fine. Unfortunately, the Turtle Systems were intermedate trend systems that did poorly and still do on indices.

- Forum Mgmnt
BARLI
Roundtable Knight
Roundtable Knight
Posts: 650
Joined: Sat Jan 17, 2004 6:01 pm
Location: USA

Post by BARLI »

Forum Mgmnt, that's an interesting story about 1985 trading of the turles. I remember when Rich was asked if he trades all markets same way, he said: " You can give me any market without letting me know what it is and I'll trade it same way". Interesting he didn't want Coffee in 1985, as you once said ( and in Original Turtles rules as I recall its all been mentioned) for Long Termers one missed trade can cost you a lot of money(of course it's a profitable one). So all signals should be taken. I agree with your classification, however not 100% just like Old European. Currencies and Interest rates have best trends, however energies also fit "good trends" group. Cocoa will never have good trends, as we saw it recently those who got into Cocoa Long would lose or simply break even in one day, same goes for Orange Juice I think.
One very important thing for a trader to learn is to clearly distinguish a trending period from non-trending one. Those who'll master that will always have good risk reward trades and confidence to stick with the trade, which is not an easy thing to do .
RedRock
Roundtable Knight
Roundtable Knight
Posts: 944
Joined: Fri Jan 30, 2004 3:54 pm
Location: Arizona

Post by RedRock »

Forum Mgmnt,

I am curious as to your thoughts on optimizing the same set of rules on a portfolio with different parameters for long and short entry and exit. Is this curve fitting, or do longs and shorts deserve different parameter sets?

Thanks,
rr
Post Reply