0% found this document useful (0 votes)
2K views34 pages

Artificial Intelligence in Finance

Artificial Intelligence in Finance

Uploaded by

fahd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views34 pages

Artificial Intelligence in Finance

Artificial Intelligence in Finance

Uploaded by

fahd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Artificial

For finance professionals and academics Key features of the AI in Finance Framework

By Miquel Noguer i Alonso, Daniel Bloch and David Pacheco Aznar


Artificial Intelligence in Finance | Volume 1: Fundamentals and Applications
keen to understand the impact of are explored, including data modelling,
artificial intelligence (AI) in their field, handling of datasets, and the intricacies of
Artificial Intelligence in Finance,Volume 1: feature engineering. Topics such as model
Fundamentals and Applications serves as a performance metrics and the explainability

Intelligence
practical and extensive guide. This book, of AI models are also addressed, providing
the first in a two-volume series, aims to a rounded perspective of AI’s current and
demystify the role of AI in finance, offering potential role in finance.
a clear and comprehensive overview that
bridges the gap between complex AI concepts Serving as a lead-up to the second volume,

in Finance
and their real-world financial applications. which will focus on reinforcement learning
in finance and applications of AI in Finance,
The content is structured to build a strong this book is an ideal resource for finance
foundation, starting with the basics of AI professionals looking to enhance their AI
and financial engineering. It delves into key knowledge and academics aiming to enter this
areas such as supervised and unsupervised evolving field. Artificial Intelligence in Finance,
learning, artificial neural networks, and Volume 1: Fundamentals and Applications offers a
natural language processing, presented in a comprehensive read for anyone interested in
manner that is accessible to both experienced
finance professionals and newcomers.
the intersection of AI and finance.
Volume1: Fundamentals and Applications
The book also covers essential aspects of
financial engineering, offering insights into
its history, theory, and practical applications.
BY MIQUEL NOGUER I ALONSO, DANIEL BLOCH
This balanced approach ensures that readers AND DAVID PACHECO AZNAR
not only gain theoretical knowledge but also
understand how these concepts are applied in
the finance industry.

RB24-AI in Finance-VOL1-FINAL V2.indd 1 25/09/2024 14:16


Artificial Intelligence in Finance
Artificial Intelligence in Finance
Volume 1: Fundamentals and Applications

by Miquel Noguer i Alonso, Daniel Bloch and


David Pacheco Aznar
Published by Risk Books

Infopro Digital
133 Houndsditch
London EC3A 7BX
Tel: + 44 (0)20 7484 9700
E-mail: [email protected]
Sites: www.riskbooks.com
www.infopro-digital.com

Risk Books is a trading name of Infopro Digital Risk Limited


©2024 Infopro Digital Risk (IP) Limited
ISBN 978-1-78272-435-3 (Vol I)
ISBN 978-1-78272-454-4 (Vol II)
ISBN 978-1-78272-455-1 (Box Set)
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library

Commissioning Editors: Sarah Hastings, Victoria Nightingale


Managing Editor: Lewis O’Sullivan
Designer: Lisa Ling
Copy-edited and typeset by T&T Productions Ltd, London
Printed and bound in the UK by PrintonDemand-Worldwide

Conditions of sale
All rights reserved. No part of this publication may be reproduced in any material form whether by photo-
copying or storing in any medium by electronic means whether or not transiently or incidentally to some
other use for this publication without the prior written consent of the copyright owner except in accordance
with the provisions of the Copyright, Designs and Patents Act 1988 or under the terms of a licence issued
by the Copyright Licensing Agency Limited of 1 St. Katharine’s Way, London E1W 1UN, UK.

Warning: the doing of any unauthorised act in relation to this work may result in both civil and criminal
liability.
Every effort has been made to ensure the accuracy of the text at the time of publication, this includes
efforts to contact each author to ensure the accuracy of their details at publication is correct. However, no
responsibility for loss occasioned to any person acting or refraining from acting as a result of the material
contained in this publication will be accepted by the copyright owner, the editor(s), the authors or Infopro
Digital Risk.
Many of the product names contained in this publication are registered trade marks, and Risk Books has
made every effort to print them with the capitalisation and punctuation used by the trademark owner. For
reasons of textual clarity, it is not our house style to use symbols such as TM, ®, etc. However, the absence
of such symbols should not be taken to indicate absence of trademark protection; anyone wishing to use
product names in the public domain should first clear such use with the product owner.
While best efforts have been intended for the preparation of this book, neither the publisher, the editor nor
any of the potentially implicitly affiliated organisations accept responsibility for any errors, mistakes and
or omissions it may provide or for any losses howsoever arising from or in reliance upon its information,
meanings and interpretations by any parties.
To all scientists and financial practitioners who have
inspired me. To my sons Jordi and Arnau; my mother,
Maria del Carmen; my dad, Jordi; and my brother, Jordi.
(Miquel)
I thank my wife and children for their patience and
support during this adventure.
(Daniel)
To everyone who has sparked my curiosity for finance,
mathematics and artificial intelligence. To my brother,
Víctor, and my parents, Fina and Jesús, for their
support. Thank you.
(David)
Contents
List of Figures xi

List of Tables xv

About the Authors xvii

Preface xix

1 Introduction 1
1.1 Artificial intelligence 1
1.2 Financial engineering 2
1.3 The“AI in finance” framework 3
1.4 Supervised learning 5
1.5 Unsupervised learning 6
1.6 Artificial neural networks 7
1.7 Natural language processing 8
1.8 Volume 2 of Artificial Intelligence in Finance 9
1.9 Where to find this book on GitHub 11

