Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
PHI 1 – Unified Algorithmic Trading
Sets you free to think markets. Propels you beyond the status quo.
Statistical Arbitrage
#Correlation Check
self.corr, self.p_value = pearsonr(self.datas[0].close.array,
self.datas[1].close.array)
Logs('Pearsons correlation coefficient: %.3f' % self.corr)
Correlation
Correlation
Stationarity
Stationarity
Statistical Arbitrage`
#Stationarity Check
X = sm.add_constant(list(self.datas[1].close.array))
model = sm.OLS(list(self.datas[0].close.array),X, hasconst=True)
self.val = model.fit()
self.adfuller = adfuller(self.val.resid)
Logs('ADF Statistic: %f' % self.adfuller[0])
Logs('p-value: %f' % self.adfuller[1])
Logs('Critical Values:')
for key, value in self.adfuller[4].items():
Logs('\t%s: %.3f' % (key, value))
Statistical Arbitrage`
#Trading Logic
self.val1 = self.datas[0].close - (self.datas[1].close * self.val.params[1]) -
self.val.params[0]
self.boll = BollingerBands(self.val1, period=20, devfactor=1.5)
Statistical Arbitrage
1. Cipla and Sun Pharma
2. NestleInd and Dabur (Infy?)
3. M and M Limited and Tata Motors
4. Sbin, Indian bank/pnb
5. hdfcbank and axis, icici
More Examples
Audience Exercise
mean_p = "Mean :" +str(self.val2)
Logs(mean_p )
std_d = "Standard Deviation :"
+str(self.val3)
Logs(std_d )
def norm(self.val.resid,mean,std):
z_score = [(x - mean)/std for x in data]
return z_score
self.val5 =
norm(self.val.resid,self.val2,self.val3)
normd_s = "Normalized Series :"
+str(self.val5)
Logs(normd_s)
def mean(sample):
return sum(sample) / len(sample)
self.val2 = mean(self.val.resid)
def std_d(data):
mean = sum(data) / len(data)
# Square deviations
deviations = [(x - mean)
** 2 for x in data]
s1=sum(deviations)
s2=s1/len(data)
s3=s2 ** (1/2)
return s3
self.val3 = std_d(self.val.resid)
Bollinger Bands Parameter Tuning
Audience Exercise
if (self.val1[0] > self.boll.lines.top[0]) and (self.position.size==0):
buy(data = self.datas[1])
sell(data = self.datas[0])
if (self.val1[0] < self.boll.lines.mid[0]) and (self.position.size!=0):
square_off()
When Residual breaches the Upper Band
Audience Exercise
Dollar Neutral
Beta Neutral
Industry/Sector Neutral
Interest Rate Neutral
Oil Price Neutral
………..
Factor Neutrality
Identify all factor risks and neutralize your portfolio (We are
capturing mispricing risk only)
Caution
The strategy heavily depends on the mean reversion of prices to their historical or predicted normal. This may not happen in certain cases and the prices can continue to drift away from the historical normal.
Systematically determine when the reversion in spread is unlikely
and exit the trade
Further Reading
Practitioners
Further Reading
Academics and Educators
Further Reading
Skeptics
ALG
OR
ITH
MIC
TR
AD
ING
WO
RK
FLO
WCREATION EVALUATION / REFINEMENT DEPLOYMENT
Screening
Basic Screening
Advanced Screening
Strategy Creation
Evaluation
Bulk Backtesting
Scenario Backtesting
Grading on Scenarios
Ideabook Simulation (Paper)
Deployment
Monitoring Scaling
AVIRAL [email protected] | +91 95655 13605
GAURAV [email protected] | +91 79000 76658
WEBSITEhttps://www.phi1.io/
OFFICEPowerweave Heuristic Investment Technologies Pvt. Ltd.Plot No. 27, Road No.11, Near Tunga Hotel,Marol Industrial Area, MIDC Andheri (E), Mumbai.
LET’S TALK