SlideShare a Scribd company logo
GPU Accelerated Backtesting and ML for
Quant Trading Strategies
GTC 2015 | San José | California
Dr. Daniel Egloff
daniel.egloff@quantalea.net
March 18, 2015
Motivation
 Goals
– Execute automated algorithmic trading strategies
– Optimize risk return
 Procedure
– Extract signals and build price forecasting indicators from market data
– Transform indicators into buy / sell decisions
– Apply portfolio risk management
 Challenges
– Find relevant signals and indicators
– Engineer and parameterize trading decision
– Find optimal parameters
 Approach
– Exploit parallelism in the computations
– Accelerate calculations by using a GPU cluster
Algo Trading Strategies
Market data
Input
Trading decision
Mathematical
operations
Output
Configurations
Rules
Example
fast moving
average
slow moving
average
Buy signal Sell signal
Markets
 Futures market
– CME 50 liquid futures
– Other exchanges
 Equity markets
– World stock indices
 FX markets
– 10 major currency pairs
– 30 alternative currency pairs
 Options markets
– Options on futures
– Options on indices
Strategy Universe
Configuration c Trading decision s(c)
1
-1
buy
sell
Utility U(s(c))
P&L / drawdown
Strategy
configurations
Strategy Engineering
Challenge 1: How can we engineer a strategy
producing buy / sell decisions ?
Random Forests
Fi < ti
Fj < tj Buy
Buy
Fi < ti
Sell Fk < tk
Sell
Fi < ti
Fi < ti
Buy Fk < tk
Fi < ti
Fj < tj Sell
Fi < ti
Sell
Buy
Sell Buy
Sell Buy
Sell Buy
Sell Buy
Random Forests
Strategy configuration c
Features Random forest
Trading decision s(c)
1
-1
buy
sell
Training Random Forests
Bootstrapping to create training sets
C 4.5 algorithm for individual tree construction
 Selecting subset of features for tree construction
 Each node is associated with a subset of training samples
 Recursive, starting at the root node
 At each node execute divide and conquer algorithm to find locally
optimal choice
– If samples are in same class (or few class) node is a leaf associated
with that class
– If samples are in two or more classes
 Calculate information gain for each feature
 Select feature if largest information gain for splitting
Entropy
𝑇 = set of samples associated with node
𝐶1, … , 𝐶 𝑛= classes of samples
Entropy
𝐸𝑛𝑡 𝑇 = − 𝑖=1
𝑛 𝑓𝑟𝑒𝑞(𝐶 𝑖,𝑇)
𝑇
𝑙𝑜𝑔2
𝑓𝑟𝑒𝑞(𝐶 𝑖,𝑇)
𝑇
 Characterizes impurity of samples
 Measure of uncertainty
 Additive: impurity of several subsets is
sum of impurities
Information Gain
𝑇1, … , 𝑇𝑠 = subsets of 𝑇 generated by splitting on selected attribute
Information gain discrete feature
𝑔𝑎𝑖𝑛 𝑇1, … , 𝑇𝑠 = 𝐸𝑛𝑡 𝑇 − 𝑖=1
𝑠 𝑇 𝑖
𝑇
𝐸𝑛𝑡 𝑇𝑖
Information gain continuous feature with optimal splitting threshold
𝑔𝑎𝑖𝑛 𝑡 = 𝑔𝑎𝑖𝑛 𝑇≤𝑡, 𝑇>𝑡
𝑡∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑔𝑎𝑖𝑛 𝑡
Actual implementation uses ratio information gain over split ratio
Training Individual Trees
Labels from positive or negative market returns
Selected
features
Permuted
labels
Label
Permutations
to
sort features
All features
Samples / observations
Training Individual Trees
Selected
features
Permuted
labels
Permutations
to
sort features
Weights
Permuted
weights
Permutations
to
sort features
Label
All features
2 0 1 4 0 2 ………
Training Individual Trees
Entropy criterion for
best feature and split
Entropy for
every split
Permuted
labels
Permuted
weights 2. Optimal
feature Fi
1. Optimal split ti
Fi < ti
Training Individual Trees
Recursively refine classification: mask data according to classification
Selected
features
Permuted
labels
Label
Permutations
to
sort features
Weight
Permuted
weights
Permutations
to
sort features
Training Individual Trees
Features
Permuted
labels
Label
Permutations
to
sort features
Weight
Permuted
weights
Permutations
to
sort features
Recursively refine classification: mask data according to classification
GPU Implementation
 Parallelism at multiple levels
