Statistics:
Missing Link between Technical Analysis and
Algorithmic Trading
Manish Jalan
Managing Partner and Quantitative Research Head
SG Analytics, Pune/Mumbai, India
APRIL, 2016
The statistical modeling
building blocks
Define End Goal Define Set of Rules
Collect
Data
Back-test Optimize Simulate
Connect to
OMS
Connect to
Exchange
Manage Risk
Improve and Maintain
Modeling Building
2Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Why Mathematics & Statistics?
Pure Technical Models
Moderate ROI when model is working
Large draw-downs when model stops
Long stretch of continuous bleeding in
returns
User might lose confidence
Technical & Statistical Models
Superior ROI when model is working
Flattish ROI when model stops
Shorter stretch of continuous flattish
period
User can diversify and make multi-models
3Statistics: Missing Link between Technical Analysis and Algorithmic Trading
The Mathematics
Data
Distributions
Time Series
Modeling
Market
Microstructure
4Statistics: Missing Link between Technical Analysis and Algorithmic Trading
The Volatility
5
2
1
1
( )
n
i
i
x
n
 

 
Volatility
Is deviation from mean
in daily, 5 min, 10 min etc.
5Statistics: Missing Link between Technical Analysis and Algorithmic Trading
The normal distribution
Normal
Distribution
Most popular data distribution
Standard normal distribution curve
Source: Wikipedia
6Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Mean ix
n
 

Standard
deviation
2
1
1
( )
n
i
i
x
n
 

 
Variance
2 2
1
1
( )
n
i
i
x
n
 

 
Correlation
( , )
x y
Cov x y
r
 

Beta
( , )
( )
s p
s
p
Cov r r
Var r
 
The normal distribution
7Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Normal vs. other distributions
CAUCHY
DISTRIBUTION
BETA
DISTRIBUTION
BINOMIAL
DISTRIBUTION
CHI-SQUARE
DISTRIBUTION
LAPLACE
DISTRIBUTION
POISSON
DISTRIBUTION
EXPONENTIAL
DISTRIBUTION
8Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Behavior of the time-series of data
– Mean reverting, Trending or Random Walk
– 50-60% time series is random walk
– Focus should be on the other 40%
Key elements: Mean and Variance
Different behaviors
– Mean reverting (E.g.: Pairs Trading)
– Non-mean reverting (E.g.: Trend)
– Constant variance (E.g.: Pairs Trading)
– Increasing variance (E.g.: Trend)
Time series modeling
9Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Mean and Variance
0
2
4
6
8
10
12
Constant Mean
0
2
4
6
8
10
Constant Variance
0
10
20
30
40
Increasing Mean
0
5
10
15
20
25
30
Increasing Variance
10Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Mean reversion modeling
Co-integration: Stationary mean and variance
Time series is stationary when
– The mean is constant
– The variance is constant
Test for co-integration
– If |r| < 1, the series is stationary
– If |r| = 1, it is non-stationary (Random walk)
Most popular test: ADF (Augmented Dickey
Fuller)
If ADF < -3.2 (95% probability of co-integrated
series)
1t t ty ry e 
11Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Variance Ratio Test: Test for variance alone
Useful when mean is varying w.r.t to the time
Ornstein-Uhlenbeck Process: Test for mean reversion alone
Useful when only mean reversion rate matters
Generic time series modeling
( )
( )
( )
k t
t
Variance r
VR k
k Variance r




( )t t tdx x dt dW    
12Statistics: Missing Link between Technical Analysis and Algorithmic Trading
0.00%
2.00%
4.00%
6.00%
8.00%
10.00%
12.00%
14.00%
16.00%
18.00%
20.00%
0 10 20 30 40 50
Growth
P/E Ratio
Cluster analysis and PCA
Grouping of similar data and pattern
Useful in factor modeling
PCA: To identify principal component
13Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Regression
-0.2
-0.15
-0.1
-0.05
0
0.05
0.1
0.15
0.2
-0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25
2
0.659
0.720
y x
R


Useful in identifying alpha-generating factors
y mx c 
14Statistics: Missing Link between Technical Analysis and Algorithmic Trading
1001.50 13
1001.00 19
1000.50 2
1000.00 17
999.50 9
999.00
10 998.50
4 998.00
16 998.00
7 998.00
Last
Traded
Price
Bid-
Ask
Spread
Price Ask QtyBid Qty
Used in UHFT, HFT, Agency Trading
Market microstructure
15Statistics: Missing Link between Technical Analysis and Algorithmic Trading
Market microstructure
09:15 09:30 09:45 10:00 10:4510:3010:15
1005.00 1007.50 1004.50 1003.00 1008.00 1010.50 1009.50
5n  1006.70 
2
1
( ) 35.3
n
i
x 

  2.657 
