SlideShare a Scribd company logo
1 of 28
Download to read offline
Programming and Backtesting Quantitative Trading
Strategies
AlgoQuant – A Quantitative Trading Research Toolbox
Haksun Li
haksun.li@numericalmethod.com
www.numericalmethod.com
Speaker Profile
 Dr. Haksun Li
 CEO, Numerical Method Inc.
 (Ex-)Adjunct Professors, Industry Fellow, Advisor,
Consultant with the National University of Singapore,
Nanyang Technological University, Fudan University,
the Hong Kong University of Science and Technology.
 Quantitative Trader/Analyst, BNPP, UBS
 PhD, Computer Sci, University of Michigan Ann Arbor
 M.S., Financial Mathematics, University of Chicago
 B.S., Mathematics, University of Chicago
2
The Role of Technology in
Quantitative Trading
3
Step 2 - Coding
4
 After modeling, we code up the quantitative trading
strategy for
 backtesting (in-sample and out-sample),
 computing the properties, e.g., expected P&L, max
drawdown, using simulation,
 calibrating parameters,
 analyzing sensitivity,
 trading live.
Ideal
5
 A trader dreams of a trading idea.
 He can quickly code it up to produce a prototype.
 He feeds the prototype to a computer system to
automatically produce a report about:
 backtesting (in-sample and out-sample)
 computing the properties, e.g., expected P&L, max
drawdown, using simulation,
 calibrating parameters,
 analyzing sensitivity,
 When he is happy with the report, he can trade the
model live.
Building Blocks
6
 Moving average crossover, Acar & Satchell 2002
 Bull/bear market probabilities, Dai 2011
 Cointegration
 Pairs trading model calibration, Elliott 2005
 Mean reverting portfolio construction, d'Aspremont
2008
 Mean-variance portfolio optimization, Lai 2009
 Cone optimization of portfolio
 Factor models
 Many more……
Creating Strategy Like Building LEGO©
7
moving average crossover
portfolio optimization
cointegration
stoploss
Reality
8
 Clean data
 Align time stamps
 Read Gigabytes of data
 Retuers’ EURUSD, tick-by-tick, is 1G/day
 Extract relevant information
 PE, BM
 Handle missing data
 Incorporate events, news and announcements
 Code up the quant. strategy
 Code up the simulation
 Bid-ask spread
 Slippage
 Execution assumptions
 Wait a very long time for the simulation to
complete
 Recalibrate parameters and simulate again
 Wait a very long time for the simulation to
complete
 Recalibrate parameters and simulate again
 Wait a very long time for the simulation to
complete
 Debug
 Debug again
 Debug more
 Debug even more
 Debug patiently
 Debug impatiently
 Debug frustratingly
 Debug furiously
 Give up
 Start to trade
Research Tools – Very Primitive
9
 Excel
 MATLAB/ R/ other scripting languages…
 MetaTrader/ Trade Station
 RTS/ other automated trading systems…
R/ Scripting Languages Advantages
10
 Most people already know it.
 There are more people who know Java/C#/C++/C than
Matlab, R, etc., combined.
 It has a huge collection of math functions for math
modeling and analysis.
 Math libraries are also available in SuanShu (Java), NMath
