SlideShare a Scribd company logo
1 of 30
Download to read offline
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

Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement LearningDongHyun Kwak
 
Probability mass functions and probability density functions
Probability mass functions and probability density functionsProbability mass functions and probability density functions
Probability mass functions and probability density functionsAnkit Katiyar
 
Tutorial: Python, PuLP and GLPK
Tutorial: Python, PuLP and GLPKTutorial: Python, PuLP and GLPK
Tutorial: Python, PuLP and GLPKsucha
 
강화학습 알고리즘의 흐름도 Part 2
강화학습 알고리즘의 흐름도 Part 2강화학습 알고리즘의 흐름도 Part 2
강화학습 알고리즘의 흐름도 Part 2Dongmin Lee
 
XGBoost: the algorithm that wins every competition
XGBoost: the algorithm that wins every competitionXGBoost: the algorithm that wins every competition
XGBoost: the algorithm that wins every competitionJaroslaw Szymczak
 
CNN Attention Networks
CNN Attention NetworksCNN Attention Networks
CNN Attention NetworksTaeoh Kim
 
Application Of Derivative In Real Life.
Application Of Derivative In Real Life.Application Of Derivative In Real Life.
Application Of Derivative In Real Life.Afnanul Hassan
 
PERBANDINGAN (Skala Peta & Model) - pertemuan 4
PERBANDINGAN (Skala Peta & Model)  - pertemuan 4PERBANDINGAN (Skala Peta & Model)  - pertemuan 4
PERBANDINGAN (Skala Peta & Model) - pertemuan 4Shinta Novianti
 
STRUKTUR ALJABAR GRUP - HOMOMORFISMA
STRUKTUR ALJABAR GRUP - HOMOMORFISMASTRUKTUR ALJABAR GRUP - HOMOMORFISMA
STRUKTUR ALJABAR GRUP - HOMOMORFISMAendahnurfebriyanti
 
An introduction to Game Theory
An introduction to Game TheoryAn introduction to Game Theory
An introduction to Game TheoryPaul Trafford
 
Integral bab-14-kuliah-matematika-ekonomi.news
Integral bab-14-kuliah-matematika-ekonomi.news Integral bab-14-kuliah-matematika-ekonomi.news
Integral bab-14-kuliah-matematika-ekonomi.news Haidar Bashofi
 
An introduction to reinforcement learning
An introduction to  reinforcement learningAn introduction to  reinforcement learning
An introduction to reinforcement learningJie-Han Chen
 
Traveling salesman problem(tsp)
Traveling salesman problem(tsp)Traveling salesman problem(tsp)
Traveling salesman problem(tsp)Viraj Patil
 
Proposal kuantitatif
Proposal kuantitatifProposal kuantitatif
Proposal kuantitatifAlina Margono
 

What's hot (16)

Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning
 
Probability mass functions and probability density functions
Probability mass functions and probability density functionsProbability mass functions and probability density functions
Probability mass functions and probability density functions
 
Data Science Crash Course
Data Science Crash CourseData Science Crash Course
Data Science Crash Course
 
Tutorial: Python, PuLP and GLPK
Tutorial: Python, PuLP and GLPKTutorial: Python, PuLP and GLPK
Tutorial: Python, PuLP and GLPK
 
강화학습 알고리즘의 흐름도 Part 2
강화학습 알고리즘의 흐름도 Part 2강화학습 알고리즘의 흐름도 Part 2
강화학습 알고리즘의 흐름도 Part 2
 
XGBoost: the algorithm that wins every competition
XGBoost: the algorithm that wins every competitionXGBoost: the algorithm that wins every competition
XGBoost: the algorithm that wins every competition
 
CNN Attention Networks
CNN Attention NetworksCNN Attention Networks
CNN Attention Networks
 
Application Of Derivative In Real Life.
Application Of Derivative In Real Life.Application Of Derivative In Real Life.
Application Of Derivative In Real Life.
 
PERBANDINGAN (Skala Peta & Model) - pertemuan 4
PERBANDINGAN (Skala Peta & Model)  - pertemuan 4PERBANDINGAN (Skala Peta & Model)  - pertemuan 4
PERBANDINGAN (Skala Peta & Model) - pertemuan 4
 
STRUKTUR ALJABAR GRUP - HOMOMORFISMA
STRUKTUR ALJABAR GRUP - HOMOMORFISMASTRUKTUR ALJABAR GRUP - HOMOMORFISMA
STRUKTUR ALJABAR GRUP - HOMOMORFISMA
 
An introduction to Game Theory
An introduction to Game TheoryAn introduction to Game Theory
An introduction to Game Theory
 
Integral bab-14-kuliah-matematika-ekonomi.news
Integral bab-14-kuliah-matematika-ekonomi.news Integral bab-14-kuliah-matematika-ekonomi.news
Integral bab-14-kuliah-matematika-ekonomi.news
 
Differentiation
DifferentiationDifferentiation
Differentiation
 
An introduction to reinforcement learning
An introduction to  reinforcement learningAn introduction to  reinforcement learning
An introduction to reinforcement learning
 
Traveling salesman problem(tsp)
Traveling salesman problem(tsp)Traveling salesman problem(tsp)
Traveling salesman problem(tsp)
 
Proposal kuantitatif
Proposal kuantitatifProposal kuantitatif
Proposal kuantitatif
 

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 webinarQuantInsti
 
Trading Systems
Trading SystemsTrading Systems
Trading Systemsapimec
 
КГТУ Лаб 1: Stocks / FIX / FAST
КГТУ Лаб 1: Stocks / FIX / FASTКГТУ Лаб 1: Stocks / FIX / FAST
КГТУ Лаб 1: Stocks / FIX / FASTIosif 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áficosErnani 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 tradingQuantInsti
 
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
 
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 ScienceVital.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 LearningSujit 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 / 2016Grigory 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

Building and deploying analytics
Building and deploying analyticsBuilding and deploying analytics
Building and deploying analyticsCollin 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 intelligenceRoger 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 fittingWush Wu
 
XLSTAT - Statistical Analysis Software
XLSTAT - Statistical Analysis Software XLSTAT - Statistical Analysis Software
XLSTAT - Statistical Analysis Software xlstat
 
DMA Analytic Challenge 2015 final
DMA Analytic Challenge 2015 finalDMA Analytic Challenge 2015 final
DMA Analytic Challenge 2015 finalKaran 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.pptAbdAbd72
 
Cheatsheet machine-learning-tips-and-tricks
Cheatsheet machine-learning-tips-and-tricksCheatsheet machine-learning-tips-and-tricks
Cheatsheet machine-learning-tips-and-tricksSteve Nouri
 
[DOLAP2020] Towards Conversational OLAP
[DOLAP2020] Towards Conversational OLAP[DOLAP2020] Towards Conversational OLAP
[DOLAP2020] Towards Conversational OLAPUniversity of Bologna
 
Artificial intelligence and IoT
Artificial intelligence and IoTArtificial intelligence and IoT
Artificial intelligence and IoTVeselin 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 ManagementYigal D. Jhirad
 
Marketing Research Approaches .docx
Marketing Research Approaches .docxMarketing Research Approaches .docx
Marketing Research Approaches .docxalfredacavx97
 
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 NakagawaKei Nakagawa
 
StackAdapt Machine Learning Pipeline
StackAdapt Machine Learning PipelineStackAdapt Machine Learning Pipeline
StackAdapt Machine Learning PipelineLarkin 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

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

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