2 Artificial intelligence 13
2.1 Definitions of intelligence 13
2.2 Definitions of artificial intelligence 15
2.3 The history of artificial intelligence 16
2.4 The nature of artificial intelligence environments 18
2.5 Artificial intelligence fields 22
2.6 Artificial intelligence in finance 24
2.7 A mathematical description of supervised, unsupervised
and reinforcement learning 25
2.8 The special case of large language models 32
2.9 Open source artificial intelligence resources 35

3 Financial engineering 39
3.1 Financial engineering history 39
3.2 Three areas of financial engineering 42
3.3 Probability theory and stochastic processes 46
3.4 Random matrix theory 145
3.5 Option theory and practice 146
3.6 Credit modelling 162
3.7 Portfolio allocation 167
3.8 Factor models of returns 177
3.9 Time-series models in finance 181
3.10 Market microstructure and high-frequency trading 183
3.11 Risk management 191
3.12 Unstructured data in finance 195

vii
ARTIFICIAL INTELLIGENCE IN FINANCE

3.13 Retail banking data science modelling 197


3.14 Open problems in financial engineering 213

4 The “AI in finance” framework 217


4.1 The modelling framework in finance 217
4.2 Data sets used in finance 219
4.3 Sparsity, outliers and missing data 220
4.4 Sample size 223
4.5 Feature engineering in finance 226
4.6 Model performance metrics 228
4.7 Model selection in finance 231
4.8 Multimodality in finance 244
4.9 Causality in finance 248
4.10 Explainability of artificial intelligence models 251
4.11 Non-parametric finance 256

5 Supervised learning 259


5.1 Introduction to learning theory 259
5.2 Dynamical systems 285
5.3 Classification and regression 289
5.4 Statistical inference 300
5.5 Statistical classification 310
5.6 Introducing state-space models 316
5.7 k-nearest neighbors 319
5.8 Support vector machine models 324
5.9 Decision trees 335
5.10 XGBoost 339

6 Unsupervised learning 351


6.1 Uniform manifold approximation and projection for
dimension reduction 351
6.2 Construction of the graph 352
6.3 t-distributed stochastic neighbor embedding 353
6.4 Singular value decomposition 355
6.5 Principal component analysis 357
6.6 Clustering 358
6.7 Generative finance 362
6.8 Gaussian mixture model 374
6.9 Generative meta-learning robust quality-diversity portfolios 377

7 Artificial neural networks 381


7.1 Presenting recurrent neural networks 381
7.2 The long short-term memory 389
7.3 N-BEATS 398
7.4 Transformers 414
7.5 Graph networks 452
7.6 Energy-based models 511
7.7 Neural stochastic differential equations 517

viii
CONTENTS

8 Natural language processing 521


8.1 An overview 521
8.2 Natural language processing tasks 526
8.3 Some example tasks 538
8.4 Contextual word representations 550
8.5 Transfer learning 556
8.6 Sentence similarity search 564
8.7 Sequence-to-sequence 571
8.8 Solving natural language processing tasks with
convolutional neural networks 599
8.9 Transfer learning 604
8.10 Deep learning models 608
8.11 Sentence-pair modelling 612
8.12 Natural language processing in finance 629
8.13 Financial Embedding Analysis of Sentiment 637
8.14 Other large language models in finance 646
8.15 Frequency methods versus deep learning methods 647
8.16 The advantages and disadvantages of natural language
processing in finance 648

References 651

ix
List of Figures

3.1 Key advancements in financial modelling 40


3.2 Areas of financial engineering 43
3.3 Inverse transform 122
3.4 Rejection sampling for density p(x) and proposal q(x) 123
3.5 Example of a rough path of order 2 on R2 158
3.6 Summary of equations 161
3.7 Modern data analysis 196
3.8 Alternative data providers 196

4.1 Artificial intelligence finance modelling 218


4.2 Missing data 223
4.3 Sources of generalisation error in financial modelling 235
4.4 The GAMI-Net architecture 253

5.1 Bias and variance diagram 267


5.2 Overfitting 268
5.3 Neural networks (a) before and (b) after dropout 278
5.4 Conditional average where x is the input variable and t is the
output variable 284
5.5 Normal distribution curve 296
5.6 Illustration of SVM 326
5.7 A decision tree for regression 1 336
5.8 A decision tree for regression 2 337
5.9 A decision tree in classification 338
5.10 Sequential boosting of an original weak model to form a robust
model, given prior calculated residual error and regularisation
penalisation metaparameter. 340
5.11 The classical and modern machine learning regimes 345
5.12 The variation of (a) the mean square error and (b) accuracy for
the random forest architecture by model over-parameterisation 345
5.13 The variation of (a) the mean square error and (b) accuracy for
the XGBoost architecture by model over-parameterisation 346
5.14 The variation of (a) the mean square error and (b) accuracy
for the deep neural network architecture by model
over-parameterisation 346
5.15 The variation of (a) the mean square error and (b) accuracy
for the long short-term memory architecture by model
over-parameterisation 347

xi
ARTIFICIAL INTELLIGENCE IN FINANCE

6.1 An autoencoder 363


6.2 Variational autoencoder 367
6.3 Types of conditional graphical model 368
6.4 CVAE model 369
6.5 GAN model 371
6.6 Logarithmic function plot 372
6.7 Conditional generative adversarial net architecture 375
6.8 GNN model architecture 378
6.9 GNN test 379

7.1 A recurrent neural network 382


