Optimizing trading strategies without overfitting By Ernest Chan and Ray Ng

Link: http://epchan.blogspot.com/2017/11/optimizing-trading-strategies-without.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+QuantitativeTrading+%28Quantitative+Trading%29



IDEA: 

Here is a somewhat trivial example of this procedure. We want to find an optimal strategy that trades  AUDCAD on an hourly basis. First, we fit a AR(1)+GARCH(1,1) model to the data using log midprices. The maximum likelihood fit is done using a one-year moving window of historical prices, and the model is refitted every month. We use MATLAB's Econometrics Toolbox for this fit. Once the sequence of monthly models are found, we can use them to predict both the log midprice at the end of the hourly bars, as well as the expected variance of log returns. So a simple trading strategy can be tested: if the expected log return in the next bar is higher than K times the expected volatility (square root of variance) of log returns, buy AUDCAD and hold for one bar, and vice versa for shorts. But what is the optimal K?

Following the procedure outlined above, each time after we fitted a new AR(1)+GARCH(1, 1) model, we use this to simulate the log prices for the next month's worth of hourly bars. In fact, we simulate this 1,000 times, generating 1,000 time series, each with the same number of hourly bars in a month. Then we simply iterate through all reasonable value of K and remember which K generates the highest Sharpe ratio for each simulated time series. We pick the K that most often results in the best Sharpe ratio among the 1,000 simulated time series (i.e. we pick the mode of the distribution of optimal K's across the simulated series). This is the sequence of K's (one for each month) that we use for our final backtest. Below is a sample distribution of optimal K's for a particular month, and the corresponding distribution of Sharpe ratios:

bestEntryZscoreForAUDCAD.png
Histogram of optimal K and corresponding Sharpe ratio for 1,000 simulated price series


Interestingly, the mode of the optimal K is 0 for any month. That certainly makes for a simple trading strategy: just buy whenever the expected log return is positive, and vice versa for shorts. The CAGR is about 4.5% assuming zero transaction costs and midprice executions. 


Attachments
No attachments
  • Votes +26
  • Project StrategyQuant X
  • Type Feature
  • Status Archived
  • Priority Normal
  • Assignee Mark Fric
  • Milestone Archived (To be done later)

History

IH
#1

clonex / Ivan Hudec

20.08.2018 16:26

Task created

IH
#2

clonex / Ivan Hudec

20.08.2018 16:46
quick example

optimal%2Btrading.png
IH
#3

clonex / Ivan Hudec

13.09.2018 17:56
Voted for this task.
mp
#4

Michele

11.11.2018 11:52
Voted for this task.
MF
#5

Mark Fric

07.01.2019 11:13

Assignee changed from Mark Fric to Mark Fric

Milestone changed from None to Build 118

N
#6

nathan

07.01.2019 12:05
Voted for this task.
IH
#7

clonex / Ivan Hudec

07.01.2019 19:06
Wow your openness to adding new features like this magnificent. Satisfied that I 2014 I decided to invest do SQ instead of other platforms. You guys doing a spectacular job.
k
#8

Karish

07.01.2019 19:08
Voted for this task.
DR
#9

mentaledge

07.01.2019 19:09
Voted for this task.
a
#10

Ash24FX

07.01.2019 19:18
Voted for this task.
FB
#11

lumbrjack

07.01.2019 20:53
Voted for this task.
o
#12

Enric

07.01.2019 22:23
Voted for this task.
m
#13

mabi

07.01.2019 23:20
Voted for this task.
l
#14

ludvick

08.01.2019 01:43
Voted for this task.
KW
#15

Sean

08.01.2019 01:45
Voted for this task.
m
#16

Martin

12.01.2019 11:28
Voted for this task.
b
#17

bentra

19.01.2019 02:40
Voted for this task.
KL
#18

kainc301

20.01.2019 04:06
Voted for this task.
KL
#19

kainc301

20.01.2019 10:58
I like this idea but I see there's a heavy reliance on time-based bars. Is there any way to calculate this with non-time-based bars like renkos if this is implemented?
AF
#20

AlexF81

23.01.2019 16:34
Voted for this task.
MF
#21

Mark Fric

01.02.2019 15:47

Milestone changed from Build 118 to Build 119

HH
#22

Hans

07.02.2019 14:05
Voted for this task.
MF
#23

Mark Fric

20.02.2019 09:56

Milestone changed from Build 119 to Build 120

BS
#24

BobS

28.02.2019 18:12
Voted for this task.
KL
#25

kainc301

30.03.2019 14:12

If any more context is needed on this, Ernest Chan goes into detail about this approach here

https://www.youtube.com/watch?v=UD92QBqA8Eo
i
#26

Ilya

31.03.2019 17:27
Voted for this task.
Ad
#27

drayzen

07.04.2019 11:08
Voted for this task.
MF
#28

Mark Fric

10.04.2019 08:17

Milestone changed from Build 120 to Build 121

MF
#29

Mark Fric

15.04.2019 10:02

Milestone changed from Build 121 to Build 122

PS
#30

ps21

13.05.2019 12:51
Voted for this task.
MF
#31

Mark Fric

29.05.2019 12:56

Milestone changed from Build 122 to To be done later

AA
#32

echelon

29.05.2019 23:45
Voted for this task.
AA
#33

echelon

29.05.2019 23:46
Voted for this task.
a
#34

Venus

04.09.2019 19:09
Voted for this task.
MF
#35

Mark Fric

16.02.2020 13:52

Status changed from New to Archived

AG
#36

Tukirito

16.02.2020 20:33
Voted for this task.
MF
#37

Marti

08.03.2021 19:10
Voted for this task.
w
#38

wiraputu

30.11.2022 14:20
Voted for this task.
A
#39

Asoea

02.04.2024 04:47
Voted for this task.

Votes: +26

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please