+ All Categories
Home > Documents > Quantitative Trading as a Mathematical...

Quantitative Trading as a Mathematical...

Date post: 06-Oct-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
54
Quantitative Trading as a Mathematical Science QuantCon Singapore 2016 Haksun Li [email protected] www.numericalmethod.com
Transcript
Page 1: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Quantitative Trading as a Mathematical Science

QuantCon Singapore 2016

Haksun Li [email protected]

www.numericalmethod.com

Page 2: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Abstract

2

Quantitative trading is distinguishable from other trading methodologies like technical analysis and analystsโ€™ opinions because it uniquely provides justifications to trading strategies using mathematical reasoning. Put differently, quantitative trading is a science that trading strategies are proven statistically profitable or even optimal under certain assumptions. There are properties about strategies that we can deduce before betting the first $1, such as P&L distribution and risks. There are exact explanations to the success and failure of strategies, such as choice of parameters. There are ways to iteratively improve strategies based on experiences of live trading, such as making more realistic assumptions. These are all made possible only in quantitative trading because we have assumptions, models and rigorous mathematical analysis.

Quantitative trading has proved itself to be a significant driver of mathematical innovations, especially in the areas of stochastic analysis and PDE-theory. For instances, we can compute the optimal timings to follow the market by solving a pair of coupled Hamiltonโ€“Jacobiโ€“Bellman equations; we can construct sparse mean reverting baskets by solving semi-definite optimization problems with cardinality constraints and can optimally trade these baskets by solving stochastic control problems; we can identify statistical arbitrage opportunities by analyzing the volatility process of a stochastic asset at different frequencies; we can compute the optimal placements of market and limit orders by solving combined singular and impulse control problems which leads to novel and difficult to solve quasi-variational inequalities.