7.2 Recurrent neural network in time 382
7.3 Weights in BPTT 385
7.4 The flow of error signals and the vanishing gradient problem
in backpropagation. 385
7.5 A plot of 1/(1 + e−2x ) and its tangent lines 387
7.6 Architecture of a memory block with one memory cell 391
7.7 Connections in an LSTM network 393
7.8 A modern LSTM memory block with one cell 394
7.9 Algorithm for the weight update of the LSTM 397
7.10 N-BEATS architecture 399
7.11 Comparison of the (a) hit-ratio, (b) MSE and (c) MAE for
N-BEATS together with LSTM, GRU, vanilla RNN and DNN 416
7.12 Box plots of the hit-ratio for (a) N-BEATS, (b) LSTM and
(c) GRU 417
7.13 Box plots of the hit-ratio for (a) the vanilla RNN and (b) the
DNN 418
7.14 Box plots of the MSE for (a) N-BEATS, (b) LSTM and (c) GRU 419
7.15 Box plots of the MSE for (a) the RNN and (b) the DNN 420
7.16 The multi-head self-attention architecture 425
7.17 Sinusoidal positional encoding with position L = 32 and
dimension d = 128 428
7.18 Schematic showing how rotary position embedding is
implemented 431
7.19 Complete architecture of the transformer model 432
7.20 The Reinforcement Learning from Human Feedback
architecture 433
7.21 Diffusion model architecture 434
7.22 Comparison of Transformer and BiLSTM-Transformer 438
7.23 Details of the BiLSTM-Transformer model 439
7.24 Comparison of prediction 439
7.25 Full GPT architecture 441
7.26 Convolutional self-attention 450
7.27 LogSparse attention 450
7.28 Graph example 454

xii
LIST OF FIGURES

7.29 Euler directed graph 455


7.30 Topological ordering of a DAG 466
7.31 A DAG G and its transitive closure 467
7.32 (a) A DAG G and (b) its transitive reduction 468
7.33 Graphical model where each arrow indicates a dependency 485
7.34 Complex networks 490
7.35 A 4-regular lattice on 12 vertices 494
7.36 A small-world network with n = 20 and k = 4 496
7.37 Sierpinski fractal networks 506
7.38 Cantor dust fractal networks 506
7.39 Multifractal system 509

8.1 A parse tree 529


8.2 Word vectorisation 531
8.3 Text-to-speech system 537
8.4 Word to vector representation 554
8.5 Transfer learning for NLP 557
8.6 Taxonomy of transfer learning for NLP 558
8.7 Probing model set-up 560
8.8 Semantic search 565
8.9 Seq2Seq model 572
8.10 Encoder model 574
8.11 Decoder model 574
8.12 Attention mechanism 578
8.13 (a) Global and (b) local attention 579
8.14 The self-attention mechanism 579
8.15 Simplified attention mechanism where c is the context vector
and a is the learnable function 580
8.16 Implementation of the simplified attention mechanism in
which z is the context vector 581
8.17 Self-attention layer code 586
8.18 Language translator code 587
8.19 The model reads input sentence “ABC” and produces
“WXYZ” as the output sentence 593
8.20 RNN encoder–decoder with context vector C 594
8.21 A hidden unit that adaptively remembers and forgets 595
8.22 Alignment attention mechanism generating the word yt given
the input sentence x 596
8.23 CNN text classification 600
8.24 CNN architecture using tensor products 603
8.25 Masked Seq2Seq framework in MASS 611
8.26 Masked Seq2Seq framework in GPT 611
8.27 Masked Seq2Seq framework in BERT 611
8.28 A typical NLI model 616
8.29 Hierarchical bidirectional RNN with max-pooling 618

xiii
ARTIFICIAL INTELLIGENCE IN FINANCE

8.30 SBERT architecture with (a) classification and (b) a regression


objective function 620
8.31 A typical string NLP model 621
8.32 A string encoder with stacked bidirectional GRUs 623
8.33 A string encoder with stacked bidirectional GRUs and shortcut
connections 624
8.34 String encoder with stacked bidirectional GRUs and
max-pooling 625
8.35 String encoder with stacked bidirectional GRUs and
self-attention mechanism 626
8.36 String encoder with stacked bidirectional GRUs and hard
alignment attention mechanism 627
8.37 String encoder with common features 628
8.38 NLP news modelling framework 633
8.39 Comparison of the company distributions 642
8.40 Comparison of the word count distributions 643
8.41 Score distribution 644
8.42 BloombergGPT performance 646

xiv
List of Tables

2.1 The nature of AI environments 20


2.2 Types of machine learning 26

3.1 From decimals to bits 112


3.2 XORing bits 120
3.3 From decimals to Gray code 121

5.1 Range of a normal deviate 297


5.2 General distance calculations 320
5.3 Pros and cons of using the k-NN methodology 323
5.4 General applications of XGBoost 344
5.5 Training and test results of different related models 348

7.1 Random hyperparameter search with error metrics for Apple


stock, evaluated with N-BEATS on the test set 401
7.2 Random hyperparameter search with error metrics for
JP Morgan stock, evaluated with N-BEATS on the test set 402
7.3 Random hyperparameter search with error metrics for Johnson
& Johnson stock, evaluated with N-BEATS on the test set 403
7.4 Random hyperparameter search with error metrics for Verizon
stock, evaluated with N-BEATS on the test set 404
7.5 Random hyperparameter search with error metrics for
Walmart stock, evaluated with N-BEATS on the test set 405
7.6 Error metrics for N-BEATS evaluated on the test set 406
7.7 Long short-term memory (LSTM) network 408
7.8 Gated Recurrent Unit (GRU) network 410
7.9 Vanilla Recurrent Neural Network (RNN) 412
7.10 Feed Forward Neural Network (DNN) 414
7.11 Mathematical notation 424
7.12 Model parameters 438
7.13 Comparison of closing price forecast results of alternative
models 440
7.14 Pros and cons of using the EBM methodology 518