(C#), Boost (C++), and Netlib (C).
R Disadvantages
11
 TOO MANY!
Some R Disadvantages
12
 Way too slow
 Must interpret the code line-by-line
 Limited memory
 How to read and process gigabytes of tick-by-tick data
 Limited parallelization
 Cannot calibrate/simulate a strategy in many scenarios in parallel
 Inconvenient editing
 No usage, rename, auto import, auto-completion
 Primitive debugging tools
 No conditional breakpoint, disable, thread switch and resume
 Obsolete C-like language
 No interface, inheritance; how to define 𝑓 𝑥 ?
R’s Biggest Disadvantage
13
 You cannot be sure your code is right!
Productivity
14
Research Tools As Weapon in Trading Warfare
15
bare hand star trader Excel R/MATLAB
MT/TS AlgoQuant
A Good Trading Research Toolbox (1)
 Allow easy strategy coding
 Allow plug-and-play multiple strategies
 Simulate using historical data
 Simulate using fake, artificial data
 Allow controlled experiments
 e.g., bid/ask, execution assumptions, news
16
A Good Trading Research Toolbox (2)
 Generate standard and user customized statistics
 Have information other than prices
 e.g., macro data, news and announcements
 Auto parameter calibration
 Sensitivity analysis
 Quick
17
Free the Trader!
18
debugging
programming
data cleaning
data extracting
waiting
calibrating
backtesting
Basic Math Programming in Java
19
Downloads
 JDK
 http://docs.oracle.com/javase/tutorial/
 NetBeans
 AlgoQuant
 http://www.numericalmethod.com/trac/numericalmethod
/wiki/AlgoQuant
20
Procedural Programming
21
 The program is a series of computational steps to be
carried out.
 The order of execution is linear from the first
statement to the second and so forth
 with occasional loops and branches.
Debugging and Testing
22
 F8/F7
 JUnit
Object-Oriented Programming
23
 Represent “Concepts” as “Objects”.
 Objects have
 data fields,
 methods to handle the data fields.
 Inheritance: a hierarchical relationships among
objects.
MovingStatistic
MovingWindow
MovingAverage MovingVolatility
Strategy Programming
24
Backtesting in AlgoQuant
25
1. Define a data source, e.g., the asset that you want to
trade.
2. Construct an instance of the strategy to be
backtested.
3. Create an order book.
4. Run the simulation.
5. Analysis the performance statistics.
Event-Driven Programming
26
 An object reacts to the events that it listens to.
 E.g., prices but not volumes.
 A trading strategy code is a set of event handlers that
 update the internal states,
 send orders to the (mock) market.
EVENT
Strategy Programming
27
 GMA(2,1)
Backtesting
28
 Historical data
 Bootstrapped data
 Simulated data

More Related Content

Similar to Programming Quantitative Trading Strategies

20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
20 Simple Questions from Exactpro for Your Enjoyment This Holiday SeasonIosif Itkin
 
Algo trading with machine learning ppt
Algo trading with machine learning pptAlgo trading with machine learning ppt
Algo trading with machine learning pptDeb prakash ganguly
 
GDG DEvFest Hellas 2020 - Automated ML - Panagiotis Papaemmanouil
GDG DEvFest Hellas 2020 -  Automated ML - Panagiotis PapaemmanouilGDG DEvFest Hellas 2020 -  Automated ML - Panagiotis Papaemmanouil
GDG DEvFest Hellas 2020 - Automated ML - Panagiotis PapaemmanouilPanagiotis Papaemmanouil
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical EngineersManish Joshi
 
How to Improve Data Labels and Feedback Loops Through High-Frequency Sensor A...
How to Improve Data Labels and Feedback Loops Through High-Frequency Sensor A...How to Improve Data Labels and Feedback Loops Through High-Frequency Sensor A...
How to Improve Data Labels and Feedback Loops Through High-Frequency Sensor A...InfluxData
 
So You Want to Write an Exporter
So You Want to Write an ExporterSo You Want to Write an Exporter
So You Want to Write an ExporterBrian Brazil
 
How to analyze text data for AI and ML with Named Entity Recognition
How to analyze text data for AI and ML with Named Entity RecognitionHow to analyze text data for AI and ML with Named Entity Recognition
How to analyze text data for AI and ML with Named Entity RecognitionSkyl.ai
 
Intel Robotics AI Use Case
Intel Robotics AI Use CaseIntel Robotics AI Use Case
Intel Robotics AI Use CaseMary Bunzel
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.pptINAM352782
 
MEL_WOLINSKY_20170124
MEL_WOLINSKY_20170124MEL_WOLINSKY_20170124
MEL_WOLINSKY_20170124Mel Wolinsky
 
ITCamp 2018 - Andrea Martorana Tusa - Failure prediction for manufacturing in...
ITCamp 2018 - Andrea Martorana Tusa - Failure prediction for manufacturing in...ITCamp 2018 - Andrea Martorana Tusa - Failure prediction for manufacturing in...
ITCamp 2018 - Andrea Martorana Tusa - Failure prediction for manufacturing in...ITCamp
 
How we built NoCRM - Piotr Karwatka, CTO of Divante
How we built NoCRM - Piotr Karwatka, CTO of DivanteHow we built NoCRM - Piotr Karwatka, CTO of Divante
How we built NoCRM - Piotr Karwatka, CTO of DivanteDataconomy Media
 
NoCRM - BigData Amsterdam 4.0
NoCRM - BigData Amsterdam 4.0NoCRM - BigData Amsterdam 4.0
NoCRM - BigData Amsterdam 4.0Divante
 
Analytics what to look for sustaining your growing business-
Analytics   what to look for sustaining your growing business-Analytics   what to look for sustaining your growing business-
Analytics what to look for sustaining your growing business-Ajay Ohri
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010Skills Matter
 

Similar to Programming Quantitative Trading Strategies (20)

20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
 
Algorithmic trading
Algorithmic tradingAlgorithmic trading
Algorithmic trading
 
Algo trading with machine learning ppt
Algo trading with machine learning pptAlgo trading with machine learning ppt
Algo trading with machine learning ppt
 
GDG DEvFest Hellas 2020 - Automated ML - Panagiotis Papaemmanouil
GDG DEvFest Hellas 2020 -  Automated ML - Panagiotis PapaemmanouilGDG DEvFest Hellas 2020 -  Automated ML - Panagiotis Papaemmanouil
GDG DEvFest Hellas 2020 - Automated ML - Panagiotis Papaemmanouil
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical Engineers
 
Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Beekman5 std ppt_13
 
Amit Bhandari
Amit BhandariAmit Bhandari
Amit Bhandari
 
How to Improve Data Labels and Feedback Loops Through High-Frequency Sensor A...
How to Improve Data Labels and Feedback Loops Through High-Frequency Sensor A...How to Improve Data Labels and Feedback Loops Through High-Frequency Sensor A...
How to Improve Data Labels and Feedback Loops Through High-Frequency Sensor A...
 
So You Want to Write an Exporter
So You Want to Write an ExporterSo You Want to Write an Exporter
So You Want to Write an Exporter
 
How to analyze text data for AI and ML with Named Entity Recognition
How to analyze text data for AI and ML with Named Entity RecognitionHow to analyze text data for AI and ML with Named Entity Recognition
How to analyze text data for AI and ML with Named Entity Recognition
 
Intel Robotics AI Use Case
Intel Robotics AI Use CaseIntel Robotics AI Use Case
Intel Robotics AI Use Case
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
 
Bachelor in-computer-application
Bachelor in-computer-applicationBachelor in-computer-application
Bachelor in-computer-application
 
MEL_WOLINSKY_20170124
MEL_WOLINSKY_20170124MEL_WOLINSKY_20170124
MEL_WOLINSKY_20170124
 
LSESU a Taste of R Language Workshop
LSESU a Taste of R Language WorkshopLSESU a Taste of R Language Workshop
LSESU a Taste of R Language Workshop
 
ITCamp 2018 - Andrea Martorana Tusa - Failure prediction for manufacturing in...
ITCamp 2018 - Andrea Martorana Tusa - Failure prediction for manufacturing in...ITCamp 2018 - Andrea Martorana Tusa - Failure prediction for manufacturing in...
ITCamp 2018 - Andrea Martorana Tusa - Failure prediction for manufacturing in...
 
How we built NoCRM - Piotr Karwatka, CTO of Divante
How we built NoCRM - Piotr Karwatka, CTO of DivanteHow we built NoCRM - Piotr Karwatka, CTO of Divante
How we built NoCRM - Piotr Karwatka, CTO of Divante
 
NoCRM - BigData Amsterdam 4.0
NoCRM - BigData Amsterdam 4.0NoCRM - BigData Amsterdam 4.0
NoCRM - BigData Amsterdam 4.0
 
Analytics what to look for sustaining your growing business-
Analytics   what to look for sustaining your growing business-Analytics   what to look for sustaining your growing business-
Analytics what to look for sustaining your growing business-
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010
 

More from Adrian Aley

Intro to Quant Trading Strategies (Lecture 10 of 10)
Intro to Quant Trading Strategies (Lecture 10 of 10)Intro to Quant Trading Strategies (Lecture 10 of 10)
Intro to Quant Trading Strategies (Lecture 10 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 9 of 10)
Intro to Quant Trading Strategies (Lecture 9 of 10)Intro to Quant Trading Strategies (Lecture 9 of 10)
Intro to Quant Trading Strategies (Lecture 9 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 8 of 10)
Intro to Quant Trading Strategies (Lecture 8 of 10)Intro to Quant Trading Strategies (Lecture 8 of 10)
Intro to Quant Trading Strategies (Lecture 8 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 7 of 10)
Intro to Quant Trading Strategies (Lecture 7 of 10)Intro to Quant Trading Strategies (Lecture 7 of 10)
Intro to Quant Trading Strategies (Lecture 7 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 6 of 10)
Intro to Quant Trading Strategies (Lecture 6 of 10)Intro to Quant Trading Strategies (Lecture 6 of 10)
Intro to Quant Trading Strategies (Lecture 6 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 5 of 10)
Intro to Quant Trading Strategies (Lecture 5 of 10)Intro to Quant Trading Strategies (Lecture 5 of 10)
Intro to Quant Trading Strategies (Lecture 5 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 4 of 10)
Intro to Quant Trading Strategies (Lecture 4 of 10)Intro to Quant Trading Strategies (Lecture 4 of 10)
Intro to Quant Trading Strategies (Lecture 4 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 3 of 10)
Intro to Quant Trading Strategies (Lecture 3 of 10)Intro to Quant Trading Strategies (Lecture 3 of 10)
Intro to Quant Trading Strategies (Lecture 3 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 2 of 10)
Intro to Quant Trading Strategies (Lecture 2 of 10)Intro to Quant Trading Strategies (Lecture 2 of 10)
Intro to Quant Trading Strategies (Lecture 2 of 10)Adrian Aley
 
Intro to Quant Trading Strategies (Lecture 1 of 10)
Intro to Quant Trading Strategies (Lecture 1 of 10)Intro to Quant Trading Strategies (Lecture 1 of 10)
Intro to Quant Trading Strategies (Lecture 1 of 10)Adrian Aley
 
Intro to Quantitative Investment (Lecture 6 of 6)
Intro to Quantitative Investment (Lecture 6 of 6)Intro to Quantitative Investment (Lecture 6 of 6)
Intro to Quantitative Investment (Lecture 6 of 6)Adrian Aley
 
Intro to Quantitative Investment (Lecture 5 of 6)
Intro to Quantitative Investment (Lecture 5 of 6)Intro to Quantitative Investment (Lecture 5 of 6)
Intro to Quantitative Investment (Lecture 5 of 6)Adrian Aley
 
Intro to Quantitative Investment (Lecture 4 of 6)
Intro to Quantitative Investment (Lecture 4 of 6)Intro to Quantitative Investment (Lecture 4 of 6)
Intro to Quantitative Investment (Lecture 4 of 6)Adrian Aley
 
Intro to Quantitative Investment (Lecture 3 of 6)
Intro to Quantitative Investment (Lecture 3 of 6)Intro to Quantitative Investment (Lecture 3 of 6)
Intro to Quantitative Investment (Lecture 3 of 6)Adrian Aley
 
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
 

More from Adrian Aley (15)

Intro to Quant Trading Strategies (Lecture 10 of 10)
Intro to Quant Trading Strategies (Lecture 10 of 10)Intro to Quant Trading Strategies (Lecture 10 of 10)
Intro to Quant Trading Strategies (Lecture 10 of 10)
 
Intro to Quant Trading Strategies (Lecture 9 of 10)
Intro to Quant Trading Strategies (Lecture 9 of 10)Intro to Quant Trading Strategies (Lecture 9 of 10)
Intro to Quant Trading Strategies (Lecture 9 of 10)
 
Intro to Quant Trading Strategies (Lecture 8 of 10)
Intro to Quant Trading Strategies (Lecture 8 of 10)Intro to Quant Trading Strategies (Lecture 8 of 10)
Intro to Quant Trading Strategies (Lecture 8 of 10)
 
Intro to Quant Trading Strategies (Lecture 7 of 10)
Intro to Quant Trading Strategies (Lecture 7 of 10)Intro to Quant Trading Strategies (Lecture 7 of 10)
Intro to Quant Trading Strategies (Lecture 7 of 10)
 
Intro to Quant Trading Strategies (Lecture 6 of 10)
Intro to Quant Trading Strategies (Lecture 6 of 10)Intro to Quant Trading Strategies (Lecture 6 of 10)
Intro to Quant Trading Strategies (Lecture 6 of 10)
 
Intro to Quant Trading Strategies (Lecture 5 of 10)
Intro to Quant Trading Strategies (Lecture 5 of 10)Intro to Quant Trading Strategies (Lecture 5 of 10)
Intro to Quant Trading Strategies (Lecture 5 of 10)
 
Intro to Quant Trading Strategies (Lecture 4 of 10)
Intro to Quant Trading Strategies (Lecture 4 of 10)Intro to Quant Trading Strategies (Lecture 4 of 10)
Intro to Quant Trading Strategies (Lecture 4 of 10)
 
Intro to Quant Trading Strategies (Lecture 3 of 10)
Intro to Quant Trading Strategies (Lecture 3 of 10)Intro to Quant Trading Strategies (Lecture 3 of 10)
Intro to Quant Trading Strategies (Lecture 3 of 10)
 
Intro to Quant Trading Strategies (Lecture 2 of 10)
Intro to Quant Trading Strategies (Lecture 2 of 10)Intro to Quant Trading Strategies (Lecture 2 of 10)
Intro to Quant Trading Strategies (Lecture 2 of 10)
 
Intro to Quant Trading Strategies (Lecture 1 of 10)
Intro to Quant Trading Strategies (Lecture 1 of 10)Intro to Quant Trading Strategies (Lecture 1 of 10)
Intro to Quant Trading Strategies (Lecture 1 of 10)
 
Intro to Quantitative Investment (Lecture 6 of 6)
Intro to Quantitative Investment (Lecture 6 of 6)Intro to Quantitative Investment (Lecture 6 of 6)
Intro to Quantitative Investment (Lecture 6 of 6)
 
Intro to Quantitative Investment (Lecture 5 of 6)
Intro to Quantitative Investment (Lecture 5 of 6)Intro to Quantitative Investment (Lecture 5 of 6)
Intro to Quantitative Investment (Lecture 5 of 6)
 
Intro to Quantitative Investment (Lecture 4 of 6)
Intro to Quantitative Investment (Lecture 4 of 6)Intro to Quantitative Investment (Lecture 4 of 6)
Intro to Quantitative Investment (Lecture 4 of 6)
 
Intro to Quantitative Investment (Lecture 3 of 6)
Intro to Quantitative Investment (Lecture 3 of 6)Intro to Quantitative Investment (Lecture 3 of 6)
Intro to Quantitative Investment (Lecture 3 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)
Intro to Quantitative Investment (Lecture 1 of 6)
 

Recently uploaded

20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdfAdnet Communications
 
Russian Call Girls In Gtb Nagar (Delhi) 9711199012 💋✔💕😘 Naughty Call Girls Se...
Russian Call Girls In Gtb Nagar (Delhi) 9711199012 💋✔💕😘 Naughty Call Girls Se...Russian Call Girls In Gtb Nagar (Delhi) 9711199012 💋✔💕😘 Naughty Call Girls Se...
Russian Call Girls In Gtb Nagar (Delhi) 9711199012 💋✔💕😘 Naughty Call Girls Se...shivangimorya083
 
Q3 2024 Earnings Conference Call and Webcast Slides
Q3 2024 Earnings Conference Call and Webcast SlidesQ3 2024 Earnings Conference Call and Webcast Slides
Q3 2024 Earnings Conference Call and Webcast SlidesMarketing847413
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Roomdivyansh0kumar0
 
(TANVI) Call Girls Nanded City ( 7001035870 ) HI-Fi Pune Escorts Service
(TANVI) Call Girls Nanded City ( 7001035870 ) HI-Fi Pune Escorts Service(TANVI) Call Girls Nanded City ( 7001035870 ) HI-Fi Pune Escorts Service
(TANVI) Call Girls Nanded City ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls In Yusuf Sarai Women Seeking Men 9654467111
Call Girls In Yusuf Sarai Women Seeking Men 9654467111Call Girls In Yusuf Sarai Women Seeking Men 9654467111
Call Girls In Yusuf Sarai Women Seeking Men 9654467111Sapana Sha
 
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130Suhani Kapoor
 
Independent Lucknow Call Girls 8923113531WhatsApp Lucknow Call Girls make you...
Independent Lucknow Call Girls 8923113531WhatsApp Lucknow Call Girls make you...Independent Lucknow Call Girls 8923113531WhatsApp Lucknow Call Girls make you...
Independent Lucknow Call Girls 8923113531WhatsApp Lucknow Call Girls make you...makika9823
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...Call Girls in Nagpur High Profile
 
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsHigh Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(ANIKA) Budhwar Peth Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANIKA) Budhwar Peth Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANIKA) Budhwar Peth Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANIKA) Budhwar Peth Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Lundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfLundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfAdnet Communications
 
Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spiritegoetzinger
 
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779Delhi Call girls
 
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Pooja Nehwal
 
