Statistical Arb/Pairs trading strategy!

getting the calculations right would be essential, but its also challenging, especially without a math expert…

the problem with trading only visually with the chart is the repainting after some time or as soon as you move the chart…

On the charts some pairs are definitely worse than others. If you compare the UK Crude Oil to the CADUSD (Inversion of USDCAD) then you get quite a nice example of a very well behaved chart. If you zoom all the way out and then begin to go back in time they don’t really change much. Their relative position pretty much stays the same at all times. But still, some numbers to back the validity of this relationship up would be very nice indeed. So far standardizing large series of 1m candles is the furthest we’ve come.

without calculating cointegration that might be the next best thing…standardizing really large data series…

I’m super excited to release an excel worksheet I’ve been working on. Just had to learn macros really quick lol. It will allow you to input a large data set of two currencies, standardize them and then automatically pull Fx data from the web as to continually update the sheet. Also as it inputs new data it does a thing where the first number in the series gets erased, all data moves up one cell and the new price is put in the last cell. It will allow the number of data entries to remain the same while allowing for a constant update. That way you can get your buy and sell signals automatically as all you have to do is watch the chart and not worry about constantly adding to it.

It’s not perfected yet but close. As soon as I’m finished I will upload a copy.

2 Likes

great, kelton…i still try to find a way to calculate cointegration in excel…not as easy as i hoped, but i don’t give up…as soon as i succeed i will tell you…

hi guys
i think i found something quite interesting this week…

on this homepage https://www.quantinsti.com/blog/augmented-dickey-fuller-adf-test-for-a-pairs-trading-strategy/ someone describes how to perfom an ADF test (at least that’s what he says) in excel…it’s basically two linear regressions…and it’s quite easy…

