Hi faculties and community,
I have 2 questions regarding the course Trading Alphas.
Question 1 : section 13 unit 8 : impact of timing alpha.
I would like to understand the date which should consider for the overnight returns and if the formula is correct.
In notebook, formula are :
Timing-1: Overnight holding
plt.plot((data.Open.shift(-1)/data.Close-1).cumsum(), label='Overnight')
Timing-2: Intraday holding
plt.plot((data.Close/data.Open-1).cumsum(), label='Intraday')
Timing-3: Buy and hold
plt.plot(data.Close.pct_change().cumsum(), label='Buy and Hold')
My problem is if I pick 1 specific date, then I have a looking ahead bias for the overnight returns as I am waiting for next day Open. Should we not use instead ?
plt.plot((data.Open.shift/data.Close(1)-1).cumsum(), label='Overnight')
Question 2 :
We have in notebook : Section 12 Unit 10 : Cross-Sectional Momentum Strategy
Run cross-sectional momentum strategy backtest
mom_backtest = (((mom.rank(axis=1) == selected_rank)) * stk.Close.shift(-1))
To evaluate the strategy, should not we pick a date and then use the ranked stocks found the day before to evaluate the strategy. So backtest would be :
mom_backtest = (((mom.rank(axis=1) == selected_rank)).shift(1) * stk.Close)
As you can see I am struggling with the logic here and am interested to clarify it.
Thanks for your help.
Remi
Here is a conversation with chatGPT which recommends to use shift(1) on the selection instead of shift(-1) on returns if one wants to have the date as point of reference :
https://chatgpt-com.translate.goog/share/671e3be2-74e0-8007-b265-7ec78db112b7?_x_tr_sl=fr&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp
Let me know if this approach is wrong.
Thanks,
Remi
Hello Remi,
You have raised a valid premise, and I will get back to you on this. Thanks.
Hi Remi,
For the first query, you can either shift the position of the open price or the close price. I understand your concern and we will update the notebook.
For the second query, we are taking the data (Close) as the percentage change of prices, i.e. this is the daily returns calculated and not the price values. You can see this in the line "stk = pd.read_csv('…/data_modules/tech_stocks_2000_2022.csv', index_col=0, header=[0, 1]).pct_change()" when we import the data.
You’re using today’s closing momentum ranking to select the stock with the highest momentum without knowing the next day’s return in advance.
stk.Close.shift(-1)
represents the next day’s percentage change, which your strategy would capture by theoretically holding overnight (from today’s close to tomorrow’s close). This was the approach taken by the author.
I understand this was the reason for your confusion and I hope it makes sense now.
Hi Rekhit,
Thanks for your answer. Regarding, the second question, I still feel unconfortable to use shift(-1). For me, if I pick a date, I expect to see the returns for that specific date either the returns of the backtested strategy or the return of the benchmark.
I feel that by using shift(-1) to foresee the future returns of the stocks we create an unalignment with the dates which makes it difficult to compare the strategy returns with any other strategy. Maybe I should not use the date as the reference to compare but if I change that I might not be able to compare the backtest with other strategies' returns.
But it is a detailas that course is my all time favorite. Thanks Quantra and Dr Starke for this great content !
Kind regards,
Remi
Hello Remi,
We understand your concern and appreciate your answer. We will convey this to the author. Also, thank you for your appreciation of the course.
Let us know if there is anything else we can assist you with.