Monthly Market Risk Update: April 2024 [SlideShare]
Monthly Market Risk Update: April 2024 [SlideShare]Monthly Market Risk Update: April 2024 [SlideShare]
Monthly Market Risk Update: April 2024 [SlideShare]Commonwealth
 
Log your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignLog your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignHenry Tapper
 
Bladex Earnings Call Presentation 1Q2024
Bladex Earnings Call Presentation 1Q2024Bladex Earnings Call Presentation 1Q2024
Bladex Earnings Call Presentation 1Q2024Bladex
 
New dynamic economic model with a digital footprint | European Business Review
New dynamic economic model with a digital footprint | European Business ReviewNew dynamic economic model with a digital footprint | European Business Review
New dynamic economic model with a digital footprint | European Business ReviewAntonis Zairis
 

Recently uploaded (20)

20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf
 
Russian Call Girls In Gtb Nagar (Delhi) 9711199012 💋✔💕😘 Naughty Call Girls Se...
Russian Call Girls In Gtb Nagar (Delhi) 9711199012 💋✔💕😘 Naughty Call Girls Se...Russian Call Girls In Gtb Nagar (Delhi) 9711199012 💋✔💕😘 Naughty Call Girls Se...
Russian Call Girls In Gtb Nagar (Delhi) 9711199012 💋✔💕😘 Naughty Call Girls Se...
 
