SlideShare uma empresa Scribd logo
1 de 30
Baixar para ler 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 ?

Mais conteĂșdo relacionado

Destaque

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
 

Destaque (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
 

Semelhante a 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
 
Portfolio Planning
Portfolio PlanningPortfolio Planning
Portfolio Planningahmad bassiouny
 
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
 

Semelhante a 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
 

Último

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
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 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
 
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
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vĂĄzquez
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - 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
 
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
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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 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...
 
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
 
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...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - 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
 
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
 

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