Hi,
I do not understand why adding 10 when slicing the returns and the treasury_ret.
running_sharpe = [sharpe_ratio(returns[i-window+10:i], treasury_ret[i-window+10:i]) for i in range(window-10, len(returns))]
because this reduces rolling period (50 -> 40, 150 -> 140 and 300 -> 290).
and I used rolling.apply function as below, but I got different result.
alfa = returns - treasury_ret
running_sharpe = alfa.rolling(40).apply(lambda x: np.mean(x)/np.std(x)) # window = 50
Could anyone help me with this?
tks.