Q3 2024 Earnings Conference Call and Webcast Slides
Q3 2024 Earnings Conference Call and Webcast SlidesQ3 2024 Earnings Conference Call and Webcast Slides
Q3 2024 Earnings Conference Call and Webcast Slides
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
 
(TANVI) Call Girls Nanded City ( 7001035870 ) HI-Fi Pune Escorts Service
(TANVI) Call Girls Nanded City ( 7001035870 ) HI-Fi Pune Escorts Service(TANVI) Call Girls Nanded City ( 7001035870 ) HI-Fi Pune Escorts Service
(TANVI) Call Girls Nanded City ( 7001035870 ) HI-Fi Pune Escorts Service
 
Call Girls In Yusuf Sarai Women Seeking Men 9654467111
Call Girls In Yusuf Sarai Women Seeking Men 9654467111Call Girls In Yusuf Sarai Women Seeking Men 9654467111
Call Girls In Yusuf Sarai Women Seeking Men 9654467111
 
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
VIP Call Girls Service Dilsukhnagar Hyderabad Call +91-8250192130
 
Independent Lucknow Call Girls 8923113531WhatsApp Lucknow Call Girls make you...
Independent Lucknow Call Girls 8923113531WhatsApp Lucknow Call Girls make you...Independent Lucknow Call Girls 8923113531WhatsApp Lucknow Call Girls make you...
Independent Lucknow Call Girls 8923113531WhatsApp Lucknow Call Girls make you...
 
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
VVIP Pune Call Girls Katraj (7001035870) Pune Escorts Nearby with Complete Sa...
 
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsHigh Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
(ANIKA) Budhwar Peth Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANIKA) Budhwar Peth Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANIKA) Budhwar Peth Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANIKA) Budhwar Peth Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Lundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfLundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdf
 