Page 3: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Speaker Profile Dr. Haksun Li CEO, NM LTD. (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 Ph.D., Computer Science, University of Michigan Ann

Arbor M.S., Financial Mathematics, University of Chicago B.S., Mathematics, University of Chicago

3

Page 4: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

What is Quantitative Trading?

4

Page 5: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Quantitative Trading?

5

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 methodologies or the emphasis is on how a strategy is proven and not on what strategy is created.

It applies (rigorous) mathematical reasoning in all steps during trading strategy construction from the start to the end.

Page 6: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Moving Average Crossover as a TA

6

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 never proven only illustrated with an example of applying the strategy to a stock for a period of time to show profits.

Page 7: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Technical Analysis is Not Quantitative Trading

7

TA books merely describes the mechanics of strategies but never prove them.

Appealing to common sense is not a mathematical proof.

Conditional probabilities of outcomes are seldom computed. (Lo, Mamaysky, & Wang, 2000)

Application of TA is more of an art (is it?) than a science. How do you choose the parameters?

For any TA rule, you almost surely can find an asset and a period that the rule โ€œworksโ€, given the large number of assets and many periods to choose from.

Page 8: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 a model is invalidated? Cannot explain winning and losing trades Cannot be analyzed (systematically)

8

Page 9: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

The Quantitative Trading Research Process

9

Page 10: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Step 1 - Modeling

11

Where does a trading idea come from? Ex-colleagues Hearsays Newspapers, books 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: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 14: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Step 4 - Trading

14

Put in capitals incrementally. Install safety measures. Monitor the performance. Regime change detection.

Page 15: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Mathematical Analysis of Moving Average Crossover

15

Page 16: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Moving Average Crossover as a Quantitative Trading Strategy

16

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 17: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Step 1 - Modeling Two moving averages: slower (๐‘›) and faster (๐‘š). Monitor the crossovers.

๐ต๐‘ก = 1๐‘šโˆ‘ ๐‘ƒ๐‘กโˆ’๐‘—๐‘šโˆ’1๐‘—=0 โˆ’ 1

๐‘›โˆ‘ ๐‘ƒ๐‘กโˆ’๐‘—๐‘›โˆ’1๐‘—=0 , ๐‘› > ๐‘š

Long when ๐ต๐‘ก โ‰ฅ 0. Short when ๐ต๐‘ก < 0.

Page 18: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 19: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Two Simplifications

19

Reduce the two dimensional problem to a one dimensional problem. Choose ๐‘š = 1. We know that m should be small.

Replace arithmetic averages with geometric averages. This is so that we can work with log returns rather than

prices.

Page 20: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 21: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

What is ๐‘›? ๐‘› = 2 ๐‘› = โˆž

Page 22: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 23: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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. Asymmetry Fat tails

Persistence is modeled by a Markov switching process.

Page 24: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 25: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 26: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Step 3 โ€“ Evaluation/Justification Assume the long term mean is 0, ๐œ‡๐‘™ = 0. When ๐‘› = 2, ๐ต๐‘ก โ‰ฅ 0 โ‰ก ๐‘…๐‘ก โ‰ฅ 0 โ‰ก ๐‘๐‘ก = 1 ๐ต๐‘ก < 0 โ‰ก ๐‘…๐‘ก < 0 โ‰ก ๐‘๐‘ก = 0

Page 27: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 28: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 29: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

๐‘‡ Period Returns ๐‘…๐‘…๐‘‡ = โˆ‘ ๐‘…๐‘ก ร— ๐ผ ๐ต๐‘กโˆ’1โ‰ฅ0

๐‘‡๐‘ก=1

Sell at this time point

๐‘‡

๐ต๐‘‡ < 0

0 1

hold

Page 30: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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

Stationary state probability: ฮ  = 1โˆ’๐‘ž

2โˆ’๐‘โˆ’๐‘ž

Page 31: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 32: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Unconditional Returns Distribution (2) ฮฆ๐‘…๐‘…๐‘‡ ๐‘  =

โˆ‘ E ๐‘’ ๐‘– โˆ‘ ๐‘…๐‘กร—๐ผ ๐ต๐‘กโˆ’1โ‰ฅ0๐‘‡๐‘ก=1 ๐‘  |๐‘ = ๐‘‡ ๐‘ƒ ๐‘ = ๐‘‡โˆž

๐‘‡=0 =โˆ‘ ฮ ๐‘๐‘‡โˆ’1 1 โˆ’ ๐‘ ฮฆ๐œ€

๐‘‡โˆ’1 ๐‘  ฮฆ๐›ฟ โˆ’๐‘ โˆž๐‘‡=1 + 1 โˆ’ ฮ  ฮฆ๐›ฟ โˆ’๐‘ 

= 1 โˆ’ ฮ  ฮฆ๐›ฟ โˆ’๐‘  + ฮ  1 โˆ’ ๐‘ ฮฆ๐›ฟ โˆ’๐‘ 1โˆ’๐‘ฮฆ๐œ€ ๐‘ 

Page 33: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Expected Returns E ๐‘…๐‘…๐‘‡ = โˆ’๐‘–ฮฆ๐‘…๐‘…๐‘‡

โ€ฒ 0

= 11โˆ’๐‘

ฮ ๐‘๐œ‡๐œ€ โˆ’ 1 โˆ’ ๐‘ ๐œ‡๐›ฟ

When is the expected return positive? ๐œ‡๐œ€ โ‰ฅ

1โˆ’๐‘ฮ ๐‘

๐œ‡๐›ฟ, shock impact

๐œ‡๐œ€ โ‰ซ ๐œ‡๐›ฟ, shock impact ฮ ๐‘ โ‰ฅ 1 โˆ’ ๐‘, if ๐œ‡๐œ€ โ‰ˆ ๐œ‡๐›ฟ, persistence

Page 34: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

GMA(โˆž,1) Rule

๐‘ƒ๐‘ก โ‰ฅ โˆ ๐‘ƒ๐‘กโˆ’๐‘—๐‘›โˆ’1๐‘—=0

1๐‘›

ln๐‘ƒ๐‘ก โ‰ฅ1๐‘›โˆ‘ ln๐‘ƒ๐‘กโˆ’๐‘—๐‘›โˆ’1๐‘—=0

ln๐‘ƒ๐‘ก โ‰ฅ ๐œ‡1

Page 35: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

GMA(โˆž,1) Expected Returns ฮฆ๐‘…๐‘…๐‘‡ ๐‘  =

1 โˆ’ ฮ  ๐‘ž ฮฆ๐›ฟ ๐‘  + ฮฆ๐›ฟ โˆ’๐‘  +1 โˆ’ ๐‘ 1 โˆ’ ฮ  ฮฆ๐œ€ ๐‘  + ฮฆ๐œ€ โˆ’๐‘ 

E ๐‘…๐‘…๐‘‡ = โˆ’ 1 โˆ’ ๐‘ 1 โˆ’ ฮ  ๐œ‡๐œ€ + ๐œ‡๐›ฟ

Page 36: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

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 37: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Optimal MA Parameters So, what are the optimal ๐‘› and ๐‘š?

Page 38: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Step 2: AR(1)

Page 39: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Step 2 : ARMA(1, 1)

no systematic winner

optimal order

Page 40: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Step 2 : ARIMA(0, d, 0)

Page 41: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Live Results of Quantitative Trading Strategies

41

Page 42: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Unique Guiding Principle What Others Do: Start with a trading strategy. Find the data that the

strategy works.

Result: Paper P&L looks good. Live P&L depends on luck.

Trading strategies are results of a non-scientific, a pure data snooping process.

What We Do: Start with simple assumptions

about the market. Compute the optimal trading

strategy given the assumptions.

Result: Can mathematically prove

that no other strategy will work better in the same market conditions.

Trading strategies are results of a scientific process.

42

Page 43: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Optimal Trend Following (TREND) We make assumptions that the market is a two (or

three) state model. The market state is either up, down, (or sideway).

In each state, we assume a random walk with positive, negative, or zero drift.

We use math to compute what the best thing to do is in each of the states.

We estimate the conditional probability, ๐‘, of that the market is going up given all the available information.

When ๐‘ is big enough, i.e., most certainly that the market is going up, we buy.

0.00%

20.00%

40.00%

60.00%

80.00%

100.00%

120.00%

140.00%

160.00%

trading period 2015/1/2 - 2016/5/2

assets traded Hang Seng china enterprises

index futures annualized return 107.00% max drawdown 6.61% Sharpe ratio 4.79

Result:

Page 44: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Optimal Trend Following (Math) Two state Markov model for a stockโ€™s prices: BULL and

BEAR.

๐‘‘๐‘†๐‘Ÿ = ๐‘†๐‘Ÿ ๐œ‡๐›ผ๐‘Ÿ๐‘‘๐‘‘ + ๐œŽ๐‘‘๐ต๐‘Ÿ , ๐‘ก โ‰ค ๐‘‘ โ‰ค ๐‘‡ < โˆž The trading period is between time ๐‘ก,๐‘‡ . ๐›ผ๐‘Ÿ = 1,2 are the two Markov states that indicates

the BULL and BEAR markets.

๐œ‡1 > 0

๐œ‡2 < 0

๐‘„ = โˆ’๐œ†1 ๐œ†1๐œ†2 โˆ’๐œ†2

, the generator matrix for the Markov

chain. When ๐‘– = 0, expected return is

E0,๐‘ก ๐‘…๐‘ก =

E๐‘ก ๐‘’๐œŒ ๐œ1โˆ’๐‘ก โˆ ๐‘†๐œˆ๐‘›๐‘†๐œ๐‘›

1โˆ’๐พ๐‘ 1+๐พ๐‘

๐ผ ๐œ๐‘›<๐‘‡๐‘’๐œŒ ๐œ๐‘›+1โˆ’๐œ๐‘›โˆž

๐‘›=1

We are long between ๐œ๐‘› and ๐œˆ๐‘› and the return is determined by the price change discounted by the commissions.

We are flat between ๐œˆ๐‘› and ๐œ๐‘›+1 and the money grows at the risk free rate.

Value function:

J0 ๐‘†,๐›ผ, ๐‘ก,ฮ›0 =

E๐‘ก๐œŒ ๐œ1 โˆ’ ๐‘ก +

โˆ‘ log ๐‘†๐œˆ๐‘›๐‘†๐œ๐‘›

+ ๐ผ ๐œ๐‘›<๐‘‡ log 1โˆ’๐พ๐‘ 1+๐พ๐‘

+ ๐œŒ ๐œ๐‘›+1 โˆ’ ๐œ๐‘›โˆž๐‘›=1

J1 ๐‘†,๐›ผ, ๐‘ก,ฮ›1 =

E๐‘กlog

๐‘†๐œˆ1๐‘†

+ ๐œŒ ๐œ2 โˆ’ ๐œˆ1 + log 1 โˆ’ ๐พ๐‘  +

โˆ‘ log ๐‘†๐œˆ๐‘›๐‘†๐œ๐‘›

+ ๐ผ ๐œ๐‘›<๐‘‡ log 1โˆ’๐พ๐‘ 1+๐พ๐‘

+ ๐œŒ ๐œ๐‘›+1 โˆ’ ๐œ๐‘›โˆž๐‘›=2

Find an optimal trading sequence (the stopping times) so that the value functions are maximized.

๐‘‰๐‘– ๐‘, ๐‘ก = supฮ›๐‘–

๐ฝ๐‘– ๐‘†, ๐‘, ๐‘ก,ฮ›๐‘–

๐‘‰๐‘–: the maximum amount of expected returns

๏ฟฝ๐‘‰0 ๐‘, ๐‘ก = sup

๐œ1๐ธ๐‘ก ๐œŒ ๐œ1 โˆ’ ๐‘ก โˆ’ log 1 + ๐พ๐‘ + ๐‘‰1 ๐‘๐œ1 , ๐œ1

๐‘‰1 ๐‘, ๐‘ก = sup๐œˆ1

๐ธ๐‘ก log๐‘†๐œˆ1๐‘†๐‘ก

+ log 1 โˆ’ ๐พ๐‘  + ๐‘‰0 ๐‘๐œˆ1 , ๐œˆ1

Hamilton-Jacobi-Bellman Equations

๏ฟฝmin โˆ’โ„’๐‘‰0 โˆ’ ๐œŒ,๐‘‰0 โˆ’ ๐‘‰1 + log 1 + ๐พ๐‘ = 0

min โˆ’โ„’๐‘‰1 โˆ’ ๐‘“ ๐œŒ ,๐‘‰1 โˆ’ ๐‘‰0 โˆ’ log 1 โˆ’ ๐พ๐‘  = 0

with terminal conditions: ๏ฟฝ ๐‘‰0 ๐‘,๐‘‡ = 0๐‘‰1 ๐‘,๐‘‡ = log 1 โˆ’ ๐พ๐‘ 

โ„’ = ๐œ•๐‘ก + 12

๐œ‡1โˆ’๐œ‡2 ๐‘ 1โˆ’๐‘๐œŽ

2๐œ•๐‘๐‘ + โˆ’ ๐œ†1 + ๐œ†2 ๐‘ + ๐œ†2 ๐œ•๐‘

Based on: M Dai, Q Zhang, QJ Zhu, "Trend following trading under a regime switching model," SIAM Journal on Financial Mathematics, 2010.

Page 45: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Optimal Mean Reversion (MR)

45

Basket construction problem: Select the right financial instruments. Obtain the optimal weights for the

selected financial instruments. Basket trading problem:

Given the portfolio can be modelled as a mean reverting OU process, dynamic spread trading is a stochastic optimal control problem.

Given a fixed amount of capital, dynamically allocate capital over a risky mean reverting portfolio and a risk-free asset over a finite time horizon to maximize a general constant relative risk aversion (CRRA) utility function of the terminal wealth .

Allocate capital amongst several mean reverting portfolios.

Based on: Mudchanatongsuk, S., Primbs, J.A., Wong, " Optimal Pairs Trading: A Stochastic Control Approach," Dept. of Manage. Sci. & Eng., Stanford Univ., CA.

Page 46: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Optimal Mean Reversion (Math)

46

Assume a risk free asset ๐‘€๐‘ก, which satisfies ๐‘‘๐‘€๐‘ก = ๐‘‘๐‘€๐‘ก๐‘‘๐‘ก

Assume two assets,๐ด๐‘ก and ๐ต๐‘ก. Assume ๐ต๐‘กfollows a geometric Brownian

motion. ๐‘‘๐ต๐‘ก = ๐œ‡๐ต๐‘ก๐‘‘๐‘ก + ๐œŽ๐ต๐‘ก๐‘‘๐‘ง๐‘ก

๐‘ฅ๐‘กis the spread between the two assets. ๐‘ฅ๐‘ก = log๐ด๐‘ก โˆ’ log๐ต๐‘ก

๐‘‘๐‘‰๐‘ก๐‘‰๐‘ก

= โ„Ž๐‘ก๐‘‘๐ด๐‘ก๐ด๐‘ก

+ โ„Ž๐‘ก๏ฟฝ๐‘‘๐ต๐‘ก๐ต๐‘ก

+ ๐‘‘๐‘€๐‘ก๐‘€๐‘ก

= โ„Ž๐‘ก ๐‘˜ ๐œƒ โˆ’ ๐‘ฅ๐‘ก + 12๐œ‚2 + ๐œŒ๐œ‚๐œŽ + ๐‘‘ ๐‘‘๐‘ก +

โ„Ž๐‘ก๐œ‚๐‘‘๐œ”๐‘ก max

โ„Ž๐‘ก๐ธ ๐‘‰๐‘‡๐›พ , s.t.,

๐‘‰ 0 = ๐‘ฃ0, x 0 = ๐‘ฅ0 ๐‘‘๐‘ฅ๐‘ก = ๐‘˜ ๐œƒ โˆ’ ๐‘ฅ๐‘ก ๐‘‘๐‘ก + ๐œ‚๐‘‘๐œ”๐‘ก ๐‘‘๐‘‰๐‘ก = โ„Ž๐‘ก๐‘‘๐‘ฅ๐‘ก = โ„Ž๐‘ก๐‘˜ ๐œƒ โˆ’ ๐‘ฅ๐‘ก ๐‘‘๐‘ก + โ„Ž๐‘ก๐œ‚๐‘‘๐œ”๐‘ก

โ„Ž ๐‘ก โˆ— = ๐‘‰๐‘ก1โˆ’๐›พ

โˆ’ ๐‘˜๐œ‚2

๐‘ฅ๐‘ก โˆ’ ๐œƒ + 2๐›ผ ๐‘ก ๐‘ฅ๐‘ก + ๐›ฝ ๐‘ก

covariance selection

Page 47: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Intraday Volatility Trading (VOL) In mid or high frequency trading, or

within a medium or short time interval, prices tend to oscillate.

If there are enough oscillations before prices move in a direction, arbitrage exists.

47

profit region

loss region

-20.00%

0.00%

20.00%

40.00%

60.00%

80.00%

100.00%

120.00%

140.00%

trading period 2014/2/27 - 2015/2/27

assets traded Hang Seng china enterprises

index futures annualized return 122.32% max drawdown 10.24% Sharpe ratio 18.45

Live Result:

Page 48: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Intraday Volatility Trading (Math) For a continuous price process ๐‘‹๐‘ก, we

define H-variation ๐‘‰๐‘‡ ๐ป,๐‘‹ = sup

๐‘‡โˆ‘ ๐‘‹ ๐‘ก๐‘™ โˆ’ ๐‘‹ ๐‘ก๐‘™โˆ’1๐ฟ๐‘™=1

It can be shown that for any H, there exists a sequence ๐œ๐‘›โˆ— , ๐œ๐‘› ๐‘›=0,1,โ€ฆ,๐‘ such that ๐œ๐‘› ๐‘›=0,1,โ€ฆ,๐‘ are Markovian and ๐œ๐‘›โˆ— are defined by ๐‘‹๐‘ก on intervals ๐œ๐‘›โˆ’1, ๐œ๐‘› . And they satisfy the equality: ๐‘‰๐‘‡ ๐ป,๐‘‹ = โˆ‘ ๐‘‹ ๐œ๐‘›โˆ— โˆ’ ๐‘‹ ๐œ๐‘›โˆ’1โˆ—๐‘

๐‘™=1

๐‘๐‘‡ ๐ป,๐‘‹ is the number of KAGI-inversion in the T-interval.

H-volatility:

๐œ‚๐‘‡ ๐ป,๐‘‹ = ๐‘‰๐‘‡ ๐ป,๐‘‹๐‘๐‘‡ ๐ป,๐‘‹

For an no-arbitrage Wiener process, we have lim

๐‘‡โ†’โˆž๐œ‚๐‘‡ ๐ป,๐œŽ๐œŽ = ๐พ๐ป = 2๐ป

Define a trading strategy such that the position of X is: ๐›พ๏ฟฝ๐‘ก๐พ ๐ป,๐‘‹ =

โˆ‘ sign ๐œ’ ๐œ๐‘›โˆ’1 โˆ’ ๐œ’ ๐œ๐‘›โˆ’1โˆ— ๐œ’ ๐œ๐‘›โˆ’1,๐œ๐‘› ๐‘ก๐‘๐‘‡ ๐ป,๐‘‹๐‘›=1

The trend following P&L is:

๐‘Œ๏ฟฝ๐‘ก๐พ ๐ป,๐‘‹ = โˆซ ๐›พ๏ฟฝ๐‘ข๐พ ๐ป,๐‘‹ ๐‘‘๐‘‹ ๐‘ข๐‘ก0

= ๐œ‚๐‘‡ ๐ป,๐‘‹ โˆ’ 2๐ป ๐‘๐‘‡ ๐ป,๐‘‹ + ๐œ€ The expected income per trade is:

๐‘Œ๐‘ก๐พ ๐ป,๐‘‹ = โˆซ ๐›พ๐‘ข๐พ ๐ป,๐‘‹ ๐‘‘๐‘‹ ๐‘ข๐‘ก0

๐‘ฆ๐‘ก๐พ ๐ป,๐‘‹ = ๐‘Œ๐‘ก๐พ ๐ป,๐‘‹๐‘๐‘ก๐พ ๐ป,๐‘‹

lim๐‘‡โ†’โˆž

E๐‘ฆ๐‘ก๐พ ๐ป,๐‘‹ = ๐พ โˆ’ 2 ๐ป

48

Based on: SV Pastukhov, "On some probabilistic-statistical methods in technical analysis," Theory of Probability & Its Applications, SIAM, 2005.

Page 49: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Optimal Market Making (MM) We optimally place limit and market

orders depending on the current inventory and spread.

49

the best market making strategy:

trading period 2015/7/16 - 2016/3/1

assets traded rebar + iron ore commodity

futures annualized return 65% max drawdown 0.90% Sharpe ratio 16.71

Live Result:

0.00%

5.00%

10.00%

15.00%

20.00%

25.00%

30.00%

35.00%

40.00%

Page 50: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Optimal Market Making (Math) State variable:

๐‘‹,๐‘Œ,๐‘ƒ, ๐‘† cash, inventory, mid price, spread

Objective:

max๐›ผ

E ๐‘ˆ ๐‘‹๐‘‡ โˆ’ ๐›พ โˆซ ๐‘” ๐‘Œ๐‘ก ๐‘‘๐‘ก๐‘‡0

๐‘Œ๐‘‡ = 0, e.g., donโ€™t hold position overnight ๐‘ˆ: utility function ๐‘‹๐‘‡: terminal wealth ๐›พ: penalty for holding inventory

Liquidation function (how much we get by selling everything):

๐ฟ ๐‘ฅ,๐‘ฆ,๐‘, ๐‘  = ๐‘ฅ โˆ’ ๐‘ โˆ’๐‘ฆ,๐‘, ๐‘  = ๐‘ฅ + ๐‘ฆ๐‘ โˆ’ ๐‘ฆ ๐‘ 2โˆ’ ๐œ€

Equivalent problem (get rid of ๐‘Œ๐‘‡ = 0):

max๐›ผ

E ๐‘ˆ ๐ฟ ๐‘‹๐‘‡ ,๐‘Œ๐‘‡ ,๐‘ƒ๐‘‡ , ๐‘†๐‘‡ โˆ’ ๐›พ โˆซ ๐‘” ๐‘Œ๐‘ก ๐‘‘๐‘ก๐‘‡0

Value function:

๐‘ฃ ๐‘ก, ๐‘ง, ๐‘  = sup๐›ผ E๐‘ก,๐‘ง,๐‘ 

๐‘ˆ ๐ฟ ๐‘๐‘‡ , ๐‘†๐‘‡ โˆ’ ๐›พ โˆซ ๐‘” ๐‘Œ๐‘ข ๐‘‘๐‘ข๐‘‡๐‘ก

๐‘ง = ๐‘ฅ,๐‘ฆ,๐‘

This is a mixed regular/impulse control problem in a regime switching jump-diffusion model.

Quasi-Variational Inequality

min โˆ’๐œ•๐œ•๐œ•๐‘กโˆ’ sup โ„’๐‘ž,๐‘™๐‘ฃ + ๐›พ๐‘”,๐‘ฃ โˆ’โ„ณ๐‘ฃ = 0

Terminal condition:

๐‘ฃ ๐‘‡, ๐‘ฅ, ๐‘ฆ,๐‘, ๐‘  = ๐‘ˆ ๐ฟ ๐‘ฅ,๐‘ฆ, ๐‘, ๐‘ 

For each state ๐‘–, we have

min

โˆ’๐œ•๐œ•๐‘–๐œ•๐‘กโˆ’ ๐’ซ๐‘ฃ๐‘– โˆ’ โˆ‘ ๐‘‘๐‘–๐‘— ๐‘ก ๐‘ฃ๐‘— ๐‘ก, ๐‘ฅ,๐‘ฆ,๐‘ โˆ’ ๐‘ฃ๐‘– ๐‘ก, ๐‘ฅ,๐‘ฆ, ๐‘๐‘š

๐‘—=1

โˆ’ sup ๐œ†๐‘–๐‘ ๐‘ž๐‘ ๐‘ฃ๐‘– ๐‘ก, ๐‘ฅ โˆ’ ๐œ‹๐‘–๐‘ ๐‘ž๐‘,๐‘ ๐‘™๐‘ ,๐‘ฆ + ๐‘™๐‘ ,๐‘ โˆ’ ๐‘ฃ๐‘– ๐‘ก, ๐‘ฅ, ๐‘ฆ,๐‘โˆ’ sup ๐œ†๐‘–๐‘Ž ๐‘ž๐‘Ž ๐‘ฃ๐‘– ๐‘ก, ๐‘ฅ + ๐œ‹๐‘–๐‘Ž ๐‘ž๐‘Ž,๐‘ ๐‘™๐‘Ž ,๐‘ฆ โˆ’ ๐‘™๐‘Ž ,๐‘ โˆ’ ๐‘ฃ๐‘– ๐‘ก, ๐‘ฅ,๐‘ฆ, ๐‘

+๐›พ๐‘”,๐‘ฃ๐‘– ๐‘ก, ๐‘ฅ,๐‘ฆ,๐‘ โˆ’ sup ๐‘ฃ๐‘– ๐‘ก, ๐‘ฅ โˆ’ ๐‘๐‘– ๐‘’, ๐‘ ,๐‘ฆ + ๐‘’, ๐‘

= 0

๐‘ฃ๐‘– ๐‘‡, ๐‘ฅ, ๐‘ฆ,๐‘ = ๐‘ˆ ๐ฟ๐‘– ๐‘ฅ,๐‘ฆ,๐‘

Assumptions:

๐‘ˆ ๐‘ฅ = ๐‘ฅ; we care about only how much money made.

๐‘ƒ๐‘ก ๐‘ก is a martingale; we know nothing about where the market will move.

Solution:

๐‘ฃ๐‘– ๐‘ก, ๐‘ฅ,๐‘ฆ, ๐‘ = ๐‘ฅ + ๐‘ฆ๐‘ + ๐œ™๐‘– ๐‘ก, ๐‘ฆ

๐œ™๐‘– ๐‘ก,๐‘ฆ is the solution to the system of integro-differential equations (IDE):

min

โˆ’๐œ•๐œ™๐‘–๐œ•๐‘ก

โˆ’ โˆ‘ ๐‘‘๐‘–๐‘— ๐‘ก ๐œ™๐‘— ๐‘ก,๐‘ฆ โˆ’ ๐œ™๐‘– ๐‘ก,๐‘ฆ๐‘š๐‘—=1

โˆ’ sup ๐œ†๐‘–๐‘ ๐‘ž๐‘ ๐œ™๐‘– ๐‘ก,๐‘ฆ + ๐‘™๐‘ โˆ’ ๐œ™๐‘– ๐‘ก,๐‘ฆ + ๐‘–๐›ฟ2โˆ’ ๐›ฟ1๐‘ž๐‘=๐‘ƒ๐‘ก๐‘+ ๐‘™๐‘

โˆ’ sup ๐œ†๐‘–๐‘Ž ๐‘ž๐‘Ž ๐œ™๐‘– ๐‘ก, ๐‘ฆ โˆ’ ๐‘™๐‘Ž โˆ’ ๐œ™๐‘– ๐‘ก, ๐‘ฆ + ๐‘–๐›ฟ2โˆ’ ๐›ฟ1๐‘ž๐‘Ž=๐‘ƒ๐‘ก๐‘Žโˆ’ ๐‘™๐‘Ž

+๐›พ๐‘” ๐‘ฆ ,๐œ™๐‘– ๐‘ก,๐‘ฆ โˆ’ sup ๐œ™๐‘– ๐‘ก,๐‘ฆ + ๐‘’ โˆ’ ๐‘–๐›ฟ

2๐‘’ โˆ’ ๐œ€

= 0

๐œ™๐‘– ๐‘‡, ๐‘ฆ = โˆ’ ๐‘ฆ ๐‘–๐›ฟ2โˆ’ ๐œ€

50

Based on: F Guilbaud, H Pham, "Optimal high-frequency trading with limit and market orders," Quantitative Finance, 2013.

Page 51: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

Conclusions

51

Page 52: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

FinMath Infrastructure Support All these mathematics and simulations are possible only with a

finmath technology that serves as the modeling infrastructure.

52

โ€ข Linear algebra

โ€ข Calculus

๏ฟฝ ๐‘“ ๐‘ฅ๐‘

๐‘Ž

= ๐น ๐‘ โˆ’ ๐น ๐‘Ž

โ€ข Unconstrained optimization

โ€ข Statistics

โ€ข Differential Equations

local minimum global minimum

Financial Mathematics

Advanced Mathematics

Foundation Mathematics

โ€ข Parallelization

โ€ข Cointegration

โ€ข Optimization (LP, QP, SQP, SDP, SOCP, IP, GA)

โ€ข Digital Signal Processing

โ€ข Time Series Analysis

Applications

โ€ข Optimal Trading Strategies

โ€ข Portfolio Optimization

โ€ข Extreme Value Theory

โ€ข Trading Signals

โ€ข Asset Allocation

โ€ข Risk Management

Page 53: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

The Essential Skills

53

Financial intuitions, market understanding, creativity. Mathematics. Computer programming.

Page 54: Quantitative Trading as a Mathematical Sciencenumericalmethod.com/wp-content/uploads/2012/07/...Result: Paper P&L looks good. Live P&L depends on luck. Trading strategies are results

An Emerging Field

54

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

science); more comprehensive and accurate prediction models

(mathematics).


Recommended