Anda di halaman 1dari 16

Pairs Trading Strategy for

BANKNIFTY
Amber Gupta
Mukund Khatod
What Is Pairs trading
Pairs Trading is a market-neutral trading strategy consisting
of a long position in one security and a short position in
another security in a predetermined ratio
Pairs trading seeks to identify stocks whereby some form of
relative pricing measure can be approximated by a long-run
equilibrium relationship.
What Is Pairs trading
Choose a pair of stocks that move together very closely,
based on a certain criteria (i.e. SBI and Axis)
Wait until the prices diverge beyond a certain threshold, then
short the winner and buy the loser
Reverse your positions when the two prices converge -->
Profit from the reversal in trend
Finding the Right Pair
The two stocks must have similar systematic risk : Hence
same sector
Co-integration approach
If there exists a relationship between two non-stationary I(1)
series, Y and X , such that the residuals of the regression

Yt 0 1 X t ut

are stationary, then the variables in question are said to be


cointegrated.
Application to Pairs Trading
If we have two stocks, X & Y, that are cointegrated in their
price movements, then any divergence in the spread from 0
should be temporary and mean-reverting.

Spread

time
Finding Cointegrated Pairs
Engle and Granger Test:

1. Calculate returns for all the possible pairs


2. Regress one bank stock over the remaining bank stocks
3. Calculate its residual
4. Apply the ADF test on residual
5. Pick the pair based on the highest ADF value
Finding Cointegrated Pairs
Used data from 2010 to 2015 to find cointegrated pairs

Stocks considered
Axis, Bank of baroda, Bank of India, Canara, Federal, HDFC , ICICI , SBI , INDUS ,
Kotak , PNB , YES
Use EGCM Package in R & Confirmation through running regression and performing
EG test
Result only SBI and AXIS were found to be co-integrated using Adjusted closing prices
using sample period from 2010 to 2015

Augmented Dickey-Fuller Test


Dickey-Fuller = -4.1799, Lag order = 10, p-value = 0.01
alternative hypothesis: stationary
Cointegrated Pair: Axis and SBI

Using Rolling regression with 50 day window


Spread=Sbi-beta*axis
Z value= Spread-Average/Std
Trading Rules
Pair trade (-A,B) or (A, -B)
Open the pair trade if when Z value hits the 2 STD barrier
Close trade when Z value hits 1 STD
Trading Rules
Trading Rules
Result
Using 50 day period for calculation of Beta we get one tradin
g signal in our sample period
Profit=155.092 using one share of SBI
Using 30 day period for calculation of Beta we get two tradin
g signals in our sample period
Profit=266.6552 using one share of SBI
Scope for further study
Using Kalman Filter instead of Rolling regression
Using Intraday data for same pair of stocks
Using Basket of Stocks instead of just 1 pair
reg=rollSFM(sbin,axisn,30)
> beta=reg$beta
> nrow(beta)
[1] 366
> beta=beta[30:366,]
> sbif=sbin[30:366,]
> axisf=axisn[30:366,]
> spread=sbif-beta*axisf
> avg=mean(spread)
> std=sd(spread)
> z=(spread-avg)/std
> plot(spread,main= "SBI vs AXIS spread with rollreg=30")
> abline(h=avg,col="red",lwd=2)
> abline(h=avg+ 2*std ,col="blue",lwd=2)
> abline(h=avg- 2*std ,col="blue",lwd=2)
> abline(h=avg+ 1*std ,col="green",lwd=2)
> abline(h=avg- 1*std ,col="green",lwd=2)
>
library(ggplot2)
> zfor=fortify(z) + > for(i in 1:337){
> zfor=zfor[,-1]
> axisadj=axisf*beta + if(zfor[i] >(2) && k==0){>
> axisadj=fortify(axisadj) >k
> axisadj=axisadj[,-1] [1] 0
> sbifor=fortify(sbif) > for(i in 1:337){
> sbifor=sbifor[,-1] + if(zfor[i] >(2) && k==0){
> pfv=0 + pfv=pfv-axisadj[i]+sbifor[i]
k=0 + k=1
+
> for(i in 1:337) +}
+ { if(zfor[i] <(-2) && k==0){ + if(zfor[i]<(1) && k==1){
+ pfv=pfv+axisadj[i]-sbifor[i] + pfv=pfv-sbifor[i]+axisadj[i]
+ k=1 + k=0
+ +}
+} +}
+ if(zfor[i]>(-1) && k==1){ > pfv
+ pfv=pfv+sbifor[i]-axisadj[i] [1] 266.6552
+ k=0
+}
+}
> pfv
[1] 128.2047
Thank You

Anda mungkin juga menyukai