Index | Recent Threads | Who's Online | Search

New Thread
This topic has been viewed 297 times and has 9 replies
Jrinne
Some Serious Mean-Reversion?

So I used this code below to download the returns of TLT and SPY.

I took the weekly mean (of TLT and SPY) and calculated the excess returns of SPY for each week. I then did a simple regression of the excess 3 week returns, as the x-axis, and the following week of excess returns for the y-axis. Image below.

One of the things that is interesting is that I have real trouble acting on something like this. We do not know the closing price until the close. And we cannot act on the close until the next open (or perhaps the after-hours market).

I did not look at this data specifically but generally this type of data looks much less impressive (maybe not even significant) if you look at the next open.

I am not sure that some institutions with fiberoptic connections next to the exchanges and access to supercomputers (not to mention a lot of information on the order-flow) are as limited as I am however. Maybe they use options. Maybe they go long one asset while shorting the other (or the option equivalent). I can say that it is my experience that a lot of this gets arbitraged away by Monday morning.

One piece of data suggesting that someone may be making the market more efficient for us. I have not done the math but there is a lot that would go into arbitraging this away by Monday morning, I think. There is a lot of volume in those ETFs and the underlying assets..

Maybe I am missing something. But on first blush the regression seems impressive. And agreed. At the end of the day probably not usable. If it is usable, be my guest.


CODE:
import os
from datetime import datetime
import pandas_datareader.data as web
tlt = web.DataReader("TLT", "av-weekly", start=datetime(2002, 8, 9),end=datetime(2021, 4, 1),api_key=('My key'))
tlt_weekly_return=tlt['close'].pct_change()
tlt_weekly_return.dropna(inplace=True)
tlt_weekly_return
spy = web.DataReader("SPY", "av-weekly", start=datetime(2002, 8, 9),end=datetime(2021, 4, 1),api_key=('My key'))
spy_weekly_return=spy['close'].pct_change()
spy_weekly_return.dropna(inplace=True)
spy_weekly_return
cat1=pd.concat([tlt_weekly_return, spy_weekly_return],axis=1)
cat1.columns=['TLT','SPY']
cat1
cat1.to_csv('~/Desktop/cat1.csv')

Attachment Mean-Reversion.png (231360 bytes) (Download count: 127)


From time to time you will encounter Luddites, who are beyond redemption.
--de Prado, Marcos López on the topic of machine learning for financial applications

Apr 3, 2021 10:18:29 AM       
Edit 13 times, last edit by Jrinne at Apr 3, 2021 11:36:54 AM
simondul
Re: Some Serious Mean-Reversion?

Jim,

Arbitrage can be done using the futures markets (/ES and /MES is available for the retail investor). Everyone has access to this on Sunday at 6:00 PM EST. Same applies to the bonds - /ZN, /ZB. There can be a lot of movement in the futures after the market closes. Looks at /ES for the past couple of days between 16:00 and 16:15. Pairs trades are normally within the same asset class (/ES vs /NQ, or things like crack spread, nob spread, gold/silver ratio, etc.), but I have not seen pairs trades that cross asset classes (like index/bonds) because the correlation is so low. SPY, TLT etc. are available now 24/7, though the hours are a little different than futures. SPY, QQQ are available 20:00 EST on Sunday, I think and are sufficiently liquid, I believe. I have not traded these though out of hours as I use /ES.

Simon

Apr 4, 2021 12:15:46 PM       
Jrinne
Re: Some Serious Mean-Reversion?

Simon,

Thank you. I have been trading in a SEP-IRA and I was thinking of that. But I am not completely limited to using a SEP-IRA as you correctly point out.

I will check that out and much appreciated!!!

Also nice information about Pairs-Trading. I joined PairTradeFinder for a while and did some paper-trading (working with another P123 member through email). I played with hierarchical clustering along with the co-integration supplied by PairTradeFinder. I did not get enough experience to add anything of value to what you say unless it is to say I think it is harder than it seems from a distance and I have a lot of respect for anyone who can do it. I find your comments very interesting and thanks for sharing!

I fully understand you point about low correlation between TLT and SPY.

Jim

From time to time you will encounter Luddites, who are beyond redemption.
--de Prado, Marcos López on the topic of machine learning for financial applications

Apr 4, 2021 1:09:03 PM       
Edit 3 times, last edit by Jrinne at Apr 4, 2021 2:09:01 PM
simondul
Re: Some Serious Mean-Reversion?