– Multiple trees, one for each set of weights
– Independent features
– Independent split points
– Multiple nodes further down the tree
 GPU kernels can be implemented with standard primitives
– Random number generation for weights
– Parallel scan (cumulative sum)
– Parallel map
– Parallel reduction to find optimal feature and split
Speedup
0
10
20
30
40
50
60
20 50 100 20 50 100 20 50 100 20 50 100
1 2 4 8
20000
50000
100000
Depth
Features
Samples
Strategy Backtesting
Challenge2: How to choose best trading
strategy ?
Walk Forward Optimization
In sample Out of sample
3-6 months 1 month
In sample Out of sample
In sample Out of sample
shift by 1 month
Trading P&L
Market returns r(ti)
r(ti) = log(P(ti) / P(ti-1))
ti-1 ti
P(ti-1)
P(ti)
r
Trading decision s(c)
P&L(c) = <s(c), r>
r r r r
1 -1 1 1 -1
…..
…..
…..
…..
Market prices Market returns
time
Optimal Configuration
s(c)
s(c)
r
s(c)
s(c)
s(c)
s(c)
s(c)
s(c)
P&L
=
Configurations
pick configuration with largest P&L
x
Bootstrapping Trading P&L
s(c)
s(c)
r
s(c)
s(c)
s(c)
s(c)
s(c)
s(c)
P&L
=
Configurations
pick configuration with largest P&L
x
w w w w
x
x
x
x
x
ww
Weights
r .* w
Hypothesis Tests
Null Hypothesis
Trading P&L<= 0
Alternative Hypothesis
Trading P&L > 0
Trading P&L Distribution
optimal configurations
for each weight
c* for w = 1
p-value for test0
P&L
x
x
x
x
x
x
White Reality Check
 Scale exposure according to distance from 0
 Do not trade if negative returns
c* for w = 1
0
p-value
c* for w = 1
0
p-value
Market 1 Market n……
GPU Implementation
 Parallelism at multiple levels
– Multiple markets
– Independent in-sample / out-of-sample windows
– Independent strategy configurations
– Independent time steps for utility functions such as mean return
 GPU kernels can be implemented with standard primitives
– Random number generation
– Matrix multiplication (almost, up to return vector scaling the weights)
– Parallel reduction
GPU Implementation
 GPU grid
– Multiple markets
– Independent in-sample / out-of-sample windows
 Per GPU
– Independent strategy configurations
– Independent time steps for utility functions such as mean return
Dr. Daniel Egloff
daniel.egloff@quantalea.net
March 18, 2015
Questions ?

More Related Content

What's hot

Bayes network
Bayes networkBayes network
Bayes network
Dr. C.V. Suresh Babu
 
Instance based learning
Instance based learningInstance based learning
Instance based learning
swapnac12
 
Resampling methods
Resampling methodsResampling methods
Resampling methods
Setia Pramana
 
Belief Networks & Bayesian Classification
Belief Networks & Bayesian ClassificationBelief Networks & Bayesian Classification
Belief Networks & Bayesian Classification
Adnan Masood
 
Introduction to Bayesian Inference
Introduction to Bayesian InferenceIntroduction to Bayesian Inference
Introduction to Bayesian Inference
Steven Scott
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
swapnac12
 
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Edureka!
 
Hypothesis Testing With Python
Hypothesis Testing With PythonHypothesis Testing With Python
Hypothesis Testing With Python
Mosky Liu
 
Naive Bayes Presentation
Naive Bayes PresentationNaive Bayes Presentation
Naive Bayes Presentation
Md. Enamul Haque Chowdhury
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
Rajendran
 
Bayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionBayesian Networks - A Brief Introduction
Bayesian Networks - A Brief Introduction
Adnan Masood
 
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Simplilearn
 
String matching algorithm
String matching algorithmString matching algorithm
String matching algorithm
Alokeparna Choudhury
 
Naive Bayes Classifier
Naive Bayes ClassifierNaive Bayes Classifier
Naive Bayes Classifier
Yiqun Hu
 
