predicting economic releases using genetic support vector ... · hybrid model) are used to predict...

111
Predicting Economic Releases using Genetic Support Vector Machines Tom ´ as Valbordo Carvalho Thesis to obtain the Master of Science Degree in Information Systems and Computer Engineering Supervisor: Prof. Rui Fuentecilla Maia Ferreira Neves Examination Committee Chairperson: Prof. Rui Filipe Fernandes Prada Supervisor: Prof. Rui Fuentecilla Maia Ferreira Neves Member of the Committee: Prof. Lu´ ıs Manuel Silveira Russo May 2019

Upload: others

Post on 27-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Predicting Economic Releases using Genetic SupportVector Machines

Tomas Valbordo Carvalho

Thesis to obtain the Master of Science Degree in

Information Systems and Computer Engineering

Supervisor: Prof. Rui Fuentecilla Maia Ferreira Neves

Examination Committee

Chairperson: Prof. Rui Filipe Fernandes PradaSupervisor: Prof. Rui Fuentecilla Maia Ferreira Neves

Member of the Committee: Prof. Luıs Manuel Silveira Russo

May 2019

Page 2: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used
Page 3: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Acknowledgments

This dissertation is the result of combined efforts not only of the author, but also of the remaining

actors involved. First, I would like to thank Larubo Global Solutions as an institution, for providing an

excellent environment and sharing the data required to create this dissertation.

I would also like to thank my thesis supervisor, Rui Fuentecilla Neves, for the advising and tracking of

the work in progress, as well as for the very valuable insights for shaping ideas into a robust dissertation.

Special thanks addressed to Joao Ribeiro and Pedro Souto for the support and companionship in the

thesis creation process.

As for last, but definitely not least, I would like to thank all my family and friends, especially my

parents, Natalia Carvalho and Manuel Carvalho, for giving the opportunity and the tools to accomplish

my objectives and my fiancee Sofia Mensurado for all the unconditional love and support not only on

this dissertation but also in my whole path to get to this point; it would not have been possible without

their help.

Page 4: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used
Page 5: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Abstract

This dissertation’s goal is financial markets forecasting. More specifically, it aims at predicting exchange

rate market behaviour during isolated periods: the period after the release of macroeconomic indica-

tors. Soft computing techniques (Support Vector Machines (SVM) and Genetic Algorithm (GA) as a

hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not

only in the used hybrid model, but also in a combination of predictive factors (including fundamental,

technical and emotional) and the focus on proximity to real world practices rather than a theoretically-

leaned overview. The model includes variables to increase the ability to trade under different scenarios,

including unpredictable and unstable times. The Genetic Algorithm is used to pinpoint three different

goals: Support Vector Machine hyperparameter tuning, finding the optimal periodicity of the technical

indicators used and selecting the back-testing variables. The model was also tested under different

conditions, namely trading a different instrument (future contract of the Standard & Poor’s 500 index)

and without period isolation (trading continuously). The results were positive and consistently beat the

corresponding benchmarks in the analyzed periods, in and out-of-sample. The success is verified not

only in the macroeconomic release isolation but also (and with even better performance across all the

used metrics) when applied to different conditions.

Keywords

Genetic Algorithms; Financial Markets; Supervised Machine Learning; Support Vector Machines

iii

Page 6: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used
Page 7: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Resumo

Esta Dissertacao tem como objectivo a previsao de mercados financeiros. Mais especificamente, a

previsao do comportamento de mercados de cambio durante periodos isolados: o periodo apos a

divulgacao de dados macro-economicos. Tecnicas de Soft Computing (algoritmo genetico e maquinas

de vetores de suporte, combinadas num modelo hıbrido) sao utilizadas para prever o retorno nos mer-

cados de cambio. A inovacao deste modelo reside nao so no modelo hıbrido utilizado, mas tambem

na combinacao unica de factores (fundamentais, tecnicos e emocionais) e no foco da proximidade a

vertente mais pratica da actividade de Trading, contrastando com modelos mais teoricos. O modelo in-

clui variaveis que lhe conferem capacidade de transacionar em diferentes cenarios mais imprevisıveis e

instaveis. O algoritmo genetico e utilizado com tres objectivos distintos: ajustar os hiper-parametros das

Maquinas de vetores de suporte, encontrar a periodicidade optima dos indicadores tecnicos utilizados e

seleccao de algumas variaveis que influenciam a propria forma como o trader age. O modelo foi ainda

testado sob diferentes condicoes, nomeadamente a transacionar um instrumento financeiro diferente

(contracto de Futuros do ındice Standard & Poor’s 500) e sem o isolamento de periodos (a transacionar

continuamente). Os resultados sao positivos e ultrapassam de forma consistente os benchmarks corre-

spondentes nos produtos analisados, quer na amostra de treino, quer na amostra de teste. O sucesso

verifica-se nao so no ambiente de isolamento de dados macro-economicos mas tambem (com valores

ainda mais expressivos em metricas relevantes) quando aplicados a diferentes condicoes.

Palavras Chave

Algoritmo Genetico; Mercado Financeiro; Aprendizagem Supervisionada; Maquina Vetores Suporte

v

Page 8: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used
Page 9: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Contents

1 Introduction 1

1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.2 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.3 Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2 Background 7

2.1 Financial Markets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.1.1 Efficient Market Hypothesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.1.2 Technical Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2.1.3 Fundamental Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.1.4 Futures Trading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.1.5 Foreign Exchange Trading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.2 Data Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.2.1 Classification, Regression and Similarity Matching . . . . . . . . . . . . . . . . . . 14

2.2.2 Data Mining in Time Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.3 Soft Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.3.1 Genetic Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

a) Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

b) Crossover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

c) Mutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.3.2 Supervised Machine Learning: Overview . . . . . . . . . . . . . . . . . . . . . . . 18

2.3.3 Principal Component Analysis (PCA) . . . . . . . . . . . . . . . . . . . . . . . . . . 19

2.3.4 Support Vector Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

2.4 Prediction in Financial Markets: Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3 Methodology 27

3.1 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.2 Import/Export Data Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

vii

Page 10: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.2.1 Data importing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

a) Event Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

b) United States Dollar Index Future (DX) Data set . . . . . . . . . . . . . . 35

c) Conjectural time series - Volatility Index Futures Contract (VX) and Standard

and Poor’s 500 Mini Futures Index (ES) . . . . . . . . . . . . . . . . . . . 35

3.2.2 Data Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

a) Building front contracts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

b) Cleaning Outliers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

c) Re-sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

3.2.3 Data Exporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

a) Individual Genetic information . . . . . . . . . . . . . . . . . . . . . . . . 37

b) Chart Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

c) Trading Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

d) DX Data set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3.3 Machine Learning Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

3.3.1 Pre-processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

a) Building Technical Indicators . . . . . . . . . . . . . . . . . . . . . . . . . 39

3.3.2 Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

a) Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

b) Training vs Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

c) Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

d) Balancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

e) Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

3.3.3 Support Vector Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

a) Principal Component Analysis (PCA) . . . . . . . . . . . . . . . . . . . . 43

b) Kernels and Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

3.4 Back-testing Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

3.5 Genetic Algorithm Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.5.1 The Individual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.5.2 Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

3.5.3 Crossover . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

3.5.4 Mutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

3.5.5 Fitness Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

viii

Page 11: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

4 Results 53

4.1 Performance Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

4.2 Case Study I - GA only for economic release training . . . . . . . . . . . . . . . . . . . . . 57

4.2.1 System Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

4.2.2 Best Individuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

4.2.3 In-Sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

4.2.4 Out-of-sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

4.3 Introducing Feature Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

4.4 Case Study II - Genetic Support Vector Machines (GSVM) for economic release trading . 65

4.4.1 System Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

4.4.2 Best Individuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

4.4.3 In-Sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

4.4.4 Out-of-sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

4.5 Case Study III - GSVM for continuous ES trading . . . . . . . . . . . . . . . . . . . . . . . 72

4.5.1 System Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

4.5.2 Best Individuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

4.5.3 In-Sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

4.5.4 Out-of-sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

4.6 Summary Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

5 Discussion 81

5.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

A Appendix: Figures 89

ix

Page 12: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

x

Page 13: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

List of Figures

2.1 Data to Information Flow chart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.2 GA Routine Flow Chart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.3 One Point Crossover Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.4 Multi Point Crossover Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2.5 Uniform Crossover Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.6 SVM chart illustration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.1 Model Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.2 Import/Export Data package Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3.3 Machine Learning package Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

3.4 Back-testing package Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

3.5 Genetic Algorithm package Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.6 Genetic structure of an example individual. . . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.7 Illustration of the Selection process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

3.8 Illustration of the Crossover process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

3.9 Illustration of the Mutation process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

3.10 Illustration of the Fitness Calculation process. . . . . . . . . . . . . . . . . . . . . . . . . . 50

4.1 Cumulative Return chart for the different in-sample runs of Case Study I. . . . . . . . . . 60

4.2 Cumulative Return chart for the different out-of-sample runs of Case Study I. . . . . . . . 62

4.3 Feature Correlation Matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

4.4 Economic Release example Chart - DX price before and after the Non-Farm Payrolls

(NFP) release, 2016-11-04 07:30 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

4.5 Trading after an Economic Release example Chart - NFP release, 2016-11-04 07:30 . . . 66

4.6 Cumulative Return chart for the different in-sample runs of Case Study II. . . . . . . . . . 69

4.7 Cumulative Return chart for the different out-of-sample runs of Case Study II. . . . . . . . 71

4.8 Cumulative Return chart for the different in-sample runs of Case Study III. . . . . . . . . . 75

xi

Page 14: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

4.9 Cumulative Return chart for the different out-of-sample runs of Case Study III. . . . . . . 77

4.10 In-sample Accuracy and Return. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

4.11 Out-of-sample Accuracy and Return. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

4.12 In-sample Hit Ratio and Return. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

4.13 Out-of-sample Hit Ratio and Return. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

xii

Page 15: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

List of Tables

2.1 Time Series Data Mining Process example . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.2 Conditional Equation Example, present in [1] . . . . . . . . . . . . . . . . . . . . . . . . . 23

2.3 Summary of the analyzed literature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.1 Trading Book Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3.2 DX Data Set Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3.3 Technical Indicators Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

3.4 Feature Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

3.5 Individual Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

4.1 Performance Metrics - Return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

4.2 Performance Metrics - Non-Return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

4.3 Case Study I Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

4.4 Case I - Best Individual per simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

4.5 Case I - In-sample performance per simulation . . . . . . . . . . . . . . . . . . . . . . . . 61

4.6 Case I - Out-of-sample performance per simulation . . . . . . . . . . . . . . . . . . . . . . 63

4.7 Case Study II Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

4.8 Case II - Best Individual per simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

4.9 Case II - In-sample performance per simulation . . . . . . . . . . . . . . . . . . . . . . . . 70

4.10 Case II - Out-of-sample performance per simulation . . . . . . . . . . . . . . . . . . . . . 72

4.11 Case Study III Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

4.12 Case III - Best Individual per simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

4.13 Case III - In-sample performance per simulation . . . . . . . . . . . . . . . . . . . . . . . 76

4.14 Case III - Out-of-sample performance per simulation . . . . . . . . . . . . . . . . . . . . . 78

A.1 Initial Configuration Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

xiii

Page 16: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

A.2 DX Data Set Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

List of Algorithms

2.1 Genetic Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.2 Principal Component Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.1 GSVM Algortihm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

xiv

Page 17: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Acronyms & Abbreviations

ML Machine Learning

AI Artificial Intelligence

SVM Support Vector Machines

GSVM Genetic Support Vector Machines

RBF Radial Basis Function

SVC Support Vector Classification

DM Data Mining

GA Genetic Algorithm

ANN Artificial Neural Networks

CS Computer Science

TSV Tab Separated Values

PCA Principal Component Analysis

PDF Portable Document Format

SMA Simple Moving Average

RSI Relative Strength Index

EMA Exponential Moving Average

MOM Momentum

PCT Percentile

LT Long Term

xv

Page 18: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

ST Short Term

FOREX Foreign Exchange

DX United States Dollar Index Future

PnL Profit and Loss

USD United States Dollar

EUR Euro Currency (C)

JPY Japanese Yen

AUD Australian Dollar

SP500 Standard and Poor’s 500 Index

ES Standard and Poor’s 500 Mini Futures Index

TA Technical Analysis

FA Fundamental Analysis

VIX Volatility Index

VX Volatility Index Futures Contract

CPI Consumer Price Index

ADP ADP National Employment Report

NFP Non-Farm Payrolls

USURTOT United States Unemployment Rate Total in Labor Force Seasonally Adjusted

RSTAMOM United States Adjusted Retail and Food Services Sales Total Monthly Percentage Change

NHSPSTOT United States New Privately Owned Housing Units Started by Structure Total

xvi

Page 19: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

1Introduction

Contents

1.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.2 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.3 Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1

Page 20: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

2

Page 21: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

As stated by Grinblatt [2], “Finance is the study of trade-offs between the present and the future”.

What players do in financial markets is try to forecast the movement of financial assets’ value and invest

according to their beliefs, capital restrictions and timings. Different investors define beliefs based on

access to information and ability to infer from it, and the difference between investors’ rationale and

environment creates a market where supply and demand sustain trading.

There are many aspects to be considered when trading, as our perception cannot control and track

information with the necessary efficiency to always be in position to perform profitable trading. The es-

calation of computing power in the last decades came to revolutionize the trader-developer relationship.

Decision making and parameter optimization are some of the many use cases for Machine Learning (ML)

techniques, and the present, fast-paced technological atmosphere fueled the already existing potential

for this approach to problem-solving by providing affordable and powerful hardware, together with in-

creased access to more reliable data.

Even though the roots of Artificial Intelligence (AI) go back several decades, the field and its branches

are still maturing. In 1950, computer scientist Alan Mathison Turing created the Turing test [3] (named

after its creator). The Turing test measures a machine’s ability to exhibit intelligent behaviour indistin-

guishable from a human. From the creation of the Turing test, the field became so complex and broad

that sub-fields sprouted, varying in shape and goals, such as Robotics or Machine Learning. Machine

learning is an AI sub-field that relies heavily on statistics with the aim of enabling machines to improve

performance on a specific task.

Using concepts from ML or Soft Computing, this work pinpoints the optimization of a specific prob-

lem: financial time-series forecast, and decision-making based on predictions. The heuristic nature of

the methodologies provide the means to get a convergent solution with considerable complexity simpli-

fication and performance gains and a minimal loss in accuracy.

1.1 Motivation

For someone with previous studies in Economics and Business Administration and professional experi-

ence in Data Mining (DM) for trading, the Financial Markets are a natural candidate for the opportunity

of blending these fields with Computer Science (CS). Uncertainty, data-driven action, statistics and a

goal-oriented mindset are the ingredients that lead the author to picking a Finance related hypothesis to

test in this work.

3

Page 22: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

1.2 Objectives

The present work aims at using the power of Machine Learning techniques, a field that has been in-

creasing in quantity and quality in the last years, to predict financial market moves on macroeconomic

releases. The idea is to understand how markets will most likely react in a short-term period after the re-

lease of economic information, and how the discrepancy between the expected and real value influence

market behavior.

Other factors impacting financial markets are investors fear sentiment or the recent history of the

most important index in the world: the Standard and Poor’s 500 Index (SP500). The study will be

focused on the United States of America, and the traded instrument reflects the value of the United

States Dollar (USD) compared to multiple currencies.

Even though the scope of this work is restricted to one instrument and one country, the analysis

can be global. Living in an increasingly globalized environment, the correlation between variations in

different economies increase: an incident that impacts consumers in China or Europe will influence the

United States Exports and the currency’s strength.

For the model, two different tools that have been successful in predicting financial markets will be

used: Support Vector Machines (SVM) classification and Genetic Algorithm (GA). The idea is to tackle

the problem by using the mentioned mechanisms as a hybrid approach.

In the end, the results are measured by comparing returns with relevant benchmark strategies (in-

cluding Buy and Hold and different case studies), and by looking at the accuracy of the prediction model.

1.3 Contributions

This thesis introduces a novel approach to seeking successful strategies for consistent returns using

financial forecasting by integrating several approaches together with the inclusion of unique features:

• Creation of a new model integrating SVM and GA seeking the maximization of both returns or

accuracy of the model.

• Creation of multi-variate fitness functions for the GA to find the optimal solution for the problem.

Each part of the fitness function has a rationale behind it to seek the best solution in terms of

consistency, overall result, and avoid overfitness.

• Three class prediction model, with a classification methodology that avoids action in less intense

signals. There are three possible signals: buy, sell and hold. The hold signal happens not only

when the present price is exactly the same as the one in the near future, but also if it does not

move considerably. Most models either only use buy and sell signals or, in some cases, hold

signals when today’s price is exactly equal to the forecasted future price.

4

Page 23: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• Wide range of factors used in the futures. Most works in financial markets only take into con-

sideration Technical Analysis (TA) indicators, this work uses not only TA but also Fundamental

Analysis (FA) (by using the economical release information to understand the mismatch between

what was expected and the actual value and using this information to predict the underlying correc-

tion) and sentiment analysis, by using the Volatility Index (VIX) and Standard and Poor’s 500 Mini

Futures Index (ES) indexes to understand where they stand versus recent/medium-term history.

• The ease of adaptation of the model. The model was built to easily accommodate being tested

with different financial instruments, time frames, or event data sources with minor changes.

1.4 Structure

This work is divided as follows:

The first and current chapter comprises the introduction and a brief description of this work’s objec-

tives.

In the second chapter, literature review and context are provided for the understanding in general of

the tackled topic. This chapter is divided in sections, each one defining concepts related to a different

field of study.

On the third chapter, the overall solution and goal of this work is explained in detail, with possibilities

that were explored and how the solution was built.

The fourth chapter contains results and metrics to evaluate the performance of the model.

The fifth chapter is a summary of the conclusions of this work followed by suggestions for future

work.

5

Page 24: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

6

Page 25: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

2Background

Contents

2.1 Financial Markets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.2 Data Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.3 Soft Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.4 Prediction in Financial Markets: Examples . . . . . . . . . . . . . . . . . . . . . . . . 22

7

Page 26: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

8

Page 27: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

To understand and tackle the challenges proposed in this work, concepts revolving around data

processing, financial markets theory and optimization are used. In this section, each of these topics

is addressed individually (and jointly, in some cases) by looking at what has been done in each field

by other authors, trying not only to enlighten the reader about the theory behind the model, but also to

understand how existing concepts will help to achieve our goals.

In the first section, concepts related to Financial Markets and Trading in general are addressed. In

the second section, considerations are shared regarding Data Processing, like classification and time

series manipulating techniques. In the third section, a rundown on Soft Computing techniques, focused

on the latest trends that may be useful for the project, and examples of specific implementations in

capital markets prediction.

2.1 Financial Markets

”One of the funny things about the stock market is that every time one person buys, another sells, and

both think they are astute.” [4]

