Optimization 101 Rev A
Optimization 101 Rev A
Bruce Robinson
[email protected]
October 8, 2005
Presentation Overview
Mechanical systems and modeling
Fitness – what is it and what are the possibilities
Back-fitting as a loaded gun – what are the issues and
pitfalls
Near-optimal solutions and a high level overview of how
its done
Walk-forward methodology
--- BREAK ---
Mechanics of the IO optimizer
Three functions
Detailed example of back-fitted optimization
Sensitivity analysis and how it predicts robustness - with
example
Detailed example of walk-forward optimization, and use of
sensitivity analysis
How to use it in your trading – some guidelines
Presentation Goal -
System vs. discretionary
trading
“Dad – are all stops signs like mandatory, or are
some just like recommended?”
There are successful mechanical traders and
successful discretionary traders
Both back-test, although differently, and over
different time periods
Discretionary traders use the “computer
between their ears”
Discretionary traders tend to factor in more
complex patterns, but don’t take all signals
Mechanical traders must take all signals to
achieve expected results – but most don’t take
Discretionary traders
Discretionary traders process –
Patterns they articulate
Patterns that they do not, OR can not
articulate
Patterns may involve price action
alone, or other information such as
markets, sectors, age of move, etc.
Fall into two categories
Setups
Projections of future effects
Mechanical system
traders
Rationale
Mechanical system can be back-tested
In theory, it removes emotions from trading
Modern T/A programs have made
development much easier
There are a number of traps waiting for a
developer of trading systems
Back-fitting is one of the worst !
Most system traders will exercise
discretion thinking that they can improve
on results
Why do we model, backtest, and
optimize -
Model
To define an “edge” in timing, selection, money
management
A model approximates history
Are we modeling an underlying crowd behavior, or
a statistical relationship with no cause and effect ?
Storks nesting in post-WWII Copenhagen -> birth
rate
Accuracy is required, but not exactness
Back-test
To verify that edge, know the odd’s
To test across different markets
To provide confidence going forward
Optimize
To maximize or minimize those factors that are
most important
CAR, MDD, Sharpe, UPI, etc.
What is fitness?
We have to decide on what we are going
to optimize on
It can be a single measure, or a weighted
combination of measures
Some typical candidates
CAR – compounded annual return
CAR / MDD
UPI - Ulcer Performance Index – penalize net.
volatility only
Sharpe ratio – neg. volatility will follow pos.
volatility
Combination measures
Fitness = CAR / Trades ^ 0.5 / MDD ^ 2 / UI ^ 0.5
Risk adjusted measures will often need
Trading System Mining
Pitfalls-
“A fossicker is one who
searches
(unsystematically) for any
object by which to make
gain - to dig - to hunt - to
bustle about - or to
rummage... “
Back-fitting to history
usually yields negative
surprises
Back-testing
???
BACKTEST AND
OPTIMIZE
Selection bias
AI optimization -
AI optimization offers many new
capabilities
To date we have fitted as much data as
possible and “hoped”
Mechanization is one of the most
important capabilities
Eliminates biases - selection, event knowledge,
etc.
Less sensitive solutions can be found for a
point in time
We can “time travel” to points in the past
and look at walk forward performance
A “spliced” equity curve can be assembled
to look at what would have happened if
Keywords –
Near optimal
Robust
Out of sample, walk-forward
Many of these concepts were
pioneered by Rober Pardo
Near optimality -
Robustness -
Rolling walk forward
testing
Days in
drawdown
Equity &
signals
Regressi
on line
Reference
Current ticker
drawdown
Parameter sensitivity
distribution -
Report of traditional
backtest -
1 year walk forward
optimization -
Walk forward vs. traditional
from 2000 -
Walk forward vs. traditional
from 1996 -
Comparison of walk-forward to
traditional -
Primary difference is that the 2003
run-up was not captured by the walk-
forward
Walk-forward actually did better in
2000, and 1997-1998
The traditional back-fit must make
compromises to handle all periods
But the walk-forward is more
sensitive to changes in the early
years
Note differences in number of trades
Additional IO
functionality -
Perform sensitivity testing on a given
system
Invoke IO from the command line and run
batch directive files
Process user defined metrics
Turn off sensitivity testing of individual
variables
Optimization of groups of variables
Walk forward on every signal
Many more options that are documented in
the IO.DOC file
How to use in your
trading -
Model your trading ideas
Don’t incorporate hidden fixed assumptions/filters
FilteredEMA example is a stop and reverse system
A system that went flat might allow for better filters and signals
with less retracement
Utilize Optimize() statements for all system parameters –
not just indicator parameters
For example - PositionSize, WorstRankHeld, ApplyStops, etc.
Perform IS (in sample) over several types of markets
Perform a walk-forward analysis
Now, there is no reason not to – we no longer have to fit and
hope
Use a problematic period – for example, 2001-2002
Use common sense –
Don’t re-optimize too frequently
Don’t have short look-back periods
Expect to iterate your model
Look at it as improving your odds for success
Conclusions -
The example used was a teaching example, not a
practical system
IO allows optimization of previously intractable
systems
But, it’s value is in allowing walk forward
optimization of any system
This allows you to see how a system would have
performed in the past
It allows you to see how it may perform in the
future and to assess its stability
You may find results you didn’t want to find
Some high performance systems may not walk forward
well
But, others will
“ The future ain't what it used to be “ – Yogi Berra
Remember, it is like going …
IO -
Questions and Answers
Preview of Optimization
201 -
Knowledge of AFL programming will be needed
Construction and optimization of timing signals
Level vs. state
Using IO to turn signal components on and off
Explore which components add value
Optimization of ticker selection and weights
Assess portfolio mix
IO optimization of rotational systems
Special case of rotational system = walk-forward system
Selecting look-back and walk-forward periods
Fine-tuning the directives and options
Minimizing run time
Design patterns
Why system design is partly a science and partly
an art