Bayesian networks
Bayesian networksBayesian networks
Bayesian networks
Massimiliano Patacchiola
 
Naive Bayes
Naive Bayes Naive Bayes
Naive Bayes
Eric Wilson
 
Bayes Belief Networks
Bayes Belief NetworksBayes Belief Networks
Bayes Belief Networks
Sai Kumar Kodam
 

What's hot (20)

Bayes network
Bayes networkBayes network
Bayes network
 
Naive bayes
Naive bayesNaive bayes
Naive bayes
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Instance based learning
Instance based learningInstance based learning
Instance based learning
 
Resampling methods
Resampling methodsResampling methods
Resampling methods
 
Belief Networks & Bayesian Classification
Belief Networks & Bayesian ClassificationBelief Networks & Bayesian Classification
Belief Networks & Bayesian Classification
 
Introduction to Bayesian Inference
Introduction to Bayesian InferenceIntroduction to Bayesian Inference
Introduction to Bayesian Inference
 
Genetic algorithms
Genetic algorithmsGenetic algorithms
Genetic algorithms
 
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
Naive Bayes Classifier in Python | Naive Bayes Algorithm | Machine Learning A...
 
Hypothesis Testing With Python
Hypothesis Testing With PythonHypothesis Testing With Python
Hypothesis Testing With Python
 
Naive Bayes Presentation
Naive Bayes PresentationNaive Bayes Presentation
Naive Bayes Presentation
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
Bayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionBayesian Networks - A Brief Introduction
Bayesian Networks - A Brief Introduction
 
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
Decision Tree Algorithm With Example | Decision Tree In Machine Learning | Da...
 
String matching algorithm
String matching algorithmString matching algorithm
String matching algorithm
 
convex hull
convex hullconvex hull
convex hull
 
Naive Bayes Classifier
Naive Bayes ClassifierNaive Bayes Classifier
Naive Bayes Classifier
 
Bayesian networks
Bayesian networksBayesian networks
Bayesian networks
 
Naive Bayes
Naive Bayes Naive Bayes
Naive Bayes
 
Bayes Belief Networks
Bayes Belief NetworksBayes Belief Networks
Bayes Belief Networks
 

Viewers also liked

Hacking The Trading Floor
Hacking The Trading FloorHacking The Trading Floor
Hacking The Trading Flooriffybird_099
 
Algorithmic & quantitative trading webinar
Algorithmic & quantitative trading webinarAlgorithmic & quantitative trading webinar
Algorithmic & quantitative trading webinar
QuantInsti
 
Trading Systems
Trading SystemsTrading Systems
Trading Systemsapimec
 
Clase 24/04/09
Clase 24/04/09Clase 24/04/09
КГТУ Лаб 1: Stocks / FIX / FAST
КГТУ Лаб 1: Stocks / FIX / FASTКГТУ Лаб 1: Stocks / FIX / FAST
КГТУ Лаб 1: Stocks / FIX / FAST
Iosif Itkin
 
Sascon 20/05 Room 1 Introduction
Sascon 20/05 Room 1 IntroductionSascon 20/05 Room 1 Introduction
Sascon 20/05 Room 1 Introductionsascon
 
A lei dos gráficos
A lei dos gráficosA lei dos gráficos
A lei dos gráficos
Ernani Dias
 
Probability Forecasting - a Machine Learning Perspective
Probability Forecasting - a Machine Learning PerspectiveProbability Forecasting - a Machine Learning Perspective
Probability Forecasting - a Machine Learning Perspectivebutest
 
Order book dynamics in high frequency trading
Order book dynamics in high frequency tradingOrder book dynamics in high frequency trading
Order book dynamics in high frequency trading
QuantInsti
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
Chester Chen
 
Pairs trading using R
Pairs trading using R Pairs trading using R
Pairs trading using R
Algoix Technologies LLP
 
Backtesting Trading Strategies with R
Backtesting Trading Strategies with RBacktesting Trading Strategies with R
Backtesting Trading Strategies with Reraviv
 
Optimizing the
 Data Supply Chain
 for Data Science
Optimizing the
 Data Supply Chain
 for Data ScienceOptimizing the
 Data Supply Chain
 for Data Science
Optimizing the
 Data Supply Chain
 for Data Science
Vital.AI
 