Financial Markets are one of the most challenging areas to be involved in. It is constantly evolving

and adapting, it is fast-paced, and offers opportunity for very distinct approaches. Players have different

objectives and behaviors, and can range from an individual potentiating the growth rate of their savings to

corporations diversifying their income sources or simply using different financial instruments to mitigate

risk.

Throughout the globe, Mutual Funds, Brokers, Pensions Funds, Hedge Funds, Insurance Compa-

nies, Investment and Commercial Banks, just to name a few, decide what should be the fair value of

every asset (such as Stocks, Commodities, Interest Rates, Future contracts, Exchange Rates, among

several others). Therefore, it is a great challenge to, not only define how markets behave, but also to

predict future movements and the likelihood of certain events [5].

2.1.1 Efficient Market Hypothesis

According to Malkiel [6], ”A capital market is said to be efficient if it fully and correctly reflects all relevant

information in determining security prices”. In practice, this means that it is impossible to profit based on

a given information set about the valuation of an asset, as its implications on what would be a fair price

for the financial instrument are already reflected in the price. Whenever new information is released,

prices react to new information quickly and to the right extent. Under this hypothesis, the only way to get

higher returns is by taking on more risk, implying that active money management does not work.

9

Page 28: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

There are three forms of efficiency:

• Weak form. Asset prices already reflect all the historical data. This means that Technical Analysis

is meaningless, and no edge for the future will come from analyzing how the price has behaved in

the past.

• Semi-strong form. Asset prices reflect not only historical data, but also public information. So

looking at Balance Sheets, and other forms of information released to the public will not increase

risk-adjusted returns. This renders fundamental analysis (derivation of the intrinsic value of an as-

set based on publicly-available information such as reports and media communication) as useless.

• Strong form. Asset prices reflect all the available information, public and/or private. No information

that any individual investor has will give him an advantage over other market agents, meaning that

even inside trading 1 will not give the agents an opportunity to increase their risk-adjusted returns.

If the Efficient Market Hypothesis held perfectly true (in its Strong Form), the direction of financial

assets prices could not be predicted with greater than 50% accuracy, meaning one would not be able to

guess whether future prices will go up or down any better than a coin toss. A lot of studies have proven

otherwise (discussed later in this chapter), and so is the goal of the presented work.

2.1.2 Technical Analysis

Technical analysis is one of the most used toolsets in the trading world. Even if unconscious, most

players in the Financial Markets use or have used Technical Indicators to drive their trades. The base

concept is simple: to trade based on history, finding and drawing conclusions from price and volume

behavior in the past in order to try to predict what will happen in the future.

This approach can be performed using different techniques, such as:

• Graphical pattern-finding (’Head and Shoulders’ pattern, ’double bottom’, among others, see [7]

for more information)

• Moving average-crossing using different periodicities (for example, buy when the 10 day moving

average crosses the 20 day moving average, sell if the opposite happens),

• Relative Strength Index (RSI) [8] tracking,

• Daily variation threshold (buy if stock goes down more than a certain percentage in a single day,

or if it drops an X number of days in a row).1Trading using privileged information such as confidential documents or having early access to information that will only be

publicly displayed in the future. As it is considered to be unfair over other market agents, it is illegal to trade based on such, sooften people with access to this type of documents and knowledge are not allowed/limited in what they trade

10

Page 29: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

There are also multiple alternative techniques that have been appearing based on people’s rational

understanding of the markets, or on empirical observation.

2.1.3 Fundamental Analysis

Fundamental Analysis is another toolset available to most market players who are willing to understand

what drives markets and try to price their assets (or seek opportunities). Nowadays, a lot of public

information is available to track financial health and future perspectives, be it in a macroeconomic envi-

ronment through reports released by the government (this topic will be addressed in more detail later),

or a microeconomic one, through companies’ annual reports and balance sheets, for example, that

enlighten market players about what would be the intrinsic value of an asset. In the current work, a

macroeconomic approach will be the one to be relied upon, as the focus is on trading currencies, which

have a very close correlation with the financial and economic health of different regions.

2.1.4 Futures Trading

Futures are a type of financial derivative that reflects the price of a good, either tradable (oil, corn, wheat,

...) or non-tradable (interest rate, ...), in a future date. On paper, a future is a contractual agreement

made between two parties through a regulated futures exchange. Each contract specifies the quantity

and quality of the item, expiration date, and all the details of the transaction except the price, which is

set in the trading process.

Future Prices derive from the price of the underlying asset, a cash or spot2 price. It was initially

created for business purpose, to mitigate risk and lock prices of assets in a current date to avoid exposure

to market conditions such as excessive supply, etc.

In the Futures markets there are mainly two types of players: Hedgers, the forementioned agents

that use futures to mitigate business exposure to price changes (usually producers or consumers); and

Speculators, who are just looking for mispricing opportunities to make a profit, without having real use

for the traded asset.

The futures market is a Zero-Sum Game, meaning that there are no net winners or losers. Everytime

a contract is bought, it means there is a seller on the other side of the trade, so all losses suffered by

one trader are wins of others. It is also extremely liquid3, risky4 and complex by nature.2The current price in the marketplace at which a given asset can be bought or sold for immediate delivery3traded volume is high4because of its leveraged nature, variations in future price may result in high gains or losses, see the concept of margin in

futures market context, explained in [9]

11

Page 30: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

2.1.5 Foreign Exchange Trading

The Foreign Exchange (FOREX) is the largest and most important financial market in the world. In a

globalized world such as the the present one, fluctuation between different currencies affects the majority

of the corporate activity and even most people’s everyday life without them even noticing it. With an

average daily trading volume of around five trillion dollars per day [10], FOREX trading purposes ranges

from commercial reasons (to mitigate currency risk) to speculative ones (short term trading, trying to

profit from fluctuations in price).

According to Dolan [11], the following are the main building blocks of currency prices:

• Economic Data Reports As drivers of government’s economic decisions and monetary policy,

these reports serve as input for both policy makers and for the market participants for gauging

the state of the economy. The values on these reports, more specifically the difference between

consensus (expected values by analysts and top market players) and actual values, may serve as

catalysts to move the markets. The reports contain information about all economic agents, from

the labor market, to consumers, business sector and structural indicators (Inflation, Growth, Trade

Balance, Fiscal Balance).

• Interest Rate Levels. Interest rates are the single most important determinant of a currency’s

value. Not only their present status, but also its future perspectives: direction (ascendant or de-

scendant), expected limits (high or low expected values), and pace (how fast are rates likely to

change). Typically, lower interest rates point to a weaker economic outlook and the probability of

lower interest rates ahead, having a negative impact on the currency; higher interest rates point to

economic optimism, usually supporting that the currency.

• Monetary Policy. Monetary policy consists on the actions of a central bank, currency board or

other regulatory committee that determines the size and rate of growth of the money supply, which

in turn affects interest rates. Monetary policy is maintained through actions such as modifying the

interest rate, buying or selling government bonds, and changing the amount of money banks are

required to keep in the vault (bank reserves).

• International Trade and Investment Flows. International Trade also determines (and is affected

by) the relative strength of a currency. Companies transact goods and set payment schemes in

different currencies to, for example, make the deal more attractive for the counterpart.

Imagine a company, who agreed to receive the payment in a foreign currency, and has production

costs in their domestic currency. This company is exposed to exchange rate risk, as the rate

between the foreign and domestic currencies may affect the margin of its sales (if the foreign

currency is suddenly worth less in terms of domestic currency, it could even be more expensive

12

Page 31: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

to produce the good then what the company is getting paid for it). So what can this company do

to eliminate this risk? The company should sell foreign currency against the domestic one in the

FOREX market. In this case, if the foreign currency’s value in domestic currency decreases, they

would lose margin but would make profit in the FOREX market, eliminating the exchange rate risk

if done in the certain amount. This process is called hedging, and shows how international trade

is directly connected with the FOREX Market.

Another relationship between International Trade and markets corresponds to the Currency Re-

serve Management. Countries with large trade surpluses will accumulate reserves of foreign cur-

rency over time. Trade surpluses arise when a nation exports more than it imports, causing foreign

currency balances accumulate. These reserve managers are active and influential players in the

FOREX market, seeking to act in the interest of the government [11].

• Geopolitical Fundamentals. This includes territory disputes, trade conflicts, terrorist attacks,

wars, and political elections in major economies. All these factors contribute to specific economic

environments, and are reflected in currencies. Uncertainty makes the markets move, the disparity

of opinions diverge and so does the valuation of the assets. Trying to figure out the turnaround of

the conflict is as hard as crucial to successful trading during darker times.

• Investors Sentiment Humans are emotional. Emotion is uncertain. Emotions spread, usually

part ways with rationality, and can have an overwhelming effect on the markets. More often than

not, traders see their predictions and valuations missing the target because of collective fear or

excessive optimism. Eventually, rationality usually prevails and either through a crash or other

type of financial phenomena, the markets adjust and correct the prices to what fundamentals point

to or where reason tells that the price should be.

In times of fear, news have more impact in the markets. Unexpected events lead to higher price

movements, volatility increases, and markets tend to go sideways (up and down) rather than one

way (up or down). To measure this effect, the Chicago Board of Options Exchange (CBOE)

launched a market volatility called VIX. VIX shows the market’s expectation of 30-day volatility,

using the implied volatilities of a wide range of S&P 500 index options. It can be transacted (it has

future contracts), or simply used in the decision making process.

13

Page 32: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

2.2 Data Processing

”We are drowning in data, but starving for knowledge.” [12]

As defined by [13], Data Mining is an analytic process designed to explore large-scale data in search

of consistent patterns and/or systematic relationships between variables, and then to validate the find-

ings by applying the detected patterns to new subsets of data. It is an interdisciplinary field merging

concepts from allied areas such as database systems, statistics, machine learning, and pattern recog-

nition.

DataSources

Pre-Processing

DataMining Evaluation Information

Figure 2.1: Data to Information Flow chart.

To understand how the concept of data analysis is important for this work, in this section useful

topics are addressed that will be part of the process of transforming our initial, large-scale dataset(s)

into shaped data where predictive layers can be laid upon. Multivariate time series will be used, that can

be stationary or non-stationary 5 (although most financial assets can be considered as non-stationary).

2.2.1 Classification, Regression and Similarity Matching

Classification is the task of attributing a class (or categorical label) to an unlabeled point Yt given

dimensions Xt1...Xtc. To build a model, it is required to have a dataset of classified points and the cor-

responding dimensions, train the model using one of the many existing prediction approaches (different

approaches suit different problems, but there is a clear overlap and wide range to choose, from Ma-

chine Learning algorithm’s such as Support Vector Machines, that will be used in the present work; to

more statistical-focused approaches such as the Autoregressive Integrated Moving Average (ARIMA)6

model). An example of class labels, according to financial time series, could be ”Positive daily returns”

or ”Negative Daily Returns”, and this type of class distribution can be used to understand if a trader’s

position should be long, short or flat7.5Stationarity defines how the mean and variance of the time series behave over time. A stationary time series’s mean and

variance will not change significantly over time, while non-stationary time series’s mean and variance can increase or decreaseover time

6Generalization autoregressive model used for information extraction and forecasting in time series. The purpose of each ofthese features is to make the model fit the data as well as possible.” [14]

7Long refers to buying the stock; Short refers to short-selling the financial asset (selling the asset and buying it only later); Flatrefers to having no open position

14

Page 33: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Regression tries to predict a real numerical output of a variable for a record in a dataset based on

its dimensions and of past (training) behavior. Simply put, classification forecasts ”whether” something

will happen, whereas Regression predicts ”how much” it will happen. Looking at financial time series,

a regression goal could be to predict the exact price a given moment and, as stated before, use this

information to understand if the best position to have open is long, short or flat.

Similarity Matching Tries to recognize similar records based on the information about them. This

is the mechanism used in most recommendation systems that are available today (such as Amazon’s

”People who bought this also like that item”, and other identical approaches). The assumption is that

if two records are similar in some known characteristics, they will possibly be similar in other unknown

characteristics as well. Picturing again a financial time series environment, similarity matching could be

used to look at volume, overall economic sentiment, interest rate values, among others to find a similar

time in the past where the scenario was similar and understand what other characteristics may this

period have and how to use this knowledge to the trader’s benefit. [15].

2.2.2 Data Mining in Time Series

Given their complexity and specific characteristics, tasks were created to simplify and transform into

more usable and stable versions of datasets. Among these tasks (see [16] for more detail), there is

Indexing (query by content), Clustering (finding natural groupings), Classification (assigning labels

to unlabeled time series), Prediction (given n, predict n+1 period), Summarization (compress and

approximate dataset into a smaller version, with similar essential features), Anomaly Detection (find

sections with unexpected occurrences) and Segmentation (break dataset to segments to build model).

Due to their usual large-scaled nature, it is also important to address Representation of time series.

This adds one challenge for data miners: not only to extract useful information from data, but also to do

so efficiently.

The following table describes a generic data mining approach for time series:

Table 2.1: Time Series Data Mining Process example

Step 1) Create smaller version, approximate version of the data, retaining its essential fea-tures, yet fitting the main memory.

Step 2) Solve the problem using the data set in the main memory.Step 3) Access original data set to confirm and test solution from Step 2). If solution is not

satisfactory, return to Step 1) and tweak.

15

Page 34: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

2.3 Soft Computing

”Exploit the tolerance for imprecision, uncertainty, partial truth, and approximation to achieve

tractability, robustness and low solution cost” [17]

2.3.1 Genetic Algorithms

InitialPopulation Selection

Mating Crossover Mutation

Criteriamet?

StopYesNo

Figure 2.2: GA Routine Flow Chart.

Genetic Programming is a class of meta-heuristic optimization algorithms aimed at solving prob-

lems without a deterministic solution, and that comes from the theory of evolution’s concept of natural

selection.

Through processes such as Crossover , Mutation and Selection, the algorithm starts from an hy-

pothesis space (each hypothesis defined by a set of parameters, assigned randomly from a pool of

possibilities) and works its way up to the individual with the highest Fitness, whose set of parameters

deliver the best results for the designated problem (as shown in 2.2).

One of the main advantages of the GA approach is the adaptability to different problems, the only

requirement being for the solutions to be rankable. The Fitness function has no other requirements, it

can be set freely by the user, despite having the recommendation of not being too complex because it

will need to be calculated multiple times.

To get a better picture of the role of these different processes in the algorithm, below is a description

of each:

a) Selection

Selecting individuals to breed (through the Crossover process) according to their fitness value. There

are multiple selection strategies:

16

Page 35: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• Roulette Wheel Selection - The probability of each individual being selected is proportional to its

fitness versus the overall population fitness. For example, if the sum of the fitness of all individuals

in a given population is 200, an individual with a fitness value of 40 has a 40/200 = 20% probability

of being selected for the breeding process. This process is repeated until all the breeders are

selected.

• Stochastic Universal Sampling - Follows a process similar to the Roulette Wheel Selection, but all

the parents are selected in a single run, by using multiple selection points.

• Tournament Selection - Select a random sub sample from the population. The individual with the

highest fitness in this sub sample is selected for breeding. This process is repeated until all the

breeders have been found.

• Truncation Selection - Select a proportion of the individuals with the highest fitness within a popu-

lation to be the breeders.

b) Crossover

Generating offspring from other individuals. The newly generated individual will inherit characteristics

from both parents. The way this inheritance is performed can have different strategies, namely:

• One Point Crossover - The newborn inherits all the genes from one parent up until a selected

crossover point is reached, after which it inherits from the other parent. An illustration can be seen

in figure 2.3.

Figure 2.3: One Point Crossover Example

• Multi Point Crossover - As in One Point crossover, the newborn inherits blocks of genes from one

parent alternated with segments from the other parent. An illustration can be seen in figure 2.4.

Figure 2.4: Multi Point Crossover Example

17

Page 36: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• Uniform Crossover - In Uniform Crossover, all the genes are evaluated separately, and copied from

one of the parents or the other with 50% split probability. This probability can be tweaked if it is

more suiting for a given problem. An illustration can be seen in figure 2.5.

Figure 2.5: Uniform Crossover Example

c) Mutation

Mutation is the exploratory part of the GA. It consists in randomly changing genes of the offspring

generated from the Crossover process. Mutation is used to search different solution spaces of the

problem and avoid being bound to a local maximum.

One of the most common strategies is to run through every gene of every offspring individual and

change its genes according to a pre-defined probability. Usually, this probability is a low value, so that

avoid reducing the GA to a random search.

Overall, according to Goldberg [18], the procedure of a simple, generic GA is shown in listing 2.1:

Algorithm 2.1 Genetic Algorithm

1: Set t = 1. Randomly generate N solutions to form the first population, P1. Evaluate the fitness ofsolutions in P1.

2: Crossover - Generate an offspring population Qt as follows:

1. Choose two solutions, x and y from Pt based on the fitness values.

2. Using a crossover operator, generate offspring and add them to Qt.

3: Mutation - Mutate each solution xQt with a predefined mutation rate.4: Fitness assignment - Evaluate and assign a fitness value to each solution Qt based on its objective

function value and infeasibility.5: Selection - Select N solutions from Qt based on their fitness and copy them to Pt+1.6: If the stopping criterion is satisfied, terminate the search and return to the current population, else,

set t = t + 1 go to Step 2.

2.3.2 Supervised Machine Learning: Overview

According to Kotsiantis [19], supervised learning can be divided into the following steps:

1. Collecting the dataset. Gathering all available data with a theoretical contribution to prediction.

Pre-processing is required, for removing useless columns, outliers and bad data.

2. Pre-Processing. Depending on the circumstances, may consist of outliers (noise) removal tools,

handling missing data, instance selection, sampling instances from large datasets.

18

Page 37: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3. Feature Subset selection and transformation. Removing irrelevant features and combining highly

correlated features into an aggregate one.

4. Algorithm Selection. To be chosen based on accuracy. Three options for accuracy measuring:

• Use two thirds of the dataset for training, one third for testing, and measure the percentage of

hits to number of total instances;

• Use cross-validation (divide dataset into equal subsets, test on each using the remaining

subsets as training – the average error will be the model’s error);

• Leave-one-out cross-validation, meaning to perform cross-validation on every instance of the

dataset (each item is a sub-set).

5. Check results. If the error is too high, return to step 2) and understand how to improve the results.

Among the possible problems causing poor performance of algorithms are: the exclusion of rele-

vant features for the problem, the necessity for a larger training set, the fact that the dimensionality

of the problem is too high, inappropriate choice of the selected algorithm, need for parameter

tuning or an unbalanced dataset used as model input.

2.3.3 Principal Component Analysis (PCA)

Principal Component Analysis is a dimension-reduction technique used to decrease the size of the

problem, by aggregating the information contained in correlated variables. Multivariate Analysis often

starts out with data involving a substantial number of correlated variables, increasing its complexity with

variables that by itself do not increase solutions accuracy and may be redundant. By aggregating the

