algorithmic-trading-python
algorithmic-trading-python copied to clipboard
002_quantitative_momentum_strategy
Hi, please note that the code
hqm_dataframe.sort_values(by = 'HQM Score', ascending = False)
hqm_dataframe = hqm_dataframe[:51]
does not work as expected. You need to add inplace = True
hqm_dataframe.sort_values(by = 'HQM Score', ascending = False, inplace = True)
otherwise you are taking the fist 51 elements in alphabetical order.
PS Shouldn't you just take the first 50 elements with
hqm_dataframe = hqm_dataframe[:50]
instead of 51 (they start from 0)
It would actually require a further line as well or an error is thrown later and i found the following worked best;
hqm_dataframe.sort_values(by = 'HQM Score', ascending=False, inplace= True)
hqm_dataframe = hqm_dataframe[:51]
hqm_dataframe.reset_index(drop = True, inplace = True)