How to design quant trading strategies using “R”?
How to design quant trading strategies using “R”?How to design quant trading strategies using “R”?
How to design quant trading strategies using “R”?
QuantInsti
 
Artificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep LearningArtificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep Learning
Sujit Pal
 
Deep Learning and the state of AI / 2016
Deep Learning and the state of AI / 2016Deep Learning and the state of AI / 2016
Deep Learning and the state of AI / 2016
Grigory Sapunov
 

Viewers also liked (16)

Hacking The Trading Floor
Hacking The Trading FloorHacking The Trading Floor
Hacking The Trading Floor
 
Algorithmic & quantitative trading webinar
Algorithmic & quantitative trading webinarAlgorithmic & quantitative trading webinar
Algorithmic & quantitative trading webinar
 
Trading Systems
Trading SystemsTrading Systems
Trading Systems
 
Clase 24/04/09
Clase 24/04/09Clase 24/04/09
Clase 24/04/09
 
КГТУ Лаб 1: Stocks / FIX / FAST
КГТУ Лаб 1: Stocks / FIX / FASTКГТУ Лаб 1: Stocks / FIX / FAST
КГТУ Лаб 1: Stocks / FIX / FAST
 
Sascon 20/05 Room 1 Introduction
Sascon 20/05 Room 1 IntroductionSascon 20/05 Room 1 Introduction
Sascon 20/05 Room 1 Introduction
 
A lei dos gráficos
A lei dos gráficosA lei dos gráficos
A lei dos gráficos
 
Probability Forecasting - a Machine Learning Perspective
Probability Forecasting - a Machine Learning PerspectiveProbability Forecasting - a Machine Learning Perspective
Probability Forecasting - a Machine Learning Perspective
 
Order book dynamics in high frequency trading
Order book dynamics in high frequency tradingOrder book dynamics in high frequency trading
Order book dynamics in high frequency trading
 
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
SF Big Analytics & SF Machine Learning Meetup: Machine Learning at the Limit ...
 
Pairs trading using R
Pairs trading using R Pairs trading using R
Pairs trading using R
 
Backtesting Trading Strategies with R
Backtesting Trading Strategies with RBacktesting Trading Strategies with R
Backtesting Trading Strategies with R
 
Optimizing the
 Data Supply Chain
 for Data Science
Optimizing the
 Data Supply Chain
 for Data ScienceOptimizing the
 Data Supply Chain
 for Data Science
Optimizing the
 Data Supply Chain
 for Data Science
 
How to design quant trading strategies using “R”?
How to design quant trading strategies using “R”?How to design quant trading strategies using “R”?
How to design quant trading strategies using “R”?
 
Artificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep LearningArtificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep Learning
 
Deep Learning and the state of AI / 2016
Deep Learning and the state of AI / 2016Deep Learning and the state of AI / 2016
Deep Learning and the state of AI / 2016
 

Similar to GPU Accelerated Backtesting and Machine Learning for Quant Trading Strategies

quantmachine
quantmachinequantmachine
quantmachine
Hovhannes Grigoryan
 
Building and deploying analytics
Building and deploying analyticsBuilding and deploying analytics
Building and deploying analytics
Collin Bennett
 
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an..."Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
Quantopian
 
Quant trading with artificial intelligence
Quant trading with artificial intelligenceQuant trading with artificial intelligence
Quant trading with artificial intelligence
Roger Lee, CFA
 
Online advertising and large scale model fitting
Online advertising and large scale model fittingOnline advertising and large scale model fitting
Online advertising and large scale model fitting
Wush Wu
 
XLSTAT - Statistical Analysis Software
XLSTAT - Statistical Analysis Software XLSTAT - Statistical Analysis Software
XLSTAT - Statistical Analysis Software
xlstat
 
Portfolio Planning
Portfolio PlanningPortfolio Planning
Portfolio Planning
ahmad bassiouny
 
DMA Analytic Challenge 2015 final
DMA Analytic Challenge 2015 finalDMA Analytic Challenge 2015 final
DMA Analytic Challenge 2015 final
Karan Sarao
 
Intro to Quantitative Investment (Lecture 1 of 6)
Intro to Quantitative Investment (Lecture 1 of 6)Intro to Quantitative Investment (Lecture 1 of 6)
Intro to Quantitative Investment (Lecture 1 of 6)
Adrian Aley
 