correlated variables, the problem decreases in complexity.

When performed on the features of a classification algorithm, the Principal Component Analysis may

decrease the training time of the model significantly without compromising accuracy, by making sure that

the selected principal components are the ones with the higher explanation power of the class’ variance.

The first principal component accounts for as much of the variability in the data as possible, and each

succeeding component accounts for as much of the remaining variability as possible.

In broad strokes, PCA can be summarized in the steps described in listing 2.2:

Algorithm 2.2 Principal Component Algorithm

1: Consider the matrix Dmxn, where m is the number of samples and n is the number of features.2: Calculate the covariance matrix Xnxn with the coveriance between all features of D.3: Calculate eigen vectors and corresponding eigen values.4: Sort the eigen vectors according to their eigen values in decreasing order.5: Choose first k eigen vectors and that will be the new k dimensions.6: Transform the original n dimensional data points into k dimensions.

19

Page 38: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

2.3.4 Support Vector Machines

Figure 2.6: SVM chart illustration.

Support Vector Machines are a binary classifier that use decision boundaries to separate points

belonging to each class or category. This optimal decision boundary, which is the classifier with the best

accuracy and best generalization ability, is also called Maximum Margin Hyperplane (represented by

the bold line in the figure 2.6, h(x) = 0), and it is the one that maximizes the distance from the plane

to any of the points that are positioned closest to the boundary (called support vectors) - all the other

points are irrelevant for the hyperplane selection process. As the separation of the points may not be

exact, error can be added to the model in order to control how many points are misclassified [20].

The hyperplane can be defined, given an n dimensional feature vector x = (X1, . . . , Xn), as equation

2.1:

β0 + β1X1 + · · ·+ βnXn = β0 +

n∑i=1

βiXi = 0 (2.1)

By rewriting the hyperplane equation using inner products, equation 2.2:

y = β0 +∑

αiyix(i) · x (2.2)

As for classification, imagine a binary solution space represented by two labels, namely y ε {-1,1},

20

Page 39: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

equation 2.3 shows that:

y =

{1, if β0 +

∑ni=1 βiXi > 0

−1, if β0 +∑n

i=1 βiXi < 0(2.3)

One of the hurdles of this approach is that, in its essence, the model is limited to linear boundaries.

This problem was overcome by introducing the concept of Kernel Functions into the equation, hence

transforming a linear problem into a higher dimensional one, where you can classify linearly, to then get

a non-linear solution in the original dimensionality.

The Kernel trick is a mathematical method applied to get linear learning algorithms (such as Support

Vector Machines) to learn a nonlinear function or decision boundary.

By replacing all dot products with a kernel function (like equation 2.4 shows), a higher-dimensional

space RM (where M > N) can be used, without explicitly building the higher-dimensional representation.

Thus, the algorithm can learn a nonlinear decision boundary in the original RN space, which corresponds

to a linear decision boundary in RM. This allows for significant time and resource savings without losing

too much accuracy (even though Kernel function parameters still need to be tweaked).

xi, xjε<N ,K(xi, xj) = 〈φ(xi), φ(xj)〉M

where 〈·, ·〉M is an inner product of <M ,M > N

and φ(x) transforms x to <M (φ : <N → <M )

(2.4)

Notice that K(x,y) needs to satisfy a technical condition (Mercer condition, see [21] for more detail)

in order for φ(.) to exist.

Among popular Kernels, listed in equations 2.5, 2.6 and 2.7 are some of the most commonly used.

Polynomial Kernel:

(γ · 〈xi, xj〉+ r)d (2.5)

Radial Basis Function (RBF) Kernel:

exp(−γ · |xi − xj |2), γ > 0 (2.6)

Sigmoid Kernel:

tanh(〈xi, xj〉+ r) (2.7)

Using a Kernel function K, equation 2.8:

y = β0 +∑

αiyiK(x(i), x) (2.8)

To control and adapt the model to the desired results, a penalty parameter is often included ( called

C parameter), that sets the SVM optimization misclassification scope. when choosing the best margin

21

Page 40: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

hyperplane, for large values of C the optimization will choose a hyperplane that has the highest accuracy

in terms of correctly classified points; conversely, small values of C will cause the optimizer to select the

largest margin hyperplane, even if that hyperplane misclassifies more points.

Among the advantages of the Support Vector Machines are the low tendency for overfitting, the

robustness in high-dimensional spaces, and the fact that it is computationally efficient.

2.4 Prediction in Financial Markets: Examples

A lot of authors have tried Machine Learning and other Optimization methodologies to try to predict

stock market movements. From Artificial Neural Networks, to Support Vector Machines and Genetic

Algorithm, several papers can be found testing a unique (or several) combination of parameters, kernels

and classifiers applied to different types of financial instruments.

While some authors focus exclusively on using technical indicators as triggers and classifiers, others

analyze the importance of fundamental data, or even include external Index’s information as a driver to

predict the price of a certain asset (for example, looking at S&P indicators and use them as a gauge to

understand overall market sentiment and how it could be influencing the traded asset’s price).

Among the problems addressed, there is kernel picking, prediction model comparison, profit seeking

approaches, where some authors focus on the research side of the matter (just track if the market goes

up or down at certain points, ”feed” the parameters to the model and directly analyzing the outputs),

others try to include a setting that mimics reality and a practical point of view of trading as much as

possible (by including transaction costs, for example).

In the researched solutions, there is usually a common gap: real world variables, present in a trader’s

everyday life, are disregarded. Aspects such as risk control (through, for example, stop-loss8 mecha-

nisms), exposure, among others that are a must in a professional trader’s activity are seldom considered,

and the model ends up being oblivious to the existence of multiple setup components. This is one of

the holes that this paper will try to fill in within the already vast literature in the successful ”joint-venture”

between Financial Markets and Computer Science.

In the early years of the usage of Machine Learning to forecast financial markets, one of the most

used models was Artificial Neural Networks (ANN). ANNs have a series of interconnected nodes that

simulate the human brain neuronal activity, and are organized into different layers based on function.

The ANN assigns weights to connections, and the output is calculated based on the inputs and the

weights. As the model trains, it analyzes patterns in the training data and reassigns the weights to get8Trigger that tracks the amount of money a trader is willing to risk when entering a position. If the current price corresponds to

a loss of less than that value, the trader will hold the trade and hope for it to invert and either profit or close the position at the priceit entered (aka ”Scratch” ); if the price movement sends it to a point where the trader is causing a loss close to or slightly higherthan the stop-loss, the trader will close the position and accept the current losses, to mitigate the dimension of poor performingtrades.

22

Page 41: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

the best possible results.

Kim and Han (2000) [22] used an hybrid approach using GA optimized ANN to predict the Korean

Stock Price Index. In this work, the GA is used not only for hyperparameter tuning but also to reduce

the complexity in the feature space. With an out-of-sample hit rate of 61.7%, the authors show that

this approach outperforms other more conventional prediction models: backpropagation neural network

(out-of-sample hit rate of 51.8% ) and an ANN simply trained using a GA (out-of-sample hit rate of

50.6%).

In the analyzed works, prediction or profit seeking models were also commonly approached using

a GA. Mendes et al (2012) [23] used GA to generate trading rules for the EUR/USD and GBP/USD

exchange rates. Using ten technical trading rules (five to enter, five to exit positions), the problem is set

to optimize a total of thirty one parameters within the technical indicators present in the rules to generate

signals. Each parameter is a gene of each individual.

The results display positive returns if transaction costs are disregarded, but shows difficulty in ob-

taining out-of-sample profits when accounting for these costs.

In 2009, Hirabayashi et al [1] also use genetic programming to optimize trading rules and maximize

returns in FOREX markets. The author focuses on calculating the most appropriate trade timing, instead

of predicting the trading prices, using a set of technical indicators as decision variables. The GA opti-

mizes the thresholds for the technical indicator signals (for example, buy if Relative Strength Index < X,

where X is a gene) and the conditional operators between different TA signals. An example is presented

in table 2.2. The used currencies were the Euro Currency (C) (EUR), USD and Australian Dollar (AUD),

all versus the Japanese Yen (JPY), and the results were sparse between different currencies, but overall

positive: +17% return on the USD/JPY, +35% return on the EUR/JPY, +85% return on the AUD/JPY.

Table 2.2: Conditional Equation Example, present in [1]

Rule Chromosomes Possible Values(c1 < RSI1 < c2)Op.1(c3 < PD < c4)

Op.2(c5 < RR < c6)Op.3(c7 < RSI2 < c8)

c1, c2, c3, c4, c5,c6, c7, c8, Op.1,

Op.2, Op.3

Op.1, Op.2, Op.3 = && or ||c1, c2, c7, c8 = 0 to 100

c3, c4, c5, c6 = Percentages

Another interesting approach to price prediction that displayed promising results was Madge (2015)

[20]. The used methodology was a SVM model, to predict the prices of 34 stocks of the NASDAQ index,

an United States index composed by the major technological players of the market.

The SVM model used the Radial Basis Function (RBF) kernel, and used four features: momentum

and volatility for both NASDAQ index (relative to the last N1 days) and analyzed stock (relative to the last

N2 days), where N1, N2ε{5, 10, 20, 90, 270}. The class is the prediction of the price M days after each

given moment, where Mε{1, 5, 10, 20, 90, 270}.

Results show that different combinations of M , N1 and N2 display different outcomes. For different

values of M, the average of all possible combinations between N1 and N2 range from 48% when M=1

23

Page 42: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

to 56% when M=20. When the author discriminates between different N1 and N2 and fixes the M=90

however, for certain combinations, the model’s accuracy can go as high as 61% (M=90, N1 = 270 and

N2 = 5). Table 2.3 summarizes articles of similar nature and the corresponding results.

Table 2.3: Summary of the analyzed literature

24

Page 43: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Ref Year Method Period Market Algo Performance Benchmark

[1] 2009 GA 2005-2007 FOREX +42% (Return) (B&H)a -18%

(Loss)

[20] 2015 SVM 2007-2014

NASDAQ (34Stocks) >60% Hit Ratio NA

[22] 2000 GA + ANN 1989-1998 KOSPIb >60% Hit Ratio (BPNNc) 51%

Hit Ratio

[24] 2005 SVM 1990-2002 NIKKEId 73% Hit Ratio (RWe) 50% Hit

Ratio

[25] 1998 GA 1928-1995 S&P500 < B&H after Transaction

Costs NA

[26] 2004 GA 1992-2000

14 companies fromTSE300f

Return > B&H whenmarkets fall/are stable,< B&H when markets

rise

NA

[27] 2003 SVM 1989-1998 KOSPI 58% Hit Ratio (BPNN) 54%

Hit Ratio

[28] 2001 SVM 1993-1999

CMM (SP, US30yBond, US10yBond, Ger10y

Bund,MATIF-CAC40)

Normalized MeanSquared Error < BPNNfor all analyzed markets

(BPNN)

[29] 2008 ANN NA FOREX

Used economicquarterly fundamentals

(GDP, CPI) do notimprove model’sprediction power.

NA

[30] 1995 ANN (Multi-variate) 1993

FOREX(USD/Swiss Franc,

USD/DEMg,USD/Yen)

RMSEhNN > RMSERW

Random WalkRMSE

[31] 2003 SVM 1991-2002

FOREX (USD,GBP, Yen,

Singapore Dollar,NZD, Swiss Franc

vs AustralianDollar)

Comparison betweendifferent Kernel type.

Polynomial and RadialBasis kernels produce

smallest NMSE

Linear, RadialBasis and

Spline Kernels

[23] 2010 GA 2006-2010

FOREX(EUR/USD,GBP/USD)

Average Return:+16.6% (EUR/USD),+11.2% (GBP/USD)

NA

aBuy and HoldbKorean Stock Price IndexcBack Propagation Neural NetworkdTokyo Stock Exchange (Japan) main IndexeRandom Walk. Explained in the Financial Markets Chapter of this work, Market Efficiency HypothesisfToronto Stock ExchangegDeutsche MarkhRoot Mean Squared Error

25

Page 44: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

26

Page 45: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3Methodology

Contents

3.1 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.2 Import/Export Data Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

3.3 Machine Learning Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

3.4 Back-testing Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

3.5 Genetic Algorithm Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

27

Page 46: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

28

Page 47: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

In this chapter, this work’s model is described. It starts with an overview of the architecture and a

superficial description of the work flow, and proceeds to sectioning each part of the model and explaining

it with more detail. It contains tables and figures to support the generic descriptions and addresses all

steps, from input required to resulting output.

The model is not only inspired by the literature review listed in Chapter 2, but also real world expe-

rience in a professional trading environment. All steps were carefully thought about and discussed with

seasoned traders.

3.1 Architecture

The Model’s architecture consists in four major blocks: Import/Export Data package, Genetic Algorithm

package, Machine Learning package and Back-testing package. Each of these contain either methods

to handle each part of the process, and the communication between the blocks is constant.

Visually, the architecture can be described as displayed in figure 3.1.

Figure 3.1: Model Architecture.

Overall, the central package is the Genetic Algorithm package. It is the core block of the model,

29

Page 48: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

and most of the other packages are accessed and do their work while the optimization via GA is un-

dertaken. Other packages, especially the Back-testing and the Machine Learning packages, are used

when updating the individual’s fitness inside the Genetic Algorithm.

To understand what is happening as the flow continues, below is a brief description of the steps in

figure 3.1:

1. The routine starts by setting up the genetic algorithm. It imports the initial configurations from a

.ini file and uses that information to prepare the environment. Appendix table A.1 displays these

parameters and possible values.

2. The initial population is generated, with the chromosomes (and ranges) specified in table 3.5. The

GA loop starts: on each iteration, a new generation is created and their fitness is assessed. Every

time a new individual is generated/bred, he is mutated with a given probability, and his fitness is

calculated. Packages Back-test and Machine Learning are used for calculating the fitness.

3. While the Genetic Algorithm package provides the genetic information of the individual, the Im-

port/Export Data package processes the required data (time series) to be used. This data is

stored in two different formats: compact .hdf5 files and a MySql database with the already trans-

formed time series.

4. With the elements from the other two packages, the Machine Learning package starts by per-

forming the necessary computations on the original time series to acquire the features and, in the

case of the training data, to classify it. After all the training data was parsed, the SVM model train-

ing routine starts. The features are then pre-processed (scaled and reduced, as explained in more

detail in the next sections of this chapter) and used to train the SVM model. The trained model is

then returned to the Genetic Algorithm Package to be sent and used in the Back-test Package

in the testing set.

5. When the training set ends and the testing set begins, instead of sending the data set to the

Machine Learning package for training, it is sent to the Back-test package for trading activity

simulation after the feature calculation. The data set is classified using the trained model to get

the trading signals.

6. After back-testing, the individual’s fitness is updated based on a defined scoring methodology (de-

scribed later in this chapter) that considers risk, reward and accuracy. With the fitness calculated,

the model proceeds to select the best individuals for breeding and generates their offspring, cre-

ating a new generation to be evaluated. Until one of the finalizing criteria of the GA is reached

(maximum number of generations or elite individual has been the same for a certain number of

generations), the loop will repeat this process.

30

Page 49: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

7. On every generation, the following information about each individual is printed by the Import/Ex-

port Data package:

• Individual genetic information;

• Charts of the trading activity on each release of the test set;

• Tables containing detail on each generated signal (class) and corresponding features for each

release of the test set;

• Tables containing detail on each position opened or closed, along with the corresponding

price, timestamp, and the type of exit (stop-loss, signal of inversion or end of trading activity

after the release);

After explaining the step by step routine that the algorithm follows, the following figure (Algorithm

3.1) shows the pseudo-code of the routine, and how each package is inserted in the process. The main

function (procedure RunGeneticRountine() in the figure) aggregates all the activity, and returns the best

individual for the problem.

There are two finishing conditions for the Genetic Algorithm: first one is a user defined generation

timeout. For example, if this variable is set to 20, then the GA will run 20 generations and the best

individual of the last generation is the one with the best gene set to solve the problem; the second

condition is a user-defined variable that states that if the best individual is not improved for X generations

in a row, then that individual is the final solution. If one of these conditions is met, the routine finishes.

31

Page 50: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Algorithm 3.1 GSVM Algortihm

1: procedure RUNGENETICROUTINE(iniInputs) . Genetic Algorithm package2: newPopulation← GenerateInitialPopulation()3: newPopulation← UpdateF itness(newPopulation)4: newPopulation← SortByFitness(newPopulation)5: allGenerations.append(newPopulation)6: while GaFinishCondition(1) == FALSE do7: parents← Select(NewPopulation)8: offspring ← Crossover(parents)9: offspring ←Mutate(offspring)

10: offspring ←11: function UPDATEFITNESS(offspring)12: for individuals in offspring do13: dataSet← ImportT imeSeries() . Import/Export Data package14: trainData, testData← SplitData(dataSet, individual) . Machine Learning package15: mlModel←16: function TRAINMODEL(trainData, individual)17: scalingModel← scalingModel.F it(trainData)18: scaledData← scalingModel.T ransform(trainData)19: pcaModel← pcaModel.F it(scaledData, individual)20: transformedData← pcaModel.T ransform(scaledData)21: svmModel← svmModel.F it(transformedData, individual)22: return [scalingModel, pcaModel, svmModel]23: end function24: tradingTrainingResult← . Back-Testing package25: function RUNBACKTEST(trainData, mlModel)26: return [tradingBook, afterTradingDataset]27: end function28: individual.fitness = getScore(tradingTrainingResult)29: end for30: return offspring31: end function32: newPopulation← SortByFitness(parents+ offspring)33: PrintPopulationOutput(newPopulation) . Import/Export Data package34: allGenerations.append(newPopulation)35: bestF itness← newPopulation[0].fitness36: end while37: return allGenerations[−1][0]38: end procedure39:40: (1) gaF inishCondition = sameBestF itnessForXGenerations || generationsT imeout, and X and

generationsTimeout are integers that come from iniInputs

32

Page 51: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.2 Import/Export Data Package

The Import/Export Data Package handles the communication between external data sources and the

program. It imports data from different sources, and exports the results to indexed folders and files,

with tags according to run-time. It is part of the starting and finishing process, and used throughout

the whole routine as data pulls are required. Figure 3.2 is a visual representation of the package, the

corresponding tasks, input and output.

Figure 3.2: Import/Export Data package Architecture.

3.2.1 Data importing

There were two main data sources for this work: Bloomberg1 for Event Information; Reuters2 Data

Services for the conjectural and the traded instrument’s data sets.

For the Reuters time series, the available granularity was tick data3, from 2008 on-wards. A program

was built with the purpose of extracting daily files from an FTP server, to be used as inputs for the model

after the required pre-processing.

For Bloomberg data, a package was included in the model to extract and parse the necessary infor-

mation.1Bloomberg is a major global provider of 24-hour financial news and information, including real-time and historic price data,

financial data, trading news and analyst coverage, as well as general news and sports.2News agency, covering the most important topics, including: business, finance, politics, sports, entertainment, technology,

health, environment, among others.3High granularity data, recorded based on changes in ask price, bid price, ask quantity, bid quantity, last executed order price,

and last executed order quantity. Every time one of these parameters change, a new data point is recorded.

33

Page 52: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

a) Event Information

