[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: OT - cointegration - pair trade



PureBytes Links

Trading Reference Links

Thank you for the pointers.

ADF was exactly what I was looking for as learning exercise.
I'm aware that most of the pair-trade alpha is quickly arbitarged away
and goes in a full circle in which bad performances drive away the
less sofisticacted and increase the opportunity which in turn attracts
more participants which again decrease the profit potential.

With your pointers I will start my long journey of learning the
anotomy and theory of internal combustion engine before driving a car.

best regards,
dxd

--- In amibroker@xxxxxxxxxxxxxxx, "vlanschot" <vlanschot@xxx> wrote:
>
> It's been a while since I created that, but yes, this can quite 
> easily be achieved in AB. However, since there's nothing more 
> important than to learn along the way, and find you own solutions, 
> I'll give you only a few pointers:
> 
> 1) You need to create a few OLS-regression functions. One simple 
> example is:
> 
> function OLSXYb2(x,y,Period)
> // y = dependent var
> {
> 	global RSq;
> 	
> 	SumX=Sum(x,Period);
> 	SumY=Sum(y,Period);
> 	CombSum=Sum(x*y,Period);
> 	SumSqX=Sum(x^2,period);
> 	SumXSq=Sum(x,period)^2;
> 	
> 	
> 	b2=(period*CombSum-SumX*SumY)/(period*SumSqX-SumXSq);
> 	//b2=OLS-beta
> 	Rsq=Correlation(x,y,Period)^2;
> 	
> 	return b2;
> }
> 
> Unfortunately, this only applies to 1 independent variable, and 
> you'll need to find out yourself how to expand it to 2 independent 
> variables, i.e. to regress y over x and z.
> 
> 2) You then need to calculate and further manipulate the OLS error 
> terms. One approach is to use the Augmented Dickey Fuller (ADF) stat. 
> 
> Again, a hint:
> 
> ADFResErr = OLSXY(P1, P2, LBPer);
> 			n = 0;
> 			ADFOLSErr[0]=0;
> 			while (n<LBPer)
> 			{
> 			ADFOLSErr = Ref(P2,-n)-SelectedValue(OLSb1) - 
> SelectedValue(OLSb2)*Ref(P1,-n);
> 			n = n+1;
> 			}
> 			etmin1 = Ref(ADFOLSErr,-1);
> 			etmin2 = Ref(ADFOLSErr,-2);
> 			ResChange = ADFOLSErr - etmin1;
> 			Lag1ResCh = Ref(ResChange,-1);
> 			Lag2ResCh = Ref(ResChange,-2);
> 			Cointgr = OLSXYZ(ResChange, 
> etmin1,Lag1ResCh,LBPer);
> 			tau = tvalueb3;
> . . . .
> 
> FWIW, too many investors are now looking at pair-trading via coint, 
> i.e. it has largely been arbitraged away. Most succesful hedge funds 
> use way more advanced strategies.
> 
> PS
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "john_dxd_smith" 
> <john_dxd_smith@> wrote:
> >
> > 
> > Hi,
> > 
> > I understand cointegration, not correlation, is used to rank stocks 
> to
> > find "pair trade" candidates.
> > I read a lot of papers I found googling but they are all too 
> technical
> > and way over my head.
> > 
> > I'm only interested in a very basic/primitive textbook-case approach
> > among many variants actually used by hedge funds.
> > 
> > How do I go about creating cointegration matrix ?
> > Is it doable with AmiBroker ?
> > If not, are there any statistical/math softwares for non-quants to
> > create the matrix ?
> > 
> > Thank you in advance.
> > 
> > best regards,
> > dxd
> >
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/