pptx - R/Finance

advertisement
Trader's DFA
Marc Wildi - Statistician and Economist
Kent Hoxsey - Programmer and Trader
A Practioner's Introduction
to the Direct Filter Approach
Signalextraction
• Noise
• Filter
• Signal
Signal
X t  Noisy Data:
Financial (stocks), macro (GDP)
Filter: a set of weights  k such that
Yt 


k 
k
X t k
is `free of noise'
Yt is the Signal
For example a Trend (Momentum)
Eurostoxx50, MA(200) Equal-Weights
(Faber 2009)
Real-Time Signalextraction
Idealized Trend:
YT 


k 
k
X T  k  `senses' the future (XT 1 , XT  2 ,...)
vs.
Real-Time Finite Sample Estimate
T 1
YˆT   ˆk X T  k
k 0
Eurostoxx50, MA(200) Symmetric and
MA(200) Real-Time
Real-Time Perspective
• Turning-points (trades) are delayed
o Performances affected
• Delay could be decreased by selecting
shorter filters
o Generate more `false’ alarms
o Performances affected
• Tradeoff: speed/timeliness vs.
smoothness/reliability
Frequency Domain
• Timeliness
• Reliability
• Both!
Real-Time Signalextraction
Frequency Domain
Idealized Target: YT 


k 
k
X T k
T 1
Real-Time Estimate: YˆT   ˆk X T  k
k 0
Transferfunctions

( ):=   k exp(ik ) ( 
if symmetric)
k 
T 1
ˆ ( ):=  ˆk exp(ik )
k 0
Optimization Criterion: Mean-Square
Filter error: rt  Yt  Yˆt
Criterion: E[ rt ]  min FILTERWEIGHTS ˆk
2
Frequency Domain
ˆ  )  min
ˆ

(

)


(

)
S(
 k
k
k
ˆ
2
k
Objectives
1.Real-time filters which are `fast’
o Detect turning-points timely
2.Real-time filters which are `reliable’
o Impose strong noise suppression
2
ˆ  ) in MS-Criterion
Idea: decompose Γ(k )-Γ(
k
ˆ  )  min
ˆ

(

)


(

)
S(
 k
k
k
ˆ
2
k
Cosine Law applied to
( )  ˆ ( )
2
ˆ ( )
ˆ ()
()  
ˆ ()

( )
2
( )  ˆ ( ) 
2

ˆ ( ))
( )  ˆ ( )  2 ( ) ˆ ( ) 1  cos(

Decomposition of Mean-Square
Criterion
T /2
 (k )  ˆ (k ) Sˆ (k )  0
2
k 1
T /2
ˆ  )
 A( )  A(
k 1
T /2
k
k
2
Sˆ (k ) 


ˆ  ) 1  cos(
ˆ ( )) Sˆ ( )
(1   ) 2A(k )A(
k
k
k
k 1
Mean-Square:   0
Faster Filter :  >0
Slower Filter:  <0
Timeliness and Noise Suppression
T /2
ˆ  ) Sˆ ( )W ( , expweight ) 
 A(k )  A(
k
k
k
2
k 1
T /2


ˆ  ) 1  cos(
ˆ ( )) Sˆ ( )W ( , expweight )
(1   ) 2A(k )A(
k
k
k
k
k 1
1 , if k  cutoff (k in passband)
W (k , expweight )  
expweight
k >cutoff (k in stopband)
|1+k  cutoff|
Three Hyperparameters:  , expweight, cutoff
Timeliness, Reliability, Signal
Control: Interfacing with the Criterion
Mean-Square:   expweight  0
CUSTOMIZATION:
Smaller delay :  >0
Stronger noise suppression: expweight  0
Both...
Cutoff: signal
Next : Kents work on these hyperparameters
Latest Developments (2011,2012)
• Fast closed-form solutions
o I-MDFA
• Generic Approach
o Replicate model-based approaches, HP-designs, CFdesigns (see http://blog.zhaw.ch/idp/sefblog)
o Customize traditional mean-square approaches
• Alleviate/control overfitting
o Regularization
o Rmetrics-2012
Background
• SEFBlog:
o http://blog.zhaw.ch/idp/sefblog
o Articles, books, applications, R-code, tutorials
• Recent Articles:
o Wildi/McElroy (2012)
 http://blog.zhaw.ch/idp/sefblog/index.php?/archives/263
-On-a-Trilemma-Between-Accuracy,-Timeliness-andSmoothness-in-Real-Time-Forecasting-and-SignalExtraction.html
o Wildi (2012)
 http://blog.zhaw.ch/idp/sefblog/index.php?/archives/262
-Up-Dated-I-MDFA-Code-and-Working-Paper.html
Background
• R-Code/tutorials
o Check the categories `I-MDFA code repository’ or
`tutorial’ on SEFBlog
• Macro-indicators
o http://www.idp.zhaw.ch/usri
o http://www.idp.zhaw.ch/euri
• Trading
o http://www.idp.zhaw.ch/MDFA-XT
o http://blog.zhaw.ch/idp/sefblog/index.php?/archives/1
57-A-Generalization-of-the-GARCH-in-Mean-ModelVola-in-I-MDFA-filter.html
A Hybrid Approach
• iMetrica
o Access to State Space, ARIMA, I-MDFA, Stochastic
Volatility, Hybrid
o Chris Blakely: www.cd-blakely.com
Vola in I-MDFA
Described in a blog post, and then in more
detail later in a conference presentation.
Exercise: Reproduce the Example
Code available on SEF-Blog at:
http://blog.zhaw.ch/idp/sefblog/uploads/Vola_in_I-MDFA_prototype1.r
Runs as-is, but you need a "trading" function
Zero-crossing function:
start with your filter weights and data series
create a vector of NAs as long as your index to be your signal
set signal to 1 where filtered data > 0
set signal to 0 where filtered data < 0
fill your NAs - na.locf() is your best friend
Not sophisticated, but tricky: watch your lags
Veddy importante: signal *today* means returns *tomorrow*
Exercise: Reproduce the Example
(2)
Corollary: Understand the Behavior
Reference code runs a multi-stage loop
calculates filters for combinations of params
runs an optimizer over the param space
Effective, but not illuminating for me
parameter changes not intuitive (for me)
needed a feel for sensitivity
And I just happen to have a lot of machines...
easy code changes: expand.grid and foreach
lots of cpu time
eventually, lots of results
Finale: Descend into Obsession
Finale: Descend into Obsession
Finale: Descend into Obsession
Finale: Descend into Obsession
Finale: Descend into Obsession
Finale: Descend into Obsession
Finale: Descend into Obsession
Results: Qualitative Analysis of M/S
Results: Qualitative Analysis of M/S
Download