As mentioned, to access information about different economic releases, Bloomberg was used as a data

source. Bloomberg has a relative importance metric, built based on how many Wall Street investors are

subscribing alerts for a specific number release - the higher the number of subscriptions, the higher the

number’s importance, hence more likely it is to stir up the markets [32], from which the most relevant

releases were selected to be included in the model.

Blpapi (Bloomberg API) was the interface used to import fields from Bloomberg. The input parame-

ters for this data pull are: list of names of the economic releases to account for; start date of the analysis

and end date of the analysis. From these inputs, the model possesses a routine to query Bloomberg to

get a list of the releases that occurred within the analyzed period, their dates and times, the expected

value and the actual released number.

The selected events were the following 4:

• Consumer Price Index (CPI)

Consumer prices (CPI) are a measure of prices paid by consumers for a market basket of con-

sumer goods and services. The yearly (or monthly) growth rates represent the inflation rate.

• ADP National Employment Report (ADP)

The ADP National Employment Report is a monthly measure of the change in total U.S. non-farm

private employment derived from actual, anonymous payroll data of client companies served by

ADP, a leading provider of human capital management solutions.

• Non-Farm Payrolls (NFP)

This indicator measures the number of employees on business payrolls. It is also sometimes re-

ferred to as establishment survey employment to distinguish it from the household survey measure

of employment.

• United States Unemployment Rate Total in Labor Force Seasonally Adjusted (USURTOT)

The unemployment rate tracks the number of unemployed persons as a percentage of the labor

force (the total number of employed plus unemployed). These figures generally come from a

household labor force survey.

• United States Adjusted Retail and Food Services Sales Total Monthly Percentage Change

(RSTAMOM)

Retail sales (also referred to as retail trade) tracks the resale of new and used goods to the general

public, for personal or household consumption. This concept is based on the value of goods sold.4The following information was retrieved directly from Bloomberg’s website [33], with the exception of ADP, which was returned

directly from ADP’s website [34]

34

Page 53: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• United States New Privately Owned Housing Units Started by Structure Total (NHSPSTOT)

Housing (or building) starts track the number of new housing units (or buildings) that have been

started during the reference period.

b) United States Dollar Index Future (DX) Data set

As mentioned in the introductory part of this work, this study will be focused on the United States of

America, one of the strongest economies in the world with the most traded capital markets, the epicenter

of market activity.

The evaluated instrument is the DX [35], a leading benchmark for the international value of the

USD and the world’s most widely-recognized traded currency index (mediated by the Intercontinental

Exchange), which tracks the overall strength of the US Dollar compared to a basket of other currencies

(instead of comparing to a specific currency, as an exchange rate, this index does an in-depth evaluation

of the USD by comparing it to multiple currencies).

The train and test data come from the time series around the macroeconomic release dates and

times. The remaining timestamps can be used for the purpose of calculating technical indicators or

other measures, but trades will only happen during macroeconomic releases.

The data for the DX data set was stored in .hdf5, as it was the format that offered the best per-

formance to load without increasing file size drastically. Rdata files (raw, as they were imported from

Reuters) were very compact, buy their read speed was extremely slow compared to hdf5, hence the

migration.

c) Conjectural time series - Volatility Index Futures Contract (VX) and ES

Conjectural time series were stored differently. After downloading the .RData files from Reuters, an R

script was created to export them to a MySql database. The idea was to build a whole data set that was

easy to use and that had some flexibility in how it was pulled and transformed (which was accomplished

by the use of MySql Views created to handle the roll).

In this case, the aim was to look at daily data that was continuous and involved more than opening

daily files for every release date. For example, to calculate percentiles for the last 60 days of the VX and

ES and understand the general market sentiment, information would be needed on all those days. The

ease of re-sampling in MySql was also a factor that helped in picking this solution. The Model would

then query the created database as needed.

35

Page 54: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.2.2 Data Manipulation

a) Building front contracts

For Future Contracts, as mentioned in the second Chapter of this work, expiration and shift of traded

contracts (a process called Roll) have to be considered. Each contract stops being traded days before

expiration (as the final settlement approaches, the price of the asset starts to closely follow fair price,

leaving no margin for arbitrage opportunities, losing its interest) and there is a general volume shift to

the following contract (as an example, in the 15th of June, a trader would stop trading a certain future

contract expiring in the 30th of June, and would start trading the one for the same asset but expiring in

the 31st of July).

When the data is raw, all that was available was individual, daily files for all the traded contracts at

a given point. For example, in August 2017, there are two DX contracts that are traded: the contract

expiring soon, Sep17; and the one expiring in the next quarter, Dec17.

As adopters of the speculator posture, the ideal contract is the one that can guarantee the easy

closing of our positions and avoid holding the contracts until expiration due to lack of opportunity to

trade. To do so, volume is used to gauge which contract is going to be traded (Front Contract). As the

files are organized by day and have tick data5, the file size is a good proxy of the volume, and it is used

to understand, for a given day, which contract is the one to be traded.

b) Cleaning Outliers

Data cleaning procedures are required, to make sure that there is no bias in the results caused by time

series of data points that did not occur, thus not executable.

One of the inconsistencies found in the data sets was timestamps where the bid was larger than the

ask which, by definition, is not possible. The bid represents the highest price available on the buy side,

and the ask reflects the lowest price that is being offered by sellers; if these two cross, a trade occurs.

Trades will continue until all bids are higher than the lowest offer are satisfied, and all offers lower than

the highest bid are satisfied. If there is a trade, it is reflected in the “Last” field, so this scenario would

not show in the “Bid” and “Ask” fields.

A second method to remove outliers was to remove points where the bid and the ask were too wide

(far from each other). As the front contract is being traded (where volume is considerable), market gaps

would seldom occur, hence the decision of removing data points where the distance between bid and

ask was above a certain threshold.

The final cleaning procedure was removing extreme values using percentiles. For each day, in the5tick data is characterized by the recording of a new data point every time one of the following fields changes its value: bid, ask,

last, bid quantity, ask quantity, last quantity. Its granularity can be as narrow as milliseconds. There is strong correlation betweenvolume and the change rate of the fore-mentioned fields, and more ticks are recorded, increasing the file size.

36

Page 55: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

tick data, the prints that are above the 99th percentile and below the 1st percentile are removed. On

this step, just like in the previous one, real prints can be excluded, but the cost of having an outlier in

data is much higher than losing a few extreme values around which, given that this is done at a tick-data

granularity stage, will possibly have values that are close to it.

c) Re-sampling

As the periods that were addressed (Economic Releases) are especially volatile and possess above-

average volume, tick data around its occurrence tends to be extremely granular. For this work, the

granularity would bring scarce value given the increase in computation complexity and run time associ-

ated with the scale of the time series. Although it was left open to be easily changed in the chromosome

range, it was decided to re-sample the data sets to a fixed value, as shown in the Chapter 4.

3.2.3 Data Exporting

a) Individual Genetic information

Simple text file (TXT format) displaying an individual’s genes. One per individual is generated after the

calculation of its fitness.

b) Chart Set

Figure containing three stacked charts:

• The price of the DX between shortly before the release occurred and a variable amount of minutes6

after the release;

• The individual’s open position (in Contracts) at every timestamp of the trading activity. The individ-

ual had a long position (1), a short position (-1) or a flat position (0);

• The evolution of the individual’s Profit and Loss (PnL) (in USD) at every timestamp of the trading

activity. This includes both the open and the already closed positions.

One Chart Set (Portable Document Format (PDF) format) per economic release per individual is

generated after the calculation of its fitness. An example of a chart set can be found in the next chapter

of this dissertation, on figure 4.5.6Set by one of the individual’s genes. See table 3.5 for more information

37

Page 56: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

c) Trading Book

Data frame (table) displaying one line per trade for a given economic release. A trade is defined by

the opening and closing of a position. The trading book contains more detail on when and under which

circumstances the trade took place, such as the timestamps and prices of entry and exit.

One Trading Book (Tab Separated Values (TSV) format) per economic release per individual is gen-

erated after the calculation of its fitness. An example of a trading book can be found in table 3.1.

Table 3.1: Trading Book Example

Entry Datetime EntryPrice Exit Datetime Exit

PriceEntryQty

PnL(USD)

ExitTypea

2017-10-13 07:30:30 92.87 2017-10-13 07:38:30 92.7225 -1 147.5 12017-10-13 07:39:00 92.72 2017-10-13 08:04:30 92.7175 1 -2.5 3

aExit Type codes: 1 = Covered conditions met exit; 2 = Stop-loss exit; 3 = End of trading period exit.

d) DX Data set

The most informative and comprehensive output exported. It contains each timestamp of the back-test

loop, and the corresponding prices, calculated features (Short Term (ST) and Long Term (LT)), signal

generated by the SVM Model and PnL information.

One DX Data set (TSV format) per economic release per individual is generated after the calculation

of its fitness. A simplified example of a DX Data set can be found in table 3.2. In this example, the

features are not included as they are analyzed in more detail in the appendix section, table A.2.

Table 3.2: DX Data Set Example

Time Mid State Open Pos Signal(Prediction) PnL

07:16 80.25 Entry Sell -1 -1 -1.407:17 80.28 Hold -1 0 -31.407:18 80.28 Hold -1 -1 -31.407:19 80.26 Hold -1 0 -11.407:20 80.27 Hold -1 -1 -26.407:21 80.27 Hold -1 -1 -26.407:22 80.26 Hold -1 0 -16.407:23 80.27 Hold -1 0 -18.907:24 80.26 Hold -1 0 -11.407:29 80.23 Hold -1 0 13.607:30 80.23 Hold -1 1 18.607:31 80.23 Cover Sell 0 1 12.2

38

Page 57: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.3 Machine Learning Package

This package contains processes related to feature calculation, pre-processing, and training of the SVM

model. Although a separate package, its operation is performed entirely inside the GA package, as part

of individual’s fitness calculation.

Figure 3.3: Machine Learning package Architecture.

3.3.1 Pre-processing

a) Building Technical Indicators

To calculate most of the technical indicators included in this analysis, TA-Lib’s python library was used

[36]. It is a widely used library with a very comprehensive range of technical indicators. This is one of

the last steps before the preparation of data for training the SVM model. The selected indicators are the

following:

• Simple Moving Average (SMA) is an arithmetic average of the data points comprised between

current and a number of periods before current.

• Relative Strength Index (RSI) is a momentum indicator that measures the magnitude of recent

price changes to analyze if the instrument is close to inverting its trend (overbought or oversold

conditions).

39

Page 58: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• Exponential Moving Average (EMA) has the same fundamentals as the Simple Moving Average,

the difference being that the EMA differentiates how it weights different periods based on distance

to current period, with the objective of giving more importance to the nearest past.

• Momentum (MOM) simply measures the difference between current price and the price a certain

number of periods before.

• Percentile (PCT) separate the N sorted prices into 100 chunks of about N/100 observations each.

Here, an input defines how many periods before current to include in the percentile calculation. The

threshold parameter controls when the price is considered to be overbought (lowest percentile) or

oversold (highest percentile).

For each indicator, longer and shorter term periodicity was included. The term’s actual periodicity

was set by the GA, but different terms had different ranges to pick values from (see table 3.5)

The following table (3.3) shows with more detail how these indicators are calculated, and how the

corresponding result helps in generating signals.

Table 3.3: Technical Indicators Structure

ShortName Input Formula Intuition

SMAnumberOfPeriods= size of rolling

windowPxt − SMAt =

∑ti=t−numberOfPeriods Pxi

numberOfPeriods

BUY if SMAt > PxtSELL if SMAt < Pxt

else, HOLD.

RSI

numberOfPeriods= size of rolling

window;thresh = RSI

threshold

RSIt = 100 - 100 / (1 + RS)RS = Average gain of up periods during thespecified time frame / Average loss of down

periods during the specified time frame

BUY ifRSI t > (100− thresh)SELL if RSI t < thresh

else, HOLD.

EMAnumberOfPeriods= size of rolling

window

EMAt = EMAt-1 + K * (Pxt - EMAt-1)

K =2

n+ 1

BUY if EMAt > PxtSELL if EMAt < Pxt

else, HOLD.

MOMnumberOfPeriods= size of rolling

windowMOMt = Pxt – Pxt-numberOfPeriods

BUY if MOM t < 0SELL if MOM t > 0

else, HOLD.

PCT

numberOfPeriods= size of rolling

window;thresh = PCT

threshold

PCT (K) =numberOfPoints(Px < K)

numberOfPeriods∗100

Where PCT(K) is given and a price K thatmakes the condition true is seeked

BUY ifPxt < PCT (thresh)

SELL ifPxt > PCT (1− thresh)

else, HOLD.

40

Page 59: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.3.2 Classification

a) Classes

The classification of each data point was divided into three categories (where SVM - Time Ahead is a

gene of each individual, see table 3.5 for more detail):

• Buy signal (1) if the price of the traded product was significantly above current in SVM - Time

Ahead future time periods.

• Sell signal (-1) if the price of the traded product was significantly below current in SVM - Time

Ahead future time periods.

• Hold signal (0) if the difference between the current price and price in SVM - Time Ahead periods

is not significant (being significant measured by the parameter SVM - Minimum Variation for Signal

of the GA).

The Hold class was added and shaped to improve the proximity to real world conditions and to mitigate

the transaction cost damage coming from the increase in the number of trades.

b) Training vs Testing

The train and test split is done at two different moments: first, all the releases are listed and split, ac-

cording to a percentage set by one of the individual’s genes; the second moment is after the aggregation

of all the training data from the first step, and before training the SVM Model (A fixed percentage of 50%

was used in this second stage of splitting, coming from trial and error).

The first moment, is a chronological division and set up of how much past data the model will be

using to train and classify future data points. The second moment is just a randomized way to downsize

the training sample, finding a percentage to increase performance without losing accuracy.

c) Features

The features are the variables that will be used to predict the outcome (class). In this work, the types of

features that were used can be divided into three:

• History of the traded product , among which lie the Techninal Indicator signals explained in

a previous subsection. They measure direction (Buy, Sell or Hold) and intensity (distance from

metric, which may indicate stronger or weaker signals).

• Conjectural variables, to analyze the status of the market compared to its medium-term history.

Percentiles of two different financial instruments for this were used: the VX, and the ES.

41

Page 60: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• Event-specific variables, to understand if the release information was different than what was

expected by market agents (according to Bloomberg), represented by the difference between what

was surveyed and the actual release.

A complete list of the features and the corresponding explanation can be found in table 3.4.

Table 3.4: Feature Explanation

Name Description Unit

SMADifference between current price and the rolling SMA. There are twoSMA features: a short and a long term. See table 3.3 to understand

how the signals are calculated.

Decimal<0 (Sell), 0 (Hold), >0

(Buy)

RSI Current RSI value. There are two RSI features: a short and a longterm. See table 3.3 to understand how the signals are calculated.

Decimal0, ..., 100

EMADifference between current price and the rolling EMA. There are twoEMA features: a short and a long term. See table 3.3 to understand

how the signals are calculated.

Decimal<0 (Sell), 0 (Hold), >0

(Buy)

MOMDifference between current price and price X periods before (where Xis a chromosome). There are two MOM features: a short and a long

term. See table 3.3 to understand how the signals are calculated.

Decimal<0 (Sell), 0 (Hold), >0

(Buy)

PCT

Difference between current value and the Percentile (set by achromosome) of the traded instrument. There are four PCT features: a

short and a long term, each with one version comparing to the highand low percentiles. See table 3.3 to understand how the signals are

calculated. DX.

Decimal

VIX

Difference between current value and the Percentile (set by achromosome) of the conjectural instrument VX. It will generate apositive signal indicating if the VX current price is above a given

threshold, negative otherwise. The underlying idea is to discriminatebetween volatile and directional periods, and adjust signals

accordingly. Calculations are as explained for the PCT indicator ontable 3.3.

Decimal

ES

Difference between current value and the Percentile (set by achromosome) of the conjectural instrument ES. It will generate apositive signal indicating if the ES current price is above a given

threshold, negative otherwise. The underlying idea is to discriminatebetween extreme and moderate values, and adjust signals accordingly.

There are two ES features: one version comparing to the high andother to the low percentiles. Calculations are as explained for the PCT

indicator on table 3.3.

Decimal

Surprise Difference between actual released value and expected value. Decimal

CPI Dummy variable to discriminate what type of Macroeconomic releasethe remaining features are associated with. 1 (True), 0 (False)

ADP Dummy variable to discriminate what type of Macroeconomic releasethe remaining features are associated with. 1 (True), 0 (False)

NFP Dummy variable to discriminate what type of Macroeconomic releasethe remaining features are associated with. 1 (True), 0 (False)

USURTOT Dummy variable to discriminate what type of Macroeconomic releasethe remaining features are associated with. 1 (True), 0 (False)

RSTAMOM Dummy variable to discriminate what type of Macroeconomic releasethe remaining features are associated with. 1 (True), 0 (False)

NHSPSTOT Dummy variable to discriminate what type of Macroeconomic releasethe remaining features are associated with. 1 (True), 0 (False)

d) Balancing

Balancing consists on finding the equilibrium between how many data points of each class are present

on the training data. Having heavily predominant classes can bias the model, so it was decided that the

data set would be balanced before training the model.

42

Page 61: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

The balancing process can be done by randomly reducing the size of the class with more occurrences

to the same size as the less predominant class. After balancing, the data set would resume its pre-

processing by moving to the scaling phase.

In this work, a balancing algorithm was tested. As some literature suggested that, for Support Vector

Machines, unbalanced data sets may actually help the model to understand the right structure of the

class distribution and given that the inclusion of the balancing routine did not improve results, we opted

to exclude it in the final approach.

e) Scaling

The usual process of scaling is used to transform all the features into small, similar (or close to) values,

not only to increase the performance (due to the avoidance of numerical difficulties during the calcu-

lations), but also to avoid domination of attributes with a greater numerical range. In this work, the

standardization was done through SciKit’s [37] RobustScaler function, a method created for this pur-

pose. Among the scaling solutions, this approach was selected because it standardizes all values to a

small scale (around [0, 1], although some points fall outside the fore-mentioned range due to the use of

quantiles instead of maximum and minimum values).

The scaling function is as shown in equation 3.1:

xi −Q1(x)

Q3(x)−Q1(x)(3.1)

As stated, quantiles are used instead of max-min range, making it more robust to outliers. Default

Q1 is 25 and Q3 is 75.

This scaler (more specifically, the quantiles) are set during the training phase, and the test data is

