SlideShare a Scribd company logo
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 Intro to Quantitative Investment (Lecture 2 of 6)

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
Iosif Itkin
 
Algorithmic trading
Algorithmic tradingAlgorithmic trading
Algorithmic trading
Jayadeep Govindu
 
Algo trading with machine learning ppt
Algo trading with machine learning pptAlgo trading with machine learning ppt
Algo trading with machine learning ppt
Deb 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 Papaemmanouil
Panagiotis Papaemmanouil
 
Matlab for Electrical Engineers
Matlab for Electrical EngineersMatlab for Electrical Engineers
Matlab for Electrical Engineers
Manish Joshi
 
Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Amit Bhandari
Amit BhandariAmit Bhandari
Amit 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...
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 Exporter
Brian 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 Recognition
Skyl.ai
 
Intel Robotics AI Use Case
Intel Robotics AI Use CaseIntel Robotics AI Use Case
Intel Robotics AI Use Case
Mary Bunzel
 
AOA Week 01.ppt
AOA Week 01.pptAOA Week 01.ppt
AOA Week 01.ppt
INAM352782
 
Bachelor in-computer-application
Bachelor in-computer-applicationBachelor in-computer-application
Bachelor in-computer-application
mahatmagandhiuniversity
 
MEL_WOLINSKY_20170124
MEL_WOLINSKY_20170124MEL_WOLINSKY_20170124
MEL_WOLINSKY_20170124
Mel Wolinsky
 
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
Korkrid Akepanidtaworn
 
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 Divante
Dataconomy Media
 
NoCRM - BigData Amsterdam 4.0
NoCRM - BigData Amsterdam 4.0NoCRM - BigData Amsterdam 4.0
NoCRM - BigData Amsterdam 4.0
Divante
 
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/2010
Skills Matter
 

