Incorrect signals?

Course Name: Momentum Trading Strategies, Section No: 19, Unit No: 8, Unit type: Notebook



Hi there,



Can you please explain what the correct interpretation should be?



The notebook states that "You go short on contracts with the future spot ratio in the bottom two deciles. You simultaneously go long on all contracts who’s future spot ratio is in the top two deciles."



Whereas the code has the following:



def signal(rank):

        # Go short on all ranks in the upper two deciles

        signal = np.where(rank>total_ranks8/10,-1,np.nan)

        # Go long on all ranks in the lower two deciles

        signal = np.where(rank<total_ranks
2/10,+1,signal)

        return signal

signal = rank.apply(signal,axis=0)



If I am reading this correctly, the code will give a short signal (-1) where rank is above 20 i.e. top two deciles and give a long signal (1) where rank is below 5, which is the opposite of what the explanation is.



Many thanks,

Ryan

Hi Ryan,



As mentioned in the notebook, You go short on contracts with the future spot ratio in the bottom two deciles and long on contracts in the top two deciles. 



The code in the notebook for the above statement is correct. But the comments above the code are a bit confusing. 



Thank you for pointing it out. We will make the changes to the earliest.

Hi Vibhu,



Thanks for your reply but I still don't quite understand this. The rank is determined as futures/spot i.e. if futures > spot than the ratio will be greater than 1 which implies contango. Also, we have seen from the notebook that the higher the ratio, the higher the ranking. Going back to the code below, if a ranking is high e.g. above 20, the position we are taking is -1 which is a short. So what we are doing here is shorting the high ranking, contango futures and not taking a long position? Thank you.



def signal(rank):

    signal = np.where(rank>total_ranks8/10,-1,np.nan)

    signal = np.where(rank<total_ranks
2/10,+1,signal)

    return signal

Yes, you are right. We are using the future to spot ratio. Higher the ratio, more the contract is in contango, and these contracts have the highest rank. Similarly, lower the value of the future to spot ratio, more the contract is in backwardation. Such contracts have the lowest rank. Once the ranking is done, you take a position on top and bottom two deciles ranks. You go short on contracts with the future-spot ratio in the bottom two deciles, i.e. contangoed contracts. Similarly, you go long on contracts with the future-spot ratio in the top two deciles, i.e. backwardated contracts.

Can refer to this paper for more detail.

Thanks!