8.1 Co-occurrence matrix 544


8.2 Semantic textual similarity benchmark 568
8.3 Masked language modelling 612
8.4 MSE for the FinEAS, BERT and BiLSTM models for different
samples from the RavenPack data set 644
8.5 MSE for the FinEAS and FinBERT models for different samples
of the RavenPack data set 645

xv
About the Authors

David Pacheco Aznar is a computational mathematician and data


scientist whose focus is on quantitative finance. He has been a quan-
titative analyst for an investment group in Barcelona for almost four
years, as well as a quantitative researcher at the Artificial Intelli-
gence Finance Institute (AIFI) for a year. As a quantitative analyst,
he developed several back-testing strategies for various models via
both classic and deep learning methods. In addition, he worked on
language-model-oriented solutions to boost the predictive power of
portfolio management strategies. His research output has resulted
in over 1,000 Social Science Research Network (SSRN) downloads
over the last year, and his papers covered generative models for time
series and deep distributional reinforcement learning research and
advancements in the field of portfolio management. He has been a
teaching fellow at Columbia University for big data and AI and rec-
ommender systems courses. David has also been a guest speaker at
New York University, where he has spoken about generative models
in finance, reinforcement learning and deep reinforcement learning
in portfolio management.
Daniel Bloch is the founder of Quant Finance Limited, a structur-
ing company that focuses on statistical arbitrage on stocks, futures
and options’ relative value as well as derivatives pricing and risk
management. He has over 20 years’ experience in modelling equity,
foreign exchange and interest rates on the exotic option trading desk
of various investment banks across the world. Daniel has devel-
oped bespoke solutions to solve problems for the industry using
machine learning. He has an extensive background in and know-
ledge of applied mathematics, engineering, algorithms, physics and
machine learning, applying a cross-application approach between
finance and industry. He has partnered with the best research teams
at École Polytechnique, Imperial College London and the University
of Oxford.
Miquel Noguer i Alonso is a seasoned financial professional and
academic with over 30 years of experience in the quantitative finance
industry. He is the founder of the AIFI and head of development

xvii
ARTIFICIAL INTELLIGENCE IN FINANCE

at Global AI. His career includes the roles of executive director at


UBS AG and chief information officer for Andbank. He has served
on the European Investment Committee at UBS for a decade and is
on the advisory board of the Financial Data Professional (FDP) Insti-
tute and the CFA Society of New York. Miquel is also an academic,
teaching AI, big data and fintech at the NYU Courant Institute, NYU
Tandon, Columbia University and ESADE (Spain), among others.
He pioneered the first fintech and big data course at the London
Business School in 2017. He is the author of 10 published papers on
artificial intelligence. Miquel holds an MBA and a degree in business
administration from ESADE and a PhD in quantitative finance from
Universidad Nacional de Educación a Distancia (UNED), as well
as professional certifications. His research interests include asset
allocation, machine learning, algorithmic trading and fintech.

xviii
Preface

Artificial intelligence (AI) and machine learning are changing all


aspects of human life and the way we live and work. AI is being used
in a variety of industries to automate tasks, improve efficiency and
make better decisions. Some examples of this include large language
models, data science applications, self-driving cars, chatbots and
medical diagnosis systems. As the technology continues to advance,
the potential applications of AI are becoming increasingly diverse
and impactful.
The two volumes of this book aim to cover all the relevant aspects
of theory and practice of AI in finance. In these volumes we shall
explore the use and implementation of AI technologies in different
areas of finance, looking specifically at quantitative finance: portfolio
management, option pricing and hedging, risk management and
retail banking.
Financial engineering has changed as a result of the introduction
of machine learning algorithms to implement “traditional” financial
engineering models in areas such as returns or alpha prediction, fac-
tor modelling, option pricing and hedging and risk management as
well as in new areas of research and modelling such as reinforce-
ment learning and natural language processing. This book intro-
duces the mathematical models and algorithms used in machine
learning, covering supervised and unsupervised learning as well
as reinforcement learning. In the chapter on supervised learning
we present traditional machine learning models, ensemble models,
artificial neural networks, deep neural networks, recurrent neural
networks and Transformers, while the natural language processing
chapter covers the use of algorithms to perform multiple tasks, with
sentiment analysis being one of the most important.
We cover the most advanced algorithms used in the different
quantitative finance domains. The development of large language
models that are multimodal AI models (such as ChatGPT, LLaMA,
LaMDA and GPT-4) will continue to have a profound impact on the
science and business community as their performance in multiple
tasks continues to improve and to sometimes reach human levels
of performance in many areas. For example, GPT-4, is a large-scale

xix
ARTIFICIAL INTELLIGENCE IN FINANCE

multimodal model that can accept image and text inputs and pro-
duce text outputs. While it is less capable than humans in many
real-world scenarios, GPT-4 exhibits human-level performance on
various professional and academic benchmarks, including passing
a simulated bar exam with a score around the top 10% of test takers.
GPT-4 is a transformer-based model pretrained to predict the next
token in a document.
This book offers both a theoretical and a practical perspective
on how we can make the most appropriate use of AI and machine
learning algorithms to carry out finance tasks such as: portfolio
management; option pricing and hedging; risk management and
retail banking. This book aims to extend the literature on generative
models in finance, natural language processing, deep learning and
reinforcement learning.