Lecture16_Process Analyzer and OPTQUEST.ppt
Lecture16_Process Analyzer and OPTQUEST.pptLecture16_Process Analyzer and OPTQUEST.ppt
Lecture16_Process Analyzer and OPTQUEST.ppt
AbdAbd72
 
Cheatsheet machine-learning-tips-and-tricks
Cheatsheet machine-learning-tips-and-tricksCheatsheet machine-learning-tips-and-tricks
Cheatsheet machine-learning-tips-and-tricks
Steve Nouri
 
[DOLAP2020] Towards Conversational OLAP
[DOLAP2020] Towards Conversational OLAP[DOLAP2020] Towards Conversational OLAP
[DOLAP2020] Towards Conversational OLAP
University of Bologna
 
Artificial intelligence and IoT
Artificial intelligence and IoTArtificial intelligence and IoT
Artificial intelligence and IoT
Veselin Pizurica
 
Predictive Analytics for Alpha Generation and Risk Management
Predictive Analytics for Alpha Generation and Risk ManagementPredictive Analytics for Alpha Generation and Risk Management
Predictive Analytics for Alpha Generation and Risk Management
Yigal D. Jhirad
 
Marketing Research Approaches .docx
Marketing Research Approaches .docxMarketing Research Approaches .docx
Marketing Research Approaches .docx
alfredacavx97
 
Parallel Processing of Big Data in Finance for Alpha Generation and Risk Mana...
Parallel Processing of Big Data in Finance for Alpha Generation and Risk Mana...Parallel Processing of Big Data in Finance for Alpha Generation and Risk Mana...
Parallel Processing of Big Data in Finance for Alpha Generation and Risk Mana...
Yigal D. Jhirad
 
Ch. 4-demand-estimation(2)
Ch. 4-demand-estimation(2)Ch. 4-demand-estimation(2)
Ch. 4-demand-estimation(2)
anj134u
 
Getting Started with MDX 20140625a
Getting Started with MDX 20140625aGetting Started with MDX 20140625a
Getting Started with MDX 20140625aRon Moore
 
IFTA2020 Kei Nakagawa
IFTA2020 Kei NakagawaIFTA2020 Kei Nakagawa
IFTA2020 Kei Nakagawa
Kei Nakagawa
 
StackAdapt Machine Learning Pipeline
StackAdapt Machine Learning PipelineStackAdapt Machine Learning Pipeline
StackAdapt Machine Learning Pipeline
Larkin Liu
 

Similar to GPU Accelerated Backtesting and Machine Learning for Quant Trading Strategies (20)

quantmachine
quantmachinequantmachine
quantmachine
 
Building and deploying analytics
Building and deploying analyticsBuilding and deploying analytics
Building and deploying analytics
 
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an..."Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
"Quantitative Trading as a Mathematical Science" by Dr. Haksun Li, Founder an...
 
Quant trading with artificial intelligence
Quant trading with artificial intelligenceQuant trading with artificial intelligence
Quant trading with artificial intelligence
 
Online advertising and large scale model fitting
Online advertising and large scale model fittingOnline advertising and large scale model fitting
Online advertising and large scale model fitting
 
XLSTAT - Statistical Analysis Software
XLSTAT - Statistical Analysis Software XLSTAT - Statistical Analysis Software
XLSTAT - Statistical Analysis Software
 
Portfolio Planning
Portfolio PlanningPortfolio Planning
Portfolio Planning
 
DMA Analytic Challenge 2015 final
DMA Analytic Challenge 2015 finalDMA Analytic Challenge 2015 final
DMA Analytic Challenge 2015 final
 
Intro to Quantitative Investment (Lecture 1 of 6)
Intro to Quantitative Investment (Lecture 1 of 6)Intro to Quantitative Investment (Lecture 1 of 6)
Intro to Quantitative Investment (Lecture 1 of 6)
 
Lecture16_Process Analyzer and OPTQUEST.ppt
Lecture16_Process Analyzer and OPTQUEST.pptLecture16_Process Analyzer and OPTQUEST.ppt
Lecture16_Process Analyzer and OPTQUEST.ppt
 