Market Price of Reliance in 5 min buckets
16Statistics: Missing Link between Technical Analysis and Algorithmic Trading
The spread
( )Spread Ticks BestAsk BestBid 
( )
( ) 10000
( )
2
BestAsk BestBid
Spread BP
BestAsk BestBid

 

Spread in BP
Spread in Ticks
17Statistics: Missing Link between Technical Analysis and Algorithmic Trading
0.00%
1.00%
2.00%
3.00%
4.00%
5.00%
6.00%
7.00%
09:00 09:50 10:40 11:30 12:20 13:10 14:00 14:50
The market curve
Volume / Market curve
BucketVolume
VolumeRatio
DaysTotalVolume

18Statistics: Missing Link between Technical Analysis and Algorithmic Trading
1055.00 2
1054.00 7
1053.00 15
1052.00 25
1051.00 31
1050.00
42 1049.00
20 1048.00
15 1047.00
11 1046.00
6 1045.00
1 2 1 3 1 4 1 5
0 1 2 3 5( ) ( ) ( ) ( )eqVB B B B B B    
1 2 1 3 1 4 1 5
0 1 2 3 5( ) ( ) ( ) ( )eqVA A A A A A    
( , ) eq
eq
VA
f Bid Ask
VB

High frequency example – for execution
Bid-Ask Density function using equivalent volumes
19Statistics: Missing Link between Technical Analysis and Algorithmic Trading
High frequency example
Short Term Upward
Momentum
10:00:00 10:00:30 10:01:00
Trades hitting the Bid
Trades lifted on the Offer
10:01:30
20Statistics: Missing Link between Technical Analysis and Algorithmic Trading
21
Conclusion
Statistical modeling can help you reduce draw-downs in technical analysis
Statistics can help filter for high probability trades
Statistics can enhance the returns on capital deployed
Technical analysis can be used for entry / exits and statistics can be used
for filtering those entries and exits
Statistics can help you re-fine your stop losses and portfolio optimization
Statistics can help in making trade execution better and reduce slippages
per trade
Statistics: Missing Link between Technical Analysis and Algorithmic Trading
22
Recommended referrals
Prop trading
• Statistical Arbitrage:
Algorithmic Trading
Insights and Techniques
by Andrew Pole
• High-Frequency Trading: A
Guide to Algorithmic
Strategies and Trading
Systems by Irene Aldridge
• The Encyclopedia of
Trading Strategies by
Jeffrey Owen and Donna
McCormick
Agency trading
• Algorithmic Trading and
DMA: An introduction to
direct access trading
strategies by Barry
Johnson
• Quantitative Trading:
How to Build Your Own
Algorithmic Trading
Business by Ernset P. Chan
Web forums
Wilmott forum:
www.wilmott.com
Nuclear Phynance:
www.nuclearphynance.com
Statistics: Missing Link between Technical Analysis and Algorithmic Trading
23
Manish Jalan
Managing Partner and Quantitative Research Head
SG Analytics, Pune/Mumbai, India