xx
1

Introduction

1.1 ARTIFICIAL INTELLIGENCE

In Chapter 2 we first provide an overview of artificial intelligence


(AI), delineating what constitutes AI in addition to diving into dif-
ferent definitions of human and artificial intelligence. Then, we
give a historical exposition, tracing the evolution of AI from its
nascent stages to its current state. This historical context sets the
stage for a deeper exploration of different contexts in which AI can
be applied. Those are then classified according to characteristics such
as observability, sample size or dimensionality, providing a compu-
tational framework to describe how AI can operate in real-world
scenarios. A sector-specific application of AI is explored in the sec-
tion on artificial intelligence in finance (Section 2.6), which show-
cases the transformative impact of AI in the financial sector and
describes some of the main areas of research, such as algorithmic
trading, fraud detection and financial forecasting. We then dive into
a mathematical description of the realms of supervised, unsuper-
vised and reinforcement learning, devoting a section to each major
learning paradigm and establishing the mathematical foundations
and algorithms that underpin these machine learning models. In
addition, “self-supervised learning” is treated as a separate section
(Section 2.7.5), detailing this emerging learning paradigm and how
it bridges the gap between supervised and unsupervised learning.
This chapter also covers the major subfields of AI, such as natural
language processing, computer vision and robotics, explaining how
each contributes to AI. There is special emphasis on the special case
of large language models (LMMs) and the advancements in models
such as GPT-3 or GPT-4 are explained as a novelty. We explore their
capabilities, limitations and the computational resources required to
train them (Section 2.8). The final section of the chapter covers the
main libraries used in building neural networks, and provides a link

1
ARTIFICIAL INTELLIGENCE IN FINANCE

to the GitHub repository hosting some of the examples illustrated


in the book.

1.2 FINANCIAL ENGINEERING


Chapter 3 dives into the realm of financial engineering, a field
that fuses financial theory with mathematical methods and com-
putational tools to solve financial problems and manage financial
risks. We begin with a delve into the history, outlining the evolu-
tion of financial engineering as a distinct discipline, its roots and its
progression over the years. This historical backdrop sets the stage
for a discussion on the three main areas of financial engineering:
option pricing, portfolio management and risk management (Sec-
tion 3.2). Throughout the chapter we cover not only classical meth-
ods involving mathematics but also novel approaches using deep
learning.
A significant portion of this chapter is dedicated to probability
theory and stochastic processes (Section 3.3), which are fundamental
to understanding the uncertainty and dynamics inherent in financial
markets. This section covers the basic tenets of probability theory, the
concept and types of random variables and the different probability
distributions used in financial modelling. Stochastic processes, the
Itô integral and Itô formula, and the applications of Itô calculus are
employed to understand the mathematical modelling of financial
markets, particularly the pricing of financial derivatives. The sec-
tion also covers other calculus, such as Stratonovich calculus and an
introduction to stochastic calculus. Finally, we provide an introduc-
tion to Monte Carlo methods, which are usually used for financial
engineering. Next, there is a short section covering random matrix
theory (Section 3.4), which provides insight into statistical behaviour
of eigenvalues and eigenvectors in random matrices, which has
applications in portfolio theory and risk management (mainly in
generating correlations between assets in financial markets). Our
exposition next looks into option theory and practice, starting with
the Black–Scholes model (Section 3.5.1) and then venturing into more
complex models such as the Heston model (Section 3.5.2) and the
rough volatility model (Section 3.5.3). These are essential for under-
standing the pricing and hedging of financial options. Discussions
on interest rate models (Section 3.5.4) cover the modelling of interest
rates and their implications for fixed-income securities pricing and

2
INTRODUCTION

risk management. This section continues by explaining numerical


and pricing, along with an exploration of rough paths and signa-
tures. Finally, it provides some new ideas in the field of quantitative
finance, such as neural stochastic differential equations and infinite-
dimensional generative adversarial networks (GANs), which high-
light the intersection of finance with cutting-edge machine learning
methodologies.
Credit modelling is briefly covered in Section 3.6, which explains
quantitative modelling methods as well as approaches such as credit
modelling using machine learning to understand and manage credit
risk. Section 3.7.3 is on portfolio allocation, which delves into the def-
inition of the portfolio optimisation problem, and showcases Dany
Cajas and Miquel Noguer i Alonso’s take on modern portfolio theory
(MPT). Finally, expected utility theory and portfolio optimisation
using reinforcement learning are discussed. The next few sections of
the chapter cover multiple factor models such as Fama–French mod-
els, traditional time-series models and an introduction to machine
learning in time series. These sections emphasise market microstruc-
ture and high-frequency trading (HFT), discussing optimal execu-
tion strategies in trading and the mechanics and implications of
HFT. We then provide an introduction to risk management and an
unstructured data framework in finance via language. To complete
the chapter, Section 3.13 covers retail banking using data science
modelling. It dives into multiple applications, including customer
segmentation and targeting, fraud detection and prevention, credit
scoring and risk management and ethical and social implications
of Data science in the field. The chapter closes with a short section
on open problems in financial engineering (Section 3.14), discussing
unresolved issues and emerging areas of research in financial engi-
neering and inviting readers to explore and contribute to the ongoing
development in this field. The most relevant topics are forecasting,
trading, regulation and risk management.

1.3 THE “AI IN FINANCE” FRAMEWORK


Chapter 4 focuses on the main topics within the “AI in finance”
framework. First, Section 4.1 sets out the modelling framework,
where the collection of data, feature extraction and model selection
are explained briefly. Then, we explain the data sets and the many