Cheatsheet machine-learning-tips-and-tricks
Cheatsheet machine-learning-tips-and-tricksCheatsheet machine-learning-tips-and-tricks
Cheatsheet machine-learning-tips-and-tricks
 
[DOLAP2020] Towards Conversational OLAP
[DOLAP2020] Towards Conversational OLAP[DOLAP2020] Towards Conversational OLAP
[DOLAP2020] Towards Conversational OLAP
 
Artificial intelligence and IoT
Artificial intelligence and IoTArtificial intelligence and IoT
Artificial intelligence and IoT
 
Predictive Analytics for Alpha Generation and Risk Management
Predictive Analytics for Alpha Generation and Risk ManagementPredictive Analytics for Alpha Generation and Risk Management
Predictive Analytics for Alpha Generation and Risk Management
 
Marketing Research Approaches .docx
Marketing Research Approaches .docxMarketing Research Approaches .docx
Marketing Research Approaches .docx
 
Parallel Processing of Big Data in Finance for Alpha Generation and Risk Mana...
Parallel Processing of Big Data in Finance for Alpha Generation and Risk Mana...Parallel Processing of Big Data in Finance for Alpha Generation and Risk Mana...
Parallel Processing of Big Data in Finance for Alpha Generation and Risk Mana...
 
Ch. 4-demand-estimation(2)
Ch. 4-demand-estimation(2)Ch. 4-demand-estimation(2)
Ch. 4-demand-estimation(2)
 
Getting Started with MDX 20140625a
Getting Started with MDX 20140625aGetting Started with MDX 20140625a
Getting Started with MDX 20140625a
 
IFTA2020 Kei Nakagawa
IFTA2020 Kei NakagawaIFTA2020 Kei Nakagawa
IFTA2020 Kei Nakagawa
 
StackAdapt Machine Learning Pipeline
StackAdapt Machine Learning PipelineStackAdapt Machine Learning Pipeline
StackAdapt Machine Learning Pipeline
 

Recently uploaded

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 

Recently uploaded (20)

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 