Similar to Intro to Quantitative Investment (Lecture 2 of 6) (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

Importance of community participation in development projects.pdf
Importance of community participation in development projects.pdfImportance of community participation in development projects.pdf
Importance of community participation in development projects.pdf
krisretro1
 
What's a worker’s market? Job quality and labour market tightness
What's a worker’s market? Job quality and labour market tightnessWhat's a worker’s market? Job quality and labour market tightness
What's a worker’s market? Job quality and labour market tightness
Labour Market Information Council | Conseil de l’information sur le marché du travail
 
Independent Study - College of Wooster Research (2023-2024)
Independent Study - College of Wooster Research (2023-2024)Independent Study - College of Wooster Research (2023-2024)
Independent Study - College of Wooster Research (2023-2024)
AntoniaOwensDetwiler
 
International Sustainability Standards Board
International Sustainability Standards BoardInternational Sustainability Standards Board
International Sustainability Standards Board
Kumar Ramaiah
 
TEST BANK Principles of cost accounting 17th edition edward j vanderbeck mari...
TEST BANK Principles of cost accounting 17th edition edward j vanderbeck mari...TEST BANK Principles of cost accounting 17th edition edward j vanderbeck mari...
TEST BANK Principles of cost accounting 17th edition edward j vanderbeck mari...
Donc Test
 
一比一原版宾夕法尼亚大学毕业证(UPenn毕业证书)学历如何办理
一比一原版宾夕法尼亚大学毕业证(UPenn毕业证书)学历如何办理一比一原版宾夕法尼亚大学毕业证(UPenn毕业证书)学历如何办理
一比一原版宾夕法尼亚大学毕业证(UPenn毕业证书)学历如何办理
vpqasyb
 
Seeman_Fiintouch_LLP_Newsletter_Jun_2024.pdf
Seeman_Fiintouch_LLP_Newsletter_Jun_2024.pdfSeeman_Fiintouch_LLP_Newsletter_Jun_2024.pdf
Seeman_Fiintouch_LLP_Newsletter_Jun_2024.pdf
Ashis Kumar Dey
 
Governor Olli Rehn: Inflation down and recovery supported by interest rate cu...
Governor Olli Rehn: Inflation down and recovery supported by interest rate cu...Governor Olli Rehn: Inflation down and recovery supported by interest rate cu...
Governor Olli Rehn: Inflation down and recovery supported by interest rate cu...
Suomen Pankki
 
Ending stagnation: How to boost prosperity across Scotland
Ending stagnation: How to boost prosperity across ScotlandEnding stagnation: How to boost prosperity across Scotland
Ending stagnation: How to boost prosperity across Scotland
ResolutionFoundation
 
falcon-invoice-discounting-a-premier-investment-platform-for-superior-returns...
falcon-invoice-discounting-a-premier-investment-platform-for-superior-returns...falcon-invoice-discounting-a-premier-investment-platform-for-superior-returns...
falcon-invoice-discounting-a-premier-investment-platform-for-superior-returns...
Falcon Invoice Discounting
 
Does teamwork really matter? Looking beyond the job posting to understand lab...
Does teamwork really matter? Looking beyond the job posting to understand lab...Does teamwork really matter? Looking beyond the job posting to understand lab...
Does teamwork really matter? Looking beyond the job posting to understand lab...
Labour Market Information Council | Conseil de l’information sur le marché du travail
 
1比1复刻(ksu毕业证书)美国堪萨斯州立大学毕业证本科文凭证书原版一模一样
1比1复刻(ksu毕业证书)美国堪萨斯州立大学毕业证本科文凭证书原版一模一样1比1复刻(ksu毕业证书)美国堪萨斯州立大学毕业证本科文凭证书原版一模一样
1比1复刻(ksu毕业证书)美国堪萨斯州立大学毕业证本科文凭证书原版一模一样
28xo7hf
 
Who Is Abhay Bhutada, MD of Poonawalla Fincorp
Who Is Abhay Bhutada, MD of Poonawalla FincorpWho Is Abhay Bhutada, MD of Poonawalla Fincorp
Who Is Abhay Bhutada, MD of Poonawalla Fincorp
beulahfernandes8
 
New Visa Rules for Tourists and Students in Thailand | Amit Kakkar Easy Visa
New Visa Rules for Tourists and Students in Thailand | Amit Kakkar Easy VisaNew Visa Rules for Tourists and Students in Thailand | Amit Kakkar Easy Visa
New Visa Rules for Tourists and Students in Thailand | Amit Kakkar Easy Visa
Amit Kakkar
 
Bridging the gap: Online job postings, survey data and the assessment of job ...
Bridging the gap: Online job postings, survey data and the assessment of job ...Bridging the gap: Online job postings, survey data and the assessment of job ...
Bridging the gap: Online job postings, survey data and the assessment of job ...
Labour Market Information Council | Conseil de l’information sur le marché du travail
 
Economic Risk Factor Update: June 2024 [SlideShare]
Economic Risk Factor Update: June 2024 [SlideShare]Economic Risk Factor Update: June 2024 [SlideShare]
Economic Risk Factor Update: June 2024 [SlideShare]
Commonwealth
 
Fabular Frames and the Four Ratio Problem
Fabular Frames and the Four Ratio ProblemFabular Frames and the Four Ratio Problem
Fabular Frames and the Four Ratio Problem
Majid Iqbal
 
Dr. Alyce Su Cover Story - China's Investment Leader
Dr. Alyce Su Cover Story - China's Investment LeaderDr. Alyce Su Cover Story - China's Investment Leader
Dr. Alyce Su Cover Story - China's Investment Leader
msthrill
 
The Impact of Generative AI and 4th Industrial Revolution
The Impact of Generative AI and 4th Industrial RevolutionThe Impact of Generative AI and 4th Industrial Revolution
The Impact of Generative AI and 4th Industrial Revolution
Paolo Maresca
 
The Rise and Fall of Ponzi Schemes in America.pptx
The Rise and Fall of Ponzi Schemes in America.pptxThe Rise and Fall of Ponzi Schemes in America.pptx
The Rise and Fall of Ponzi Schemes in America.pptx
Diana Rose
 

Recently uploaded (20)

Importance of community participation in development projects.pdf
Importance of community participation in development projects.pdfImportance of community participation in development projects.pdf
Importance of community participation in development projects.pdf
 
What's a worker’s market? Job quality and labour market tightness
What's a worker’s market? Job quality and labour market tightnessWhat's a worker’s market? Job quality and labour market tightness
What's a worker’s market? Job quality and labour market tightness
 
Independent Study - College of Wooster Research (2023-2024)
Independent Study - College of Wooster Research (2023-2024)Independent Study - College of Wooster Research (2023-2024)
Independent Study - College of Wooster Research (2023-2024)
 
International Sustainability Standards Board
International Sustainability Standards BoardInternational Sustainability Standards Board
International Sustainability Standards Board
 
TEST BANK Principles of cost accounting 17th edition edward j vanderbeck mari...
TEST BANK Principles of cost accounting 17th edition edward j vanderbeck mari...TEST BANK Principles of cost accounting 17th edition edward j vanderbeck mari...
TEST BANK Principles of cost accounting 17th edition edward j vanderbeck mari...
 
一比一原版宾夕法尼亚大学毕业证(UPenn毕业证书)学历如何办理
一比一原版宾夕法尼亚大学毕业证(UPenn毕业证书)学历如何办理一比一原版宾夕法尼亚大学毕业证(UPenn毕业证书)学历如何办理
一比一原版宾夕法尼亚大学毕业证(UPenn毕业证书)学历如何办理
 
Seeman_Fiintouch_LLP_Newsletter_Jun_2024.pdf
Seeman_Fiintouch_LLP_Newsletter_Jun_2024.pdfSeeman_Fiintouch_LLP_Newsletter_Jun_2024.pdf
Seeman_Fiintouch_LLP_Newsletter_Jun_2024.pdf
 
Governor Olli Rehn: Inflation down and recovery supported by interest rate cu...
Governor Olli Rehn: Inflation down and recovery supported by interest rate cu...Governor Olli Rehn: Inflation down and recovery supported by interest rate cu...
Governor Olli Rehn: Inflation down and recovery supported by interest rate cu...
 
Ending stagnation: How to boost prosperity across Scotland
Ending stagnation: How to boost prosperity across ScotlandEnding stagnation: How to boost prosperity across Scotland
Ending stagnation: How to boost prosperity across Scotland
 
falcon-invoice-discounting-a-premier-investment-platform-for-superior-returns...
falcon-invoice-discounting-a-premier-investment-platform-for-superior-returns...falcon-invoice-discounting-a-premier-investment-platform-for-superior-returns...
falcon-invoice-discounting-a-premier-investment-platform-for-superior-returns...
 
Does teamwork really matter? Looking beyond the job posting to understand lab...
Does teamwork really matter? Looking beyond the job posting to understand lab...Does teamwork really matter? Looking beyond the job posting to understand lab...
Does teamwork really matter? Looking beyond the job posting to understand lab...
 
1比1复刻(ksu毕业证书)美国堪萨斯州立大学毕业证本科文凭证书原版一模一样
1比1复刻(ksu毕业证书)美国堪萨斯州立大学毕业证本科文凭证书原版一模一样1比1复刻(ksu毕业证书)美国堪萨斯州立大学毕业证本科文凭证书原版一模一样
1比1复刻(ksu毕业证书)美国堪萨斯州立大学毕业证本科文凭证书原版一模一样
 
Who Is Abhay Bhutada, MD of Poonawalla Fincorp
Who Is Abhay Bhutada, MD of Poonawalla FincorpWho Is Abhay Bhutada, MD of Poonawalla Fincorp
Who Is Abhay Bhutada, MD of Poonawalla Fincorp
 
New Visa Rules for Tourists and Students in Thailand | Amit Kakkar Easy Visa
New Visa Rules for Tourists and Students in Thailand | Amit Kakkar Easy VisaNew Visa Rules for Tourists and Students in Thailand | Amit Kakkar Easy Visa
New Visa Rules for Tourists and Students in Thailand | Amit Kakkar Easy Visa
 
Bridging the gap: Online job postings, survey data and the assessment of job ...
Bridging the gap: Online job postings, survey data and the assessment of job ...Bridging the gap: Online job postings, survey data and the assessment of job ...
Bridging the gap: Online job postings, survey data and the assessment of job ...
 
Economic Risk Factor Update: June 2024 [SlideShare]
Economic Risk Factor Update: June 2024 [SlideShare]Economic Risk Factor Update: June 2024 [SlideShare]
Economic Risk Factor Update: June 2024 [SlideShare]
 
Fabular Frames and the Four Ratio Problem
Fabular Frames and the Four Ratio ProblemFabular Frames and the Four Ratio Problem
Fabular Frames and the Four Ratio Problem
 
Dr. Alyce Su Cover Story - China's Investment Leader
Dr. Alyce Su Cover Story - China's Investment LeaderDr. Alyce Su Cover Story - China's Investment Leader
Dr. Alyce Su Cover Story - China's Investment Leader
 
The Impact of Generative AI and 4th Industrial Revolution
The Impact of Generative AI and 4th Industrial RevolutionThe Impact of Generative AI and 4th Industrial Revolution
The Impact of Generative AI and 4th Industrial Revolution
 
The Rise and Fall of Ponzi Schemes in America.pptx
The Rise and Fall of Ponzi Schemes in America.pptxThe Rise and Fall of Ponzi Schemes in America.pptx
The Rise and Fall of Ponzi Schemes in America.pptx
 

Intro to Quantitative Investment (Lecture 2 of 6)

  • 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