and here you can download an add-in for excel with a lot of statistical functions…it also provides an ADF test (in “Time S” -> “Testing”)…
http://www.real-statistics.com/free-download/real-statistics-resource-pack/
for using the ADF test of the package you have to perform a regression on the pairs you chose and then do the ADF test on the residuals of the regression (as described here: https://www.quora.com/How-does-one-do-a-cointegration-test-in-Excel)
i read about this 2-step method in various forums…

unfortunately i could not find a Johansen Test for excel up to now…a lot of people write that this would be the best test for pairs trading…

mike

hi guys,

anyone still working/thinking about this?

how many data would you think necessary for testing for cointegration?
remember i use 1h data, so i started with 6000 hours that is about 1 year (only business days, ~250 days/year).

Hi,
Even though we don’t yet have any real numbers backing up the trades and setups, we decided (since it had worked well on trial period) to use the stat arb on our main account. So for it hasn’t produced a single loss, and it has made quite a few pips. I have been continuously researching for the last couple of months, but haven’t yet been able to find anything conclusive, the only thing I have found are people saying cointegration doesn’t exist in Forex since the markets by nature are trending.
I think you are right (Mike) in choosing around a year’s worth of data. That should be plenty to determine if the two series are cointegrated or not.
Btw, I found this (Link below) excel model, which is something I had planned on building myself, but couldn’t just figure out exactly how to. I have tried to feed it with 5min data from AUDUSD and NZDUSD (a stat arb pair that works really well) but it didn’t output any result. One of you guys may figure it out.

hi jens,

i also found that link some time ago…and i have to admit that i didn’t figure out how to use it…it seems that it only works with the data that is already saved in the file…

why wouldn’t cointegration exist in forex…forex is said to trend only 20% of the time and trade in sideway ranges about 80% of the time (although it’s always smart to be cautionary with general statements about percentages).

i think i will stick with one year’s worth of data, as i noticed that using more data in the end more and more time series become cointegrated (remember i trade every combination of the 8 major currencies = 28 pairs = 378 total combinations)…6000h of data ~30 cointegrated pairs, 8000h of data ~45 cointegrated pairs, 10000h of data ~80 cointegrated pairs…

would be interesting if kelton found out something about the topic, but it seems that he stopped researching…

Well…
I mean I of course don’t know for sure, and this is a long time ago, but these people on the thread linked below seem to know what they are talking about, and they couldn’t get cointegration based synthetic hedges to work because of faulty cointegration, so I assume they’re right. I’ve been thinking about stitching chart data together to get a complete Stat Arb chart, that doesn’t shift when you scroll left or right, and then try to determine what makes the different pairs ‘slip’. When I get around to doing it I’ll post it here.

Link to Synthetic Hedges and stuff…
https://www.forexfactory.com/showthread.php?t=262827

i already know this thread…but i think what they tried was a bit different…from what i understand they wanted to construct a basket of pairs that should be all cointegrated to trade them all together…i only look for trades with two cointegrated pairs, no basket…more like what kelton originally did using correlation…
what i already saw is that many cointegrated pairs are not correlated or at least not at the necessary level kelton needed for his trades…and until now all trades went well for me…what i observed is that correlation brakes up much faster and more often than cointegration, so this should give one much safer trades…but of course, it’s not as riskless as real arbitrage…

Well yeah, what they were trying to accomplish with their baskets is not the same, but the principle behind it is. Looking for cointegration is the right thing to do, correlation by itself doesn’t really do us any good, and if the series isn’t stationery it doesn’t apply at all. But if cointegration could be set up in excel or google sheets, an algorithm could easily be created that automatically enters trades, and backtests the strategy.

i already posted links where it’s explained how to do it in excel…i have never worked with google sheets, so i can’t say anything about that.

hi jens,

are you still trading 15min timeframe?
how many time do you have to check your open trades?

as you might remember, i mainly trade the 1h TF…if i check once a day it’s more than enough, even every other day might be enough…so i hold my trades a lot longer than you do with yours…just curious how many trades you have open at the same time and for how long…

I don’t even check the trades that often. I can once in a while check the P/L on my phone and exit if it has reached a level I am satisfied with. Once I am on my computer I check maybe once a day how the chart is looking to see where I stand with regards to any possible slip. The amount of time a trade is open varies quite a lot. On average it is probably a couple of days, maybe 3-5,but they can be both intraday and take several weeks. Depending on how much other trading takes place on the account I may open several SA trades at once, I don’t want to miss any really good setups. More recently we have begun adding to the positions as the spread becomes larger (only rarely does one get get perfect entry first try) and thereby earning a lot more when the trade finally closes. We have just today closed a position on DOW JONES - NASDAQ (US30 - US Tech 100 NAS) Where the base position only made around 400 hundred dollars, but by adding to the trade several times it ended up making way more than that. By doing this you do risk a bit more, but you can also “scalp” the SA by closing the added position once they make some money and then adding later if the spread widens again.

i trade with the 1h data, so my average trade length is about 12 days right now.

that’s what i am also doing…there are so many opportunities (before the spread nears zero) which i don’t want to miss. with the correct position sizes you can manage the risk quite well.

seems that Kelton is out of the thread again…does anyone know what happened to his excel-project?

another question i still have not decided is how much data to use for the calcs…i observed that the more data (most was 30.000h ~5 years) the more cointegrated pairs exist…the big question to me is: is it really more accurate and meaningful to years old data? or is the more recent data more useful?
I suspect that if you would use endless data nearly all pairs might become cointegrated…and o don’t think this would be useful neither. what do you think?

The guys that did the cointegrated forex basket trading would regularly run cointegration tests seeing that the relationship between the series/pairs is ever changing. In your case, you probably only need to run the test over a half or whole year, and then just update it every month or so. I guess it depends on what ‘feel’ you get when watching the chart that you usually trade SA with. You might be able to sense when it moves in and out of being properly cointegrated. Do you have any of your previous trades logged in excel og google sheets? If so I would be very interested in seeing it to get a feel for how well it works trading SA on 1h charts. I have done so for 2018 in sheets and would happily share it with you, if you just drop your mail either here or in a DM/PM.
BTW what’s the biggest you’ve ever had a SA trade go against you? I still haven’t figured out when to stop a trade going against me and looking at that 3k loss isn’t all that fun, so I’m trying to figure something out there as well.

Yes, statistical arbitrage works for FOREX, but it uses completely different principles and patterns, in contrast to similar strategies that use correlation.

Many tests have been done to exploit the correlation and convergence on which these FOREX strategies are based. This strategy will certainly lead to losses and very large ones. Or you will find yourself in a long-term capital drawdown, which ultimately will lead to the loss of your deposit.

In the FOREX market, you can use a statistical arbitrage strategy (buy and sell two currencies at the same time), but you need to use completely different principles and select other currency pairs (not exotic).