scaled using the trained scaling model. For example, if Q1training = -10 and Q3training = 10, when

scaling a value of 17, the result would be 1.35 as the scaled value.

3.3.3 Support Vector Machines

The Machine Learning methodology selected for the prediction of financial time series in this work was

the SVM model. The SciKit’s Python package Support Vector Classification (SVC) function was used to

train and elaborate the model.

a) Principal Component Analysis (PCA)

In order to decrease the size of the problem and increase the performance, PCA was used. For the

purpose, SciKit’s Decomposition PCA function was used. According to the documentation, this function

43

Page 62: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

uses ”Linear dimensionality reduction using Singular Value Decomposition7 of the data to project it to a

lower dimensional space”.

The number of dimensions the whole feature space is reduced to is a gene of each individual, within

a predefined range.

b) Kernels and Parameters

Among the tested kernels, the most popular ones were used: Linear, Radial-Basis Function, Polynomial

and Sigmoid functions. It is part of the genetic optimization routine to understand which of these kernels

deliver the best results, together with the tuning of the hyper-parameters of each trained model.

The tuned parameters are either kernel-agnostic (the penalty parameter C and the time ahead vari-

able that defines how far long each point will try to predict) or kernel-specific (the Degree parameter is

only used in the Polynomial kernel, and the gamma parameter is not used in the Linear kernel).

Another set of parameters that can be tweaked in the SciKit’s SVC function to improve the model

accuracy (with a given computational cost) are the using probability and the shrinking parameters, rep-

resenting the use of probabilities in the estimation part of the model and the shrinking heuristic, respec-

tively.7factorization of a real or complex matrix, see [38] for more detail.

44

Page 63: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.4 Back-testing Package

The Back-testing Package is where the parameters are applied to a simulated-trading environment.

Being it for in-sample optimization or for out-of-sample performance measuring, this package puts the

parameters to test to understand how a trader following that specific set of rules would perform.

Figure 3.4: Back-testing package Architecture.

As explained, the back-test routine consists in the simulation of trading activity to try to understand

how a specific set of parameters would perform in the markets. It receives a set of parameters (genes for

a given individual) and a prediction package (composed by three elements: a Scaler, a Principal Com-

ponent Analysis trained model and an Support Vector Machine trained model), that it uses to generate

Buy, Sell or Hold signals based on present data and act accordingly.

The progression is then done through a loop on the time series of the Dollar Index Future after the

release of the number.

A set of rules were also included to approach this simulated moment of trading to reality:

• Initial lag. The trading activity only starts after a predefined amount of time passes after the

release of the economic data (for example, the first buy/sell for a number that was released at

14:00:00 will only be possible after 14:01:00).

• Execution delay. After the model generates the signal, the action takes 1 period to be undertaken.

If the used got a Buy signal at 14:15:00, he will only act upon it in the next data point (for 30 second

data, it would be at 14:15:30).

45

Page 64: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• Stop-loss. When the trader has an open position, it will exit that position in one of three possible

ways: (1) closing the position when the next opposite signal is generated and that position is at

least breaking-even; (2) closing the position to avoid further losses (through a specific stop-loss

percentage); (3) when the time after the number that is being traded expires.

• Conservative execution. The price at which the trader is able to execute its market actions is not

the market price (buying the best bid, selling the best ask), but the mid price (average between

best bid and best ask).

Alternative approaches have been used in other work, such as using market or last price, but it

was decided that using last price (last traded price) or assuming fills at bid when buying or ask

when selling would be unrealistic.

It is considered that there are uncontrollable moving parts on the possibilities of being able to