3
ARTIFICIAL INTELLIGENCE IN FINANCE

different types of data that can be used in a financial context (Sec-


tion 4.2). This section elaborates on the types of data used in financial
modelling (including time-series data, financial statements data and
alternative data) and how such data sets can be used in the financial
domain. However, knowing the main sources of data is not enough.
Hence, Section 4.3 is devoted to exploring the main problems: spar-
sity, outliers and missing data. This chapter also provides strategies
for handling such issues to ensure the robustness and reliability of
the models. The importance of sample size is emphasised, and we
discuss the implications of sample size on the stability and gener-
alisability of financial models. Many areas in finance rely on small
data problems, where deep learning techniques might be infeasible.
In the segment on feature engineering in finance (Section 4.5), we
highlight the importance of crafting meaningful features that can
capture the underlying patterns and relationships in financial data.
We delve into the techniques for feature selection, extraction and
transformation, which are crucial for the performance of AI mod-
els. The narrative then shifts to evaluating the efficacy of models
through performance metrics, discussing various metrics and eval-
uation techniques to assess the accuracy, robustness and reliability
of financial models. The comprehensive section on model selection
in finance (Section 4.7) explores the process of choosing the right
model for a particular financial problem. We delve into model uncer-
tainty approaches (Section 4.7.2) and discuss the challenges posed by
model uncertainty and possible mitigation strategies. To avoid dis-
crepancies between training and testing, Section 4.7.3 covers mul-
tiple strategies to work around this problem. Our discussion fur-
ther expands into the unique challenges posed by non-stationarity
and proceeds to compare the pros and cons of parametric and non-
parametric models in the financial context. One of the proposed solu-
tions uses conformal prediction, which offers a framework for reli-
able and valid prediction intervals. Further improvement on these
models is explored by defining the tractability of joint probabil-
ity distributions, which provides insights into the complexities of
modelling joint distributions in finance and how interpolation and
extrapolation techniques can be utilised in financial modelling. Sec-
tion 4.7.10, on regularisation, introduces some mathematical tech-
niques to prevent overfitting and improve model generalisation.
Another point to take into consideration is multimodal distributions

4
INTRODUCTION

in finance; Section 4.8 discusses their occurrence and the impli-


cations that pose challenges for traditional modelling approaches.
Our narrative then transitions into causality in finance (Section 4.9),
discussing the importance of understanding causal relationships in
financial variables to build more reliable and interpretable models.
One of the core problems of AI models – explainability – is addressed
in Section 4.10, which discusses techniques and frameworks to ren-
der AI models more interpretable to stakeholders, a crucial require-
ment in the heavily regulated financial sector. The chapter is capped
off with Section 4.11, on non-parametric finance, which discusses
non-parametric modelling approaches that do not assume a partic-
ular form for the underlying data distribution; these offer flexibility
in capturing complex financial relationships.

1.4 SUPERVISED LEARNING


Chapter 5 provides an in-depth exploration of supervised learning
within the context of AI’s applications in finance. Our narrative
begins by providing foundational knowledge on AI and its trans-
formative role in the financial industry. While AI boasts a range
of learning paradigms, in this chapter we zoom in on supervised
learning, shedding light on its theories and methodologies and its
pivotal role in leveraging labelled data for financial predictions and
insights. Delving deeper, we systematically unpack the intricacies
of supervised learning models tailored for financial applications.
Models such as k-nearest neighbors (Section 5.7), support vector
machines (Section 5.8), decision trees (Section 5.9) and XGBoost (Sec-
tion 5.10) are dissected, each accompanied by mathematical formu-
lations and their specific relevance in the financial data science con-
text. The narrative also emphasises the practical challenges often
encountered in finance, such as data sparsity, outliers and the critical-
ity of model explainability, especially given the sector’s regulatory
demands. Techniques for function estimation, optimisation prob-
lems and stochastic optimisation are highlighted, further cement-
ing the reader’s understanding of how supervised learning operates
within financial time-series data. This chapter balances mathemati-
cal insights with real-world applications to ensure both a theoretical
and practical grasp of supervised learning in the finance domain.
It not only serves as a guide but also underscores open challenges

5
ARTIFICIAL INTELLIGENCE IN FINANCE

and questions, encouraging readers further to probe the evolving


landscape of AI-enhanced financial operations.

1.5 UNSUPERVISED LEARNING


Chapter 6, on unsupervised learning, serves as a deep dive into
the several techniques and methodologies specially tailored for the
world of finance, in which it is common to have high-dimensional
spaces without labelled data sets. We start with the topic of dimen-
sion reduction in Section 6.1; our discussion is steered towards uni-
form manifold approximation and projection (UMAP) for dimen-
sion reduction. This foundational approach is complemented with
an in-depth exploration of how graphs are constructed and laid out
(Section 6.2), smoothing the way for a greater understanding of com-
plex data sets. Subsequently, the spotlight is cast on the t-distributed
stochastic neighbor embedding algorithm (Section 6.3). The t-SNE
technique is dissected, shedding light on its mechanics, plus we reca-
pitulate on SNE and the phenomenon where mismatched tails coun-
terbalance mismatched dimensionalities. As the chapter continues
and we dive into the foundational algorithms of unsupervised learn-
ing and dimensionality reduction, we introduce two classic meth-
ods: singular value decomposition (Section 6.4) and principal com-
ponent analysis (Section 6.5). Both are pivotal in data decomposition
and dimensionality reduction, especially in financial data sets. An
ensuing exploration into clustering techniques (Section 6.6) unveils
the methods and strategies for handling group data, highlighting
their significance in understanding financial patterns.
Section 6.7 stands as a crucial section on generative finance, bring-
ing together multiple generative models that can be applied in
the context of finance. The narrative starts with traditional auto-
encoders (AEs), simple yet powerful neural networks known for
their data compression capabilities. We then move into the genera-
tive space. The chapter unfurls the advancements proposed in vari-
ational autoencoders and conditional variational autoencoders. The
section continues by moving on to another fundamental generative
model type, thus leading to the introduction of GANs, models that
have revolutionised data generation. A special emphasis is placed
on how GANs are tailored for financial time series, showcasing their
potential in simulating financial trends. This is further enriched with
insights into conditional GANs, which provide a more nuanced data

