Cointegration and mean-reversion

Sell the highs, buy the lows, take their money, bash their nose.
User avatar
jungle
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by jungle »

hi crowlogic



i have a couple of questions.  if you are trying to leg the spread, doesn't this say something about the efficacy of the system, i.e. it isn't profitable after costs if you have trade at market?  also, if you are legging into the ETFs vs. the underlyings, then you are just taking outright directional risk on one side until you have the other on, which doesn't seem to be a cointegration-based trade...
it's axiomatic, deal with it.
User avatar
crowlogic
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by crowlogic »

My trading rules are showing excess profit even after accounting for worst-case commissions (no rebates for patient limit orders).



Also, right, it is temporarily directional but the trades are still generated by cointegration analysis..e.g., 6 factors move in one direction, 1 underlying/factor fails to move it shows that the underlying that didn't move is in disequilibrium.
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
User avatar
crowlogic
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by crowlogic »

OK.. I finally got it straight, I think I temporarily went insane.



I've went back to the basics and estimated a cointegrating vector by an ordinary least squares regression on the ETF as the dependent, and 7 other etfs/equities as indendent vars, this also gives me the "optimal" hedge ratios.



>> lsr=ols(data(:,1),data(:,2: Cool )

beta: 0.29399, 0.19167, 0.027305, 0.1689, 0.077172, 0.18674, -0.038626

sige: 1.9368e-07

rsqr: 0.96992

rbar: 0.96991

dw: 0.0090629



The Augmented dickey-fuller test shows that the residuals are stationary, here is a plot.



[img]http://crowlogic.biz/images/mispricing.png[/img]



Also, the vartiance ratio profile shows that the series is indeed mostly mean reverting.



[img]http://crowlogic.biz/images/vrprofile.png[/img]



I normalized the betas to calculate the optimal hedge ratio so that the sum of absolute values = 1.



>> (lsr.beta/sum(abs(lsr.beta)))'

0.29865

0.19471

0.027737

0.17158

0.078394

0.1897

-0.039238



Is that the correct way to determine offsetting portfolio weights?



When I optimize the trading rules on this I only get a few combinations that are slightly profitible after costs.



However, when I don't hedge and only take directional bets then the profits after costs are significant. How can this be?
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
User avatar
FDAXHunter
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by FDAXHunter »

[b]crowlogic:[/b] [i]When I optimize the trading rules on this I only get a few combinations that are slightly profitible after costs.[/i]



From what it looks like over here, you are now essentially doing basket arbitrage/basket trading. This is one of the most efficiently priced relationship in all of finance. There are market participants that do nothing but this, all day long. So it comes as a small surprise that you can't really make any money on it. People do this for razor thin margins nowadays.



[b]crowlogic:[/b] [i]However, when I don't hedge and only take directional bets then the profits after costs are significant. How can this be?[/i]



As you seem to be doing this on intradaily data, and from looking at the distribution of your residuals, it looks to me like you're going to be skewed to the buy side. If you look at a chart of what US equity markets did over the last 3 years, that may be the reason. Just a guess though. Does that sound like a possibility?
The Figs Protocol.
User avatar
jungle
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by jungle »

[i]However, when I don't hedge and only take directional bets then the profits after costs are significant. How can this be?[/i]



in theory, higher risk => higher reward...
it's axiomatic, deal with it.
Jaxx
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by Jaxx »

i'd be really interested in the shape of the pnl distribution - i would guess you'd have plenty of small winners - but then some really horrible negative selection and a couple of big losses - what sort of stop loss are you assuming as possible/using?
User avatar
crowlogic
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by crowlogic »

It's really hard to draw the p/l distribution because I don't fully enter and exit positions.. I scale in and out of the position as the indicator approaches the tails.



I suppose I could draw two distributions.. one showing my cash spent entering and another showing my cash gain exiting. Does anyone know of this being done before?
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
User avatar
FDAXHunter
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by FDAXHunter »

This is what pretty much every large market participant does and alot of position management is done that way (funds with a mandate to be invested to some degree X also fall under this category). In addition, option positions tend to behave exactly like this.



You can still generate a P/L distribution in a few ways. One is to see where you print a Profit (or Loss) when the sign of your exposure changes.

Another way to calculate it is to see how much cash is entering or leaving your cash account.



Both of those are not really the way to go.

A more appropriate way is a distribution of marked-to-market P/Ls (closed trades can significantly distort the real picture that is going on under the covers).

For every time slice that you are tracking, calculate the total value of your portfolio (cash + marked-to-marked position).

Then calculate returns for one time slice to the next.

Generate distribution for those returns.

Done.



Hope this helps.
The Figs Protocol.
User avatar
crowlogic
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by crowlogic »

Ahh, I don't know why I didn't just think of that. Sleep deprived.



At every instant I calculate the liquidation value based on current market prices, which I suppose is the mark-to-market value.



Give me a few minutes and I'll post one up..
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
User avatar
crowlogic
Posts: 0
Joined: Thu Jan 01, 2004 12:00 am

Cointegration and mean-reversion

Post by crowlogic »

The liquidation value never drops below initial cash.. but nor does it go very high either even after trading quite a few shares so this basically confirms the results are stable and the market for this ETF is effecient.



Here is a pure ETF arb strategy intraday..the PL graph does not include fees assed during the day because they do not cut into buying power.. they are assed at T+1. Mark-to-market is based on bid/ask prices depending on the position and I have quick execution so it looks reasonable. 3:1 buying power is used.



EOD fees were Fees=$190.35 with the final liquidation value of $196.



$6 profit from 24000 shares traded. Suffice it to say, that QQQQ is very efficient.



Optimizing for other smoothing strategies brings a max profit of $55.



Good thing is that this confirms my hunch.. now I can go searching for other baskets to trade instead of index arb.

[img]/User%20Files/1210/markToMarket25KCashPL.png[/img]
One should respect public opinion insofar as is necessary to avoid starvation and keep out of prison, but anything that goes beyond this is voluntary submission to an unnecessary tyranny. --Bertrand Russell
Post Reply