SlideShare une entreprise Scribd logo
1  sur  47
Télécharger pour lire hors ligne
Introduction to pair trading
  -Based on cointegration-

       ・Shinichi Takayanagi
         ・Kohta Ishikawa

                               1
Topics
1.   What is pair trading?
2.   What is cointegration?
3.   Idea of pair trading based on cointegration
4.   Simulation by R language
5.   Summary & concluding remarks




                                               2
1. What is pair trading?


                       3
Pair trading was pioneered by …



•   Gerry Bamberger and Nunzio Tartaglia
•   Quantitative group at Morgan Stanley
•   Around 1980s
•   D.E. Shaw & Co. is famous for this strategy




                                                  4
Pair trading is …




Market neutral trading strategy




                              5
Pair trading belongs to …




Statistical Arbitrage


                               6
Basic idea of pair trading …



 Select two stocks
which move similarly

                                 7
Basic idea of pair trading …




Sell high priced stock
Buy low priced stock

                                 8
Basic idea of pair trading …
Stock A : --------
Stock B : --------
                                          Sell
                       Sell             Stock B
                     Stock A



                                       Buy
                                     Stock A
                         Buy
                       Stock B
                                               9
Basic idea of pair trading …



    Usually, monitor
     the difference
between two stock prices

                                  10
Basic idea of pair trading …
   the difference between two stock prices
  Sell
Stock A                          Sell
                               Stock B


       Buy
     Stock B
                                    Buy
                                  Stock A    11
2. What is cointegration?


                       12
Cointegration is …



• Pioneered by Engle and Granger
• Statistical property of time series
• Around 1990s


                                   13
Cointegration is …




Not correlation

                        14
Cointegration and correlation

•Correlation
 –Specify co-movement of return
 –Short term relationship

•Cointegration
 –Specify co-movement of price
 –Long term relationship
                                   15
(weak) Stationary time series

     Not depend on time
・E  X t   
・ X t   
 var                   2


・  X t , X t  s    s 
 cov
                                    16
Example of stationary time series

          White noise
・E  t   0
・  t   
 var                  2


・  t ,  s   0, t  s
 cov
                                      17
Non stationary time series

        Depend on time
・E  X t   t
・ X t    t
                      2
 var
・  X t , X t  s    t , s 
 cov
                                   18
Example of non stationary time series

       Brownian motion

・E Wt   0
・ Wt   t
 var
・ Wt ,Wt  s   t  s
 cov
                                    19
Lag operator   L

・LX t  X t 1
・1  L X t  X t  X t 1  X t
 

                               20
Integrated of order P

X t : non stationary
1  L    p
               X t : stationary


      X t~I  p 
                                  21
Example of “integrate”

  Z t  Z t 1   t : Random walk
   t : White noise
       Calculate difference

Z t  Z t  Z t 1   t : Stationary
 Z t~I 1
                                     22
X t and Yt are cointegrated if …


ut  Yt    X t 
ut : ~I 0, stationary process
X t , Yt : ~I 1

*This is a special version of general cointegration for I(1)
                                                               23
Example of cointegrated time series




                Yt  50  0.5 X t  ut
Xt : --------   X t : 100  2  Normal brownian motion
Yt : --------   ut : 3  Gaussian noise
                                                     24
Example of cointegrated time series




       Plot : ut = Yt – 0.5 Xt
                                      25
ut seems to be…


 Stationary
      &
Mean reversion
                     26
Question




Can we apply this idea
  to trading strategy?

                     27
3. Idea of pair trading
based on cointegration


                      28
Geometric brownian motion

The most widely used model of stock price


dSt
     dt  dWt
 St                          St : Stock price
                              : Average return
                              : Volatility
                             Wt : Brownian motion
                                                29
From Ito’s lemma



                    2
                          
d log St     
                         dt  dWt
                          
                    2    

Log price follow Brownian motion
                                  30
Brownian motion(log price) is …




                    I(1)
* Random walk can be considered as discretization of Brownian motion
                                                                31
Then, we can apply




Cointegration idea
 to log stock price

                          32
Log price spread(*) is…


 Stationary
      &
Mean reversion
※Spreadt : logYt      log X t ,   X t , Yt : stock price
                                                                      33
Simple trading idea

if Spread t  very hish : Buy X t ,Sell Yt
if Spread t  very low : Buy Yt ,Sell X t


 Spread t  log Yt      log  X t 
 X t , Yt : stock price

                                          34
4. Simulation by R language



                         35