6
INTRODUCTION

generation mechanism. Finally, the reader is introduced to Gaussian


mixture models, which provide a probabilistic approach to data clus-
tering, and a novel approach known as the generative meta-learning
robust quality-diversity portfolio (Sections 6.8 and 6.9).

1.6 ARTIFICIAL NEURAL NETWORKS


Chapter 7 delves into the wide range of topics surrounding artifi-
cial neural networks (ANNs). It commences with our exploration
of recurrent neural networks (RNNs), a type of ANN where con-
nections between nodes form a directed graph along a temporal
sequence: a design that allows the network to maintain a “memory”
of previous inputs. The basic algorithm of RNNs involves a loop
within the network that propagates information from one step to
the next. However, RNNs face a challenge known as the vanishing
gradient problem, where gradients computed during the training
process vanish, making it hard to optimise the weights in the net-
work. This issue also makes it difficult for RNNs to recognise and
exploit long-term dependencies in data.
Transitioning from RNNs, Section 7.2 introduces long short-term
memory networks (LSTMs), which address the vanishing gradient
problem through a mechanism called the constant error carousel.
This mechanism ensures that the error can flow through many time
steps without vanishing or exploding. LSTMs exhibit a unique net-
work architecture with memory cells and multiple gates to better
manage the network’s memory. Our discourse then shifts to N-
BEATS, a neural network architecture tailored for time-series fore-
casting. Section 7.3 provides a detailed mathematical description
of the architecture and discusses the results from meta-learning
experiments conducted using the N-BEATS architecture. Section 7.4
explores Transformers, initially introduced for natural language pro-
cessing (NLP) tasks. Due to their self-attention mechanism, Trans-
formers have become a cornerstone of NLP. Additionally, their par-
allel processing capabilities and scalability have led to explorations
beyond NLP, including applications in financial scenarios, which
are likely to focus on time-series analysis and predictions. Our nar-
rative further unfolds into the realm of graph networks (Section 7.5),
grounding the discussion in the basics of graph theory and graphi-
cal models. It delves into complex networks and their applications
in various domains. Section 7.6 focuses on energy-based models

7
ARTIFICIAL INTELLIGENCE IN FINANCE

(EBMs), a type of probabilistic graphical model that associates scalar


energy to each configuration of the variables of interest. We eluci-
date the mathematical foundations of EBMs, including the learning
process and approximation techniques. A comparative analysis is
provided against other generative models, discussing preferences,
pros and cons. Lastly, Section 7.7 takes a short diversion into neu-
ral stochastic differential equations, introducing stochastic differen-
tial equations in the context of neural networks and discussing how
they can be utilised within a neural network framework for financial
applications.

1.7 NATURAL LANGUAGE PROCESSING


Chapter 8 focuses on NLP, a branch of AI that merges the depth of
human linguistics with the precision of computer science. Our guide
provides an in-depth examination of NLP, bridging the nuances of
human communication with the capabilities of AI. Section 8.1 traces
the evolution of NLP, from its early days of basic rule-based systems
to the current, advanced machine learning-driven techniques. Dif-
ferent language representations have shaped this transformation,
guiding how machines process and understand language.
Several core tasks lie at the heart of NLP. Syntax deals with the
structural framework of language, focusing on how words come
together to form sentences. Semantics delves into the meanings
behind words and phrases, considering the intricacies of context
and connotation. Beyond just individual sentences, NLP also tack-
les broader narratives, studying how sentences link together to
form coherent stories. On the practical side, applications range from
optical character recognition (OCR), which transforms written con-
tent into digital formats, to techniques that make large volumes of
data more accessible, such as text simplification and named-entity
recognition.
As the chapter progresses, we introduce more advanced NLP top-
ics. Words, when viewed in isolation, can be restrictive. This poses a
problem and leads to the introduction of word vectors: mathemati-
cal models that capture the essence of words and their relationships.
These vectors, particularly when context-aware, are adept at captur-
ing semantic nuances that static models often miss. We highlight the
concept of transfer learning, showcasing how knowledge from one

8
INTRODUCTION

area can be repurposed for another, a potent approach in NLP. Break-


through models such as OpenAI’s GPT and BERT are spotlighted
for their innovative approaches. Furthermore, NLP’s potential in
finance is explored, with vast textual data sources, from news to
reports, being mined for novel insights using techniques such as the
financial embedding analysis sentiment (FinEAS) model. In conclu-
sion, Chapter 8 presents a comparative analysis of traditional fre-
quency methods against modern deep learning approaches in NLP,
weighing up their pros and cons. It wraps up with reflections on
the use of NLP in finance, outlining its transformative possibilities
while recognising potential challenges.

1.8 VOLUME 2 OF ARTIFICIAL INTELLIGENCE IN FINANCE


