Introduction to Algorithmic Trading Strategies Lecture 1...
Transcript of Introduction to Algorithmic Trading Strategies Lecture 1...
![Page 1: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/1.jpg)
Introduction to Algorithmic Trading Strategies Lecture 1
Technical Analysis: A Scientific Perspective
Haksun Li [email protected]
www.numericalmethod.com
![Page 2: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/2.jpg)
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
![Page 3: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/3.jpg)
Numerical Method Incorporation Limited
3
A consulting firm in mathematical modeling, esp. algorithmic trading and quantitative investment.
Products: SuanShu: a modern math or numerical library AlgoQuant: a financial technology for quantitative trading
Customers: brokerage houses and funds multinational corporations very high net worth individuals gambling groups academic institutions
![Page 4: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/4.jpg)
References Emmanual Acar, Stephen Satchell. Chapters 4, 5 & 6,
Advanced Trading Rules, Second Edition. Butterworth-Heinemann; 2nd edition. June 19, 2002.
Andrew W. Lo , Mark T. Mueller. Warning: Physics Envy May be Hazardous to Your Wealth! 2010
Algorithmic Trading: Hidden Markov Models on Foreign Exchange Data. Patrik Idvall, Conny Jonsson. University essay from Linköpings universitet/Matematiska institutionen; Linköpings universitet/Matematiska institutionen. 2008.
A tutorial on hidden Markov models and selected applications in speech recognition. Rabiner, L.R. Proceedings of the IEEE, vol 77 Issue 2, Feb 1989.
4
![Page 5: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/5.jpg)
What is Quantitative Trading?
5
![Page 6: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/6.jpg)
Quantitative Trading?
6
Quantitative trading is the buying and selling of assets following the instructions computed from a set of proven mathematical models.
The differentiation from other trading approaches or the emphasis is on how a strategy is generated and not on what strategy is created.
It applies (rigorous) mathematics in all steps during trading strategy construction from the start to the end.
![Page 7: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/7.jpg)
Moving Average Crossover as a TA
7
A popular TA signal: Moving Average Crossover. A crossover occurs when a faster moving average (i.e. a
shorter period moving average) crosses above/below a slower moving average (i.e. a longer period moving average); then you buy/sell.
In most TA book, it is then illustrated with an example of applying the strategy to a stock for a period of time to show the profits.
![Page 8: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/8.jpg)
Technical Analysis is Not Quantitative Trading
8
TA books merely describes the mechanics of strategies but seldom/never prove them.
Appealing to common sense is not a mathematical proof.
Conditional probabilities of outcomes are never computed. (Lo, Mamaysky, & Wang, 2000)
Application of TA is more of an art (is it?) than a science. How do you choose the parameters?
![Page 9: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/9.jpg)
Fake Quantitative Models Data snooping Misuse of mathematics Assumptions cannot be quantified No model validation against the current regime Ad-hoc take profit and stop-loss why 2?
How do you know when the model is invalidated? Cannot explain winning and losing trades Cannot be analyzed (systematically)
9
![Page 10: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/10.jpg)
NM Quantitative Trading Research Process
10
1. Translate a vague trading intuition (hypothesis) into a concrete mathematical model.
2. Translate the mathematical symbols and equations into a computer program.
3. Strategy evaluation. 4. Live execution for making money.
![Page 11: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/11.jpg)
Step 1 - Modeling
11
Where does a trading idea come from? Ex-colleagues Hearsays Newspapers, books NOW TV, e.g., Moving Average Crossover (MA)
A quantitative trading strategy is a math function, f, that at any given time, t, takes as inputs any information that the strategy cares and that is available, Ft, and gives as output the position to take, f(t,Ft).
![Page 12: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/12.jpg)
Step 2 - Coding
12
The computer code enables analysis of the strategy. Most study of a strategy cannot be done analytically. We must resort to simulation.
The same piece of code used for research and investigation should go straight into the production for live trading. Eliminate the possibility of research-to-IT translation
errors.
![Page 13: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/13.jpg)
Step 3 – Evaluation/Justification
13
Compute the properties of a trading strategy. the P&L distribution the holding time distribution the stop-loss the maximal drawdown
http://redmine.numericalmethod.com/projects/public/repository/svn-algoquant/show/core/src/main/java/com/numericalmethod/algoquant/execution/performance
![Page 14: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/14.jpg)
Step 4 - Trading
14
Put in capitals incrementally. Install safety measures. Monitor the performance. Regime change detection.
![Page 15: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/15.jpg)
The Basics
15
![Page 16: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/16.jpg)
Quantitative Trading Strategy
16
positions = 𝑓 𝑡,ℱ𝑡 ℱ𝑡: filtration, the current information set. E.g., 𝑓 𝑡,𝑉𝑡 ,𝑥𝑡 ,
t: current time 𝑉𝑡: current portfolio value 𝑥𝑡: current price
![Page 17: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/17.jpg)
Probability Space
17
A probability space is specified by Ω,ℱ,𝑃 . Ω: the set of outcomes.
Ω = 𝐻,𝑇 , as in a coin toss ℱ: the set of events. An event is a set of zero of more outcomes.
An event is considered to have "happened" during an experiment when the outcome of the latter is an element of the event. Since the same outcome may be a member of many events, it is possible for many events to have happened given a single outcome. ℱ = 𝜙,𝐻,𝑇,Ω
P: the probabilities of events, satisfying 𝑃 𝑤 ≥ 0 ∑𝑃 𝑤 = 𝑃 Ω = 1 Often it is sufficient to specify the probabilities of outcomes to
define the function.
![Page 18: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/18.jpg)
Filtration (1)
18
We flip a fair coin two times.
Sample space, outcomes: Ω =
𝜔1 = 𝐻,𝐻 ,𝜔2 = 𝐻,𝑇 ,𝜔3 = 𝑇,𝐻 ,𝜔4 = 𝑇,𝑇
![Page 19: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/19.jpg)
Filtration (2)
19
Σ-algebra, events or information available: ℱ0 = 𝜙,Ω
ℱ1 = 𝜙,Ω,𝐴 = 𝜔1 = 𝐻,𝐻 ,𝜔2 = 𝐻,𝑇 , �̅� = 𝜔3 = 𝑇,𝐻 ,
𝜔4 = 𝑇,𝑇
Outcomes of the 2nd toss:
𝐵 = 𝜔1 = 𝐻,𝐻 ,𝜔3 = 𝑇,𝐻 ,𝐵� = 𝜔2 = 𝐻,𝑇 ,
𝜔4 = 𝑇,𝑇
ℱ2 = 2Ω, σ-field generated by 𝐴, 𝐴, 𝐵, 𝐵� . This set contains 16 events.
ℱ0 ⊂ ℱ1 ⊂ ℱ2 is the filtration generated by the coin flip process of two tosses.
![Page 20: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/20.jpg)
Random Variable and Process
20
Random variable, 𝑋:Ω → 𝐸 Assign a numeric value to each of the possible outcomes
(not events). Random process: 𝑋𝑡 A collection of random variables indexed by time.
![Page 21: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/21.jpg)
The Problem
21
A short term security valuation problem. A regime identification problem to verify if the market
is still in the regime assumed by our valuation. That is, are the model’s assumptions valid in live trading.
![Page 22: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/22.jpg)
Risk vs. Uncertainty - Easy
22
1. Complete Certainty: all past and future states of the system are determined exactly if initial conditions are fixed and known-nothing is uncertain.
1. A coin with both sides being H. 2. Risk without Uncertainty: no statistical inference is
needed, because we know the relevant probability distributions exactly, and while we do not know the outcome of any given wager, we know all the rules and the odds, and no other information relevant to the outcome is hidden.
1. A fair coin.
![Page 23: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/23.jpg)
Risk vs. Uncertainty - Challenging
23
Fully Reducible Uncertainty: situations in which randomness can be rendered arbitrarily close to Level-2 uncertainty with sufficiently large amounts of data using the tools of statistical analysis. An unfair coin.
Partially Reducible Uncertainty: situations in which there is a limit to what we can deduce about the underlying phenomena the data. Stochastic or time-varying parameters that vary too
frequently to be estimated accurately. A bag of many different unfair coins.
Complex non-linearities. The dependencies on the unknowable.
![Page 24: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/24.jpg)
Risk vs. Uncertainty – Divinity!
24
Irreducible Uncertainty: this type of uncertainty is the domain of philosophers and religious leaders, who focus on not only the unknown, but [also] the unknowable. Is there God who plays dice with the quantum coin, say,
spin-½. Zen Uncertainty: attempts to understand uncertainty,
are mere illusions; there is only suffering.
![Page 25: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/25.jpg)
Information Ratio
25
IR = IC * √Breadth IR: information ratio IC: information coefficient, e.g., correlation between forecasts
and actuals Breadth: number of independent bets
For the same IR, we can be less accurate if we can trade more, e.g., intra-day trading. Monthly vs. Daily
ICM * √BM = ICD * √BD ICD = ICM * √BM / √BD = ICM / 5
Daily vs. hourly ICD * √BD = ICH * √BH ICH = ICD * √BD / √BH = ICM / 2.45
Excellent IC: 0.05
![Page 26: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/26.jpg)
Returns
26
Real return = 𝑠1 = 𝑃1−𝑃0𝑃0
= 𝑃1𝑃0− 1
Log return = 𝑟1 = log 𝑃1𝑃0
= log𝑃1 − log𝑃0
Time additive: the compound return for n period = 𝑟1 + ⋯+ 𝑟𝑛 = log 𝑃𝑛
𝑃0
Normality: in quantitative finance, we often assume the prices are log-normally distributed to avoid the violation of limited liability. Normality is preserved under addition, hence return
compounding. Total return is also normal.
Good approximation to real return: 𝑟 = log 1 + 𝑠 ≈ 𝑠
![Page 27: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/27.jpg)
The Quantitative Trading Research Process
27
![Page 28: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/28.jpg)
Moving Average Crossover as a Quantitative Trading Strategy
28
There are many mathematical justifications to Moving Average Crossover. weighted Sum of lags of a time series Kuo, 2002
Whether a strategy is quantitative or not depends not on the strategy itself but entirely on the process to construct it; or, whether there is a scientific justification to prove it.
![Page 29: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/29.jpg)
Step 2 - Modeling Two moving averages: slower (𝑛) and faster (𝑚). Monitor the crossovers.
𝐵𝑡 = 1𝑚∑ 𝑃𝑡−𝑗𝑚−1𝑗=0 − 1
𝑛∑ 𝑃𝑡−𝑗𝑛−1𝑗=0 , 𝑛 > 𝑚
Long when 𝐵𝑡 ≥ 0. Short when 𝐵𝑡 < 0.
![Page 30: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/30.jpg)
How to Choose 𝑛 and 𝑚? It is an art, not a science (so far). They should be related to the length of market cycles. Different assets have different 𝑛 and 𝑚. Popular choices: (250, 5) (250 , 20) (20 , 5) (20 , 1) (250 , 1)
![Page 31: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/31.jpg)
Two Simplifications
31
Reduce the two dimensional problem to a one dimensional problem.
Replace arithmetic averages with geometric averages. This is so that we can work with log returns rather than
prices.
![Page 32: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/32.jpg)
AMA(n , 1)
𝐵𝑡 ≥ 0 iff 𝑃𝑡 ≥1𝑛∑ 𝑃𝑡−𝑗𝑛−1𝑗=0
𝐵𝑡 < 0 iff 𝑃𝑡 < 1𝑛∑ 𝑃𝑡−𝑗𝑛−1𝑗=0
![Page 33: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/33.jpg)
GMA(n , 1)
𝐵𝑡 ≥ 0 iff 𝑃𝑡 ≥ ∏ 𝑃𝑡−𝑗𝑛−1𝑗=0
1𝑛
𝑅𝑡 ≥ −∑ 𝑛− 𝑗+1𝑛−1
𝑅𝑡−𝑗𝑛−2𝑗=1 (by taking log)
𝐵𝑡 < 0 iff 𝑃𝑡 < ∏ 𝑃𝑡−𝑗𝑛−1𝑗=0
1𝑛
𝑅𝑡 < −∑ 𝑛− 𝑗+1𝑛−1
𝑅𝑡−𝑗𝑛−2𝑗=1 (by taking log)
![Page 34: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/34.jpg)
What is 𝑛? 𝑛 = 2 𝑛 = ∞
![Page 35: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/35.jpg)
Acar Framework Acar (1993): to investigate the probability distribution
of realized returns from a trading rule, we need the explicit specification of the trading rule the underlying stochastic process for asset returns the particular return concept involved
![Page 36: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/36.jpg)
Empirical Properties of Financial Time Series Asymmetry Fat tails
![Page 37: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/37.jpg)
Knight-Satchell-Tran Intuition Stock returns staying going up (down) depends on the realizations of positive (negative) shocks the persistence of these shocks
Shocks are modeled by gamma processes. Persistence is modeled by a Markov switching process.
![Page 38: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/38.jpg)
Knight-Satchell-Tran 𝑍𝑡
Zt = 0 DOWN TREND
𝑓𝛿 𝑥
=𝜆2
𝛼2𝑥𝛼2−1
Γ 𝛼2𝑒−𝜆2𝑥
Zt = 1 UP TREND 𝑓𝜀 𝑥
=𝜆1
𝛼1𝑥𝛼1−1
Γ 𝛼1𝑒−𝜆1𝑥
q p
1-q
1-p
![Page 39: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/39.jpg)
Knight-Satchell-Tran Process 𝑅𝑡 = 𝜇𝑙 + 𝑍𝑡𝜀𝑡 − 1 − 𝑍𝑡 𝛿𝑡 𝜇𝑙: long term mean of returns, e.g., 0 𝜀𝑡, 𝛿𝑡: positive and negative shocks, non-negative, i.i.d
𝑓𝜀 𝑥 = 𝜆1𝛼1𝑥𝛼1−1
Γ 𝛼1𝑒−𝜆1𝑥
𝑓𝛿 𝑥 = 𝜆2𝛼2𝑥𝛼2−1
Γ 𝛼2𝑒−𝜆2𝑥
![Page 40: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/40.jpg)
Estimation of Parameters
40
Zt = 0 DOWN TREND 𝑓𝛿 𝑥 =?
Zt = 1 UP TREND
𝑓𝜀 𝑥 =?
? ?
?
?
![Page 41: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/41.jpg)
Markov Property Given the current information available at time
𝑡 − 1 , the history, e.g., path, is irrelevant. 𝑃 𝑞𝑡|𝑞𝑡−1,⋯ , 𝑞1 = 𝑃 𝑞𝑡|𝑞𝑡−1 Consistent with the weak form of the efficient market
hypothesis.
41
![Page 42: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/42.jpg)
Hidden Markov Chain Only observations are observable (duh). World states may not be known (hidden). We want to model the hidden states as a Markov Chain.
Two assumptions: Markov property 𝑃 𝜔𝑡|𝑞𝑡−1,⋯ , 𝑞1,𝜔𝑡−1,⋯ ,𝜔1 = 𝑃 𝜔𝑡|𝑞𝑡
42
![Page 43: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/43.jpg)
Problems Likelihood Given the parameters, λ, and an observation sequence, Ω,
compute 𝑃 Ω|𝜆 . Decoding Given the parameters, λ, and an observation sequence, Ω,
determine the best hidden sequence Q. Learning Given an observation sequence, Ω, and HMM structure,
learn λ.
43
![Page 44: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/44.jpg)
Learning as a Maximization Problem Our objective is to find λ that maximizes 𝑃 Ω|𝜆 . For any given λ, we can compute 𝑃 Ω|𝜆 . Then solve a maximization problem. Algorithms: Nelder-Mead Baum-Welch (E-M algorithm)
44
![Page 45: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/45.jpg)
Stationary State
Π = 1−𝑞2−𝑝−𝑞
𝑅𝑡 = 𝜇𝑙 + 𝜀𝑡 ≥ 𝜇𝑙, with probability Π 𝑅𝑡 = 𝜇𝑙 − 𝛿𝑡 < 𝜇𝑙 , with probability 1 − Π
![Page 46: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/46.jpg)
Step 3 – Evaluation/Justification Assume the long term mean is 0, 𝜇𝑙 = 0. When 𝑛 = 2, 𝐵𝑡 ≥ 0 ≡ 𝑅𝑡 ≥ 0 ≡ 𝑍𝑡 = 1 𝐵𝑡 < 0 ≡ 𝑅𝑡 < 0 ≡ 𝑍𝑡 = 0
![Page 47: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/47.jpg)
GMA(2, 1) – Naïve MA Trading Rule Buy when the asset return in the present period is
positive. Sell when the asset return in the present period is
negative.
![Page 48: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/48.jpg)
Naïve MA Conditions The expected value of the positive shocks to asset
return >> the expected value of negative shocks. The positive shocks persistency >> that of negative
shocks.
![Page 49: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/49.jpg)
𝑇 Period Returns 𝑅𝑅𝑇 = ∑ 𝑅𝑡 × 𝐼 𝐵𝑡−1≥0
𝑇𝑡=1
Sell at this time point
𝑇
𝐵𝑇 < 0
0 1
hold
![Page 50: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/50.jpg)
Holding Time Distribution 𝑃 𝑁 = 𝑇 = 𝑃 𝐵𝑇 < 0,𝐵𝑇−1 ≥ 0, … ,𝐵1 ≥ 0,𝐵0 ≥ 0 = 𝑃 𝑍𝑇 = 0,𝑍𝑇−1 = 1, … ,𝑍1 = 1,𝑍0 = 1 = 𝑃 𝑍𝑇 = 0,𝑍𝑇−1 = 1, … ,𝑍1 = 1|𝑍0 = 1 𝑃 𝑍0 = 1
= �Π𝑝𝑇−1 1− 𝑝 , T ≥1
1 − Π, T=0
![Page 51: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/51.jpg)
Conditional Returns Distribution (1)
Φ𝑅𝑅𝑇|𝑁=𝑇 𝑠 = E 𝑒 𝑖 ∑ 𝑅𝑡×𝐼 𝐵𝑡−1≥0𝑇𝑡=1 𝑠 |𝑁 = 𝑇
= E 𝑒 𝑖 ∑ 𝑅𝑡×𝐼 𝐵𝑡−1≥0𝑇𝑡=1 𝑠 |𝐵𝑇 < 0,𝐵𝑇−1 ≥ 0, … ,𝐵0 ≥ 0
= E 𝑒 𝑖 ∑ 𝑅𝑡𝑇𝑡=1 𝑠 |𝑍𝑇 = 0,𝑍𝑇−1 = 1, … ,𝑍1 = 1
= E 𝑒 𝑖 𝜀1+⋯+𝜀𝑇−1−𝛿𝑇 𝑠
= �Φ𝜀𝑇−1 𝑠 Φ𝛿 −𝑠 , T ≥1Φ𝛿 −𝑠 , T =0
![Page 52: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/52.jpg)
Unconditional Returns Distribution (2) Φ𝑅𝑅𝑇 𝑠 =
∑ E 𝑒 𝑖 ∑ 𝑅𝑡×𝐼 𝐵𝑡−1≥0𝑇𝑡=1 𝑠 |𝑁 = 𝑇 𝑃 𝑁 = 𝑇∞
𝑇=0 =∑ Π𝑝𝑇−1 1− 𝑝 Φ𝜀
𝑇−1 𝑠 Φ𝛿 −𝑠∞𝑇=1 + 1 − Π Φ𝛿 −𝑠
= 1 − Π Φ𝛿 −𝑠 + Π 1 − 𝑝 Φ𝛿 −𝑠1−𝑝Φ𝜀 𝑠
![Page 53: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/53.jpg)
Long-Only Returns Distribution
Φ𝑅𝑅𝑇 𝑠|𝑅0 ≥ 0 = 1−𝑝 Φ𝛿 −𝑠1−𝑝Φ𝜀 𝑠
Proof: make 𝑃 𝑍0 = 1 = Π = 1
![Page 54: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/54.jpg)
Expected Returns E 𝑅𝑅𝑇 = −𝑖Φ𝑅𝑅𝑇
′ 0
= 11−𝑝
Π𝑝𝜇𝜀 − 1 − 𝑝 𝜇𝛿
When is the expected return positive? 𝜇𝜀 ≥
1−𝑝Π𝑝
𝜇𝛿, shock impact
𝜇𝜀 ≫ 𝜇𝛿 , shock impact Π𝑝 ≥ 1 − 𝑝, if 𝜇𝜀 ≈ 𝜇𝛿 , persistence
![Page 55: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/55.jpg)
GMA(∞,1) Rule
𝑃𝑡 ≥ ∏ 𝑃𝑡−𝑗𝑛−1𝑗=0
1𝑛
ln𝑃𝑡 ≥1𝑛∑ ln𝑃𝑡−𝑗𝑛−1𝑗=0
ln𝑃𝑡 ≥ 𝜇1
![Page 56: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/56.jpg)
GMA(∞,1) Expected Returns Φ𝑅𝑅𝑇 𝑠 =
1 − Π 𝑞 Φ𝛿 𝑠 + Φ𝛿 −𝑠 +1 − 𝑝 1 − Π Φ𝜀 𝑠 + Φ𝜀 −𝑠
E 𝑅𝑅𝑇 = − 1 − 𝑝 1 − Π 𝜇𝜀 + 𝜇𝛿
![Page 57: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/57.jpg)
MA Using the Whole History An investor will always expect to lose money using
GMA(∞,1)! An investor loses the least amount of money when the
return process is a random walk.
![Page 58: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/58.jpg)
Optimal MA Parameters So, what are the optimal 𝑛 and 𝑚?
![Page 59: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/59.jpg)
A Mathematical Analysis of Linear Technical Indicators
59
![Page 60: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/60.jpg)
Linear Technical Indicators As we shall see, a number of linear technical
indicators, including the Moving Average Crossover, are really the “same” generalized indicator using different parameters.
![Page 61: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/61.jpg)
The Generalized Linear Trading Rule A linear predictor of weighted lagged returns 𝐹𝑡 = 𝛿 + ∑ 𝑑𝑗𝑋𝑡−𝑗𝑡
𝑗=0
The trading rule Long: 𝐵𝑡 = 1, iff, 𝐹𝑡 > 0 Short: 𝐵𝑡 = −1, iff, 𝐹𝑡 < 0
(Unrealized) rule returns 𝑅𝑡 = 𝐵𝑡−1𝑋𝑡
𝑅𝑡 = −𝑋𝑡 if 𝐵𝑡−1 = −1 𝑅𝑡 = +𝑋𝑡 if 𝐵𝑡−1 = +1
![Page 62: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/62.jpg)
Buy And Hold 𝐵𝑡 = 1
![Page 63: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/63.jpg)
Predictor Properties Linear Autoregressive Gaussian, assuming 𝑋𝑡 is Gaussian If the underlying returns process is linear, 𝐹𝑡 yields the
best forecasts in the mean squared error sense.
![Page 64: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/64.jpg)
Returns Variance Var 𝑅𝑡 = E 𝑅𝑡2 − E 𝑅𝑡 2
= E 𝐵𝑡−12𝑋𝑡2 − E 𝑅𝑡 2
= E 𝑋𝑡2 − E 𝑅𝑡 2 = 𝜎2 + 𝜇2 − E 𝑅𝑡 2
![Page 65: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/65.jpg)
Maximization Objective Variance of returns is inversely proportional to
expected returns. The more profitable the trading rule is, the less risky
this will be if risk is measured by volatility of the portfolio.
Maximizing returns will also maximize returns per unit of risk.
![Page 66: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/66.jpg)
Expected Returns E 𝑅𝑡 = E 𝐵𝑡−1𝑋𝑡 = E 𝐵𝑡−1 𝜇 + 𝜎𝑁 = 𝜎 E 𝐵𝑡−1𝑁 + 𝜇 E 𝐵𝑡−1 E 𝐵𝑡−1 = 1 × P 𝐹𝑡−1 > 0 + −1 × P 𝐹𝑡−1 < 0 = P 𝐹𝑡−1 > 0 − P 𝐹𝑡−1 < 0 = 1 − 2 × P 𝐹𝑡−1 < 0
= 1 − 2 × Φ −𝜇𝐹𝜎𝐹
![Page 67: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/67.jpg)
Truncated Bivariate Moments Johnston and Kotz, 1972, p.116
E 𝐵𝑡−1𝑁 = ∬ 𝑁𝐹𝑡>0−∬ 𝑁𝐹𝑡<0
= 2𝜋𝜌𝑒
− 𝜇𝐹2
2𝜎𝐹2
Correlation: 𝜌 = Corr 𝑋𝑡 ,𝐹𝑡−1
![Page 68: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/68.jpg)
Expected Returns As a Weighted Sum E 𝑅𝑡 = 𝜎 E 𝐵𝑡−1𝑁 + 𝜇 E 𝐵𝑡−1
= 𝜎 2𝜋𝜌𝑒
− 𝜇𝐹2
2𝜎𝐹2 + 𝜇 1 − 2 × Φ −𝜇𝐹𝜎𝐹
a term for volatility a term for drift
![Page 69: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/69.jpg)
Praetz model, 1976 Returns as a random walk with drift. E 𝑅𝑡 = 𝜇 1 − 2𝑓 , 𝑓 the frequency of short positions Var 𝑅𝑡 = 𝜎2
![Page 70: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/70.jpg)
Comparison with Praetz model
the probability of being short
increased variance
Random walk implies 𝜌 = Corr 𝑋𝑡 ,𝐹𝑡−1 = 0.
E 𝑅𝑡 = 𝜇 1− 2 × Φ −𝜇𝐹𝜎𝐹
Var 𝑅𝑡 = 𝜎2 + 𝜇2 − 𝜇 1 − 2 × Φ −𝜇𝐹𝜎𝐹
2
= 𝜎2 + 4𝜇2 Φ −𝜇𝐹𝜎𝐹
1 −Φ −𝜇𝐹𝜎𝐹
![Page 71: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/71.jpg)
Biased Forecast A biased (Gaussian) forecast may be suboptimal. Assume underlying mean 𝜇 = 0. Assume forecast mean 𝜇𝐹 ≠ 0.
E 𝑅𝑡 = 𝜎 2𝜋𝜌𝑒
− 𝜇𝐹2
2𝜎𝐹2 ≤ 𝜎 2𝜋𝜌
![Page 72: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/72.jpg)
Maximizing Returns Maximizing the correlation between forecast and one-
ahead return. First order condition:
𝜇𝐹𝜎𝐹
= 𝜇𝜎𝜎
![Page 73: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/73.jpg)
First Order Condition Let x = 𝜇𝐹
𝜎𝐹
E 𝑅𝑡 = 𝜎 2𝜋𝜌𝑒−
𝑥2
2 + 𝜇 1 − 2 × Φ −𝑥
𝑑 E 𝑅𝑡𝑑𝑥
= 0
𝜎 2𝜋𝜌 −𝑥 𝑒−
𝑥2 + 𝜇 2
𝜋𝑒−
𝑥2
2 = 0
𝑥 = 𝜇𝐹𝜎𝐹
= 𝜇𝜎𝜎
![Page 74: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/74.jpg)
Fitting vs. Prediction If 𝑋𝑡 process is Gaussian, no linear trading rule
obtained from a finite history of 𝑋𝑡 can generate expected returns over and above 𝐹𝑡.
Minimizing mean squared error ≠ maximizing P&L. In general, the relationship between MSE and P&L is
highly non-linear (Acar 1993).
![Page 75: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/75.jpg)
Technical Analysis Use a finite set of historical prices. Aim to maximize profit rather than to minimize mean
squared error. Claim to be able to capture complex non-linearity. Certain rules are ill-defined.
![Page 76: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/76.jpg)
Technical Linear Indicators For any technical indicator that generates signals from
a finite linear combination of past prices Sell: 𝐵𝑡 = −1 iff ∑ 𝑎𝑗𝑃𝑡−𝑗𝑚−1
𝑗=0 < 0
There exists an (almost) equivalent AR rule. Sell: 𝐵𝑡� = −1 iff δ + ∑ 𝑑𝑗𝑋𝑡−𝑗𝑚−2
𝑗=0 < 0
𝑋𝑡 = ln 𝑃𝑡𝑃𝑡−1
𝛿 = ∑ 𝑎𝑗𝑚−1𝑗=0 , 𝑑𝑗 = −∑ 𝑎𝑖𝑚−2
𝑖=𝑗
![Page 77: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/77.jpg)
Conversion Assumption
1 − 𝑃𝑡−𝑗𝑃𝑡
≈ ln 𝑃𝑡𝑃𝑡−𝑗
Monte Carlo simulation: 97% accurate 3% error.
![Page 78: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/78.jpg)
Example Linear Technical Indicators Simple order Simple MA Weighted MA Exponential MA Momentum Double orders Double MA
![Page 79: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/79.jpg)
Returns: Random Walk With Drift 𝑋𝑡 = 𝜇 + 𝜀𝑡 The bigger the order, the better. Momentum > SMAV > WMAV
How to estimate the future drift? Crystal ball? Delphic oracle?
![Page 80: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/80.jpg)
Results
![Page 81: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/81.jpg)
Results
![Page 82: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/82.jpg)
Returns: AR(1) 𝑋𝑡 = 𝛼𝑋𝑡−1 + 𝜀𝑡 Auto-correlation is required to be profitable. The smaller the order, the better. (quicker response)
![Page 83: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/83.jpg)
Results
![Page 84: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/84.jpg)
Returns: ARMA(1, 1) 𝑋𝑡 − 𝜇 − 𝑝 𝑋𝑡−1 − 𝜇 = 𝜀𝑡 − 𝑞𝜀𝑡−1 Prices tend to move in one direction (trend) for a
period of time and then change in a random and unpredictable fashion. Mean duration of trends: 𝑚𝑑 = 1
1−𝑝
Information has impacts on the returns in different days (lags). Returns correlation: 𝜌ℎ = 𝐴𝑝ℎ
AR MA
![Page 85: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/85.jpg)
Results
no systematic winner
optimal order
![Page 86: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/86.jpg)
Returns: ARIMA(0, d, 0) 𝛻𝑑 𝑋𝑡 − 𝜇 = 𝑒𝑡 Irregular, erratic, aperiodic cycles.
![Page 87: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/87.jpg)
Results
![Page 88: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/88.jpg)
Returns: ARCH(p)
𝑋𝑡 = 𝜇 + 𝛼0 + ∑ 𝛼𝑖 𝑋𝑡−𝑖 − 𝜇 2𝑝𝑖=1 𝜀𝑡
𝑋𝑡 − 𝜇 are the residuals When 𝜇 = 0, E 𝑅𝑡 = 0.
residual coefficients as a function of lagged squared
residuals
![Page 89: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/89.jpg)
Returns: AR(2) + GARCH(1,1) AR(2) GARCH(1,1)
innovations
ARCH(1): lagged squared residuals
lagged variance
𝑋𝑡 = 𝑎 + 𝑏1𝑋𝑡−1 + 𝑏2𝑋𝑡−2 + 𝜀𝑡 𝜀𝑡 = ℎ𝑡𝑧𝑡 ℎ𝑡 = 𝛼0 + 𝛼1𝜀𝑡−12 + 𝛽ℎ𝑡−1
![Page 90: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/90.jpg)
Results The presence of conditional heteroskedasticity will not
drastically affect returns generated by linear rules. The presence of conditional heteroskedasticity, if
unrelated to serial dependencies, may be neither a source of profits nor losses for linear rules.
![Page 91: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/91.jpg)
Playing Trend Following Strategies Trend following model requires positive (negative)
autocorrelation to be profitable. What do you do when there is zero autocorrelation?
Trend following models are profitable when there are drifts. How to estimate drifts?
It seems quicker response rules tend to work better. Weights should be given to the more recent data.
![Page 92: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/92.jpg)
Conclusions
92
![Page 93: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/93.jpg)
The Essential Skills
93
Financial intuitions, market understanding, creativity. Mathematics. Computer programming.
![Page 94: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/94.jpg)
An Emerging Field
94
It is a financial industry where mathematics and computer science meet.
It is an arms race to build more reliable and faster execution platforms (computer
sciences); more comprehensive and accurate prediction models
(mathematics). Structured products seem to be an evening industry
after the financial crisis. Could quantitative trading be another gold mine?
![Page 95: Introduction to Algorithmic Trading Strategies Lecture 1 …numericalmethod.com/papers/hkust2015/lecture1.pdf · 2015-10-07 · Introduction to Algorithmic Trading Strategies Lecture](https://reader034.fdocuments.in/reader034/viewer/2022042512/5f476fa4ece5210f334baf83/html5/thumbnails/95.jpg)
AlgoQuant Demo
95