Process
1.   Find two likely cointegrated stocks
2.   Estimate spreads
3.   Check stationarity
4.   Create trading signal
5.   Run back-test




                                           36
1.Find two likely cointegrated stocks
> library(PairTrading)
> #load sample stock price data
> data(stock.price)
> #select 2 stocks
> price.pair <- stock.price[,1:2]["2008-12-31::"]
> head(price.pair)
       7201 7203
2009-01-05 333 3010
2009-01-06 341 3050
2009-01-07 374 3200
2009-01-08 361 3140

* Just load sample data in this case….
                                                    37
2. Estimate spreads
> reg <- EstimateParameters(price.pair, method = lm)
> str(reg)
List of 3
 $ spread :An ‘xts’ object from 2008-12-30 to 2011-08-05 containing:
  Data: num [1:635, 1] -0.08544 -0.0539 -0.04306 -0.00426 -0.01966 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr "B"
  Indexed by objects of class: [Date] TZ:
  xts Attributes:
 NULL
 $ hedge.ratio: num 0.0997
 $ premium : num 7.48
                                                                  38
2. Estimate spreads
> plot(reg$spread, main = "Spread“)




    Spreadt  logYt      log X t , X t , Yt : stock price
                                                                      39
3. Check stationarity
> PP.test(as.numeric(reg$spread))
   Phillips-Perron Unit Root Test
data: as.numeric(reg$spread)
Dickey-Fuller = -3.2299, Truncation lag parameter = 6, p-value
   = 0.08278
> adf.test(as.numeric(reg$spread))
   Augmented Dickey-Fuller Test
data: as.numeric(reg$spread)
Dickey-Fuller = -3.6462, Lag order = 8, p-value = 0.02825
alternative hypothesis: stationary

                                                          40
4. Create trading signal
> params <-
  EstimateParametersHistorically(price.pair,
  period = 180)
> signal <- Simple(params$spread, 0.05)
> barplot(signal,col="blue",space = 0, border =
  "blue",xaxt="n",yaxt="n",xlab="",ylab="")
> par(new=TRUE)
> plot(params$spread, type="l", col = "red",
  lwd = 3, main = "Spread & Signal")
                                             41
4. Create trading signal




                           42
5. Run back-test

> return.pairtrading <-
 Return(price.pair, lag(signal),
 lag(params$hedge.ratio))
> plot(100 * cumprod(1 +
 return.pairtrading), main =
 "Performance of pair trading")

                                   43
5. Run back-test




                   44
5. Summary &
concluding remarks


                     45
Summary & concluding remarks
• Pair trading is simple quantitative trading strategy
• Cointegration is long term relation ship of time
  series
• Idea of cointegration may give a chance to make a
  profit from financial market by pair trading

• Next step ….
  – Sophisticate parameter estimation & trading rule
  – Make a simulation close to real

                                                       46
Reference
• Pairs trade(http://en.wikipedia.org/wiki/Pairs_trade)
• Cointegration(http://en.wikipedia.org/wiki/Cointegration)
• Andrew Neil Burgess, “A Computational Methodology for
  Modeling the Dynamics of Statistical Arbitrage”
• Russell Wojcik, “Pairs Trading: A Professional Approach”
• Daniel Herlemont, “Pairs trading, convergence trading,
  cointegration”
• Paul Teetor, “Using R to Test Pairs of Securities for
  Cointegration”(http://quanttrader.info/public/testForCoint.html)
• Ganapathy Vidyamurthy, “Pairs Trading: Quantitative Methods
  and Analysis “



                                                                47

Contenu connexe

Tendances

ブラック・リッターマン法を用いたリスクベース・ポートフォリオの拡張
ブラック・リッターマン法を用いたリスクベース・ポートフォリオの拡張ブラック・リッターマン法を用いたリスクベース・ポートフォリオの拡張
ブラック・リッターマン法を用いたリスクベース・ポートフォリオの拡張Kei Nakagawa
 
CF-FinML 金融時系列予測のための機械学習
CF-FinML 金融時系列予測のための機械学習CF-FinML 金融時系列予測のための機械学習
CF-FinML 金融時系列予測のための機械学習Katsuya Ito
 
(実験心理学徒だけど)一般化線形混合モデルを使ってみた
(実験心理学徒だけど)一般化線形混合モデルを使ってみた(実験心理学徒だけど)一般化線形混合モデルを使ってみた
(実験心理学徒だけど)一般化線形混合モデルを使ってみたTakashi Yamane
 
StanとRでベイズ統計モデリングに関する読書会(Osaka.stan) 第四章
StanとRでベイズ統計モデリングに関する読書会(Osaka.stan) 第四章StanとRでベイズ統計モデリングに関する読書会(Osaka.stan) 第四章
StanとRでベイズ統計モデリングに関する読書会(Osaka.stan) 第四章nocchi_airport
 
【DL輪読会】Reward Design with Language Models
【DL輪読会】Reward Design with Language Models【DL輪読会】Reward Design with Language Models
【DL輪読会】Reward Design with Language ModelsDeep Learning JP
 
内容的妥当性,構造的妥当性と仮説検定の評価
内容的妥当性,構造的妥当性と仮説検定の評価内容的妥当性,構造的妥当性と仮説検定の評価
内容的妥当性,構造的妥当性と仮説検定の評価Yoshitake Takebayashi
 
不均衡データのクラス分類
不均衡データのクラス分類不均衡データのクラス分類
不均衡データのクラス分類Shintaro Fukushima
 
Risk based portfolio with large dynamic covariance matrices
Risk based portfolio with large dynamic covariance matricesRisk based portfolio with large dynamic covariance matrices
Risk based portfolio with large dynamic covariance matricesKei Nakagawa
 
階層モデルの分散パラメータの事前分布について
階層モデルの分散パラメータの事前分布について階層モデルの分散パラメータの事前分布について
階層モデルの分散パラメータの事前分布についてhoxo_m
 
Curso de avaliação pelo fluxo de caixa descontado (Valuation)
Curso de avaliação pelo fluxo de caixa descontado (Valuation)Curso de avaliação pelo fluxo de caixa descontado (Valuation)
Curso de avaliação pelo fluxo de caixa descontado (Valuation)Felipe Pontes
 
混合モデルとEMアルゴリズム(PRML第9章)
混合モデルとEMアルゴリズム(PRML第9章)混合モデルとEMアルゴリズム(PRML第9章)
混合モデルとEMアルゴリズム(PRML第9章)Takao Yamanaka
 
MCMCでマルチレベルモデル
MCMCでマルチレベルモデルMCMCでマルチレベルモデル
MCMCでマルチレベルモデルHiroshi Shimizu
 
金融予測アルゴリズムのより良い評価手法について
金融予測アルゴリズムのより良い評価手法について金融予測アルゴリズムのより良い評価手法について
金融予測アルゴリズムのより良い評価手法についてKentaro Imajo
 
Pairs Trading
Pairs TradingPairs Trading
Pairs Tradingnattyvirk
 
MCMCとともだちになろう【※Docswellにも同じものを上げています】
MCMCとともだちになろう【※Docswellにも同じものを上げています】MCMCとともだちになろう【※Docswellにも同じものを上げています】
MCMCとともだちになろう【※Docswellにも同じものを上げています】Hiroyuki Muto
 
アセットアロケーションの未来
アセットアロケーションの未来アセットアロケーションの未来
アセットアロケーションの未来Kei Nakagawa
 
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin..."Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...Quantopian
 

Tendances (20)

2 3.GLMの基礎
2 3.GLMの基礎2 3.GLMの基礎
2 3.GLMの基礎
 
ブラック・リッターマン法を用いたリスクベース・ポートフォリオの拡張
ブラック・リッターマン法を用いたリスクベース・ポートフォリオの拡張ブラック・リッターマン法を用いたリスクベース・ポートフォリオの拡張
ブラック・リッターマン法を用いたリスクベース・ポートフォリオの拡張
 
Prml14 5
Prml14 5Prml14 5
Prml14 5
 
CF-FinML 金融時系列予測のための機械学習
CF-FinML 金融時系列予測のための機械学習CF-FinML 金融時系列予測のための機械学習
CF-FinML 金融時系列予測のための機械学習
 
(実験心理学徒だけど)一般化線形混合モデルを使ってみた
(実験心理学徒だけど)一般化線形混合モデルを使ってみた(実験心理学徒だけど)一般化線形混合モデルを使ってみた
(実験心理学徒だけど)一般化線形混合モデルを使ってみた
 
StanとRでベイズ統計モデリングに関する読書会(Osaka.stan) 第四章
StanとRでベイズ統計モデリングに関する読書会(Osaka.stan) 第四章StanとRでベイズ統計モデリングに関する読書会(Osaka.stan) 第四章
StanとRでベイズ統計モデリングに関する読書会(Osaka.stan) 第四章
 
【DL輪読会】Reward Design with Language Models
【DL輪読会】Reward Design with Language Models【DL輪読会】Reward Design with Language Models
【DL輪読会】Reward Design with Language Models
 
.pptx
.pptx.pptx
.pptx
 
内容的妥当性,構造的妥当性と仮説検定の評価
内容的妥当性,構造的妥当性と仮説検定の評価内容的妥当性,構造的妥当性と仮説検定の評価
内容的妥当性,構造的妥当性と仮説検定の評価
 
不均衡データのクラス分類
不均衡データのクラス分類不均衡データのクラス分類
不均衡データのクラス分類
 
Risk based portfolio with large dynamic covariance matrices
Risk based portfolio with large dynamic covariance matricesRisk based portfolio with large dynamic covariance matrices
Risk based portfolio with large dynamic covariance matrices
 
階層モデルの分散パラメータの事前分布について
階層モデルの分散パラメータの事前分布について階層モデルの分散パラメータの事前分布について
階層モデルの分散パラメータの事前分布について
 
Curso de avaliação pelo fluxo de caixa descontado (Valuation)
Curso de avaliação pelo fluxo de caixa descontado (Valuation)Curso de avaliação pelo fluxo de caixa descontado (Valuation)
Curso de avaliação pelo fluxo de caixa descontado (Valuation)
 
混合モデルとEMアルゴリズム(PRML第9章)
混合モデルとEMアルゴリズム(PRML第9章)混合モデルとEMアルゴリズム(PRML第9章)
混合モデルとEMアルゴリズム(PRML第9章)
 
MCMCでマルチレベルモデル
MCMCでマルチレベルモデルMCMCでマルチレベルモデル
MCMCでマルチレベルモデル
 
金融予測アルゴリズムのより良い評価手法について
金融予測アルゴリズムのより良い評価手法について金融予測アルゴリズムのより良い評価手法について
金融予測アルゴリズムのより良い評価手法について
 
Pairs Trading
Pairs TradingPairs Trading
Pairs Trading
 
MCMCとともだちになろう【※Docswellにも同じものを上げています】
MCMCとともだちになろう【※Docswellにも同じものを上げています】MCMCとともだちになろう【※Docswellにも同じものを上げています】
MCMCとともだちになろう【※Docswellにも同じものを上げています】
 
アセットアロケーションの未来
アセットアロケーションの未来アセットアロケーションの未来
アセットアロケーションの未来
 
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin..."Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
"Enhancing Statistical Significance of Backtests" by Dr. Ernest Chan, Managin...
 

Similaire à Introduction to pairtrading

Dynamic Trading Volume
Dynamic Trading VolumeDynamic Trading Volume
Dynamic Trading Volumeguasoni
 
Transactional Data Mining
Transactional Data MiningTransactional Data Mining
Transactional Data MiningTed Dunning
 
Incomplete-Market Equilibrium with Unhedgeable Fundamentals and Heterogeneous...
Incomplete-Market Equilibrium with Unhedgeable Fundamentals and Heterogeneous...Incomplete-Market Equilibrium with Unhedgeable Fundamentals and Heterogeneous...
Incomplete-Market Equilibrium with Unhedgeable Fundamentals and Heterogeneous...guasoni
 
Hedging, Arbitrage, and Optimality with Superlinear Frictions
Hedging, Arbitrage, and Optimality with Superlinear FrictionsHedging, Arbitrage, and Optimality with Superlinear Frictions
Hedging, Arbitrage, and Optimality with Superlinear Frictionsguasoni
 
Black-Scholes overview
Black-Scholes overviewBlack-Scholes overview
Black-Scholes overviewInon Sharony
 
Estimation of Static Discrete Choice Models Using Market Level Data
Estimation of Static Discrete Choice Models Using Market Level DataEstimation of Static Discrete Choice Models Using Market Level Data
Estimation of Static Discrete Choice Models Using Market Level DataNBER
 
Transaction Costs Made Tractable
Transaction Costs Made TractableTransaction Costs Made Tractable
Transaction Costs Made Tractableguasoni
 
Introduction to time series.pptx
Introduction to time series.pptxIntroduction to time series.pptx
Introduction to time series.pptxHamidUllah50
 
UT Austin - Portugal Lectures on Portfolio Choice
UT Austin - Portugal Lectures on Portfolio ChoiceUT Austin - Portugal Lectures on Portfolio Choice
UT Austin - Portugal Lectures on Portfolio Choiceguasoni
 
The Orbit Rulebook.pdf
The Orbit Rulebook.pdfThe Orbit Rulebook.pdf
The Orbit Rulebook.pdfSamm Ikwue
 
Stochastic Dividend Modeling
Stochastic Dividend ModelingStochastic Dividend Modeling
Stochastic Dividend ModelingClebson Derivan
 
Introduction to Interest Rate Models by Antoine Savine
Introduction to Interest Rate Models by Antoine SavineIntroduction to Interest Rate Models by Antoine Savine
Introduction to Interest Rate Models by Antoine SavineAntoine Savine
 
Stochastic Control of Optimal Trade Order Execution
Stochastic Control of Optimal Trade Order ExecutionStochastic Control of Optimal Trade Order Execution
Stochastic Control of Optimal Trade Order ExecutionAshwin Rao
 
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...Volatility
 
A Quantitative Case Study on the Impact of Transaction Cost in High-Frequency...
A Quantitative Case Study on the Impact of Transaction Cost in High-Frequency...A Quantitative Case Study on the Impact of Transaction Cost in High-Frequency...
A Quantitative Case Study on the Impact of Transaction Cost in High-Frequency...Cognizant
 

Similaire à Introduction to pairtrading (20)

Dynamic Trading Volume
Dynamic Trading VolumeDynamic Trading Volume
Dynamic Trading Volume
 
Transactional Data Mining
Transactional Data MiningTransactional Data Mining
Transactional Data Mining
 
Incomplete-Market Equilibrium with Unhedgeable Fundamentals and Heterogeneous...
Incomplete-Market Equilibrium with Unhedgeable Fundamentals and Heterogeneous...Incomplete-Market Equilibrium with Unhedgeable Fundamentals and Heterogeneous...
Incomplete-Market Equilibrium with Unhedgeable Fundamentals and Heterogeneous...
 
Hedging, Arbitrage, and Optimality with Superlinear Frictions
Hedging, Arbitrage, and Optimality with Superlinear FrictionsHedging, Arbitrage, and Optimality with Superlinear Frictions
Hedging, Arbitrage, and Optimality with Superlinear Frictions
 
Black-Scholes overview
Black-Scholes overviewBlack-Scholes overview
Black-Scholes overview
 
Estimation of Static Discrete Choice Models Using Market Level Data
Estimation of Static Discrete Choice Models Using Market Level DataEstimation of Static Discrete Choice Models Using Market Level Data
Estimation of Static Discrete Choice Models Using Market Level Data
 
Pres fibe2015-pbs-org
Pres fibe2015-pbs-orgPres fibe2015-pbs-org
Pres fibe2015-pbs-org
 
Pres-Fibe2015-pbs-Org
Pres-Fibe2015-pbs-OrgPres-Fibe2015-pbs-Org
Pres-Fibe2015-pbs-Org
 
Transaction Costs Made Tractable
Transaction Costs Made TractableTransaction Costs Made Tractable
Transaction Costs Made Tractable
 
Margrabe option
Margrabe optionMargrabe option
Margrabe option
 
Black-Schole Model.pptx
Black-Schole Model.pptxBlack-Schole Model.pptx
Black-Schole Model.pptx
 
Introduction to time series.pptx
Introduction to time series.pptxIntroduction to time series.pptx
Introduction to time series.pptx
 
DP_M4_L2.pdf
DP_M4_L2.pdfDP_M4_L2.pdf
DP_M4_L2.pdf
 
UT Austin - Portugal Lectures on Portfolio Choice
UT Austin - Portugal Lectures on Portfolio ChoiceUT Austin - Portugal Lectures on Portfolio Choice
UT Austin - Portugal Lectures on Portfolio Choice
 
The Orbit Rulebook.pdf
The Orbit Rulebook.pdfThe Orbit Rulebook.pdf
The Orbit Rulebook.pdf
 
Stochastic Dividend Modeling
Stochastic Dividend ModelingStochastic Dividend Modeling
Stochastic Dividend Modeling
 
Introduction to Interest Rate Models by Antoine Savine
Introduction to Interest Rate Models by Antoine SavineIntroduction to Interest Rate Models by Antoine Savine
Introduction to Interest Rate Models by Antoine Savine
 
Stochastic Control of Optimal Trade Order Execution
Stochastic Control of Optimal Trade Order ExecutionStochastic Control of Optimal Trade Order Execution
Stochastic Control of Optimal Trade Order Execution
 
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
An Approximate Distribution of Delta-Hedging Errors in a Jump-Diffusion Model...
 
A Quantitative Case Study on the Impact of Transaction Cost in High-Frequency...
A Quantitative Case Study on the Impact of Transaction Cost in High-Frequency...A Quantitative Case Study on the Impact of Transaction Cost in High-Frequency...
A Quantitative Case Study on the Impact of Transaction Cost in High-Frequency...
 

Plus de Kohta Ishikawa

[Paper reading] Hamiltonian Neural Networks
 [Paper reading] Hamiltonian Neural Networks [Paper reading] Hamiltonian Neural Networks
[Paper reading] Hamiltonian Neural NetworksKohta Ishikawa
 
Spherical CNNs paper reading
Spherical CNNs paper readingSpherical CNNs paper reading
Spherical CNNs paper readingKohta Ishikawa
 
Model Transport: Towards Scalable Transfer Learning on Manifolds 論文紹介
Model Transport: Towards Scalable Transfer Learning on Manifolds 論文紹介Model Transport: Towards Scalable Transfer Learning on Manifolds 論文紹介
Model Transport: Towards Scalable Transfer Learning on Manifolds 論文紹介Kohta Ishikawa
 
A brief explanation of Causal Entropic Forces
A brief explanation of Causal Entropic ForcesA brief explanation of Causal Entropic Forces
A brief explanation of Causal Entropic ForcesKohta Ishikawa
 
量子アニーリング解説 1
量子アニーリング解説 1量子アニーリング解説 1
量子アニーリング解説 1Kohta Ishikawa
 
R Language Definition 2.2 to 2.3
R Language Definition 2.2 to 2.3R Language Definition 2.2 to 2.3
R Language Definition 2.2 to 2.3Kohta Ishikawa
 
Nonlinear Filtering and Path Integral Method (Paper Review)
Nonlinear Filtering and Path Integral Method (Paper Review)Nonlinear Filtering and Path Integral Method (Paper Review)
Nonlinear Filtering and Path Integral Method (Paper Review)Kohta Ishikawa
 
Particle Filter Tracking in Python
Particle Filter Tracking in PythonParticle Filter Tracking in Python
Particle Filter Tracking in PythonKohta Ishikawa
 
Rでisomap(多様体学習のはなし)
Rでisomap(多様体学習のはなし)Rでisomap(多様体学習のはなし)
Rでisomap(多様体学習のはなし)Kohta Ishikawa
 
Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statisticsKohta Ishikawa
 

Plus de Kohta Ishikawa (11)

[Paper reading] Hamiltonian Neural Networks
 [Paper reading] Hamiltonian Neural Networks [Paper reading] Hamiltonian Neural Networks
[Paper reading] Hamiltonian Neural Networks
 
Spherical CNNs paper reading
Spherical CNNs paper readingSpherical CNNs paper reading
Spherical CNNs paper reading
 
Model Transport: Towards Scalable Transfer Learning on Manifolds 論文紹介
Model Transport: Towards Scalable Transfer Learning on Manifolds 論文紹介Model Transport: Towards Scalable Transfer Learning on Manifolds 論文紹介
Model Transport: Towards Scalable Transfer Learning on Manifolds 論文紹介
 
A brief explanation of Causal Entropic Forces
A brief explanation of Causal Entropic ForcesA brief explanation of Causal Entropic Forces
A brief explanation of Causal Entropic Forces
 
量子アニーリング解説 1
量子アニーリング解説 1量子アニーリング解説 1
量子アニーリング解説 1
 
R Language Definition 2.2 to 2.3
R Language Definition 2.2 to 2.3R Language Definition 2.2 to 2.3
R Language Definition 2.2 to 2.3
 
Nonlinear Filtering and Path Integral Method (Paper Review)
Nonlinear Filtering and Path Integral Method (Paper Review)Nonlinear Filtering and Path Integral Method (Paper Review)
Nonlinear Filtering and Path Integral Method (Paper Review)
 
Particle Filter Tracking in Python
Particle Filter Tracking in PythonParticle Filter Tracking in Python
Particle Filter Tracking in Python
 
Rでisomap(多様体学習のはなし)
Rでisomap(多様体学習のはなし)Rでisomap(多様体学習のはなし)
Rでisomap(多様体学習のはなし)
 
Introduction to statistics
Introduction to statisticsIntroduction to statistics
Introduction to statistics
 
PRML_2.3.1~2.3.3
PRML_2.3.1~2.3.3PRML_2.3.1~2.3.3
PRML_2.3.1~2.3.3
 

Dernier

Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂EscortCall Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escortdlhescort
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...amitlee9823
 
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 MonthsSEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 MonthsIndeedSEO
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...allensay1
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756dollysharma2066
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Sheetaleventcompany
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Adnet Communications
 
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Falcon Invoice Discounting
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...lizamodels9
 
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876dlhescort
 
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...lizamodels9
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...lizamodels9
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLkapoorjyoti4444
 
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLWhitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLkapoorjyoti4444
 
Falcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business PotentialFalcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business PotentialFalcon investment
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting
 
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Sheetaleventcompany
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentationuneakwhite
 

Dernier (20)

Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂EscortCall Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
 
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
Call Girls Kengeri Satellite Town Just Call 👗 7737669865 👗 Top Class Call Gir...
 
Falcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in indiaFalcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in india
 
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 MonthsSEO Case Study: How I Increased SEO Traffic & Ranking by 50-60%  in 6 Months
SEO Case Study: How I Increased SEO Traffic & Ranking by 50-60% in 6 Months
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
 
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Majnu Ka Tilla, Delhi Contact Us 8377877756
 
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
Chandigarh Escorts Service 📞8868886958📞 Just📲 Call Nihal Chandigarh Call Girl...
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
 
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876
Cheap Rate Call Girls In Noida Sector 62 Metro 959961乂3876
 
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
Call Girls From Raj Nagar Extension Ghaziabad❤️8448577510 ⊹Best Escorts Servi...
 
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
Call Girls From Pari Chowk Greater Noida ❤️8448577510 ⊹Best Escorts Service I...
 
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLBAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
BAGALUR CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRLWhitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
Whitefield CALL GIRL IN 98274*61493 ❤CALL GIRLS IN ESCORT SERVICE❤CALL GIRL
 
Falcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business PotentialFalcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business Potential
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investors
 
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Uneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration PresentationUneak White's Personal Brand Exploration Presentation
Uneak White's Personal Brand Exploration Presentation
 

Introduction to pairtrading

  • 1. Introduction to pair trading -Based on cointegration- ・Shinichi Takayanagi ・Kohta Ishikawa 1
  • 2. Topics 1. What is pair trading? 2. What is cointegration? 3. Idea of pair trading based on cointegration 4. Simulation by R language 5. Summary & concluding remarks 2
  • 3. 1. What is pair trading? 3
  • 4. Pair trading was pioneered by … • Gerry Bamberger and Nunzio Tartaglia • Quantitative group at Morgan Stanley • Around 1980s • D.E. Shaw & Co. is famous for this strategy 4
  • 5. Pair trading is … Market neutral trading strategy 5
  • 6. Pair trading belongs to … Statistical Arbitrage 6
  • 7. Basic idea of pair trading … Select two stocks which move similarly 7
  • 8. Basic idea of pair trading … Sell high priced stock Buy low priced stock 8
  • 9. Basic idea of pair trading … Stock A : -------- Stock B : -------- Sell Sell Stock B Stock A Buy Stock A Buy Stock B 9
  • 10. Basic idea of pair trading … Usually, monitor the difference between two stock prices 10
  • 11. Basic idea of pair trading … the difference between two stock prices Sell Stock A Sell Stock B Buy Stock B Buy Stock A 11
  • 12. 2. What is cointegration? 12
  • 13. Cointegration is … • Pioneered by Engle and Granger • Statistical property of time series • Around 1990s 13
  • 14. Cointegration is … Not correlation 14
  • 15. Cointegration and correlation •Correlation –Specify co-movement of return –Short term relationship •Cointegration –Specify co-movement of price –Long term relationship 15
  • 16. (weak) Stationary time series Not depend on time ・E  X t    ・ X t    var 2 ・  X t , X t  s    s  cov 16
  • 17. Example of stationary time series White noise ・E  t   0 ・  t    var 2 ・  t ,  s   0, t  s cov 17
  • 18. Non stationary time series Depend on time ・E  X t   t ・ X t    t 2 var ・  X t , X t  s    t , s  cov 18
  • 19. Example of non stationary time series Brownian motion ・E Wt   0 ・ Wt   t var ・ Wt ,Wt  s   t  s cov 19
  • 20. Lag operator L ・LX t  X t 1 ・1  L X t  X t  X t 1  X t  20
  • 21. Integrated of order P X t : non stationary 1  L  p X t : stationary X t~I  p  21
  • 22. Example of “integrate” Z t  Z t 1   t : Random walk  t : White noise Calculate difference Z t  Z t  Z t 1   t : Stationary  Z t~I 1 22
  • 23. X t and Yt are cointegrated if … ut  Yt    X t  ut : ~I 0, stationary process X t , Yt : ~I 1 *This is a special version of general cointegration for I(1) 23
  • 24. Example of cointegrated time series Yt  50  0.5 X t  ut Xt : -------- X t : 100  2  Normal brownian motion Yt : -------- ut : 3  Gaussian noise 24
  • 25. Example of cointegrated time series Plot : ut = Yt – 0.5 Xt 25
  • 26. ut seems to be… Stationary & Mean reversion 26
  • 27. Question Can we apply this idea to trading strategy? 27
  • 28. 3. Idea of pair trading based on cointegration 28
  • 29. Geometric brownian motion The most widely used model of stock price dSt  dt  dWt St St : Stock price  : Average return  : Volatility Wt : Brownian motion 29
  • 30. From Ito’s lemma   2  d log St       dt  dWt   2  Log price follow Brownian motion 30
  • 31. Brownian motion(log price) is … I(1) * Random walk can be considered as discretization of Brownian motion 31
  • 32. Then, we can apply Cointegration idea to log stock price 32
  • 33. Log price spread(*) is… Stationary & Mean reversion ※Spreadt : logYt      log X t , X t , Yt : stock price 33
  • 34. Simple trading idea if Spread t  very hish : Buy X t ,Sell Yt if Spread t  very low : Buy Yt ,Sell X t Spread t  log Yt      log  X t  X t , Yt : stock price 34
  • 35. 4. Simulation by R language 35
  • 36. Process 1. Find two likely cointegrated stocks 2. Estimate spreads 3. Check stationarity 4. Create trading signal 5. Run back-test 36
  • 37. 1.Find two likely cointegrated stocks > library(PairTrading) > #load sample stock price data > data(stock.price) > #select 2 stocks > price.pair <- stock.price[,1:2]["2008-12-31::"] > head(price.pair) 7201 7203 2009-01-05 333 3010 2009-01-06 341 3050 2009-01-07 374 3200 2009-01-08 361 3140 * Just load sample data in this case…. 37
  • 38. 2. Estimate spreads > reg <- EstimateParameters(price.pair, method = lm) > str(reg) List of 3 $ spread :An ‘xts’ object from 2008-12-30 to 2011-08-05 containing: Data: num [1:635, 1] -0.08544 -0.0539 -0.04306 -0.00426 -0.01966 ... - attr(*, "dimnames")=List of 2 ..$ : NULL ..$ : chr "B" Indexed by objects of class: [Date] TZ: xts Attributes: NULL $ hedge.ratio: num 0.0997 $ premium : num 7.48 38
  • 39. 2. Estimate spreads > plot(reg$spread, main = "Spread“) Spreadt  logYt      log X t , X t , Yt : stock price 39
  • 40. 3. Check stationarity > PP.test(as.numeric(reg$spread)) Phillips-Perron Unit Root Test data: as.numeric(reg$spread) Dickey-Fuller = -3.2299, Truncation lag parameter = 6, p-value = 0.08278 > adf.test(as.numeric(reg$spread)) Augmented Dickey-Fuller Test data: as.numeric(reg$spread) Dickey-Fuller = -3.6462, Lag order = 8, p-value = 0.02825 alternative hypothesis: stationary 40
  • 41. 4. Create trading signal > params <- EstimateParametersHistorically(price.pair, period = 180) > signal <- Simple(params$spread, 0.05) > barplot(signal,col="blue",space = 0, border = "blue",xaxt="n",yaxt="n",xlab="",ylab="") > par(new=TRUE) > plot(params$spread, type="l", col = "red", lwd = 3, main = "Spread & Signal") 41
  • 42. 4. Create trading signal 42
  • 43. 5. Run back-test > return.pairtrading <- Return(price.pair, lag(signal), lag(params$hedge.ratio)) > plot(100 * cumprod(1 + return.pairtrading), main = "Performance of pair trading") 43
  • 46. Summary & concluding remarks • Pair trading is simple quantitative trading strategy • Cointegration is long term relation ship of time series • Idea of cointegration may give a chance to make a profit from financial market by pair trading • Next step …. – Sophisticate parameter estimation & trading rule – Make a simulation close to real 46
  • 47. Reference • Pairs trade(http://en.wikipedia.org/wiki/Pairs_trade) • Cointegration(http://en.wikipedia.org/wiki/Cointegration) • Andrew Neil Burgess, “A Computational Methodology for Modeling the Dynamics of Statistical Arbitrage” • Russell Wojcik, “Pairs Trading: A Professional Approach” • Daniel Herlemont, “Pairs trading, convergence trading, cointegration” • Paul Teetor, “Using R to Test Pairs of Securities for Cointegration”(http://quanttrader.info/public/testForCoint.html) • Ganapathy Vidyamurthy, “Pairs Trading: Quantitative Methods and Analysis “ 47