The second volume of this book provides a comprehensive explo-
ration of the application of AI techniques in the financial sector
and delves into advanced AI methodologies and their practical
implementations in finance, focusing on areas such as reinforcement
learning, Markov decision processes and deep learning.
This volume begins with a detailed examination of Markov deci-
sion problems (MDPs), which form the mathematical backbone of
many AI decision-making models. It introduces the key components
of MDPs (ie, states, actions, transition probabilities and rewards)
and it discusses how these elements interact to model complex
decision-making processes. We shall explain various solution meth-
ods, including dynamic programming, value iteration and policy
iteration, emphasising the importance of function approximation
techniques to handle large-scale problems.
Next, we explore the concept of learning optimal policies through
reinforcement learning. We shall cover the foundational algorithms
such as Q-learning and policy gradient methods, explaining how
these techniques can be used to optimise decision-making by max-
imising expected rewards. The text delves into actor–critic algo-
rithms, highlighting their dual-agent structure, where one agent (the
actor) decides on actions while the other (the critic) evaluates them.
The exploration–exploitation trade-off is discussed in detail, provid-
ing insights into balancing the need for exploration with the goal of
policy optimisation.
We revisit the core principles of reinforcement learning in a dedi-
cated chapter, offering a detailed analysis of the agent–environment

9
ARTIFICIAL INTELLIGENCE IN FINANCE

interaction, value functions and the Bellman equations. Temporal


difference (TD) learning is revisited, focusing on prediction and con-
trol tasks, and we introduce advanced TD methods such as forward
TD prediction and eligibility traces. The chapter also examines Q-
learning’s off-policy nature and its efficiency in learning optimal
control policies.
Further enhancing the TD learning framework, we explore mod-
ified TD models, incorporating enhancements such as target-based
TD methods, momentum-based updates and neural network func-
tion approximation. These modifications aim to improve learning
efficiency and convergence rates, addressing specific challenges in
traditional TD learning.
Stochastic approximation techniques in MDPs are also discussed,
highlighting their role in approximating solutions for complex
decision-making problems. We shall introduce Bellman operators,
value iteration, policy iteration and linear programming as meth-
ods to solve MDPs, focusing on stochastic approaches to improve
approximation accuracy.
Deep reinforcement learning is another major focus, leveraging
deep neural networks for function approximation. This volume
covers various deep reinforcement learning algorithms, including
the Deep Q-Network (DQN), Soft Actor-Critic (SAC) and Proxi-
mal Policy Optimization (PPO). We shall explain the integration of
Q-learning with deep neural networks and the role of techniques
such as experience replay and target networks in enhancing learning
stability and performance.
The practical applications of AI in finance are extensively covered,
showcasing case studies in areas such as credit valuation adjustment
hedging, equity machine factor models, option pricing and portfolio
optimisation. These examples illustrate the real-world impact of
AI techniques in improving financial decision-making and strategy
formulation.
Lastly, the volume includes appendixes giving technical details
on local risk minimisation, optimal hedging, risk-averse pricing,
the Black–Scholes framework, the parametric MixVol model and
the application of transformers in finance. These sections provide
additional depth and practical insights, making the book a valuable
resource for both academics and practitioners in the field of AI and
finance.

10
INTRODUCTION

In summary, volume 2 of Artificial Intelligence in Finance offers an


in-depth exploration of advanced AI techniques and their applica-
tions in the financial industry, blending theoretical foundations with
practical case studies to demonstrate the transformative potential of
AI in finance.

1.9 WHERE TO FIND THIS BOOK ON GITHUB


All the code and examples in this book can be found in the follow-
ing GitHub repository: https://github.com/Artificial-Intelligence-
in-Finance/AI-in-Finance-Book.

11
Artificial
For finance professionals and academics Key features of the AI in Finance Framework

By Miquel Noguer i Alonso, Daniel Bloch and David Pacheco Aznar


Artificial Intelligence in Finance | Volume 1: Fundamentals and Applications
keen to understand the impact of are explored, including data modelling,
artificial intelligence (AI) in their field, handling of datasets, and the intricacies of
Artificial Intelligence in Finance,Volume 1: feature engineering. Topics such as model
Fundamentals and Applications serves as a performance metrics and the explainability

Intelligence
practical and extensive guide. This book, of AI models are also addressed, providing
the first in a two-volume series, aims to a rounded perspective of AI’s current and
demystify the role of AI in finance, offering potential role in finance.
a clear and comprehensive overview that
bridges the gap between complex AI concepts Serving as a lead-up to the second volume,

in Finance
and their real-world financial applications. which will focus on reinforcement learning
in finance and applications of AI in Finance,
The content is structured to build a strong this book is an ideal resource for finance
foundation, starting with the basics of AI professionals looking to enhance their AI
and financial engineering. It delves into key knowledge and academics aiming to enter this
areas such as supervised and unsupervised evolving field. Artificial Intelligence in Finance,
learning, artificial neural networks, and Volume 1: Fundamentals and Applications offers a
natural language processing, presented in a comprehensive read for anyone interested in
manner that is accessible to both experienced
finance professionals and newcomers.
the intersection of AI and finance.
Volume1: Fundamentals and Applications
The book also covers essential aspects of
financial engineering, offering insights into
its history, theory, and practical applications.
BY MIQUEL NOGUER I ALONSO, DANIEL BLOCH
This balanced approach ensures that readers AND DAVID PACHECO AZNAR
not only gain theoretical knowledge but also
understand how these concepts are applied in
the finance industry.

RB24-AI in Finance-VOL1-FINAL V2.indd 1 25/09/2024 14:16

You might also like