The nob spread, crack spread and gold/silver ratio are the easiest to get into. There is a lot of information around on the web if you do enough digging. I keep it simple (CL/HO) but you can do 3:2:1 using CL, HO and RB. The interesting thing is there is a high correlation between the crack spread and the refiners. 6 months ago the CL/HO spread was around 8 - now its 15; take a look at VLO and MPC over the past four months to see the impact. This is not oil increase because crude is a cost to these guys. It is the crack spread that drives profits.

I do these types of trade in my "discretionary" accounts, as this more driven "macro" opinion; I find if very difficult to create these types of models.

If you're interested in pairs trading using futures, https://www.mrci.com/web/index.php is a good place to start as any. They can get pretty interesting - I only do a few but they have lots of research to support their trades. I did the gold/silver ratio last year after it hit 125 after the COVID crash (I would call it the Ackman crash, but that's another story) and went long silver/short gold. It around 50 now which is the long term average. I find these type of opportunities offset nicely the PURE mechanical (P123) systems. Plus it keeps me engaged!

What people forget when trading in futures is you have to factor in the notional value. /SI might be $25, but it is $5k/point, so the notional value is $125,000, while the margin (initial) is only $8k. This is the biggest challenge when moving into these types of products. /SI can move 10% - so that's a $12,500 per contract move. if you want to stick with stocks, things like the Nasdaq versus Russell 2k (/NQ versus /RTK) are also interesting. Finally, pairs significantly reduce volatility - this in itself allows exposure to different asset classes without taking on significant risk. That 10% move in /SI will be significantly reduced if you're also on the other side of a /GC contract.

I generally use ThinkOrSwim for my pairs setups, but also use Tasty Works. There are brokerages that allow futures and options on futures in IRAs.

This is probably a little off topic, so excuse my digression :)

Apr 4, 2021 3:15:26 PM       
Chipper6
Re: Some Serious Mean-Reversion?

Why did you pick a three week look-back period?

You can generate the signals a few minutes before the close, and trade highly liquid ETFs using limit on close orders.

Apr 6, 2021 3:37:28 PM       
Jrinne
Re: Some Serious Mean-Reversion?

Why did you pick a three week look-back period?

You can generate the signals a few minutes before the close, and trade highly liquid ETFs using limit on close orders.

Chaim,

Great question.

That is just one of the periods that I have looked at with multiple different sets of ETFs. I showed it because it was clearly significant statistically and had a large enough effect that perhaps there might be a useful trading alogorithm.

I will trade whatever works including doing exactly as you suggest (generating signals just before the close and trading on the close).

Perhaps you would agree that there are a few more things I could look at. Here is a backtest of an adaptive allocation strategy that I am looking at. Any regression on the ETFs IS NOT significant and it is just a backtest. Perhaps this is why I showed the regression (which is highly significant statistically).

I remember your comments about adaptive allocation strategies recently and I agree with all of them including your comments about the limitations of backtests.

Not sure what I will do ultimately but I DEFINITELY appreciate you ideas.

Best,

Jim

Attachment Backtest.png (228093 bytes) (Download count: 77)


From time to time you will encounter Luddites, who are beyond redemption.
--de Prado, Marcos López on the topic of machine learning for financial applications

Apr 6, 2021 4:30:14 PM       
Edit 7 times, last edit by Jrinne at Apr 7, 2021 4:54:25 AM
mmasand
Re: Some Serious Mean-Reversion?

James - What platform are you using for adaptive asset allocation?

Apr 6, 2021 7:32:43 PM       
Jrinne
Re: Some Serious Mean-Reversion?

mmasand,

I use Portfolio Visualizer. Link here: Portfolio Visualizer

Jim

From time to time you will encounter Luddites, who are beyond redemption.
--de Prado, Marcos López on the topic of machine learning for financial applications

Apr 7, 2021 4:40:57 AM       
Edit 1 times, last edit by Jrinne at Apr 7, 2021 4:45:40 AM
mmasand
Re: Some Serious Mean-Reversion?

Thanks Jim

Apr 8, 2021 1:20:56 PM       
Chipper6
Re: Some Serious Mean-Reversion?

Adaptive Asset Allocation is a great tool to reduce risk. Even the basic indicators available on Portfolio Visualizer such as momentum, mean reversion and recent volatility are somewhat predictive of future volatility.

Adaptive Asset Allocation may also be a decent tool to outperform. However there is a lot of noise in the momentum, mean reversion, and volatility signals so it's tricky to backtest properly and hard to stick to a system that's up and running.

It's really a shame that Portfolio123 does not do adaptive asset allocation yet. There are so many useful signals possible using the data already on site. I don't know why it's not being done. The market for ETFs is so much larger than the market for trading small cap value stocks.

Apr 8, 2021 5:29:48 PM