Statistics - The Missing Link Between Technical Analysis and Algorithmic Trading by Manish Jalan at QuantCon 2016

  • 1.
    Statistics: Missing Link betweenTechnical Analysis and Algorithmic Trading Manish Jalan Managing Partner and Quantitative Research Head SG Analytics, Pune/Mumbai, India APRIL, 2016
  • 2.
    The statistical modeling buildingblocks Define End Goal Define Set of Rules Collect Data Back-test Optimize Simulate Connect to OMS Connect to Exchange Manage Risk Improve and Maintain Modeling Building 2Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 3.
    Why Mathematics &Statistics? Pure Technical Models Moderate ROI when model is working Large draw-downs when model stops Long stretch of continuous bleeding in returns User might lose confidence Technical & Statistical Models Superior ROI when model is working Flattish ROI when model stops Shorter stretch of continuous flattish period User can diversify and make multi-models 3Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 4.
    The Mathematics Data Distributions Time Series Modeling Market Microstructure 4Statistics:Missing Link between Technical Analysis and Algorithmic Trading
  • 5.
    The Volatility 5 2 1 1 ( ) n i i x n     Volatility Is deviation from mean in daily, 5 min, 10 min etc. 5Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 6.
    The normal distribution Normal Distribution Mostpopular data distribution Standard normal distribution curve Source: Wikipedia 6Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 7.
    Mean ix n    Standard deviation 2 1 1 () n i i x n      Variance 2 2 1 1 ( ) n i i x n      Correlation ( , ) x y Cov x y r    Beta ( , ) ( ) s p s p Cov r r Var r   The normal distribution 7Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 8.
    Normal vs. otherdistributions CAUCHY DISTRIBUTION BETA DISTRIBUTION BINOMIAL DISTRIBUTION CHI-SQUARE DISTRIBUTION LAPLACE DISTRIBUTION POISSON DISTRIBUTION EXPONENTIAL DISTRIBUTION 8Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 9.
    Behavior of thetime-series of data – Mean reverting, Trending or Random Walk – 50-60% time series is random walk – Focus should be on the other 40% Key elements: Mean and Variance Different behaviors – Mean reverting (E.g.: Pairs Trading) – Non-mean reverting (E.g.: Trend) – Constant variance (E.g.: Pairs Trading) – Increasing variance (E.g.: Trend) Time series modeling 9Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 10.
    Mean and Variance 0 2 4 6 8 10 12 ConstantMean 0 2 4 6 8 10 Constant Variance 0 10 20 30 40 Increasing Mean 0 5 10 15 20 25 30 Increasing Variance 10Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 11.
    Mean reversion modeling Co-integration:Stationary mean and variance Time series is stationary when – The mean is constant – The variance is constant Test for co-integration – If |r| < 1, the series is stationary – If |r| = 1, it is non-stationary (Random walk) Most popular test: ADF (Augmented Dickey Fuller) If ADF < -3.2 (95% probability of co-integrated series) 1t t ty ry e  11Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 12.
    Variance Ratio Test:Test for variance alone Useful when mean is varying w.r.t to the time Ornstein-Uhlenbeck Process: Test for mean reversion alone Useful when only mean reversion rate matters Generic time series modeling ( ) ( ) ( ) k t t Variance r VR k k Variance r     ( )t t tdx x dt dW     12Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 13.
    0.00% 2.00% 4.00% 6.00% 8.00% 10.00% 12.00% 14.00% 16.00% 18.00% 20.00% 0 10 2030 40 50 Growth P/E Ratio Cluster analysis and PCA Grouping of similar data and pattern Useful in factor modeling PCA: To identify principal component 13Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 14.
    Regression -0.2 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 -0.2 -0.15 -0.1-0.05 0 0.05 0.1 0.15 0.2 0.25 2 0.659 0.720 y x R   Useful in identifying alpha-generating factors y mx c  14Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 15.
    1001.50 13 1001.00 19 1000.502 1000.00 17 999.50 9 999.00 10 998.50 4 998.00 16 998.00 7 998.00 Last Traded Price Bid- Ask Spread Price Ask QtyBid Qty Used in UHFT, HFT, Agency Trading Market microstructure 15Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 16.
    Market microstructure 09:15 09:3009:45 10:00 10:4510:3010:15 1005.00 1007.50 1004.50 1003.00 1008.00 1010.50 1009.50 5n  1006.70  2 1 ( ) 35.3 n i x     2.657  Market Price of Reliance in 5 min buckets 16Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 17.
    The spread ( )SpreadTicks BestAsk BestBid  ( ) ( ) 10000 ( ) 2 BestAsk BestBid Spread BP BestAsk BestBid     Spread in BP Spread in Ticks 17Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 18.
    0.00% 1.00% 2.00% 3.00% 4.00% 5.00% 6.00% 7.00% 09:00 09:50 10:4011:30 12:20 13:10 14:00 14:50 The market curve Volume / Market curve BucketVolume VolumeRatio DaysTotalVolume  18Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 19.
    1055.00 2 1054.00 7 1053.0015 1052.00 25 1051.00 31 1050.00 42 1049.00 20 1048.00 15 1047.00 11 1046.00 6 1045.00 1 2 1 3 1 4 1 5 0 1 2 3 5( ) ( ) ( ) ( )eqVB B B B B B     1 2 1 3 1 4 1 5 0 1 2 3 5( ) ( ) ( ) ( )eqVA A A A A A     ( , ) eq eq VA f Bid Ask VB  High frequency example – for execution Bid-Ask Density function using equivalent volumes 19Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 20.
    High frequency example ShortTerm Upward Momentum 10:00:00 10:00:30 10:01:00 Trades hitting the Bid Trades lifted on the Offer 10:01:30 20Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 21.
    21 Conclusion Statistical modeling canhelp you reduce draw-downs in technical analysis Statistics can help filter for high probability trades Statistics can enhance the returns on capital deployed Technical analysis can be used for entry / exits and statistics can be used for filtering those entries and exits Statistics can help you re-fine your stop losses and portfolio optimization Statistics can help in making trade execution better and reduce slippages per trade Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 22.
    22 Recommended referrals Prop trading •Statistical Arbitrage: Algorithmic Trading Insights and Techniques by Andrew Pole • High-Frequency Trading: A Guide to Algorithmic Strategies and Trading Systems by Irene Aldridge • The Encyclopedia of Trading Strategies by Jeffrey Owen and Donna McCormick Agency trading • Algorithmic Trading and DMA: An introduction to direct access trading strategies by Barry Johnson • Quantitative Trading: How to Build Your Own Algorithmic Trading Business by Ernset P. Chan Web forums Wilmott forum: www.wilmott.com Nuclear Phynance: www.nuclearphynance.com Statistics: Missing Link between Technical Analysis and Algorithmic Trading
  • 23.
    23 Manish Jalan Managing Partnerand Quantitative Research Head SG Analytics, Pune/Mumbai, India