Trouble understanding the logic

Course Name: Trading with Machine Learning: Classification and SVM, Section No: 5, Unit No: 3, Unit type: Notebook

Hello!

I understand the code but it is not very clear what is the purpose behind this code? In other words what are we trying to achieve?

Df.loc[Df['Fut_Ret']>Df['Fut_Ret'][:split].quantile(q=0.66), 'Signal'] = 1

Thanks!

Hi Amit, 



We’re checking if the current returns are greater than the highest quantile returns(q=0.66) of train data, and then we’re assigning a signal = 1 or a buy signal. Basically, if the returns stored in a particular row of Df['Fut_Ret'] are greater than the highest quantile returns of train data, we’ll take a long position. 



Thanks,

Bhavika