Instant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School SpiritInstant Issue Debit Cards - High School Spirit
Instant Issue Debit Cards - High School Spirit
 
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
Best VIP Call Girls Noida Sector 18 Call Me: 8448380779
 
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
Independent Call Girl Number in Kurla Mumbai📲 Pooja Nehwal 9892124323 💞 Full ...
 
Monthly Market Risk Update: April 2024 [SlideShare]
Monthly Market Risk Update: April 2024 [SlideShare]Monthly Market Risk Update: April 2024 [SlideShare]
Monthly Market Risk Update: April 2024 [SlideShare]
 
Log your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignLog your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaign
 
Bladex Earnings Call Presentation 1Q2024
Bladex Earnings Call Presentation 1Q2024Bladex Earnings Call Presentation 1Q2024
Bladex Earnings Call Presentation 1Q2024
 
New dynamic economic model with a digital footprint | European Business Review
New dynamic economic model with a digital footprint | European Business ReviewNew dynamic economic model with a digital footprint | European Business Review
New dynamic economic model with a digital footprint | European Business Review
 
Veritas Interim Report 1 January–31 March 2024
Veritas Interim Report 1 January–31 March 2024Veritas Interim Report 1 January–31 March 2024
Veritas Interim Report 1 January–31 March 2024
 

