# A Curious Intraday Pattern in the Brazilian stock Index Future

Since the first article of this blog (Technical Analysis for intraday stocks trading? FORGET IT!), i’m pointing to the fact that there is a lot of cross correlation between stocks and between stocks and the future index. That’s not new to anyone and even those who are starting at the quantitative trading/analysis come to realize this on their own. But, is there some way we can explore that pattern and extract some alpha?

My last post Arbitrage on cross-section returns in Brazilian stock market presents an example about how can we profit from this. The intention of this article is to show another curious pattern that was born here in the brazilian future stock index that is derived from this interaction between those markets.

For those who doesn’t know what i’m taking about, i do strongly suggest that read the previous posts for a deep understanding.

## Some basic concepts

Before explaining the curious pattern, let me explain the conditions that the future market and the stock markets have here in Brazil which led me to suppose why of such a pattern do exists. And when i said suppose is because i’m not 100% sure that the following explanation is the right one. It’s only the most plausible for me.

When we thinking in enter in the brazilian stock market, basically, we have 3 options:

1. Buy stocks (obviously). They are traded at the BOVESPA stock market.
2. Buy the IBOVESPA’S ETF. His ticker is BOVA11. Traded at BOVESPA also.
3. Buy the stock index future. His ticker is IND. Traded at the BM&F.

As explained before, these assets are traded by different peoples, looking at different reports, with different opinions (That’s the main reason why trend-following in the stock market it’s not so profitable as in commodities: there must be a consensus in the market about the direction that the the whole stock market is taking).

The stock market and the future market opens and closes at different times: Stocks and ETFs opens at 10:00 AM and closes at 05:00 PM and the futures market opens at 09:00 AM and closes at 18:00 PM, as you can see in the picture down here:

## The birth of a different pattern

Well, as they are the same thing, stocks, Index ETF and Future Stock Index have to trade at a same level. If they don’t, anyone can profit from a simple arbitrage stategy. But, the future stock index spend 2 hours more trading than the other. That mean that only the players that do trade at him will incorporate the newsflow to the price. If a very relevant company announces it results, the future stock will be the first proxy of how the market reacted to this. The key point here is: Do the Stocks traders agree with the overall change that future stocks had overnight?

That fact allow us to create at least three hypothetical scenarios:

1. The Stock market will agree with the overnight change on the price and converge to the Future Stock Index when they open (10:00 AM). In this scenario the stocks tends to converge to the Future Index and it will stay wherever it is. So we can profit buying/selling any stock that open bellow/above the index variation.
2. Half of the days they will agree, half they won’t. So, in 50% of the days the Index will converge to the stocks, 50% the stocks will converge to the index. In this scenario, we can’t make profit because we can’t suppose who is going where.
3. The Stock market will not agree and will stay closer to where it closed on the last day then on the Future Index. So, the Future Index will be forced to converge to the Stocks prices. In this scenario, we sell/buy the Future Index if they go up/down at the open at the stock market and waits it goes down/up.

## The Data

As the previous articles, to test those hypothesis, i’ll be using only the IND serie that can be found on the official FTP provided by the BM&F. I created a continuos series, adding the roll returns (same method used by Bloomberg). The data here vary from 22/12/2014 to 31/05/2016. All the data was stored in a local MongoDB server, acessed via Python by a excellent API called Arctic.

## Statistical Testing and Results

To test which of those scenarios is was what prevailed in the dataset, i’ll try to fit the following linear model in the data i have:

$\textbf{y=}\boldsymbol{\alpha}\textbf{.x+}\boldsymbol{\beta}$

Where will be today’s return of the stock index between 10:00 AM and 10:30 AM and will be the return from yesterday’s close ’till today’s stock market open. That means we are trying to find some form of predictive power in the overnight’s change on the firsts minutes when both markets are open.

We begin collecting the data from our server and storing into a Pandas DataFrame called ind.

store = Arctic('localhost')
lib = store['OMR']  # Acessing the Library where the index data will be
ind = lib.read('data').data  # Storing the index data 

If we plot the index serie, we’ll see that it is perfect:

After that, we can create both and DataFrames. By this, we begin slicing our data in the desired times:

time1 = datetime.time(10, 0)
time2 = datetime.time(10, 30)
aux_ind = ind.index.time

# Slice the data in the desired times

# And get the last price of the day
lasts = ind.groupby('data_').last().copy()

With that done, we can create our X and Y vectors. I used the absolute returns insted of percentual changes.

ret1 = open_trade.shift(-1) - lasts
ret2 = ret2.iloc[1:]

We can then make a scatter plot:

A first glance tells us that there is a certain relationship between the data. We can mesure this using the linregress function from scipy library.

from scipy.stats import linregress
linregress(ret1.iloc[:-1].close, ret2.close)

What results:

LinregressResult(slope=-0.12893318214562502, intercept=-3.7789479936766783, rvalue=-0.25846893596511661, pvalue=9.1634252170004753e-07, stderr=0.025794645132302303)

What this output is telling us is that the calculated value for slope in our model is negative and equals to -0.1289 and it is statistically different from zero (as we can see interpreting that pretty low pvalue).

## How can we interpret this?

A negative slope means that there is a negative relation between the return of yesterday’s close and todays open (X) and the return of today’s 10:30 AM with today’s open. So, we can conclude that the hypothesis 3 is the correct and can create a trading system that sells/buy the index if they go up/down at the open at the stock market and rebuys/resells 10:30 AM.

But, is 10:30 AM the best hour to close our trade? Is there any kind of filter we can put in the strategy? There is some better form to operate this? This patterns cover the coasts? Obviously, all that questions need to be answered before trading this system, but, we got another alpha here. I intend to exploid more this results in the next articles.

## 8 thoughts on “A Curious Intraday Pattern in the Brazilian stock Index Future”

1. Nice to see someone here in Brazil up on Quantocracy!
Keep up the good posts!

Abracos

Bom dia, Eduardo!
Bom saber que também há brasileiros lendo o QuantoCracy.
Fico decepcionado quando vejo uma gama gigantesca de traders brasileiros discutindo estratégias ridículos como as do forum do Portal do Trader, sem nenhum compromisso com a segurança estatística dos backtests que fazem.

Nosso mercado ainda tem muito pra crescer.
Seja bem vindo ao blog. Qualquer sugestão de artigo vai ser muito bem vinda.

1. Boa tarde, Rodrigo!

Acredito que nós sejamos muito poucos, infelizmente.. hahah (que acessam o QuantoCracy)
Nacionalmente, a galera prefere discutir “analise grafica” e olhe lá. Se alguém se der ao trabalho de fazer um backtest e saber o que é curve fitting, In sample, Out of sample, eu já bato palmas!
A galera que sabe o que faz normalmente não fala muito por aí, até aonde eu sei, mas até porque NÃO tem aonde falar. Diferente de lá fora.

Fico no aguardo dos próximos posts e qualquer coisa, pode pedir pitaco também. Essa parte aí é muito interessante, de sazonalidade intraday pra trading, ainda mais usando os horários diferentes de aberturas e fechamentos. (Inclusive, nunca testei, mas deve dar pra usar um proxy dos mercados offshore (que abrem antes do nosso) pra ter um input do nosso).

O que mais sinto falta aqui é uma API aberta para se linkar plataformas, tipo uma IB lá fora, todas as plataformas tem uma API pra IB.

2. I see your site needs some unique content. Writing manually
is time consuming, but there is solution for this. Just search for – Masquro’s strategies