GPU Accelerated Backtesting and Machine Learning for Quant Trading Strategies

  • 1. GPU Accelerated Backtesting and ML for Quant Trading Strategies GTC 2015 | San José | California Dr. Daniel Egloff daniel.egloff@quantalea.net March 18, 2015
  • 2. Motivation  Goals – Execute automated algorithmic trading strategies – Optimize risk return  Procedure – Extract signals and build price forecasting indicators from market data – Transform indicators into buy / sell decisions – Apply portfolio risk management  Challenges – Find relevant signals and indicators – Engineer and parameterize trading decision – Find optimal parameters  Approach – Exploit parallelism in the computations – Accelerate calculations by using a GPU cluster
  • 3. Algo Trading Strategies Market data Input Trading decision Mathematical operations Output Configurations Rules
  • 5. Markets  Futures market – CME 50 liquid futures – Other exchanges  Equity markets – World stock indices  FX markets – 10 major currency pairs – 30 alternative currency pairs  Options markets – Options on futures – Options on indices
  • 6. Strategy Universe Configuration c Trading decision s(c) 1 -1 buy sell Utility U(s(c)) P&L / drawdown Strategy configurations
  • 7. Strategy Engineering Challenge 1: How can we engineer a strategy producing buy / sell decisions ?
  • 8. Random Forests Fi < ti Fj < tj Buy Buy Fi < ti Sell Fk < tk Sell Fi < ti Fi < ti Buy Fk < tk Fi < ti Fj < tj Sell Fi < ti Sell Buy Sell Buy Sell Buy Sell Buy Sell Buy
  • 9. Random Forests Strategy configuration c Features Random forest Trading decision s(c) 1 -1 buy sell
  • 10. Training Random Forests Bootstrapping to create training sets C 4.5 algorithm for individual tree construction  Selecting subset of features for tree construction  Each node is associated with a subset of training samples  Recursive, starting at the root node  At each node execute divide and conquer algorithm to find locally optimal choice – If samples are in same class (or few class) node is a leaf associated with that class – If samples are in two or more classes  Calculate information gain for each feature  Select feature if largest information gain for splitting
  • 11. Entropy 𝑇 = set of samples associated with node 𝐶1, … , 𝐶 𝑛= classes of samples Entropy 𝐸𝑛𝑡 𝑇 = − 𝑖=1 𝑛 𝑓𝑟𝑒𝑞(𝐶 𝑖,𝑇) 𝑇 𝑙𝑜𝑔2 𝑓𝑟𝑒𝑞(𝐶 𝑖,𝑇) 𝑇  Characterizes impurity of samples  Measure of uncertainty  Additive: impurity of several subsets is sum of impurities
  • 12. Information Gain 𝑇1, … , 𝑇𝑠 = subsets of 𝑇 generated by splitting on selected attribute Information gain discrete feature 𝑔𝑎𝑖𝑛 𝑇1, … , 𝑇𝑠 = 𝐸𝑛𝑡 𝑇 − 𝑖=1 𝑠 𝑇 𝑖 𝑇 𝐸𝑛𝑡 𝑇𝑖 Information gain continuous feature with optimal splitting threshold 𝑔𝑎𝑖𝑛 𝑡 = 𝑔𝑎𝑖𝑛 𝑇≤𝑡, 𝑇>𝑡 𝑡∗ = 𝑎𝑟𝑔𝑚𝑎𝑥 𝑔𝑎𝑖𝑛 𝑡 Actual implementation uses ratio information gain over split ratio
  • 13. Training Individual Trees Labels from positive or negative market returns Selected features Permuted labels Label Permutations to sort features All features Samples / observations
  • 14. Training Individual Trees Selected features Permuted labels Permutations to sort features Weights Permuted weights Permutations to sort features Label All features 2 0 1 4 0 2 ………
  • 15. Training Individual Trees Entropy criterion for best feature and split Entropy for every split Permuted labels Permuted weights 2. Optimal feature Fi 1. Optimal split ti Fi < ti
  • 16. Training Individual Trees Recursively refine classification: mask data according to classification Selected features Permuted labels Label Permutations to sort features Weight Permuted weights Permutations to sort features
  • 17. Training Individual Trees Features Permuted labels Label Permutations to sort features Weight Permuted weights Permutations to sort features Recursively refine classification: mask data according to classification
  • 18. GPU Implementation  Parallelism at multiple levels – Multiple trees, one for each set of weights – Independent features – Independent split points – Multiple nodes further down the tree  GPU kernels can be implemented with standard primitives – Random number generation for weights – Parallel scan (cumulative sum) – Parallel map – Parallel reduction to find optimal feature and split
  • 19. Speedup 0 10 20 30 40 50 60 20 50 100 20 50 100 20 50 100 20 50 100 1 2 4 8 20000 50000 100000 Depth Features Samples
  • 20. Strategy Backtesting Challenge2: How to choose best trading strategy ?
  • 21. Walk Forward Optimization In sample Out of sample 3-6 months 1 month In sample Out of sample In sample Out of sample shift by 1 month
  • 22. Trading P&L Market returns r(ti) r(ti) = log(P(ti) / P(ti-1)) ti-1 ti P(ti-1) P(ti) r Trading decision s(c) P&L(c) = <s(c), r> r r r r 1 -1 1 1 -1 ….. ….. ….. ….. Market prices Market returns time
  • 24. Bootstrapping Trading P&L s(c) s(c) r s(c) s(c) s(c) s(c) s(c) s(c) P&L = Configurations pick configuration with largest P&L x w w w w x x x x x ww Weights r .* w
  • 25. Hypothesis Tests Null Hypothesis Trading P&L<= 0 Alternative Hypothesis Trading P&L > 0
  • 26. Trading P&L Distribution optimal configurations for each weight c* for w = 1 p-value for test0 P&L x x x x x x
  • 27. White Reality Check  Scale exposure according to distance from 0  Do not trade if negative returns c* for w = 1 0 p-value c* for w = 1 0 p-value Market 1 Market n……
  • 28. GPU Implementation  Parallelism at multiple levels – Multiple markets – Independent in-sample / out-of-sample windows – Independent strategy configurations – Independent time steps for utility functions such as mean return  GPU kernels can be implemented with standard primitives – Random number generation – Matrix multiplication (almost, up to return vector scaling the weights) – Parallel reduction
  • 29. GPU Implementation  GPU grid – Multiple markets – Independent in-sample / out-of-sample windows  Per GPU – Independent strategy configurations – Independent time steps for utility functions such as mean return