Programming Quantitative Trading Strategies

  • 1. Programming and Backtesting Quantitative Trading Strategies AlgoQuant – A Quantitative Trading Research Toolbox Haksun Li haksun.li@numericalmethod.com www.numericalmethod.com
  • 2. Speaker Profile  Dr. Haksun Li  CEO, Numerical Method Inc.  (Ex-)Adjunct Professors, Industry Fellow, Advisor, Consultant with the National University of Singapore, Nanyang Technological University, Fudan University, the Hong Kong University of Science and Technology.  Quantitative Trader/Analyst, BNPP, UBS  PhD, Computer Sci, University of Michigan Ann Arbor  M.S., Financial Mathematics, University of Chicago  B.S., Mathematics, University of Chicago 2
  • 3. The Role of Technology in Quantitative Trading 3
  • 4. Step 2 - Coding 4  After modeling, we code up the quantitative trading strategy for  backtesting (in-sample and out-sample),  computing the properties, e.g., expected P&L, max drawdown, using simulation,  calibrating parameters,  analyzing sensitivity,  trading live.
  • 5. Ideal 5  A trader dreams of a trading idea.  He can quickly code it up to produce a prototype.  He feeds the prototype to a computer system to automatically produce a report about:  backtesting (in-sample and out-sample)  computing the properties, e.g., expected P&L, max drawdown, using simulation,  calibrating parameters,  analyzing sensitivity,  When he is happy with the report, he can trade the model live.
  • 6. Building Blocks 6  Moving average crossover, Acar & Satchell 2002  Bull/bear market probabilities, Dai 2011  Cointegration  Pairs trading model calibration, Elliott 2005  Mean reverting portfolio construction, d'Aspremont 2008  Mean-variance portfolio optimization, Lai 2009  Cone optimization of portfolio  Factor models  Many more……
  • 7. Creating Strategy Like Building LEGO© 7 moving average crossover portfolio optimization cointegration stoploss
  • 8. Reality 8  Clean data  Align time stamps  Read Gigabytes of data  Retuers’ EURUSD, tick-by-tick, is 1G/day  Extract relevant information  PE, BM  Handle missing data  Incorporate events, news and announcements  Code up the quant. strategy  Code up the simulation  Bid-ask spread  Slippage  Execution assumptions  Wait a very long time for the simulation to complete  Recalibrate parameters and simulate again  Wait a very long time for the simulation to complete  Recalibrate parameters and simulate again  Wait a very long time for the simulation to complete  Debug  Debug again  Debug more  Debug even more  Debug patiently  Debug impatiently  Debug frustratingly  Debug furiously  Give up  Start to trade
  • 9. Research Tools – Very Primitive 9  Excel  MATLAB/ R/ other scripting languages…  MetaTrader/ Trade Station  RTS/ other automated trading systems…
  • 10. R/ Scripting Languages Advantages 10  Most people already know it.  There are more people who know Java/C#/C++/C than Matlab, R, etc., combined.  It has a huge collection of math functions for math modeling and analysis.  Math libraries are also available in SuanShu (Java), NMath (C#), Boost (C++), and Netlib (C).
  • 12. Some R Disadvantages 12  Way too slow  Must interpret the code line-by-line  Limited memory  How to read and process gigabytes of tick-by-tick data  Limited parallelization  Cannot calibrate/simulate a strategy in many scenarios in parallel  Inconvenient editing  No usage, rename, auto import, auto-completion  Primitive debugging tools  No conditional breakpoint, disable, thread switch and resume  Obsolete C-like language  No interface, inheritance; how to define 𝑓 𝑥 ?
  • 13. R’s Biggest Disadvantage 13  You cannot be sure your code is right!
  • 15. Research Tools As Weapon in Trading Warfare 15 bare hand star trader Excel R/MATLAB MT/TS AlgoQuant
  • 16. A Good Trading Research Toolbox (1)  Allow easy strategy coding  Allow plug-and-play multiple strategies  Simulate using historical data  Simulate using fake, artificial data  Allow controlled experiments  e.g., bid/ask, execution assumptions, news 16
  • 17. A Good Trading Research Toolbox (2)  Generate standard and user customized statistics  Have information other than prices  e.g., macro data, news and announcements  Auto parameter calibration  Sensitivity analysis  Quick 17
  • 18. Free the Trader! 18 debugging programming data cleaning data extracting waiting calibrating backtesting
  • 20. Downloads  JDK  http://docs.oracle.com/javase/tutorial/  NetBeans  AlgoQuant  http://www.numericalmethod.com/trac/numericalmethod /wiki/AlgoQuant 20
  • 21. Procedural Programming 21  The program is a series of computational steps to be carried out.  The order of execution is linear from the first statement to the second and so forth  with occasional loops and branches.
  • 22. Debugging and Testing 22  F8/F7  JUnit
  • 23. Object-Oriented Programming 23  Represent “Concepts” as “Objects”.  Objects have  data fields,  methods to handle the data fields.  Inheritance: a hierarchical relationships among objects. MovingStatistic MovingWindow MovingAverage MovingVolatility
  • 25. Backtesting in AlgoQuant 25 1. Define a data source, e.g., the asset that you want to trade. 2. Construct an instance of the strategy to be backtested. 3. Create an order book. 4. Run the simulation. 5. Analysis the performance statistics.
  • 26. Event-Driven Programming 26  An object reacts to the events that it listens to.  E.g., prices but not volumes.  A trading strategy code is a set of event handlers that  update the internal states,  send orders to the (mock) market. EVENT
  • 28. Backtesting 28  Historical data  Bootstrapped data  Simulated data