If you had to be long DAX one day per week, which one would it be?

This post wants to replicate the plots in this tweet from @Kkta90:

First some imports:

from datetime import datetime, date, time
import pickle
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

Load the data from 15 minutes bars of DAX futures continuously adjusted from 2006-2016. I cannot redistribute the data, so you will have to obtain it from your broker or data provider of choice:

with open('dax-15min-2006-2016.pkl', 'rb') as input:
    dax_15min=pickle.load(input)

Build the cumulative returns of mean 15 minutes returns for each different day of the week:

dax_15min_rets = (dax_15min.Close/dax_15min.shift(1).Close)

dax_15min_rets_monday=-1+dax_15min_rets[dax_15min_rets.index.dayofweek==0].groupby(lambda t: time(t.hour,t.minute)).aggregate(np.mean).cumprod()
dax_15min_rets_tuesday=-1+dax_15min_rets[dax_15min_rets.index.dayofweek==1].groupby(lambda t: time(t.hour,t.minute)).aggregate(np.mean).cumprod()
dax_15min_rets_wednesday=-1+dax_15min_rets[dax_15min_rets.index.dayofweek==2].groupby(lambda t: time(t.hour,t.minute)).aggregate(np.mean).cumprod()
dax_15min_rets_thrusday=-1+dax_15min_rets[dax_15min_rets.index.dayofweek==3].groupby(lambda t: time(t.hour,t.minute)).aggregate(np.mean).cumprod()
dax_15min_rets_friday=-1+dax_15min_rets[dax_15min_rets.index.dayofweek==4].groupby(lambda t: time(t.hour,t.minute)).aggregate(np.mean).cumprod()
dax_15min_rets_avg=-1+dax_15min_rets.groupby(lambda t: time(t.hour,t.minute)).aggregate(np.mean).cumprod()

And plot:

def add_subplot(id,title, rets):
    plt.subplot(2, 3, id)
    plt.plot(rets)
    plt.title(title)
    plt.xlim(time(8,15), time(22,15))
    plt.xticks([time(8,0),time(10,0),time(12,0),time(14,0),time(16,0),time(18,0),time(20,0),time(22,0)])
    plt.ylim(-0.0010, 0.0015)
    
add_subplot(1,'Monday', dax_15min_rets_monday)
add_subplot(2,'Tuesday', dax_15min_rets_tuesday)
add_subplot(3,'Wednesday', dax_15min_rets_wednesday)
add_subplot(4,'Thrusday', dax_15min_rets_thrusday)
add_subplot(5,'Friday', dax_15min_rets_friday)
add_subplot(6,'Average', dax_15min_rets_avg)
    
plt.suptitle('DAX 2006-2016')
plt.show()

This is what you get:

Note that the returns of each time series doesn’t start at 0. This is because the mean overnight gap. I found it interesting to have this information but you can always substract it as in the tweet from @Kkta90.