execute at those values (last is a reflex of past information, and market fills are attributed according

to a complex group of variables (part FIFO, part based on how many contracts you are quoting,

part determined algorithmically).

Another important part of the developed back-tester are the exit and entry conditions. The individual

has three possible states: he has an open long position, an open short position, or no open position

(using trading jargon, he is flat).

For the individual to open a position, two conditions need to be met: first, the individual needs to

be in the no open position state; when in that state, the SVM model signal will determine what type of

entry position the individual will open (or not, in case of a hold signal).

For the individual to close a position, three conditions need to be met: first, the individual needs

to have an open position of either of the types (long or short); second, the SVM model signal needs

to be the opposite of the already opened position; finally the mid price needs to be higher or equal

to the associated entry price (this last condition can be disregarded depending on the gene set of the

individual).

46

Page 65: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.5 Genetic Algorithm Package

Figure 3.5: Genetic Algorithm package Architecture.

3.5.1 The Individual

Figure 3.6: Genetic structure of anexample individual.

In this Genetic Algorithm, an Individual is composed by a set of

genes, each of them with influence on the calculation of the indi-

vidual’s fitness and affecting calculations in other packages.

The chromosomes of the individual can be divided into four

generic types:

• Sizing parameters

• Trading parameters

• SVM hyperparameters

• Pre-processing parameters.

The two following figures enlighten how these individual are

structured: figure 3.6 shows an example of an individual’s genetic

information with a possible random example of values, while table

3.5 shows all the 29 chromosomes complemented by a description

of each and the range of valid values.

47

Page 66: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Table 3.5: Individual StructureChromosome Description Unit Range

Time after release Minutes after the release with trading activity. Integer(Minutes) 30 ,..., 120

Tick datare-sampling size Tick size to re-sample time-series. Integer

(Seconds) 60

Stop Loss How much the trader is willing to lose until hecloses a position and accepts the loss. Percentage 3% ,..., 7%

Loss ClosePrevention

Allows (or forbids) the trader to close positionsthat have a negative PnL when the model

generates a cover signal.Bool True/False

PCA - Number ofComponents

Number of components that the model reducesthe features to. Integer 3 ,..., 19

SVM - Kernel Kernel to be used when training the SVM model. String ”Linear”, ”Poly”,”RBF”, ”Sigmoid”

SVM - C Penalty parameter of the SVM model. Decimal 2(−3,...,10)

SVM - Gamma Kernel coefficient for ”rbf”, ”poly” and ”sigmoid”functions. Decimal 2(−5,...,4)

SVM - UsingProbability?

Whether to enable probability estimates.Slowsdown model but may increase accuracy. Bool True/False

SVM - Shrinking? Eliminates variables to reduce size of theproblem and increase performance [39]. Bool True/False

SVM - Maxiterations

Hard limit on iterations within solver. Introducedto improve efficiency. Integer 15000

SVM - Degree Degree of the polynomial kernel function. Integer 1 ,..., 4

SVM - Time Ahead Determines how far ahead the model will try topredict.

Integer(Seconds) 600 ,..., 1800

SVM - Trainpercentage

Percentage of the total sample that will be usedfor training. Percentage 66.6%

SVM - MinimumVariation for Signal

Minimum variation of price that triggers a Buy orSell Signal. Percentage 0.1% ,..., 1.5%

EMA - Number ofPeriods (x2)

Number of periods to be used in the calculationof the EMA (see table 3.3 for more detail).

Integer(Seconds)

120 ,..., 720 ST;3000 ,..., 4800 LT

SMA - Number ofPeriods (x2)

Number of periods to be used in the calculationof the SMA (see table 3.3 for more detail).

Integer(Seconds)

120 ,..., 720 ST;3000 ,..., 4800 LT

MOM - Number ofPeriods (x2)

Number of periods to be used in the calculationof the MOM (see table 3.3 for more detail).

Integer(Seconds)

120 ,..., 720 ST;3000 ,..., 4800 LT

RSI - Number ofPeriods (x2)

Number of periods to be used in the calculationof the RSI (see table 3.3 for more detail).

Integer(Seconds)

120 ,..., 720 ST;3000 ,..., 4800 LT

DX - Number ofPeriods (x2)

Number of periods to be used in the calculationof the DX percentile (see table 3.3 for more

detail).

Integer(Seconds)

120 ,..., 720 ST;3000 ,..., 4800 LT

RSI - Threshold Threshold value to trigger decision from RSIcalculations (see table 3.3 for more detail). Integer 1 ,..., 50

DX - PercentileThreshold

Threshold value to trigger decision from RSIcalculations (see table 3.3 for more detail). Integer 1 ,..., 50

VIX - PercentileThreshold

Threshold value to trigger decision from VIXpercentile (see table 3.3 for more detail). Integer 1 ,..., 50

ES - PercentileThreshold

Threshold value to trigger decision from ESpercentile (see table 3.3 for more detail). Integer 1 ,..., 50

48

Page 67: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.5.2 Selection

Figure 3.7: Illustration of the Selection process.

For the selection process, a hybrid approach was selected between a Truncate Selection (Individuals

with the highest fit would breed) and a randomized lesser number of individuals to be included in the

breeding process. Elitism was also implemented, so breeders would not only generate children, but

also move on to the next generation to compare fitness with the new individuals.

The selected Elite was 10 % of the top individuals of the previous generation, the randomly picked

individuals would account for 15 % percent of the next generation (and around 60% of the breeders), and

the remainder of the generation would be offspring from the crossover/mutation process. The selected

breeders would all move on to the next generation.

3.5.3 Crossover

Figure 3.8: Illustration of the Crossover process.

From the individuals selected to breed, the offspring for the new generation is created. The breeding

(or crossover) process consists on the generation of a new individual based on the characteristics of two

other individuals (parents), inheriting one gene from one parent or the other with 50% probability.

This is a good way to find if there is gene set between two already good performing individuals that

would get you into a higher fitness boundary, discovering a better solution for the problem.

49

Page 68: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

3.5.4 Mutation

Figure 3.9: Illustration of the Mutation process.

Because the Crossover process is prone to sticking to local maximum/minimum, before calculating

the generated offspring’s fitness, their genes are mutated.

The mutation rate determines the probability of gene randomization given an individual that resulted

from breeding. The objective is to avoid local extremes and randomly seeking better global solutions for

the optimization problem. When setting the mutation rate, one also needs to be careful with its value

being set too high, as it will make it harder for the model to converge within a specified region. It will look

for spread solutions across the total search space, but it will be less likely (or take more time) to find the

most optimal solution in a specific region of the search space.

A mutation rate of 10% was used.

3.5.5 Fitness Function

Figure 3.10: Illustration of the Fitness Calculation process.

The Fitness function is a key element for the GA. It defines what to search for, sets what is reasonable

or not in terms of comparison, and it is fully customizable from a developing perspective, as long as

it results in a metric that is uniform and comparable throughout all the analyzed individuals within a

population.

Given its flexible nature, it is a challenge for the developer to understand the considerations of using

available metrics.

Tendency to overfit is one of the characteristics that should be highly controlled when selecting

a fitness measure. If the selected metric is too specific to each sample, than there is the possibility

50

Page 69: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

of the GA finding a solution that performs very well in-sample and poorly out-of-sample. This is a

common problem in ML, challenging to solve and a flag to the possibility of the analyzed problem not

being solvable using the selected model. The role of the developer is to pick a metric that tests the

generalization potential of the solution rather than simply its raw performance during the training period.

Another challenge when creating a fitness function is the complexity of the calculations involved.

This is more problematic because of its impact on the model’s resource usage (time and computing

power) rather than the direct impact on the found solution. Indirectly, having a high resource cost will

limit the developer’s possibility to increase population size and/or number of generations, and these

variables directly affect convergence to an optimized solution.

Scaling is also a factor to consider. Should the metrics be normalized to the same scale (0-100, for

example)? In some cases, this might not be required, but if a mixed fitness function based on multiple

metrics is created (for example, PnL and prediction accuracy), then one would not want a metric to

overwhelm others because of its absolute value being much greater than others. This could ultimately

lead to overfit or bias the results to a metric that was supposed to be complementary.

For the fitness value and a way to compare individuals in this model, two different paths were initially

tested: using the PnL (in USD) and using the model’s accuracy (in percentage of right hits). In the

background, one might consider that these two will ultimately lead to the same results: higher accuracy

means that the model successfully predicts more often, and better information about latest periods would

lead to better decisions today, resulting in a higher PnL. This logic may hold but, in the trading landscape,

frequency of right hits may be overtaken by successfully predicting the right, most-profitable patterns.

When using PnL, overfit was always present. Most optimized parameters performed very well in-

sample, and then very poorly out-of-sample (loss, and performance below Buy and Hold). When using

Accuracy, most of the times there was a loss (negative PnL), showing that, as a single criteria, the

found solution would tend to privilege hitting right most of the times and this was not the best performing

strategy (Profit & Loss wise).

Knowing that each of the solutions captured part of what the model sought to achieve while keeping

the fore-mentioned fitness function challenges in mind, the decisive next step was to create a weighted

fitness function that would include three action avenues: raw Profit & Loss, Risk and Accuracy. Four

metrics were selected to account for the three action avenues: the Sharpe Ratio, Accuracy, PnL and

PnL to Max Drawdown Ratio (more detail in chapter 4). Weights were set to each metric, and after

testing multiple combinations, a trial and error process led to a combination that is displayed in chapter

4, more specifically in tables 4.3, 4.7 and 4.11.

To scale the metrics, equations 3.2 3.3 and 3.4 were used:

51

Page 70: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

ScaledPnli =Pnli −min(generation(Pnl))

max(generation(Pnl))−min(generation(Pnl))(3.2)

ScaledSharpei =Sharpei −min(generation(Sharpe))

max(generation(Sharpe))−min(generation(Sharpe))(3.3)

ScaledPnlddi =Pnlddi −min(generation(Pnldd))

max(generation(Pnldd))−min(generation(Pnldd))(3.4)

As for the accuracy metric, it was kept as its original value as it was already in the right scale (between

0 and 1).

To show how the formulas work, equations 3.5 and 3.6 illustrate with an easy example. Imagine the

following vector of PnL values:

PnlV ec = [2,−20, 10, 20, 10] SharpeV ec = [0.1, 0.2, 0, 0.5, 0.8] Weights = [0.8, 0.2] (3.5)

Notice that the maximum value of the PnlVector is 20, while the minimum is -20. In the SharpeVector,

the maximum value is 0.8, while the minimum is 0. Applying the scaling formulas, we would get the

following scaled vectors:

ScaledPnlV ec = [0.55, 0, 0.75, 1, 0.75] ScaledSharpeV ec = [0.125, 0.25, 0, 0.625, 1] (3.6)

After scaling all the necessary vectors, we would then use the setup weights to build a score for each

individual: Scores = [0.55∗0.8+0.125∗0.2 = 0.465, 0∗0.8+0.25∗0.2 = 0.05, ...], and rank the individuals

based on the score.

The Fitness function calculation of the GA involves parts of the other three packages of the model: the

Import/Export Data package, the Back-test package and the Machine Learning package. It wraps up

most of the described steps in this chapter and its calculation represents the most resource-demanding

phase of the model.

To increase performance and given the functional split between different individuals, the fitness up-

date calculations run in parallel (using python’s multiprocessing capabilities), where one process is one

individual. This way, the hardware capabilities are exploited and a speed up factor close to the number

of cores in the CPU of the computer the model is running in is achieved.

52

Page 71: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

4Results

Contents

4.1 Performance Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

4.2 Case Study I - GA only for economic release training . . . . . . . . . . . . . . . . . . 57

4.3 Introducing Feature Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

4.4 Case Study II - Genetic Support Vector Machines (GSVM) for economic release

trading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

4.5 Case Study III - GSVM for continuous ES trading . . . . . . . . . . . . . . . . . . . . . 72

4.6 Summary Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

53

Page 72: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

54

Page 73: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

In this chapter, the results are analyzed, not only from the main focus of this dissertation, but also

alternative scenarios (referred to as case studies).

It starts with the description of the used metrics to compare different runs of each scenario, and pro-

ceeds to inspecting the outcome of every ran scenario. In each analysis, four subsections are included:

one to disclose the initial configuration of the case study; one to evaluate the genome of the best indi-

vidual of each run, looking for patterns; the third subsection pinpoints scrutinizing in-sample results and

the fourth subsection focuses on the out-of-sample fragment of the scenario.

This chapter ends with a comparative analysis between the assessed case studies, why they were

selected, how the results changed, and possible causes for the drawn conclusions.

Notice that in all scenarios and case studies, we are trading futures and, as explained in Chapter 2,

these financial instruments are highly leveraged because they only require the trader to use a margin of

the price of the contract while keeping the returns inherent to the full price move.

The DX has a margin requirement of around 2.5 % (around 1:40 leverage factor) while the ES contract

has a margin requirement of around 7 % (around 1:14 leverage factor). As an example, imagine that

the price of a given futures contract is 100 USD, and its margin requirement is 10%. The trader buys

the contract at the price of 100 USD and, after that, the contract moves to 105 USD, price at which the

trader sells the contract. The trader only had to use 10 USD (price times margin requirement) of capital,

and he got a 5 USD profit. So even though the contract price only increased by 5 %, the trader got a

return of 50 % on its 10 USD investment. The same logic works for losses, so it is a heavily regulated,

high risk trade.

4.1 Performance Evaluation

To evaluate and compare results, a list of metrics was selected. The used formulas and measuring

methodologies pinpoint not only understanding and directly comparing the main result (profit), but also

to analyze consistency, risk/reward relationship and the behaviour of the model throughout the training

and testing period.

A script was created to calculate the evaluation metrics. The input for this script are the different

Trading Books and Discriminated Time Series for all the best individuals of each algorithm run. Notice

that, in the following descriptions, the term ”trade” is used to describe not a single transaction, but the

opening and closing of a position. Tables 4.2 and 4.1 summarize the used metrics, together with a brief

description and formula to explain how these metrics work.

In table 4.1, metrics that are related with the overall performance of the individual are evaluated.

This is a table summary with return and risk adjusted measures of how the individual performed in

the analyzed period. It shows results-related metrics that are used to compare how different scenarios

55

Page 74: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

behaved in the period as a whole.

Table 4.1: Performance Metrics - Return

Metric Formula Description

AnnualizedSharpe Ratio

Avg(DailyReturns)∗√#TradingDays

StDev(DailyReturns)

Risk adjusted returns - a ratiobetween the average value of the

model’s PnL curve and thecorresponding Standard Deviation.

The higher the Sharpe ratio, thebetter the risk-adjusted returns

Total P&L∑DailyP&L Sum of the PnL of all trades

Used Capital − Used capital during the tradingperiod.

CumulativeReturns

TotalP&LUsedCapital

Ratio between the Total P&L and theUsed Capital

AnnualizedReturns (1 + CumRet)(

252#TradingDays ) − 1

Adjustment to Cumulative Returnsto make the value comparable with

different periodicity strategies

P&L / MaxDrawdown

TotalP&LMaxDrawdown

Risk adjusted measure to comparereturn (via Total P&L) with risk (viaMax Drawdown). The higher, the

better risk-adjusted returns.

In table 4.2, metrics are evaluated, but in this specific table the metrics are related with the evolution

of the trading activity, the peaks, consistency, accuracy of the model, among other pieces of useful

information that do not reflect the raw performance of each individual, but more of an overview on

its overtime stability and how it behaved during the run. This information leads to conclusions and

understanding of what drove the results.

56

Page 75: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Table 4.2: Performance Metrics - Non-Return

Metric Formula Description

Accuracy #CorrectClassifications#TotalClassifications

Percentage of right classificationsof the SVM algorithm

Average Profit∑

ProfitPerTrade#Trades

Mean of every trade

Number ofTrades #Trades Total number of trades

Winning TradeRate

#TradesWhereP&L>0#Trades

Ratio between the trades withpositive PnL and the total number

of trades

Number ofstop-lossTrades

#ExitsByStopLossNumber of trades that triggered the

stop-loss criteria

Most ProfitableTrade Max(ProfitPerTrade) Trade with the highest PnL

Most CostlyTrade Min(ProfitPerTrade) Trade with the lowest PnL

HighestWinning Streak Max(ConsecutiveTradesWhereP&L > 0)

Highest number of consecutivewinning trades

Highest LosingStreak Max(ConsecutiveTradesWhereP&L < 0)

Highest number of consecutivelosing trades

MaximumDrawdown

P − Lwhere P = Peak value before largest drop

and L = Lowest value before new highestablished

Maximum loss (in USD) from apeak to a trough of the model’sPnL curve, before a new peak is

attained

Positive Days #DayswhereP&L > 0Number of days in the trading

period where PnL > 0

Negative Days #DayswhereP&L < 0Number of days in the trading

period where PnL < 0

4.2 Case Study I - GA only for economic release training

The analysis started with the simplest scenario: the environment maintained, the model simplified.

In this case study, no SVM was used, only a simple GA that generates signals based on the simple

aggregation of technical indicators. The trading activity takes place during a short period after economic

releases, and the traded financial instrument is the DX. The trading signals are trivial: all the indicators

are calculated for each time period, and transformed individually in one of three values: 1 (Buy signal),

0 (Hold signal) and -1 (Sell signal). All the signals added, and a similar logic is used in this aggregated

57

Page 76: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

signal: if it is greater than 0, it is a buy signal; if it is equal to 0, it is a Hold signal; if lower than 0, it is a

sell signal. This aggregated signal is what drives the trading activity.

4.2.1 System Parameters

For greater convenience, all the parameters of the implemented system are summarized in table 4.3.

In this case study, we fixed the granularity to 60 seconds (1 minute), so the number of periods in the

technical indicators is expressed in minutes.

Table 4.3: Case Study I Configuration Parameters

Category Parameter ExamplePeriod Start date [2010,10,20]Period End date [2017,10,20]

Instrument Details DX margin 2.5%Instrument Details DX tick value 1000Instrument Details DX transaction cost 1.41Instrument Details ES margin 7%Instrument Details ES tick value 50Instrument Details ES transaction cost 1.41

GA Population size 30GA Rounds timeout 10GA Improvement stop 5GA Best sample 0.1GA Lucky sample 0.15GA Chance of mutation 0.1GA Weight Accuracy 0.4GA Weight P&L 0GA Weight Sharpe 0GA Weight P&L/dd 0.6

MySql Long term days 75MySql Long term periodicity (Seconds) 86400

No adjustments of any kind were made to the system during its evaluation.

4.2.2 Best Individuals

These were the top individuals of the final generation of five separate GA runs. Doing multiple simula-

tions helped in understanding what changed in between them, if they converged to a similar individual

or not, how spread were the parameters, and if there were multiple valid solutions to tackle the problem.

Notice that the technical indicator number of periods are minutes (as we used 60 seconds as the fixed

granularity for this case study).

58

Page 77: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Table 4.4: Case I - Best Individual per simulation

Chromosome 1 2 3 4 5 Min Max AvgTime after Release 31 36 35 32 59 31 59 38.6

Tick Data Re-samplingsize 60 60 60 60 60 60 60 60

Train Percentage 0.66 0.66 0.66 0.66 0.66 0.66 0.66 0.66Stop-loss 0.14 0.08 0.075 0.1 0.085 0.075 0.14 0.096

Loss Close Prevention True True True True TrueEMA LT number of periods 60 50 60 50 50 50 60 54SMA LT number of periods 70 50 70 70 70 50 70 66

MOM LT number ofperiods 70 70 70 70 70 70 70 70

RSI LT number of periods 60 70 70 70 70 60 70 68DX LT number of periods 60 50 70 50 70 50 70 60

EMA ST number ofperiods 4 8 4 2 6 2 8 4.8

SMA ST number ofperiods 2 6 6 6 2 2 6 4.4

MOM ST number ofperiods 10 8 10 8 4 4 10 8

RSI ST number of periods 2 4 2 8 4 2 8 4DX ST number of periods 4 6 4 6 10 4 10 6

RSI threshold 46 41 26 41 41 26 46 39DX percent rank threshold 0.21 0.31 0.41 0.36 0.01 0.01 0.41 0.26

VX percentile to trade 0.41 0.46 0.46 0.41 0.01 0.01 0.46 0.35ES percentile to trade 0.21 0.41 0.46 0.46 0.41 0.21 0.46 0.39

By looking at table 4.4, the first pattern that meets the eye is the low Time after Release across the

board (all the best individuals of the five runs have a Time after Release value lower than 60, when this

variable could take values up to 120). This means that these individuals prefer to stay off the market

rather than involved for longer periods after economic data is released.

In terms of Stop-loss, the range is wide: from a minimum of 7.5% up to 14% value, indicating that

there are different perspectives from different individuals in terms of realizing when a non profitable trade

is not recoverable.

Finally, the predominance of the Loss Close prevention rule is noticeable, helping the trading signals

to avoid acting too early, reflecting a lack of power in the signal to let it fully drive the trading activity.

59

Page 78: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

4.2.3 In-Sample

Despite the positive performance (above zero cumulative returns), the in-sample results for the single

GA approach were not satisfactory. One individual would have made more money by simply buying the

DX contract and simply holding it until the end of the period, rather than follow the signals generated by

the model.

To be noted that although the final outcome is unfavourable when compared to the Buy and Hold

approach, looking at figure 4.1, the GA runs yield steadier results, with modest variations, making it an

approach with apparently less risk that the Buy and Hold strategy.

Figure 4.1: Cumulative Return chart for the different in-sample runs of Case Study I.

Looking at table 4.5 and as seen in figure 4.1, this case study’s individuals follow a similar pattern.

Due to the way that the signals are calculated, only an extreme difference would cause a more uncorre-

lated outcome in terms of trading action, which does not happen. All the scenarios look highly correlated,

with the exception of the best individual of the 5th run, who outperformed their competitors (but not the

Buy and Hold follower).

60

Page 79: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Table 4.5: Case I - In-sample performance per simulation

Metric 1 2 3 4 5 B&H Min Max AvgAccuracy (%) NA NA NA NA NA 0Average Profit 1.94 4.07 2.67 2.97 3.15 20042 1.94 4.07 2.96

# Trades 908 1056 1014 971 1544 1 908 1544 1098.6Winning Trade

Rate (%) 65.42 68.84 66.17 67.97 74.29 100 65.42 74.29 68.538

# Stop-loss 12 67 78 36 99 0 12 99 58.4Max Profit 382.2 382.2 382.2 382.2 382.2 20042 382.18 382.18 382.18Min Profit -351 -201.8 -189.3 -251.5 -214.2 0 -351 -189.3 -241.6Max WinStreak 11 11 14 17 16 1 11 17 13.8

Max LossStreak 6 7 6 7 5 0 5 7 6.2

MaxDrawdown 1790.3 1573.5 1543.9 1610.7 1688 8452.5 1543.9 1790.3 1641.3

AnnualizedSharpe 3.82 8.1 5.43 5.78 8.93 7.45 3.82 8.93 6.41

P&L 1828 4365.7 2757 2950.3 4931.4 20042 1828 4931.4 3366.5Used Capital 10000 10000 10000 10000 10000 10000 10000 10000 10000CumulativeReturns (%) 18.28 43.66 27.57 29.5 49.31 200.43 18.28 49.31 33.66

AnnualizedReturns (%) 0.72 1.55 1.04 1.1 1.72 4.78 0.72 1.72 1.23

Positive Days 141 143 148 145 142 137 141 148 143.8Negative Days 119 117 112 115 118 123 112 119 116.2

P&L / MaxDrawdown 1.02 2.77 1.79 1.83 2.92 2.37 1.02 2.92 2.07

4.2.4 Out-of-sample

When trading out-of-sample, the results were surprisingly better than in-sample: all runs’ best individu-

als had higher cumulative returns than the Buy and Hold follower, and most of them even had positive

returns, as displayed in figure 4.2. This chart displays the same characteristic as the in-sample perfor-

mance: modest movements, especially when compared with the Buy and Hold return evolution, caused

by the lack of participation of the trading agents in the markets during most of the time that it is open to

trading, coherent with the focus of this dissertation on the aftermath of economic releases and the fact

that the best performing individuals naturally prefer to stay for a short time even after these periods, as

stressed in the in-sample section of this Case Study.

61

Page 80: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Figure 4.2: Cumulative Return chart for the different out-of-sample runs of Case Study I.

Table 4.6 also reflects the similarity in results of every individual: small range between the maximum

and minimum ranges in most metrics, timid results yet better than the Buy and Hold follower.

One of the metrics that change the most in between individuals is the number of Stop-loss hits,

ranging from 6 to 58, but there is no direct correlation of this factor alone with returns, as there are

individuals who perform well while getting stopped often (like the best individual of the 3rd run) while

other are able to perform positively as well without triggering the stopping mechanism as much (like the

best individual of the 1st run).

62

Page 81: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Table 4.6: Case I - Out-of-sample performance per simulation

Metric 1 2 3 4 5 B&H Min Max AvgAccuracy (%) NA NA NA NA NA 0Average Profit 2.42 -0.2 3.2 -0.11 0.93 -1600 -0.2 3.2 1.248

# Trades 413 539 529 473 751 1 413 751 541Winning Trade

Rate (%) 64.65 64.75 65.97 65.54 70.31 0 64.65 70.31 66.24

# Stop-loss 6 58 55 24 54 0 6 58 39.4Max Profit 322.2 322.2 322.2 322.2 322.2 0 322.2 322.2 322.2Min Profit -356.7 -207.4 -194.6 -258.6 -220.2 -1600 -356.7 -194.6 -247.5Max WinStreak 10 9 11 11 13 0 9 13 10.8

Max LossStreak 5 6 5 4 4 1 4 6 4.8

MaxDrawdown 2630.8 2817 2506.4 2464.2 2333.2 11790 2333.2 2817 2550.3

AnnualizedSharpe 3.18 0.87 4.68 0.54 2.34 1.75 0.54 4.68 2.32

P&L 1017.8 -73.4 1751.5 -9.1 738.5 -1600 -73.4 1751.5 685Used Capital 10000 10000 10000 10000 10000 10000 10000 10000 10000CumulativeReturns (%) 10.18 -0.73 17.51 -0.09 7.39 -16 -0.73 17.51 6.85

AnnualizedReturns (%) 0.44 -0.03 0.73 0 0.32 -0.78 -0.03 0.73 0.29

Positive Days 68 62 69 67 67 68 62 69 66.6Negative Days 59 65 58 60 60 59 58 65 60.4

P&L / MaxDrawdown 0.39 -0.03 0.7 0 0.32 -0.14 -0.03 0.7 0.28

4.3 Introducing Feature Selection

As explained in chapter 3, a total of 22 features were selected as a starting point for the forecasting

exercise. These features would be filtered and used in the process of training the SVM model and

generate new signals after the model was trained.

Figure 4.3 displays a correlation matrix calculated for all the features, explaining the relationship

between them and how the PCA model could aggregate some of the features to reduce the complexity

of the problem and focus on features with more explanatory power.

63

Page 82: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Figure 4.3: Feature Correlation Matrix.

As the table shows, and as their computations are most of the times based in similar numbers, the

most correlated set of features are the technical indicators, especially among themselves in two split

groups: long term and short term. This is expected, as they are trying to capture the same activity

directly: buy and sell signals, distance from a history based metric to today’s value that tells the trader

that he should take action (or not). Notice that it was decided to use the difference between the price

and the technical indicator valor rather than to transform it into a binary signal to be able to capture

intensity: a signal with a higher absolute value should indicate a stronger motivation to take action than

a lower difference. The logic is similar to the physics associated with a rubber band: the further it is from

its original state (in this case, it is historical data, represented by the technical indicator), the higher the

pressure to return to it, and the more likely it is to happen.

This is the rationale behind multiple short term trading strategies, even though the opposite logic is

also defended by other professionals in the field: if the price of a Financial Instrument is increasing (or

decreasing), it will likely keep increasing (or decreasing).

Another curious fact is the presence of correlation (not very high, but still present) between the fact

64

Page 83: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

that a release was different from the expectation (Release Surprise) and some types of releases (dummy

variables).

4.4 Case Study II - GSVM for economic release trading

This is the main case study of this dissertation: it uses an hybrid model (GSVM, comprised by a combi-

nation of a GA and SVM) to generate forecasting signals and trade a FOREX instrument (in this case,

DX) in a short period after the disclosure of macroeconomic release information. These periods are

known as very active trading-wise (depending on the type and value of the release, and the recent

history of market volatility) as shown in figure 4.4, and our main goal is to use a powerful forecasting

framework to profit from the market movement around them.

Figure 4.4: Economic Release example Chart - DX price before and after the NFP release, 2016-11-04 07:30

There are four separate moments in a day when a relevant macroeconomic indicator is released:

• Before the release. Usually slow periods, with low volume and volatility. Only minor adjustments

to the market agent’s positions. Seldom does a relevant agent take action during this period, as

there is no certainty about what the after-release period will look like, only conjectures based on

guesses.

• During the release. Volume reduces even more than in the previous moment. Most electronic

traders hold off until the market is thinner (meaning, the distance between the best bid and best

ask has reduced), as the algorithms may not be able to keep up with the quick and sudden price

movements inherent to these moments.

• Shortly after the release. Electronic traders return. The market is overflowed with orders, traders

adjusting and acting based on the most up-to-date information about the economic release and

its implications. Wide executing price range and sudden movements, hard to predict, and multiple

inversions while the equilibrium price is being corrected.

65

Page 84: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• Rest of the day. Either slow or active, depending on the the release value and on the overall

economic sentiment. Most of the action has already taken place, but under certain conditions may

keep some of its pace until the market closes.

In this case study, the goal is to capture trading activity in the third moment (Shortly after the release),

knowing that there is a high risk that this type of movement is too random and hard to predict.

An example of the trading activity around one macroeconomic release can be found in figure 4.5:

Figure 4.5: Trading after an Economic Release example Chart - NFP release, 2016-11-04 07:30

The top subplot represents DX price with time (as in figure 4.4). The middle subplot represents the

trader’s open position over time. When openPos is 1, it means that the trader has a long open position

(bought one contract, is waiting for a cover sell signal); when it is -1, the trader has a short position (sold

one contract, is waiting for a cover buy signal); when it is zero, the trader has no open position. As the

trader opens and closes positions, the P&L curve (bottom subplot) is updated and reflects how much

money the trader is making at any given time.

66

Page 85: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

4.4.1 System Parameters

For greater convenience, all the parameters of the implemented system are summarized in table 4.7.

In this case study, we fixed the granularity to 60 seconds (1 minute), so the number of periods in the

technical indicators is expressed in minutes.

Table 4.7: Case Study II Configuration Parameters

Category Parameter ExamplePeriod Start date [2010,10,20]Period End date [2017,10,20]

Instrument Details DX margin 2.5%Instrument Details DX tick value 1000Instrument Details DX transaction cost 1.41Instrument Details ES margin 7%Instrument Details ES tick value 50Instrument Details ES transaction cost 1.41

GA Population size 30GA Rounds timeout 10GA Improvement stop 5GA Best sample 0.1GA Lucky sample 0.15GA Chance of mutation 0.1GA Weight Accuracy 0.4GA Weight P&L 0GA Weight Sharpe 0GA Weight P&L/dd 0.6

MySql Long term days 75MySql Long term periodicity (Seconds) 86400

No adjustments of any kind were made to the system during its evaluation.

4.4.2 Best Individuals

Here, the characteristics of the best performing individuals of five different runs of this case study are

analyzed. Notice that the technical indicator number of periods are minutes (as we used 60 seconds as

the fixed granularity for this case study).

67

Page 86: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Table 4.8: Case II - Best Individual per simulation

Chromosome 1 2 3 4 5 Min Max AvgStop-loss 0.035 0.03 0.04 0.035 0.035 0.03 0.035 0.0325

Loss Close Prevention True True False False FalseTime after Release 120 91 106 106 101 91 120 105.5

Tick Data Re-samplingsize 60 60 60 60 60 60 60 60

PCA Components 15 18 16 16 19 15 18 16.5SVM kernel RBF RBF RBF RBF RBF

SVM C 32 128 512 8 8 32 128 80SVM gamma 8 8 8 8 8 8 8 8

SVM using probability True True False True FalseSVM degree 4 1 2 1 4 1 4 2.5SVM max iter 15000 15000 15000 15000 15000 15000 15000 15000SVM shrinking True False True True True

SVM time ahead 10 25 15 10 10 10 25 17.5SVM min profit 0.011 0.006 0.011 0.006 0.011 0.006 0.011 0.0085

Train Percentage 0.66 0.66 0.66 0.66 0.66 0.66 0.66 0.66EMA LT number of periods 70 50 50 60 70 50 70 60SMA LT number of periods 60 50 70 50 70 50 60 55

MOM LT number ofperiods 50 60 70 60 60 50 60 55

RSI LT number of periods 50 50 60 60 70 50 50 50DX LT number of periods 50 50 70 50 60 50 50 50

EMA ST number ofperiods 6 4 8 6 8 4 6 5

SMA ST number ofperiods 8 8 10 10 10 8 8 8

MOM ST number ofperiods 2 10 6 2 8 2 10 6

RSI ST number of periods 2 10 6 4 8 2 10 6DX ST number of periods 6 10 6 10 8 6 10 8

RSI threshold 46 31 31 21 21 31 46 38.5DX percent rank threshold 0.26 0.11 0.31 0.21 0.21 0.11 0.26 0.185

VX percentile to trade 0.01 0.46 0.16 0.31 0.26 0.01 0.46 0.235ES percentile to trade 0.06 0.16 0.36 0.11 0.06 0.06 0.16 0.11

To simplify the exercise and focus on the most important optimization parameters, three of the chro-

mosomes were fixed in all individuals: Tick Data Re-sampling size (60 seconds), SVM max iterations

(15000, with the sole purpose of speeding-up the routine and prevent non-converging SVM models to

keep the training from proceeding for too long) and Train Percentage (0.66, or 66%, representing the

percentage of the whole data-set to be using for training, while the rest would be the testing period).

Among the best performing individuals of each run, there are points where there is convergence and

divergence. The first thing that should be highlighted is the Kernel used in the SVM model: the optimal

individual always uses the RBF kernel function. This is in line with the literature presented in chapter 2,

68

Page 87: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

where multiple authors stated that this Kernel performs well in financial forecasting problems.

Another curious pattern is the selected SVM time ahead gene given the provided range: it could

take values from 10 (equivalent to 600 seconds) to 30 (1800 seconds), and the majority of the best

performing individuals pick the minimum value that is allowed. This indicates that the best fitness (with

return, risk and predictive power components considered) is achieved when the model is generating

signals to forecast a short period after the signal generation rather than a farthest one.

In most of the long term technical indicators, a tendency to go for a shorter periodicity is present: an

average value of around 55 predominates, closer to the lower boundary of the search space set between

50 and 80. Notice that 55 is the number of bars, so it is equivalent to 55 * 60 = 3300 seconds.

4.4.3 In-Sample

Figure 4.6 shows that the in-sample results were positive. All runs resulted in expressive cumulative

returns of over 600 %, much higher than the 200 % obtained by the Buy and Hold Strategy. The

algorithm found what it was looking for: great performers in-sample, balanced in terms of risk-adjusted

returns and complemented by significant prediction accuracy (as displayed in table 4.9 with more detail).

The cumulative return curve is sustained and keeps the climbing pace with time.

Figure 4.6: Cumulative Return chart for the different in-sample runs of Case Study II.

Confirming figure 4.6 picture, the metrics in table 4.9 point to a successful solution found by the

algorithm. Accuracy-wise, the SVM model successfully predicted over 68 % of the attempts, with a

maximum value of around 80 % in one of the five best individuals of each run. In terms of profit range

and trade frequency, there are individuals who trade more often and close their positions with a lower

profit per trade (like the 4th run’s top performer), while others prefer to wait for the right signals, trade

69

Page 88: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

less frequently, but act upon trades that will yield higher profits (like the 2nd run’s top performer). Another

interesting metric is the relationship between positive P&L days vs the negative ones, reflecting the

consistency mentioned above: over 95 % of the non-null days (where P&L is zero) are days where the

P&L is positive.

Table 4.9: Case II - In-sample performance per simulation

Metric 1 2 3 4 5 B&H Min Max AvgAccuracy (%) 68.13 81.71 76.16 69.85 74.27 0 68.13 81.71 74.024Average Profit 35.24 38.23 34.06 25.84 41.82 19845 25.84 41.82 35.038

# Trades 3081 1868 2808 4037 2588 1 1868 4037 2876.4Winning Trade

Rate (%) 86.11 80.62 70.87 66.41 74.57 100 66.41 86.11 75.7

# Stop-loss 315 321 80 87 84 0 80 321 177.4Max Profit 619.7 634.7 592.2 607.2 632.2 19845 592.2 634.7 617.2Min Profit -89.5 -77.7 -127.8 -142.8 -142.8 0 -142.8 -77.7 -116.1Max WinStreak 60 72 24 27 30 1 24 72 42.6

Max LossStreak 4 4 6 8 9 0 4 9 6.2

MaxDrawdown 526.4 465.7 779 384.7 348.8 8462.5 348.8 779 500.9

AnnualizedSharpe 55.46 57.15 60.24 58.5 57.64 7.36 55.46 60.24 57.8

P&L 108570 70970 95733 104744 108294 19845 70970 108570 97662.4Used Capital 10000 10000 10000 10000 10000 10000 10000 10000 10000CumulativeReturns (%) 1085.7 709.7 957.3 1047.4 1082.9 198.5 709.7 1085.7 976.6

AnnualizedReturns (%) 11.07 9.29 10.53 10.91 11.06 4.75 9.29 11.07 10.572

Positive Days 251 251 255 250 256 136 250 256 252.6Negative Days 9 9 5 10 4 124 4 10 7.4

P&L / MaxDrawdown 206.25 152.39 122.89 272.26 310.48 2.35 122.89 310.48 212.85

4.4.4 Out-of-sample

In the out-of-sample segment, the algorithm was also able to yield positive cumulative returns and to

beat the benchmark in all runs. One of the runs stood out, achieving positive 100% returns (doubling the

initial capital) during a period when the Buy and Hold return was around -20%. Notice that this was also

the best in-sample performer. In fact, the worst in-sample performer is the second best out-of-sample

P&L-wise, showing less signals of overfitness than other individuals. Notice also that all the runs are

much less volatile than the benchmark: the Buy and Hold strategy ranges 120 percentage points from

-40 % to +80 % in terms of cumulative returns, while the algorithmic traders have a maximum range

70

Page 89: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

of 100 percentage points in the best out-of-sample individual and around 45 percentage in the other

individuals.

Figure 4.7: Cumulative Return chart for the different out-of-sample runs of Case Study II.

Looking at all the simulations in table 4.10, there is a clear distinction between two groups: a top per-

former that largely surpassed the benchmark and yielded positive results; and four average performers,

with more modest positive returns and that also outperformed the Buy and Hold strategy.

The 1st Run’s best individual (top performer) is significantly different from the others, not only in the

results but also in its genetic structure. In the hyper parameter set, there is a small prediction time

ahead value compared with other runs (10, when the maximum is 25) and the lowest number of PCA

components (15), resulting in the best out-of-sample accuracy. Surprisingly, this run was the worst

in-sample performer in terms of accuracy.

Another aspect of this gene set is the sensitive stop-loss trigger (0.035, second lowest of the five sim-

ulations), that allowed this trader to cut the losses on poor performing trades, and achieve a respectable

winning trade rate of 72 % . It is the the second least active trader (943 trades, versus a maximum of

1876 and average 1140.4), and presents the lowest drawdown value.

In terms of winning trade rate, there is an interesting tendency: although the top individuals from the

3rd, 4th and 5th runs had a low rate (below 50%, indicating that money was lost more often than won),

they still had a positive overall result in terms of cumulative returns, stressing the previously mentioned

idea that a trader may be profitable with few right predictions in the right moments. This is also reflected

in the Max Profit and Min Profit fields of table 4.10, as these individuals were the ones with higher Max

profit in a single trade.

Overall, accuracy dropped significantly compared to the in-sample period, but all scenarios are still

better than a randomized scenario (given that there are three possible classes, 33.3 % is the probability

71

Page 90: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

of selecting one randomly).

Table 4.10: Case II - Out-of-sample performance per simulation

Metric 1 2 3 4 5 B&H Min Max AvgAccuracy (%) 37.03 37.19 34.54 37.38 36.61 0 34.54 37.38 36.55Average Profit 10.76 5.68 1.54 1.31 1.83 -1585 1.31 10.76 4.224

# Trades 943 740 1114 1876 1029 1 740 1876 1140.4Winning Trade

Rate (%) 72 58.24 48.03 48.61 48.2 0 48.03 72 55.016

# Stop-loss 209 275 169 199 218 0 169 275 214Max Profit 427.2 557.2 694.7 629.7 609.7 0 427.2 694.7 583.7Min Profit -93.2 -80.1 -147.8 -202.8 -150.3 -1585 -202.8 -80.1 -134.8Max WinStreak 17 12 14 8 7 0 7 17 11.6

Max LossStreak 6 14 11 11 10 1 6 14 10.4

MaxDrawdown 1288.8 2126.5 2538.8 2723.7 2541.7 11790 1288.8 2723.7 2243.9

AnnualizedSharpe 27.67 9.21 3.95 6.25 4.67 1.97 3.95 27.67 10.35

P&L 10042.8 4134.9 1559.5 2470.8 1829.9 -1585 1559.5 10042.8 4007.6Used Capital 10000 10000 10000 10000 10000 10000 10000 10000 10000CumulativeReturns (%) 100.4 41.4 15.6 24.7 18.3 -15.9 15.6 100.4 40.1

AnnualizedReturns (%) 3.18 1.57 0.65 1 0.76 -0.77 0.65 3.18 1.43

Positive Days 64 71 62 64 62 62 62 71 64.6Negative Days 48 56 65 63 65 64 48 65 59.4

P&L / MaxDrawdown 7.79 1.94 0.61 0.91 0.72 -0.13 0.61 7.79 2.39

4.5 Case Study III - GSVM for continuous ES trading

The third selected case study was a test to the algorithm under different conditions. Comparing to the

main focus of this thesis, the following environment conditions changed:

• Traded Instrument. Instead of using the DX future, in this scenario, the ES future is traded. Tick

size and margin for metric calculation were adjusted accordingly. Notice that the ES is a directional

product, with tendency to increase its value.

• Trading Periods. In the main scenario, the trading activity is focused around macroeconomic

releases. In this case study, trading activity is continuous, with no distinction between periods.

To adjust to the much greater data-set size, the granularity was adjusted from 60 second bars (1

minute, as in the previous runs) to 1800 second bars (30 minutes per bar).

72

Page 91: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

• Features. In this case study, the macroeconomic (like the distance to VX and ES long term

percentile) and release specific features (like the type of release and if it was a surprise or not)

were removed, either to simplify the calculations or because they no longer applied. It uses a total

of 12 features, around half of the 22 features used in the previous case study.

The predictive model remained the same: the GSVM, hybrid GA with SVM in its fitness function.

4.5.1 System Parameters

For greater convenience, all the parameters of the implemented system are summarized in table 4.11.

In this case study, we fixed the granularity to 1800 seconds (30 minutes), so the number of periods in

the technical indicators is expressed in 30 minute periods hours.

Table 4.11: Case Study III Configuration Parameters

Category Parameter ExamplePeriod Start date [2011,10,20]Period End date [2018,10,20]

Instrument Details DX margin 2.5%Instrument Details DX tick value 1000Instrument Details DX transaction cost 1.41Instrument Details ES margin 7%Instrument Details ES tick value 50Instrument Details ES transaction cost 1.41

GA Population size 30GA Rounds timeout 10GA Improvement stop 5GA Best sample 0.1GA Lucky sample 0.15GA Chance of mutation 0.1GA Weight Accuracy 0.4GA Weight P&L 0GA Weight Sharpe 0GA Weight P&L/dd 0.6

MySql Long term days 75MySql Long term periodicity (Seconds) 86400

No adjustments of any kind were made to the system during its evaluation.

73

Page 92: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

4.5.2 Best Individuals

Here, the characteristics of the best performing individuals of five different runs of this case study are

analyzed. Notice that the technical indicator number of periods are 30 minute bars (as we used 1800

seconds as the fixed granularity for this case study).

Table 4.12: Case III - Best Individual per simulation

Chromosome 1 2 3 4 5 Min Max AvgStop-loss 0.03 0.045 0.035 0.035 0.055 0.03 0.045 0.0375

Loss Close Prevention False True False True FalseTime after Release 49 92 72 57 65 49 92 70.5

Tick Data Re-samplingsize 1800 1800 1800 1800 1800 1800 1800 1800

PCA Components 18 13 19 8 8 13 18 15.5SVM kernel RBF RBF RBF RBF RBF

SVM C 8 32 2 8 2 8 32 20SVM gamma 0.5 2 8 8 8 0.5 2 1.25

SVM using probability False True True False FalseSVM degree 4 4 3 4 4 4 4 4SVM max iter 15000 15000 15000 15000 15000 15000 15000 15000SVM shrinking True True False False False

SVM time ahead 10 15 10 15 10 10 15 12.5SVM min profit 0.011 0.011 0.011 0.001 0.006 0.011 0.011 0.011

Train Percentage 0.66 0.66 0.66 0.66 0.66 0.66 0.66 0.66EMA LT number of periods 70 50 70 50 50 50 70 60SMA LT number of periods 60 60 60 50 50 60 60 60

MOM LT number ofperiods 60 60 70 70 60 60 60 60

RSI LT number of periods 60 50 50 60 50 50 60 55DX LT number of periods 70 60 60 70 50 60 70 65

EMA ST number ofperiods 4 6 4 10 4 4 6 5

SMA ST number ofperiods 8 4 2 10 6 4 8 6

MOM ST number ofperiods 10 2 2 4 8 2 10 6

RSI ST number of periods 4 2 2 6 4 2 4 3DX ST number of periods 10 2 6 10 2 2 10 6

RSI threshold 31 31 16 36 21 31 31 31DX percent rank threshold 0.06 0.41 0.21 0.21 0.11 0.06 0.41 0.235

As in the previous case study, the Kernel selected by all the five top individuals is the same, the RBF

kernel. The penalty to misclassification (SVM C parameter) is lower overall compared to the previous

case study. These are curious changes in the structure of the converging chromosomes affecting the

SVM model directly.

Another interesting point is that only two of the five best individuals are not closing positions until

74

Page 93: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

profit is achieved on each trade, the remaining three individuals let the SVM generated signals fully

control its trading activity. To be noted that, by observing table 4.13, the best in-sample performer (best

individual of the 4th run) is the one with higher accuracy, hence its ability to rely on the signals without

support rules.

The SVM time ahead parameter also shows a pattern: the two individuals with higher values in this

parameter (15 on both the 2nd and the 4th, versus 10 in all the other runs) displayed the worst accuracy

(in and out-of-sample) but the best out-of-sample cumulative returns.

4.5.3 In-Sample

Similarly with what happened in the previous Case Study, in-sample results are very expressive. All the

best individuals of each run beat the Buy and Hold with a good margin and they all have positive returns,

between 1500 % and 4000 %. Notice that around September 2015, there is an opposite move in the

returns of the GSVM traders and the Buy and Hold follower: the slope of the movement steepens in all

traders, but while the Buy and Hold trader is losing capital, the GSVM individuals are able to capture the

short selling opportunity and profit from the drop in price.

Figure 4.8: Cumulative Return chart for the different in-sample runs of Case Study III.

When looking at the in-sample metrics, the results are positive, even more than the previous case

study in terms of return. Accuracy values are of over 65 %, and a maximum achieved profit of 5245.7 in

a single trade. The best in-sample performer (best individual of the 4th simulation) of this case study is

the one with the best Winning Trade Rate. This individual is not most active trader (highest number of

trades), but prefers to be involved in the market when it has strong evidence that it will profit. It also has

the highest number of consecutive profitable trades and the lowest Max Drawdown, another signal of its

caution when opening positions.

75

Page 94: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

There is a pattern in the Loss Close prevention chromosome when looking at the results: the lower

the accuracy, the more likely it is that the individual has the Loss Close prevention set to TRUE. The

intuition behind this relationship is the fact that if the generated signals are not as accurate, this additional

rule will help the algorithm to avoid closing positions too soon.

Table 4.13: Case III - In-sample performance per simulation

Metric 1 2 3 4 5 B&H Min Max AvgAccuracy (%) 67.14 65.85 71.96 66.01 70.63 0 65.85 71.96 68.32Average Profit 113.47 90.1 69.34 100.19 59.52 36223.75 59.52 113.47 86.52

# Trades 1408 3278 4405 3937 4976 1 1408 4976 3600.8Winning Trade

Rate (%) 37.93 73.03 53.19 73.08 55.2 100 37.93 73.08 58.49

# Stop-loss 576 865 475 1031 189 0 189 1031 627.2Max Profit 4602.9 3156.7 5152.4 5245.7 5152.4 36223.8 3156.7 5245.7 4662Min Profit -689.8 -347.8 -1565 -271.4 -828.6 0 -1565 -271.4 -740.6Max WinStreak 7 22 14 30 13 1 7 30 17.2

Max LossStreak 14 5 11 5 12 0 5 14 9.4

MaxDrawdown 4154.3 3636.4 3478.1 2792.3 3362.6 16170 2792.3 4154.3 3484.8

AnnualizedSharpe 14.01 21.23 23.72 23.68 21.86 4.76 14.01 23.72 20.9

P&L 159771 295333 305432 394456 296182 36223 159771 394456 290235Used Capital 10000 10000 10000 10000 10000 10000 10000 10000 10000CumulativeReturns (%) 1597.7 2953.3 3054.3 3944.6 2961.8 362.2 1597.7 3944.6 2902.4

AnnualizedReturns (%) 12.86 15.73 15.89 17.13 15.74 6.76 12.86 17.13 15.47

Positive Days 560 657 683 745 673 530 560 745 663.6Negative Days 414 332 297 260 304 446 260 414 321.4

P&L / MaxDrawdown 38.46 81.22 87.82 141.26 88.08 2.24 38.46 141.26 87.37

4.5.4 Out-of-sample

In this scenario, the end goal is achieved: cumulative returns are above the Buy and Hold strategy in

all runs. One of the most interesting facts of these results other than the returns is the accuracy: all

the runs have predictive power close to their in-sample runs, proving the learning ability of the model

and the presence of patterns helpful in the decision making process. The average accuracy of all the

out-of-sample runs is only 7 percentage points lower than in-sample.

76

Page 95: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Figure 4.9: Cumulative Return chart for the different out-of-sample runs of Case Study III.

As shown in figure 4.9, out-of-sample performance was also favorable. All the individuals surpassed

the Buy and Hold strategy, showing positive returns in all cases.

Curiously, the best performer (2nd simulation’s best individual, as displayed in table 4.14) is the

second least accurate individual, and one of the individuals with the highest stop-loss trigger percentage.

On the other hand, this individual is the one with the highest winning trade rate (metric at which this

individual also performed very well in-sample).

On the other end, the worst performer (best individual of the 5th run) is the most active trader and

one of the individuals with the best out-of-sample accuracy. It has the best single trade in terms of profit,

but also the worst in terms of loss, and the worst risk adjusted returns in terms of P&L / Max Drawdown

ratio.

77

Page 96: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Table 4.14: Case III - Out-of-sample performance per simulation

Metric 1 2 3 4 5 B&H Min Max AvgAccuracy (%) 64.97 59.39 64.5 54.56 64.23 0 54.56 64.97 61.53Average Profit 92.29 59.47 19.47 45.17 13.92 32958 13.92 92.29 46.06

# Trades 730 1597 2456 1983 2793 1 730 2793 1911.8Winning Trade

Rate (%) 40.55 73.51 47.8 71.91 49.19 100 40.55 73.51 56.59

# Stop-loss 281 412 241 540 84 0 84 540 311.6Max Profit 4018.9 2993.2 3333.4 4687.9 4813.7 32958 2993.2 4813.7 3969.4Min Profit -1107 -465.5 -1611 -361.5 -1702 0 -1702 -361.5 -1049Max WinStreak 9 17 8 31 10 1 8 31 15

Max LossStreak 11 6 9 7 10 0 6 11 8.6

MaxDrawdown 8561.4 3822.3 6853.2 8172.6 7103 16488 3822.3 8561.4 6902.5

AnnualizedSharpe 13.08 11.18 7.12 13.21 7.43 6.82 7.12 13.21 10.4

P&L 67370 94975 47824 89569 38865 32958 38865 94975 67721Used Capital 10000 10000 10000 10000 10000 10000 10000 10000 10000CumulativeReturns (%) 673.7 949.8 478.3 895.7 388.7 329.6 388.7 949.8 677.2

AnnualizedReturns (%) 9.62 11.13 8.19 10.87 7.38 6.76 7.38 11.13 9.44

Positive Days 284 293 274 313 274 278 274 313 287.6Negative Days 218 218 237 200 237 226 200 237 222

P&L / MaxDrawdown 7.87 24.85 6.98 10.96 5.47 2 5.47 24.85 11.23

4.6 Summary Conclusions

When looking at the three scenarios in parallel, their performances differ, but overall the algorithm suc-

cessfully accomplishes what it was aiming at.

The first scenario is just a benchmark scenario, simplified, shown to compare with the proposed

model in this dissertation. As expected, the GA alone, with the same input parameters, performs worse

than the hybrid GSVM approach when trading in the aftermath of economic releases only.

The third scenario tests the power of the algorithm in a different environment: continuous trading,

different financial instrument and different granularity. As there is less isolation in intrinsically noisy

periods such as economic releases, this last scenario is where the model shines the most in terms of

accuracy and predictive power as whole, leading to better metric values across the board.

78

Page 97: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Figure 4.10: In-sample Accuracy and Return. Figure 4.11: Out-of-sample Accuracy and Return.

Figures 4.10 and 4.11 show the results by zone, considering accuracy and annualized return as the

axis. The idea is to clearly see and compare each run of each case study. As in these figures accuracy

is one of the axis, the GA case study was not included. The points with colored fill and situated on the 0

% accuracy axis are the Buy and Hold runs of each scenario.

The figures highlight the good results of both case studies: all runs with positive, above Buy and

Hold returns. The GSVM ESLT All (Case Study III) scenario displays more consistency in terms of both

accuracy and return, as the difference between in and out-of-sample is modest, unlike what happens in

the GSVM LT Releases (Case Study II) scenario, where accuracy drops from an average of around 72

percent to values between 34 and 40 percent.

Figure 4.12: In-sample Hit Ratio and Return. Figure 4.13: Out-of-sample Hit Ratio and Return.

In figures 4.12 and 4.13, the relationship between annualized return and Trade hit ratio is analyzed

for every run of the three different case studies.

Three groups are present:

• The GA Releases group (orange, Case Study I), with the worst annualized return (in and out-of-

79

Page 98: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

sample) and average Trade Hit ratio (all the points of this group are close overall, not being the

best or worst when looking at Hit Ratio).

• The GSVM LT Releases (yellow, Case Study II, and the main focus of this dissertation), with the

second best performance in terms of Annualized Return (in and out-of-sample), the best in-sample

group in terms of Trade Hit Ratio. The Annualized returns of this group are the ones that drop the

most between the in and out-of-sample scenarios.

• The GSVM ESLT All group (grey, Case Study III), where the best in and out-of-sample annualized

return performance lies even though they do not perform as well as individuals of other groups in

terms of Trade Hit ratio. Notice that this group’s individuals have more opportunity to make money

(has they are trading continuously).

These figures let us understand the distribution of runs in terms of how well the individuals performed

overall and the number of times they traded profitably. Hit frequency (represented by the hit ratio) is

compared with hit quality (represented by the annualized returns).

80

Page 99: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

5Discussion

Contents

5.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.2 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

81

Page 100: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

82

Page 101: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

The main purpose of this chapter is to present the final conclusions and key findings, together with a

set of suggestions to continue this work.

5.1 Conclusions

This work presents three case studies on financial market trading optimization:

• Case Study I: Genetic Algorithm to trade the US Dollar Index instrument in a short period after

economic releases.

• Case Study II: Hybrid model using Genetic Algorithm with Support Vector Machines to trade the

US Dollar Index instrument in a short period after economic releases.

• Case Study II: Hybrid model using Genetic Algorithm with Support Vector Machines to trade the

ES (SP500 future contract) instrument continuously.

The first approach yielded the worst results, in and out-of-sample. The significant distance between

in and out-of-sample results suggested that predicting under the proposed conditions using a simple

Genetic Algorithm is not achievable consistently, given that the pace with which markets change their

behaviour in periods of high volatility results in a solution that performs poorly when used in prediction.

In order to try to improve the quality of the predictive solution, a SVM model was included in the

fitness function to generate the trading signals based in which the algorithm would trade, included in a

hybrid framework (named Genetic Support Vector Machines). The GA influences not only the hyper-

parameters of the SVM (like which kernel, C parameter and Gamma to use, see chapter 2 for more

information) but also the calculations of the Technical Indicators to be used by the SVM as classifiers in

the signal-generating process.

In this second case study that was addressed, the GSVM algorithm successfully obtained positive

results in and out-of-sample. It outperformed the pure GA approach, confirming the value added in

the inclusion of the SVM model within the fitness calculation of individuals. The pinpointed solutions

performed very well in-sample, and always above the Buy and Hold strategy in train and test periods.

The third case study was raised by the need to understand how the algorithm would perform under

different conditions, changing the problem statement but keeping the used solution as close as possible

to the release prediction model used in the previous case study. It was accomplished by maintaining the

algorithm structure while changing from economic release prediction to continuous trading, by changing

from DX to ES as the traded instrument, and time-series granularity from 60 seconds to 1800 seconds.

In this case study, the results were even more favorable than the previous two scenarios: the algorithm

obtained monetary gains both in and out-of-sample, always better than the Buy and Hold strategy. The

accuracy was also higher in this last case study than in the previous two, especially out-of-sample.

83

Page 102: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

The algorithm was not only learning better in terms of right forecast, but it also increased the financial

performance of the trading agent. The explanation of the results lies on the fact that the weight of longer

term settings is greater than the noise associated with short term events such as economic releases,

making it more suited to fit prediction frameworks.

5.2 Future Work

In this section, possibilities for continuing the work presented in this dissertation are suggested. This

represents both what would have been done by the author to increase the depth of this work if it was to

be continued, and the next steps to be done by third parties desiring to test the framework further.

One of the biggest challenges throughout the development process was the complexity of the prob-

lem. The inclusion of the SVM training inside the fitness function of a GA is rather intense in terms of

computing power usage, and the considerable run time of the routine made it harder to tweak and test,

as each modification would lead to running the routine again, which would take a long time.

The inclusion of parallel programming within Python greatly increased the performance (the popula-

tion fitness calculation was split into processes, one process per individual, and all the used cores of the

processor would share the load, resulting in a close to linear speed up). What would be considered to

tackle this problem would be to test alternative programming languages and/or include more computing

power to increase size and performance of the algorithm. Modifications such as an increase in popula-

tion size and number of generations, in the GA fraction of the algorithm or the removal of the limiter of

the number of iterations in the SVM fraction of the algorithm would improve the quality of the solution.

Another possible tweak to the model would be to revisit and/or find different ways to classify each

data point to generate signals. A significant scope of variable types and information was included, but

additional information may always add relevant predictive capabilities to the model. Together with this,

the inclusion of additional economic releases would also be relevant, as there are still important releases

that were left out for simplicity.

Finally, even though the objective of this thesis was specifically to test the proposed model, a different

combination of optimization and learning algorithms could be used. This work proves the power of

combining frameworks, but there could be different results if the structure is maintained while the moving

parts are changed.

84

Page 103: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Bibliography

[1] A. Hirabayashi, C. Aranha, and H. Iba, “Optimization of the trading rule in foreign exchange us-

ing genetic algorithm,” in Proceedings of the 11th Annual conference on Genetic and evolutionary

computation. ACM, 2009, pp. 1529–1536.

[2] M. Grinblatt and S. Titman, Financial markets & corporate strategy. McGraw-Hill Higher Education,

2011.

[3] S. Harnad, “The annotation game: On turing (1950) on computing, machinery, and intelligence,” in

The Turing test sourcebook: philosophical and methodological issues in the quest for the thinking

computer. Kluwer, 2006.

[4] W. Feather, 2000, [Online; accessed 20-November-2018]. [Online]. Available: https:

//www.brainyquote.com/quotes/william feather 391335

[5] P. Souto, “Marketopolis: A market simulation based on investors decisions,” Master’s thesis, Nova

School of Business and Economics, Universidade Nova de Lisboa, Portugal, 2016.

[6] B. G. Malkiel, “Efficient market hypothesis,” The New Palgrave: Finance. Norton, New York, pp.

127–134, 1989.

[7] T. N. Bulkowski, Trading classic chart patterns. John Wiley & Sons, 2003, vol. 176.

[8] R. A. Levy, “Relative strength as a criterion for investment selection,” The Journal of Finance,

vol. 22, no. 4, pp. 595–610, 1967.

[9] Investopedia, “What does margin mean in investing?” 2017, [Online; accessed 20-November-

2017]. [Online]. Available: https://www.investopedia.com/terms/m/margin.asp

[10] B. F. I. Settlements, “Bis papers no 90 - foreign exchange liquidity in the americas,” 2017.

[11] B. Dolan, Currency trading for dummies. John Wiley & Sons, 2011.

[12] W. I. D. Mining, “Data mining: Concepts and techniques,” Morgan Kaufinann, 2006.

85

Page 104: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

[13] E. S. Textbook, “Statsoft,” Inc., Tulsa, OK, USA, 2011.

[14] Wikipedia, “Autoregressive integrated moving average — Wikipedia, the free encyclopedia,”

2017, [Online; accessed 15-November-2017]. [Online]. Available: https://en.wikipedia.org/wiki/

Autoregressive integrated moving average#Definition

[15] C. C. Aggarwal, Data classification: algorithms and applications. CRC Press, 2014.

[16] C. A. Ralanamahatana, J. Lin, D. Gunopulos, E. Keogh, M. Vlachos, and G. Das, “Mining time

series data,” in Data mining and knowledge discovery handbook. Springer, 2005, pp. 1069–1103.

[17] L. A. Zadeh, “Soft computing and fuzzy logic,” IEEE software, vol. 11, no. 6, pp. 48–56, 1994.

[18] D. E. Goldberg et al., “Genetic algorithms in search optimization and machine learning,” 1989.

[19] S. B. Kotsiantis, I. Zaharakis, and P. Pintelas, “Supervised machine learning: A review of classifica-

tion techniques,” 2007.

[20] S. Madge and S. Bhatt, “Predicting stock price direction using support vector machines,” Indepen-

dent Work Report Spring, 2015.

[21] M. Hazewinkel, “Encyclopedia of mathematics,” 1997.

[22] K.-j. Kim and I. Han, “Genetic algorithms approach to feature discretization in artificial neural net-

works for the prediction of stock price index,” Expert systems with Applications, vol. 19, no. 2, pp.

125–132, 2000.

[23] L. Mendes, P. Godinho, and J. Dias, “A forex trading system based on a genetic algorithm,” Journal

of Heuristics, vol. 18, no. 4, pp. 627–656, 2012.

[24] W. Huang, Y. Nakamori, and S.-Y. Wang, “Forecasting stock market movement direction with sup-

port vector machine,” Computers & Operations Research, vol. 32, no. 10, pp. 2513–2522, 2005.

[25] F. Allen and R. Karjalainen, “Using genetic algorithms to find technical trading rules,” Journal of

financial Economics, vol. 51, no. 2, pp. 245–271, 1999.

[26] J.-Y. Potvin, P. Soriano, and M. Vallee, “Generating trading rules on the stock markets with genetic

programming,” Computers & Operations Research, vol. 31, no. 7, pp. 1033–1047, 2004.

[27] K.-j. Kim, “Financial time series forecasting using support vector machines,” Neurocomputing,

vol. 55, no. 1, pp. 307–319, 2003.

[28] F. E. Tay and L. Cao, “Application of support vector machines in financial time series forecasting,”

omega, vol. 29, no. 4, pp. 309–317, 2001.

86

Page 105: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

[29] M. H. Eng, Y. Li, Q.-G. Wang, and T. H. Lee, “Forecast forex with ann using fundamental data,”

in Information Management, Innovation Management and Industrial Engineering, 2008. ICIII’08.

International Conference on, vol. 1. IEEE, 2008, pp. 279–282.

[30] W.-S. Gan and K.-H. Ng, “Multivariate forex forecasting using artificial neural networks,” in Neural

Networks, 1995. Proceedings., IEEE International Conference on, vol. 2. IEEE, 1995, pp. 1018–

1022.

[31] J. Kamruzzaman, R. A. Sarker, and I. Ahmad, “Svm based models for predicting foreign currency

exchange rates,” in Data Mining, 2003. ICDM 2003. Third IEEE International Conference on. IEEE,

2003, pp. 557–560.

[32] R. Yamarone, “The economic indicator handbook: How to evaluate economic trends to maximize

profits and minimize losses,” 2016.

[33] B. L.P., “Bloomberg website,” [Online; accessed 21-March-2018]. [Online]. Available: https:

//www.bloomberg.com/

[34] A. Hackman, “Adp national employment report,” ADP National Employment Report, p. 4, 2018.

[35] I. Exchange, “Us dollar index® futures,” 2017, [Online; accessed 21-November-2017]. [Online].

Available: https://www.theice.com/products/194/US-Dollar-Index-Futures

[36] M. Fortier, “TA-Lib: Open source financial tools for Python,” 1999–, [Online; accessed

15-July-2018]. [Online]. Available: http://ta-lib.org/

[37] F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Pretten-

hofer, R. Weiss, V. Dubourg et al., “Scikit-learn: Machine learning in python,” Journal of machine

learning research, vol. 12, no. Oct, pp. 2825–2830, 2011.

[38] G. H. Golub and C. Reinsch, “Singular value decomposition and least squares solutions,” Nu-

merische mathematik, vol. 14, no. 5, pp. 403–420, 1970.

[39] L. Bottou and C.-J. Lin, “Support vector machine solvers,” Large scale kernel machines, vol. 3,

no. 1, pp. 301–320, 2007.

[40] I. Exchange, “Us dollar index® futures margin rates,” 2018, [Online; accessed 15-August-2018].

[Online]. Available: https://www.theice.com/clear-us/risk-management#margin-rates

87

Page 106: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

88

Page 107: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

AAppendix: Figures

89

Page 108: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Table A.1: Initial Configuration Parameters

Category Parameter Description Example

Period Start date Start date of the analyzed period, before splitbetween train and test. [2014,10,20]

Period End date End date of the analyzed period, before splitbetween train and test. [2017,10,20]

InstrumentDetails DX margin

DX Margin Rate (percentage of the contractvalue) required to trade the instrument.

Information was found in the products’ brokerwebsite [40].

2.5%

InstrumentDetails DX tick value

DX Tick Value (in USD). This is used to convertbetween the instrument’s price and its notional

value in USD. Information was found in theproducts’ broker website [35].

1000

InstrumentDetails

DX transactioncost

DX transaction cost (in USD) per contracttraded. 1.41

InstrumentDetails ES margin ES Margin Rate (percentage of the contract

value) required to trade the instrument. 7%

InstrumentDetails ES tick value

ES Tick Value (in USD). This is used to convertbetween the instrument’s price and its notional

value in USD.50

InstrumentDetails

ES transactioncost

ES transaction cost (in USD) per contracttraded. 1.41

GA Population size Size of each generation of the GA. 80GA Rounds timeout Number of iterations of the GA. 30

GA Improvement stop Consecutive iterations with the same solution toforce the GA to finish. 10

GA Best samplePercentage of the top of the individuals with thehighest fitness to be selected to breed and to

move on to the next generation.0.1

GA Lucky samplePercentage of the random, non-elite individualsto be selected to breed and to move on to the

next generation.0.15

GA Chance ofmutation

Probability of mutation of a gene of eachoffspring child. 0.1

GA Weight Accuracy Weight of the accuracy metric in the fitnessfunction. 0.1

GA Weight P&L Weight of the normalized P&L metric in thefitness function. 0.1

GA Weight Sharpe Weight of the normalized Sharpe Ratio metric inthe fitness function. 0.1

GA Weight P&L/dd Weight of the normalized P&L / Max Drawdownratio metric in the fitness function. 0.1

MySql Long term daysWindow size, in days, of the long term variables

(ES and VX) whose percentile is used as afeature in the SVM model.

75

MySqlLong termperiodicity(Seconds)

Granularity of the long term variables (ES andVX) whose percentile is used as a feature in the

SVM model.86400

90

Page 109: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

Tabl

eA

.2:

DX

Dat

aS

etE

xam

ple

Tim

eM

idV

XE

S LE

S HA

DP

NFP

US

UR

TOT

RS

TAM

OM

NH

SP

STO

TC

PI

SM

AS

TR

SI

ST

EM

AS

TM

OM

ST

PC

TH ST

PC

TL ST

SM

ALT

RS

ILT

EM

ALT

MO

MLT

PC

TH LT

PC

TL LT

Sur

pris

eS

ig

07:1

680

.25

1.4

3815

10

00

00

0.02

710.

010.

030

0.04

0.02

550.

020

00.

040.

1-1

07:1

780

.28

1.4

3815

10

00

00

0.04

810.

020.

060

0.07

0.05

630.

040.

030.

010.

070.

10

07:1

880

.28

1.4

3815

10

00

00

0.03

810.

010.

060

0.07

0.05

630.

040.

030

0.07

0.1

-1

07:1

980

.26

1.4

3815

10

00

00

062

00.

04- 0.02

0.05

0.02

560.

020.

01- 0.02

0.05

0.1

0

07:2

080

.27

1.4

3815

10

00

00

0.01

680.

010.

070

0.06

0.04

590.

040.

030

0.07

0.1

-107

:21

80.2

71.

438

151

00

00

00

680

0.06

00.

050.

0459

0.04

0.03

00.

070.

1-1

07:2

280

.26

1.4

3815

10

00

00

- 0.01

600

0.04

- 0.02

0.04

0.03

570.

020.

01- 0.02

0.06

0.1

0

07:2

380

.27

1.4

3815

10

00

00

061

00.

04- 0.01

0.04

0.03

570.

030.

01- 0.01

0.06

0.1

0

07:2

480

.26

1.4

3815

10

00

00

- 0.01

540

0.04

- 0.02

0.01

0.02

550.

020.

01- 0.02

0.05

0.1

0

07:2

980

.23

1.4

3815

10

00

00

- 0.02

38-

0.01

-0.

02- 0.04

00

49-

0.01

-0.

02- 0.05

0.03

0.1

0

07:3

080

.23

1.4

3815

10

00

00

- 0.02

35-

0.01

-0.

05- 0.04

0- 0.01

48-

0.01

-0.

02- 0.05

0.02

0.1

1

07:3

180

.23

1.4

3815

10

00

00

- 0.01

400

-0.

04- 0.03

00

49-

0.01

-0.

01- 0.05

0.03

0.1

1

91

Page 110: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

92

Page 111: Predicting Economic Releases using Genetic Support Vector ... · hybrid model) are used to predict Foreign Exchange (FOREX) market returns. The innovation lies not only in the used

93